@depsmith/depsmith-sdk 0.6.0 → 0.8.0

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.cts CHANGED
@@ -44,7 +44,12 @@ interface UserPropertyOps {
44
44
  type Scalar = string | number | boolean | null;
45
45
  type PropertyValue = Scalar | Scalar[] | Record<string, Scalar>;
46
46
  type Properties = Record<string, PropertyValue>;
47
- type EventType = 'track' | 'page_view' | 'screen' | 'identify' | 'alias' | 'group' | 'autocapture' | 'session_start' | 'session_end';
47
+ /** The third argument of `page()` / `screen()`. */
48
+ interface PageOptions {
49
+ /** The kind of page (`product`, `collection`, `cart`, …), sent as `$page_type`. */
50
+ type?: string;
51
+ }
52
+ type EventType = 'track' | 'page_view' | 'page_leave' | 'screen' | 'identify' | 'alias' | 'group' | 'autocapture' | 'session_start' | 'session_end';
48
53
  type NetworkType = '2g' | '3g' | '4g' | '5g' | 'wifi' | 'ethernet' | 'none' | 'unknown';
49
54
  interface EventContext {
50
55
  library: {
@@ -56,8 +61,44 @@ interface EventContext {
56
61
  referrer?: string;
57
62
  title?: string;
58
63
  path?: string;
64
+ /** Host of `url`. */
65
+ domain?: string;
66
+ /** `url` without query string or fragment. */
67
+ url_base?: string;
68
+ /**
69
+ * The page viewed immediately before this one, tracked by the SDK across History
70
+ * navigation. NOT `document.referrer`, which the browser freezes at document load and so
71
+ * keeps pointing at the landing referrer for the whole of an SPA visit.
72
+ */
73
+ previous_url?: string;
74
+ previous_type?: 'direct' | 'internal' | 'external';
75
+ /** Pages seen so far this session; 1 on the first. Resets when the session rotates. */
76
+ counter?: number;
77
+ };
78
+ /**
79
+ * Marketing attribution, carried on every event (not just the landing pageview) so campaign
80
+ * breakdowns work on any event. Key names match what the collector reads — see
81
+ * `web/src/attribution.ts`.
82
+ */
83
+ campaign?: {
84
+ source?: string;
85
+ medium?: string;
86
+ name?: string;
87
+ term?: string;
88
+ content?: string;
59
89
  };
60
- screen?: {
90
+ /**
91
+ * `url`/`domain` describe this visit's external referrer; `initial_*` is the first-ever
92
+ * referrer for this anonymous_id and is never overwritten. Distinct from `page.referrer`,
93
+ * which is `document.referrer` and therefore wrong after the first SPA route change.
94
+ */
95
+ referrer?: {
96
+ url?: string;
97
+ domain?: string;
98
+ initial_url?: string;
99
+ initial_domain?: string;
100
+ };
101
+ screen_size?: {
61
102
  width?: number;
62
103
  height?: number;
63
104
  density?: number;
@@ -160,15 +201,18 @@ interface TrackingOptions {
160
201
  deviceManufacturer?: boolean;
161
202
  deviceModel?: boolean;
162
203
  deviceType?: boolean;
204
+ /** context.device.idfv — iOS only, and the ONLY control over it: nothing else suppresses it. */
205
+ idfv?: boolean;
163
206
  /** context.locale. */
164
207
  language?: boolean;
165
208
  /** context.network in full. Subsumes carrier. */
166
209
  network?: boolean;
167
210
  osName?: boolean;
168
211
  osVersion?: boolean;
169
- /** context.page. Not the `name` property on $page_view — that is a property, not context. */
212
+ /** context.page. Not `$page_name` on $page_view — that is a property, not context. */
170
213
  page?: boolean;
171
- screen?: boolean;
214
+ /** context.screen_size: display width, height and density. */
215
+ screenSize?: boolean;
172
216
  timezone?: boolean;
173
217
  /** context.user_agent. */
174
218
  userAgent?: boolean;
@@ -219,7 +263,22 @@ interface DepsmithSdkConfig {
219
263
  cookieDomain?: string;
220
264
  /** Queue persistence backend. */
221
265
  storage?: 'localstorage' | 'indexeddb' | 'memory';
266
+ /**
267
+ * Readable `$page_name`s for automatic page views, and for `page()` calls made without a name.
268
+ * A name passed to `page()` always wins; with no match the name falls back to the title.
269
+ *
270
+ * - **Patterns:** `{ '/products/*': 'Product', '/': 'Home' }`. `*` is one path segment, `**` the
271
+ * rest of the path. The first match wins, in insertion order, so put specific patterns
272
+ * before broad ones (or use the `[pattern, name]` array form). A pattern match also sets
273
+ * `$page_type` to its name.
274
+ * - **Function:** `(location) => string | undefined`, called per view. Sets the name only.
275
+ * Web-only; config.schema.json can describe the object form alone.
276
+ */
277
+ pageNames?: PageNames;
222
278
  }
279
+ /** What a `pageNames` function is handed: `window.location`, or a URL with the same fields. */
280
+ type PageLocation = Pick<Location, 'href' | 'pathname' | 'search' | 'hash' | 'host'>;
281
+ type PageNames = Record<string, string> | ReadonlyArray<readonly [pattern: string, name: string]> | ((location: PageLocation) => string | undefined);
223
282
  /**
224
283
  * Which clicks produce a `$autocapture` event.
225
284
  * 'interactive' — only clicks resolving to a link/button/[role=button]/submit control
@@ -228,13 +287,40 @@ interface DepsmithSdkConfig {
228
287
  * true — alias of 'interactive'; false disables click capture.
229
288
  */
230
289
  type ClickCapture = boolean | 'interactive' | 'all';
290
+ /**
291
+ * When an automatic `$page_view` (and its `$page_leave`) is sent.
292
+ * 'path' — when `location.pathname` changes. The default: a query-string or `#` change is
293
+ * filters, sort order, pagination or an in-page anchor, not a new page.
294
+ * 'all' — when anything in the URL changes, query and `#` included (the pre-0.8 behaviour).
295
+ * true — alias of 'path'; false sends none automatically.
296
+ */
297
+ type PageViewCapture = boolean | 'path' | 'all';
231
298
  interface AutocaptureConfig {
232
299
  clicks?: ClickCapture;
233
300
  forms?: boolean;
234
301
  scrolls?: boolean;
235
- pageviews?: boolean;
302
+ pageviews?: PageViewCapture;
236
303
  ignoredSelectors?: string[];
237
304
  selectorMaxDepth?: number;
305
+ /**
306
+ * Extra patterns for ids, classes and test-attribute values that `$ac_selector` should skip as
307
+ * generated, on top of the built-in rules (CSS-in-JS and CSS-module hashes, utility classes,
308
+ * long digit runs). Regex sources, e.g. `['^theme-', '^js-']`; an invalid one is skipped with
309
+ * a debug warning.
310
+ */
311
+ selectorIgnore?: string[];
312
+ /**
313
+ * `data-*` attribute names to attach to click and change events as `$ac_attr_<name>`.
314
+ *
315
+ * An explicit allow-list, NOT a prefix, and empty by default. Data attributes routinely hold
316
+ * exactly the values this SDK is careful never to capture — `data-user-email`,
317
+ * `data-customer-id` — so a prefix rule means any attribute a developer adds later ships
318
+ * silently from then on. Naming each one keeps the decision with the person who can see the
319
+ * markup. Values obey the masking rules: nothing inside `[data-depsmith-sdk-mask]` is read.
320
+ *
321
+ * Given as bare names: `['product-id']` captures `data-product-id` as `$ac_attr_product_id`.
322
+ */
323
+ attributes?: string[];
238
324
  }
239
325
 
240
326
  /**
@@ -246,12 +332,7 @@ interface KVStorage {
246
332
  set(key: string, value: string): void;
247
333
  remove(key: string): void;
248
334
  }
249
- /**
250
- * Every key DepsmithSdk persists. Single source of truth for hosts that must enumerate
251
- * them up front — e.g. `AsyncMirrorAdapter`, whose backend has no bulk read.
252
- * Kept in sync with the `KEY_*` consts in identity/session/consent/queue/depsmith-sdk/breaker.
253
- */
254
- declare const DEPSMITH_SDK_STORAGE_KEYS: readonly ["depsmith_anonymous_id", "depsmith_user_id", "depsmith_group_id", "depsmith_user_props", "depsmith_session", "depsmith_consent", "depsmith_queue", "depsmith_config_fp", "depsmith_net_breaker"];
335
+ declare const DEPSMITH_SDK_STORAGE_KEYS: readonly ["depsmith_anonymous_id", "depsmith_user_id", "depsmith_group_id", "depsmith_user_props", "depsmith_session", "depsmith_consent", "depsmith_queue", "depsmith_config_fp", "depsmith_net_breaker", "depsmith_campaign", "depsmith_referrer"];
255
336
  /**
256
337
  * Minimal async key-value backend. Shaped to accept Shopify's `browser.localStorage`
257
338
  * / `browser.sessionStorage` directly (all methods Promise-returning, proxied to the
@@ -347,6 +428,26 @@ declare class DepsmithSdkClient {
347
428
  private identity;
348
429
  private session;
349
430
  private consent;
431
+ private attribution;
432
+ private superProperties;
433
+ /**
434
+ * `$page_view` / `$page_leave` and the navigation half of `context.page`. Everything but this
435
+ * handle lives in `page.ts`, which the Shopify pixel build swaps for a no-op — see the note
436
+ * on {@link PageLifecycle}.
437
+ */
438
+ private pageLife;
439
+ /**
440
+ * Autocapture's unload-time `$page_leave` trigger, when pageview tracking is on.
441
+ *
442
+ * The client owns the call site rather than autocapture, because it must run BEFORE the
443
+ * teardown drain — see {@link attachLifecycle}. Undefined means no page-leave tracking:
444
+ * autocapture is off, compiled out, or still loading.
445
+ */
446
+ private leaveOnUnload?;
447
+ /** Core Web Vitals, when autocapture is on. Reported once, on the first hide. */
448
+ private vitals?;
449
+ /** Set once $web_vitals has been emitted, so a tab shown and hidden again does not repeat it. */
450
+ private vitalsReported;
350
451
  private queue;
351
452
  private uploader;
352
453
  private flushTimer;
@@ -362,6 +463,13 @@ declare class DepsmithSdkClient {
362
463
  private ready;
363
464
  constructor(config: DepsmithSdkConfig, overrides?: InternalOverrides);
364
465
  track(name: string, properties?: Properties): void;
466
+ /**
467
+ * `track()` without the `$`-key check on properties, for the SDK's own integrations. Not part
468
+ * of the public API: the Shopify pixel needs it because it stamps `$shopify_client_id` on every
469
+ * event it maps, which a public `track()` would now drop as reserved. Event names are checked
470
+ * exactly as in `track()`.
471
+ */
472
+ trackInternal(name: string, properties?: Properties): void;
365
473
  /**
366
474
  * Rejects an envelope id the collector's schema would refuse, at the point it enters the SDK.
367
475
  *
@@ -376,10 +484,36 @@ declare class DepsmithSdkClient {
376
484
  * prefix, inventing data rather than losing it. Rejecting a schema-invalid value at capture is
377
485
  * the rule throughout: such an event would 400 and take the whole batch with it.
378
486
  */
487
+ /** Client traits as sent: `$` keys dropped, then sanitised like event properties. */
488
+ private traits;
379
489
  private tooLong;
380
- page(name?: string, properties?: Properties): void;
490
+ /** `options.type` is sent as `$page_type` (API_SPEC §2). */
491
+ page(name?: string, properties?: Properties, options?: PageOptions): void;
492
+ /**
493
+ * `page()` without the `$`-key check, for the SDK's own integrations. Not part of the public
494
+ * API: the Shopify pixel sends checkout page views with `$checkout_step` and
495
+ * `$shopify_client_id`, which a public `page()` would now drop as reserved. Still a manual
496
+ * view — it is a call, not autocapture.
497
+ *
498
+ * Advances navigation state even for an explicit call, so an app that drives pageviews by hand
499
+ * (no autocapture) still gets previous_url and counter — and claims the URL so autocapture
500
+ * cannot emit a second view for the same page.
501
+ */
502
+ pageInternal(name?: string, properties?: Properties, options?: PageOptions): void;
503
+ /**
504
+ * `$web_vitals`, once per page, on the first time the tab is hidden.
505
+ *
506
+ * Hidden rather than loaded, because three of the five are not final until then: LCP can be
507
+ * superseded by a later paint, CLS accumulates for the life of the page, and INP is the worst
508
+ * interaction so far. Reporting at load would under-report all three — worse than not reporting,
509
+ * because the numbers would look plausible.
510
+ *
511
+ * Once, not per hide: a tab switched away and back has the same page-load metrics, and a second
512
+ * event would double-count the page in every average built on it.
513
+ */
514
+ private emitWebVitals;
381
515
  /** Alias of page() — unified mobile naming. */
382
- screen(name?: string, properties?: Properties): void;
516
+ screen(name?: string, properties?: Properties, options?: PageOptions): void;
383
517
  identify(userId: string, traits?: Properties): void;
384
518
  alias(aliasId: string): void;
385
519
  reset(): void;
@@ -416,6 +550,19 @@ declare class DepsmithSdkClient {
416
550
  * Silently does nothing when nothing survives validation — a key claimed twice, a
417
551
  * non-finite `$add`, an empty map — since the schema forbids an empty operator object.
418
552
  */
553
+ /**
554
+ * Registers properties attached to every later event, surviving a reload.
555
+ *
556
+ * A property passed directly to `track()` wins over a registered one with the same key.
557
+ * `$`-prefixed keys are rejected, as everywhere else. Cleared by `reset()`.
558
+ */
559
+ register(properties: Properties): void;
560
+ /**
561
+ * Registers only keys that are not registered yet — for first-touch values like the plan a user
562
+ * signed up on, which a later state change must not overwrite.
563
+ */
564
+ registerOnce(properties: Properties): void;
565
+ unregister(key: string): void;
419
566
  setUserProperties(ops: UserPropertyOps): void;
420
567
  optIn(): void;
421
568
  optOut(): void;
@@ -535,8 +682,8 @@ declare class DepsmithSdkClient {
535
682
  declare const DepsmithSdk: {
536
683
  init(config: DepsmithSdkConfig, overrides?: InternalOverrides): DepsmithSdkClient | null;
537
684
  track: (name: string, properties?: Properties) => void;
538
- page: (name?: string, properties?: Properties) => void;
539
- screen: (name?: string, properties?: Properties) => void;
685
+ page: (name?: string, properties?: Properties, options?: PageOptions) => void;
686
+ screen: (name?: string, properties?: Properties, options?: PageOptions) => void;
540
687
  identify: (userId: string, traits?: Properties) => void;
541
688
  alias: (aliasId: string) => void;
542
689
  reset: () => void;
@@ -547,6 +694,11 @@ declare const DepsmithSdk: {
547
694
  unsetProperty: (key: string) => void;
548
695
  /** Applies the §14 operator set server-side: $set, $add, $append, $unset, $clear_all, … */
549
696
  setUserProperties: (ops: UserPropertyOps) => void;
697
+ /** Properties attached to every later event. A direct track() property wins over these. */
698
+ register: (properties: Properties) => void;
699
+ /** Only keys not registered yet — first-touch values a later state must not overwrite. */
700
+ registerOnce: (properties: Properties) => void;
701
+ unregister: (key: string) => void;
550
702
  optIn: () => void;
551
703
  optOut: () => void;
552
704
  flush: () => Promise<void>;
@@ -557,4 +709,4 @@ declare const DepsmithSdk: {
557
709
  shutdown(): void;
558
710
  };
559
711
 
560
- export { type AsyncKV, AsyncMirrorAdapter, type AutocaptureConfig, type BatchPayload, type ConsentState, DEPSMITH_SDK_STORAGE_KEYS, DepsmithSdk, DepsmithSdkClient, type DepsmithSdkConfig, type DepsmithSdkEvent, type EventContext, type EventType, type InternalOverrides, type KVStorage, type Properties, type PropertyValue, type Scheduler, type TrackingOptions, type UserPropertyOps, idleScheduler, syncScheduler };
712
+ export { type AsyncKV, AsyncMirrorAdapter, type AutocaptureConfig, type BatchPayload, type ConsentState, DEPSMITH_SDK_STORAGE_KEYS, DepsmithSdk, DepsmithSdkClient, type DepsmithSdkConfig, type DepsmithSdkEvent, type EventContext, type EventType, type InternalOverrides, type KVStorage, type PageLocation, type PageNames, type PageOptions, type Properties, type PropertyValue, type Scheduler, type TrackingOptions, type UserPropertyOps, idleScheduler, syncScheduler };
package/dist/index.d.ts CHANGED
@@ -44,7 +44,12 @@ interface UserPropertyOps {
44
44
  type Scalar = string | number | boolean | null;
45
45
  type PropertyValue = Scalar | Scalar[] | Record<string, Scalar>;
46
46
  type Properties = Record<string, PropertyValue>;
47
- type EventType = 'track' | 'page_view' | 'screen' | 'identify' | 'alias' | 'group' | 'autocapture' | 'session_start' | 'session_end';
47
+ /** The third argument of `page()` / `screen()`. */
48
+ interface PageOptions {
49
+ /** The kind of page (`product`, `collection`, `cart`, …), sent as `$page_type`. */
50
+ type?: string;
51
+ }
52
+ type EventType = 'track' | 'page_view' | 'page_leave' | 'screen' | 'identify' | 'alias' | 'group' | 'autocapture' | 'session_start' | 'session_end';
48
53
  type NetworkType = '2g' | '3g' | '4g' | '5g' | 'wifi' | 'ethernet' | 'none' | 'unknown';
49
54
  interface EventContext {
50
55
  library: {
@@ -56,8 +61,44 @@ interface EventContext {
56
61
  referrer?: string;
57
62
  title?: string;
58
63
  path?: string;
64
+ /** Host of `url`. */
65
+ domain?: string;
66
+ /** `url` without query string or fragment. */
67
+ url_base?: string;
68
+ /**
69
+ * The page viewed immediately before this one, tracked by the SDK across History
70
+ * navigation. NOT `document.referrer`, which the browser freezes at document load and so
71
+ * keeps pointing at the landing referrer for the whole of an SPA visit.
72
+ */
73
+ previous_url?: string;
74
+ previous_type?: 'direct' | 'internal' | 'external';
75
+ /** Pages seen so far this session; 1 on the first. Resets when the session rotates. */
76
+ counter?: number;
77
+ };
78
+ /**
79
+ * Marketing attribution, carried on every event (not just the landing pageview) so campaign
80
+ * breakdowns work on any event. Key names match what the collector reads — see
81
+ * `web/src/attribution.ts`.
82
+ */
83
+ campaign?: {
84
+ source?: string;
85
+ medium?: string;
86
+ name?: string;
87
+ term?: string;
88
+ content?: string;
59
89
  };
60
- screen?: {
90
+ /**
91
+ * `url`/`domain` describe this visit's external referrer; `initial_*` is the first-ever
92
+ * referrer for this anonymous_id and is never overwritten. Distinct from `page.referrer`,
93
+ * which is `document.referrer` and therefore wrong after the first SPA route change.
94
+ */
95
+ referrer?: {
96
+ url?: string;
97
+ domain?: string;
98
+ initial_url?: string;
99
+ initial_domain?: string;
100
+ };
101
+ screen_size?: {
61
102
  width?: number;
62
103
  height?: number;
63
104
  density?: number;
@@ -160,15 +201,18 @@ interface TrackingOptions {
160
201
  deviceManufacturer?: boolean;
161
202
  deviceModel?: boolean;
162
203
  deviceType?: boolean;
204
+ /** context.device.idfv — iOS only, and the ONLY control over it: nothing else suppresses it. */
205
+ idfv?: boolean;
163
206
  /** context.locale. */
164
207
  language?: boolean;
165
208
  /** context.network in full. Subsumes carrier. */
166
209
  network?: boolean;
167
210
  osName?: boolean;
168
211
  osVersion?: boolean;
169
- /** context.page. Not the `name` property on $page_view — that is a property, not context. */
212
+ /** context.page. Not `$page_name` on $page_view — that is a property, not context. */
170
213
  page?: boolean;
171
- screen?: boolean;
214
+ /** context.screen_size: display width, height and density. */
215
+ screenSize?: boolean;
172
216
  timezone?: boolean;
173
217
  /** context.user_agent. */
174
218
  userAgent?: boolean;
@@ -219,7 +263,22 @@ interface DepsmithSdkConfig {
219
263
  cookieDomain?: string;
220
264
  /** Queue persistence backend. */
221
265
  storage?: 'localstorage' | 'indexeddb' | 'memory';
266
+ /**
267
+ * Readable `$page_name`s for automatic page views, and for `page()` calls made without a name.
268
+ * A name passed to `page()` always wins; with no match the name falls back to the title.
269
+ *
270
+ * - **Patterns:** `{ '/products/*': 'Product', '/': 'Home' }`. `*` is one path segment, `**` the
271
+ * rest of the path. The first match wins, in insertion order, so put specific patterns
272
+ * before broad ones (or use the `[pattern, name]` array form). A pattern match also sets
273
+ * `$page_type` to its name.
274
+ * - **Function:** `(location) => string | undefined`, called per view. Sets the name only.
275
+ * Web-only; config.schema.json can describe the object form alone.
276
+ */
277
+ pageNames?: PageNames;
222
278
  }
279
+ /** What a `pageNames` function is handed: `window.location`, or a URL with the same fields. */
280
+ type PageLocation = Pick<Location, 'href' | 'pathname' | 'search' | 'hash' | 'host'>;
281
+ type PageNames = Record<string, string> | ReadonlyArray<readonly [pattern: string, name: string]> | ((location: PageLocation) => string | undefined);
223
282
  /**
224
283
  * Which clicks produce a `$autocapture` event.
225
284
  * 'interactive' — only clicks resolving to a link/button/[role=button]/submit control
@@ -228,13 +287,40 @@ interface DepsmithSdkConfig {
228
287
  * true — alias of 'interactive'; false disables click capture.
229
288
  */
230
289
  type ClickCapture = boolean | 'interactive' | 'all';
290
+ /**
291
+ * When an automatic `$page_view` (and its `$page_leave`) is sent.
292
+ * 'path' — when `location.pathname` changes. The default: a query-string or `#` change is
293
+ * filters, sort order, pagination or an in-page anchor, not a new page.
294
+ * 'all' — when anything in the URL changes, query and `#` included (the pre-0.8 behaviour).
295
+ * true — alias of 'path'; false sends none automatically.
296
+ */
297
+ type PageViewCapture = boolean | 'path' | 'all';
231
298
  interface AutocaptureConfig {
232
299
  clicks?: ClickCapture;
233
300
  forms?: boolean;
234
301
  scrolls?: boolean;
235
- pageviews?: boolean;
302
+ pageviews?: PageViewCapture;
236
303
  ignoredSelectors?: string[];
237
304
  selectorMaxDepth?: number;
305
+ /**
306
+ * Extra patterns for ids, classes and test-attribute values that `$ac_selector` should skip as
307
+ * generated, on top of the built-in rules (CSS-in-JS and CSS-module hashes, utility classes,
308
+ * long digit runs). Regex sources, e.g. `['^theme-', '^js-']`; an invalid one is skipped with
309
+ * a debug warning.
310
+ */
311
+ selectorIgnore?: string[];
312
+ /**
313
+ * `data-*` attribute names to attach to click and change events as `$ac_attr_<name>`.
314
+ *
315
+ * An explicit allow-list, NOT a prefix, and empty by default. Data attributes routinely hold
316
+ * exactly the values this SDK is careful never to capture — `data-user-email`,
317
+ * `data-customer-id` — so a prefix rule means any attribute a developer adds later ships
318
+ * silently from then on. Naming each one keeps the decision with the person who can see the
319
+ * markup. Values obey the masking rules: nothing inside `[data-depsmith-sdk-mask]` is read.
320
+ *
321
+ * Given as bare names: `['product-id']` captures `data-product-id` as `$ac_attr_product_id`.
322
+ */
323
+ attributes?: string[];
238
324
  }
239
325
 
240
326
  /**
@@ -246,12 +332,7 @@ interface KVStorage {
246
332
  set(key: string, value: string): void;
247
333
  remove(key: string): void;
248
334
  }
249
- /**
250
- * Every key DepsmithSdk persists. Single source of truth for hosts that must enumerate
251
- * them up front — e.g. `AsyncMirrorAdapter`, whose backend has no bulk read.
252
- * Kept in sync with the `KEY_*` consts in identity/session/consent/queue/depsmith-sdk/breaker.
253
- */
254
- declare const DEPSMITH_SDK_STORAGE_KEYS: readonly ["depsmith_anonymous_id", "depsmith_user_id", "depsmith_group_id", "depsmith_user_props", "depsmith_session", "depsmith_consent", "depsmith_queue", "depsmith_config_fp", "depsmith_net_breaker"];
335
+ declare const DEPSMITH_SDK_STORAGE_KEYS: readonly ["depsmith_anonymous_id", "depsmith_user_id", "depsmith_group_id", "depsmith_user_props", "depsmith_session", "depsmith_consent", "depsmith_queue", "depsmith_config_fp", "depsmith_net_breaker", "depsmith_campaign", "depsmith_referrer"];
255
336
  /**
256
337
  * Minimal async key-value backend. Shaped to accept Shopify's `browser.localStorage`
257
338
  * / `browser.sessionStorage` directly (all methods Promise-returning, proxied to the
@@ -347,6 +428,26 @@ declare class DepsmithSdkClient {
347
428
  private identity;
348
429
  private session;
349
430
  private consent;
431
+ private attribution;
432
+ private superProperties;
433
+ /**
434
+ * `$page_view` / `$page_leave` and the navigation half of `context.page`. Everything but this
435
+ * handle lives in `page.ts`, which the Shopify pixel build swaps for a no-op — see the note
436
+ * on {@link PageLifecycle}.
437
+ */
438
+ private pageLife;
439
+ /**
440
+ * Autocapture's unload-time `$page_leave` trigger, when pageview tracking is on.
441
+ *
442
+ * The client owns the call site rather than autocapture, because it must run BEFORE the
443
+ * teardown drain — see {@link attachLifecycle}. Undefined means no page-leave tracking:
444
+ * autocapture is off, compiled out, or still loading.
445
+ */
446
+ private leaveOnUnload?;
447
+ /** Core Web Vitals, when autocapture is on. Reported once, on the first hide. */
448
+ private vitals?;
449
+ /** Set once $web_vitals has been emitted, so a tab shown and hidden again does not repeat it. */
450
+ private vitalsReported;
350
451
  private queue;
351
452
  private uploader;
352
453
  private flushTimer;
@@ -362,6 +463,13 @@ declare class DepsmithSdkClient {
362
463
  private ready;
363
464
  constructor(config: DepsmithSdkConfig, overrides?: InternalOverrides);
364
465
  track(name: string, properties?: Properties): void;
466
+ /**
467
+ * `track()` without the `$`-key check on properties, for the SDK's own integrations. Not part
468
+ * of the public API: the Shopify pixel needs it because it stamps `$shopify_client_id` on every
469
+ * event it maps, which a public `track()` would now drop as reserved. Event names are checked
470
+ * exactly as in `track()`.
471
+ */
472
+ trackInternal(name: string, properties?: Properties): void;
365
473
  /**
366
474
  * Rejects an envelope id the collector's schema would refuse, at the point it enters the SDK.
367
475
  *
@@ -376,10 +484,36 @@ declare class DepsmithSdkClient {
376
484
  * prefix, inventing data rather than losing it. Rejecting a schema-invalid value at capture is
377
485
  * the rule throughout: such an event would 400 and take the whole batch with it.
378
486
  */
487
+ /** Client traits as sent: `$` keys dropped, then sanitised like event properties. */
488
+ private traits;
379
489
  private tooLong;
380
- page(name?: string, properties?: Properties): void;
490
+ /** `options.type` is sent as `$page_type` (API_SPEC §2). */
491
+ page(name?: string, properties?: Properties, options?: PageOptions): void;
492
+ /**
493
+ * `page()` without the `$`-key check, for the SDK's own integrations. Not part of the public
494
+ * API: the Shopify pixel sends checkout page views with `$checkout_step` and
495
+ * `$shopify_client_id`, which a public `page()` would now drop as reserved. Still a manual
496
+ * view — it is a call, not autocapture.
497
+ *
498
+ * Advances navigation state even for an explicit call, so an app that drives pageviews by hand
499
+ * (no autocapture) still gets previous_url and counter — and claims the URL so autocapture
500
+ * cannot emit a second view for the same page.
501
+ */
502
+ pageInternal(name?: string, properties?: Properties, options?: PageOptions): void;
503
+ /**
504
+ * `$web_vitals`, once per page, on the first time the tab is hidden.
505
+ *
506
+ * Hidden rather than loaded, because three of the five are not final until then: LCP can be
507
+ * superseded by a later paint, CLS accumulates for the life of the page, and INP is the worst
508
+ * interaction so far. Reporting at load would under-report all three — worse than not reporting,
509
+ * because the numbers would look plausible.
510
+ *
511
+ * Once, not per hide: a tab switched away and back has the same page-load metrics, and a second
512
+ * event would double-count the page in every average built on it.
513
+ */
514
+ private emitWebVitals;
381
515
  /** Alias of page() — unified mobile naming. */
382
- screen(name?: string, properties?: Properties): void;
516
+ screen(name?: string, properties?: Properties, options?: PageOptions): void;
383
517
  identify(userId: string, traits?: Properties): void;
384
518
  alias(aliasId: string): void;
385
519
  reset(): void;
@@ -416,6 +550,19 @@ declare class DepsmithSdkClient {
416
550
  * Silently does nothing when nothing survives validation — a key claimed twice, a
417
551
  * non-finite `$add`, an empty map — since the schema forbids an empty operator object.
418
552
  */
553
+ /**
554
+ * Registers properties attached to every later event, surviving a reload.
555
+ *
556
+ * A property passed directly to `track()` wins over a registered one with the same key.
557
+ * `$`-prefixed keys are rejected, as everywhere else. Cleared by `reset()`.
558
+ */
559
+ register(properties: Properties): void;
560
+ /**
561
+ * Registers only keys that are not registered yet — for first-touch values like the plan a user
562
+ * signed up on, which a later state change must not overwrite.
563
+ */
564
+ registerOnce(properties: Properties): void;
565
+ unregister(key: string): void;
419
566
  setUserProperties(ops: UserPropertyOps): void;
420
567
  optIn(): void;
421
568
  optOut(): void;
@@ -535,8 +682,8 @@ declare class DepsmithSdkClient {
535
682
  declare const DepsmithSdk: {
536
683
  init(config: DepsmithSdkConfig, overrides?: InternalOverrides): DepsmithSdkClient | null;
537
684
  track: (name: string, properties?: Properties) => void;
538
- page: (name?: string, properties?: Properties) => void;
539
- screen: (name?: string, properties?: Properties) => void;
685
+ page: (name?: string, properties?: Properties, options?: PageOptions) => void;
686
+ screen: (name?: string, properties?: Properties, options?: PageOptions) => void;
540
687
  identify: (userId: string, traits?: Properties) => void;
541
688
  alias: (aliasId: string) => void;
542
689
  reset: () => void;
@@ -547,6 +694,11 @@ declare const DepsmithSdk: {
547
694
  unsetProperty: (key: string) => void;
548
695
  /** Applies the §14 operator set server-side: $set, $add, $append, $unset, $clear_all, … */
549
696
  setUserProperties: (ops: UserPropertyOps) => void;
697
+ /** Properties attached to every later event. A direct track() property wins over these. */
698
+ register: (properties: Properties) => void;
699
+ /** Only keys not registered yet — first-touch values a later state must not overwrite. */
700
+ registerOnce: (properties: Properties) => void;
701
+ unregister: (key: string) => void;
550
702
  optIn: () => void;
551
703
  optOut: () => void;
552
704
  flush: () => Promise<void>;
@@ -557,4 +709,4 @@ declare const DepsmithSdk: {
557
709
  shutdown(): void;
558
710
  };
559
711
 
560
- export { type AsyncKV, AsyncMirrorAdapter, type AutocaptureConfig, type BatchPayload, type ConsentState, DEPSMITH_SDK_STORAGE_KEYS, DepsmithSdk, DepsmithSdkClient, type DepsmithSdkConfig, type DepsmithSdkEvent, type EventContext, type EventType, type InternalOverrides, type KVStorage, type Properties, type PropertyValue, type Scheduler, type TrackingOptions, type UserPropertyOps, idleScheduler, syncScheduler };
712
+ export { type AsyncKV, AsyncMirrorAdapter, type AutocaptureConfig, type BatchPayload, type ConsentState, DEPSMITH_SDK_STORAGE_KEYS, DepsmithSdk, DepsmithSdkClient, type DepsmithSdkConfig, type DepsmithSdkEvent, type EventContext, type EventType, type InternalOverrides, type KVStorage, type PageLocation, type PageNames, type PageOptions, type Properties, type PropertyValue, type Scheduler, type TrackingOptions, type UserPropertyOps, idleScheduler, syncScheduler };