@decocms/blocks 8.16.1 → 8.18.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.
Files changed (112) hide show
  1. package/dist/v8/analytics/client.d.ts +48 -0
  2. package/dist/v8/analytics/client.d.ts.map +1 -0
  3. package/dist/v8/analytics/client.js +71 -0
  4. package/dist/v8/analytics/client.js.map +1 -0
  5. package/dist/v8/analytics/runtime/modules/click.d.ts +2 -0
  6. package/dist/v8/analytics/runtime/modules/click.d.ts.map +1 -0
  7. package/dist/v8/analytics/runtime/modules/click.js +48 -0
  8. package/dist/v8/analytics/runtime/modules/click.js.map +1 -0
  9. package/dist/v8/analytics/runtime/modules/commerce.d.ts +2 -0
  10. package/dist/v8/analytics/runtime/modules/commerce.d.ts.map +1 -0
  11. package/dist/v8/analytics/runtime/modules/commerce.js +41 -0
  12. package/dist/v8/analytics/runtime/modules/commerce.js.map +1 -0
  13. package/dist/v8/analytics/runtime/modules/consent.d.ts +33 -0
  14. package/dist/v8/analytics/runtime/modules/consent.d.ts.map +1 -0
  15. package/dist/v8/analytics/runtime/modules/consent.js +154 -0
  16. package/dist/v8/analytics/runtime/modules/consent.js.map +1 -0
  17. package/dist/v8/analytics/runtime/modules/deco.d.ts +2 -0
  18. package/dist/v8/analytics/runtime/modules/deco.d.ts.map +1 -0
  19. package/dist/v8/analytics/runtime/modules/deco.js +209 -0
  20. package/dist/v8/analytics/runtime/modules/deco.js.map +1 -0
  21. package/dist/v8/analytics/runtime/modules/engagement.d.ts +2 -0
  22. package/dist/v8/analytics/runtime/modules/engagement.d.ts.map +1 -0
  23. package/dist/v8/analytics/runtime/modules/engagement.js +128 -0
  24. package/dist/v8/analytics/runtime/modules/engagement.js.map +1 -0
  25. package/dist/v8/analytics/runtime/modules/errors.d.ts +2 -0
  26. package/dist/v8/analytics/runtime/modules/errors.d.ts.map +1 -0
  27. package/dist/v8/analytics/runtime/modules/errors.js +167 -0
  28. package/dist/v8/analytics/runtime/modules/errors.js.map +1 -0
  29. package/dist/v8/analytics/runtime/modules/heatmap.d.ts +2 -0
  30. package/dist/v8/analytics/runtime/modules/heatmap.d.ts.map +1 -0
  31. package/dist/v8/analytics/runtime/modules/heatmap.js +316 -0
  32. package/dist/v8/analytics/runtime/modules/heatmap.js.map +1 -0
  33. package/dist/v8/analytics/runtime/modules/vitals.d.ts +2 -0
  34. package/dist/v8/analytics/runtime/modules/vitals.d.ts.map +1 -0
  35. package/dist/v8/analytics/runtime/modules/vitals.js +119 -0
  36. package/dist/v8/analytics/runtime/modules/vitals.js.map +1 -0
  37. package/dist/v8/analytics/runtime/src/guards.d.ts +10 -0
  38. package/dist/v8/analytics/runtime/src/guards.d.ts.map +1 -0
  39. package/dist/v8/analytics/runtime/src/guards.js +70 -0
  40. package/dist/v8/analytics/runtime/src/guards.js.map +1 -0
  41. package/dist/v8/analytics/runtime/src/index.d.ts +2 -0
  42. package/dist/v8/analytics/runtime/src/index.d.ts.map +1 -0
  43. package/dist/v8/analytics/runtime/src/index.js +562 -0
  44. package/dist/v8/analytics/runtime/src/index.js.map +1 -0
  45. package/dist/v8/analytics/runtime/src/queue.d.ts +15 -0
  46. package/dist/v8/analytics/runtime/src/queue.d.ts.map +1 -0
  47. package/dist/v8/analytics/runtime/src/queue.js +36 -0
  48. package/dist/v8/analytics/runtime/src/queue.js.map +1 -0
  49. package/dist/v8/analytics/runtime/src/trim.d.ts +13 -0
  50. package/dist/v8/analytics/runtime/src/trim.d.ts.map +1 -0
  51. package/dist/v8/analytics/runtime/src/trim.js +38 -0
  52. package/dist/v8/analytics/runtime/src/trim.js.map +1 -0
  53. package/dist/v8/analytics/runtime/view/heat-core.d.ts +69 -0
  54. package/dist/v8/analytics/runtime/view/heat-core.d.ts.map +1 -0
  55. package/dist/v8/analytics/runtime/view/heat-core.js +314 -0
  56. package/dist/v8/analytics/runtime/view/heat-core.js.map +1 -0
  57. package/dist/v8/analytics/runtime/view/view.d.ts +51 -0
  58. package/dist/v8/analytics/runtime/view/view.d.ts.map +1 -0
  59. package/dist/v8/analytics/runtime/view/view.js +525 -0
  60. package/dist/v8/analytics/runtime/view/view.js.map +1 -0
  61. package/dist/v8/analytics/shared/anchor.d.ts +71 -0
  62. package/dist/v8/analytics/shared/anchor.d.ts.map +1 -0
  63. package/dist/v8/analytics/shared/anchor.js +155 -0
  64. package/dist/v8/analytics/shared/anchor.js.map +1 -0
  65. package/dist/v8/analytics/shared/contract.d.ts +294 -0
  66. package/dist/v8/analytics/shared/contract.d.ts.map +1 -0
  67. package/dist/v8/analytics/shared/contract.js +652 -0
  68. package/dist/v8/analytics/shared/contract.js.map +1 -0
  69. package/dist/v8/builtins/data.d.ts +20 -6
  70. package/dist/v8/builtins/data.d.ts.map +1 -1
  71. package/dist/v8/builtins/data.js +33 -8
  72. package/dist/v8/builtins/data.js.map +1 -1
  73. package/dist/v8/cms.js +2 -2
  74. package/dist/v8/cms.js.map +1 -1
  75. package/dist/v8/settings.d.ts +28 -9
  76. package/dist/v8/settings.d.ts.map +1 -1
  77. package/dist/v8/settings.js +6 -10
  78. package/dist/v8/settings.js.map +1 -1
  79. package/dist/v8/telemetry.d.ts +13 -11
  80. package/dist/v8/telemetry.d.ts.map +1 -1
  81. package/dist/v8/telemetry.js +27 -17
  82. package/dist/v8/telemetry.js.map +1 -1
  83. package/dist/v8/types.d.ts +7 -3
  84. package/dist/v8/types.d.ts.map +1 -1
  85. package/package.json +6 -1
  86. package/skills/deco-storefront-performance/references/render-location.md +3 -2
  87. package/skills/deco-v7-to-v8-migration/references/telemetry.md +1 -1
  88. package/skills/deco-v7-to-v8-migration/scripts/siteSettings.ts +1 -1
  89. package/src/v8/analytics/client.ts +110 -0
  90. package/src/v8/analytics/runtime/globals.d.ts +36 -0
  91. package/src/v8/analytics/runtime/modules/click.ts +54 -0
  92. package/src/v8/analytics/runtime/modules/commerce.ts +73 -0
  93. package/src/v8/analytics/runtime/modules/consent.ts +150 -0
  94. package/src/v8/analytics/runtime/modules/deco.ts +207 -0
  95. package/src/v8/analytics/runtime/modules/engagement.ts +140 -0
  96. package/src/v8/analytics/runtime/modules/errors.ts +217 -0
  97. package/src/v8/analytics/runtime/modules/heatmap.ts +360 -0
  98. package/src/v8/analytics/runtime/modules/vitals.ts +128 -0
  99. package/src/v8/analytics/runtime/src/guards.ts +70 -0
  100. package/src/v8/analytics/runtime/src/index.ts +606 -0
  101. package/src/v8/analytics/runtime/src/queue.ts +40 -0
  102. package/src/v8/analytics/runtime/src/trim.ts +39 -0
  103. package/src/v8/analytics/runtime/view/heat-core.ts +335 -0
  104. package/src/v8/analytics/runtime/view/view.ts +596 -0
  105. package/src/v8/analytics/shared/anchor.ts +171 -0
  106. package/src/v8/analytics/shared/contract.ts +691 -0
  107. package/src/v8/analytics/tsconfig.json +14 -0
  108. package/src/v8/builtins/data.ts +44 -9
  109. package/src/v8/cms.ts +4 -4
  110. package/src/v8/settings.ts +13 -16
  111. package/src/v8/telemetry.ts +33 -29
  112. package/src/v8/types.ts +7 -3
