@qurvo/sdk-browser 0.0.13 → 0.0.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1,29 +1,163 @@
1
+ /**
2
+ * Configuration for the browser SDK.
3
+ *
4
+ * Only `apiKey` is required. All other fields have sensible defaults:
5
+ * endpoint defaults to `http://localhost:3001`, autocapture is enabled,
6
+ * and flush occurs every 3 s or 10 events (whichever comes first).
7
+ */
1
8
  export interface BrowserSdkConfig {
9
+ /** Project API key used to authenticate events with the ingest server. */
2
10
  apiKey: string;
11
+ /** Ingest server URL. Defaults to `http://localhost:3001`. */
3
12
  endpoint?: string;
4
13
  /** If known upfront (e.g. Telegram Mini App), pass user ID to avoid identity gaps and namespace storage per user. */
5
14
  distinctId?: string;
15
+ /** Enable automatic pageview tracking on navigation (pushState, popstate, hashchange). Defaults to `true`. */
6
16
  autocapture?: boolean;
17
+ /** Milliseconds between automatic queue flushes. Defaults to `3000`. */
7
18
  flushInterval?: number;
19
+ /** Maximum number of events buffered before an automatic flush. Defaults to `10`. */
8
20
  flushSize?: number;
9
21
  }
22
+ /**
23
+ * Browser SDK singleton that captures events, manages user identity, and
24
+ * persists an offline queue in localStorage.
25
+ *
26
+ * Lifecycle: call {@link QurvoBrowser.init | init()} once with your API key.
27
+ * The SDK generates an anonymous ID on first visit, stores it in localStorage,
28
+ * and upgrades to a known identity when {@link QurvoBrowser.identify | identify()}
29
+ * is called. Autocapture hooks into `pushState`, `popstate`, and `hashchange`
30
+ * to track pageviews automatically.
31
+ */
10
32
  declare class QurvoBrowser {
11
33
  private queue;
12
34
  private userId;
13
35
  private initialized;
36
+ /** Debounce: last page() URL + timestamp to suppress duplicate $pageview */
37
+ private lastPageUrl;
38
+ private lastPageTime;
39
+ /** Flag: $pageleave already emitted for current page, reset on new page() */
40
+ private pageLeaveEmitted;
41
+ /** Stored listener references for cleanup in shutdown() */
42
+ private listeners;
43
+ /** Original history methods saved for restore in shutdown() */
44
+ private originalPushState;
45
+ private originalReplaceState;
46
+ /**
47
+ * Initialize the SDK with the given configuration.
48
+ *
49
+ * Resolves `distinct_id` in priority order: explicit `config.distinctId` →
50
+ * previously stored userId in localStorage → auto-generated anonymous ID.
51
+ * Sets up a localStorage-backed event queue (namespaced per user when
52
+ * `distinctId` is provided), starts the flush timer, enables autocapture
53
+ * (unless opted out), and emits an initial `$pageview`.
54
+ *
55
+ * Calling `init()` a second time is a no-op unless `config.distinctId`
56
+ * differs from the current user, in which case the SDK resets identity
57
+ * and re-initializes to prevent cross-user event linkage.
58
+ *
59
+ * @param config - SDK configuration (only `apiKey` is required).
60
+ */
14
61
  init(config: BrowserSdkConfig): void;
62
+ /**
63
+ * Send a custom event.
64
+ *
65
+ * UTM parameters from the current URL are automatically merged into
66
+ * `properties`; explicitly provided properties take priority over UTM values.
67
+ * Requires {@link QurvoBrowser.init | init()} to have been called first.
68
+ *
69
+ * @param event - Event name (e.g. `"signup"`, `"purchase"`).
70
+ * @param properties - Arbitrary key/value pairs attached to the event.
71
+ */
15
72
  track(event: string, properties?: Record<string, unknown>): void;
73
+ /**
74
+ * Link the current anonymous session to a known user.
75
+ *
76
+ * Stores `userId` in localStorage and sends a `$identify` event that
77
+ * carries the current `anonymous_id`, allowing the server to merge
78
+ * pre-identify anonymous events with the identified user profile.
79
+ *
80
+ * If the user was already identified as a *different* user, the SDK
81
+ * automatically calls {@link QurvoBrowser.reset | reset()} first to
82
+ * prevent cross-user identity linkage.
83
+ *
84
+ * @param userId - Your application's stable user identifier.
85
+ * @param userProperties - Optional user-level properties (e.g. name, plan).
86
+ */
16
87
  identify(userId: string, userProperties?: Record<string, unknown>): void;
88
+ /**
89
+ * Track a pageview (`$pageview` event).
90
+ *
91
+ * Applies a 50 ms debounce on the same URL to suppress duplicate events
92
+ * caused by `pushState` and `popstate` firing in quick succession. Also
93
+ * resets the `$pageleave` flag so a fresh leave event can be emitted when
94
+ * the user navigates away from this page.
95
+ *
96
+ * Called automatically on navigation when `autocapture` is enabled.
97
+ *
98
+ * @param properties - Extra properties to attach to the pageview event.
99
+ */
17
100
  page(properties?: Record<string, unknown>): void;
101
+ /**
102
+ * Track a screen view (`$screen` event).
103
+ *
104
+ * Intended for non-web contexts (e.g. React Native, Telegram Mini Apps)
105
+ * where navigation doesn't map to browser URLs. Sends `$screen_name`
106
+ * inside the event properties.
107
+ *
108
+ * @param screenName - Logical screen name (e.g. `"Settings"`, `"Profile"`).
109
+ * @param properties - Extra properties to attach to the screen event.
110
+ */
18
111
  screen(screenName: string, properties?: Record<string, unknown>): void;
112
+ /**
113
+ * Set user properties on the current user (`$set` event).
114
+ *
115
+ * Properties are always overwritten with the provided values.
116
+ * Use {@link QurvoBrowser.setOnce | setOnce()} to write only if
117
+ * the property has not been set before.
118
+ *
119
+ * @param properties - Key/value pairs to set on the user profile.
120
+ */
19
121
  set(properties: Record<string, unknown>): void;
122
+ /**
123
+ * Set user properties only if they have not been set before (`$set_once` event).
124
+ *
125
+ * Useful for recording first-touch attribution (e.g. `initial_referrer`,
126
+ * `signup_date`) without overwriting values set by earlier events.
127
+ *
128
+ * @param properties - Key/value pairs to set once on the user profile.
129
+ */
20
130
  setOnce(properties: Record<string, unknown>): void;
131
+ /**
132
+ * Clear the current user identity.
133
+ *
134
+ * Removes `userId`, `anonymousId`, and `sessionId` from storage so the
135
+ * next event is treated as a brand-new anonymous visitor. Call this on
136
+ * logout to prevent post-logout events from being attributed to the
137
+ * previous user.
138
+ */
21
139
  reset(): void;
140
+ /** Gracefully stop the SDK: flush remaining events, remove all listeners. */
141
+ shutdown(): void;
22
142
  /** Anonymous ID — always per-device, never namespaced. Links pre-identify events to identified users. */
23
143
  private getAnonymousId;
144
+ private addListener;
24
145
  private setupAutocapture;
25
146
  private setupBeaconFlush;
26
147
  }
