export type CustomEvent = {eventId?: string | undefined, identifyId: string, propertyKey: string, date?: number | undefined, eventType?: string | undefined, sessionId?: string | undefined, userType: 'LEAD' | 'USER' | 'VISITOR' | 'EMPTY_USER_TYPE', accountId?: string | undefined, globalContext?: Record | undefined, eventName: string, attributes?: Record | undefined, url?: string | undefined, referrer?: string | undefined, remoteHost?: string | undefined}; export type CreateApiV1EventsCustomArgs = {body: CustomEvent}; export type CreateApiV1EventsCustomOptions = {baseUrl?: string | undefined, fetch?: typeof fetch | undefined}; /** * Create custom event * * POST /v1/events/custom */ export const createApiV1EventsCustom = async (args: CreateApiV1EventsCustomArgs, options?: CreateApiV1EventsCustomOptions) => { const {baseUrl = "https://app.aptrinsic.com", fetch: fetchFn = fetch} = options ?? {} const query = new URLSearchParams() const headers = new Headers() headers.set('content-type', "application/json") headers.set('accept', "*/*") const url = `${baseUrl.replace(/\/+$/, '')}/v1/events/custom${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 res.blob() };