(
event: string,
properties: object,
includeDeviceId: boolean = true,
)
| 104 | |
| 105 | /** Generic event handling via dp-server kpis endpoint, e.g. billing events */ |
| 106 | const asyncDPTrackEvent = async ( |
| 107 | event: string, |
| 108 | properties: object, |
| 109 | includeDeviceId: boolean = true, |
| 110 | ) => { |
| 111 | try { |
| 112 | // create the payload |
| 113 | const payload: { |
| 114 | event: string; |
| 115 | unique_id?: string; |
| 116 | properties: object; |
| 117 | } = { event: event, properties: properties }; |
| 118 | if (includeDeviceId) { |
| 119 | payload.unique_id = await getDeviceId(); |
| 120 | } |
| 121 | |
| 122 | window.navigator.sendBeacon(KPIS_ENDPOINT, JSON.stringify(payload)); |
| 123 | } catch (e) { |
| 124 | console.error("An event error occurred", e); |
| 125 | } |
| 126 | }; |
| 127 | |
| 128 | /** Used for tracking usage for billing and for PostHog analytics */ |
| 129 | export const trackReportView = (properties: ReportViewPayload) => { |
no test coverage detected