148
+ /**
149
+ * Default SDK instance.
150
+ *
151
+ * Import and call `qurvo.init({ apiKey })` to start capturing events.
152
+ *
153
+ * @example
154
+ * ```ts
155
+ * import { qurvo } from '@qurvo/sdk-browser';
156
+ *
157
+ * qurvo.init({ apiKey: 'pk_...' });
158
+ * qurvo.track('signup', { plan: 'pro' });
159
+ * ```
160
+ */
27
161
  export declare const qurvo: QurvoBrowser;
28
162
  export {};
29
163
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AA8CA,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,qHAAqH;IACrH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,cAAM,YAAY;IAChB,OAAO,CAAC,KAAK,CAA2B;IACxC,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,WAAW,CAAS;IAE5B,IAAI,CAAC,MAAM,EAAE,gBAAgB;IAmE7B,KAAK,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAezD,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAiBjE,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAIzC,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAI/D,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAevC,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAe3C,KAAK;IAIL,yGAAyG;IACzG,OAAO,CAAC,cAAc;IAStB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OAWG;IACH,IAAI,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAqBzC;;;;;;;;;OASG;IACH,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAI/D;;;;;;;;OAQG;IACH,GAAG,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAkBvC;;;;;;;OAOG;IACH,OAAO,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAkB3C;;;;;;;OAOG;IACH,KAAK;IAOL,6EAA6E;IAC7E,QAAQ,IAAI,IAAI;IA0BhB,yGAAyG;IACzG,OAAO,CAAC,cAAc;IAStB,OAAO,CAAC,WAAW;IAKnB,OAAO,CAAC,gBAAgB;IAyBxB,OAAO,CAAC,gBAAgB;CAuBzB;AAED;;;;;;;;;;;;GAYG;AACH,eAAO,MAAM,KAAK,cAAqB,CAAC"}
package/dist/index.js CHANGED
@@ -4,10 +4,13 @@ exports.qurvo = void 0;
4
4
  const fflate_1 = require("fflate");
