export type Event = {session_id?: (string | null) | undefined, event_name?: (string | null) | undefined, properties?: ({[key: string]: unknown} | null) | undefined}; export type CreateApiDevicesIdTrackArgs = {id: string, body: Event}; export type CreateApiDevicesIdTrackOptions = {baseUrl?: string | undefined, Bearer?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create an event associated with a device. * * POST /devices/{id}/track * * Also accepts auth: ApiKeyInHeader, ApiKeyInQuery */ export const createApiDevicesIdTrack = async (args: CreateApiDevicesIdTrackArgs, options?: CreateApiDevicesIdTrackOptions) => { const {baseUrl = "https://api.reveldigital.com", fetch: fetchFn = fetch, Bearer} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") if (Bearer !== undefined) headers.set('authorization', `Bearer ${Bearer}`) const url = `${baseUrl.replace(/\/+$/, '')}/devices/${encodeURIComponent(String(args.id))}/track${query.size > 0 ? `?${query}` : ''}` const res = await fetchFn(url, {method: "POST", headers, body: JSON.stringify(args.body)}) if (!res.ok) throw new Error(`Request failed with status ${res.status}`, {cause: {status: res.status, body: await res.text()}}) return undefined };