Commit db73be0
committed
fix(measurement): cache robots.txt for 0s, name the property, stitch to gtag
Four measurement defects, three of them silent.
ROBOTS.TXT WAS CACHED FOR FOUR HOURS. Measured live on both zones:
`cache-control: public, max-age=14400, must-revalidate`. That is Cloudflare Pages'
default, not ours — the string 14400 appears in this repo only inside two
explanatory comments, and the built _headers had no /robots.txt rule at all, so no
zone Cache Rule was involved either. robots.txt is the one file where being wrong
for four hours can cost a crawl of everything: a bad Disallow, a missing Allow for a
new AI crawler, a corrected Sitemap line. Now max-age=0, must-revalidate — the edge
copy and the ETag are kept, the 304s already worked, every fetch just asks first.
Same for /llms.txt, /llms-full.txt and the mirrors: they are the ingestion surface,
regenerated on every deploy, and an agent holding a four-hour-old index is following
links to content that may have moved. Consolidated to one block per path so this
does not depend on Cloudflare merging rules that match the same URL.
`mp=` IN x-agent-analytics. The hardest question to answer from outside was "events
are being sent, but to WHICH property?" — and it is not academic: the two editions
shared one property by accident until 2026-08-02, with imqueue.org's traffic landing
in the one named imqueue.com. A repo cannot tell you which property owns an id, which
is exactly why the id lives in the deployment and its value now appears in the
header. G-… ids are public. The api_secret is never named, only its presence.
GTAG STITCHING. The edge used a salted IP+UA digest; gtag uses its own `_ga` client
id. Both are fine identifiers and they are different ones — so a person reading three
pages was one user to gtag and a second, unrelated user to this middleware, and no
per-user metric in the property was true for anyone appearing in both streams. The
`_ga` cookie is now read when it is already there. Nothing is created, no consent
state is touched, and a crawler never borrows one even if a cookie is presented —
asserted, because merging GPTBot into a real user's history would corrupt exactly the
numbers this exists to make true.
probe:agent-analytics WAS BROKEN AND ITS PREMISE WAS BACKWARDS.
* `buildEvent(...).events[0]` — buildEvent became async when the visitor digest was
added, so this read `.events` off a promise and the probe threw before sending
anything.
* It REFUSED to run against the site's own property, to keep crawler events out of
the human numbers. Rule 1 reversed that on 2026-08-03: both streams share one
property on purpose and the separation is the srv_page_view event name, since
GA4's `Views` counts only page_view. The refusal was rejecting the only supported
configuration. It is now the inverse — a non-site id is probably a stale copy —
and the closing advice says to look for srv_page_view, not page_view.
* A fourth case added: a browser arriving from a Perplexity answer, which is the
outcome the whole programme exists to produce and the one row nobody had seen
arrive. Verified against GA4's validation endpoint: four payloads, empty
validationMessages, `ai=perplexity` on the fourth.
npm test green, 11 analytics checks.1 parent 5623017 commit db73be0
4 files changed
Lines changed: 200 additions & 29 deletions
File tree
- lib
- scripts
- src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
385 | 385 | | |
386 | 386 | | |
387 | 387 | | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
388 | 418 | | |
389 | 419 | | |
390 | 420 | | |
| |||
483 | 513 | | |
484 | 514 | | |
485 | 515 | | |
486 | | - | |
| 516 | + | |
487 | 517 | | |
488 | 518 | | |
489 | 519 | | |
| |||
511 | 541 | | |
512 | 542 | | |
513 | 543 | | |
514 | | - | |
| 544 | + | |
| 545 | + | |
| 546 | + | |
| 547 | + | |
515 | 548 | | |
516 | 549 | | |
517 | 550 | | |
| |||
620 | 653 | | |
621 | 654 | | |
622 | 655 | | |
| 656 | + | |
| 657 | + | |
| 658 | + | |
| 659 | + | |
| 660 | + | |
| 661 | + | |
| 662 | + | |
| 663 | + | |
623 | 664 | | |
624 | 665 | | |
625 | | - | |
| 666 | + | |
626 | 667 | | |
627 | 668 | | |
628 | 669 | | |
| |||
657 | 698 | | |
658 | 699 | | |
659 | 700 | | |
| 701 | + | |
| 702 | + | |
660 | 703 | | |
661 | 704 | | |
662 | 705 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
340 | 340 | | |
341 | 341 | | |
342 | 342 | | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
343 | 392 | | |
344 | 393 | | |
345 | 394 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
| 12 | + | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
26 | 28 | | |
27 | 29 | | |
28 | 30 | | |
29 | | - | |
30 | | - | |
31 | | - | |
32 | | - | |
33 | | - | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
34 | 45 | | |
35 | 46 | | |
36 | 47 | | |
| |||
41 | 52 | | |
42 | 53 | | |
43 | 54 | | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
44 | 59 | | |
45 | 60 | | |
46 | 61 | | |
47 | 62 | | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
48 | 69 | | |
49 | 70 | | |
50 | 71 | | |
| |||
68 | 89 | | |
69 | 90 | | |
70 | 91 | | |
| 92 | + | |
71 | 93 | | |
72 | | - | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
73 | 99 | | |
74 | | - | |
75 | | - | |
76 | | - | |
77 | | - | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
78 | 105 | | |
79 | 106 | | |
80 | 107 | | |
| |||
84 | 111 | | |
85 | 112 | | |
86 | 113 | | |
87 | | - | |
| 114 | + | |
88 | 115 | | |
89 | | - | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
90 | 135 | | |
91 | 136 | | |
92 | | - | |
93 | | - | |
| 137 | + | |
| 138 | + | |
94 | 139 | | |
95 | 140 | | |
96 | 141 | | |
97 | 142 | | |
98 | 143 | | |
99 | | - | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
100 | 148 | | |
101 | 149 | | |
102 | 150 | | |
103 | 151 | | |
104 | 152 | | |
105 | 153 | | |
106 | 154 | | |
107 | | - | |
108 | | - | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
109 | 159 | | |
110 | 160 | | |
111 | 161 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
18 | | - | |
19 | | - | |
20 | | - | |
21 | | - | |
22 | | - | |
23 | 15 | | |
24 | 16 | | |
25 | 17 | | |
| |||
44 | 36 | | |
45 | 37 | | |
46 | 38 | | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
47 | 76 | | |
48 | 77 | | |
49 | 78 | | |
| |||
0 commit comments