5
5
  const sdk_core_1 = require("@qurvo/sdk-core");
6
6
  const version_1 = require("./version");
7
+ const utm_1 = require("./utm");
7
8
  const SDK_NAME = '@qurvo/sdk-browser';
8
9
  const ANON_ID_KEY = 'qurvo_anonymous_id';
9
10
  const SESSION_ID_KEY = 'qurvo_session_id';
10
11
  const USER_ID_KEY = 'qurvo_user_id';
12
+ /** Debounce window for page() to prevent pushState + popstate double-fire */
13
+ const PAGE_DEBOUNCE_MS = 50;
11
14
  function safeGetItem(storage, key) {
12
15
  try {
13
16
  return storage.getItem(key);
@@ -22,6 +25,12 @@ function safeSetItem(storage, key, value) {
22
25
  }
23
26
  catch { /* noop */ }
24
27
  }
28
+ function safeRemoveItem(storage, key) {
29
+ try {
30
+ storage.removeItem(key);
31
+ }
32
+ catch { /* noop */ }
33
+ }
25
34
  function generateId() {
26
35
  return crypto.randomUUID?.() || Math.random().toString(36).substring(2) + Date.now().toString(36);
27
36
  }
@@ -48,13 +57,66 @@ function getContext() {
48
57
  sdk_version: version_1.SDK_VERSION,
49
58
  };
50
59
  }
