OpenPanel is an open-source web and product analytics platform, an open-source alternative to Mixpanel with optional self-hosting.
fix(sdk): add timestamp when queueing events
Carl-Gerhard Lindesvärdf2c414b4b472
diff --git a/packages/sdks/sdk/src/index.ts b/packages/sdks/sdk/src/index.tsindex 6a56d2f0c..d6b834f9c 100644--- a/packages/sdks/sdk/src/index.ts+++ b/packages/sdks/sdk/src/index.ts@@ -95,13 +95,24 @@ export class OpenPanel {return false;}+ addQueue(payload: TrackHandlerPayload) {+ if (payload.type === 'track') {+ payload.payload.properties = {+ ...(payload.payload.properties ?? {}),+ __timestamp: new Date().toISOString(),+ };+ }++ this.queue.push(payload);+ }+async send(payload: TrackHandlerPayload) {if (this.options.filter && !this.options.filter(payload)) {return Promise.resolve();}if (this.shouldQueue(payload)) {- this.queue.push(payload);+ this.addQueue(payload);return Promise.resolve();}