@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.
- package/dist/v8/analytics/client.d.ts +48 -0
- package/dist/v8/analytics/client.d.ts.map +1 -0
- package/dist/v8/analytics/client.js +71 -0
- package/dist/v8/analytics/client.js.map +1 -0
- package/dist/v8/analytics/runtime/modules/click.d.ts +2 -0
- package/dist/v8/analytics/runtime/modules/click.d.ts.map +1 -0
- package/dist/v8/analytics/runtime/modules/click.js +48 -0
- package/dist/v8/analytics/runtime/modules/click.js.map +1 -0
- package/dist/v8/analytics/runtime/modules/commerce.d.ts +2 -0
- package/dist/v8/analytics/runtime/modules/commerce.d.ts.map +1 -0
- package/dist/v8/analytics/runtime/modules/commerce.js +41 -0
- package/dist/v8/analytics/runtime/modules/commerce.js.map +1 -0
- package/dist/v8/analytics/runtime/modules/consent.d.ts +33 -0
- package/dist/v8/analytics/runtime/modules/consent.d.ts.map +1 -0
- package/dist/v8/analytics/runtime/modules/consent.js +154 -0
- package/dist/v8/analytics/runtime/modules/consent.js.map +1 -0
- package/dist/v8/analytics/runtime/modules/deco.d.ts +2 -0
- package/dist/v8/analytics/runtime/modules/deco.d.ts.map +1 -0
- package/dist/v8/analytics/runtime/modules/deco.js +209 -0
- package/dist/v8/analytics/runtime/modules/deco.js.map +1 -0
- package/dist/v8/analytics/runtime/modules/engagement.d.ts +2 -0
- package/dist/v8/analytics/runtime/modules/engagement.d.ts.map +1 -0
- package/dist/v8/analytics/runtime/modules/engagement.js +128 -0
- package/dist/v8/analytics/runtime/modules/engagement.js.map +1 -0
- package/dist/v8/analytics/runtime/modules/errors.d.ts +2 -0
- package/dist/v8/analytics/runtime/modules/errors.d.ts.map +1 -0
- package/dist/v8/analytics/runtime/modules/errors.js +167 -0
- package/dist/v8/analytics/runtime/modules/errors.js.map +1 -0
- package/dist/v8/analytics/runtime/modules/heatmap.d.ts +2 -0
- package/dist/v8/analytics/runtime/modules/heatmap.d.ts.map +1 -0
- package/dist/v8/analytics/runtime/modules/heatmap.js +316 -0
- package/dist/v8/analytics/runtime/modules/heatmap.js.map +1 -0
- package/dist/v8/analytics/runtime/modules/vitals.d.ts +2 -0
- package/dist/v8/analytics/runtime/modules/vitals.d.ts.map +1 -0
- package/dist/v8/analytics/runtime/modules/vitals.js +119 -0
- package/dist/v8/analytics/runtime/modules/vitals.js.map +1 -0
- package/dist/v8/analytics/runtime/src/guards.d.ts +10 -0
- package/dist/v8/analytics/runtime/src/guards.d.ts.map +1 -0
- package/dist/v8/analytics/runtime/src/guards.js +70 -0
- package/dist/v8/analytics/runtime/src/guards.js.map +1 -0
- package/dist/v8/analytics/runtime/src/index.d.ts +2 -0
- package/dist/v8/analytics/runtime/src/index.d.ts.map +1 -0
- package/dist/v8/analytics/runtime/src/index.js +562 -0
- package/dist/v8/analytics/runtime/src/index.js.map +1 -0
- package/dist/v8/analytics/runtime/src/queue.d.ts +15 -0
- package/dist/v8/analytics/runtime/src/queue.d.ts.map +1 -0
- package/dist/v8/analytics/runtime/src/queue.js +36 -0
- package/dist/v8/analytics/runtime/src/queue.js.map +1 -0
- package/dist/v8/analytics/runtime/src/trim.d.ts +13 -0
- package/dist/v8/analytics/runtime/src/trim.d.ts.map +1 -0
- package/dist/v8/analytics/runtime/src/trim.js +38 -0
- package/dist/v8/analytics/runtime/src/trim.js.map +1 -0
- package/dist/v8/analytics/runtime/view/heat-core.d.ts +69 -0
- package/dist/v8/analytics/runtime/view/heat-core.d.ts.map +1 -0
- package/dist/v8/analytics/runtime/view/heat-core.js +314 -0
- package/dist/v8/analytics/runtime/view/heat-core.js.map +1 -0
- package/dist/v8/analytics/runtime/view/view.d.ts +51 -0
- package/dist/v8/analytics/runtime/view/view.d.ts.map +1 -0
- package/dist/v8/analytics/runtime/view/view.js +525 -0
- package/dist/v8/analytics/runtime/view/view.js.map +1 -0
- package/dist/v8/analytics/shared/anchor.d.ts +71 -0
- package/dist/v8/analytics/shared/anchor.d.ts.map +1 -0
- package/dist/v8/analytics/shared/anchor.js +155 -0
- package/dist/v8/analytics/shared/anchor.js.map +1 -0
- package/dist/v8/analytics/shared/contract.d.ts +294 -0
- package/dist/v8/analytics/shared/contract.d.ts.map +1 -0
- package/dist/v8/analytics/shared/contract.js +652 -0
- package/dist/v8/analytics/shared/contract.js.map +1 -0
- package/dist/v8/builtins/data.d.ts +20 -6
- package/dist/v8/builtins/data.d.ts.map +1 -1
- package/dist/v8/builtins/data.js +33 -8
- package/dist/v8/builtins/data.js.map +1 -1
- package/dist/v8/cms.js +2 -2
- package/dist/v8/cms.js.map +1 -1
- package/dist/v8/settings.d.ts +28 -9
- package/dist/v8/settings.d.ts.map +1 -1
- package/dist/v8/settings.js +6 -10
- package/dist/v8/settings.js.map +1 -1
- package/dist/v8/telemetry.d.ts +13 -11
- package/dist/v8/telemetry.d.ts.map +1 -1
- package/dist/v8/telemetry.js +27 -17
- package/dist/v8/telemetry.js.map +1 -1
- package/dist/v8/types.d.ts +7 -3
- package/dist/v8/types.d.ts.map +1 -1
- package/package.json +6 -1
- package/skills/deco-storefront-performance/references/render-location.md +3 -2
- package/skills/deco-v7-to-v8-migration/references/telemetry.md +1 -1
- package/skills/deco-v7-to-v8-migration/scripts/siteSettings.ts +1 -1
- package/src/v8/analytics/client.ts +110 -0
- package/src/v8/analytics/runtime/globals.d.ts +36 -0
- package/src/v8/analytics/runtime/modules/click.ts +54 -0
- package/src/v8/analytics/runtime/modules/commerce.ts +73 -0
- package/src/v8/analytics/runtime/modules/consent.ts +150 -0
- package/src/v8/analytics/runtime/modules/deco.ts +207 -0
- package/src/v8/analytics/runtime/modules/engagement.ts +140 -0
- package/src/v8/analytics/runtime/modules/errors.ts +217 -0
- package/src/v8/analytics/runtime/modules/heatmap.ts +360 -0
- package/src/v8/analytics/runtime/modules/vitals.ts +128 -0
- package/src/v8/analytics/runtime/src/guards.ts +70 -0
- package/src/v8/analytics/runtime/src/index.ts +606 -0
- package/src/v8/analytics/runtime/src/queue.ts +40 -0
- package/src/v8/analytics/runtime/src/trim.ts +39 -0
- package/src/v8/analytics/runtime/view/heat-core.ts +335 -0
- package/src/v8/analytics/runtime/view/view.ts +596 -0
- package/src/v8/analytics/shared/anchor.ts +171 -0
- package/src/v8/analytics/shared/contract.ts +691 -0
- package/src/v8/analytics/tsconfig.json +14 -0
- package/src/v8/builtins/data.ts +44 -9
- package/src/v8/cms.ts +4 -4
- package/src/v8/settings.ts +13 -16
- package/src/v8/telemetry.ts +33 -29
- package/src/v8/types.ts +7 -3
|
@@ -0,0 +1,562 @@
|
|
|
1
|
+
import { LIMITS, WIRE, CAMPAIGN_KEYS, campaignKey, isSampleable, } from "../../shared/contract.js";
|
|
2
|
+
import { trimProps } from "./trim.js";
|
|
3
|
+
import { BoundedQueue } from "./queue.js";
|
|
4
|
+
import { shouldSkip, whenVisible } from "./guards.js";
|
|
5
|
+
const w = globalThis;
|
|
6
|
+
const cfg = w.__dq ?? (w.__dq = { s: "unknown" });
|
|
7
|
+
/** Config carried on the script tag itself, read before anything else.
|
|
8
|
+
*
|
|
9
|
+
* Instrumenting a real TanStack storefront found the hazard this exists for: the
|
|
10
|
+
* framework hoisted `<script async src=".../_dq/a.js">` into `<head>`, ABOVE the inline
|
|
11
|
+
* block that was supposed to configure it — measured at byte 190 against byte 1108. The
|
|
12
|
+
* collector therefore ran with no `dev` flag, `shouldSkip` correctly saw a development
|
|
13
|
+
* host, and boot returned early. The only symptom was silence, and `window.__dq` looked
|
|
14
|
+
* half-built afterwards.
|
|
15
|
+
*
|
|
16
|
+
* An attribute cannot lose that race: it is on the element that is executing. This is
|
|
17
|
+
* why OneDollarStats carries `data-hostname` and `data-devmode` rather than expecting a
|
|
18
|
+
* global to be there first, and it is the shape `<Stats />` (6.3) has to ship. */
|
|
19
|
+
const tag = (() => {
|
|
20
|
+
try {
|
|
21
|
+
return (document.currentScript ??
|
|
22
|
+
document.querySelector('script[src*="/_dq/a.js"]'));
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
})();
|
|
28
|
+
const attr = (n) => tag?.dataset?.[n];
|
|
29
|
+
/** Where beacons go.
|
|
30
|
+
*
|
|
31
|
+
* Derived from the SCRIPT'S OWN src, not from a relative path. Instrumenting a real
|
|
32
|
+
* storefront found why: the tag was loaded from our collector, the beacon used `/_dq/e`,
|
|
33
|
+
* and a relative path resolves against the PAGE's origin — so every event was posted to
|
|
34
|
+
* the shop's own server, which answered 200 with its homepage. Nothing reached the
|
|
35
|
+
* collector and nothing reported an error, because a 200 is a 200.
|
|
36
|
+
*
|
|
37
|
+
* A site on our CDN is unaffected, since both are the same origin; that is exactly why
|
|
38
|
+
* this survived every local test. It breaks for every site that is NOT on our CDN — the
|
|
39
|
+
* self-serve tier, which is the whole reason the `?k=` path exists.
|
|
40
|
+
*
|
|
41
|
+
* An explicit `cfg.e` still wins, and the relative path remains the last resort. */
|
|
42
|
+
const ENDPOINT = (() => {
|
|
43
|
+
if (cfg.e)
|
|
44
|
+
return cfg.e;
|
|
45
|
+
try {
|
|
46
|
+
const src = tag?.src;
|
|
47
|
+
if (src)
|
|
48
|
+
return new URL("/_dq/e", src).toString();
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
/* a src we cannot parse is not a reason to fail to collect */
|
|
52
|
+
}
|
|
53
|
+
return "/_dq/e";
|
|
54
|
+
})();
|
|
55
|
+
const queue = new BoundedQueue();
|
|
56
|
+
let superProps = {};
|
|
57
|
+
let optedOut = false;
|
|
58
|
+
/** Readable from config so it is on BEFORE boot. The skip reason — "local", "opt-out",
|
|
59
|
+
* "automation" — is logged during boot, so a flag that can only be set by calling a
|
|
60
|
+
* method afterwards cannot explain the one failure it exists for: nothing arrives and
|
|
61
|
+
* there is no way to tell whether the tag is wrong, the site is wrong, or the host is
|
|
62
|
+
* excluded. OneDollarStats reaches the same conclusion with `data-devmode`. */
|
|
63
|
+
if (attr("dev") !== undefined)
|
|
64
|
+
w.__dq = Object.assign(w.__dq ?? {}, { dev: attr("dev") !== "false" });
|
|
65
|
+
if (attr("debug") !== undefined)
|
|
66
|
+
w.__dq = Object.assign(w.__dq ?? {}, { debug: attr("debug") !== "false" });
|
|
67
|
+
let skipped = false;
|
|
68
|
+
let debugOn = Boolean(w.__dq?.debug);
|
|
69
|
+
let timer;
|
|
70
|
+
let firstSent = false;
|
|
71
|
+
/** Run just before the last flush of a page load, so a module can add what it only knows
|
|
72
|
+
* at the end without spending a request of its own. */
|
|
73
|
+
const finalHooks = [];
|
|
74
|
+
/** Run when an SPA navigation changes the URL, BEFORE the new `$pageview`, with the path that
|
|
75
|
+
* is being left. A module measuring "this view" closes it here, so route 2 does not inherit
|
|
76
|
+
* route 1's scroll depth -- which is exactly what `$scroll` did before this existed. */
|
|
77
|
+
const routeHooks = [];
|
|
78
|
+
const log = (...a) => debugOn && console.log("[dq]", ...a);
|
|
79
|
+
const uuidv7 = () => {
|
|
80
|
+
// Time-ordered so replay dedups by a key that also sorts, without pulling a dependency.
|
|
81
|
+
const t = Date.now();
|
|
82
|
+
const hex = t.toString(16).padStart(12, "0");
|
|
83
|
+
const r = crypto.getRandomValues(new Uint8Array(10));
|
|
84
|
+
const h = [...r].map((b) => b.toString(16).padStart(2, "0")).join("");
|
|
85
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-7${h.slice(0, 3)}-${((parseInt(h[3], 16) & 0x3) | 0x8).toString(16)}${h.slice(4, 7)}-${h.slice(7, 19)}`;
|
|
86
|
+
};
|
|
87
|
+
function enqueue(rawName, rawProps, extra, urgent = false) {
|
|
88
|
+
if (optedOut || cfg.killed)
|
|
89
|
+
return;
|
|
90
|
+
// Only the tail is sheddable. `$` events carry every core metric and are bounded per
|
|
91
|
+
// pageview anyway, so exempting them costs almost no volume and keeps visitor counts,
|
|
92
|
+
// sessions and vitals exact at any rate.
|
|
93
|
+
if (typeof cfg.r === "number" &&
|
|
94
|
+
cfg.r < 1 &&
|
|
95
|
+
isSampleable(String(rawName ?? "")) &&
|
|
96
|
+
Math.random() > cfg.r)
|
|
97
|
+
return;
|
|
98
|
+
// Only the two violations that cost upload bytes are caught here; the Worker owns the
|
|
99
|
+
// rest, including the event name. Sending a name unnormalised costs nothing and saves
|
|
100
|
+
// 2.3 KB of normaliser in every visitor's download.
|
|
101
|
+
const trunc = new Set();
|
|
102
|
+
const props = trimProps({ ...superProps, ...(rawProps ?? {}) }, (f) => trunc.add(f));
|
|
103
|
+
const name = String(rawName ?? "").slice(0, LIMITS.nameLen * 2);
|
|
104
|
+
// Short keys on the wire. Field names are a double-digit share of a ~293 byte event, and
|
|
105
|
+
// the visitor pays that upload — often on mobile data. The Worker expands them, so
|
|
106
|
+
// nothing downstream ever sees the abbreviation.
|
|
107
|
+
const e = {
|
|
108
|
+
[WIRE.event_id]: uuidv7(),
|
|
109
|
+
[WIRE.ts]: new Date().toISOString(),
|
|
110
|
+
[WIRE.name]: name,
|
|
111
|
+
[WIRE.path]: location.pathname.slice(0, LIMITS.pathLen),
|
|
112
|
+
[WIRE.props]: props,
|
|
113
|
+
};
|
|
114
|
+
if (document.referrer)
|
|
115
|
+
e[WIRE.referrer] = document.referrer.slice(0, LIMITS.refLen);
|
|
116
|
+
// On EVERY event of the page load, not just the landing pageview: an event fired
|
|
117
|
+
// after a client-side route change still belongs to the campaign that brought the
|
|
118
|
+
// visitor, and by then the query string is long gone.
|
|
119
|
+
if (hasCampaign)
|
|
120
|
+
e[WIRE.utm] = campaign;
|
|
121
|
+
// Installed by the consent module, which only tier-1 sites download. Core asks; it does
|
|
122
|
+
// not know what consent is, the same way it does not know what a cart is.
|
|
123
|
+
const ci = w.__dqCid?.();
|
|
124
|
+
if (ci)
|
|
125
|
+
e[WIRE.client_id] = ci;
|
|
126
|
+
if (cfg.x && Object.keys(cfg.x).length)
|
|
127
|
+
e[WIRE.exp] = cfg.x;
|
|
128
|
+
// Absent rather than empty: a key that is not sent costs nothing, while an empty one
|
|
129
|
+
// costs its own name on every event.
|
|
130
|
+
if (extra) {
|
|
131
|
+
for (const [k, v] of Object.entries(extra)) {
|
|
132
|
+
if (v === undefined || v === null || v === "")
|
|
133
|
+
continue;
|
|
134
|
+
const short = WIRE[k];
|
|
135
|
+
e[short ?? k] = v;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (trunc.size)
|
|
139
|
+
e[WIRE._trunc] = [...trunc];
|
|
140
|
+
queue.push(e);
|
|
141
|
+
// The FIRST event of a page load goes immediately; everything after it batches.
|
|
142
|
+
//
|
|
143
|
+
// End-to-end latency measured 8.3s and none of it was the warehouse — ClickHouse answers
|
|
144
|
+
// in milliseconds. It was this queue: an event waits up to flushMs before anyone can see
|
|
145
|
+
// it, which makes a realtime view structurally impossible however fast the read side is.
|
|
146
|
+
//
|
|
147
|
+
// Flushing only the first costs ONE extra request per page load rather than one per
|
|
148
|
+
// event, so the batching that protects the collector is untouched — and the first event
|
|
149
|
+
// is the one realtime needs, because it is the pageview saying a visitor arrived.
|
|
150
|
+
if (!firstSent) {
|
|
151
|
+
firstSent = true;
|
|
152
|
+
flush();
|
|
153
|
+
return;
|
|
154
|
+
}
|
|
155
|
+
// Some events must not wait, and CORE DOES NOT DECIDE WHICH. This started as a name
|
|
156
|
+
// check here -- `name === "purchase"` -- which put the word "purchase" in the core
|
|
157
|
+
// bundle and broke the test asserting that a site without the commerce module does not
|
|
158
|
+
// download commerce vocabulary. That test was right: core does not know what a cart is,
|
|
159
|
+
// and the module that owns an event is the only thing that can judge what losing it
|
|
160
|
+
// costs. So urgency arrives as a parameter from the caller.
|
|
161
|
+
if (urgent) {
|
|
162
|
+
flush();
|
|
163
|
+
return;
|
|
164
|
+
}
|
|
165
|
+
log("queued", name, e);
|
|
166
|
+
if (queue.length >= LIMITS.eventsPerBatch)
|
|
167
|
+
flush();
|
|
168
|
+
}
|
|
169
|
+
function applyCommand(cmd) {
|
|
170
|
+
if (!cmd)
|
|
171
|
+
return;
|
|
172
|
+
if (cmd.k) {
|
|
173
|
+
cfg.killed = true;
|
|
174
|
+
log("killed by server");
|
|
175
|
+
}
|
|
176
|
+
if (typeof cmd.r === "number") {
|
|
177
|
+
cfg.r = cmd.r;
|
|
178
|
+
log("sampling ->", cmd.r);
|
|
179
|
+
}
|
|
180
|
+
// Module-level switch: `{h:0}` stops the heatmap module for the rest of the page load
|
|
181
|
+
// without touching core collection.
|
|
182
|
+
if ("h" in cmd)
|
|
183
|
+
cfg.h = cmd.h;
|
|
184
|
+
}
|
|
185
|
+
const payload = (events) => JSON.stringify({ site: cfg.s, key: cfg.k, events });
|
|
186
|
+
/** The last chance to deliver, so it does not get to fail quietly.
|
|
187
|
+
*
|
|
188
|
+
* sendBeacon returns false more often than people expect: over the browser's beacon
|
|
189
|
+
* queue limit, blocked by a connect-src CSP, or simply absent. Some privacy modes throw
|
|
190
|
+
* instead of returning false. Either way the batch is still in hand, and keepalive fetch
|
|
191
|
+
* survives unload too — so it is the fallback rather than the primary, which sendBeacon
|
|
192
|
+
* remains because it is the more reliable of the two during teardown. */
|
|
193
|
+
function sendFinal(body) {
|
|
194
|
+
try {
|
|
195
|
+
const blob = new Blob([body], { type: "text/plain" });
|
|
196
|
+
if (navigator.sendBeacon && navigator.sendBeacon(ENDPOINT, blob)) {
|
|
197
|
+
log("final via sendBeacon", body.length);
|
|
198
|
+
return;
|
|
199
|
+
}
|
|
200
|
+
log("sendBeacon declined, falling back");
|
|
201
|
+
}
|
|
202
|
+
catch (e) {
|
|
203
|
+
log("sendBeacon threw, falling back", e);
|
|
204
|
+
}
|
|
205
|
+
try {
|
|
206
|
+
fetch(ENDPOINT, {
|
|
207
|
+
method: "POST",
|
|
208
|
+
body,
|
|
209
|
+
keepalive: true,
|
|
210
|
+
headers: { "Content-Type": "text/plain" },
|
|
211
|
+
}).catch(() => { });
|
|
212
|
+
log("final via keepalive fetch", body.length);
|
|
213
|
+
}
|
|
214
|
+
catch (e) {
|
|
215
|
+
log("both transports failed", e);
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
function flush(final = false) {
|
|
219
|
+
if (final) {
|
|
220
|
+
// Drain everything, not one batch. A tab closing with 120 events queued would
|
|
221
|
+
// otherwise deliver 50 and lose 70 — and nothing would report the loss.
|
|
222
|
+
let batch;
|
|
223
|
+
while ((batch = queue.drain()).length)
|
|
224
|
+
sendFinal(payload(batch));
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const batch = queue.drain();
|
|
228
|
+
if (!batch.length)
|
|
229
|
+
return;
|
|
230
|
+
// text/plain avoids the CORS preflight: application/json cross-origin would trigger an
|
|
231
|
+
// OPTIONS before every beacon and double the request count.
|
|
232
|
+
fetch(ENDPOINT + (debugOn ? "?debug=1" : ""), {
|
|
233
|
+
method: "POST",
|
|
234
|
+
body: payload(batch),
|
|
235
|
+
keepalive: true,
|
|
236
|
+
headers: { "Content-Type": "text/plain" },
|
|
237
|
+
})
|
|
238
|
+
.then((r) => (r.status === 200 ? r.json() : null))
|
|
239
|
+
.then((cmd) => {
|
|
240
|
+
// With debug on the Worker echoes the flags it applied, so a developer sees what was
|
|
241
|
+
// rewritten without querying the warehouse — and without the client carrying the
|
|
242
|
+
// normaliser to find out.
|
|
243
|
+
const c = cmd;
|
|
244
|
+
if (c?._trunc && debugOn)
|
|
245
|
+
console.warn("[dq] server adjusted:", c._trunc);
|
|
246
|
+
applyCommand(c);
|
|
247
|
+
})
|
|
248
|
+
.catch(() => {
|
|
249
|
+
/* losing a batch is not worth breaking the page over */
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
function pageview(props) {
|
|
253
|
+
enqueue("$pageview", props);
|
|
254
|
+
}
|
|
255
|
+
/** trimProps accepts primitives and returns them unchanged; superProps is the string map
|
|
256
|
+
* every event spreads. Narrow here rather than widening superProps. */
|
|
257
|
+
/** Campaign parameters live in the query string of the LANDING url and are gone by the
|
|
258
|
+
* next navigation. Captured once at load and attached to every event in this page load.
|
|
259
|
+
*
|
|
260
|
+
* Deliberately NOT persisted to storage: keeping them across page loads would need
|
|
261
|
+
* device storage, which is the one thing that turns a cookieless collector into one
|
|
262
|
+
* that needs a consent banner. Attribution across the visit is a server-side question
|
|
263
|
+
* instead — the landing event carries the campaign, and a session inherits it from its
|
|
264
|
+
* own first event. */
|
|
265
|
+
const campaign = (() => {
|
|
266
|
+
const out = {};
|
|
267
|
+
try {
|
|
268
|
+
const q = new URLSearchParams(location.search);
|
|
269
|
+
for (const raw of CAMPAIGN_KEYS) {
|
|
270
|
+
const v = q.get(raw);
|
|
271
|
+
if (!v)
|
|
272
|
+
continue;
|
|
273
|
+
const k = campaignKey(raw);
|
|
274
|
+
if (k)
|
|
275
|
+
out[k] = v.slice(0, 200);
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
catch {
|
|
279
|
+
/* a malformed query string is not worth breaking collection over */
|
|
280
|
+
}
|
|
281
|
+
return out;
|
|
282
|
+
})();
|
|
283
|
+
const hasCampaign = Object.keys(campaign).length > 0;
|
|
284
|
+
const asStrings = (o) => {
|
|
285
|
+
const out = {};
|
|
286
|
+
for (const k in o)
|
|
287
|
+
out[k] = String(o[k]);
|
|
288
|
+
return out;
|
|
289
|
+
};
|
|
290
|
+
const api = {
|
|
291
|
+
track: (name, props) => enqueue(name, props),
|
|
292
|
+
pageview,
|
|
293
|
+
// trimProps, not sanitizeProps: the latter has never existed anywhere in the repo. A
|
|
294
|
+
// rename in "one payload contract" (f07c704) missed these two call sites; esbuild
|
|
295
|
+
// treats an unknown identifier as a runtime global rather than an error, and nothing
|
|
296
|
+
// typechecked — so two of the fourteen documented API methods have thrown
|
|
297
|
+
// ReferenceError ever since, silently, because no test called them.
|
|
298
|
+
//
|
|
299
|
+
// The no-op flag sink is deliberate: enqueue() re-trims { ...superProps, ...props } on
|
|
300
|
+
// every event, so anything worth flagging is flagged there with the event it affects.
|
|
301
|
+
// Flagging here as well would attribute it to whichever event happened to be next.
|
|
302
|
+
set: (p) => {
|
|
303
|
+
superProps = { ...superProps, ...asStrings(trimProps(p, () => { })) };
|
|
304
|
+
},
|
|
305
|
+
setOnce: (p) => {
|
|
306
|
+
const clean = asStrings(trimProps(p, () => { }));
|
|
307
|
+
for (const k in clean)
|
|
308
|
+
if (!(k in superProps))
|
|
309
|
+
superProps[k] = clean[k];
|
|
310
|
+
},
|
|
311
|
+
unset: (keys) => {
|
|
312
|
+
for (const k of keys)
|
|
313
|
+
delete superProps[k];
|
|
314
|
+
},
|
|
315
|
+
setExperiment: (id, variant) => {
|
|
316
|
+
cfg.x = { ...(cfg.x ?? {}), [id]: variant };
|
|
317
|
+
},
|
|
318
|
+
variant: (id) => cfg.x?.[id],
|
|
319
|
+
captureException: (err, props) => {
|
|
320
|
+
const e = err;
|
|
321
|
+
enqueue("$error", props, {
|
|
322
|
+
error_type: e?.name ?? "Error",
|
|
323
|
+
error_message: String(e?.message ?? err).slice(0, LIMITS.valueLen),
|
|
324
|
+
error_stack: (e?.stack ?? "").slice(0, 8000),
|
|
325
|
+
});
|
|
326
|
+
},
|
|
327
|
+
optIn: () => {
|
|
328
|
+
optedOut = false;
|
|
329
|
+
try {
|
|
330
|
+
localStorage.removeItem("__dq_ignore");
|
|
331
|
+
}
|
|
332
|
+
catch { }
|
|
333
|
+
},
|
|
334
|
+
optOut: () => {
|
|
335
|
+
optedOut = true;
|
|
336
|
+
try {
|
|
337
|
+
localStorage.setItem("__dq_ignore", "true");
|
|
338
|
+
}
|
|
339
|
+
catch { }
|
|
340
|
+
},
|
|
341
|
+
hasOptedOut: () => optedOut,
|
|
342
|
+
/** Replaced by the consent module on a tier-1 site. Left as a no-op so a site that
|
|
343
|
+
* calls it at tier 0 does not throw — declining consent that was never asked for is
|
|
344
|
+
* not an error. */
|
|
345
|
+
consent: (_v) => { },
|
|
346
|
+
/** Send whatever is queued now. Useful before a hard navigation the SDK cannot see,
|
|
347
|
+
* such as handing off to a payment provider. */
|
|
348
|
+
flush: () => flush(),
|
|
349
|
+
debug: (on = true) => {
|
|
350
|
+
debugOn = on;
|
|
351
|
+
},
|
|
352
|
+
reset: () => {
|
|
353
|
+
superProps = {};
|
|
354
|
+
},
|
|
355
|
+
};
|
|
356
|
+
/** The seam optional modules attach to. Core knows how to queue an event and nothing
|
|
357
|
+
* about what the event means — a module can add named helpers on top without the core
|
|
358
|
+
* learning what a cart is. */
|
|
359
|
+
w.__dqRegister = (fn) => {
|
|
360
|
+
// A module must not install its helpers when collection is off. Found on a real
|
|
361
|
+
// storefront: with boot skipped, `window.__dq` carried `addToCart` and
|
|
362
|
+
// `captureException` from the modules while core's own `pageview` and `flush` were
|
|
363
|
+
// absent — a half-built object that invites a site to call into a runtime that will
|
|
364
|
+
// never send. Skipped means skipped, for everyone.
|
|
365
|
+
if (skipped)
|
|
366
|
+
return;
|
|
367
|
+
try {
|
|
368
|
+
fn(enqueue, cfg, (h) => {
|
|
369
|
+
finalHooks.push(h);
|
|
370
|
+
}, (h) => {
|
|
371
|
+
routeHooks.push(h);
|
|
372
|
+
});
|
|
373
|
+
}
|
|
374
|
+
catch (err) {
|
|
375
|
+
log("module failed", err);
|
|
376
|
+
}
|
|
377
|
+
};
|
|
378
|
+
/** One call recorded by the stub, replayed against the real API.
|
|
379
|
+
*
|
|
380
|
+
* Two shapes. `{ m, a }` is the official snippet's: a METHOD and its arguments, so a helper
|
|
381
|
+
* called before boot (`viewItem`, `purchase`, `captureException`) arrives with its typed columns
|
|
382
|
+
* -- value, currency, item_ids, transaction_id -- instead of being flattened into props or
|
|
383
|
+
* dropped. Anything else is the original `track` stub's `[name, props]`, which keeps working.
|
|
384
|
+
*
|
|
385
|
+
* `replaying` stops the one loop this can make: a method no module provided is still the stub,
|
|
386
|
+
* and the stub pushes straight back here. That call is dropped, with a debug line saying why. */
|
|
387
|
+
let replaying = false;
|
|
388
|
+
function replay(r) {
|
|
389
|
+
if (!r || replaying) {
|
|
390
|
+
if (r)
|
|
391
|
+
log("no such method; dropped", r);
|
|
392
|
+
return;
|
|
393
|
+
}
|
|
394
|
+
replaying = true;
|
|
395
|
+
try {
|
|
396
|
+
const rec = r;
|
|
397
|
+
if (typeof rec.m === "string") {
|
|
398
|
+
const fn = cfg[rec.m];
|
|
399
|
+
if (typeof fn === "function")
|
|
400
|
+
fn(...Array.from(rec.a ?? []));
|
|
401
|
+
else
|
|
402
|
+
log("no such method; dropped", rec.m);
|
|
403
|
+
}
|
|
404
|
+
else {
|
|
405
|
+
enqueue(rec[0], rec[1]);
|
|
406
|
+
}
|
|
407
|
+
}
|
|
408
|
+
catch (e) {
|
|
409
|
+
log("replay failed", e);
|
|
410
|
+
}
|
|
411
|
+
finally {
|
|
412
|
+
replaying = false;
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
function boot() {
|
|
416
|
+
// ONCE PER PAGE, whatever put the tag there.
|
|
417
|
+
//
|
|
418
|
+
// Two identical `<script src>` tags both execute — the browser reuses the cached RESOURCE, not
|
|
419
|
+
// the execution — and measured, that is two `$pageview` events for one page load, doubling
|
|
420
|
+
// every number the page produces. It stopped being hypothetical when the TanStack framework
|
|
421
|
+
// started mounting the tag itself: any site that had already added it by hand now has both,
|
|
422
|
+
// and the duplicate arrives on a dependency bump rather than on a code change anyone reviews.
|
|
423
|
+
//
|
|
424
|
+
// The guard belongs HERE and not in either component, because the component can only know
|
|
425
|
+
// about itself. This covers every way a page ends up with two tags — two components, a
|
|
426
|
+
// component plus a hand-pasted snippet, a tag manager that injects a third.
|
|
427
|
+
//
|
|
428
|
+
// `w` rather than a module-level flag: two copies of this bundle are two module scopes, so a
|
|
429
|
+
// local `let` would be two separate flags, each false.
|
|
430
|
+
if (w.__dqBooted) {
|
|
431
|
+
log("already booted; this tag is a duplicate");
|
|
432
|
+
return;
|
|
433
|
+
}
|
|
434
|
+
w.__dqBooted = true;
|
|
435
|
+
// VIEW MODE: Studio framing this page to draw a heatmap over it. Nothing is collected -- no
|
|
436
|
+
// pageview, no module, no beacon -- and the overlay is a separate chunk that only this branch
|
|
437
|
+
// downloads; every other visitor pays for this test and nothing else. The chunk does the
|
|
438
|
+
// origin handshake: until an allow-listed parent speaks first, it does nothing at all.
|
|
439
|
+
if (/[?&]dq_view=1(&|$)/.test(location.search) && w.top !== w.self) {
|
|
440
|
+
skipped = true;
|
|
441
|
+
const s = document.createElement("script");
|
|
442
|
+
s.src = ENDPOINT.replace(/\/_dq\/e$/, "/_dq/v.js");
|
|
443
|
+
document.head.appendChild(s);
|
|
444
|
+
return;
|
|
445
|
+
}
|
|
446
|
+
const skip = shouldSkip(w);
|
|
447
|
+
if (skip) {
|
|
448
|
+
skipped = true;
|
|
449
|
+
log("not collecting:", skip);
|
|
450
|
+
return;
|
|
451
|
+
}
|
|
452
|
+
const stubbed = (cfg.q ?? []);
|
|
453
|
+
Object.assign(cfg, api);
|
|
454
|
+
// From here on the stub's queue is a live dispatcher, so a stub method a site captured before
|
|
455
|
+
// boot (or one no module replaced) still delivers instead of pushing into an array nobody reads.
|
|
456
|
+
cfg.q = { push: replay };
|
|
457
|
+
// A MICROTASK, because the commerce helpers do not exist yet: modules are appended after core
|
|
458
|
+
// in the same bundle and register when it finishes executing. Replaying here would find
|
|
459
|
+
// `viewItem` still pointing at the stub, which is exactly how a storefront that fires
|
|
460
|
+
// `view_item` before the script loads lost 94% of them.
|
|
461
|
+
queueMicrotask(() => {
|
|
462
|
+
for (const r of stubbed)
|
|
463
|
+
replay(r);
|
|
464
|
+
});
|
|
465
|
+
whenVisible(document, () => pageview());
|
|
466
|
+
// SPA navigation. The framework serves full documents, but islands and client routers
|
|
467
|
+
// change the URL without one.
|
|
468
|
+
// One notion of "the URL changed", shared by every path that can change it.
|
|
469
|
+
//
|
|
470
|
+
// pushState, popstate and hashchange are not independent events: assigning
|
|
471
|
+
// `location.hash` fires hashchange AND popstate, so a hash-routed site counted every
|
|
472
|
+
// navigation twice — measured, five page views for what was three. Routing all three
|
|
473
|
+
// through here makes a repeat of the same URL a no-op, which also covers the router that
|
|
474
|
+
// calls pushState and then dispatches popstate itself.
|
|
475
|
+
//
|
|
476
|
+
// The hash is part of "the URL" only on a site that routes on it. Elsewhere a click on
|
|
477
|
+
// `#reviews` is an anchor -- and it still fires popstate, so leaving the fragment in the key
|
|
478
|
+
// counted every in-page jump as a page view even with `hash` off.
|
|
479
|
+
const here = () => location.pathname + location.search + (cfg.hash ? location.hash : "");
|
|
480
|
+
let lastUrl = here();
|
|
481
|
+
let lastPath = location.pathname;
|
|
482
|
+
const route = () => {
|
|
483
|
+
const prev = lastPath;
|
|
484
|
+
lastPath = location.pathname;
|
|
485
|
+
for (const fn of routeHooks) {
|
|
486
|
+
try {
|
|
487
|
+
fn(prev);
|
|
488
|
+
}
|
|
489
|
+
catch {
|
|
490
|
+
/* one module must not stop another */
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
};
|
|
494
|
+
const navigated = () => {
|
|
495
|
+
const now = here();
|
|
496
|
+
if (now === lastUrl)
|
|
497
|
+
return;
|
|
498
|
+
lastUrl = now;
|
|
499
|
+
route();
|
|
500
|
+
pageview();
|
|
501
|
+
};
|
|
502
|
+
const push = history.pushState;
|
|
503
|
+
if (push) {
|
|
504
|
+
history.pushState = function (...a) {
|
|
505
|
+
push.apply(this, a);
|
|
506
|
+
navigated();
|
|
507
|
+
};
|
|
508
|
+
addEventListener("popstate", navigated);
|
|
509
|
+
}
|
|
510
|
+
// replaceState was not patched at all, and routers use it constantly — canonical
|
|
511
|
+
// rewrites, redirects, writing filter state into the URL. Only a changed PATH counts
|
|
512
|
+
// here: a PLP rewriting its query string on every filter click is one page view, and
|
|
513
|
+
// firing on each would turn browsing into a traffic spike. This is deliberately stricter
|
|
514
|
+
// than `navigated`, which treats any URL change as a navigation.
|
|
515
|
+
const replace = history.replaceState;
|
|
516
|
+
if (replace) {
|
|
517
|
+
history.replaceState = function (...a) {
|
|
518
|
+
const before = location.pathname;
|
|
519
|
+
replace.apply(this, a);
|
|
520
|
+
if (location.pathname !== before) {
|
|
521
|
+
lastUrl = here();
|
|
522
|
+
route();
|
|
523
|
+
pageview();
|
|
524
|
+
}
|
|
525
|
+
};
|
|
526
|
+
}
|
|
527
|
+
// Hash routing, opt-in per site. NOT automatic: on an ordinary page `#secao` is an
|
|
528
|
+
// anchor, and counting those would inflate every long article and every FAQ. A site that
|
|
529
|
+
// routes on the hash declares it — which is how Plausible and OneDollarStats handle it
|
|
530
|
+
// too, each with a mode for the case.
|
|
531
|
+
if (cfg.hash)
|
|
532
|
+
addEventListener("hashchange", navigated);
|
|
533
|
+
timer = setInterval(() => flush(), LIMITS.flushMs);
|
|
534
|
+
// Both, on purpose. pagehide misses backgrounding on mobile, and visibilitychange
|
|
535
|
+
// misses some desktop closes; a page can also be restored from bfcache after either.
|
|
536
|
+
// Double-firing is harmless because a drained queue makes the second call a no-op.
|
|
537
|
+
// Modules that only know their value when the page ends — scroll depth, the vitals,
|
|
538
|
+
// the accumulated error repeats — contribute HERE, and then ONE flush carries all of
|
|
539
|
+
// it. Each of them used to call flush() itself, which produced four requests on the
|
|
540
|
+
// way out where one would do: the collector paying per module rather than per visit.
|
|
541
|
+
const onFinal = () => {
|
|
542
|
+
for (const fn of finalHooks) {
|
|
543
|
+
try {
|
|
544
|
+
fn();
|
|
545
|
+
}
|
|
546
|
+
catch {
|
|
547
|
+
/* one module must not stop another */
|
|
548
|
+
}
|
|
549
|
+
}
|
|
550
|
+
flush(true);
|
|
551
|
+
};
|
|
552
|
+
addEventListener("pagehide", onFinal);
|
|
553
|
+
// On document, not window: visibilitychange is specified to fire at the Document. It
|
|
554
|
+
// does bubble, so a window listener happens to work in a real browser — but relying on
|
|
555
|
+
// that is fragile, and it silently does nothing for any dispatch that is not bubbling.
|
|
556
|
+
document.addEventListener("visibilitychange", () => {
|
|
557
|
+
if (document.visibilityState === "hidden")
|
|
558
|
+
onFinal();
|
|
559
|
+
});
|
|
560
|
+
}
|
|
561
|
+
boot();
|
|
562
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/v8/analytics/runtime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AAG,EAAE,CAAC,KAAK,EAAE,EAAE,MAAM,CAAC,OAAO,CAAsB,CAAC;IAExE,kFAAkF;IAClF,qFAAqF;IACrF,mFAAmF;IACnF,oFAAoF;IACpF,qFAAqF;IACrF,oFAAoF;IACpF,qFAAqF;IACrF,MAAM,OAAO,GAAG,GAAG,EAAE;QACnB,KAAK,MAAM,EAAE,IAAI,UAAU,EAAE,CAAC;YAC5B,IAAI,CAAC;gBACH,EAAE,EAAE,CAAC;YACP,CAAC;YAAC,MAAM,CAAC;gBACP,sCAAsC;YACxC,CAAC;QACH,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,CAAC;IACd,CAAC,CAAC;IACF,gBAAgB,CAAC,UAAU,EAAE,OAAO,CAAC,CAAC;IACtC,qFAAqF;IACrF,uFAAuF;IACvF,uFAAuF;IACvF,QAAQ,CAAC,gBAAgB,CAAC,kBAAkB,EAAE,GAAG,EAAE;QACjD,IAAI,QAAQ,CAAC,eAAe,KAAK,QAAQ;YAAE,OAAO,EAAE,CAAC;IACvD,CAAC,CAAC,CAAC;AACL,CAAC;AAED,IAAI,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export type QueuedEvent = Record<string, unknown>;
|
|
2
|
+
/** Bounded, because a page firing events in a loop must not grow memory in a customer's
|
|
3
|
+
* browser without limit. Drops the oldest and marks the survivor, so the loss is visible
|
|
4
|
+
* in the data rather than inferred from a gap. */
|
|
5
|
+
export declare class BoundedQueue {
|
|
6
|
+
private items;
|
|
7
|
+
push(e: QueuedEvent): void;
|
|
8
|
+
/** Up to `eventsPerBatch` events AND `batchBytes` of them. Fifty `$error`s at 8 KB each is a
|
|
9
|
+
* 400 KB body: the collector answers 413, and keepalive or sendBeacon refuses it outright, so
|
|
10
|
+
* the whole batch was lost. Always at least one event, so an oversize one cannot wedge the
|
|
11
|
+
* queue; the collector judges it alone. */
|
|
12
|
+
drain(): QueuedEvent[];
|
|
13
|
+
get length(): number;
|
|
14
|
+
}
|
|
15
|
+
//# sourceMappingURL=queue.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.d.ts","sourceRoot":"","sources":["../../../../../src/v8/analytics/runtime/src/queue.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;AAElD;;mDAEmD;AACnD,qBAAa,YAAY;IACvB,OAAO,CAAC,KAAK,CAAqB;IAElC,IAAI,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,CAQzB;IAED;;;gDAG4C;IAC5C,KAAK,IAAI,WAAW,EAAE,CAUrB;IAED,IAAI,MAAM,IAAI,MAAM,CAEnB;CACF"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { F_QUEUE_OVERFLOW, LIMITS, WIRE } from "../../shared/contract.js";
|
|
2
|
+
/** Bounded, because a page firing events in a loop must not grow memory in a customer's
|
|
3
|
+
* browser without limit. Drops the oldest and marks the survivor, so the loss is visible
|
|
4
|
+
* in the data rather than inferred from a gap. */
|
|
5
|
+
export class BoundedQueue {
|
|
6
|
+
items = [];
|
|
7
|
+
push(e) {
|
|
8
|
+
if (this.items.length >= LIMITS.queueMax) {
|
|
9
|
+
this.items.shift();
|
|
10
|
+
const t = e[WIRE._trunc] ?? [];
|
|
11
|
+
if (!t.includes(F_QUEUE_OVERFLOW))
|
|
12
|
+
t.push(F_QUEUE_OVERFLOW);
|
|
13
|
+
e[WIRE._trunc] = t;
|
|
14
|
+
}
|
|
15
|
+
this.items.push(e);
|
|
16
|
+
}
|
|
17
|
+
/** Up to `eventsPerBatch` events AND `batchBytes` of them. Fifty `$error`s at 8 KB each is a
|
|
18
|
+
* 400 KB body: the collector answers 413, and keepalive or sendBeacon refuses it outright, so
|
|
19
|
+
* the whole batch was lost. Always at least one event, so an oversize one cannot wedge the
|
|
20
|
+
* queue; the collector judges it alone. */
|
|
21
|
+
drain() {
|
|
22
|
+
let n = 0, bytes = 0;
|
|
23
|
+
const enc = new TextEncoder();
|
|
24
|
+
while (n < this.items.length && n < LIMITS.eventsPerBatch) {
|
|
25
|
+
bytes += enc.encode(JSON.stringify(this.items[n])).length + 1;
|
|
26
|
+
if (n && bytes > LIMITS.batchBytes)
|
|
27
|
+
break;
|
|
28
|
+
n++;
|
|
29
|
+
}
|
|
30
|
+
return this.items.splice(0, n);
|
|
31
|
+
}
|
|
32
|
+
get length() {
|
|
33
|
+
return this.items.length;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"queue.js","sourceRoot":"","sources":["../../../../../src/v8/analytics/runtime/src/queue.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,0BAA0B,CAAC;AAI1E;;mDAEmD;AACnD,MAAM,OAAO,YAAY;IACf,KAAK,GAAkB,EAAE,CAAC;IAElC,IAAI,CAAC,CAAc;QACjB,IAAI,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACzC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,CAAC;YACnB,MAAM,CAAC,GAAI,CAAC,CAAC,IAAI,CAAC,MAAM,CAA0B,IAAI,EAAE,CAAC;YACzD,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,gBAAgB,CAAC;gBAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,CAAC,CAAC;YAC5D,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QACrB,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IAED;;;gDAG4C;IAC5C,KAAK;QACH,IAAI,CAAC,GAAG,CAAC,EACP,KAAK,GAAG,CAAC,CAAC;QACZ,MAAM,GAAG,GAAG,IAAI,WAAW,EAAE,CAAC;QAC9B,OAAO,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,CAAC,GAAG,MAAM,CAAC,cAAc,EAAE,CAAC;YAC1D,KAAK,IAAI,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC;YAC9D,IAAI,CAAC,IAAI,KAAK,GAAG,MAAM,CAAC,UAAU;gBAAE,MAAM;YAC1C,CAAC,EAAE,CAAC;QACN,CAAC;QACD,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACjC,CAAC;IAED,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;IAC3B,CAAC;CACF"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** The client's share of the contract, kept to the two violations that actually cost
|
|
2
|
+
* upload bytes: an oversized value and a non-primitive that would be serialised whole.
|
|
3
|
+
*
|
|
4
|
+
* Everything else — charset, reserved names, currency, timestamps — is left to the
|
|
5
|
+
* Worker. Shipping the full normaliser cost 2.3 KB minified in every visitor's download
|
|
6
|
+
* to save bytes on payloads most sites never send, which is the wrong trade. The Worker
|
|
7
|
+
* is the authority regardless, so the client's job is bandwidth, not correctness.
|
|
8
|
+
*
|
|
9
|
+
* What a developer loses by not normalising here is visibility, and that comes back the
|
|
10
|
+
* cheaper way: with `debug()` on, the collect response echoes the flags the Worker
|
|
11
|
+
* applied. Zero bytes in the normal path, full feedback when someone is looking. */
|
|
12
|
+
export declare function trimProps(input: unknown, flag: (f: string) => void): Record<string, unknown>;
|
|
13
|
+
//# sourceMappingURL=trim.d.ts.map
|