60
+ /**
61
+ * Browser SDK singleton that captures events, manages user identity, and
62
+ * persists an offline queue in localStorage.
63
+ *
64
+ * Lifecycle: call {@link QurvoBrowser.init | init()} once with your API key.
65
+ * The SDK generates an anonymous ID on first visit, stores it in localStorage,
66
+ * and upgrades to a known identity when {@link QurvoBrowser.identify | identify()}
67
+ * is called. Autocapture hooks into `pushState`, `popstate`, and `hashchange`
68
+ * to track pageviews automatically.
69
+ */
51
70
  class QurvoBrowser {
52
71
  queue = null;
53
72
  userId = null;
54
73
  initialized = false;
74
+ /** Debounce: last page() URL + timestamp to suppress duplicate $pageview */
75
+ lastPageUrl = null;
76
+ lastPageTime = 0;
77
+ /** Flag: $pageleave already emitted for current page, reset on new page() */
78
+ pageLeaveEmitted = false;
79
+ /** Stored listener references for cleanup in shutdown() */
80
+ listeners = [];
81
+ /** Original history methods saved for restore in shutdown() */
82
+ originalPushState = null;
83
+ originalReplaceState = null;
84
+ /**
85
+ * Initialize the SDK with the given configuration.
86
+ *
87
+ * Resolves `distinct_id` in priority order: explicit `config.distinctId` →
88
+ * previously stored userId in localStorage → auto-generated anonymous ID.
89
+ * Sets up a localStorage-backed event queue (namespaced per user when
90
+ * `distinctId` is provided), starts the flush timer, enables autocapture
91
+ * (unless opted out), and emits an initial `$pageview`.
92
+ *
93
+ * Calling `init()` a second time is a no-op unless `config.distinctId`
94
+ * differs from the current user, in which case the SDK resets identity
95
+ * and re-initializes to prevent cross-user event linkage.
96
+ *
97
+ * @param config - SDK configuration (only `apiKey` is required).
98
+ */
55
99
  init(config) {
56
- if (this.initialized)
100
+ // Account switch detection: if already initialized with a different distinctId,
101
+ // reset anonymous_id and clean up stale queue key to prevent cross-user linkage.
102
+ if (this.initialized && config.distinctId) {
103
+ const previousUserId = safeGetItem(localStorage, USER_ID_KEY);
104
+ if (previousUserId && previousUserId !== config.distinctId) {
105
+ // Remove stale queue key from previous user
106
+ safeRemoveItem(localStorage, `qurvo_queue:${previousUserId}`);
107
+ // Reset anonymous_id so a fresh one is generated for the new user
108
+ safeRemoveItem(localStorage, ANON_ID_KEY);
109
+ safeRemoveItem(sessionStorage, SESSION_ID_KEY);
110
+ // Shutdown existing queue and allow full re-initialization
111
+ this.shutdown();
112
+ }
113
+ else {
114
+ return; // Same user or no previous user — no-op
115
+ }
116
+ }
117
+ else if (this.initialized) {
57
118
  return;
119
+ }
58
120
  // If distinctId passed at init — use it, otherwise fall back to stored/anonymous
59
121
  if (config.distinctId) {
60
122
  this.userId = config.distinctId;
@@ -110,23 +172,59 @@ class QurvoBrowser {
110
172
  this.setupBeaconFlush();
111
173
  this.page();
112
174
  }
175
+ /**
176
+ * Send a custom event.
177
+ *
178
+ * UTM parameters from the current URL are automatically merged into
179
+ * `properties`; explicitly provided properties take priority over UTM values.
180
+ * Requires {@link QurvoBrowser.init | init()} to have been called first.
181
+ *
182
+ * @param event - Event name (e.g. `"signup"`, `"purchase"`).
183
+ * @param properties - Arbitrary key/value pairs attached to the event.
184
+ */
113
185
  track(event, properties) {
114
- if (!this.queue)
186
+ if (!this.queue) {
187
+ console.warn('[Qurvo] SDK not initialized. Call qurvo.init() first.');
115
188
  return;
189
+ }
190
+ // Auto-capture UTM params from URL; user-supplied properties take priority
191
+ const utm = (0, utm_1.getUtmParams)();
192
+ const mergedProperties = Object.keys(utm).length > 0 ? { ...utm, ...properties } : properties;
116
193
  const payload = {
117
194
  event,
118
195
  distinct_id: this.userId || this.getAnonymousId(),
119
196
  anonymous_id: this.getAnonymousId(),
120
- properties,
197
+ properties: mergedProperties,
121
198
  context: getContext(),
122
199
  timestamp: new Date().toISOString(),
123
200
  event_id: generateId(),
124
201
  };
125
202
  this.queue.enqueue(payload);
126
203
  }
204
+ /**
205
+ * Link the current anonymous session to a known user.
206
+ *
207
+ * Stores `userId` in localStorage and sends a `$identify` event that
208
+ * carries the current `anonymous_id`, allowing the server to merge
209
+ * pre-identify anonymous events with the identified user profile.
210
+ *
211
+ * If the user was already identified as a *different* user, the SDK
212
+ * automatically calls {@link QurvoBrowser.reset | reset()} first to
213
+ * prevent cross-user identity linkage.
214
+ *
215
+ * @param userId - Your application's stable user identifier.
216
+ * @param userProperties - Optional user-level properties (e.g. name, plan).
217
+ */
127
218
  identify(userId, userProperties) {
128
- if (!this.queue)
219
+ if (!this.queue) {
220
+ console.warn('[Qurvo] SDK not initialized. Call qurvo.init() first.');
129
221
  return;
222
+ }
223
+ // Auto-reset when re-identifying as a different user (PostHog behavior).
224
+ // Prevents anonymous_id from linking two distinct accounts.
225
+ if (this.userId && this.userId !== userId) {
226
+ this.reset();
227
+ }
130
228
  this.userId = userId;
131
229
  safeSetItem(localStorage, USER_ID_KEY, userId);
132
230
  const payload = {
@@ -140,15 +238,62 @@ class QurvoBrowser {
140
238
  };
141
239
  this.queue.enqueue(payload);
142
240
  }
241
+ /**
242
+ * Track a pageview (`$pageview` event).
243
+ *
244
+ * Applies a 50 ms debounce on the same URL to suppress duplicate events
245
+ * caused by `pushState` and `popstate` firing in quick succession. Also
246
+ * resets the `$pageleave` flag so a fresh leave event can be emitted when
247
+ * the user navigates away from this page.
248
+ *
249
+ * Called automatically on navigation when `autocapture` is enabled.
250
+ *
251
+ * @param properties - Extra properties to attach to the pageview event.
252
+ */
143
253
  page(properties) {
254
+ if (!this.queue) {
255
+ console.warn('[Qurvo] SDK not initialized. Call qurvo.init() first.');
256
+ return;
257
+ }
258
+ // Debounce: skip if same URL was tracked within PAGE_DEBOUNCE_MS
259
+ const now = Date.now();
260
+ const currentUrl = window.location.href;
261
+ if (this.lastPageUrl === currentUrl && now - this.lastPageTime < PAGE_DEBOUNCE_MS) {
262
+ return;
263
+ }
264
+ this.lastPageUrl = currentUrl;
265
+ this.lastPageTime = now;
266
+ // New page navigation — allow a fresh $pageleave on unload
267
+ this.pageLeaveEmitted = false;
144
268
  this.track('$pageview', properties);
145
269
  }
270
+ /**
271
+ * Track a screen view (`$screen` event).
272
+ *
273
+ * Intended for non-web contexts (e.g. React Native, Telegram Mini Apps)
274
+ * where navigation doesn't map to browser URLs. Sends `$screen_name`
275
+ * inside the event properties.
276
+ *
277
+ * @param screenName - Logical screen name (e.g. `"Settings"`, `"Profile"`).
278
+ * @param properties - Extra properties to attach to the screen event.
279
+ */
146
280
  screen(screenName, properties) {
147
281
  this.track('$screen', { $screen_name: screenName, ...properties });
148
282
  }
283
+ /**
284
+ * Set user properties on the current user (`$set` event).
285
+ *
286
+ * Properties are always overwritten with the provided values.
287
+ * Use {@link QurvoBrowser.setOnce | setOnce()} to write only if
288
+ * the property has not been set before.
289
+ *
290
+ * @param properties - Key/value pairs to set on the user profile.
291
+ */
149
292
  set(properties) {
150
- if (!this.queue)
293
+ if (!this.queue) {
294
+ console.warn('[Qurvo] SDK not initialized. Call qurvo.init() first.');
151
295
  return;
296
+ }
152
297
  const payload = {
153
298
  event: '$set',
154
299
  distinct_id: this.userId || this.getAnonymousId(),
@@ -160,9 +305,19 @@ class QurvoBrowser {
160
305
  };
161
306
  this.queue.enqueue(payload);
162
307
  }
308
+ /**
309
+ * Set user properties only if they have not been set before (`$set_once` event).
310
+ *
311
+ * Useful for recording first-touch attribution (e.g. `initial_referrer`,
312
+ * `signup_date`) without overwriting values set by earlier events.
313
+ *
314
+ * @param properties - Key/value pairs to set once on the user profile.
315
+ */
163
316
  setOnce(properties) {
164
- if (!this.queue)
317
+ if (!this.queue) {
318
+ console.warn('[Qurvo] SDK not initialized. Call qurvo.init() first.');
165
319
  return;
320
+ }
166
321
  const payload = {
167
322
  event: '$set_once',
168
323
  distinct_id: this.userId || this.getAnonymousId(),
@@ -174,8 +329,42 @@ class QurvoBrowser {
174
329
  };
175
330
  this.queue.enqueue(payload);
176
331
  }
332
+ /**
333
+ * Clear the current user identity.
334
+ *
335
+ * Removes `userId`, `anonymousId`, and `sessionId` from storage so the
336
+ * next event is treated as a brand-new anonymous visitor. Call this on
337
+ * logout to prevent post-logout events from being attributed to the
338
+ * previous user.
339
+ */
177
340
  reset() {
178
341
  this.userId = null;
342
+ safeRemoveItem(localStorage, USER_ID_KEY);
343
+ safeRemoveItem(localStorage, ANON_ID_KEY);
344
+ safeRemoveItem(sessionStorage, SESSION_ID_KEY);
345
+ }
346
+ /** Gracefully stop the SDK: flush remaining events, remove all listeners. */
347
+ shutdown() {
348
+ // Remove all registered event listeners
349
+ for (const { target, event, fn } of this.listeners) {
350
+ target.removeEventListener(event, fn);
351
+ }
352
+ this.listeners = [];
353
+ // Restore original history methods
354
+ if (this.originalPushState) {
355
+ history.pushState = this.originalPushState;
356
+ this.originalPushState = null;
357
+ }
358
+ if (this.originalReplaceState) {
359
+ history.replaceState = this.originalReplaceState;
360
+ this.originalReplaceState = null;
361
+ }
362
+ // Shutdown the queue (flush remaining + stop timer)
363
+ if (this.queue) {
364
+ this.queue.shutdown();
365
+ this.queue = null;
366
+ }
367
+ this.initialized = false;
179
368
  }
180
369
  /** Anonymous ID — always per-device, never namespaced. Links pre-identify events to identified users. */
181
370
  getAnonymousId() {
@@ -186,27 +375,40 @@ class QurvoBrowser {
186
375
  }
187
376
  return id;
188
377
  }
378
+ addListener(target, event, fn) {
379
+ target.addEventListener(event, fn);
380
+ this.listeners.push({ target, event, fn });
381
+ }
189
382
  setupAutocapture() {
190
- const originalPushState = history.pushState;
383
+ this.originalPushState = history.pushState;
384
+ const originalPushState = this.originalPushState;
191
385
  history.pushState = (...args) => {
192
386
  originalPushState.apply(history, args);
193
387
  this.page();
194
388
  };
195
- const originalReplaceState = history.replaceState;
389
+ // replaceState intentionally does NOT trigger page() because it replaces
390
+ // the current URL without navigation (e.g. query param updates, scroll restoration)
391
+ this.originalReplaceState = history.replaceState;
392
+ const originalReplaceState = this.originalReplaceState;
196
393
  history.replaceState = (...args) => {
197
394
  originalReplaceState.apply(history, args);
198
- this.page();
199
395
  };
200
- window.addEventListener('popstate', () => {
396
+ this.addListener(window, 'popstate', () => {
201
397
  this.page();
202
398
  });
203
- window.addEventListener('hashchange', () => {
399
+ this.addListener(window, 'hashchange', () => {
204
400
  this.page();
205
401
  });
206
402
  }
207
403
  setupBeaconFlush() {
208
404
  const flushForUnload = () => {
209
- this.track('$pageleave');
405
+ // Only emit $pageleave once per page — visibilitychange (hidden) and
406
+ // pagehide/beforeunload can both fire on tab close. First call tracks +
407
+ // flushes; subsequent calls only flush remaining queue items.
408
+ if (!this.pageLeaveEmitted) {
409
+ this.track('$pageleave');
410
+ this.pageLeaveEmitted = true;
411
+ }
210
412
  if (this.queue && this.queue.size > 0) {
211
413
  this.queue.flushForUnload();
212
414
  }
@@ -214,12 +416,25 @@ class QurvoBrowser {
214
416
  // pagehide is more reliable than beforeunload in mobile webviews (Telegram, TikTok, etc.)
215
417
  // see https://calendar.perfplanet.com/2020/beaconing-in-practice/#beaconing-reliability-avoiding-abandons
216
418
  const unloadEvent = 'onpagehide' in self ? 'pagehide' : 'beforeunload';
217
- window.addEventListener(unloadEvent, flushForUnload);
218
- document.addEventListener('visibilitychange', () => {
419
+ this.addListener(window, unloadEvent, flushForUnload);
420
+ this.addListener(document, 'visibilitychange', () => {
219
421
  if (document.visibilityState === 'hidden')
220
422
  flushForUnload();
221
423
  });
222
424
  }
223
425
  }
426
+ /**
427
+ * Default SDK instance.
428
+ *
429
+ * Import and call `qurvo.init({ apiKey })` to start capturing events.
430
+ *
431
+ * @example
432
+ * ```ts
433
+ * import { qurvo } from '@qurvo/sdk-browser';
434
+ *
435
+ * qurvo.init({ apiKey: 'pk_...' });
436
+ * qurvo.track('signup', { plan: 'pro' });
437
+ * ```
438
+ */
224
439
  exports.qurvo = new QurvoBrowser();
225
440
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,mCAA2C;AAC3C,8CAA6D;AAE7D,uCAAwC;A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