MCPcopy Create free account
hub / github.com/datapane/datapane / asyncDPTrackEvent

Function asyncDPTrackEvent

web-components/shared/dp-track.ts:106–126  ·  view source on GitHub ↗
(
    event: string,
    properties: object,
    includeDeviceId: boolean = true,
)

Source from the content-addressed store, hash-verified

104
105/** Generic event handling via dp-server kpis endpoint, e.g. billing events */
106const 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 */
129export const trackReportView = (properties: ReportViewPayload) => {

Callers 1

trackLocalReportViewFunction · 0.85

Calls 3

getDeviceIdFunction · 0.85
stringifyMethod · 0.80
errorMethod · 0.80

Tested by

no test coverage detected