tagreeve 0.6.0-rc.3 → 0.6.1
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/README.md +8 -4
- package/dist/cli.js +353 -116
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -9,7 +9,7 @@
|
|
|
9
9
|
|
|
10
10
|
Agent-first testing for tags and consent. Tagreeve plays a visitor in a real browser, records every tracking hit the site sends, and checks the result against what you expect. Web tag reports (which GTM web tags fired) come from a GTM template you install. Server tag reports are planned.
|
|
11
11
|
|
|
12
|
-
> **Status: 0.6 (`0.6.
|
|
12
|
+
> **Status: 0.6 (`0.6.1`).** Tagreeve plays a visitor in Chromium, records and decodes hits, answers the consent banner, checks YAML expectations and writes a JSONL record. 0.3 adds rules on payload fields and cookies, a `deniedIdentifiers` check, `tagreeve suite`, an HTML report, a Done control for handoff steps, role-based locators and a `select` step. 0.4 adds handoffs that end by themselves, an opt-in test payment step, baselines, a viewport option and fake identities by country. 0.5 adds `--server-container`, which runs your own server container in Docker and records what it sends to each vendor, a Conversions API decoder, several stores in one suite and platform hosts for Shopify. 0.6.0-rc.1 adds path defaults, `tagreeve init`, `tagreeve/config.yml`, `--label`, default baseline paths and `suite --baseline`, exact links between server container calls and browser hits by client ID, and the frame of each `dataLayer` push. 0.6.0-rc.2 adds web tag reports, `tagreeve template web`, `tag` rules, `expectedTags`, masked `dataLayer` push shapes in `diff` and baselines, and the `consentModeSetup` check. 0.6.0-rc.3 fixes the reporter in real GTM, keeps the `dataLayer` hook working when a page replaces `push`, adds push kinds and a `dataLayerIncomplete` flag, and sends handoff text to stderr. 0.6.0 is rc.3 with the release prep and no code change; it was field-tested on a real store with a real GTM web container in a workspace preview (rc.2 and rc.3). The rest of this README describes where Tagreeve is going, and marks what is not built yet. The design is in [docs/design.md](docs/design.md). Feedback is welcome in issues.
|
|
13
13
|
>
|
|
14
14
|
> **In 0.1:** `tagreeve run` with `stub` and `live` network modes; consent epochs, with withdrawals labelled apart from first rejects; seeded fake identities, hash checks and leak detection; decoders for GA4, Google Ads, Meta, Stape custom loader and a minimal server-container data client; banner handling through autoconsent; expectations; JSONL output.
|
|
15
15
|
>
|
|
@@ -17,6 +17,10 @@ Agent-first testing for tags and consent. Tagreeve plays a visitor in a real bro
|
|
|
17
17
|
>
|
|
18
18
|
> **In 0.3:** `body.has` and `body.only` rules on the field names of a hit; `cookie` rules; a `deniedIdentifiers` check that fails when an identifier goes out on a denied hit; `tagreeve suite` runs a folder of scenarios against several GTM builds; `tagreeve report` writes an HTML report of one run or a suite; a Done button in the handoff window; `click` and `wait` by role and name or from a list of selectors; a `select` step; the `server` network mode; record schema version 2. `deniedIdentifiers` fails by default, so a run that passed in 0.2 can exit 1. See [CHANGELOG.md](CHANGELOG.md).
|
|
19
19
|
>
|
|
20
|
+
> **In 0.6.1:** fixes after 0.6.0, with no new command and no new option. A `dataLayer` push that holds data not from the run identity gets a `possibleRealDataPush` warning that never changes the exit code. `diff` names events as recorded. A few baseline, `init`, `wait` and server link cases changed. The record stays at schema version 5. `npm i -g tagreeve` installs it. To upgrade from 0.6.0, read "Upgrading from 0.6.0" in [CHANGELOG.md](CHANGELOG.md). What is still open is in the same file under "Known in 0.6.1".
|
|
21
|
+
>
|
|
22
|
+
> **In 0.6.0:** everything in the 0.6.0 release candidates below, with no code change after rc.3. The record stays at schema version 5. To upgrade from 0.5.0, read "Upgrading from 0.5.0" in [CHANGELOG.md](CHANGELOG.md). What is still open is in the same file under "Known in 0.6.0".
|
|
23
|
+
>
|
|
20
24
|
> **In 0.6.0-rc.3:** the reporter template sends tag IDs as strings, so real GTM reports are no longer recorded as invalid, and a 0.6.0-rc.2 template still works; the `dataLayer` hook leaves `push` as the page assigned it, and a page that replaces `window.dataLayer` after a Google loader request gets a `dataLayerReassigned` flag; a frame whose `dataLayer` holds pushes the run did not record gets a `dataLayerIncomplete` flag; push shapes have a `kind`, `gtag` or `object`; `consentModeSetup` names the `gcd` letters; the Result line counts baseline warnings; handoff text goes to stderr, so `--json` stdout is only JSON; `wait` with a `url` takes a `timeout`. The record stays at schema version 5. What is still open is in [CHANGELOG.md](CHANGELOG.md) under "Known in 0.6.0-rc.3".
|
|
21
25
|
>
|
|
22
26
|
> **In 0.6.0-rc.2:** the run record is schema version 5 and holds web tag reports from the `tagreeveTagReport` binding; `tagreeve template web` prints the reporter's GTM template; `tag` rules in `must` and `mustNot` and `expectedTags` in the GTM override file check which tags fired; the `--json` summary and the text summary have a `dataLayer` section; `diff` and `baseline` compare masked push shapes, with `diff --event-map`; `options.dataLayerNames` hooks a `dataLayer` with a custom name; the `consentModeSetup` check warns on a Consent Mode signal that was never set; `tagreeve init` writes `tagreeve/config.yml`; and a server container call that is not an exact link records why. What is still open is in [CHANGELOG.md](CHANGELOG.md) under "Known in 0.6.0-rc.2".
|
|
@@ -86,15 +90,15 @@ tagreeve run scenarios/undecided-visitor.yml --site https://staging.example.com
|
|
|
86
90
|
## Install
|
|
87
91
|
|
|
88
92
|
```bash
|
|
89
|
-
npm i -g tagreeve
|
|
93
|
+
npm i -g tagreeve
|
|
90
94
|
tagreeve install-browser
|
|
91
95
|
```
|
|
92
96
|
|
|
93
|
-
Node 22.18 or later. `npm i -g tagreeve
|
|
97
|
+
Node 22.18 or later. `npm i -g tagreeve` installs the newest release. Other ways to install, from a git tag or a tarball, are in [docs/cli.md](docs/cli.md).
|
|
94
98
|
|
|
95
99
|
## Quick start
|
|
96
100
|
|
|
97
|
-
1. `npm i -g tagreeve
|
|
101
|
+
1. `npm i -g tagreeve`
|
|
98
102
|
2. `tagreeve install-browser`. In a project folder, `tagreeve init` makes `tagreeve/scenarios/` and `tagreeve/baselines/`, writes a starter `tagreeve/config.yml` and keeps `tagreeve/runs/` out of git.
|
|
99
103
|
3. Write `scenario.yml`:
|
|
100
104
|
|
package/dist/cli.js
CHANGED
|
@@ -1356,8 +1356,8 @@ var googleAds = {
|
|
|
1356
1356
|
const oid = p.get("oid");
|
|
1357
1357
|
if (oid) params.transaction_id = oid;
|
|
1358
1358
|
for (const [k, v] of p) {
|
|
1359
|
-
|
|
1360
|
-
|
|
1359
|
+
const name = k.startsWith("ep.") ? k.slice(3) : k.startsWith("epn.") ? k.slice(4) : void 0;
|
|
1360
|
+
if (name && name !== "conversionId") params[name] = v;
|
|
1361
1361
|
}
|
|
1362
1362
|
return [
|
|
1363
1363
|
withFields({
|
|
@@ -2542,13 +2542,14 @@ var MAX_LETTER_SETS = 3;
|
|
|
2542
2542
|
function tagId(hit) {
|
|
2543
2543
|
const conversionId = hit.params.conversionId;
|
|
2544
2544
|
const tid = hit.vendor === "ga4" ? hit.params.tid : conversionId && /^\d+$/.test(conversionId) ? `AW-${conversionId}` : void 0;
|
|
2545
|
-
return tid && TAG_ID.test(tid) ? tid : "(no tag ID)
|
|
2545
|
+
return tid && TAG_ID.test(tid) ? tid : `${hit.vendor === "ga4" ? "GA4" : "Google Ads"} (no tag ID)`;
|
|
2546
2546
|
}
|
|
2547
2547
|
function list(names) {
|
|
2548
2548
|
return names.length < 2 ? names.join("") : `${names.slice(0, -1).join(", ")} and ${names[names.length - 1]}`;
|
|
2549
2549
|
}
|
|
2550
2550
|
function lettersNote(sets) {
|
|
2551
|
-
|
|
2551
|
+
const shown2 = [...sets].slice(0, MAX_LISTED).map(([tid, letters]) => `${tid} ${[...letters].slice(0, MAX_LETTER_SETS).join(", ")}`).join("; ");
|
|
2552
|
+
return sets.size > MAX_LISTED ? `${shown2}; and ${sets.size - MAX_LISTED} more` : shown2;
|
|
2552
2553
|
}
|
|
2553
2554
|
function consentModeSetup(hits, dataLayer) {
|
|
2554
2555
|
const google = hits.filter((h) => GOOGLE_VENDORS.has(h.vendor));
|
|
@@ -2591,7 +2592,8 @@ function consentModeSetup(hits, dataLayer) {
|
|
|
2591
2592
|
const groups = [...unset].map(([tid, names]) => {
|
|
2592
2593
|
const ordered = GCD_SIGNALS.filter((n) => names.has(n));
|
|
2593
2594
|
const note = v1Only.has(tid) ? " (a default for ad_storage and analytics_storage only, without the two v2 signals)" : "";
|
|
2594
|
-
const
|
|
2595
|
+
const unsetFirst = [...letterSets.get(tid) ?? []].sort((a, b) => Number(b.includes("l")) - Number(a.includes("l")));
|
|
2596
|
+
const letters = unsetFirst.slice(0, MAX_LETTER_SETS).join(", ");
|
|
2595
2597
|
return `Google tag ${tid} never set ${list(ordered)}${note} (gcd letters: ${letters})`;
|
|
2596
2598
|
});
|
|
2597
2599
|
const shown2 = groups.slice(0, MAX_LISTED).join("; ");
|
|
@@ -2616,10 +2618,11 @@ var STATUS_WORD = /^[a-z_]{1,20}$/;
|
|
|
2616
2618
|
var ID_WORD = /^[\w.-]{1,40}$/;
|
|
2617
2619
|
var COARSE_SEPARATORS = /[\s/=:?&#|,;]+/;
|
|
2618
2620
|
var NAME_SEPARATORS = /[\s/=:?&#|,;._+()[\]{}<>'"`]+/;
|
|
2621
|
+
var ALNUM_RUNS = /[^A-Za-z0-9]+/;
|
|
2619
2622
|
function maskTagName(name) {
|
|
2620
2623
|
const kinds = valueKinds(name);
|
|
2621
2624
|
if (kinds.has("email") || kinds.has("phone")) return OTHER_NAME;
|
|
2622
|
-
return [...name.split(COARSE_SEPARATORS), ...name.split(NAME_SEPARATORS)].some((part) => isValueSegment(part)) ? OTHER_NAME : name;
|
|
2625
|
+
return [...name.split(COARSE_SEPARATORS), ...name.split(NAME_SEPARATORS), ...name.split(ALNUM_RUNS)].some((part) => isValueSegment(part)) ? OTHER_NAME : name;
|
|
2623
2626
|
}
|
|
2624
2627
|
function maskTagId(id) {
|
|
2625
2628
|
return ID_WORD.test(id) ? id : OTHER_NAME;
|
|
@@ -2790,8 +2793,11 @@ function evaluateRule(rule, ctx) {
|
|
|
2790
2793
|
if (unjudged.length === 0) return outcome;
|
|
2791
2794
|
if (rule.kind === "mustNot") {
|
|
2792
2795
|
if (!outcome.pass) return outcome;
|
|
2793
|
-
} else
|
|
2794
|
-
|
|
2796
|
+
} else {
|
|
2797
|
+
const exact = rule.count?.op === "=";
|
|
2798
|
+
const sizes = exact ? Array.from({ length: unjudged.length }, (_, i) => i + 1) : [unjudged.length];
|
|
2799
|
+
const changes = sizes.some((k) => evaluateRuleHits(rule, { ...ctx, anywhere: new Set(unjudged.slice(0, k).map((h) => h.id)) }).pass !== outcome.pass);
|
|
2800
|
+
if (!changes) return outcome;
|
|
2795
2801
|
}
|
|
2796
2802
|
return {
|
|
2797
2803
|
pass: false,
|
|
@@ -3885,24 +3891,30 @@ function readingForms(text2) {
|
|
|
3885
3891
|
}
|
|
3886
3892
|
function mergeEdgeReadings(found, bodies) {
|
|
3887
3893
|
const best = (f) => Math.min(...f.where.values());
|
|
3888
|
-
const
|
|
3894
|
+
const valueOf3 = (key, kind) => key.slice(kind.length + 1);
|
|
3889
3895
|
const fields2 = [...found].filter(([, f]) => best(f) < 2);
|
|
3890
3896
|
for (const [key, f] of [...found]) {
|
|
3891
3897
|
if (best(f) < 2 || [...f.where.keys()].some((w) => w !== "the body")) continue;
|
|
3892
|
-
const value =
|
|
3893
|
-
const twin = fields2.find(([k, other]) => other.kind === f.kind && isEdgeShift(
|
|
3898
|
+
const value = valueOf3(key, f.kind);
|
|
3899
|
+
const twin = fields2.find(([k, other]) => other.kind === f.kind && isEdgeShift(valueOf3(k, other.kind), value, bodies));
|
|
3894
3900
|
if (!twin) continue;
|
|
3895
3901
|
for (const [w, tier] of f.where) twin[1].where.set(w, Math.min(tier, twin[1].where.get(w) ?? tier));
|
|
3896
3902
|
found.delete(key);
|
|
3897
3903
|
}
|
|
3898
3904
|
}
|
|
3899
|
-
function findForeignData(requests, hits, identity) {
|
|
3905
|
+
function findForeignData(requests, hits, identity, dataLayerEvents = []) {
|
|
3900
3906
|
const byRequest = /* @__PURE__ */ new Map();
|
|
3901
3907
|
const slot = (key, stepId) => {
|
|
3902
3908
|
let entry = byRequest.get(key);
|
|
3903
3909
|
if (!entry) byRequest.set(key, entry = { texts: [], hitIds: [], stepId });
|
|
3904
3910
|
return entry;
|
|
3905
3911
|
};
|
|
3912
|
+
for (const event of dataLayerEvents) {
|
|
3913
|
+
const entry = slot(event.id, event.stepId);
|
|
3914
|
+
entry.push = true;
|
|
3915
|
+
const body = JSON.stringify(event.args);
|
|
3916
|
+
entry.texts.push({ text: body, where: "the body" }, ...leafTexts(body));
|
|
3917
|
+
}
|
|
3906
3918
|
const hitRequests = new Set(hits.map((h) => h.requestId));
|
|
3907
3919
|
for (const request of requests) {
|
|
3908
3920
|
if (request.resourceType === "script" && isLibraryLoadPath(pathOf(request.url))) continue;
|
|
@@ -3917,15 +3929,15 @@ function findForeignData(requests, hits, identity) {
|
|
|
3917
3929
|
entry.hitIds.push(hit.id);
|
|
3918
3930
|
for (const [key, value] of Object.entries(hit.params)) entry.texts.push({ text: `${key}=${value}`, where: guardFieldName(key) });
|
|
3919
3931
|
}
|
|
3920
|
-
const
|
|
3921
|
-
|
|
3922
|
-
);
|
|
3932
|
+
const stableFrom = (entries) => findStableHashes([...entries].flatMap(([requestId, entry]) => entry.texts.map(({ text: text2 }) => ({ requestId, text: text2 }))));
|
|
3933
|
+
const requestStable = stableFrom([...byRequest].filter(([, entry]) => !entry.push));
|
|
3934
|
+
const pushStable = stableFrom(byRequest);
|
|
3923
3935
|
const out = [];
|
|
3924
3936
|
for (const [requestId, entry] of byRequest) {
|
|
3925
3937
|
const found = /* @__PURE__ */ new Map();
|
|
3926
3938
|
for (const { text: text2, where: where2, leaf, name } of entry.texts) {
|
|
3927
3939
|
const tier = where2 === "the URL" || where2 === "the body" ? 2 : leaf ? 1 : 0;
|
|
3928
|
-
for (const m of scan(text2, identity, { stableHashes })) {
|
|
3940
|
+
for (const m of scan(text2, identity, { stableHashes: entry.push ? pushStable : requestStable })) {
|
|
3929
3941
|
if (name && m.kind === "phone") continue;
|
|
3930
3942
|
const key = `${m.kind}:${m.value}`;
|
|
3931
3943
|
const seen = found.get(key) ?? { kind: m.kind, where: /* @__PURE__ */ new Map() };
|
|
@@ -3948,8 +3960,9 @@ function findForeignData(requests, hits, identity) {
|
|
|
3948
3960
|
const in_ = shown2.length > 5 ? `${shown2.slice(0, 5).join(", ")} and ${shown2.length - 5} more` : shown2.join(", ");
|
|
3949
3961
|
const step = entry.stepId ? ` in step ${entry.stepId}` : "";
|
|
3950
3962
|
out.push({
|
|
3963
|
+
source: entry.push ? "push" : "request",
|
|
3951
3964
|
requestId,
|
|
3952
|
-
detail:
|
|
3965
|
+
detail: `${entry.push ? "dataLayer push" : "request"} ${requestId}${step} carries ${found.size} ${kinds} value(s) that are not from the run identity, in ${in_}`,
|
|
3953
3966
|
evidence: [requestId, ...entry.hitIds, ...entry.stepId ? [entry.stepId] : []]
|
|
3954
3967
|
});
|
|
3955
3968
|
}
|
|
@@ -3964,6 +3977,60 @@ var TOP_KEYS2 = /* @__PURE__ */ new Set(["events", "paths"]);
|
|
|
3964
3977
|
function isRecord(value) {
|
|
3965
3978
|
return typeof value === "object" && value !== null && !Array.isArray(value);
|
|
3966
3979
|
}
|
|
3980
|
+
function objectEntries(text2, from) {
|
|
3981
|
+
let i = from;
|
|
3982
|
+
const skipSpace = () => {
|
|
3983
|
+
while (i < text2.length && /\s/.test(text2[i])) i++;
|
|
3984
|
+
};
|
|
3985
|
+
const readString = () => {
|
|
3986
|
+
const begin = i++;
|
|
3987
|
+
while (i < text2.length && text2[i] !== '"') i += text2[i] === "\\" ? 2 : 1;
|
|
3988
|
+
i++;
|
|
3989
|
+
return JSON.parse(text2.slice(begin, i));
|
|
3990
|
+
};
|
|
3991
|
+
const skipValue = () => {
|
|
3992
|
+
skipSpace();
|
|
3993
|
+
const c = text2[i];
|
|
3994
|
+
if (c === '"') {
|
|
3995
|
+
readString();
|
|
3996
|
+
} else if (c === "{" || c === "[") {
|
|
3997
|
+
const close = c === "{" ? "}" : "]";
|
|
3998
|
+
i++;
|
|
3999
|
+
skipSpace();
|
|
4000
|
+
while (text2[i] !== close) {
|
|
4001
|
+
if (c === "{") {
|
|
4002
|
+
readString();
|
|
4003
|
+
skipSpace();
|
|
4004
|
+
i++;
|
|
4005
|
+
}
|
|
4006
|
+
skipValue();
|
|
4007
|
+
skipSpace();
|
|
4008
|
+
if (text2[i] === ",") i++;
|
|
4009
|
+
skipSpace();
|
|
4010
|
+
}
|
|
4011
|
+
i++;
|
|
4012
|
+
} else {
|
|
4013
|
+
while (i < text2.length && !/[\s,}\]]/.test(text2[i])) i++;
|
|
4014
|
+
}
|
|
4015
|
+
};
|
|
4016
|
+
const entries = [];
|
|
4017
|
+
i++;
|
|
4018
|
+
skipSpace();
|
|
4019
|
+
while (text2[i] !== "}") {
|
|
4020
|
+
const key = readString();
|
|
4021
|
+
skipSpace();
|
|
4022
|
+
i++;
|
|
4023
|
+
skipSpace();
|
|
4024
|
+
const start = i;
|
|
4025
|
+
skipValue();
|
|
4026
|
+
entries.push({ key, start, end: i });
|
|
4027
|
+
skipSpace();
|
|
4028
|
+
if (text2[i] === ",") i++;
|
|
4029
|
+
skipSpace();
|
|
4030
|
+
}
|
|
4031
|
+
return entries;
|
|
4032
|
+
}
|
|
4033
|
+
var valueOf = (text2, e) => JSON.parse(text2.slice(e.start, e.end));
|
|
3967
4034
|
function parseEventMap(text2, file) {
|
|
3968
4035
|
let json;
|
|
3969
4036
|
try {
|
|
@@ -3972,30 +4039,40 @@ function parseEventMap(text2, file) {
|
|
|
3972
4039
|
throw new Error(`${file}: the event map is not valid JSON.`);
|
|
3973
4040
|
}
|
|
3974
4041
|
if (!isRecord(json)) throw new Error(`${file}: the event map must be a JSON object.`);
|
|
3975
|
-
|
|
4042
|
+
const top = objectEntries(text2, text2.indexOf("{"));
|
|
4043
|
+
top.forEach((e, i) => {
|
|
4044
|
+
if (!TOP_KEYS2.has(e.key)) throw new Error(`${file}: top-level key ${i + 1} is not "events" or "paths".`);
|
|
4045
|
+
});
|
|
3976
4046
|
const map = { events: /* @__PURE__ */ Object.create(null), paths: /* @__PURE__ */ Object.create(null) };
|
|
3977
4047
|
const events = json.events ?? {};
|
|
3978
4048
|
if (!isRecord(events)) throw new Error(`${file}: "events" must be an object.`);
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
|
|
3983
|
-
|
|
4049
|
+
const eventsEntry = !isRecord(json.events) ? void 0 : top.findLast((e) => e.key === "events");
|
|
4050
|
+
(eventsEntry === void 0 ? [] : objectEntries(text2, eventsEntry.start)).forEach((e, i) => {
|
|
4051
|
+
const to = valueOf(text2, e);
|
|
4052
|
+
if (!EVENT_NAME.test(e.key)) throw new Error(`${file}: "events" key ${i + 1} is not an event name.`);
|
|
4053
|
+
if (typeof to !== "string" || !EVENT_NAME.test(to)) throw new Error(`${file}: "events" key ${i + 1} must map to an event name.`);
|
|
4054
|
+
map.events[e.key] = to;
|
|
4055
|
+
});
|
|
3984
4056
|
const paths = json.paths ?? {};
|
|
3985
4057
|
if (!isRecord(paths)) throw new Error(`${file}: "paths" must be an object.`);
|
|
3986
|
-
|
|
3987
|
-
|
|
3988
|
-
|
|
4058
|
+
const pathsEntry = !isRecord(json.paths) ? void 0 : top.findLast((e) => e.key === "paths");
|
|
4059
|
+
(pathsEntry === void 0 ? [] : objectEntries(text2, pathsEntry.start)).forEach((e, i) => {
|
|
4060
|
+
const at = `"paths" key ${i + 1}`;
|
|
4061
|
+
const renames = valueOf(text2, e);
|
|
4062
|
+
if (!EVENT_NAME.test(e.key)) throw new Error(`${file}: ${at} is not an event name.`);
|
|
4063
|
+
if (!isRecord(renames)) throw new Error(`${file}: ${at} must be an object.`);
|
|
3989
4064
|
const out = /* @__PURE__ */ Object.create(null);
|
|
3990
|
-
|
|
3991
|
-
|
|
3992
|
-
|
|
3993
|
-
|
|
3994
|
-
if (
|
|
3995
|
-
|
|
3996
|
-
|
|
3997
|
-
|
|
3998
|
-
|
|
4065
|
+
const inner = objectEntries(text2, e.start);
|
|
4066
|
+
if (inner.some((p) => p.key === ROOT) && inner.length > 1) throw new Error(`${file}: ${at} with the "${ROOT}" source key takes no other key.`);
|
|
4067
|
+
inner.forEach((p, j) => {
|
|
4068
|
+
const to = valueOf(text2, p);
|
|
4069
|
+
if (!PATH_NAME.test(p.key)) throw new Error(`${file}: ${at}, key ${j + 1} is not a key path.`);
|
|
4070
|
+
if (typeof to !== "string" || to !== ROOT && !PATH_NAME.test(to)) throw new Error(`${file}: ${at}, key ${j + 1} must map to a key path.`);
|
|
4071
|
+
if (p.key === ROOT && to === ROOT) throw new Error(`${file}: ${at}, key ${j + 1} must name a key path to move the root under.`);
|
|
4072
|
+
out[p.key] = to;
|
|
4073
|
+
});
|
|
4074
|
+
map.paths[e.key] = out;
|
|
4075
|
+
});
|
|
3999
4076
|
return map;
|
|
4000
4077
|
}
|
|
4001
4078
|
function builtInEventName(event) {
|
|
@@ -4033,14 +4110,18 @@ function mapPushGroups(groups, rename2, paths = {}, pathKeys = (recorded, final)
|
|
|
4033
4110
|
return { ...g, event, ...toGtag && g.kind !== void 0 ? { kind: "gtag" } : {}, paths: mapped };
|
|
4034
4111
|
});
|
|
4035
4112
|
}
|
|
4113
|
+
function mappedEventName(event, userMap) {
|
|
4114
|
+
return builtInEventName(userEventName(event, userMap?.events));
|
|
4115
|
+
}
|
|
4116
|
+
function userEventName(event, user) {
|
|
4117
|
+
const named = builtInEventName(event);
|
|
4118
|
+
return user !== void 0 && Object.hasOwn(user, event) ? user[event] : user !== void 0 && Object.hasOwn(user, named) ? user[named] : named;
|
|
4119
|
+
}
|
|
4036
4120
|
function normalizePushGroups(groups, userMap) {
|
|
4037
4121
|
const user = userMap?.events;
|
|
4038
|
-
const
|
|
4039
|
-
|
|
4040
|
-
|
|
4041
|
-
};
|
|
4042
|
-
const rename2 = (event) => builtInEventName(userName(event));
|
|
4043
|
-
const pathKeys = (recorded, final) => [final, recorded, userName(recorded)];
|
|
4122
|
+
const rename2 = (event) => mappedEventName(event, userMap);
|
|
4123
|
+
const targets = new Set(user === void 0 ? [] : Object.values(user));
|
|
4124
|
+
const pathKeys = (recorded, final) => [final, userEventName(recorded, user), recorded].filter((k, i) => i < 2 || !targets.has(k));
|
|
4044
4125
|
return mapPushGroups(groups, rename2, userMap?.paths, pathKeys);
|
|
4045
4126
|
}
|
|
4046
4127
|
|
|
@@ -4090,10 +4171,14 @@ function commandOf(e) {
|
|
|
4090
4171
|
const list3 = argumentsLike(e.args);
|
|
4091
4172
|
return list3 !== void 0 && isGtagCommand(list3) ? { list: list3, fromObject: true } : void 0;
|
|
4092
4173
|
}
|
|
4174
|
+
var CONSENT_COMMANDS = /* @__PURE__ */ new Set(["default", "update"]);
|
|
4175
|
+
function isObjectConsent(command) {
|
|
4176
|
+
return command?.fromObject === true && command.list[0] === "consent" && typeof command.list[1] === "string" && CONSENT_COMMANDS.has(command.list[1]);
|
|
4177
|
+
}
|
|
4093
4178
|
function commandLabel(command) {
|
|
4094
4179
|
const [name, second] = command.list;
|
|
4095
4180
|
if (command.fromObject && typeof second === "string") {
|
|
4096
|
-
if (
|
|
4181
|
+
if (isObjectConsent(command)) return `consent ${second}`;
|
|
4097
4182
|
if (name === "event") return safeName(second);
|
|
4098
4183
|
}
|
|
4099
4184
|
return GTAG_COMMANDS.has(name) ? `gtag ${name}` : GTAG_OTHER;
|
|
@@ -4108,7 +4193,8 @@ function frameKind(e) {
|
|
|
4108
4193
|
}
|
|
4109
4194
|
function collectPaths(e, command, into) {
|
|
4110
4195
|
if (e.event?.startsWith("gtm.")) return;
|
|
4111
|
-
if (
|
|
4196
|
+
if (command?.fromObject && command.list[0] === "event" && typeof command.list[1] === "string" && command.list[1].startsWith("gtm.")) return;
|
|
4197
|
+
if (e.isConsentCommand || isObjectConsent(command)) {
|
|
4112
4198
|
const signals = (command?.fromObject ? command.list : e.args)[2];
|
|
4113
4199
|
if (typeof signals === "object" && signals !== null) for (const [name, value] of Object.entries(signals)) walk(value, safeKey(name), 0, into);
|
|
4114
4200
|
return;
|
|
@@ -4227,27 +4313,68 @@ function pushNodes(groups, acrossFrames, mergeKinds) {
|
|
|
4227
4313
|
const frame = acrossFrames ? "any" : g.frame;
|
|
4228
4314
|
const kind = mergeKinds ? void 0 : g.kind;
|
|
4229
4315
|
const id = JSON.stringify([g.epoch, g.event, kind ?? null, frame]);
|
|
4230
|
-
const node = nodes.get(id) ?? { epoch: g.epoch, event: g.event, ...kind === void 0 ? {} : { kind }, frame, frames: [], types: /* @__PURE__ */ new Map() };
|
|
4316
|
+
const node = nodes.get(id) ?? { epoch: g.epoch, event: g.event, ...kind === void 0 ? {} : { kind }, frame, frames: [], types: /* @__PURE__ */ new Map(), ...g.renamedFrom === void 0 ? {} : { renamedFrom: g.renamedFrom } };
|
|
4231
4317
|
if (!node.frames.includes(g.frame)) node.frames.push(g.frame);
|
|
4232
4318
|
for (const p of g.paths) node.types.set(p.path, [.../* @__PURE__ */ new Set([...node.types.get(p.path) ?? [], ...p.types])].sort());
|
|
4233
4319
|
nodes.set(id, node);
|
|
4234
4320
|
}
|
|
4235
4321
|
return nodes;
|
|
4236
4322
|
}
|
|
4237
|
-
var nodeRef = (n
|
|
4323
|
+
var nodeRef = (n, renamedFrom = n.renamedFrom) => ({
|
|
4324
|
+
epoch: n.epoch,
|
|
4325
|
+
event: n.event,
|
|
4326
|
+
...n.kind === void 0 ? {} : { kind: n.kind },
|
|
4327
|
+
frame: n.frame,
|
|
4328
|
+
...renamedFrom === void 0 ? {} : { renamedFrom }
|
|
4329
|
+
});
|
|
4330
|
+
var epochEventId = (g) => JSON.stringify([g.epoch, g.event]);
|
|
4331
|
+
var byEventThenEpoch = (x, y) => x.event < y.event ? -1 : x.event > y.event ? 1 : x.epoch < y.epoch ? -1 : x.epoch > y.epoch ? 1 : 0;
|
|
4332
|
+
function pairNames(a, b, userMap) {
|
|
4333
|
+
const inA = new Set(a.map(epochEventId));
|
|
4334
|
+
const inB = new Set(b.map(epochEventId));
|
|
4335
|
+
const unique = (groups) => [...new Map(groups.map((g) => [epochEventId(g), g])).values()];
|
|
4336
|
+
const onlyA = unique(a.filter((g) => !inB.has(epochEventId(g)))).sort(byEventThenEpoch);
|
|
4337
|
+
const onlyB = unique(b.filter((g) => !inA.has(epochEventId(g)))).sort(byEventThenEpoch);
|
|
4338
|
+
const movedNames = new Set(onlyA.map((g) => g.event).filter((n) => onlyB.some((g) => g.event === n)));
|
|
4339
|
+
const taken = new Set(inA);
|
|
4340
|
+
const claimed = /* @__PURE__ */ new Set();
|
|
4341
|
+
const joined = /* @__PURE__ */ new Map();
|
|
4342
|
+
const pair = (sameEpoch) => {
|
|
4343
|
+
for (const from of onlyA) {
|
|
4344
|
+
if (joined.has(epochEventId(from)) || !sameEpoch && movedNames.has(from.event)) continue;
|
|
4345
|
+
const want = mappedEventName(from.event, userMap);
|
|
4346
|
+
const to = onlyB.find(
|
|
4347
|
+
(g) => !claimed.has(epochEventId(g)) && builtInEventName(g.event) === want && !taken.has(JSON.stringify([from.epoch, g.event])) && (sameEpoch ? g.epoch === from.epoch : !movedNames.has(g.event))
|
|
4348
|
+
);
|
|
4349
|
+
if (to === void 0) continue;
|
|
4350
|
+
claimed.add(epochEventId(to));
|
|
4351
|
+
taken.add(JSON.stringify([from.epoch, to.event]));
|
|
4352
|
+
joined.set(epochEventId(from), to.event);
|
|
4353
|
+
}
|
|
4354
|
+
};
|
|
4355
|
+
pair(true);
|
|
4356
|
+
pair(false);
|
|
4357
|
+
const targets = new Set(Object.values(userMap?.events ?? {}));
|
|
4358
|
+
const kept = mapPushGroups(a, (e) => e, userMap?.paths, (r) => [r, builtInEventName(r)].filter((k, i) => i === 0 || !targets.has(k)));
|
|
4359
|
+
return normalizePushGroups(a, userMap).map((g, i) => {
|
|
4360
|
+
const recorded = a[i];
|
|
4361
|
+
const to = joined.get(epochEventId(recorded));
|
|
4362
|
+
return to === void 0 ? kept[i] : { ...g, event: to, renamedFrom: recorded.event };
|
|
4363
|
+
});
|
|
4364
|
+
}
|
|
4238
4365
|
var typesId = (n) => JSON.stringify([...n.types].sort(([x], [y]) => x < y ? -1 : x > y ? 1 : 0));
|
|
4239
4366
|
function diffPushes(a, b, options = {}) {
|
|
4240
4367
|
const result = { eventsAdded: [], eventsRemoved: [], pathsAdded: [], pathsRemoved: [], typeChanges: [], moved: [], kindChanged: [], changed: false };
|
|
4241
4368
|
const mergeKinds = [...a, ...b].some((g) => g.kind === void 0);
|
|
4242
|
-
const na = pushNodes(
|
|
4243
|
-
const nb = pushNodes(
|
|
4369
|
+
const na = pushNodes(pairNames(a, b, options.eventMap), options.acrossFrames ?? false, mergeKinds);
|
|
4370
|
+
const nb = pushNodes(b, options.acrossFrames ?? false, mergeKinds);
|
|
4244
4371
|
const gone = [];
|
|
4245
4372
|
const fresh = [];
|
|
4246
4373
|
const compare = (x, y) => {
|
|
4247
4374
|
for (const [path, types] of y.types) {
|
|
4248
4375
|
const before = x.types.get(path);
|
|
4249
|
-
if (!before) result.pathsAdded.push({ ...nodeRef(y), path, types });
|
|
4250
|
-
else if (before.join() !== types.join()) result.typeChanges.push({ ...nodeRef(y), path, a: before, b: types });
|
|
4376
|
+
if (!before) result.pathsAdded.push({ ...nodeRef(y, x.renamedFrom), path, types });
|
|
4377
|
+
else if (before.join() !== types.join()) result.typeChanges.push({ ...nodeRef(y, x.renamedFrom), path, a: before, b: types });
|
|
4251
4378
|
}
|
|
4252
4379
|
for (const [path, types] of x.types) if (!y.types.has(path)) result.pathsRemoved.push({ ...nodeRef(x), path, types });
|
|
4253
4380
|
if (x.frames.slice().sort().join() !== y.frames.slice().sort().join()) {
|
|
@@ -4280,14 +4407,14 @@ function diffPushes(a, b, options = {}) {
|
|
|
4280
4407
|
return i >= 0 && j >= 0 && Math.abs(i - j) === 1 && order.filter((l) => l === g.epoch || l === f.epoch).length === 2;
|
|
4281
4408
|
});
|
|
4282
4409
|
if (!match) {
|
|
4283
|
-
result.eventsRemoved.push(nodeRef(g));
|
|
4410
|
+
result.eventsRemoved.push({ ...nodeRef({ ...g, renamedFrom: void 0 }), event: g.renamedFrom ?? g.event });
|
|
4284
4411
|
continue;
|
|
4285
4412
|
}
|
|
4286
4413
|
taken.add(match);
|
|
4287
4414
|
result.moved.push({ event: g.event, kind: "epoch", frame: g.frame, from: g.epoch, to: match.epoch });
|
|
4288
4415
|
}
|
|
4289
4416
|
for (const f of fresh) if (!taken.has(f)) result.eventsAdded.push(nodeRef(f));
|
|
4290
|
-
result.changed = result.eventsAdded.length + result.eventsRemoved.length + result.pathsAdded.length + result.pathsRemoved.length + result.typeChanges.length > 0;
|
|
4417
|
+
result.changed = result.eventsAdded.length + result.eventsRemoved.length + result.pathsAdded.length + result.pathsRemoved.length + result.typeChanges.length + result.kindChanged.length > 0;
|
|
4291
4418
|
return result;
|
|
4292
4419
|
}
|
|
4293
4420
|
function hitShape(run, options = {}) {
|
|
@@ -4921,7 +5048,7 @@ function dataLayerInitScript(names = []) {
|
|
|
4921
5048
|
}
|
|
4922
5049
|
};
|
|
4923
5050
|
let assigned = own && 'value' in own ? own.value : record;
|
|
4924
|
-
const state = { info, sync, schedule };
|
|
5051
|
+
const state = { info, name: layerName, sync, schedule };
|
|
4925
5052
|
hooks.set(layer, state);
|
|
4926
5053
|
// A push accessor the page defined stays in place; the growth check still records.
|
|
4927
5054
|
const foreign = own && !('value' in own);
|
|
@@ -4962,8 +5089,12 @@ function dataLayerInitScript(names = []) {
|
|
|
4962
5089
|
if (!found) return !(name in window);
|
|
4963
5090
|
return found.configurable === true && 'value' in found && Array.isArray(found.value);
|
|
4964
5091
|
};
|
|
5092
|
+
const untrapped = [];
|
|
4965
5093
|
for (const name of names) {
|
|
4966
|
-
if (!trappable(name))
|
|
5094
|
+
if (!trappable(name)) {
|
|
5095
|
+
untrapped.push(name);
|
|
5096
|
+
continue;
|
|
5097
|
+
}
|
|
4967
5098
|
current[name] = window[name];
|
|
4968
5099
|
try {
|
|
4969
5100
|
hook(current[name], name);
|
|
@@ -4992,25 +5123,34 @@ function dataLayerInitScript(names = []) {
|
|
|
4992
5123
|
},
|
|
4993
5124
|
});
|
|
4994
5125
|
}
|
|
5126
|
+
// Text, so page code cannot change the answer by replacing an Array method.
|
|
5127
|
+
const untrappedText = JSON.stringify(untrapped);
|
|
4995
5128
|
Object.defineProperty(window, ${JSON.stringify(DATALAYER_TALLY)}, {
|
|
4996
5129
|
value: () => {
|
|
4997
5130
|
const arrays = [];
|
|
4998
|
-
|
|
4999
|
-
|
|
5000
|
-
|
|
5001
|
-
|
|
5131
|
+
// Page code can break Set or the array iterator; the untrapped list must still come back.
|
|
5132
|
+
try {
|
|
5133
|
+
const seen = new Set();
|
|
5134
|
+
for (const name of names) {
|
|
5002
5135
|
try {
|
|
5003
|
-
layer
|
|
5004
|
-
|
|
5005
|
-
|
|
5006
|
-
|
|
5007
|
-
|
|
5008
|
-
|
|
5009
|
-
|
|
5010
|
-
|
|
5011
|
-
|
|
5012
|
-
|
|
5013
|
-
|
|
5136
|
+
let layer;
|
|
5137
|
+
reading = true;
|
|
5138
|
+
try {
|
|
5139
|
+
layer = window[name];
|
|
5140
|
+
} finally {
|
|
5141
|
+
reading = false;
|
|
5142
|
+
}
|
|
5143
|
+
if (!Array.isArray(layer) || seen.has(layer)) continue;
|
|
5144
|
+
seen.add(layer);
|
|
5145
|
+
const state = hooks.get(layer);
|
|
5146
|
+
// Another frame's hook owns it and that frame counts it.
|
|
5147
|
+
if (!state && Object.prototype.hasOwnProperty.call(layer, '__tagreeveHooked')) continue;
|
|
5148
|
+
if (state) state.sync();
|
|
5149
|
+
arrays.push({ layer: state ? state.name : name, a: state ? state.info.a : null, length: layer.length, posted: state ? state.info.posted : 0 });
|
|
5150
|
+
} catch {}
|
|
5151
|
+
}
|
|
5152
|
+
} catch {}
|
|
5153
|
+
return { d: token, arrays, untrapped: untrappedText };
|
|
5014
5154
|
},
|
|
5015
5155
|
});
|
|
5016
5156
|
})();`;
|
|
@@ -5094,7 +5234,7 @@ function isFirstPartySubdomain(req, scope, trackers = trackerList) {
|
|
|
5094
5234
|
function flag(runId, kind, recordIds, detail) {
|
|
5095
5235
|
return { type: "flag", id: newId("flag"), runId, kind, recordIds, detail };
|
|
5096
5236
|
}
|
|
5097
|
-
function buildFlags({ runId, networkMode, siteUrl, firstPartyHosts, trackers = trackerList, platformHosts: platformHosts2 = true, requests, hits, identity, routedRequestIds, responses = [], handedToChromium = /* @__PURE__ */ new Set(), redirectHeaderWithoutRedirect = /* @__PURE__ */ new Set() }) {
|
|
5237
|
+
function buildFlags({ runId, networkMode, siteUrl, firstPartyHosts, trackers = trackerList, platformHosts: platformHosts2 = true, requests, hits, identity, dataLayerEvents = [], routedRequestIds, responses = [], handedToChromium = /* @__PURE__ */ new Set(), redirectHeaderWithoutRedirect = /* @__PURE__ */ new Set() }) {
|
|
5098
5238
|
const answered = new Set(responses.map((r) => r.requestId));
|
|
5099
5239
|
const scope = { siteHost: parse(siteUrl)?.hostname ?? "", firstPartyHosts };
|
|
5100
5240
|
const flags2 = [];
|
|
@@ -5125,7 +5265,9 @@ function buildFlags({ runId, networkMode, siteUrl, firstPartyHosts, trackers = t
|
|
|
5125
5265
|
}
|
|
5126
5266
|
}
|
|
5127
5267
|
if (identity) {
|
|
5128
|
-
for (const leak of findForeignData(requests, hits, identity
|
|
5268
|
+
for (const leak of findForeignData(requests, hits, identity, dataLayerEvents)) {
|
|
5269
|
+
flags2.push(flag(runId, leak.source === "push" ? "possibleRealDataPush" : "possibleRealData", leak.evidence, leak.detail));
|
|
5270
|
+
}
|
|
5129
5271
|
}
|
|
5130
5272
|
return flags2;
|
|
5131
5273
|
}
|
|
@@ -5381,9 +5523,9 @@ function handoffOverlayScript(nonce) {
|
|
|
5381
5523
|
setText(button, 'Done');
|
|
5382
5524
|
appendChild(pill, label, button);
|
|
5383
5525
|
appendToRoot(root, pill);
|
|
5384
|
-
apply(pill, { display: 'flex', 'align-items': '
|
|
5385
|
-
apply(label, {
|
|
5386
|
-
apply(button, { all: 'unset', 'box-sizing': 'border-box', background: '#2f7d4f', color: '#fff', padding: '4px 14px', 'border-radius': '999px', 'font-weight': '600', cursor: 'pointer', 'flex-shrink': '0' });
|
|
5526
|
+
apply(pill, { display: 'flex', 'align-items': 'flex-start', gap: '10px', padding: '6px 6px 6px 12px', background: '#1d2530', color: '#fff', font: '13px/1.3 system-ui, sans-serif', 'border-radius': '999px', 'box-sizing': 'border-box', 'max-width': '100%', 'box-shadow': '0 2px 10px rgba(0,0,0,.35)', cursor: 'grab', 'user-select': 'none', 'touch-action': 'none' });
|
|
5527
|
+
apply(label, { display: '-webkit-box', '-webkit-box-orient': 'vertical', '-webkit-line-clamp': '4', overflow: 'hidden', 'overflow-wrap': 'anywhere', 'max-width': '300px', 'min-width': '0' });
|
|
5528
|
+
apply(button, { all: 'unset', 'box-sizing': 'border-box', background: '#2f7d4f', color: '#fff', padding: '4px 14px', 'align-self': 'stretch', display: 'flex', 'align-items': 'center', 'border-radius': '999px', 'font-weight': '600', cursor: 'pointer', 'flex-shrink': '0' });
|
|
5387
5529
|
addListener(button, 'click', (event) => {
|
|
5388
5530
|
if (!trusted(event)) return;
|
|
5389
5531
|
Promise.resolve(doneFn(NONCE)).catch(() => {});
|
|
@@ -5870,9 +6012,18 @@ var PayloadCounts = class _PayloadCounts {
|
|
|
5870
6012
|
}
|
|
5871
6013
|
};
|
|
5872
6014
|
var isCount = (value) => Number.isSafeInteger(value) && value >= 0;
|
|
6015
|
+
function parseNames(text2) {
|
|
6016
|
+
if (typeof text2 !== "string" || text2.length > 4096) return [];
|
|
6017
|
+
try {
|
|
6018
|
+
const parsed = JSON.parse(text2);
|
|
6019
|
+
return Array.isArray(parsed) ? parsed.filter((n) => typeof n === "string") : [];
|
|
6020
|
+
} catch {
|
|
6021
|
+
return [];
|
|
6022
|
+
}
|
|
6023
|
+
}
|
|
5873
6024
|
function validateTally(frame, value, names) {
|
|
5874
6025
|
if (typeof value !== "object" || value === null) return null;
|
|
5875
|
-
const { d, arrays } = value;
|
|
6026
|
+
const { d, arrays, untrapped } = value;
|
|
5876
6027
|
if (typeof d !== "string" || d.length > 64 || !Array.isArray(arrays)) return null;
|
|
5877
6028
|
const kept = [];
|
|
5878
6029
|
for (const entry of arrays) {
|
|
@@ -5882,7 +6033,8 @@ function validateTally(frame, value, names) {
|
|
|
5882
6033
|
if (!isCount(length) || !isCount(posted) || !(a === null || isCount(a))) continue;
|
|
5883
6034
|
kept.push({ layer, a, length, posted });
|
|
5884
6035
|
}
|
|
5885
|
-
|
|
6036
|
+
const untrappedKept = parseNames(untrapped).filter((n) => n !== DEFAULT_DATALAYER && names.includes(n));
|
|
6037
|
+
return { frame, d, arrays: kept, untrapped: [...new Set(untrappedKept)] };
|
|
5886
6038
|
}
|
|
5887
6039
|
function postedAhead(tallies, counts) {
|
|
5888
6040
|
return tallies.some(
|
|
@@ -6165,7 +6317,8 @@ function loaderLayerName(req) {
|
|
|
6165
6317
|
}
|
|
6166
6318
|
var MAX_LISTED_NAMES = 5;
|
|
6167
6319
|
function buildDataLayerNotHookedFlag(input) {
|
|
6168
|
-
const
|
|
6320
|
+
const untrapped = new Set(input.untrapped ?? []);
|
|
6321
|
+
const hooked = new Set([DEFAULT_DATALAYER, ...input.hooked].filter((name) => !untrapped.has(name)));
|
|
6169
6322
|
const misses = input.loaders.filter((l) => !hooked.has(l.name));
|
|
6170
6323
|
if (misses.length === 0) return void 0;
|
|
6171
6324
|
const names = [...new Set(misses.map((m) => isDataLayerName(m.name) && !isValueSegment(m.name) ? `"${m.name}"` : "(other)"))];
|
|
@@ -6173,13 +6326,14 @@ function buildDataLayerNotHookedFlag(input) {
|
|
|
6173
6326
|
const rest = names.length - MAX_LISTED_NAMES;
|
|
6174
6327
|
const shown2 = rest > 0 ? `${listed} and ${rest} more` : listed;
|
|
6175
6328
|
const plural2 = names.length > 1;
|
|
6329
|
+
const advice = misses.every((m) => untrapped.has(m.name) && input.hooked.includes(m.name)) ? "The page defines them in a way the hook cannot trap." : "Add them to options.dataLayerNames.";
|
|
6176
6330
|
return {
|
|
6177
6331
|
type: "flag",
|
|
6178
6332
|
id: newId("flag"),
|
|
6179
6333
|
runId: input.runId,
|
|
6180
6334
|
kind: "dataLayerNotHooked",
|
|
6181
6335
|
recordIds: misses.map((m) => m.id),
|
|
6182
|
-
detail: plural2 ? `Google loaders name the data layers ${shown2}, which are not hooked, so pushes to them are not recorded.
|
|
6336
|
+
detail: plural2 ? `Google loaders name the data layers ${shown2}, which are not hooked, so pushes to them are not recorded. ${advice}` : `A Google loader names the data layer ${shown2}, which is not hooked, so pushes to it are not recorded. ${advice.replace("them", "it")}`
|
|
6183
6337
|
};
|
|
6184
6338
|
}
|
|
6185
6339
|
|
|
@@ -7637,6 +7791,14 @@ function linkServerHits({ hits, requests, serverHosts, identity, inFlight }) {
|
|
|
7637
7791
|
onServerHost
|
|
7638
7792
|
};
|
|
7639
7793
|
});
|
|
7794
|
+
const hitRequestIds = new Set(hits.map((h) => h.requestId));
|
|
7795
|
+
const hasConcurrentRequest = (only, from, to, callClientIds) => requests.some((r) => {
|
|
7796
|
+
if (r.captured === "serverContainer" || r.id === only.hit.requestId || !isServerContainerRequest(r, serverHosts)) return false;
|
|
7797
|
+
const sentAt = inFlight?.get(r.id)?.sentAt ?? r.t;
|
|
7798
|
+
if (sentAt < from || sentAt > to) return false;
|
|
7799
|
+
if (!hitRequestIds.has(r.id)) return true;
|
|
7800
|
+
return [...clientIdsOf(r)].some((id) => callClientIds.has(id));
|
|
7801
|
+
});
|
|
7640
7802
|
const isServer = (f) => f.request?.captured === "serverContainer";
|
|
7641
7803
|
const browser = facts.filter((f) => !isServer(f));
|
|
7642
7804
|
return facts.map((f) => {
|
|
@@ -7654,10 +7816,12 @@ function linkServerHits({ hits, requests, serverHosts, identity, inFlight }) {
|
|
|
7654
7816
|
});
|
|
7655
7817
|
const only = sameKey.length === 1 ? sameKey[0] : void 0;
|
|
7656
7818
|
const window2 = only && inFlight?.get(only.hit.requestId);
|
|
7657
|
-
|
|
7819
|
+
const inFlightNow = only !== void 0 && window2 && callAt !== void 0 && callAt < window2.answeredAt;
|
|
7820
|
+
const concurrent = inFlightNow && hasConcurrentRequest(only, window2.sentAt, callAt, f.clientIds);
|
|
7821
|
+
if (inFlightNow && !concurrent) {
|
|
7658
7822
|
return { ...f.hit, via: { hitId: only.hit.id, by: "clientId", confidence: "exact" } };
|
|
7659
7823
|
}
|
|
7660
|
-
const clientIdMiss = f.hit.event === null || f.clientIds.size === 0 ? "noClientId" : sameKey.length === 0 ? "noSameKeyHit" : sameKey.length > 1 ? "severalSameKeyHits" : "answeredBefore";
|
|
7824
|
+
const clientIdMiss = f.hit.event === null || f.clientIds.size === 0 ? "noClientId" : sameKey.length === 0 ? "noSameKeyHit" : sameKey.length > 1 ? "severalSameKeyHits" : concurrent ? "concurrentRequest" : "answeredBefore";
|
|
7661
7825
|
const linkMiss = { eventId: eventIdMiss, clientId: clientIdMiss };
|
|
7662
7826
|
const earlier = browser.flatMap((b) => {
|
|
7663
7827
|
const by = b.hit.t <= f.hit.t ? sharedKind(f, b) : void 0;
|
|
@@ -7843,6 +8007,7 @@ var Recorder = class _Recorder {
|
|
|
7843
8007
|
dataLayerEvents = [];
|
|
7844
8008
|
dataLayerReassigns = [];
|
|
7845
8009
|
payloadCounts = new PayloadCounts();
|
|
8010
|
+
untrappedLayerNames = [];
|
|
7846
8011
|
eventFrames = /* @__PURE__ */ new Map();
|
|
7847
8012
|
frameNumbers = /* @__PURE__ */ new WeakMap();
|
|
7848
8013
|
frameNavigations = /* @__PURE__ */ new WeakMap();
|
|
@@ -8576,15 +8741,15 @@ var Recorder = class _Recorder {
|
|
|
8576
8741
|
const tallies = [];
|
|
8577
8742
|
let frames = [];
|
|
8578
8743
|
try {
|
|
8579
|
-
frames = this.context.pages().flatMap((page2) => page2.frames());
|
|
8744
|
+
frames = this.context.pages().flatMap((page2) => page2.frames().map((frame, i) => ({ frame, top: i === 0 })));
|
|
8580
8745
|
} catch {
|
|
8581
8746
|
return tallies;
|
|
8582
8747
|
}
|
|
8583
8748
|
const script = `window.${DATALAYER_TALLY}?.()`;
|
|
8584
|
-
const asking = frames.map(async (frame) => {
|
|
8749
|
+
const asking = frames.map(async ({ frame, top }) => {
|
|
8585
8750
|
try {
|
|
8586
8751
|
const tally = validateTally(this.frameNumber(frame), await frame.evaluate(script), names);
|
|
8587
|
-
if (tally) tallies.push(tally);
|
|
8752
|
+
if (tally) tallies.push(top ? tally : { ...tally, untrapped: [] });
|
|
8588
8753
|
} catch {
|
|
8589
8754
|
}
|
|
8590
8755
|
});
|
|
@@ -8598,6 +8763,7 @@ var Recorder = class _Recorder {
|
|
|
8598
8763
|
}
|
|
8599
8764
|
async tallyDataLayers() {
|
|
8600
8765
|
const tallies = await this.collectTallies();
|
|
8766
|
+
this.untrappedLayerNames = [...new Set(tallies.flatMap((t) => t.untrapped))];
|
|
8601
8767
|
const start = Date.now();
|
|
8602
8768
|
while (postedAhead(tallies, this.payloadCounts) && Date.now() - start < TALLY_POSTED_WAIT_MS) await this.wait(20);
|
|
8603
8769
|
return buildTallyFlags(this.runId, tallies, this.payloadCounts);
|
|
@@ -8670,6 +8836,7 @@ var Recorder = class _Recorder {
|
|
|
8670
8836
|
requests,
|
|
8671
8837
|
hits,
|
|
8672
8838
|
identity: this.run.identity,
|
|
8839
|
+
dataLayerEvents: this.dataLayerEvents,
|
|
8673
8840
|
routedRequestIds: this.routed,
|
|
8674
8841
|
responses: this.responses,
|
|
8675
8842
|
handedToChromium: this.handedToChromium,
|
|
@@ -8682,7 +8849,7 @@ var Recorder = class _Recorder {
|
|
|
8682
8849
|
flags2.push({ type: "flag", id: newId("flag"), runId: this.runId, kind: "netLogUnreadable", recordIds: [], detail: "The net log could not be read, so requests sent while a frame unloads may be missing." });
|
|
8683
8850
|
}
|
|
8684
8851
|
flags2.push(...this.dataLayerReassignedFlags(requests));
|
|
8685
|
-
const notHooked = buildDataLayerNotHookedFlag({ runId: this.runId, loaders: this.loaderLayers, hooked: this.options.dataLayerNames ?? [] });
|
|
8852
|
+
const notHooked = buildDataLayerNotHookedFlag({ runId: this.runId, loaders: this.loaderLayers, hooked: this.options.dataLayerNames ?? [], untrapped: this.untrappedLayerNames });
|
|
8686
8853
|
if (notHooked) flags2.push(notHooked);
|
|
8687
8854
|
flags2.push(...tallyFlags);
|
|
8688
8855
|
this.recordServerContainer(requests, hits, containerCounts, flags2);
|
|
@@ -8903,12 +9070,13 @@ var BLOCK_REASONS = ["required, not ticked", "invalid", "aria-invalid"];
|
|
|
8903
9070
|
var INPUT_TYPES = ["checkbox", "color", "date", "datetime-local", "email", "file", "month", "number", "password", "radio", "range", "search", "tel", "text", "time", "url", "week"];
|
|
8904
9071
|
var WIDGET_ROLES = ["checkbox", "combobox", "listbox", "radio", "radiogroup", "searchbox", "slider", "spinbutton", "switch", "textbox"];
|
|
8905
9072
|
var KINDS = [...INPUT_TYPES, ...WIDGET_ROLES, "select", "textarea"];
|
|
8906
|
-
function readBlockingControls(max) {
|
|
9073
|
+
function readBlockingControls({ max, form }) {
|
|
8907
9074
|
const found = [];
|
|
8908
9075
|
const nameOf2 = (el) => el.getAttribute("aria-label")?.trim() || el.getAttribute("name") || el.id;
|
|
8909
9076
|
for (const el of document.querySelectorAll('input, select, textarea, [aria-invalid="true"]')) {
|
|
8910
9077
|
if (el instanceof HTMLInputElement && (el.type === "hidden" || el.type === "submit" || el.type === "button" || el.type === "reset" || el.type === "image")) continue;
|
|
8911
9078
|
const input = el;
|
|
9079
|
+
if (form && el.form !== form) continue;
|
|
8912
9080
|
const checkbox = el instanceof HTMLInputElement && el.type === "checkbox";
|
|
8913
9081
|
let reason;
|
|
8914
9082
|
if (checkbox && !input.checked && input.willValidate && (input.required || el.getAttribute("aria-required") === "true")) reason = "required, not ticked";
|
|
@@ -8929,11 +9097,11 @@ function withDeadline(work, ms) {
|
|
|
8929
9097
|
});
|
|
8930
9098
|
return Promise.race([work, deadline]).finally(() => clearTimeout(timer));
|
|
8931
9099
|
}
|
|
8932
|
-
async function blockingControls(context) {
|
|
9100
|
+
async function blockingControls(context, form = null) {
|
|
8933
9101
|
const listed = [];
|
|
8934
9102
|
for (const page2 of context.pages()) {
|
|
8935
9103
|
try {
|
|
8936
|
-
const controls = await withDeadline(page2.evaluate(readBlockingControls, MAX_LISTED4), DIAGNOSTIC_DEADLINE_MS);
|
|
9104
|
+
const controls = await withDeadline(page2.evaluate(readBlockingControls, { max: MAX_LISTED4, form }), DIAGNOSTIC_DEADLINE_MS);
|
|
8937
9105
|
for (const c of controls) {
|
|
8938
9106
|
if (!BLOCK_REASONS.includes(c.reason)) continue;
|
|
8939
9107
|
const kind = KINDS.includes(c.kind) ? c.kind : "control";
|
|
@@ -9039,7 +9207,7 @@ async function markerInCardContainer(frames, marker, timeout) {
|
|
|
9039
9207
|
return false;
|
|
9040
9208
|
}
|
|
9041
9209
|
}
|
|
9042
|
-
function
|
|
9210
|
+
function valueOf2(kind, provider, card, identity) {
|
|
9043
9211
|
if (kind === "number") return card;
|
|
9044
9212
|
if (kind === "expiry") return provider.expiry;
|
|
9045
9213
|
if (kind === "cvc") return provider.cvc;
|
|
@@ -9071,7 +9239,7 @@ async function runPayment(page2, recorder, value, identity, testPayment, record,
|
|
|
9071
9239
|
const typed = typedValues(provider, card, identity);
|
|
9072
9240
|
for (const [index, field] of runtime.fields.entries()) {
|
|
9073
9241
|
try {
|
|
9074
|
-
await fillVerified(found[index].element, field, runtime.cardHost,
|
|
9242
|
+
await fillVerified(found[index].element, field, runtime.cardHost, valueOf2(field.kind, provider, card, identity), timeout, typed);
|
|
9075
9243
|
} catch (error) {
|
|
9076
9244
|
throw new Error(`card field ${field.kind} could not be filled: ${reasonOf(error, typed)}`);
|
|
9077
9245
|
}
|
|
@@ -9087,37 +9255,64 @@ async function frameStillServed(element, cardHost, field) {
|
|
|
9087
9255
|
return frame;
|
|
9088
9256
|
}
|
|
9089
9257
|
var FILL_TRY_MS = 500;
|
|
9258
|
+
var UNREADABLE_FRAME = "the card frame could not be read";
|
|
9259
|
+
var DEADLINE_GRACE_MS = 500;
|
|
9260
|
+
var Unresponsive = class extends Error {
|
|
9261
|
+
};
|
|
9262
|
+
function withinDeadline(work, deadline) {
|
|
9263
|
+
let timer;
|
|
9264
|
+
const late = new Promise((_, reject) => {
|
|
9265
|
+
timer = setTimeout(() => reject(new Unresponsive()), Math.max(1, deadline - Date.now()) + DEADLINE_GRACE_MS);
|
|
9266
|
+
});
|
|
9267
|
+
work.catch(() => void 0);
|
|
9268
|
+
return Promise.race([work, late]).finally(() => clearTimeout(timer));
|
|
9269
|
+
}
|
|
9090
9270
|
async function fillVerified(element, field, cardHost, value, timeout, typed) {
|
|
9091
9271
|
const deadline = Date.now() + timeout;
|
|
9092
9272
|
const tryMs = () => Math.max(1, Math.min(FILL_TRY_MS, deadline - Date.now()));
|
|
9273
|
+
const readable = (work) => withinDeadline(work, deadline).catch((error) => {
|
|
9274
|
+
throw error instanceof Unresponsive ? new OwnReason(UNREADABLE_FRAME) : error;
|
|
9275
|
+
});
|
|
9093
9276
|
for (; ; ) {
|
|
9094
|
-
const frame = await frameStillServed(element, cardHost, field);
|
|
9277
|
+
const frame = await readable(frameStillServed(element, cardHost, field));
|
|
9095
9278
|
const checkedUrl = frame.url();
|
|
9096
9279
|
const inputs = frame.locator(field.input).filter({ visible: true });
|
|
9097
|
-
const count = await inputs.count();
|
|
9280
|
+
const count = await readable(inputs.count());
|
|
9098
9281
|
if (count === 1) {
|
|
9099
9282
|
let handle;
|
|
9100
9283
|
try {
|
|
9101
9284
|
handle = await inputs.elementHandle({ timeout: tryMs() });
|
|
9102
|
-
if ((await frameStillServed(element, cardHost, field)).url() !== checkedUrl) throw new OwnReason(GONE_FRAME);
|
|
9285
|
+
if ((await readable(frameStillServed(element, cardHost, field))).url() !== checkedUrl) throw new OwnReason(GONE_FRAME);
|
|
9103
9286
|
await handle.fill(value, { timeout: tryMs() });
|
|
9104
9287
|
return;
|
|
9105
9288
|
} catch (error) {
|
|
9106
9289
|
const timedOut = error instanceof Error && error.name === "TimeoutError";
|
|
9107
9290
|
if (error instanceof OwnReason) throw error;
|
|
9108
9291
|
if (timedOut && Date.now() < deadline) continue;
|
|
9109
|
-
|
|
9110
|
-
|
|
9111
|
-
|
|
9292
|
+
try {
|
|
9293
|
+
const moved = (await withinDeadline(frameStillServed(element, cardHost, field), deadline)).url() !== checkedUrl;
|
|
9294
|
+
const attached = handle ? await withinDeadline(handle.evaluate((e) => e.isConnected), deadline).catch((e) => {
|
|
9295
|
+
if (e instanceof Unresponsive) throw e;
|
|
9296
|
+
return false;
|
|
9297
|
+
}) : true;
|
|
9298
|
+
if (moved || !attached) throw new OwnReason(GONE_FRAME);
|
|
9299
|
+
} catch (check) {
|
|
9300
|
+
if (check instanceof Unresponsive) throw error;
|
|
9301
|
+
throw check;
|
|
9302
|
+
}
|
|
9112
9303
|
throw error;
|
|
9113
9304
|
}
|
|
9114
9305
|
}
|
|
9115
9306
|
if (Date.now() >= deadline) {
|
|
9116
|
-
const
|
|
9117
|
-
|
|
9118
|
-
|
|
9119
|
-
|
|
9120
|
-
|
|
9307
|
+
const unreadable2 = new OwnReason(`${count} visible inputs match in ${pathOf2(checkedUrl)}: inputs not readable`);
|
|
9308
|
+
const settle = async () => {
|
|
9309
|
+
const current = await frameStillServed(element, cardHost, field).catch(() => void 0);
|
|
9310
|
+
if (!current || current.url() !== checkedUrl) throw new OwnReason(GONE_FRAME);
|
|
9311
|
+
const reason = await countReason(current, pathOf2(checkedUrl), count, typed);
|
|
9312
|
+
if ((await frameStillServed(element, cardHost, field)).url() !== checkedUrl) throw new OwnReason(GONE_FRAME);
|
|
9313
|
+
throw new OwnReason(reason);
|
|
9314
|
+
};
|
|
9315
|
+
throw await withinDeadline(settle(), deadline).catch((error) => error instanceof Unresponsive ? unreadable2 : error);
|
|
9121
9316
|
}
|
|
9122
9317
|
await new Promise((resolve5) => setTimeout(resolve5, 100));
|
|
9123
9318
|
}
|
|
@@ -9388,13 +9583,48 @@ async function evaluateGuarded(page2, script) {
|
|
|
9388
9583
|
if (blocked || changed.length > 0) throw new Error(`the script set a card or password field. ${HANDOFF_REQUIRED}`);
|
|
9389
9584
|
if (scriptError) throw scriptError;
|
|
9390
9585
|
}
|
|
9586
|
+
var clickedForms = /* @__PURE__ */ new WeakMap();
|
|
9587
|
+
var REMEMBER_FORM_MS = 1e3;
|
|
9588
|
+
async function rememberClickedForm(recorder, target) {
|
|
9589
|
+
clickedForms.get(recorder)?.dispose().catch(() => void 0);
|
|
9590
|
+
clickedForms.delete(recorder);
|
|
9591
|
+
let timer;
|
|
9592
|
+
let expired = false;
|
|
9593
|
+
try {
|
|
9594
|
+
const work = target.evaluateHandle(
|
|
9595
|
+
(el) => {
|
|
9596
|
+
const control = el;
|
|
9597
|
+
const submits = control instanceof HTMLButtonElement && control.type === "submit" || control instanceof HTMLInputElement && (control.type === "submit" || control.type === "image");
|
|
9598
|
+
return submits ? control.form : null;
|
|
9599
|
+
},
|
|
9600
|
+
void 0,
|
|
9601
|
+
{ timeout: REMEMBER_FORM_MS }
|
|
9602
|
+
);
|
|
9603
|
+
work.then(
|
|
9604
|
+
(late) => {
|
|
9605
|
+
if (expired) late.dispose().catch(() => void 0);
|
|
9606
|
+
},
|
|
9607
|
+
() => void 0
|
|
9608
|
+
);
|
|
9609
|
+
const limit = new Promise((_, reject) => {
|
|
9610
|
+
timer = setTimeout(() => reject(new Error("form lookup timed out")), REMEMBER_FORM_MS + 500);
|
|
9611
|
+
});
|
|
9612
|
+
const handle = await Promise.race([work, limit]);
|
|
9613
|
+
if (handle.asElement() !== null) clickedForms.set(recorder, handle);
|
|
9614
|
+
else await handle.dispose();
|
|
9615
|
+
} catch {
|
|
9616
|
+
expired = true;
|
|
9617
|
+
} finally {
|
|
9618
|
+
clearTimeout(timer);
|
|
9619
|
+
}
|
|
9620
|
+
}
|
|
9391
9621
|
async function waitForUrl(recorder, url, timeout) {
|
|
9392
9622
|
const condition = { url };
|
|
9393
9623
|
const deadline = Date.now() + timeout;
|
|
9394
9624
|
while (!await conditionHolds(recorder.context, condition)) {
|
|
9395
9625
|
if (Date.now() >= deadline) {
|
|
9396
9626
|
const message = `page did not reach ${describeCondition(condition)} within ${formatDuration(timeout)}`;
|
|
9397
|
-
const blocking = await blockingControls(recorder.context);
|
|
9627
|
+
const blocking = await blockingControls(recorder.context, clickedForms.get(recorder) ?? null);
|
|
9398
9628
|
throw new Error(blocking.length === 0 ? message : `${message}. Blocking controls: ${blocking.join(", ")}.`);
|
|
9399
9629
|
}
|
|
9400
9630
|
await recorder.wait(100);
|
|
@@ -9418,6 +9648,7 @@ async function runStep(step, recorder, scenario, identity, options, record) {
|
|
|
9418
9648
|
case "click": {
|
|
9419
9649
|
const deadline = Date.now() + timeout;
|
|
9420
9650
|
const target = await locate(page2, recorder, step.value, record, timeout);
|
|
9651
|
+
await rememberClickedForm(recorder, target);
|
|
9421
9652
|
await withControlList(page2, recorder, step.value, () => target.click({ timeout: remaining(deadline) }));
|
|
9422
9653
|
return;
|
|
9423
9654
|
}
|
|
@@ -10035,13 +10266,14 @@ function flagChangeLabel(f) {
|
|
|
10035
10266
|
return `${f.host ? `${f.kind} ${f.host}` : f.kind}: ${f.a} -> ${f.b}`;
|
|
10036
10267
|
}
|
|
10037
10268
|
function describePushDiff(d) {
|
|
10269
|
+
const named = (r) => r.renamedFrom === void 0 ? r.event : `${r.event} (renamed from ${r.renamedFrom})`;
|
|
10038
10270
|
const at = (r) => `[epoch ${r.epoch}, frame ${r.frame}${r.kind === void 0 ? "" : `, kind ${r.kind}`}]`;
|
|
10039
10271
|
return [
|
|
10040
10272
|
...d.eventsRemoved.map((r) => `removed event ${r.event} ${at(r)}`),
|
|
10041
10273
|
...d.eventsAdded.map((r) => `new event ${r.event} ${at(r)}`),
|
|
10042
|
-
...d.pathsRemoved.map((p) => `missing path ${p.path} (${p.types.join("|")}) in ${p
|
|
10043
|
-
...d.pathsAdded.map((p) => `new path ${p.path} (${p.types.join("|")}) in ${p
|
|
10044
|
-
...d.typeChanges.map((p) => `type change ${p.path}: ${p.a.join("|")} -> ${p.b.join("|")} in ${p
|
|
10274
|
+
...d.pathsRemoved.map((p) => `missing path ${p.path} (${p.types.join("|")}) in ${named(p)} ${at(p)}`),
|
|
10275
|
+
...d.pathsAdded.map((p) => `new path ${p.path} (${p.types.join("|")}) in ${named(p)} ${at(p)}`),
|
|
10276
|
+
...d.typeChanges.map((p) => `type change ${p.path}: ${p.a.join("|")} -> ${p.b.join("|")} in ${named(p)} ${at(p)}`),
|
|
10045
10277
|
...d.moved.map(
|
|
10046
10278
|
(m) => m.kind === "frame" ? `moved event ${m.event} from frame ${m.from} to ${m.to} [epoch ${m.epoch}]` : `moved event ${m.event} from epoch ${m.from} to ${m.to} [frame ${m.frame}]`
|
|
10047
10279
|
)
|
|
@@ -10304,6 +10536,9 @@ var FRAME_KINDS = /* @__PURE__ */ new Set(["main", "embedded", "unknown"]);
|
|
|
10304
10536
|
function validPushGroup(g) {
|
|
10305
10537
|
return isRecord2(g) && typeof g.epoch === "string" && typeof g.event === "string" && (g.kind === void 0 || g.kind === "gtag" || g.kind === "object") && typeof g.frame === "string" && FRAME_KINDS.has(g.frame) && Array.isArray(g.paths) && g.paths.every((p) => isRecord2(p) && typeof p.path === "string" && isStringArray(p.types));
|
|
10306
10538
|
}
|
|
10539
|
+
function uniformKinds(groups) {
|
|
10540
|
+
return groups.every((g) => g.kind === void 0 === (groups[0].kind === void 0));
|
|
10541
|
+
}
|
|
10307
10542
|
function parseBaseline(text2, label) {
|
|
10308
10543
|
let json;
|
|
10309
10544
|
try {
|
|
@@ -10319,7 +10554,7 @@ function parseBaseline(text2, label) {
|
|
|
10319
10554
|
if (typeof json.scenario !== "string" || typeof json.site !== "string" || typeof json.byPage !== "boolean" || !Array.isArray(json.keys) || !json.keys.every(validKey)) {
|
|
10320
10555
|
throw new BaselineError(`${label} is not a valid baseline file`, "invalid");
|
|
10321
10556
|
}
|
|
10322
|
-
if (json.dataLayer !== void 0 && !(Array.isArray(json.dataLayer) && json.dataLayer.every(validPushGroup))) {
|
|
10557
|
+
if (json.dataLayer !== void 0 && !(Array.isArray(json.dataLayer) && json.dataLayer.every(validPushGroup) && uniformKinds(json.dataLayer))) {
|
|
10323
10558
|
throw new BaselineError(`${label} has an invalid dataLayer section`, "invalid");
|
|
10324
10559
|
}
|
|
10325
10560
|
return json;
|
|
@@ -10385,7 +10620,7 @@ function compareBaseline(baseline, records) {
|
|
|
10385
10620
|
const diff = diffShapes(baseline.keys, hitShape(records, { byPage: baseline.byPage }), { epochOrder: epochOrder2 });
|
|
10386
10621
|
warnings.push(...diff.moved.map(describeMove));
|
|
10387
10622
|
if (baseline.dataLayer === void 0) {
|
|
10388
|
-
warnings.push("dataLayer pushes not compared: the baseline has no push shapes (saved
|
|
10623
|
+
warnings.push("dataLayer pushes not compared: the baseline has no push shapes (saved before 0.6.0-rc.2). Save it again to compare them.");
|
|
10389
10624
|
} else {
|
|
10390
10625
|
const pushes = diffPushes(baseline.dataLayer, pushGroups(records), { epochOrder: epochOrder2 });
|
|
10391
10626
|
warnings.push(...describePushDiff(pushes).map((line) => `dataLayer ${line}`));
|
|
@@ -10503,14 +10738,6 @@ var STARTER_CONFIG = `configSchemaVersion: 1
|
|
|
10503
10738
|
# out:
|
|
10504
10739
|
# options:
|
|
10505
10740
|
`;
|
|
10506
|
-
async function exists(path) {
|
|
10507
|
-
try {
|
|
10508
|
-
await stat4(path);
|
|
10509
|
-
return true;
|
|
10510
|
-
} catch {
|
|
10511
|
-
return false;
|
|
10512
|
-
}
|
|
10513
|
-
}
|
|
10514
10741
|
async function ensureIgnoreLine(cwd) {
|
|
10515
10742
|
const file = join9(cwd, ".gitignore");
|
|
10516
10743
|
let current;
|
|
@@ -10534,7 +10761,9 @@ async function ensureFolder(cwd, folder) {
|
|
|
10534
10761
|
return { path: `${folder}/`, action: "created", text: `Created ${folder}/` };
|
|
10535
10762
|
}
|
|
10536
10763
|
async function ensureConfig(cwd) {
|
|
10537
|
-
|
|
10764
|
+
const found = await stat4(join9(cwd, CONFIG)).catch(() => void 0);
|
|
10765
|
+
if (found && !found.isFile()) throw Object.assign(new Error("not a file"), { code: "NOTFILE" });
|
|
10766
|
+
if (found) return { path: CONFIG, action: "skipped", text: `Skipped ${CONFIG}: it exists` };
|
|
10538
10767
|
await mkdir3(join9(cwd, "tagreeve"), { recursive: true });
|
|
10539
10768
|
await writeFile3(join9(cwd, CONFIG), STARTER_CONFIG, { flag: "wx" });
|
|
10540
10769
|
return { path: CONFIG, action: "created", text: `Created ${CONFIG}` };
|
|
@@ -10542,6 +10771,8 @@ async function ensureConfig(cwd) {
|
|
|
10542
10771
|
function failureText(path, error) {
|
|
10543
10772
|
const code = error?.code;
|
|
10544
10773
|
if (code === "NOTFOLDER") return `${path.replace(/\/$/, "")} is not a folder
|
|
10774
|
+
`;
|
|
10775
|
+
if (code === "NOTFILE") return `${path} is not a file
|
|
10545
10776
|
`;
|
|
10546
10777
|
const reason = code === "EACCES" || code === "EPERM" ? "permission denied" : code === "EEXIST" ? "it exists" : code === "ENOTDIR" || code === "EISDIR" ? "a file or folder is in the way" : "the write failed";
|
|
10547
10778
|
return `Could not write ${path}: ${reason}
|
|
@@ -11323,7 +11554,7 @@ function testPaymentOf(records) {
|
|
|
11323
11554
|
function notExactCounts(hits) {
|
|
11324
11555
|
const out = {
|
|
11325
11556
|
eventId: { none: 0, noMatch: 0, several: 0 },
|
|
11326
|
-
clientId: { noClientId: 0, noSameKeyHit: 0, severalSameKeyHits: 0, answeredBefore: 0 }
|
|
11557
|
+
clientId: { noClientId: 0, noSameKeyHit: 0, severalSameKeyHits: 0, answeredBefore: 0, concurrentRequest: 0 }
|
|
11327
11558
|
};
|
|
11328
11559
|
for (const { linkMiss } of hits) {
|
|
11329
11560
|
if (!linkMiss) continue;
|
|
@@ -11390,11 +11621,16 @@ function formatFlags(flags2) {
|
|
|
11390
11621
|
const lines = [];
|
|
11391
11622
|
const groups = /* @__PURE__ */ new Map();
|
|
11392
11623
|
let realData = 0;
|
|
11624
|
+
let realDataPush = 0;
|
|
11393
11625
|
for (const f of flags2) {
|
|
11394
11626
|
if (f.kind === "possibleRealData") {
|
|
11395
11627
|
realData += 1;
|
|
11396
11628
|
continue;
|
|
11397
11629
|
}
|
|
11630
|
+
if (f.kind === "possibleRealDataPush") {
|
|
11631
|
+
realDataPush += 1;
|
|
11632
|
+
continue;
|
|
11633
|
+
}
|
|
11398
11634
|
if (f.kind === "platformHost" && platformOf(f)) continue;
|
|
11399
11635
|
const target = groupTarget(f);
|
|
11400
11636
|
if (!target) {
|
|
@@ -11414,13 +11650,14 @@ function formatFlags(flags2) {
|
|
|
11414
11650
|
lines.push(` ${kind}: ${host} x${count} (${shown2.join(", ")}${more > 0 ? ` and ${more} more` : ""})`);
|
|
11415
11651
|
}
|
|
11416
11652
|
if (realData > 0) lines.push(` possibleRealData: x${realData}`);
|
|
11653
|
+
if (realDataPush > 0) lines.push(` possibleRealDataPush: x${realDataPush}`);
|
|
11417
11654
|
lines.push(...platformHostLines(flags2));
|
|
11418
11655
|
return lines;
|
|
11419
11656
|
}
|
|
11420
11657
|
var URL_TOKEN = /[a-z][a-z0-9+.-]*:\/\/\S+/gi;
|
|
11421
11658
|
var URL_PARTS = /^(?:(?:([a-z][a-z0-9+.-]*:)?\/\/)([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#.*)?$/is;
|
|
11422
11659
|
var RECEIVED_PAGE = /^(\S+ received )(.+)( as the page)$/s;
|
|
11423
|
-
var PROSE_KINDS = /* @__PURE__ */ new Set(["possibleRealData", "unloadGap", "netLogUnreadable", "serverContainerFailed", "dataLayerReassigned", "dataLayerNotHooked", "dataLayerIncomplete"]);
|
|
11660
|
+
var PROSE_KINDS = /* @__PURE__ */ new Set(["possibleRealData", "possibleRealDataPush", "unloadGap", "netLogUnreadable", "serverContainerFailed", "dataLayerReassigned", "dataLayerNotHooked", "dataLayerIncomplete"]);
|
|
11424
11661
|
var URL_AT_END = /^(.*?(?:\b[A-Z]+ |: ))((?:[a-z][a-z0-9+.-]*:)?\/\/.*|\/.*)$/s;
|
|
11425
11662
|
function queryName(pair) {
|
|
11426
11663
|
const eq = pair.indexOf("=");
|