(body: unknown, ip: string)
| 92 | export type TrackResponse = { deviceId: string; sessionId: string }; |
| 93 | |
| 94 | export async function track(body: unknown, ip: string): Promise<TrackResponse> { |
| 95 | const res = await fetch(`${API_URL}/track`, { |
| 96 | method: 'POST', |
| 97 | headers: { |
| 98 | 'content-type': 'application/json', |
| 99 | 'openpanel-client-id': CLIENT_ID, |
| 100 | 'user-agent': UA, |
| 101 | 'x-client-ip': ip, |
| 102 | }, |
| 103 | body: JSON.stringify(body), |
| 104 | }); |
| 105 | if (!res.ok) { |
| 106 | throw new Error(`POST /track ${res.status}: ${await res.text()}`); |
| 107 | } |
| 108 | return (await res.json()) as TrackResponse; |
| 109 | } |
| 110 | |
| 111 | export const screenView = ( |
| 112 | ip: string, |
no test coverage detected