@decocms/parity 0.35.27 → 0.35.28
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 +13 -0
- package/dist/cli.js +320 -173
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -110,6 +110,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/).
|
|
|
110
110
|
|
|
111
111
|
### Changed
|
|
112
112
|
|
|
113
|
+
* **A missing tag manager is one finding per page, not four checks' worth.** `analytics-beacon-parity`
|
|
114
|
+
reports `analytics-beacon:tag-manager-absent:<page>` when prod loaded the GTM container and cand did
|
|
115
|
+
not, naming the container and the tags that go with it (replaces the per-tag
|
|
116
|
+
`analytics-beacon:missing:*` ids on that page; with the container present on cand they are
|
|
117
|
+
unchanged). `third-party-scripts-parity` lowers analytics/marketing vendor origins explained by it
|
|
118
|
+
to `low` + `inconclusive` (other missing origins keep `high`), and `html-structural-diff`
|
|
119
|
+
discounts those vendors' `<script>` tags from the script count and lists them once in
|
|
120
|
+
`html-structural:tag-manager-scripts`. Shared helper: `checks/lib/tag-manager.ts`.
|
|
121
|
+
* **A local dev server counts as a staging host** (`localhost`, `127.0.0.0/8`, `[::1]`,
|
|
122
|
+
`*.localhost`, prod not local), so the existing staging leniency applies there without a noindex
|
|
123
|
+
signal; `--cand-is-production` turns it off. On a dev server the consolidated tag-manager finding
|
|
124
|
+
is `low` + `inconclusive`.
|
|
125
|
+
|
|
113
126
|
* **`parity run`'s visual module runs on the `parity heatmap` engine — no LLM.**
|
|
114
127
|
The old pass sent screenshot pairs to a vision model and filed what it said.
|
|
115
128
|
On real runs it invented findings — a stat card on neither side, prod and cand
|
package/dist/cli.js
CHANGED
|
@@ -76646,100 +76646,6 @@ function urlPageKey(url, viewport) {
|
|
|
76646
76646
|
return `${path}::${viewport}`;
|
|
76647
76647
|
}
|
|
76648
76648
|
|
|
76649
|
-
// src/checks/analytics-beacon-parity.ts
|
|
76650
|
-
var BEACON_PATTERNS = [
|
|
76651
|
-
{
|
|
76652
|
-
id: "gtm-container",
|
|
76653
|
-
label: "Google Tag Manager (gtm.js)",
|
|
76654
|
-
match: (u) => /googletagmanager\.com\/gtm\.js/.test(u)
|
|
76655
|
-
},
|
|
76656
|
-
{
|
|
76657
|
-
id: "gtag-js",
|
|
76658
|
-
label: "Google gtag.js / Google Ads",
|
|
76659
|
-
match: (u) => /googletagmanager\.com\/gtag\/js/.test(u)
|
|
76660
|
-
},
|
|
76661
|
-
{
|
|
76662
|
-
id: "ga4-collect",
|
|
76663
|
-
label: "GA4 collect beacon",
|
|
76664
|
-
match: (u) => /google-analytics\.com\/g\/collect|analytics\.google\.com\/g\/collect/.test(u)
|
|
76665
|
-
},
|
|
76666
|
-
{
|
|
76667
|
-
id: "meta-pixel",
|
|
76668
|
-
label: "Meta (Facebook) Pixel",
|
|
76669
|
-
match: (u) => /connect\.facebook\.(net|com)\/.*\/fbevents\.js|facebook\.com\/tr\//.test(u)
|
|
76670
|
-
},
|
|
76671
|
-
{
|
|
76672
|
-
id: "tiktok-pixel",
|
|
76673
|
-
label: "TikTok Pixel",
|
|
76674
|
-
match: (u) => /analytics\.tiktok\.com\/i18n\/pixel/.test(u)
|
|
76675
|
-
},
|
|
76676
|
-
{
|
|
76677
|
-
id: "pinterest-tag",
|
|
76678
|
-
label: "Pinterest Tag",
|
|
76679
|
-
match: (u) => /ct\.pinterest\.com\/v3/.test(u)
|
|
76680
|
-
}
|
|
76681
|
-
];
|
|
76682
|
-
function analyticsBeaconParity(ctx) {
|
|
76683
|
-
const start = Date.now();
|
|
76684
|
-
if (ctx.prodPages.length === 0) {
|
|
76685
|
-
return skip(start, "sem baseline prod — nada para comparar (single-site)");
|
|
76686
|
-
}
|
|
76687
|
-
const { pairs } = pairCaptures(ctx.prodPages, ctx.candPages);
|
|
76688
|
-
const issues = [];
|
|
76689
|
-
let pairsWithAnyBeacon = 0;
|
|
76690
|
-
for (const pair of pairs) {
|
|
76691
|
-
const prodHits = detectedBeacons(pair.prod);
|
|
76692
|
-
const candHits = detectedBeacons(pair.cand);
|
|
76693
|
-
if (prodHits.size === 0 && candHits.size === 0)
|
|
76694
|
-
continue;
|
|
76695
|
-
pairsWithAnyBeacon++;
|
|
76696
|
-
for (const pattern of BEACON_PATTERNS) {
|
|
76697
|
-
const inProd = prodHits.has(pattern.id);
|
|
76698
|
-
const inCand = candHits.has(pattern.id);
|
|
76699
|
-
if (inProd && !inCand) {
|
|
76700
|
-
issues.push({
|
|
76701
|
-
id: `analytics-beacon:missing:${pattern.id}:${pair.key}`,
|
|
76702
|
-
severity: "high",
|
|
76703
|
-
category: "network",
|
|
76704
|
-
page: pair.key,
|
|
76705
|
-
check: "analytics-beacon-parity",
|
|
76706
|
-
summary: `${pattern.label} disparou em prod mas não no candidato em ${pair.key}`,
|
|
76707
|
-
suggestedFix: "Confirme o container/pixel ID no candidato — tag manager ausente derruba TODO o rastreamento a jusante dele, não só este evento."
|
|
76708
|
-
});
|
|
76709
|
-
}
|
|
76710
|
-
}
|
|
76711
|
-
}
|
|
76712
|
-
const hasHigh = issues.some((i) => i.severity === "high");
|
|
76713
|
-
return {
|
|
76714
|
-
name: "analytics-beacon-parity",
|
|
76715
|
-
status: hasHigh ? "fail" : issues.length > 0 ? "warn" : "pass",
|
|
76716
|
-
severity: "high",
|
|
76717
|
-
durationMs: Date.now() - start,
|
|
76718
|
-
summary: pairsWithAnyBeacon === 0 ? "Nenhum beacon de analytics conhecido observado em nenhum dos lados — nada a validar (ou o site usa uma ferramenta fora da lista de padrões)" : `${issues.length} beacon(s) de analytics perdido(s) em ${pairsWithAnyBeacon} página(s) com tráfego de analytics`,
|
|
76719
|
-
issues
|
|
76720
|
-
};
|
|
76721
|
-
}
|
|
76722
|
-
function detectedBeacons(page) {
|
|
76723
|
-
const hits = new Set;
|
|
76724
|
-
for (const entry of page.network) {
|
|
76725
|
-
for (const pattern of BEACON_PATTERNS) {
|
|
76726
|
-
if (pattern.match(entry.url))
|
|
76727
|
-
hits.add(pattern.id);
|
|
76728
|
-
}
|
|
76729
|
-
}
|
|
76730
|
-
return hits;
|
|
76731
|
-
}
|
|
76732
|
-
function skip(start, summary) {
|
|
76733
|
-
return {
|
|
76734
|
-
name: "analytics-beacon-parity",
|
|
76735
|
-
status: "skipped",
|
|
76736
|
-
severity: "high",
|
|
76737
|
-
durationMs: Date.now() - start,
|
|
76738
|
-
summary,
|
|
76739
|
-
issues: []
|
|
76740
|
-
};
|
|
76741
|
-
}
|
|
76742
|
-
|
|
76743
76649
|
// src/diff/dom.ts
|
|
76744
76650
|
init_esm10();
|
|
76745
76651
|
|
|
@@ -77400,6 +77306,264 @@ function diffMeta(prod, cand) {
|
|
|
77400
77306
|
return out;
|
|
77401
77307
|
}
|
|
77402
77308
|
|
|
77309
|
+
// src/util/localhost.ts
|
|
77310
|
+
var LOCALHOST_HOSTS = new Set(["localhost", "127.0.0.1", "0.0.0.0", "::1", "[::1]"]);
|
|
77311
|
+
function isLocalhost(rawUrl) {
|
|
77312
|
+
try {
|
|
77313
|
+
const url = new URL(rawUrl);
|
|
77314
|
+
return LOCALHOST_HOSTS.has(url.hostname);
|
|
77315
|
+
} catch {
|
|
77316
|
+
return false;
|
|
77317
|
+
}
|
|
77318
|
+
}
|
|
77319
|
+
|
|
77320
|
+
// src/checks/lib/staging.ts
|
|
77321
|
+
function isCandOnStagingHost(prodPages, candPages, candIsProduction = false) {
|
|
77322
|
+
if (candIsProduction)
|
|
77323
|
+
return false;
|
|
77324
|
+
if (isCandOnLoopbackHost(prodPages, candPages, candIsProduction))
|
|
77325
|
+
return true;
|
|
77326
|
+
const prodSite = siteHost(prodPages);
|
|
77327
|
+
const candSite = siteHost(candPages);
|
|
77328
|
+
if (!prodSite || !candSite || prodSite === candSite)
|
|
77329
|
+
return false;
|
|
77330
|
+
const { pairs } = pairCaptures(prodPages, candPages);
|
|
77331
|
+
const judged = pairs.filter((p) => bareHost(finalOf(p.prod)) === prodSite && bareHost(finalOf(p.cand)) === candSite && !isNoindex(p.prod) && hasHead(p.cand));
|
|
77332
|
+
if (judged.length === 0)
|
|
77333
|
+
return false;
|
|
77334
|
+
const noindexed = judged.filter((p) => isNoindex(p.cand)).length;
|
|
77335
|
+
return noindexed * 2 > judged.length;
|
|
77336
|
+
}
|
|
77337
|
+
function isCandOnLoopbackHost(prodPages, candPages, candIsProduction = false) {
|
|
77338
|
+
if (candIsProduction)
|
|
77339
|
+
return false;
|
|
77340
|
+
const prodSite = siteHost(prodPages);
|
|
77341
|
+
const candSite = siteHost(candPages);
|
|
77342
|
+
if (!prodSite || !candSite)
|
|
77343
|
+
return false;
|
|
77344
|
+
return isLoopbackHost(candSite) && !isLoopbackHost(prodSite);
|
|
77345
|
+
}
|
|
77346
|
+
function isLoopbackHost(host) {
|
|
77347
|
+
return isLocalhost(`http://${host}/`) || host.endsWith(".localhost") || /^127\./.test(host);
|
|
77348
|
+
}
|
|
77349
|
+
var STAGING_NOTE = "cand está num host de staging (noindex no host inteiro com prod indexável, ou dev server local) — esperado ali; reconfira depois da troca de domínio, ou rode com --cand-is-production se cand já é o domínio final.";
|
|
77350
|
+
function hasHead(page) {
|
|
77351
|
+
const { meta } = snapshotDom(page.html ?? "");
|
|
77352
|
+
return meta.title != null || meta.robots != null || Boolean(page.xRobotsTag);
|
|
77353
|
+
}
|
|
77354
|
+
function isNoindex(page) {
|
|
77355
|
+
const meta = snapshotDom(page.html ?? "").meta.robots ?? "";
|
|
77356
|
+
return /\bnoindex\b/i.test(meta) || /\bnoindex\b/i.test(page.xRobotsTag ?? "");
|
|
77357
|
+
}
|
|
77358
|
+
function finalOf(page) {
|
|
77359
|
+
return page.finalUrl || page.url;
|
|
77360
|
+
}
|
|
77361
|
+
function siteHost(pages) {
|
|
77362
|
+
const counts = new Map;
|
|
77363
|
+
for (const page of pages) {
|
|
77364
|
+
const host = bareHost(finalOf(page));
|
|
77365
|
+
if (host)
|
|
77366
|
+
counts.set(host, (counts.get(host) ?? 0) + 1);
|
|
77367
|
+
}
|
|
77368
|
+
let best = null;
|
|
77369
|
+
for (const [host, n] of counts)
|
|
77370
|
+
if (!best || n > (counts.get(best) ?? 0))
|
|
77371
|
+
best = host;
|
|
77372
|
+
return best;
|
|
77373
|
+
}
|
|
77374
|
+
function bareHost(url) {
|
|
77375
|
+
try {
|
|
77376
|
+
return new URL(url).hostname.replace(/^www\./, "");
|
|
77377
|
+
} catch {
|
|
77378
|
+
return null;
|
|
77379
|
+
}
|
|
77380
|
+
}
|
|
77381
|
+
var SECOND_LEVEL = new Set(["com", "net", "org", "gov", "edu", "co", "ac", "ne", "or", "go"]);
|
|
77382
|
+
function registrableDomain(hostname) {
|
|
77383
|
+
const parts = hostname.split(".");
|
|
77384
|
+
if (parts.length <= 2)
|
|
77385
|
+
return hostname;
|
|
77386
|
+
const sld = parts[parts.length - 2];
|
|
77387
|
+
const tld = parts[parts.length - 1];
|
|
77388
|
+
const take = tld.length === 2 && SECOND_LEVEL.has(sld) ? 3 : 2;
|
|
77389
|
+
return parts.slice(-take).join(".");
|
|
77390
|
+
}
|
|
77391
|
+
|
|
77392
|
+
// src/checks/lib/tag-manager.ts
|
|
77393
|
+
var GTM_CONTAINER_URL = /googletagmanager\.com\/gtm\.js/;
|
|
77394
|
+
function loadsTagManager(page) {
|
|
77395
|
+
return page.network.some((e) => GTM_CONTAINER_URL.test(e.url));
|
|
77396
|
+
}
|
|
77397
|
+
function tagManagerAbsentOnCand(prod, cand) {
|
|
77398
|
+
return loadsTagManager(prod) && !loadsTagManager(cand);
|
|
77399
|
+
}
|
|
77400
|
+
function tagManagerContainerIds(page) {
|
|
77401
|
+
const ids = new Set;
|
|
77402
|
+
for (const e of page.network) {
|
|
77403
|
+
if (GTM_CONTAINER_URL.test(e.url))
|
|
77404
|
+
ids.add(new URL(e.url).searchParams.get("id") ?? "(sem id)");
|
|
77405
|
+
}
|
|
77406
|
+
return [...ids];
|
|
77407
|
+
}
|
|
77408
|
+
var VENDOR_DOMAINS = new Set([
|
|
77409
|
+
"googletagmanager.com",
|
|
77410
|
+
"google-analytics.com",
|
|
77411
|
+
"doubleclick.net",
|
|
77412
|
+
"googleadservices.com",
|
|
77413
|
+
"facebook.net",
|
|
77414
|
+
"facebook.com",
|
|
77415
|
+
"clarity.ms",
|
|
77416
|
+
"bing.com",
|
|
77417
|
+
"hotjar.com",
|
|
77418
|
+
"tiktok.com",
|
|
77419
|
+
"pinterest.com"
|
|
77420
|
+
]);
|
|
77421
|
+
var GOOGLE_ADS_PATH = /^\/(pagead|ccm|rmkt|ads|g\/collect|j\/collect)(\/|$)/;
|
|
77422
|
+
function tagManagerVendorOrigins(prod) {
|
|
77423
|
+
const googlePaths = new Map;
|
|
77424
|
+
const out = new Set;
|
|
77425
|
+
for (const e of prod.network) {
|
|
77426
|
+
let u;
|
|
77427
|
+
try {
|
|
77428
|
+
u = new URL(e.url);
|
|
77429
|
+
} catch {
|
|
77430
|
+
continue;
|
|
77431
|
+
}
|
|
77432
|
+
const domain = registrableDomain(u.hostname);
|
|
77433
|
+
if (VENDOR_DOMAINS.has(domain))
|
|
77434
|
+
out.add(domain);
|
|
77435
|
+
else if (/^google\./.test(domain)) {
|
|
77436
|
+
googlePaths.set(domain, (googlePaths.get(domain) ?? true) && GOOGLE_ADS_PATH.test(u.pathname));
|
|
77437
|
+
}
|
|
77438
|
+
}
|
|
77439
|
+
for (const [domain, adsOnly] of googlePaths)
|
|
77440
|
+
if (adsOnly)
|
|
77441
|
+
out.add(domain);
|
|
77442
|
+
return out;
|
|
77443
|
+
}
|
|
77444
|
+
|
|
77445
|
+
// src/checks/analytics-beacon-parity.ts
|
|
77446
|
+
var BEACON_PATTERNS = [
|
|
77447
|
+
{
|
|
77448
|
+
id: "gtm-container",
|
|
77449
|
+
label: "Google Tag Manager (gtm.js)",
|
|
77450
|
+
match: (u) => GTM_CONTAINER_URL.test(u)
|
|
77451
|
+
},
|
|
77452
|
+
{
|
|
77453
|
+
id: "gtag-js",
|
|
77454
|
+
label: "Google gtag.js / Google Ads",
|
|
77455
|
+
match: (u) => /googletagmanager\.com\/gtag\/js/.test(u)
|
|
77456
|
+
},
|
|
77457
|
+
{
|
|
77458
|
+
id: "ga4-collect",
|
|
77459
|
+
label: "GA4 collect beacon",
|
|
77460
|
+
match: (u) => /google-analytics\.com\/g\/collect|analytics\.google\.com\/g\/collect/.test(u)
|
|
77461
|
+
},
|
|
77462
|
+
{
|
|
77463
|
+
id: "meta-pixel",
|
|
77464
|
+
label: "Meta (Facebook) Pixel",
|
|
77465
|
+
match: (u) => /connect\.facebook\.(net|com)\/.*\/fbevents\.js|facebook\.com\/tr\//.test(u)
|
|
77466
|
+
},
|
|
77467
|
+
{
|
|
77468
|
+
id: "tiktok-pixel",
|
|
77469
|
+
label: "TikTok Pixel",
|
|
77470
|
+
match: (u) => /analytics\.tiktok\.com\/i18n\/pixel/.test(u)
|
|
77471
|
+
},
|
|
77472
|
+
{
|
|
77473
|
+
id: "pinterest-tag",
|
|
77474
|
+
label: "Pinterest Tag",
|
|
77475
|
+
match: (u) => /ct\.pinterest\.com\/v3/.test(u)
|
|
77476
|
+
}
|
|
77477
|
+
];
|
|
77478
|
+
function analyticsBeaconParity(ctx) {
|
|
77479
|
+
const start = Date.now();
|
|
77480
|
+
if (ctx.prodPages.length === 0) {
|
|
77481
|
+
return skip(start, "sem baseline prod — nada para comparar (single-site)");
|
|
77482
|
+
}
|
|
77483
|
+
const { pairs } = pairCaptures(ctx.prodPages, ctx.candPages);
|
|
77484
|
+
const issues = [];
|
|
77485
|
+
let pairsWithAnyBeacon = 0;
|
|
77486
|
+
const devServer = isCandOnLoopbackHost(ctx.prodPages, ctx.candPages, ctx.candIsProduction);
|
|
77487
|
+
for (const pair of pairs) {
|
|
77488
|
+
const prodHits = detectedBeacons(pair.prod);
|
|
77489
|
+
const candHits = detectedBeacons(pair.cand);
|
|
77490
|
+
if (prodHits.size === 0 && candHits.size === 0)
|
|
77491
|
+
continue;
|
|
77492
|
+
pairsWithAnyBeacon++;
|
|
77493
|
+
const containerAbsent = tagManagerAbsentOnCand(pair.prod, pair.cand);
|
|
77494
|
+
if (containerAbsent) {
|
|
77495
|
+
const dependents = BEACON_PATTERNS.filter((p) => p.id !== "gtm-container" && prodHits.has(p.id) && !candHits.has(p.id));
|
|
77496
|
+
const containers = tagManagerContainerIds(pair.prod);
|
|
77497
|
+
issues.push({
|
|
77498
|
+
id: `analytics-beacon:tag-manager-absent:${pair.key}`,
|
|
77499
|
+
severity: devServer ? "low" : "high",
|
|
77500
|
+
...devServer ? { inconclusive: true } : {},
|
|
77501
|
+
category: "network",
|
|
77502
|
+
page: pair.key,
|
|
77503
|
+
check: "analytics-beacon-parity",
|
|
77504
|
+
summary: `Tag manager (${containers.join(", ")}) carregou em prod mas não no candidato em ${pair.key}${dependents.length > 0 ? ` — leva junto: ${dependents.map((d) => d.label).join(", ")}` : " — nenhuma outra tag conhecida de prod ficou de fora"}`,
|
|
77505
|
+
details: `${[
|
|
77506
|
+
`Container: ${containers.join(", ")} (gtm.js ausente no candidato).`,
|
|
77507
|
+
dependents.length > 0 ? `Tags de prod ausentes no candidato, atribuídas ao container:
|
|
77508
|
+
${dependents.map((d) => ` - ${d.label}`).join(`
|
|
77509
|
+
`)}` : "",
|
|
77510
|
+
"Atribuição presumida, não observada: um snippet hard-coded em prod não se distingue de uma tag injetada pelo container. Corrija o ID do container no candidato e rode de novo antes de procurar cada tag.",
|
|
77511
|
+
devServer ? "cand é um dev server local, onde o rastreamento não é ligado de propósito: informativo. Reconfira num host de preview." : ""
|
|
77512
|
+
].filter(Boolean).join(`
|
|
77513
|
+
|
|
77514
|
+
`)}`,
|
|
77515
|
+
suggestedFix: "Configure o container ID do tag manager no candidato — sem ele, todo o rastreamento a jusante some junto."
|
|
77516
|
+
});
|
|
77517
|
+
}
|
|
77518
|
+
for (const pattern of BEACON_PATTERNS) {
|
|
77519
|
+
const inProd = prodHits.has(pattern.id);
|
|
77520
|
+
const inCand = candHits.has(pattern.id);
|
|
77521
|
+
if (containerAbsent && inProd && !inCand)
|
|
77522
|
+
continue;
|
|
77523
|
+
if (inProd && !inCand) {
|
|
77524
|
+
issues.push({
|
|
77525
|
+
id: `analytics-beacon:missing:${pattern.id}:${pair.key}`,
|
|
77526
|
+
severity: "high",
|
|
77527
|
+
category: "network",
|
|
77528
|
+
page: pair.key,
|
|
77529
|
+
check: "analytics-beacon-parity",
|
|
77530
|
+
summary: `${pattern.label} disparou em prod mas não no candidato em ${pair.key}`,
|
|
77531
|
+
suggestedFix: "Confirme o container/pixel ID no candidato — tag manager ausente derruba TODO o rastreamento a jusante dele, não só este evento."
|
|
77532
|
+
});
|
|
77533
|
+
}
|
|
77534
|
+
}
|
|
77535
|
+
}
|
|
77536
|
+
const hasHigh = issues.some((i) => i.severity === "high");
|
|
77537
|
+
return {
|
|
77538
|
+
name: "analytics-beacon-parity",
|
|
77539
|
+
status: hasHigh ? "fail" : issues.length > 0 ? "warn" : "pass",
|
|
77540
|
+
severity: "high",
|
|
77541
|
+
durationMs: Date.now() - start,
|
|
77542
|
+
summary: pairsWithAnyBeacon === 0 ? "Nenhum beacon de analytics conhecido observado em nenhum dos lados — nada a validar (ou o site usa uma ferramenta fora da lista de padrões)" : `${issues.length} achado(s) de analytics em ${pairsWithAnyBeacon} página(s) com tráfego de analytics`,
|
|
77543
|
+
issues
|
|
77544
|
+
};
|
|
77545
|
+
}
|
|
77546
|
+
function detectedBeacons(page) {
|
|
77547
|
+
const hits = new Set;
|
|
77548
|
+
for (const entry of page.network) {
|
|
77549
|
+
for (const pattern of BEACON_PATTERNS) {
|
|
77550
|
+
if (pattern.match(entry.url))
|
|
77551
|
+
hits.add(pattern.id);
|
|
77552
|
+
}
|
|
77553
|
+
}
|
|
77554
|
+
return hits;
|
|
77555
|
+
}
|
|
77556
|
+
function skip(start, summary) {
|
|
77557
|
+
return {
|
|
77558
|
+
name: "analytics-beacon-parity",
|
|
77559
|
+
status: "skipped",
|
|
77560
|
+
severity: "high",
|
|
77561
|
+
durationMs: Date.now() - start,
|
|
77562
|
+
summary,
|
|
77563
|
+
issues: []
|
|
77564
|
+
};
|
|
77565
|
+
}
|
|
77566
|
+
|
|
77403
77567
|
// src/checks/lib/counts.ts
|
|
77404
77568
|
function unitCounts(args) {
|
|
77405
77569
|
const judged = new Set(args.judged);
|
|
@@ -78255,64 +78419,6 @@ function diffConsole(prod, cand, opts = {}) {
|
|
|
78255
78419
|
};
|
|
78256
78420
|
}
|
|
78257
78421
|
|
|
78258
|
-
// src/checks/lib/staging.ts
|
|
78259
|
-
function isCandOnStagingHost(prodPages, candPages, candIsProduction = false) {
|
|
78260
|
-
if (candIsProduction)
|
|
78261
|
-
return false;
|
|
78262
|
-
const prodSite = siteHost(prodPages);
|
|
78263
|
-
const candSite = siteHost(candPages);
|
|
78264
|
-
if (!prodSite || !candSite || prodSite === candSite)
|
|
78265
|
-
return false;
|
|
78266
|
-
const { pairs } = pairCaptures(prodPages, candPages);
|
|
78267
|
-
const judged = pairs.filter((p) => bareHost(finalOf(p.prod)) === prodSite && bareHost(finalOf(p.cand)) === candSite && !isNoindex(p.prod) && hasHead(p.cand));
|
|
78268
|
-
if (judged.length === 0)
|
|
78269
|
-
return false;
|
|
78270
|
-
const noindexed = judged.filter((p) => isNoindex(p.cand)).length;
|
|
78271
|
-
return noindexed * 2 > judged.length;
|
|
78272
|
-
}
|
|
78273
|
-
var STAGING_NOTE = "cand está num host de staging (noindex no host inteiro, prod indexável) — esperado ali; reconfira depois da troca de domínio, ou rode com --cand-is-production se cand já é o domínio final.";
|
|
78274
|
-
function hasHead(page) {
|
|
78275
|
-
const { meta } = snapshotDom(page.html ?? "");
|
|
78276
|
-
return meta.title != null || meta.robots != null || Boolean(page.xRobotsTag);
|
|
78277
|
-
}
|
|
78278
|
-
function isNoindex(page) {
|
|
78279
|
-
const meta = snapshotDom(page.html ?? "").meta.robots ?? "";
|
|
78280
|
-
return /\bnoindex\b/i.test(meta) || /\bnoindex\b/i.test(page.xRobotsTag ?? "");
|
|
78281
|
-
}
|
|
78282
|
-
function finalOf(page) {
|
|
78283
|
-
return page.finalUrl || page.url;
|
|
78284
|
-
}
|
|
78285
|
-
function siteHost(pages) {
|
|
78286
|
-
const counts = new Map;
|
|
78287
|
-
for (const page of pages) {
|
|
78288
|
-
const host = bareHost(finalOf(page));
|
|
78289
|
-
if (host)
|
|
78290
|
-
counts.set(host, (counts.get(host) ?? 0) + 1);
|
|
78291
|
-
}
|
|
78292
|
-
let best = null;
|
|
78293
|
-
for (const [host, n] of counts)
|
|
78294
|
-
if (!best || n > (counts.get(best) ?? 0))
|
|
78295
|
-
best = host;
|
|
78296
|
-
return best;
|
|
78297
|
-
}
|
|
78298
|
-
function bareHost(url) {
|
|
78299
|
-
try {
|
|
78300
|
-
return new URL(url).hostname.replace(/^www\./, "");
|
|
78301
|
-
} catch {
|
|
78302
|
-
return null;
|
|
78303
|
-
}
|
|
78304
|
-
}
|
|
78305
|
-
var SECOND_LEVEL = new Set(["com", "net", "org", "gov", "edu", "co", "ac", "ne", "or", "go"]);
|
|
78306
|
-
function registrableDomain(hostname) {
|
|
78307
|
-
const parts = hostname.split(".");
|
|
78308
|
-
if (parts.length <= 2)
|
|
78309
|
-
return hostname;
|
|
78310
|
-
const sld = parts[parts.length - 2];
|
|
78311
|
-
const tld = parts[parts.length - 1];
|
|
78312
|
-
const take = tld.length === 2 && SECOND_LEVEL.has(sld) ? 3 : 2;
|
|
78313
|
-
return parts.slice(-take).join(".");
|
|
78314
|
-
}
|
|
78315
|
-
|
|
78316
78422
|
// src/checks/console-errors.ts
|
|
78317
78423
|
var BENIGN = [/\bTransition was (?:skipped|aborted)\b/i];
|
|
78318
78424
|
var DETERMINISTIC = new Set(["hydration", "section-crash"]);
|
|
@@ -79040,6 +79146,7 @@ function htmlStructuralDiff(ctx) {
|
|
|
79040
79146
|
const issues = [];
|
|
79041
79147
|
const staging = isCandOnStagingHost(ctx.prodPages, ctx.candPages, ctx.candIsProduction);
|
|
79042
79148
|
const vendorDeltas = [];
|
|
79149
|
+
const tagManagerDeltas = [];
|
|
79043
79150
|
for (const pair of pairs) {
|
|
79044
79151
|
const prodSnap = snapshotDom(pair.prod.html ?? "");
|
|
79045
79152
|
const candSnap = snapshotDom(pair.cand.html ?? "");
|
|
@@ -79061,6 +79168,31 @@ function htmlStructuralDiff(ctx) {
|
|
|
79061
79168
|
}
|
|
79062
79169
|
if (lines.length > 0)
|
|
79063
79170
|
vendorDeltas.push({ page: pair.key, lines });
|
|
79171
|
+
} else if (tagManagerAbsentOnCand(pair.prod, pair.cand)) {
|
|
79172
|
+
const vendors = tagManagerVendorOrigins(pair.prod);
|
|
79173
|
+
const site = new Set([pair.prod, pair.cand].map((p) => hostDomain(p.finalUrl || p.url)).filter(Boolean));
|
|
79174
|
+
const prod = embeds(pair.prod.html ?? "", "scripts", site);
|
|
79175
|
+
const cand = embeds(pair.cand.html ?? "", "scripts", site);
|
|
79176
|
+
const lines = [];
|
|
79177
|
+
let lost = 0;
|
|
79178
|
+
for (const [origin, n] of prod.vendor) {
|
|
79179
|
+
const gone = Math.max(0, n - (cand.vendor.get(origin) ?? 0));
|
|
79180
|
+
if (!vendors.has(origin) || gone === 0)
|
|
79181
|
+
continue;
|
|
79182
|
+
lost += gone;
|
|
79183
|
+
lines.push(`${origin} ×${n}→${cand.vendor.get(origin) ?? 0}`);
|
|
79184
|
+
}
|
|
79185
|
+
const tag = "scripts";
|
|
79186
|
+
const scripts = diff.countsDelta[tag];
|
|
79187
|
+
if (lost > 0 && scripts) {
|
|
79188
|
+
const delta = scripts.delta + lost;
|
|
79189
|
+
if (Math.abs(delta) > COUNT_TOLERANCE) {
|
|
79190
|
+
diff.countsDelta[tag] = { prod: scripts.prod - lost, cand: scripts.cand, delta };
|
|
79191
|
+
} else {
|
|
79192
|
+
delete diff.countsDelta[tag];
|
|
79193
|
+
}
|
|
79194
|
+
tagManagerDeltas.push({ page: pair.key, lines });
|
|
79195
|
+
}
|
|
79064
79196
|
}
|
|
79065
79197
|
const NOISY = new Set(["imgs"]);
|
|
79066
79198
|
const structural = Object.entries(diff.countsDelta).filter(([k]) => !NOISY.has(k));
|
|
@@ -79126,6 +79258,23 @@ function htmlStructuralDiff(ctx) {
|
|
|
79126
79258
|
${STAGING_NOTE}`
|
|
79127
79259
|
});
|
|
79128
79260
|
}
|
|
79261
|
+
if (tagManagerDeltas.length > 0) {
|
|
79262
|
+
issues.push({
|
|
79263
|
+
id: "html-structural:tag-manager-scripts",
|
|
79264
|
+
severity: "low",
|
|
79265
|
+
inconclusive: true,
|
|
79266
|
+
category: "functional",
|
|
79267
|
+
page: tagManagerDeltas[0].page,
|
|
79268
|
+
check: "html-structural-diff",
|
|
79269
|
+
summary: `Scripts de vendors do tag manager ausentes em ${tagManagerDeltas.length} página(s) — descontados da contagem (tag manager ausente no candidato)`,
|
|
79270
|
+
details: `${tagManagerDeltas.map((v) => `${v.page}
|
|
79271
|
+
${v.lines.join(`
|
|
79272
|
+
`)}`).join(`
|
|
79273
|
+
`)}
|
|
79274
|
+
|
|
79275
|
+
Mesma causa de analytics-beacon:tag-manager-absent: o container não carregou no candidato, então as tags que ele injetaria não existem. Scripts inline escritos pelo container não são atribuídos e continuam na contagem.`
|
|
79276
|
+
});
|
|
79277
|
+
}
|
|
79129
79278
|
const hasBlocking = issues.some((i) => i.severity === "high" && !i.inconclusive);
|
|
79130
79279
|
return {
|
|
79131
79280
|
name: "html-structural-diff",
|
|
@@ -82934,19 +83083,6 @@ function hydrationDuringNavIssue(viewport, side, count, step) {
|
|
|
82934
83083
|
|
|
82935
83084
|
// src/checks/ssr-no-js.ts
|
|
82936
83085
|
init_esm10();
|
|
82937
|
-
|
|
82938
|
-
// src/util/localhost.ts
|
|
82939
|
-
var LOCALHOST_HOSTS = new Set(["localhost", "127.0.0.1", "0.0.0.0", "::1", "[::1]"]);
|
|
82940
|
-
function isLocalhost(rawUrl) {
|
|
82941
|
-
try {
|
|
82942
|
-
const url = new URL(rawUrl);
|
|
82943
|
-
return LOCALHOST_HOSTS.has(url.hostname);
|
|
82944
|
-
} catch {
|
|
82945
|
-
return false;
|
|
82946
|
-
}
|
|
82947
|
-
}
|
|
82948
|
-
|
|
82949
|
-
// src/checks/ssr-no-js.ts
|
|
82950
83086
|
async function ssrNoJs(ctx) {
|
|
82951
83087
|
const start = Date.now();
|
|
82952
83088
|
const issues = [];
|
|
@@ -85818,19 +85954,30 @@ function thirdPartyScriptsParity(ctx) {
|
|
|
85818
85954
|
const missing = [...prodOrigins].filter((o) => !candOrigins.has(o)).sort();
|
|
85819
85955
|
const added = [...candOrigins].filter((o) => !prodOrigins.has(o)).sort();
|
|
85820
85956
|
if (missing.length > 0) {
|
|
85957
|
+
const viaTagManager = tagManagerAbsentOnCand(pair.prod, pair.cand) ? tagManagerVendorOrigins(pair.prod) : new Set;
|
|
85958
|
+
const explained = missing.filter((o) => viaTagManager.has(o));
|
|
85959
|
+
const unexplained = missing.filter((o) => !viaTagManager.has(o));
|
|
85960
|
+
const lenient = staging || unexplained.length === 0;
|
|
85961
|
+
const body = [
|
|
85962
|
+
unexplained.join(`
|
|
85963
|
+
`),
|
|
85964
|
+
explained.length > 0 ? `Explicadas pela ausência do tag manager no candidato (ver analytics-beacon:tag-manager-absent:${pair.key}), não contam como severidade alta:
|
|
85965
|
+
${explained.join(`
|
|
85966
|
+
`)}` : ""
|
|
85967
|
+
].filter(Boolean).join(`
|
|
85968
|
+
|
|
85969
|
+
`);
|
|
85821
85970
|
issues.push({
|
|
85822
85971
|
id: `3p-scripts:missing:${pair.key}`,
|
|
85823
|
-
severity:
|
|
85824
|
-
...
|
|
85972
|
+
severity: lenient ? "low" : "high",
|
|
85973
|
+
...lenient ? { inconclusive: true } : {},
|
|
85825
85974
|
category: "network",
|
|
85826
85975
|
page: pair.key,
|
|
85827
85976
|
check: "third-party-scripts-parity",
|
|
85828
|
-
summary: `${missing.length} origem(ns) de terceiro presente(s) em prod mas ausente(s) no candidato em ${pair.key}`,
|
|
85829
|
-
details: staging ? `${
|
|
85830
|
-
`)}
|
|
85977
|
+
summary: `${missing.length} origem(ns) de terceiro presente(s) em prod mas ausente(s) no candidato em ${pair.key}${explained.length > 0 ? ` (${explained.length} explicada(s) pelo tag manager ausente)` : ""}`,
|
|
85978
|
+
details: staging ? `${body}
|
|
85831
85979
|
|
|
85832
|
-
${STAGING_NOTE}` :
|
|
85833
|
-
`),
|
|
85980
|
+
${STAGING_NOTE}` : body,
|
|
85834
85981
|
suggestedFix: "Confirme se o script foi migrado deliberadamente ou se a tag (GTM, pixel, chat, avaliações, etc.) foi perdida na porta."
|
|
85835
85982
|
});
|
|
85836
85983
|
}
|
|
@@ -118470,7 +118617,7 @@ function detectRunCaveats(input) {
|
|
|
118470
118617
|
id: "cand-staging-host",
|
|
118471
118618
|
level: "warn",
|
|
118472
118619
|
summary: "Candidato num host de staging — noindex e terceiros não julgados",
|
|
118473
|
-
detail: "cand está noutro host e marca noindex em todas as páginas que prod indexa
|
|
118620
|
+
detail: "cand está noutro host e marca noindex em todas as páginas que prod indexa (é o comportamento de um host de staging: deco marca noindex fora do domínio de produção), ou é um dev server local, onde rastreamento e vendors não são ligados. noindex/nofollow, terceiros ausentes e requests a terceiros que falham só em cand ficaram inconclusivos. Reconfira depois da troca de domínio, ou rode com --cand-is-production se cand já é o domínio final."
|
|
118474
118621
|
});
|
|
118475
118622
|
}
|
|
118476
118623
|
for (const side of ["prod", "cand"]) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@decocms/parity",
|
|
3
|
-
"version": "0.35.
|
|
3
|
+
"version": "0.35.28",
|
|
4
4
|
"description": "E2E parity validator for site migrations. Compares prod vs cand and reports UI, functional, SEO, visual, and Web Vitals deltas with a ranked HTML report.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|