tagreeve 0.8.1 → 0.9.0-rc.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/CHANGELOG.md +32 -0
- package/README.md +4 -2
- package/dist/cli.js +210 -27
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,37 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.9.0-rc.1
|
|
4
|
+
|
|
5
|
+
The first release candidate of 0.9.0. Install it with `npm i -g tagreeve@next`. It has no new command or option. The record stays at schema version 5. To go back to the final release, run `npm i -g tagreeve`.
|
|
6
|
+
|
|
7
|
+
### What 0.9.0-rc.1 adds
|
|
8
|
+
|
|
9
|
+
- Decode Pinterest Conversions API calls from server containers as `pinterest-capi`, and link them to browser hits by event ID (#1648, #1663).
|
|
10
|
+
|
|
11
|
+
### Fixes in 0.9.0-rc.1
|
|
12
|
+
|
|
13
|
+
- Server container: a call that arrives up to 2000 ms after its one same-key hit was answered, with no other same-client request or consent change between, is now an exact client-ID link, so a rule that only warned on it can now fail the run (#1640, #1659).
|
|
14
|
+
- Canaries: a control character inside a reserved name is refused, a `#` in an unused variable no longer refuses the run, and padded Base64 SHA-256 digests of canary and identity values now match (#1612, #1660).
|
|
15
|
+
- Consent matrix keeps event names with spaces or colons when they read as names (#1611, #1661).
|
|
16
|
+
- `dataLayer`: an iframe loader is bounded by a main-frame navigation of its page. A popup's first document request now has a frame, so a main-frame loader followed only by a popup navigation can warn (#1591, #1664).
|
|
17
|
+
|
|
18
|
+
### Upgrading from 0.8
|
|
19
|
+
|
|
20
|
+
- **Some warnings are now failures.** A server call behind a container that answers first, with one same-key hit and no concurrent request or consent change, is `exact`. A `mustNot`, `deniedIdentifiers`, `earlyIdentifiers` or `identifierRoute` result that was a `serverSendProbableLink` warning is now a judged link that can fail the run and exit 1.
|
|
21
|
+
- **`answeredBefore` and `concurrentRequest` cover different calls.** `answeredBefore` keeps its meaning and covers fewer calls: only a call more than 2000 ms after the answer, after a consent change, or with no answer time. An answered call with a concurrent request is now `concurrentRequest` where it was `answeredBefore`. Scripts that count either reason in `serverContainer.notExact` see different numbers.
|
|
22
|
+
- **A new vendor, `pinterest-capi`.** A baseline made before 0.9.0 shows added hits for a run that records the call. A rule for `vendor: pinterest` is not changed. A custom tracker-list entry with the vendor key `pinterest-capi` is now refused, as for any decoder key. A browser request to `api.pinterest.com/v5/.../events` is now stubbed in `stub` mode, and its hit replaces the unknown destination flag.
|
|
23
|
+
- **`Request.frame` has an optional `page`.** The schema version stays 5. A script that compares frames with strict equality sees one more key. A record made before 0.9.0 reads as before.
|
|
24
|
+
- **Stored event names change.** A spaced or coloned event name that read `(other)` in a stored suite now reads as itself, so a `suite.json` made by 0.8 differs in `events` and `notInAccept`.
|
|
25
|
+
- **A canary can newly fail a run.** A padded Base64 SHA-256 digest of a canary value, or of the identity email or phone, that was in a request before and went unseen is now found. A route flag for it reads transform `other`.
|
|
26
|
+
- **A new release needs a new server image.** On arm64 (Apple silicon), run `tagreeve server-container build` after `npm i -g tagreeve@next`. A run with `--server-container` exits 2 with "The image tagreeve-sgtm:<version> is not available" until the image for that version exists. On amd64 the command builds nothing.
|
|
27
|
+
|
|
28
|
+
### Known in 0.9.0-rc.1
|
|
29
|
+
|
|
30
|
+
Issues still open that you can meet, in addition to those in 0.7.0:
|
|
31
|
+
|
|
32
|
+
- The canary search reads only the forms it lists. It skips gzip and binary bodies, bodies cut at 64 KiB and net-log requests with no body, and it does not search headers. A pass means no planted value was found in the searched forms.
|
|
33
|
+
- The Stape loader unwrap covers `/g/collect` and `/data`. Stape's hosting layer may act on a loader request in other ways, and the record says so in fixed text.
|
|
34
|
+
|
|
3
35
|
## 0.8.1
|
|
4
36
|
|
|
5
37
|
`npm i -g tagreeve` installs this release. 0.8.1 is a patch release after 0.8.0. It has no new command, option or record field. The record stays at schema version 5. A 0.8.0 record reads as before.
|
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.
|
|
12
|
+
> **Status: 0.9 (`0.9.0-rc.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). 0.7.0 adds the `earlyIdentityPush`, `idHandover` and `serverContainerRejected` checks and `dataLayer:` rules. 0.8.0-rc.1 adds a consent audit: `suite --consent`, identifier canaries and the `identifierRoute` check. 0.8.0 is rc.4 with the release prep and no code change; it was field-tested on a real Shopify store with a first-party server container (rc.1 to rc.4). 0.9.0-rc.1 fixes server container links, canaries, consent matrix names and `dataLayer` loaders, and decodes Pinterest Conversions API calls. 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,8 @@ 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.9.0-rc.1:** the first release candidate of 0.9.0, with no new command or option. A server call that arrives up to 2000 ms after its answered same-key hit now links exactly, so a rule that only warned can now fail the run. Pinterest Conversions API calls are decoded as `pinterest-capi` and link to browser hits by event ID. Fixes to canaries, consent matrix event names and `dataLayer` iframe loaders. The record stays at schema version 5. `npm i -g tagreeve@next` installs it. On arm64, run `tagreeve server-container build` after the upgrade. What is new is in [CHANGELOG.md](CHANGELOG.md) under 0.9.0-rc.1.
|
|
21
|
+
>
|
|
20
22
|
> **In 0.8.1:** a patch release with no new command or option. `tagreeve diff --by-page` prints only the path of a recorded page, so a fake canary value in a page URL no longer reaches the text or `diff --json`. The `identifierRoute` pass message is true when every route went to an allowed host. The record stays at schema version 5. `npm i -g tagreeve` installs it. On arm64, run `tagreeve server-container build` after the upgrade. What is new is in [CHANGELOG.md](CHANGELOG.md) under 0.8.1.
|
|
21
23
|
|
|
22
24
|
> **In 0.8.0:** everything in the 0.8.0 release candidates, with no code change after rc.4. A consent audit: `tagreeve suite --consent accept,reject,none,withdraw` runs each scenario once per consent state, `options.canaries: true` plants fake click IDs and the run follows them to the vendor requests they reach, and the new `identifierRoute` check fails when a canary reaches a vendor that consent did not allow. The server container links more calls to browser hits and judges an unlinked server call by its own send time. Many fixes to consent commands, `dataLayer` rules, `idHandover`, the identity matcher and `diff`. The record stays at schema version 5. `npm i -g tagreeve` installs it. On arm64, run `tagreeve server-container build` after the upgrade. To upgrade from 0.7.0, read "Upgrading from 0.7.0" in [CHANGELOG.md](CHANGELOG.md). What is still open is in the same file under "Known in 0.8.0".
|
|
@@ -139,7 +141,7 @@ configSchemaVersion: 1
|
|
|
139
141
|
site: https://shop.example
|
|
140
142
|
```
|
|
141
143
|
|
|
142
|
-
`consent: none` needs a banner that autoconsent detects. If none is shown, the run stops with "banner not shown" and exit code 2. Vendor keys are `ga4`, `google-ads`, `meta`, `meta-capi`, `pinterest`, `sgtm`, and every vendor on the tracker list (`linkedin`, `microsoft-uet`, `reddit`) or in a `--tracker-list` file. A scenario that names any other vendor is rejected when it is parsed.
|
|
144
|
+
`consent: none` needs a banner that autoconsent detects. If none is shown, the run stops with "banner not shown" and exit code 2. Vendor keys are `ga4`, `google-ads`, `meta`, `meta-capi`, `pinterest`, `pinterest-capi`, `sgtm`, and every vendor on the tracker list (`linkedin`, `microsoft-uet`, `reddit`) or in a `--tracker-list` file. A scenario that names any other vendor is rejected when it is parsed.
|
|
143
145
|
|
|
144
146
|
Stub mode is the default: known collection endpoints are recorded and answered locally. Unknown destinations still receive hits and are flagged as `unknownDestination`, which fails the run. The registrable domain of `--site` is first party: for `--site https://www.shop.co.uk`, `shop.co.uk` and every `*.shop.co.uk` host are not unknown. Data-carrying requests to those subdomains that no decoder matches, such as server-side GTM on `sgtm.shop.co.uk/collect`, are listed as `firstPartySubdomain` flags, grouped by host. They do not fail the run. Hosts without a registrable domain, such as IP addresses and `localhost`, are first party only as the exact `--site` host. If a site serves its own assets from another domain, list it under `options: { firstPartyHosts: ['i.example-cdn.com', '*.example-static.com'] }`. To accept specific unknown hosts without calling them first party, use `options: { allowUnknownDestination: ['tracker.example.net'] }`; every other unknown destination still fails. `allowUnknownDestination: true` allows all of them, and the summary still lists them. Requests to Shopify's CDN, telemetry and Shop Pay hosts (`cdn.shopify.com`, `cdn.shopifycloud.com`, `monorail-edge.shopifysvc.com`, `*.shopifysvc.com`, `pay.shopify.com`, `shop.app`) are flagged `platformHost` instead. They are listed but never fail the run. `options: { platformHosts: false }` flags them as `unknownDestination` again. A request sent while a sandboxed `srcdoc` iframe is loading can escape stubbing and recording (see [design §5.3](docs/design.md)). Use `--network live` to let everything through. Tagreeve decodes GA4, Google Ads, Meta, Meta Conversions API, Pinterest and Stape traffic, and stubs the hosts on the tracker list. Hits to other vendors, such as TikTok, are not stubbed unless you add them with `--tracker-list`: they pass through and can only show up as `unknownDestination` flags.
|
|
145
147
|
|
package/dist/cli.js
CHANGED
|
@@ -686,6 +686,11 @@ function canaryPool(canaries, identity) {
|
|
|
686
686
|
const nameOf2 = (text2) => {
|
|
687
687
|
const exact = forms.get(text2);
|
|
688
688
|
if (exact !== void 0) return exact;
|
|
689
|
+
const bare = text2.replace(/=+$/, "");
|
|
690
|
+
if (bare !== text2) {
|
|
691
|
+
const padded = forms.get(bare);
|
|
692
|
+
if (padded !== void 0) return padded;
|
|
693
|
+
}
|
|
689
694
|
const token = CLICK_ID_COOKIE.exec(text2)?.[1];
|
|
690
695
|
return token === void 0 ? void 0 : forms.get(token);
|
|
691
696
|
};
|
|
@@ -775,7 +780,7 @@ function isServerContainerRequest(req, serverHosts) {
|
|
|
775
780
|
|
|
776
781
|
// packages/decoders/src/decoder.ts
|
|
777
782
|
var defaultHitId = () => newId("hit");
|
|
778
|
-
var vendorKeys = ["ga4", "google-ads", "meta", "meta-capi", "pinterest", "sgtm"];
|
|
783
|
+
var vendorKeys = ["ga4", "google-ads", "meta", "meta-capi", "pinterest", "pinterest-capi", "sgtm"];
|
|
779
784
|
|
|
780
785
|
// packages/decoders/src/identifiers.ts
|
|
781
786
|
var ANALYTICS_ID_NAMES = ["user_id", "uid", "up.user_id"];
|
|
@@ -1028,6 +1033,7 @@ var PAGE_FIELDS = {
|
|
|
1028
1033
|
meta: { page: ["dl"], referrer: ["rl"] },
|
|
1029
1034
|
"meta-capi": { page: ["event_source_url"], referrer: [] },
|
|
1030
1035
|
pinterest: { page: [PINTEREST_PAGE], referrer: [] },
|
|
1036
|
+
"pinterest-capi": { page: ["event_source_url"], referrer: [] },
|
|
1031
1037
|
sgtm: { page: ["page_location"], referrer: [] },
|
|
1032
1038
|
tracker: { page: ["dl", "page_location", "page_url", "url", "u", "loc", "href"], referrer: [] }
|
|
1033
1039
|
};
|
|
@@ -1401,6 +1407,83 @@ var metaCapi = {
|
|
|
1401
1407
|
}
|
|
1402
1408
|
};
|
|
1403
1409
|
|
|
1410
|
+
// packages/decoders/src/pinterest-capi.ts
|
|
1411
|
+
var EVENTS_PATH2 = /^\/v5\/ad_accounts\/([^/]+)\/events\/?$/;
|
|
1412
|
+
function eventsAccount(req) {
|
|
1413
|
+
try {
|
|
1414
|
+
const url = new URL(req.url);
|
|
1415
|
+
return url.hostname === "api.pinterest.com" ? EVENTS_PATH2.exec(url.pathname)?.[1] : void 0;
|
|
1416
|
+
} catch {
|
|
1417
|
+
return void 0;
|
|
1418
|
+
}
|
|
1419
|
+
}
|
|
1420
|
+
function isPinterestCapiEndpoint(req) {
|
|
1421
|
+
return eventsAccount(req) !== void 0;
|
|
1422
|
+
}
|
|
1423
|
+
function pinterestEventKey(name) {
|
|
1424
|
+
return name.toLowerCase().replaceAll("_", "");
|
|
1425
|
+
}
|
|
1426
|
+
function isObject2(v) {
|
|
1427
|
+
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
1428
|
+
}
|
|
1429
|
+
function str2(v) {
|
|
1430
|
+
const first = Array.isArray(v) ? v[0] : v;
|
|
1431
|
+
if (typeof first === "string") return first === "" ? void 0 : first;
|
|
1432
|
+
return typeof first === "number" ? String(first) : void 0;
|
|
1433
|
+
}
|
|
1434
|
+
function eventItems2(body) {
|
|
1435
|
+
if (!body) return void 0;
|
|
1436
|
+
try {
|
|
1437
|
+
const json = JSON.parse(body);
|
|
1438
|
+
const data = isObject2(json) ? json.data : void 0;
|
|
1439
|
+
return Array.isArray(data) && data.every(isObject2) ? data : void 0;
|
|
1440
|
+
} catch {
|
|
1441
|
+
return void 0;
|
|
1442
|
+
}
|
|
1443
|
+
}
|
|
1444
|
+
function decodeItem2(item, req, newHitId, complete) {
|
|
1445
|
+
const userData2 = isObject2(item.user_data) ? item.user_data : {};
|
|
1446
|
+
const ids = {};
|
|
1447
|
+
const params = {};
|
|
1448
|
+
const email = str2(userData2.em);
|
|
1449
|
+
if (email) {
|
|
1450
|
+
ids.hashedEmail = true;
|
|
1451
|
+
params.hashedEmail = email;
|
|
1452
|
+
}
|
|
1453
|
+
const eventId = str2(item.event_id);
|
|
1454
|
+
if (eventId) {
|
|
1455
|
+
ids.event_id = true;
|
|
1456
|
+
params.eventId = eventId;
|
|
1457
|
+
}
|
|
1458
|
+
return withFields({
|
|
1459
|
+
type: "hit",
|
|
1460
|
+
id: newHitId(),
|
|
1461
|
+
runId: req.runId,
|
|
1462
|
+
stepId: req.stepId,
|
|
1463
|
+
requestId: req.id,
|
|
1464
|
+
t: req.t,
|
|
1465
|
+
vendor: "pinterest-capi",
|
|
1466
|
+
event: str2(item.event_name) ?? null,
|
|
1467
|
+
consent: { ads: "unknown", analytics: "unknown", adUserData: "unknown", adPersonalization: "unknown", raw: {} },
|
|
1468
|
+
ids,
|
|
1469
|
+
page: str2(item[PAGE_FIELDS["pinterest-capi"].page[0]]) ?? null,
|
|
1470
|
+
transport: req.resourceType === "ping" ? "beacon" : req.resourceType,
|
|
1471
|
+
params
|
|
1472
|
+
}, jsonEntries(item), complete);
|
|
1473
|
+
}
|
|
1474
|
+
var pinterestCapi = {
|
|
1475
|
+
name: "pinterest-capi",
|
|
1476
|
+
match: (req) => req.method.toUpperCase() === "POST" && eventsAccount(req) !== void 0,
|
|
1477
|
+
isCollectionEndpoint: isPinterestCapiEndpoint,
|
|
1478
|
+
decode(req, newHitId = defaultHitId) {
|
|
1479
|
+
if (req.method.toUpperCase() !== "POST" || eventsAccount(req) === void 0) return [];
|
|
1480
|
+
const items = eventItems2(req.postData);
|
|
1481
|
+
if (!items) return [decodeItem2({}, req, newHitId, false)];
|
|
1482
|
+
const complete = bodyComplete(req);
|
|
1483
|
+
return items.map((item) => decodeItem2(item, req, newHitId, complete));
|
|
1484
|
+
}
|
|
1485
|
+
};
|
|
1486
|
+
|
|
1404
1487
|
// packages/decoders/src/pinterest.ts
|
|
1405
1488
|
function onCollectionHost(req) {
|
|
1406
1489
|
try {
|
|
@@ -1610,22 +1693,22 @@ function parseObject(text2) {
|
|
|
1610
1693
|
}
|
|
1611
1694
|
}
|
|
1612
1695
|
var parseDtdc = (value) => parseObject(value ? decodeBase64Text(value) : void 0);
|
|
1613
|
-
var
|
|
1614
|
-
var hasId = (v) =>
|
|
1696
|
+
var str3 = (v) => typeof v === "string" && v !== "" ? v : void 0;
|
|
1697
|
+
var hasId = (v) => str3(v) !== void 0 || typeof v === "number" && Number.isFinite(v);
|
|
1615
1698
|
var USER_DATA_FIELDS = ["email_address", "phone_number", "first_name", "last_name", "street", "city", "postal_code", "country"];
|
|
1616
|
-
function
|
|
1699
|
+
function isObject3(v) {
|
|
1617
1700
|
return v !== null && typeof v === "object" && !Array.isArray(v);
|
|
1618
1701
|
}
|
|
1619
|
-
var firstOf = (v) => Array.isArray(v) ? v.find((x) =>
|
|
1702
|
+
var firstOf = (v) => Array.isArray(v) ? v.find((x) => str3(x) !== void 0 || isObject3(x)) : v;
|
|
1620
1703
|
function userData(...sources) {
|
|
1621
1704
|
const out = {};
|
|
1622
1705
|
for (const source of sources) {
|
|
1623
|
-
const hasUserData =
|
|
1706
|
+
const hasUserData = isObject3(source.user_data);
|
|
1624
1707
|
const fields2 = hasUserData ? source.user_data : source;
|
|
1625
1708
|
const addressValue = firstOf(fields2.address);
|
|
1626
|
-
const address =
|
|
1709
|
+
const address = isObject3(addressValue) ? addressValue : {};
|
|
1627
1710
|
for (const field of USER_DATA_FIELDS) {
|
|
1628
|
-
const value =
|
|
1711
|
+
const value = str3(firstOf(fields2[field])) ?? str3(firstOf(address[field]));
|
|
1629
1712
|
if (value && out[`user_data.${field}`] === void 0) out[`user_data.${field}`] = value;
|
|
1630
1713
|
}
|
|
1631
1714
|
}
|
|
@@ -1644,7 +1727,7 @@ function dataRequest(req, viaLoader) {
|
|
|
1644
1727
|
if (Object.keys(parseDtdc(p.get("dtdc"))).length > 0) return url;
|
|
1645
1728
|
if (p.has("v") && (p.has("event") || p.has("en"))) return url;
|
|
1646
1729
|
const body = req.method === "POST" ? parseObject(req.postData) : {};
|
|
1647
|
-
if (
|
|
1730
|
+
if (str3(body.event_name) && str3(body[PAGE_FIELDS.sgtm.page[0]])) return url;
|
|
1648
1731
|
return isCutDataBody(req) ? url : void 0;
|
|
1649
1732
|
}
|
|
1650
1733
|
function isCutDataBody(req) {
|
|
@@ -1672,7 +1755,7 @@ var sgtmDataClient = {
|
|
|
1672
1755
|
const params = {};
|
|
1673
1756
|
const tid = p.get("tid");
|
|
1674
1757
|
if (tid) params.tid = tid;
|
|
1675
|
-
const hostname2 =
|
|
1758
|
+
const hostname2 = str3(dtdc.page_hostname) ?? str3(body.page_hostname);
|
|
1676
1759
|
if (hostname2) params.page_hostname = hostname2;
|
|
1677
1760
|
Object.assign(params, userData(dtdc, body));
|
|
1678
1761
|
return [
|
|
@@ -1684,10 +1767,10 @@ var sgtmDataClient = {
|
|
|
1684
1767
|
requestId: req.id,
|
|
1685
1768
|
t: req.t,
|
|
1686
1769
|
vendor: "sgtm",
|
|
1687
|
-
event: p.get("event") ?? p.get("en") ??
|
|
1770
|
+
event: p.get("event") ?? p.get("en") ?? str3(dtdc.event_name) ?? str3(body.event_name) ?? null,
|
|
1688
1771
|
consent: decodeGa4Consent(p),
|
|
1689
1772
|
ids,
|
|
1690
|
-
page:
|
|
1773
|
+
page: str3(dtdc[PAGE_FIELDS.sgtm.page[0]]) ?? str3(body[PAGE_FIELDS.sgtm.page[0]]) ?? null,
|
|
1691
1774
|
transport: req.resourceType === "ping" ? "beacon" : req.resourceType,
|
|
1692
1775
|
params
|
|
1693
1776
|
}, entries, complete)
|
|
@@ -1824,7 +1907,7 @@ function decodeTracker(req, list3 = trackerList, newHitId = defaultHitId) {
|
|
|
1824
1907
|
}
|
|
1825
1908
|
|
|
1826
1909
|
// packages/decoders/src/registry.ts
|
|
1827
|
-
var direct = [ga4, meta, metaCapi, pinterest, googleAds, sgtmDataClient];
|
|
1910
|
+
var direct = [ga4, meta, metaCapi, pinterest, pinterestCapi, googleAds, sgtmDataClient];
|
|
1828
1911
|
var decoders = [...direct, createStapeCustomLoader(direct)];
|
|
1829
1912
|
function decodeRequest(req, newHitId, trackers = trackerList) {
|
|
1830
1913
|
const matched = decoders.filter((d) => d.match(req));
|
|
@@ -1922,11 +2005,15 @@ function corsHeaders(headers) {
|
|
|
1922
2005
|
return out;
|
|
1923
2006
|
}
|
|
1924
2007
|
var CAPI_ANSWER = Buffer.from('{"events_received":1,"messages":[],"fbtrace_id":"pw-fixture"}');
|
|
2008
|
+
var PINTEREST_CAPI_ANSWER = Buffer.from('{"num_events_received":1,"num_events_processed":1,"events":[{"status":"processed","error_message":""}]}');
|
|
1925
2009
|
function stubResponse(req) {
|
|
1926
2010
|
const cors = corsHeaders(req.headers);
|
|
1927
2011
|
if (req.url !== void 0 && isMetaCapiEndpoint({ url: req.url })) {
|
|
1928
2012
|
return { status: 200, headers: { ...cors, "content-type": "application/json", "cache-control": "no-store" }, body: CAPI_ANSWER };
|
|
1929
2013
|
}
|
|
2014
|
+
if (req.url !== void 0 && isPinterestCapiEndpoint({ url: req.url })) {
|
|
2015
|
+
return { status: 200, headers: { ...cors, "content-type": "application/json", "cache-control": "no-store" }, body: PINTEREST_CAPI_ANSWER };
|
|
2016
|
+
}
|
|
1930
2017
|
switch (req.resourceType) {
|
|
1931
2018
|
case "image":
|
|
1932
2019
|
return { status: 200, headers: { ...cors, "content-type": "image/gif", "cache-control": "no-store" }, body: GIF };
|
|
@@ -2479,7 +2566,7 @@ function parseScenario(text2, extraVendorKeys = []) {
|
|
|
2479
2566
|
stepLabels2.add(label);
|
|
2480
2567
|
steps.push({ ...body, label, line });
|
|
2481
2568
|
};
|
|
2482
|
-
const
|
|
2569
|
+
const str4 = () => {
|
|
2483
2570
|
if (typeof value === "string" && value) return value;
|
|
2484
2571
|
fail([...path, kind], "must be a non-empty string");
|
|
2485
2572
|
return void 0;
|
|
@@ -2554,7 +2641,7 @@ function parseScenario(text2, extraVendorKeys = []) {
|
|
|
2554
2641
|
};
|
|
2555
2642
|
switch (kind) {
|
|
2556
2643
|
case "visit": {
|
|
2557
|
-
const v =
|
|
2644
|
+
const v = str4();
|
|
2558
2645
|
if (v !== void 0) {
|
|
2559
2646
|
checkVars(v, [...path, kind]);
|
|
2560
2647
|
add2({ kind, value: v });
|
|
@@ -2569,13 +2656,13 @@ function parseScenario(text2, extraVendorKeys = []) {
|
|
|
2569
2656
|
case "addToCart":
|
|
2570
2657
|
case "evaluate":
|
|
2571
2658
|
case "checkpoint": {
|
|
2572
|
-
const v =
|
|
2659
|
+
const v = str4();
|
|
2573
2660
|
if (v !== void 0) add2({ kind, value: v });
|
|
2574
2661
|
return;
|
|
2575
2662
|
}
|
|
2576
2663
|
case "handoff": {
|
|
2577
2664
|
if (!isMap(value)) {
|
|
2578
|
-
const v =
|
|
2665
|
+
const v = str4();
|
|
2579
2666
|
if (v !== void 0) add2({ kind, value: v });
|
|
2580
2667
|
return;
|
|
2581
2668
|
}
|
|
@@ -3988,7 +4075,11 @@ function evaluatePushRuleIn(rule, ctx) {
|
|
|
3988
4075
|
}
|
|
3989
4076
|
function loaderReachesScope(loader, ctx, inScope, windowStartAt) {
|
|
3990
4077
|
if (!loader) return true;
|
|
3991
|
-
const sameFrame2 = (r) =>
|
|
4078
|
+
const sameFrame2 = (r) => {
|
|
4079
|
+
if (!(loader.frame && r.frame)) return r.frame?.main !== false;
|
|
4080
|
+
if (r.frame.n === loader.frame.n) return true;
|
|
4081
|
+
return !loader.frame.main && r.frame.main && loader.frame.page !== void 0 && r.frame.page === loader.frame.page;
|
|
4082
|
+
};
|
|
3992
4083
|
const aborted = (r) => r.outcome === "failed" && r.failure === "net::ERR_ABORTED";
|
|
3993
4084
|
const navigations = [
|
|
3994
4085
|
...ctx.visitTimes,
|
|
@@ -4716,14 +4807,14 @@ var NAMED_HASH_IN_SEGMENT = /(?<=\/[^/=;]+[-_.])[0-9a-f]{64}(?=\.[a-z0-9]{1,8}(?
|
|
|
4716
4807
|
var NAMED_HASH_NOT_GIF = /(?<=\/[^/=;]+[-_.])[0-9a-f]{64}(?=\.(?!gif(?:$|\/))[a-z0-9]{1,8}(?:$|\/))/gi;
|
|
4717
4808
|
var NAMED_HASH_TYPES = /* @__PURE__ */ new Set(["script", "stylesheet", "font", "media", "fetch", "xhr"]);
|
|
4718
4809
|
var HEX64 = /^[0-9a-f]{64}$/i;
|
|
4719
|
-
var
|
|
4810
|
+
var isObject4 = (v) => typeof v === "object" && v !== null && !Array.isArray(v);
|
|
4720
4811
|
function blankOperation(op) {
|
|
4721
|
-
if (!
|
|
4812
|
+
if (!isObject4(op)) return;
|
|
4722
4813
|
for (const key of Object.keys(op)) {
|
|
4723
4814
|
if (/^(?:id|sha256hash)$/i.test(key) && typeof op[key] === "string" && HEX64.test(op[key])) op[key] = "";
|
|
4724
4815
|
}
|
|
4725
4816
|
const extensions = typeof op.extensions === "string" ? parseJson(op.extensions) : op.extensions;
|
|
4726
|
-
if (
|
|
4817
|
+
if (isObject4(extensions) && isObject4(extensions.persistedQuery)) {
|
|
4727
4818
|
const pq = extensions.persistedQuery;
|
|
4728
4819
|
if (typeof pq.sha256Hash === "string" && HEX64.test(pq.sha256Hash)) pq.sha256Hash = "";
|
|
4729
4820
|
if (typeof op.extensions === "string") op.extensions = JSON.stringify(extensions);
|
|
@@ -4994,8 +5085,25 @@ function findForeignData(requests, hits, identity, dataLayerEvents = []) {
|
|
|
4994
5085
|
// packages/expect/src/state-table.ts
|
|
4995
5086
|
var EVENT_NAME = /^[\w.:-]+(?: [\w.:-]+)*$/;
|
|
4996
5087
|
var byName = (x, y) => x < y ? -1 : x > y ? 1 : 0;
|
|
5088
|
+
var MAX_EVENT_WORDS = 6;
|
|
5089
|
+
var MAX_EVENT_DIGITS = 3;
|
|
5090
|
+
function spacedNameOk(name) {
|
|
5091
|
+
if (name.includes("@") || (name.match(/\d/g)?.length ?? 0) > MAX_EVENT_DIGITS) return false;
|
|
5092
|
+
if (name.split(" ").length > MAX_EVENT_WORDS) return false;
|
|
5093
|
+
const words2 = name.split(/[ .:]/).filter(Boolean);
|
|
5094
|
+
for (let i = 0; i < words2.length; i++) {
|
|
5095
|
+
for (let j = i + 1; j <= words2.length; j++) {
|
|
5096
|
+
const span = words2.slice(i, j).join("");
|
|
5097
|
+
if (isValueSegment(span)) return false;
|
|
5098
|
+
const kinds = valueKinds(span);
|
|
5099
|
+
if (kinds.has("email") || kinds.has("phone")) return false;
|
|
5100
|
+
}
|
|
5101
|
+
}
|
|
5102
|
+
return true;
|
|
5103
|
+
}
|
|
4997
5104
|
function guardName(name, isEvent = false) {
|
|
4998
5105
|
if (isEvent && (name.length > 64 || !EVENT_NAME.test(name))) return OTHER_NAME;
|
|
5106
|
+
if (isEvent && /[ :]/.test(name)) return spacedNameOk(name) ? name : OTHER_NAME;
|
|
4999
5107
|
return guardFieldName(name) === name && !isValueSegment(name) ? name : OTHER_NAME;
|
|
5000
5108
|
}
|
|
5001
5109
|
function idNames(ids) {
|
|
@@ -6925,6 +7033,20 @@ import {
|
|
|
6925
7033
|
request as playwrightRequest
|
|
6926
7034
|
} from "playwright";
|
|
6927
7035
|
|
|
7036
|
+
// packages/recorder/src/frame-page.ts
|
|
7037
|
+
function createPageNumbers() {
|
|
7038
|
+
const numbers = /* @__PURE__ */ new WeakMap();
|
|
7039
|
+
let next = 0;
|
|
7040
|
+
return (page2) => {
|
|
7041
|
+
let number = numbers.get(page2);
|
|
7042
|
+
if (number === void 0) {
|
|
7043
|
+
number = next++;
|
|
7044
|
+
numbers.set(page2, number);
|
|
7045
|
+
}
|
|
7046
|
+
return number;
|
|
7047
|
+
};
|
|
7048
|
+
}
|
|
7049
|
+
|
|
6928
7050
|
// packages/recorder/src/datalayer-tally.ts
|
|
6929
7051
|
var MAX_TALLY_KEYS = 256;
|
|
6930
7052
|
var PayloadCounts = class _PayloadCounts {
|
|
@@ -8901,6 +9023,12 @@ var CLIENT_ID_NAMES = /* @__PURE__ */ new Set(["cid", "client_id", "clientid", "
|
|
|
8901
9023
|
function eventIdOf(hit) {
|
|
8902
9024
|
return hit.params.eventId ?? hit.params.eid ?? hit.params.event_id;
|
|
8903
9025
|
}
|
|
9026
|
+
function sameEventName(server, browser) {
|
|
9027
|
+
if (server.vendor === "pinterest-capi" && browser.vendor === "pinterest" && server.event !== null && browser.event !== null) {
|
|
9028
|
+
return pinterestEventKey(server.event) === pinterestEventKey(browser.event);
|
|
9029
|
+
}
|
|
9030
|
+
return server.event === browser.event;
|
|
9031
|
+
}
|
|
8904
9032
|
function collectNamed(value, names, out) {
|
|
8905
9033
|
if (Array.isArray(value)) {
|
|
8906
9034
|
for (const item of value) collectNamed(item, names, out);
|
|
@@ -8953,6 +9081,7 @@ ${decoded}`.toLowerCase();
|
|
|
8953
9081
|
return values.some((v) => text2.includes(v));
|
|
8954
9082
|
}
|
|
8955
9083
|
var LATER_HIT_WINDOW_MS = 5e3;
|
|
9084
|
+
var ANSWERED_WINDOW_MS = 2e3;
|
|
8956
9085
|
function sharedKind(server, browser) {
|
|
8957
9086
|
if (server.eventId && server.eventId.length >= MIN_VALUE_LENGTH && server.eventId === browser.eventId) return "eventId";
|
|
8958
9087
|
for (const id of server.clientIds) if (browser.clientIds.has(id)) return "clientId";
|
|
@@ -9000,7 +9129,7 @@ function linkServerHits({ hits, requests, serverHosts, identity, inFlight, epoch
|
|
|
9000
9129
|
const callAt = f.request?.t;
|
|
9001
9130
|
const epochEnd = callAt !== void 0 && sortedStarts ? nextEpochStart(callAt) : void 0;
|
|
9002
9131
|
const exact = f.eventId === void 0 ? [] : browser.filter((b) => {
|
|
9003
|
-
if (b.eventId !== f.eventId ||
|
|
9132
|
+
if (b.eventId !== f.eventId || !sameEventName(f.hit, b.hit)) return false;
|
|
9004
9133
|
if (callAt === void 0) return true;
|
|
9005
9134
|
const sentAt = sentAtOf(b.hit.requestId, b.hit.t);
|
|
9006
9135
|
return sentAt <= callAt || epochEnd !== void 0 && f.eventId.length >= MIN_VALUE_LENGTH && sentAt - callAt <= LATER_HIT_WINDOW_MS && sentAt < epochEnd;
|
|
@@ -9017,10 +9146,14 @@ function linkServerHits({ hits, requests, serverHosts, identity, inFlight, epoch
|
|
|
9017
9146
|
const only = sameKey.length === 1 ? sameKey[0] : void 0;
|
|
9018
9147
|
const window2 = only && inFlight?.get(only.hit.requestId);
|
|
9019
9148
|
const inFlightNow = only !== void 0 && window2 && callAt !== void 0 && callAt < window2.answeredAt;
|
|
9020
|
-
const
|
|
9149
|
+
const answeredNow = only !== void 0 && window2 && callAt !== void 0 && sortedStarts !== void 0 && callAt >= window2.answeredAt;
|
|
9150
|
+
const concurrent = (inFlightNow || answeredNow) && hasConcurrentRequest(only, window2.sentAt, callAt, f.clientIds);
|
|
9021
9151
|
if (inFlightNow && !concurrent) {
|
|
9022
9152
|
return { ...f.hit, via: { hitId: only.hit.id, by: "clientId", confidence: "exact" } };
|
|
9023
9153
|
}
|
|
9154
|
+
if (answeredNow && !concurrent && callAt - window2.answeredAt <= ANSWERED_WINDOW_MS && !sortedStarts.some((t) => t > window2.sentAt && t <= callAt)) {
|
|
9155
|
+
return { ...f.hit, via: { hitId: only.hit.id, by: "clientId", confidence: "exact" } };
|
|
9156
|
+
}
|
|
9024
9157
|
const clientIdMiss = f.hit.event === null || f.clientIds.size === 0 ? "noClientId" : sameKey.length === 0 ? "noSameKeyHit" : sameKey.length > 1 ? "severalSameKeyHits" : concurrent ? "concurrentRequest" : "answeredBefore";
|
|
9025
9158
|
const linkMiss = { eventId: eventIdMiss, clientId: clientIdMiss };
|
|
9026
9159
|
const earlier = browser.flatMap((b) => {
|
|
@@ -9235,6 +9368,10 @@ var Recorder = class _Recorder {
|
|
|
9235
9368
|
frameNumbers = /* @__PURE__ */ new WeakMap();
|
|
9236
9369
|
frameNavigations = /* @__PURE__ */ new WeakMap();
|
|
9237
9370
|
frameCount = 0;
|
|
9371
|
+
pageNumber = createPageNumbers();
|
|
9372
|
+
/** A popup's first request is sent before its frame exists, so it has no frame until the popup's page event. */
|
|
9373
|
+
framelessNavigations = [];
|
|
9374
|
+
framelessEntryOf = /* @__PURE__ */ new Map();
|
|
9238
9375
|
navigationSeen = /* @__PURE__ */ new WeakSet();
|
|
9239
9376
|
requestFrameIds = /* @__PURE__ */ new Map();
|
|
9240
9377
|
collectorReports = [];
|
|
@@ -9375,6 +9512,10 @@ var Recorder = class _Recorder {
|
|
|
9375
9512
|
await context.addInitScript(handoffOverlayScript(this.handoff.nonce));
|
|
9376
9513
|
}
|
|
9377
9514
|
context.on("request", (request) => void this.recordFor(request));
|
|
9515
|
+
context.on("page", (page2) => {
|
|
9516
|
+
if (this.pageNumber(page2) === 0) return;
|
|
9517
|
+
this.claimPopups();
|
|
9518
|
+
});
|
|
9378
9519
|
context.on("requestfailed", (request) => {
|
|
9379
9520
|
const record = this.recordFor(request);
|
|
9380
9521
|
if (!record) return;
|
|
@@ -9468,6 +9609,9 @@ var Recorder = class _Recorder {
|
|
|
9468
9609
|
frameRef(frame) {
|
|
9469
9610
|
return { main: frame === frame.page().mainFrame(), n: this.frameNumber(frame) };
|
|
9470
9611
|
}
|
|
9612
|
+
requestFrameRef(frame) {
|
|
9613
|
+
return { ...this.frameRef(frame), page: this.pageNumber(frame.page()) };
|
|
9614
|
+
}
|
|
9471
9615
|
frameNumber(frame) {
|
|
9472
9616
|
let number = this.frameNumbers.get(frame);
|
|
9473
9617
|
if (number === void 0) {
|
|
@@ -9506,7 +9650,7 @@ var Recorder = class _Recorder {
|
|
|
9506
9650
|
const body = request.postData();
|
|
9507
9651
|
let frame;
|
|
9508
9652
|
try {
|
|
9509
|
-
frame = this.
|
|
9653
|
+
frame = this.requestFrameRef(request.frame());
|
|
9510
9654
|
} catch {
|
|
9511
9655
|
}
|
|
9512
9656
|
let record = {
|
|
@@ -9529,6 +9673,7 @@ var Recorder = class _Recorder {
|
|
|
9529
9673
|
if (loaderName2 !== void 0) this.loaderLayers.push({ id: record.id, name: loaderName2 });
|
|
9530
9674
|
record = this.redactForHandoff(record);
|
|
9531
9675
|
this.requests.set(request, record);
|
|
9676
|
+
if (!frame && request.isNavigationRequest()) this.trackFrameless(request, record);
|
|
9532
9677
|
const frameId = this.requestFrameId(request);
|
|
9533
9678
|
if (frameId !== null) this.requestFrameIds.set(record.id, frameId);
|
|
9534
9679
|
if (request.isNavigationRequest() && isTopLevelFrameRequest(request)) {
|
|
@@ -9537,6 +9682,30 @@ var Recorder = class _Recorder {
|
|
|
9537
9682
|
}
|
|
9538
9683
|
return record;
|
|
9539
9684
|
}
|
|
9685
|
+
trackFrameless(request, record) {
|
|
9686
|
+
const previous = request.redirectedFrom();
|
|
9687
|
+
const earlier = previous ? this.requests.get(previous) : void 0;
|
|
9688
|
+
const entry = earlier && this.framelessEntryOf.get(earlier.id) || { records: [], request };
|
|
9689
|
+
if (!this.framelessEntryOf.has(record.id) && entry.records.length === 0) this.framelessNavigations.push(entry);
|
|
9690
|
+
entry.records.push(record);
|
|
9691
|
+
this.framelessEntryOf.set(record.id, entry);
|
|
9692
|
+
if (entry.frame) record.frame = entry.frame;
|
|
9693
|
+
else this.claimPopups();
|
|
9694
|
+
}
|
|
9695
|
+
/** Asks Playwright for each open entry's frame again. It answers once the popup's page event has fired, so a blank popup that sent no request cannot be paired with another popup's request. */
|
|
9696
|
+
claimPopups() {
|
|
9697
|
+
for (const entry of this.framelessNavigations) {
|
|
9698
|
+
if (entry.frame) continue;
|
|
9699
|
+
let frame;
|
|
9700
|
+
try {
|
|
9701
|
+
frame = this.requestFrameRef(entry.request.frame());
|
|
9702
|
+
} catch {
|
|
9703
|
+
continue;
|
|
9704
|
+
}
|
|
9705
|
+
entry.frame = frame;
|
|
9706
|
+
for (const r of entry.records) r.frame = frame;
|
|
9707
|
+
}
|
|
9708
|
+
}
|
|
9540
9709
|
/** A person is typing during a handoff, so only requests that decode as tracking hits keep their body and query. */
|
|
9541
9710
|
redactForHandoff(record, at = Date.now(), graceMs = 0) {
|
|
9542
9711
|
if (!this.duringHandoff(at, graceMs)) return record;
|
|
@@ -12504,6 +12673,7 @@ var VENDOR_NAMES = {
|
|
|
12504
12673
|
meta: "Meta",
|
|
12505
12674
|
"meta-capi": "Meta Conversions API",
|
|
12506
12675
|
pinterest: "Pinterest",
|
|
12676
|
+
"pinterest-capi": "Pinterest Conversions API",
|
|
12507
12677
|
sgtm: "server container",
|
|
12508
12678
|
linkedin: "LinkedIn",
|
|
12509
12679
|
"microsoft-uet": "Microsoft UET",
|
|
@@ -13365,7 +13535,7 @@ function declarationHint(spec, label) {
|
|
|
13365
13535
|
function queryNames(start) {
|
|
13366
13536
|
const query = start.split("#")[0].split("?").slice(1).join("?");
|
|
13367
13537
|
return query.split("&").map((pair) => {
|
|
13368
|
-
const raw = pair.split("=")[0];
|
|
13538
|
+
const raw = pair.split("=")[0].replace(/[\t\n\r]/g, "");
|
|
13369
13539
|
try {
|
|
13370
13540
|
return decodeURIComponent(raw.replace(/\+/g, " "));
|
|
13371
13541
|
} catch {
|
|
@@ -13373,6 +13543,19 @@ function queryNames(start) {
|
|
|
13373
13543
|
}
|
|
13374
13544
|
});
|
|
13375
13545
|
}
|
|
13546
|
+
function usedVarValues(start, vars) {
|
|
13547
|
+
const seen = /* @__PURE__ */ new Set();
|
|
13548
|
+
const queue = [start];
|
|
13549
|
+
while (queue.length) {
|
|
13550
|
+
for (const m of queue.pop().matchAll(/\{(\w+)\}/g)) {
|
|
13551
|
+
const name = m[1];
|
|
13552
|
+
if (!Object.hasOwn(vars, name) || seen.has(name)) continue;
|
|
13553
|
+
seen.add(name);
|
|
13554
|
+
queue.push(vars[name]);
|
|
13555
|
+
}
|
|
13556
|
+
}
|
|
13557
|
+
return [...seen].map((name) => vars[name]);
|
|
13558
|
+
}
|
|
13376
13559
|
function withCanaries(start, canaries, probe2 = start) {
|
|
13377
13560
|
const hash = start.indexOf("#");
|
|
13378
13561
|
const base2 = hash < 0 ? start : start.slice(0, hash);
|
|
@@ -13412,8 +13595,8 @@ async function executeRun(spec, rawIo) {
|
|
|
13412
13595
|
seed ??= parsed.options.seed ?? Math.floor(Math.random() * 2 ** 31);
|
|
13413
13596
|
canaries = canaryValues(seed, spec.consentCell);
|
|
13414
13597
|
const refilled = [...resolved.matchAll(/\{(\w+)\}/g)].some((m) => Object.hasOwn(parsed.vars, m[1]));
|
|
13415
|
-
if (refilled &&
|
|
13416
|
-
return failed("options.canaries: a variable
|
|
13598
|
+
if (refilled && usedVarValues(parsed.start, parsed.vars).some((v) => v.includes("#"))) {
|
|
13599
|
+
return failed("options.canaries: a variable the start URL uses holds a #, while a variable holds a {placeholder} that is filled again, so the canary parameters could land in the URL fragment. Remove one, or turn canaries off.\n");
|
|
13417
13600
|
}
|
|
13418
13601
|
parsed = { ...parsed, start: refilled ? withCanaries(parsed.start, canaries, resolved) : withCanaries(resolved, canaries) };
|
|
13419
13602
|
}
|