@@ -160,9 +160,9 @@ export interface Telemetry {
160
160
  enabled?: boolean;
161
161
  /** Default `true`. */
162
162
  metrics?: boolean;
163
- /** Default 0.05, capped by `telemetry.limits`. */
163
+ /** 0 to 1. When not saved: `telemetry.defaults` from code, else 0.05. */
164
164
  errorSampleRate?: number;
165
- /** Default 0, capped by `telemetry.limits`. */
165
+ /** 0 to 1. When not saved: `telemetry.defaults` from code, else 0. */
166
166
  traceSampleRate?: number;
167
167
  }
168
168
  /** The `analytics` section of the CMS settings, and `AnalyticsScript`'s props. */
@@ -219,7 +219,11 @@ export interface TelemetryConfig {
219
219
  * `service.version`, `deployment.environment.name`, …).
220
220
  */
221
221
  resource?: Record<string, string>;
222
- limits?: {
222
+ /**
223
+ * The sample rates when the `telemetry` section of the CMS settings saves
224
+ * none (built-in: 0.05 and 0). A rate content saves wins, from 0 to 1.
225
+ */
226
+ defaults?: {
223
227
  errorSampleRate?: number;
224
228
  traceSampleRate?: number;
225
229
  };
@@ -1 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,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;IAC3D;;;OAGG;IACH,WAAW,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC,CAAC;CAC3D"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decocms/blocks",
3
- "version": "8.16.1",
3
+ "version": "8.18.0",
4
4
  "type": "module",
5
5
  "engines": {
6
6
  "node": ">=24"
@@ -68,6 +68,11 @@
68
68
  "source": "./src/v8/analytics.ts",
69
69
  "default": "./dist/v8/analytics.js"
70
70
  },
71
+ "./analytics/client": {
72
+ "types": "./dist/v8/analytics/client.d.ts",
73
+ "source": "./src/v8/analytics/client.ts",
74
+ "default": "./dist/v8/analytics/client.js"
75
+ },
71
76
  "./cli": {
72
77
  "types": "./dist/v8/cli/index.d.ts",
73
78
  "source": "./src/v8/cli/index.ts",
@@ -43,8 +43,9 @@ not the absolute numbers.
43
43
  In production, the same data exists as telemetry spans: when a trace is sampled, every
44
44
  block run becomes a span named after its block type, with `deco.block.type`. Sampling
45
45
  is off by default. It needs a telemetry destination (a `token` or a `telemetry.endpoint`
46
- on `createCMS`), the cap `createCMS({ telemetry: { limits: { traceSampleRate } } })`
47
- (default 0), and `telemetry.traceSampleRate` in the saved `CMS` block (default 0).
46
+ on `createCMS`) and a trace rate: `telemetry.traceSampleRate` in the saved `CMS` block,
47
+ which wins, else code's `createCMS({ telemetry: { defaults: { traceSampleRate } } })`
48
+ (both default 0).
48
49
 
49
50
  ## 2. A prop resolved eagerly and then thrown away
50
51
 
@@ -4,7 +4,7 @@ From the site migrations; the sites and what the commit hashes refer to are list
4
4
 
5
5
  - Telemetry is explicit params only: the SDK reads no environment variable (`OTEL_*` and v7's `DECO_OTEL_*` are ignored). A site that kept a collector reads its own variables and passes `telemetry: { endpoint, headers }`; with `createCMS({ site, token })` and no `endpoint`, telemetry goes to the hosted collector (a `token` without `site` is a configuration error). Pass `telemetry: false` in dev or parity runs (`89eae7d`). v7's per-signal `DECO_OTEL_{METRICS,LOGS,TRACES}_ENDPOINT` have no v8 equivalent: every signal goes to `<endpoint>/v1/<signal>`.
6
6
  - **New telemetry is a behaviour change.** A site with its own OpenTelemetry export that v7 never fed CMS telemetry starts sending it once `telemetry` points at that collector. List the new traffic for the product owner.
7
- - `service.name`, `service.version` and `deployment.environment.name` come from `telemetry.resource`, on the hosted collector too (`telemetry: { resource }` without `endpoint`). v7 took them from `DECO_SITE_NAME`, the `CF_VERSION_METADATA` binding and `DECO_ENV_NAME`: keep the `version_metadata` binding in `wrangler.jsonc`, read the three in the site and pass them (or a Vite `define` of the commit). Vars left in `wrangler.jsonc` that nothing reads are dead config a reviewer will flag. v7's `DECO_OTEL_ERROR_PROMOTION_RATE` becomes `errorSampleRate` in `CMS.json`'s telemetry section (default 0.05, capped by `telemetry.limits`, default 0.1); `DECO_OTEL_LOGS_MIN_LEVEL` has no equivalent (v8 sends error logs only): list it.
7
+ - `service.name`, `service.version` and `deployment.environment.name` come from `telemetry.resource`, on the hosted collector too (`telemetry: { resource }` without `endpoint`). v7 took them from `DECO_SITE_NAME`, the `CF_VERSION_METADATA` binding and `DECO_ENV_NAME`: keep the `version_metadata` binding in `wrangler.jsonc`, read the three in the site and pass them (or a Vite `define` of the commit). Vars left in `wrangler.jsonc` that nothing reads are dead config a reviewer will flag. v7's `DECO_OTEL_ERROR_PROMOTION_RATE` becomes `errorSampleRate` in `CMS.json`'s telemetry section (default 0.05, which wins over code's `telemetry.defaults`; there's no cap); `DECO_OTEL_LOGS_MIN_LEVEL` has no equivalent (v8 sends error logs only): list it.
8
8
  - **Local development and hosted releases.** `createCMS` reads no `NODE_ENV` and has no `dev` option. With `site`, content always comes from the CDN, on the dev server too; without `site`, it is the `content` the site passes. Passing both throws. A site that wants local files in dev picks one or the other in its own code.
9
9
  - **v7 Workers bindings with no v8 writer.** v7's `instrumentWorker` wrote per-route request counts, edge cache hit/miss and request duration to an Analytics Engine dataset (`DECO_METRICS`) and read `CF_VERSION_METADATA`. In v8, `createDecoWorker` records every request as `http.server.request.duration` (seconds) in the CMS's own telemetry, with `http.route` (the content's page template, `redirect` for every CMS redirect, a fixed one such as `/_serverFn/*` or `/assets/*`, else `unmatched`), `http.request.method`, `status_class`, `cache` (`DRAFT` for a preview, else from the `X-Cache` the site's `pageCache` answers: `HIT`/`MISS`/`BYPASS`) and `device`; with no `token` and no `endpoint` it records nothing. On Next.js, `export { register } from "@decocms/nextjs/instrumentation"` in `instrumentation.ts` records the same metric from Next's own request span: `http.route` is Next's route template (`/[[...path]]`, `/_draft/[[...path]]`; RSC requests under their page's), `cache` is `DRAFT` for a draft render and otherwise `BYPASS` (Next's `x-nextjs-cache` is not visible to the span), no `device`; responses the proxy answers itself are not counted and Edge routes are `unmatched`. A site with its own OpenTelemetry SDK (`@vercel/otel`) adds `serverRequestSpanProcessor()` to its span processors instead. Both bindings record through `recordServerRequest` from `@decocms/blocks/metrics`; a site never imports it (and `@decocms/blocks/fetch` is only `createInstrumentedFetch`). Nothing writes `DECO_METRICS`; a site that still wants it writes there from its worker entry's `pageCache` (it knows the profile and the decision). Don't keep a binding nothing writes, and don't drop one silently: list each by name (and the edge layer's `deco.cache.requests` counter) as a product decision in the PR.
10
10
  - Analytics: `AnalyticsScript` with `(await cms.settings()).analytics` plus `track` replace OneDollarStats (the collector lives in the `analytics` section of `CMS.json`); it sends collector beacons directly instead of loading the SDK (`4a50b13`, blog `9e97455`).
@@ -241,7 +241,7 @@ export function foldSiteSettings(root: string, report: Report): void {
241
241
  step: "settings",
242
242
  subject: "DECO_OTEL_* sampling",
243
243
  message:
244
- "if your hosting sets sampling variables, move them to the telemetry section's errorSampleRate and traceSampleRate, within the limits in code (/next/telemetry#sampling)",
244
+ "if your hosting sets sampling variables, move them to the telemetry section's errorSampleRate and traceSampleRate, which win over code's telemetry.defaults (/next/telemetry#sampling)",
245
245
  },
246
246
  {
247
247
  step: "settings",
@@ -0,0 +1,110 @@
1
+ /**
2
+ * `@decocms/blocks/analytics/client`: the Deco Analytics client for a v8 site,
3
+ * without the external tag. It runs the same files decocms/analytics bundles
4
+ * into `/_dq/a.js` (core, then each module), so identification, the queue,
5
+ * the transport and the automatic collection have one implementation for both.
6
+ *
7
+ * Importing this module does nothing: no DOM access, safe on the server.
8
+ * `startAnalytics()` does the work in the browser and never rejects, so a
9
+ * failure is "analytics stopped", never "the page broke".
10
+ */
11
+
12
+ /** The optional modules, by the names the collector's site config uses. */
13
+ export type AnalyticsModule =
14
+ | "click"
15
+ | "commerce"
16
+ | "consent"
17
+ | "deco"
18
+ | "engagement"
19
+ | "errors"
20
+ | "heatmap"
21
+ | "vitals";
22
+
23
+ export interface AnalyticsClientOptions {
24
+ /** Modules to load after core, in this order. Default none: core alone collects page views. */
25
+ modules?: AnalyticsModule[];
26
+ /**
27
+ * Where events go. Default `/_dq/e` on the page's own host, which is what makes the
28
+ * collector resolve the site from the `Host` header, the only resolution billing trusts.
29
+ */
30
+ endpoint?: string;
31
+ /** The site's declared key, for a host the collector can't resolve. Its events are `tag`-grade. */
32
+ key?: string;
33
+ /** Share of sheddable events to keep, 0 to 1. Core events (`$…`) are always kept. */
34
+ sampling?: number;
35
+ /** 1 lets the consent module keep a stable id once the visitor consents. Default 0. */
36
+ tier?: 0 | 1;
37
+ /** The site routes on `location.hash`, so a hash change is a page view. */
38
+ hash?: boolean;
39
+ /** Collect on a development host too (localhost, private ranges). */
40
+ dev?: boolean;
41
+ /** Heatmap module: share of page views it samples, 0 to 1. */
42
+ heatmapRate?: number;
43
+ /** Errors module: cross-origin script hosts that count as the site's own. */
44
+ errorHosts?: string[];
45
+ }
46
+
47
+ /** One loader per file, so a bundler splits each module into its own chunk. */
48
+ const MODULES: Record<AnalyticsModule, () => Promise<unknown>> = {
49
+ click: () => import("./runtime/modules/click.ts"),
50
+ commerce: () => import("./runtime/modules/commerce.ts"),
51
+ consent: () => import("./runtime/modules/consent.ts"),
52
+ deco: () => import("./runtime/modules/deco.ts"),
53
+ engagement: () => import("./runtime/modules/engagement.ts"),
54
+ errors: () => import("./runtime/modules/errors.ts"),
55
+ heatmap: () => import("./runtime/modules/heatmap.ts"),
56
+ vitals: () => import("./runtime/modules/vitals.ts"),
57
+ };
58
+
59
+ /**
60
+ * Starts collection in the browser: the page view now and on every client-side
61
+ * navigation, plus whatever the modules collect. Call it once, after the page is
62
+ * interactive; nothing visual should wait on it. Resolves to the client's API
63
+ * (`track`, `pageview`, the modules' helpers such as `addToCart`), or null on the
64
+ * server, when collection is off for this visitor (automation, opt-out, a
65
+ * development host) or when anything failed.
66
+ *
67
+ * If the external tag already booted on this page, it is left alone and its API
68
+ * is returned: one client per page, whichever came first.
69
+ */
70
+ export async function startAnalytics(
71
+ options: AnalyticsClientOptions = {},
72
+ ): Promise<Record<string, unknown> | null> {
73
+ if (typeof window === "undefined") return null;
74
+ const w = window as unknown as Record<string, any>;
75
+ try {
76
+ if (w.__dqBooted) return typeof w.__dq?.track === "function" ? w.__dq : null;
77
+
78
+ // The same fields the collector writes ahead of `/_dq/a.js`, and the same precedence: what
79
+ // the page already set on `window.__dq` wins. `q` is held back and replayed below, once
80
+ // every module has registered: core replays its stub in a microtask, and a module in its
81
+ // own chunk arrives later than that, so a helper queued before boot would be dropped.
82
+ const page = (w.__dq ?? {}) as Record<string, unknown>;
83
+ const queued = Array.isArray(page.q) ? [...page.q] : [];
84
+ w.__dq = Object.assign(
85
+ {
86
+ s: "unknown",
87
+ e: options.endpoint ?? "/_dq/e",
88
+ r: options.sampling ?? 1,
89
+ tier: options.tier ?? 0,
90
+ ...(options.hash ? { hash: 1 } : {}),
91
+ ...(options.dev ? { dev: true } : {}),
92
+ ...(options.key ? { k: options.key } : {}),
93
+ ...(options.heatmapRate !== undefined ? { hr: options.heatmapRate } : {}),
94
+ ...(options.errorHosts?.length ? { er: options.errorHosts } : {}),
95
+ },
96
+ page,
97
+ { q: [] },
98
+ );
99
+
100
+ await import("./runtime/src/index.ts");
101
+ // Core assigns its API only when it collects; skipped means skipped, modules included.
102
+ if (typeof w.__dq.track !== "function") return null;
103
+
104
+ for (const name of new Set(options.modules ?? [])) await MODULES[name]?.();
105
+ for (const r of queued) w.__dq.q?.push?.(r);
106
+ return w.__dq;
107
+ } catch {
108
+ return null;
109
+ }
110
+ }
@@ -0,0 +1,36 @@
1
+ // The seam optional modules attach through. Declared once, ambiently, so a module does
2
+ // not have to redeclare `window` as `any` just to reach it — which is what commerce.ts
3
+ // did, and it disabled every other type check in the file as a side effect.
4
+ interface Window {
5
+ __dqRegister?: (
6
+ fn: (
7
+ enqueue: EnqueueFn,
8
+ api: Record<string, unknown>,
9
+ /** Register work to run just BEFORE the last flush of a page load. A module that
10
+ * only knows its value at the end — scroll depth, the vitals, accumulated error
11
+ * repeats — contributes here rather than spending a request of its own. */
12
+ onFinal: (hook: () => void) => void,
13
+ /** Register work to run when an SPA navigation changes the URL, BEFORE the new
14
+ * `$pageview`, with the path being left. A per-view measurement closes its view here. */
15
+ onRoute: (hook: (prev: string) => void) => void,
16
+ ) => void,
17
+ ) => void;
18
+ __dq?: Record<string, unknown>;
19
+ __dqAllowAutomation?: boolean;
20
+ /** Set by `boot()` so a second copy of this bundle on the same page does nothing. Two
21
+ * identical script tags both execute -- the browser reuses the cached resource, not the
22
+ * execution -- and that is two pageviews for one page load. */
23
+ __dqBooted?: boolean;
24
+ }
25
+
26
+ type EnqueueFn = (
27
+ name: string,
28
+ props?: Record<string, string | number | boolean>,
29
+ extra?: Record<string, unknown>,
30
+ /** Send this event NOW instead of letting it batch. The module that owns an event is the
31
+ * only thing that can judge what losing it costs, and core must not learn event names to
32
+ * decide -- a name check in core put the word "purchase" in the bundle served to sites
33
+ * that do not have the commerce module. Costs one request, so it is for events whose loss
34
+ * is not recoverable from anything else: `purchase`, and so far nothing else. */
35
+ urgent?: boolean,
36
+ ) => void;
@@ -0,0 +1,54 @@
1
+ /** A/B testing interaction capture: per-click telemetry for whichever elements a site
2
+ * wants scored against an experiment variant.
3
+ *
4
+ * Not tied to a specific experiment id in the payload -- `enqueue` already merges
5
+ * `cfg.x` (the map `setExperiment` builds) into every event, so `exp` on this row is
6
+ * free. Carrying it again here would duplicate a column this event already gets by
7
+ * riding the same pipe as everything else.
8
+ *
9
+ * `engagement.ts` already tracks outbound/download clicks unconditionally, because
10
+ * those are a fixed, small vocabulary. Clicks in general are not: GA4 sends one event
11
+ * per click with no cap, which is the shape this module exists to avoid repeating.
12
+ */
13
+ import { LIMITS } from "../../shared/contract.ts";
14
+
15
+ const CAPTURE_PHASE: Record<number, string> = {
16
+ 1: "capturing",
17
+ 2: "at_target",
18
+ 3: "bubbling",
19
+ };
20
+
21
+ window.__dqRegister?.((enqueue) => {
22
+ // Same reasoning as engagement's outbound cap: an experiment CTA rage-clicked ten
23
+ // times is one fact about that click, not ten rows.
24
+ const MAX_CLICKS = 30;
25
+ let sent = 0;
26
+
27
+ addEventListener(
28
+ "click",
29
+ (event: MouseEvent) => {
30
+ if (sent >= MAX_CLICKS) return;
31
+ const el = event.target as Element | null;
32
+ if (!el) return;
33
+ sent++;
34
+
35
+ const classList = el.classList ? [...el.classList].slice(0, 5).join(" ") : "";
36
+
37
+ enqueue("experiment_click", {
38
+ capture_phase: CAPTURE_PHASE[event.eventPhase] ?? "none",
39
+ // Viewport, for reading `page_x`/`page_y` as a fraction of what the visitor could
40
+ // actually see -- document size, not screen size, is a separate question nobody
41
+ // asked here.
42
+ viewport_width: window.innerWidth || document.documentElement.clientWidth || 0,
43
+ viewport_height: window.innerHeight || document.documentElement.clientHeight || 0,
44
+ page_x: Math.round(event.pageX),
45
+ page_y: Math.round(event.pageY),
46
+ element_type: el.tagName?.toLowerCase() ?? "",
47
+ element_id: el.id ?? "",
48
+ element_class: classList.slice(0, LIMITS.valueLen),
49
+ is_trusted: event.isTrusted,
50
+ });
51
+ },
52
+ { capture: true, passive: true },
53
+ );
54
+ });
@@ -0,0 +1,73 @@
1
+ /** Commerce is a module, not core.
2
+ *
3
+ * These helpers are sugar over `track`: `addToCart({...})` and
4
+ * `track("add_to_cart", {...})` produce the identical event. Their value is type safety
5
+ * and IDE discovery, which is a build-time concern — so the core has no reason to carry
6
+ * them, and a site that never sells anything has no reason to download them.
7
+ *
8
+ * Event names are GA4's, because the deco framework already emits those and existing
9
+ * experiment queries already join on them. Whoever prescribes a different vocabulary
10
+ * fragments the market rather than unifying it — Segment calls this `Product Added`. */
11
+ type Primitive = string | number | boolean;
12
+ type Props = Record<string, Primitive>;
13
+
14
+ type Money = {
15
+ value?: number;
16
+ currency?: string;
17
+ items?: number;
18
+ itemIds?: string[];
19
+ props?: Props;
20
+ };
21
+
22
+ window.__dqRegister?.((enqueue, api: Record<string, unknown>) => {
23
+ const of =
24
+ (name: string) =>
25
+ (m: Money = {}) =>
26
+ enqueue(name, m.props, {
27
+ value: m.value,
28
+ currency: m.currency,
29
+ items_count: m.items,
30
+ item_ids: m.itemIds,
31
+ });
32
+
33
+ api.viewItemList = of("view_item_list");
34
+ api.selectItem = of("select_item");
35
+ api.viewItem = of("view_item");
36
+ api.addToCart = of("add_to_cart");
37
+ api.removeFromCart = of("remove_from_cart");
38
+ api.beginCheckout = of("begin_checkout");
39
+
40
+ /** transaction_id is what stops a purchase being counted twice when the customer
41
+ * reloads the confirmation page — the most common e-commerce analytics bug, and one
42
+ * that lands straight in reported revenue.
43
+ *
44
+ * URGENT, the last argument. Core flushes the first event of a page load and then
45
+ * batches until 50 events, `flushMs` (10s), or the page ending — the right trade for a
46
+ * scroll depth and the wrong one for money. Most visits are shorter than ten seconds,
47
+ * so a purchase in a short session rides entirely on a beacon fired while the page is
48
+ * being torn down, and that beacon is what a slow device is worst at. Measured on the CI
49
+ * runner, which is slower than a laptop and therefore closer to a real phone: a purchase
50
+ * fired and the tab closed stored nothing, intermittently, while passing every time on a
51
+ * laptop.
52
+ *
53
+ * The cost is bounded by CONVERSIONS rather than by traffic — at most one extra request
54
+ * per visit, on the small fraction of visits that convert. Deliberately not the other
55
+ * six: an abandoned cart is a funnel number, and losing a funnel number is not losing
56
+ * revenue. A cart that precedes a purchase in the same queue rides along anyway, because
57
+ * a flush drains the queue rather than one event. */
58
+ api.purchase = (m: Money & { transactionId: string }) =>
59
+ enqueue(
60
+ "purchase",
61
+ m.props,
62
+ {
63
+ value: m.value,
64
+ currency: m.currency,
65
+ items_count: m.items,
66
+ item_ids: m.itemIds,
67
+ transaction_id: m.transactionId,
68
+ },
69
+ true,
70
+ );
71
+ });
72
+
73
+ export {};
@@ -0,0 +1,150 @@
1
+ /** Consent, and the stable identifier it unlocks.
2
+ *
3
+ * At tier 0 — the default, and what every site runs today — there is no consent to ask
4
+ * for and nothing here does anything. Identity is an HMAC over a salt the Worker rotates
5
+ * and deletes every day, which is what makes the collector cookieless and is the same
6
+ * design Plausible ships. Its cost is that the same person is a new identifier tomorrow,
7
+ * so retention cannot be measured at all.
8
+ *
9
+ * Tier 1 buys that back, and only where a visitor has actually agreed. We deliberately do
10
+ * NOT ship a banner: every serious storefront already runs a CMP — farmrio loads OneTrust,
11
+ * 898 KB of it — and a second prompt would ask the visitor twice while leaving it
12
+ * ambiguous which consent governs. So this listens for the consent that already exists
13
+ * and adds an explicit call for sites whose banner is homegrown.
14
+ *
15
+ * Three sources, in the order a site is likely to have them:
16
+ * 1. `__dq.consent(true|false)` — explicit, and always wins
17
+ * 2. IAB TCF v2 `__tcfapi` — what OneTrust and Cookiebot expose
18
+ * 3. Google Consent Mode — `analytics_storage` on the dataLayer, for GTM sites
19
+ */
20
+
21
+ const KEY = "_dq_cid";
22
+
23
+ type Listener = (granted: boolean) => void;
24
+ const listeners: Listener[] = [];
25
+ let granted: boolean | null = null; // null = not yet known, which is not "no"
26
+
27
+ /** A random identifier, not derived from anything about the visitor. It is a label the
28
+ * browser carries, so it can be deleted by the visitor and is meaningless anywhere else.
29
+ * The Worker hashes it with the site before storing, so the same browser is a different
30
+ * identifier on each customer's site — without that we would have built the cross-client
31
+ * identity graph that tier 0 exists to avoid. */
32
+ function mint(): string {
33
+ const b = new Uint8Array(16);
34
+ (globalThis.crypto ?? ({} as Crypto)).getRandomValues?.(b);
35
+ return Array.from(b, (x) => x.toString(16).padStart(2, "0")).join("");
36
+ }
37
+
38
+ function store(): Storage | null {
39
+ try {
40
+ return window.localStorage;
41
+ } catch {
42
+ return null;
43
+ } // blocked in some privacy modes
44
+ }
45
+
46
+ /** The stable id, or "" when there is no consent. Reading this never creates one: an id
47
+ * minted before consent arrived is a persistent identifier set without permission, which
48
+ * is the exact thing consent is being asked about. */
49
+ export function clientId(): string {
50
+ if (granted !== true) return "";
51
+ const s = store();
52
+ if (!s) return "";
53
+ let v = "";
54
+ try {
55
+ v = s.getItem(KEY) ?? "";
56
+ } catch {
57
+ return "";
58
+ }
59
+ if (!v || v.length !== 32) {
60
+ v = mint();
61
+ try {
62
+ s.setItem(KEY, v);
63
+ } catch {
64
+ return "";
65
+ }
66
+ }
67
+ return v;
68
+ }
69
+
70
+ /** Withdrawal has to erase, not merely stop sending. A visitor who says no and still finds
71
+ * the identifier in their browser was not given a choice, they were given a checkbox. */
72
+ function forget() {
73
+ try {
74
+ store()?.removeItem(KEY);
75
+ } catch {
76
+ /* nothing to do about it */
77
+ }
78
+ }
79
+
80
+ export function setConsent(v: boolean) {
81
+ if (granted === v) return;
82
+ granted = v;
83
+ if (!v) forget();
84
+ for (const fn of listeners) {
85
+ try {
86
+ fn(v);
87
+ } catch {
88
+ /* one listener must not stop another */
89
+ }
90
+ }
91
+ }
92
+
93
+ export function onConsent(fn: Listener) {
94
+ listeners.push(fn);
95
+ }
96
+ export function consentKnown(): boolean {
97
+ return granted !== null;
98
+ }
99
+
100
+ /** Wires up whichever CMP is present. Safe to call when none is: every branch is guarded,
101
+ * and a site with no banner simply never grants, which leaves it at tier 0. */
102
+ export function watchConsent(w: any) {
103
+ // 1. Google Consent Mode. GTM sites push `['consent', 'update', {analytics_storage}]`,
104
+ // and the state may already be on the dataLayer before we load.
105
+ const dl = w.dataLayer;
106
+ if (Array.isArray(dl)) {
107
+ const read = (a: any) => {
108
+ if (a?.[0] === "consent" && (a[1] === "update" || a[1] === "default") && a[2]) {
109
+ if (a[2].analytics_storage === "granted") setConsent(true);
110
+ else if (a[2].analytics_storage === "denied") setConsent(false);
111
+ }
112
+ };
113
+ for (const a of dl) read(a);
114
+ const push = dl.push.bind(dl);
115
+ dl.push = function (...args: any[]) {
116
+ try {
117
+ read(args[0]);
118
+ } catch {
119
+ /* keep GTM working */
120
+ }
121
+ return push(...args);
122
+ };
123
+ }
124
+
125
+ // 2. IAB TCF v2. Purpose 1 is "store and access information on a device", which is
126
+ // exactly what an identifier in localStorage is — not purpose 8 (measurement), which
127
+ // covers what we do with it once stored.
128
+ if (typeof w.__tcfapi === "function") {
129
+ try {
130
+ w.__tcfapi("addEventListener", 2, (data: any, ok: boolean) => {
131
+ if (!ok || !data) return;
132
+ if (data.eventStatus !== "tcloaded" && data.eventStatus !== "useractioncomplete") return;
133
+ setConsent(Boolean(data.purpose?.consents?.[1]));
134
+ });
135
+ } catch {
136
+ /* a CMP that throws is a CMP that has not granted */
137
+ }
138
+ }
139
+ }
140
+
141
+ // Registered like every other module: core exposes the hook, this fills it in. A site at
142
+ // tier 0 downloads none of this — the same rule that keeps `commerce` off a blog.
143
+ window.__dqRegister?.((_enqueue, api: Record<string, unknown>) => {
144
+ watchConsent(window as any);
145
+ (window as any).__dqCid = clientId;
146
+ // Overrides the core no-op, so a homegrown banner has something to call.
147
+ api.consent = (v: unknown) => setConsent(Boolean(v));
148
+ });
149
+
150
+ export const CONSENT_KEY = KEY;