tagreeve 0.7.0-rc.1 → 0.7.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/README.md +2 -2
  2. package/dist/cli.js +33 -16
  3. 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.7 (`0.7.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). 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.
12
+ > **Status: 0.7 (`0.7.0-rc.2`).** 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,7 +17,7 @@ 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.7.0-rc.1:** two new built-in checks and a rule kind for `dataLayer` pushes. `earlyIdentityPush` warns when a push carries the run's own test identity before consent. `idHandover` warns when the GA4 client or session ID differs between two contexts. Both warn by default and can be set to `fail`. `dataLayer:` rules check which pushes a page makes. A `consent default` pushed as a plain object now counts for `consentModeSetup`. `diff` keeps a cross-epoch join. The fixture site has a plain GTM demo shop. The record stays at schema version 5. `npm i -g tagreeve@next` installs it. To upgrade from 0.6.2, read "Upgrading from 0.6.2" in [CHANGELOG.md](CHANGELOG.md). What is still open is in the same file under "Known in 0.7.0-rc.1".
20
+ > **In 0.7.0-rc.2:** rc.2 fixes the `earlyIdentityPush` masking, the `dataLayer` rule messages and `must` and `mustNot` rules on pushes past the shape caps. It has two new built-in checks and a rule kind for `dataLayer` pushes. `earlyIdentityPush` warns when a push carries the run's own test identity before consent. `idHandover` warns when the GA4 client or session ID differs between two contexts. Both warn by default and can be set to `fail`. `dataLayer:` rules check which pushes a page makes. A `consent default` pushed as a plain object now counts for `consentModeSetup`. `diff` keeps a cross-epoch join. The fixture site has a plain GTM demo shop. The record stays at schema version 5. `npm i -g tagreeve@next` installs it. To upgrade from 0.6.2, read "Upgrading from 0.6.2" in [CHANGELOG.md](CHANGELOG.md). What is still open is in the same file under "Known in 0.7.0-rc.1".
21
21
  >
22
22
  > **In 0.6.2:** fixes after 0.6.1, with no new command and no new option. A test payment ends by its deadline when a card frame stops answering. A scoped `must` rule can now warn where 0.6.1 failed, so a run can exit 0. `diff --json` has `renamedFrom` and `pushKind`. `tagreeve init` creates nothing when a target is refused. The record stays at schema version 5. `npm i -g tagreeve` installs it. To upgrade from 0.6.1, read "Upgrading from 0.6.1" in [CHANGELOG.md](CHANGELOG.md). What is still open is in the same file under "Known in 0.6.2".
23
23
  >
package/dist/cli.js CHANGED
@@ -1874,6 +1874,8 @@ var NO_STEP = "(no step)";
1874
1874
  var EVENT_CHARS = /^[A-Za-z0-9_.:-]+$/;
1875
1875
  var MAX_DEPTH2 = 8;
1876
1876
  var MAX_PATHS = 200;
1877
+ var SHAPE_LIMITS = { paths: MAX_PATHS, depth: MAX_DEPTH2 };
1878
+ var NO_LIMITS = { paths: Infinity, depth: Infinity };
1877
1879
  var GTAG_COMMANDS = /* @__PURE__ */ new Set(["config", "consent", "event", "get", "js", "set"]);
1878
1880
  var GTAG_OTHER = "gtag (other)";
1879
1881
  var PUSH_KINDS = ["gtag", "object"];
@@ -1901,15 +1903,15 @@ function typeOf(value) {
1901
1903
  if (value === null || value === void 0) return "null";
1902
1904
  return Array.isArray(value) ? "array" : typeof value;
1903
1905
  }
1904
- function walk(value, path, depth, out) {
1906
+ function walk(value, path, depth, out, limits) {
1905
1907
  const children = typeof value !== "object" || value === null ? [] : Array.isArray(value) ? value.map((v) => ["[*]", v]) : Object.entries(value);
1906
- if (children.length === 0 || depth >= MAX_DEPTH2) {
1907
- if (path === "" || !out.has(path) && out.size >= MAX_PATHS) return;
1908
+ if (children.length === 0 || depth >= limits.depth) {
1909
+ if (path === "" || !out.has(path) && out.size >= limits.paths) return;
1908
1910
  (out.get(path) ?? out.set(path, /* @__PURE__ */ new Set()).get(path)).add(typeOf(value));
1909
1911
  return;
1910
1912
  }
1911
1913
  for (const [key, child] of children) {
1912
- walk(child, key === "[*]" ? `${path}[*]` : path === "" ? safeKey(key) : `${path}.${safeKey(key)}`, depth + 1, out);
1914
+ walk(child, key === "[*]" ? `${path}[*]` : path === "" ? safeKey(key) : `${path}.${safeKey(key)}`, depth + 1, out, limits);
1913
1915
  }
1914
1916
  }
1915
1917
  function startsWithString(args) {
@@ -1942,24 +1944,24 @@ function labelKind(label) {
1942
1944
  function frameKind(e) {
1943
1945
  return e.frame === void 0 ? "unknown" : e.frame.main ? "main" : "embedded";
1944
1946
  }
1945
- function collectPaths(e, command, into) {
1947
+ function collectPaths(e, command, into, limits) {
1946
1948
  if (e.event?.startsWith("gtm.")) return;
1947
1949
  if (command?.fromObject && command.list[0] === "event" && typeof command.list[1] === "string" && command.list[1].startsWith("gtm.")) return;
1948
1950
  if (e.isConsentCommand || isObjectConsent(command)) {
1949
1951
  const signals = (command?.fromObject ? command.list : e.args)[2];
1950
- if (typeof signals === "object" && signals !== null) for (const [name, value] of Object.entries(signals)) walk(value, safeKey(name), 0, into);
1952
+ if (typeof signals === "object" && signals !== null) for (const [name, value] of Object.entries(signals)) walk(value, safeKey(name), 0, into, limits);
1951
1953
  return;
1952
1954
  }
1953
1955
  if (command !== void 0) {
1954
- for (const arg of command.list.slice(command.list[0] === "set" ? 1 : 2)) walk(arg, "", 0, into);
1956
+ for (const arg of command.list.slice(command.list[0] === "set" ? 1 : 2)) walk(arg, "", 0, into, limits);
1955
1957
  return;
1956
1958
  }
1957
- for (const arg of e.args) walk(arg, "", 0, into);
1959
+ for (const arg of e.args) walk(arg, "", 0, into, limits);
1958
1960
  }
1959
1961
  function pushShapeOf(e) {
1960
1962
  const command = commandOf(e);
1961
1963
  const paths = /* @__PURE__ */ new Map();
1962
- collectPaths(e, command, paths);
1964
+ collectPaths(e, command, paths, NO_LIMITS);
1963
1965
  return { event: eventLabel(e, command), kind: command === void 0 ? "object" : "gtag", frame: frameKind(e), paths };
1964
1966
  }
1965
1967
  function pushShapes(records) {
@@ -1976,7 +1978,7 @@ function pushShapes(records) {
1976
1978
  const group = groups.get(key) ?? groups.set(key, { shape: { event, kind, frame, count: 0, paths: [], ids: [] }, types: /* @__PURE__ */ new Map() }).get(key);
1977
1979
  group.shape.count += 1;
1978
1980
  group.shape.ids.push(e.id);
1979
- collectPaths(e, command, group.types);
1981
+ collectPaths(e, command, group.types, SHAPE_LIMITS);
1980
1982
  }
1981
1983
  return {
1982
1984
  pushes: records.dataLayerEvents.length,
@@ -2863,10 +2865,24 @@ function consentModeSetup(hits, dataLayer) {
2863
2865
  // packages/expect/src/early-identity-push.ts
2864
2866
  var MAX_DEPTH3 = 8;
2865
2867
  var MAX_LISTED2 = 5;
2868
+ var MIN_BARE_LOCAL = 6;
2869
+ var AT_MARKERS = ["@", "_at_", "%40", "(at)"];
2870
+ var holdsLocalPart = (key, identity) => {
2871
+ const [local = "", domain = ""] = identity.email.toLowerCase().split("@");
2872
+ if (local === "") return false;
2873
+ const k = key.toLowerCase();
2874
+ if (local.length >= MIN_BARE_LOCAL && k.includes(local)) return true;
2875
+ const label = domain.split(".")[0] ?? "";
2876
+ const next = [...AT_MARKERS, ...label === "" ? [] : [`_${label}`, `-${label}`, `.${label}`, label]];
2877
+ for (let at = k.indexOf(local); at !== -1; at = k.indexOf(local, at + 1)) {
2878
+ const rest = k.slice(at + local.length);
2879
+ if (next.some((m) => rest.startsWith(m))) return true;
2880
+ }
2881
+ return false;
2882
+ };
2866
2883
  var safeKey2 = (key, identity) => {
2867
2884
  if (guardFieldName(key) !== key || isValueSegment(key)) return OTHER_NAME;
2868
- const local = identity.email.split("@")[0]?.toLowerCase() ?? "";
2869
- return local.length >= 3 && key.toLowerCase().includes(local) || ownValueKinds(key, identity).size > 0 ? OTHER_NAME : key;
2885
+ return holdsLocalPart(key, identity) || ownValueKinds(key, identity).size > 0 ? OTHER_NAME : key;
2870
2886
  };
2871
2887
  function ownLeaves(value, path, key, identity, depth, out) {
2872
2888
  if (depth > MAX_DEPTH3) return;
@@ -2997,7 +3013,7 @@ function withContainers(leaves) {
2997
3013
  }
2998
3014
  return all;
2999
3015
  }
3000
- var plural = (n, word) => `${n} ${word}${n === 1 ? "" : "s"}`;
3016
+ var plural = (n, word) => `${n} ${word}${n === 1 ? "" : /(s|x|ch|sh)$/.test(word) ? "es" : "s"}`;
3001
3017
  function holdsPath(push, matcher) {
3002
3018
  for (const path of push.paths.keys()) if (matcher.test(path)) return true;
3003
3019
  return false;
@@ -3048,16 +3064,17 @@ function evaluatePushRule(rule, input) {
3048
3064
  const label = types.join(" or ");
3049
3065
  found.set(label, (found.get(label) ?? 0) + 1);
3050
3066
  }
3051
- if (found.size) problems.push(`${path} is ${type} but found ${[...found].map(([label, n]) => `${label} in ${plural(n, "push")}`).join(", ")}`);
3067
+ if (found.size) problems.push(`${path} should be ${type}, found ${[...found].map(([label, n]) => `${label} in ${plural(n, "push")}`).join(", ")}`);
3052
3068
  }
3053
3069
  if (problems.length) {
3054
- return { pass: false, evidence: [...evidence], message: `Expected every ${subject}${where2} to have the types in dataLayer.types, but ${problems.join("; ")} (${before}).` };
3070
+ return { pass: false, evidence: [...evidence], message: `Expected every ${subject}${where2} to have the types in dataLayer.types: ${problems.join("; ")} (${before}).` };
3055
3071
  }
3056
3072
  }
3057
3073
  const holders = matchers2.length ? selected.filter((p) => matchers2.every((m) => holdsPath(p, m))) : selected;
3058
3074
  const count = rule.count ?? { op: ">=", n: 1 };
3059
3075
  const pass = countHolds(count, holders.length);
3060
- const holding = sel.has ? ` holding ${sel.has.join(", ")}` : "";
3076
+ const typed = sel.types ? ` with types ${Object.entries(sel.types).map(([path, type]) => `${path}: ${type}`).join(", ")}` : "";
3077
+ const holding = `${sel.has ? ` holding ${sel.has.join(", ")}` : ""}${typed}`;
3061
3078
  const unseenPushCouldBreak = sel.types !== void 0 || count.op === "<=" || count.op === "<" || count.op === "=";
3062
3079
  if (pass && input.hookIncomplete && unseenPushCouldBreak) {
3063
3080
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "tagreeve",
3
- "version": "0.7.0-rc.1",
3
+ "version": "0.7.0-rc.2",
4
4
  "description": "Agent-first testing for website tracking and consent.",
5
5
  "license": "MIT",
6
6
  "repository": {