tagreeve 0.0.0-stage → 0.4.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Alf
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,216 @@
1
- # Temporary Holding Version
1
+ <h1>
2
+ <picture>
3
+ <source media="(prefers-color-scheme: dark)" srcset="brand/lockup-dark.svg">
4
+ <img alt="Tagreeve" src="brand/lockup.svg" width="284" height="64">
5
+ </picture>
6
+ </h1>
2
7
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
8
+ > **Pingwright is now Tagreeve.** The command `pingwright` still works until 0.5.0. Versions up to 0.3.0 are on npm as `pingwright`, and `tagreeve` starts at 0.4.0-rc.1. The steps to move over are in [CHANGELOG.md](CHANGELOG.md).
9
+
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. Tag-firing reports (which tags fired) are planned.
11
+
12
+ > **Status: 0.4 (`0.4.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. 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
+ >
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
+ >
16
+ > **In 0.2:** `--gtm-override` runs the page against an unpublished GTM web workspace, also through a Stape-style custom loader; `tagreeve diff` compares two runs; a Pinterest decoder; a curated tracker list (LinkedIn, Microsoft UET, Reddit) that is stubbed and recorded as minimal hits, extendable with `--tracker-list` (X, for example); a record schema version; a Shopify checkout pattern ([docs/shopify-checkout.md](docs/shopify-checkout.md)).
17
+ >
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
+ >
20
+ > **In 0.4.0-rc.1** (install with `npm i -g tagreeve@next` until 0.4.0): a `handoff` step can end at a URL or an element (`until`, `settle`, `timeout`); a `payment` step types a provider's test card on a store you allow, with three opt-in checks; `tagreeve baseline save` and `run --baseline` catch drift in the shape of a run; `--viewport <W>x<H>`; `identity.country` picks the format of the fake identity (US, SE, GB, DE); optional `fill` entries; a `possibleRedirectHop` flag; and the rename to Tagreeve. What is still open is in [CHANGELOG.md](CHANGELOG.md) under "Known in 0.4.0-rc.1".
21
+ >
22
+ > **Not built yet:** the server tag reporter, several stores in one suite, a Shopify bridge, a full Microsoft UET decoder, a `mobile` viewport preset, Firefox and WebKit. There is no MCP server: Tagreeve is a CLI, and agents read `--json`.
23
+
24
+ ## Why
25
+
26
+ Tracking setups break quietly. A trigger change lets a pixel fire before consent. A container update sends hits to the wrong place. A consent banner update stops the analytics tags. The usual tools for catching this need a person:
27
+
28
+ - Google Tag Assistant and GTM Preview show which tags fired, but only to a signed-in person clicking through a page.
29
+ - Browser extensions decode hits in DevTools, but nothing can call them.
30
+ - Commercial auditing services run in their own cloud, on their own schedule.
31
+
32
+ Tagreeve is built so that a coding agent, a CI job or a person can answer these questions with one command and get structured results:
33
+
34
+ - What did the site send to each vendor, before and after the visitor's consent choice?
35
+ - Which tags fired for each event, and which expected tags did not? (Planned, not built yet.)
36
+ - Does an unpublished GTM workspace behave as intended, before you publish it? Run the same scenario with and without `--gtm-override` and compare the two records with `tagreeve diff`. (In 0.2.)
37
+
38
+ ## What it does
39
+
40
+ 1. **Plays a visitor.** A Playwright browser opens your site, answers the consent banner (accept, reject, or no answer), visits pages, fills forms with a fake identity and adds to cart. Steps that a tool must not do, such as paying or logging in, are handoff steps: a person acts in a visible window while recording continues.
41
+ 2. **Records requests** from the page and from all iframes, including sandboxed iframes such as Shopify custom pixels. Capture from service workers works in Chromium only, and requests to the collector origin from dedicated workers are captured too. Each run reports which sources it covered.
42
+ 3. **Decodes hits.** Vendor plugins turn raw requests into readable hits: GA4 events and consent state, Google Ads, Meta and Stape server-container traffic. Pinterest is decoded in 0.2. Hosts on the tracker list, such as LinkedIn, Microsoft UET and Reddit, give minimal hits with the vendor name. A full Microsoft UET decoder is not built yet.
43
+ 4. **Reports tag firing (not built yet).** An optional GTM template reports which tags fired or failed for each event, in the web container and the server container. Agents get this without a Google sign-in. Given the container's tag list, Tagreeve also reports which expected tags did not fire.
44
+ 5. **Checks expectations.** Each scenario lists what must and must not happen, for example "no Meta request before consent" or "GA4 hits after a reject carry no user ID". Tagreeve reports pass or fail, with the evidence. A scenario that names a vendor Tagreeve does not know is rejected when it is parsed.
45
+ 6. **Checks hashing.** Because Tagreeve knows the fake identity it typed, it can check that the hashed email and phone sent to Google and Meta are correct.
46
+ 7. **Compares runs.** `tagreeve diff` shows what changed per vendor and per event between two runs, for example before and after a GTM change. `tagreeve suite` does this for a folder of scenarios.
47
+ 8. **Reports.** `tagreeve report` turns a run or a suite into one HTML file for people who do not read JSONL.
48
+
49
+ ## A scenario
50
+
51
+ ```yaml
52
+ # scenarios/undecided-visitor.yml
53
+ start: /products/{product}
54
+ vars:
55
+ product: fake-tee
56
+ steps:
57
+ - consent: none # the banner must appear, and gets no answer
58
+ - wait: 4s
59
+ - visit: /collections/all
60
+ expect:
61
+ mustNot:
62
+ - { vendor: [meta, google-ads], before: consent }
63
+ - { vendor: ga4, ids.user_id: present, consent.analytics: denied }
64
+ must:
65
+ - { vendor: ga4, event: page_view, consent.analytics: denied, count: ">=2" }
66
+ ```
67
+
68
+ ```bash
69
+ tagreeve run scenarios/undecided-visitor.yml --site https://staging.example.com
70
+ ```
71
+
72
+ ## Install
73
+
74
+ ```bash
75
+ npm i -g tagreeve@next
76
+ tagreeve install-browser
77
+ ```
78
+
79
+ Node 22.18 or later. `npm i -g tagreeve@next` installs the newest 0.4 release candidate. Other ways to install, from a git tag or a tarball, are in [docs/cli.md](docs/cli.md).
80
+
81
+ ## Quick start
82
+
83
+ 1. `npm i -g tagreeve@next`
84
+ 2. `tagreeve install-browser`
85
+ 3. Write `scenario.yml`:
86
+
87
+ ```yaml
88
+ start: /
89
+ steps:
90
+ - consent: none
91
+ - wait: 4s
92
+ expect:
93
+ mustNot:
94
+ - { vendor: [meta, google-ads], before: consent }
95
+ ```
96
+
97
+ 4. `tagreeve run scenario.yml --site https://staging.example.com`
98
+ 5. Read the summary, and the full record in `runs/run_<id>.jsonl`.
99
+
100
+ `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`, `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.
101
+
102
+ 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. 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, 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.
103
+
104
+ ## Override and diff quick start
105
+
106
+ Run one scenario against the published container and against an unpublished workspace, then compare.
107
+
108
+ 1. Get the preview values for the workspace from the GTM UI, a GTM API client or a GTM MCP server. Tagreeve never calls the GTM API. Write them to `override.json`:
109
+
110
+ ```json
111
+ {"container": "GTM-XXXXXXX", "gtmAuth": "…", "gtmPreview": "env-12"}
112
+ ```
113
+
114
+ 2. Run the scenario twice:
115
+
116
+ ```bash
117
+ tagreeve run scenario.yml --site https://staging.example.com --out runs/published
118
+ tagreeve run scenario.yml --site https://staging.example.com --out runs/workspace --gtm-override override.json
119
+ ```
120
+
121
+ 3. Compare the two records:
122
+
123
+ ```bash
124
+ tagreeve diff runs/published/run_<id>.jsonl runs/workspace/run_<id>.jsonl
125
+ ```
126
+
127
+ `diff` lists added, removed and changed hits per consent epoch, vendor and event, and changed flag counts per host. Add `--by-page` to pair hits page by page, or `--json` for the full result. It exits 0 whether or not the runs differ; the exit code of each `run` tells you whether its rules passed.
128
+
129
+ The override fetches the workspace build of `gtm.js?id=<container>` and answers the page with it. If no request matched, or the build did not return 200, the run exits 2. The `gtmAuth` value never appears in the record or in any output. For a site that loads the container through a Stape-style custom loader, the override works through the loader by default. Add `"loader": {"replace": "<script URL>"}` to replace the loader script instead. Details are in [docs/cli.md](docs/cli.md).
130
+
131
+ ## Suite and report quick start
132
+
133
+ Run a folder of scenarios against the published container and an unpublished workspace, then make a report that people can read without JSONL.
134
+
135
+ ```bash
136
+ tagreeve suite scenarios/ --site https://staging.example.com \
137
+ --variant published --variant workspace=override.json --out runs
138
+ tagreeve report runs/suite_<id> --html suite-report.html
139
+ ```
140
+
141
+ `suite` runs every `*.yml` file in the folder once per variant, and prints a table with the result of each run and the diff between the variants. The runs and a `suite.json` manifest go to `runs/suite_<id>/`. The exit code is 2 if a run did not finish, 1 if an expectation failed, else 0. A scenario with a `handoff` step is skipped unless you add `--with-handoff`. `report` writes one HTML file with a timeline per vendor and consent state, the expectations, the flags and the diff. It has names and counts only, no script and no network request. `tagreeve report runs/run_<id>.jsonl --html report.html` makes the report for one run. Details are in [docs/cli.md](docs/cli.md).
142
+
143
+ ## Rules and steps added in 0.3
144
+
145
+ ```yaml
146
+ steps:
147
+ - consent: reject
148
+ - click: { role: radio, name: "White (01)" }
149
+ - click: { any: ['[role=radio][title$="White (01)"]', 'text=White (01)'] }
150
+ - select: { "select[name=countryCode]": DE }
151
+ expect:
152
+ mustNot:
153
+ - { vendor: sgtm, body.has: [email, phone, "user_data.*", "cookie*"], in: epoch(denied) }
154
+ - { cookie: "_ga*", in: epoch(denied) }
155
+ must:
156
+ - { vendor: sgtm, event: page_view, body.only: [event_name, page_location, page_title, page_referrer] }
157
+ options:
158
+ builtins: { deniedIdentifiers: warn }
159
+ ```
160
+
161
+ - `body.has` matches hits by the names of the fields they sent, and `body.only` is an allowlist of field names. They read names, never values.
162
+ - `cookie` checks which cookies were set, by name, before or after consent. In `stub` mode a stubbed endpoint sets no cookies, so use `--network server` with `options.serverHosts` to see the cookies of a server container.
163
+ - `deniedIdentifiers` is a built-in check. It fails when a hit carries `user_id`, `uid`, a hashed `user_data` field or another identifier while the matching consent signal is denied. It is `fail` by default. Set it to `warn` to keep the old exit code while you fix the cause.
164
+ - `click` and `wait` take `{ role, name }` or `{ any: [selectors] }`, so a theme change does not break every scenario. `select` chooses an option of a `<select>` by value, then by label, and reads it back.
165
+
166
+ ## Tracker list
167
+
168
+ In `stub` mode, Tagreeve stubs and records requests to a curated list of tracker hosts, so a pixel without a decoder no longer leaks to the vendor. The list is small, kept in the repo, and each entry links to the vendor's own docs. A listed request becomes a minimal hit with the vendor name, so rules, flags and `diff` work on it. Add your own entries with `--tracker-list`:
169
+
170
+ ```json
171
+ [{"vendor": "acme", "host": "t.example.com", "paths": ["/collect"], "source": "https://docs.example.com/pixel"}]
172
+ ```
173
+
174
+ ```bash
175
+ tagreeve run scenario.yml --site https://staging.example.com --tracker-list trackers.json
176
+ ```
177
+
178
+ `vendor` is a lowercase key you can then use in `expect` rules. `host` is an exact host or `*.domain`. `paths` is optional. See [docs/cli.md](docs/cli.md) for the matching rules.
179
+
180
+ ## Safe by default
181
+
182
+ - **Known collection endpoints are stubbed by default.** Scripts load normally, but requests to known collection endpoints are recorded and answered locally. Unknown destinations pass through, so test hits can still reach vendors that way. Requests to hosts outside the site's registrable domain are flagged when they are `fetch`, `xhr`, `ping` or `beacon` requests, or images or other requests that carry a query or a body. They are flagged as `unknownDestination`. Scripts, stylesheets, fonts and documents are not flagged. Requests a sandboxed `srcdoc` iframe sends while it loads can escape stubbing and recording (design §5.3). Tagreeve lets them through because blocking by host would stop vendor scripts from loading and make a broken setup look compliant. Use `--network live` to let everything through.
183
+ - **Fake identities.** Every run uses a generated test identity. Tagreeve flags any email, phone number or hashed identifier in a recording that does not belong to that identity.
184
+ - **No log-ins, and payments only as an opt-in test.** On a hosted site a log-in is always a handoff step for a person, who should use test accounts. A payment is a handoff step too, except for the opt-in `payment` step, which types a provider's documented test card after three checks: `--allow-test-payment <host>`, the host in your allowlist file, and the provider's test mode on the page. Only loopback hosts, such as the fixture shop, may be automated through a fake payment form.
185
+ - **You own the data.** There is no Tagreeve-hosted service. When server-side reports are built, they will go to a sink you run: a tunnel to your machine, or a small Worker in your own Cloudflare account.
186
+
187
+ ## For agents
188
+
189
+ There is no MCP server. An agent uses the CLI: `run --json`, `diff --json` and `suite --json` print structured results. Every record has a stable ID, and every result names the run and step.
190
+
191
+ Tagreeve will not change GTM containers or sign in to Google. An agent that edits a workspace with a GTM API client (for example a GTM MCP server) passes the workspace preview values to Tagreeve for one run with `--gtm-override`.
192
+
193
+ ## Packages
194
+
195
+ | Package | Job | State |
196
+ | --- | --- | --- |
197
+ | `core` | IDs, clock, record types, record schema version, JSONL run store, fake identity | 0.4 |
198
+ | `recorder` | Launch the browser, play steps, capture requests, responses, cookies and dataLayer events, GTM override, Done control, locators, `server` mode | 0.4 |
199
+ | `decoders` | One plugin per vendor, with synthetic fixtures as tests | 0.4 (GA4, Google Ads, Meta, Pinterest, Stape, server-container data client, tracker list; hit field names) |
200
+ | `consent` | Banner handling through DuckDuckGo autoconsent, Consent Mode probe, epochs | 0.1 |
201
+ | `expect` | Scenario format, expectations, `deniedIdentifiers`, diff engine | 0.4 |
202
+ | `cli` | `tagreeve run`, `diff`, `suite`, `report`, `baseline`, `install-browser` | 0.4 |
203
+ | `gtm` | Tag-firing reporter templates | not built yet |
204
+ | `platforms/shopify` | Custom-pixel bridge, sandbox URL handling, checkout handoff | not built yet |
205
+
206
+ ## Related tools
207
+
208
+ - **EDPS website-evidence-collector** records cookies and beacons, including before consent. Tagreeve adds vendor decoding, expectations and diffs. Tag reports are planned.
209
+ - **DuckDuckGo autoconsent** handles consent banners. Tagreeve uses it.
210
+ - **Snowplow Micro** does local, assertable event collection for Snowplow trackers.
211
+ - **ObservePoint**, **DataTrue** and **Trackingplan** are commercial services for tag auditing and monitoring.
212
+ - **Avo**, **Segment Protocols** and **Amplitude Data** govern the schema of your own product events.
213
+
214
+ ## License
215
+
216
+ [MIT](LICENSE)