seo-supervisor 1.2.0 → 2.0.0
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/.claude-plugin/icon.png +0 -0
- package/.claude-plugin/marketplace.json +2 -2
- package/.claude-plugin/plugin.json +16 -3
- package/CHANGELOG.md +430 -0
- package/NOTICE +7 -0
- package/README.md +230 -25
- package/agents/seo-auditor.md +16 -0
- package/agents/seo-reviewer.md +16 -0
- package/bin/agents.mjs +194 -29
- package/bin/extras.mjs +422 -0
- package/bin/prompt.mjs +34 -14
- package/bin/seo-supervisor.mjs +386 -53
- package/commands/seo-audit.md +29 -3
- package/commands/seo-brief.md +28 -0
- package/commands/seo-connect.md +27 -0
- package/commands/seo-fix.md +24 -3
- package/commands/seo-grow.md +26 -0
- package/commands/seo-launch.md +17 -3
- package/commands/seo-review.md +13 -1
- package/commands/seo-rewrite.md +25 -0
- package/commands/seo-setup.md +17 -1
- package/commands/seo-watch.md +28 -0
- package/hooks/hooks.json +117 -0
- package/package.json +20 -7
- package/skills/seo-supervisor/NOTICE +7 -0
- package/skills/seo-supervisor/SKILL.md +302 -21
- package/skills/seo-supervisor/audience.md +61 -0
- package/skills/seo-supervisor/examples/drafts/security.md +41 -0
- package/skills/seo-supervisor/examples/hooks/README.md +28 -0
- package/skills/seo-supervisor/examples/hooks/claude-code-settings.json +15 -0
- package/skills/seo-supervisor/examples/hooks/codex-hooks.json +17 -0
- package/skills/seo-supervisor/examples/hooks/copilot-hooks.json +15 -0
- package/skills/seo-supervisor/examples/hooks/cursor-hooks.json +11 -0
- package/skills/seo-supervisor/examples/hooks/github-actions.yml +21 -0
- package/skills/seo-supervisor/examples/hooks/pre-commit +17 -0
- package/skills/seo-supervisor/examples/hooks/reading-ease.yml +24 -0
- package/skills/seo-supervisor/examples/sample-audit.json +94 -2
- package/skills/seo-supervisor/examples/sample-report.html +111 -61
- package/skills/seo-supervisor/examples/sample-report.md +147 -44
- package/skills/seo-supervisor/examples/scheduled-runs.md +89 -0
- package/skills/seo-supervisor/examples/snippets.md +648 -1
- package/skills/seo-supervisor/grow.md +342 -0
- package/skills/seo-supervisor/og-images.md +85 -0
- package/skills/seo-supervisor/page-types.md +124 -0
- package/skills/seo-supervisor/planning.md +19 -7
- package/skills/seo-supervisor/profile-template.md +41 -0
- package/skills/seo-supervisor/report-format.md +177 -10
- package/skills/seo-supervisor/rewrite.md +59 -0
- package/skills/seo-supervisor/rules/ai-search.md +65 -12
- package/skills/seo-supervisor/rules/content.md +33 -9
- package/skills/seo-supervisor/rules/crawl-index.md +33 -6
- package/skills/seo-supervisor/rules/internal-linking.md +49 -6
- package/skills/seo-supervisor/rules/launch-monitoring.md +17 -8
- package/skills/seo-supervisor/rules/media.md +13 -1
- package/skills/seo-supervisor/rules/metadata.md +41 -9
- package/skills/seo-supervisor/rules/performance.md +50 -5
- package/skills/seo-supervisor/rules/rendering.md +39 -2
- package/skills/seo-supervisor/rules/search-intent.md +32 -0
- package/skills/seo-supervisor/rules/sitemaps-robots.md +24 -12
- package/skills/seo-supervisor/rules/structured-data.md +37 -14
- package/skills/seo-supervisor/rules/trust-security.md +25 -2
- package/skills/seo-supervisor/rules/urls.md +10 -2
- package/skills/seo-supervisor/scripts/ai-answers.mjs +314 -0
- package/skills/seo-supervisor/scripts/backlinks.mjs +412 -0
- package/skills/seo-supervisor/scripts/change-check.mjs +281 -0
- package/skills/seo-supervisor/scripts/checks/agents.mjs +488 -0
- package/skills/seo-supervisor/scripts/checks/assets.mjs +404 -0
- package/skills/seo-supervisor/scripts/checks/bots.mjs +146 -0
- package/skills/seo-supervisor/scripts/checks/business-type.mjs +193 -0
- package/skills/seo-supervisor/scripts/checks/content.mjs +391 -0
- package/skills/seo-supervisor/scripts/checks/coverage.mjs +184 -0
- package/skills/seo-supervisor/scripts/checks/crawl.mjs +95 -0
- package/skills/seo-supervisor/scripts/checks/hreflang.mjs +396 -0
- package/skills/seo-supervisor/scripts/checks/hygiene.mjs +227 -0
- package/skills/seo-supervisor/scripts/checks/lighthouse.mjs +271 -0
- package/skills/seo-supervisor/scripts/checks/link-strength.mjs +59 -0
- package/skills/seo-supervisor/scripts/checks/links.mjs +360 -0
- package/skills/seo-supervisor/scripts/checks/local.mjs +101 -0
- package/skills/seo-supervisor/scripts/checks/media.mjs +194 -0
- package/skills/seo-supervisor/scripts/checks/outbound.mjs +53 -0
- package/skills/seo-supervisor/scripts/checks/page.mjs +223 -0
- package/skills/seo-supervisor/scripts/checks/probes.mjs +130 -0
- package/skills/seo-supervisor/scripts/checks/render.mjs +552 -0
- package/skills/seo-supervisor/scripts/checks/robots.mjs +144 -0
- package/skills/seo-supervisor/scripts/checks/schema.mjs +206 -0
- package/skills/seo-supervisor/scripts/checks/site-agents.mjs +79 -0
- package/skills/seo-supervisor/scripts/checks/site-content.mjs +135 -0
- package/skills/seo-supervisor/scripts/checks/site-hygiene.mjs +202 -0
- package/skills/seo-supervisor/scripts/checks/site-pages.mjs +474 -0
- package/skills/seo-supervisor/scripts/checks/site-security.mjs +102 -0
- package/skills/seo-supervisor/scripts/checks/sitemap.mjs +473 -0
- package/skills/seo-supervisor/scripts/checks/speed.mjs +267 -0
- package/skills/seo-supervisor/scripts/checks/technical.mjs +368 -0
- package/skills/seo-supervisor/scripts/checks/tls.mjs +297 -0
- package/skills/seo-supervisor/scripts/checks/trust.mjs +421 -0
- package/skills/seo-supervisor/scripts/checks/visual.mjs +1132 -0
- package/skills/seo-supervisor/scripts/checks/writing.mjs +192 -0
- package/skills/seo-supervisor/scripts/commoncrawl.mjs +452 -0
- package/skills/seo-supervisor/scripts/connect-keys.mjs +422 -0
- package/skills/seo-supervisor/scripts/content-scan.mjs +515 -158
- package/skills/seo-supervisor/scripts/crawl/catalog.mjs +1248 -0
- package/skills/seo-supervisor/scripts/crawl/fetch.mjs +362 -0
- package/skills/seo-supervisor/scripts/crawl/page.mjs +741 -0
- package/skills/seo-supervisor/scripts/crawl/queue.mjs +190 -0
- package/skills/seo-supervisor/scripts/dashboard.mjs +140 -0
- package/skills/seo-supervisor/scripts/data/ai-bots.json +38 -0
- package/skills/seo-supervisor/scripts/data/build-schema-vocab.mjs +57 -0
- package/skills/seo-supervisor/scripts/data/business-types.json +338 -0
- package/skills/seo-supervisor/scripts/data/google-rich-results.json +79 -0
- package/skills/seo-supervisor/scripts/data/schema-vocab.json +1 -0
- package/skills/seo-supervisor/scripts/deploy-check.mjs +462 -0
- package/skills/seo-supervisor/scripts/disavow.mjs +176 -0
- package/skills/seo-supervisor/scripts/doctor.mjs +174 -0
- package/skills/seo-supervisor/scripts/geo-grid.mjs +371 -0
- package/skills/seo-supervisor/scripts/google/search-console.mjs +151 -0
- package/skills/seo-supervisor/scripts/google/session.mjs +167 -0
- package/skills/seo-supervisor/scripts/google-updates.mjs +189 -0
- package/skills/seo-supervisor/scripts/google.mjs +1341 -0
- package/skills/seo-supervisor/scripts/gsc-import.mjs +298 -0
- package/skills/seo-supervisor/scripts/guard/adapters/claude-code.mjs +149 -0
- package/skills/seo-supervisor/scripts/guard/adapters/cline.mjs +28 -0
- package/skills/seo-supervisor/scripts/guard/adapters/codex.mjs +26 -0
- package/skills/seo-supervisor/scripts/guard/adapters/copilot.mjs +36 -0
- package/skills/seo-supervisor/scripts/guard/adapters/cursor.mjs +33 -0
- package/skills/seo-supervisor/scripts/guard/adapters/devin.mjs +25 -0
- package/skills/seo-supervisor/scripts/guard/adapters/edits.mjs +124 -0
- package/skills/seo-supervisor/scripts/guard/mode.mjs +37 -0
- package/skills/seo-supervisor/scripts/guard/rules.mjs +931 -0
- package/skills/seo-supervisor/scripts/guard.mjs +74 -0
- package/skills/seo-supervisor/scripts/images.mjs +408 -0
- package/skills/seo-supervisor/scripts/indexnow.mjs +300 -0
- package/skills/seo-supervisor/scripts/issues.mjs +217 -0
- package/skills/seo-supervisor/scripts/keys/authority.mjs +135 -0
- package/skills/seo-supervisor/scripts/keys/bing.mjs +239 -0
- package/skills/seo-supervisor/scripts/keys/clarity.mjs +137 -0
- package/skills/seo-supervisor/scripts/keys/dataforseo.mjs +57 -0
- package/skills/seo-supervisor/scripts/keys/googleplaces.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/http.mjs +212 -0
- package/skills/seo-supervisor/scripts/keys/matomo.mjs +138 -0
- package/skills/seo-supervisor/scripts/keys/openai.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/perplexity.mjs +26 -0
- package/skills/seo-supervisor/scripts/keys/posthog.mjs +165 -0
- package/skills/seo-supervisor/scripts/keys/semrush.mjs +25 -0
- package/skills/seo-supervisor/scripts/keys/services.mjs +41 -0
- package/skills/seo-supervisor/scripts/keys/store.mjs +140 -0
- package/skills/seo-supervisor/scripts/keys/visits.mjs +58 -0
- package/skills/seo-supervisor/scripts/keys/youtube.mjs +84 -0
- package/skills/seo-supervisor/scripts/keyword-data.mjs +316 -0
- package/skills/seo-supervisor/scripts/keyword-ideas.mjs +503 -0
- package/skills/seo-supervisor/scripts/lib/args.mjs +56 -0
- package/skills/seo-supervisor/scripts/lib/business.mjs +27 -0
- package/skills/seo-supervisor/scripts/lib/cdp.mjs +242 -0
- package/skills/seo-supervisor/scripts/lib/cli.mjs +56 -0
- package/skills/seo-supervisor/scripts/lib/csv.mjs +38 -0
- package/skills/seo-supervisor/scripts/lib/findings.mjs +100 -0
- package/skills/seo-supervisor/scripts/lib/google-client.mjs +9 -0
- package/skills/seo-supervisor/scripts/lib/html.mjs +146 -0
- package/skills/seo-supervisor/scripts/lib/http.mjs +28 -0
- package/skills/seo-supervisor/scripts/lib/image-size.mjs +78 -0
- package/skills/seo-supervisor/scripts/lib/is-main.mjs +13 -0
- package/skills/seo-supervisor/scripts/lib/net.mjs +116 -0
- package/skills/seo-supervisor/scripts/lib/proxy.mjs +47 -0
- package/skills/seo-supervisor/scripts/lib/recheck.mjs +106 -0
- package/skills/seo-supervisor/scripts/lib/redact.mjs +78 -0
- package/skills/seo-supervisor/scripts/lib/robots.mjs +73 -0
- package/skills/seo-supervisor/scripts/lib/score.mjs +266 -0
- package/skills/seo-supervisor/scripts/lib/settings-dir.mjs +81 -0
- package/skills/seo-supervisor/scripts/links-import.mjs +603 -0
- package/skills/seo-supervisor/scripts/log-scan.mjs +597 -0
- package/skills/seo-supervisor/scripts/og-card.mjs +273 -0
- package/skills/seo-supervisor/scripts/osm.mjs +359 -0
- package/skills/seo-supervisor/scripts/rdap.mjs +164 -0
- package/skills/seo-supervisor/scripts/render-report.mjs +324 -690
- package/skills/seo-supervisor/scripts/report/client.js +37 -0
- package/skills/seo-supervisor/scripts/report/diff.mjs +264 -0
- package/skills/seo-supervisor/scripts/report/findings.mjs +165 -0
- package/skills/seo-supervisor/scripts/report/format.mjs +111 -0
- package/skills/seo-supervisor/scripts/report/markdown.mjs +250 -0
- package/skills/seo-supervisor/scripts/report/model.mjs +171 -0
- package/skills/seo-supervisor/scripts/report/overview-lines.mjs +158 -0
- package/skills/seo-supervisor/scripts/report/overview.mjs +224 -0
- package/skills/seo-supervisor/scripts/report/page.mjs +127 -0
- package/skills/seo-supervisor/scripts/report/panel.mjs +172 -0
- package/skills/seo-supervisor/scripts/report/panels/ai.mjs +211 -0
- package/skills/seo-supervisor/scripts/report/panels/connections.mjs +139 -0
- package/skills/seo-supervisor/scripts/report/panels/content.mjs +204 -0
- package/skills/seo-supervisor/scripts/report/panels/data-search.mjs +379 -0
- package/skills/seo-supervisor/scripts/report/panels/data-site.mjs +44 -0
- package/skills/seo-supervisor/scripts/report/panels/links.mjs +380 -0
- package/skills/seo-supervisor/scripts/report/panels/local.mjs +221 -0
- package/skills/seo-supervisor/scripts/report/panels/site.mjs +359 -0
- package/skills/seo-supervisor/scripts/report/panels/speed-media.mjs +267 -0
- package/skills/seo-supervisor/scripts/report/sources.mjs +163 -0
- package/skills/seo-supervisor/scripts/report/styles.css +223 -0
- package/skills/seo-supervisor/scripts/report/traffic.mjs +264 -0
- package/skills/seo-supervisor/scripts/report-plan.mjs +112 -33
- package/skills/seo-supervisor/scripts/schema-check.mjs +717 -0
- package/skills/seo-supervisor/scripts/seo-crawl.mjs +1086 -638
- package/skills/seo-supervisor/scripts/seo-diff.mjs +584 -0
- package/skills/seo-supervisor/scripts/update-check.mjs +82 -0
- package/skills/seo-supervisor/site-types/content.md +34 -1
- package/skills/seo-supervisor/site-types/ecommerce.md +38 -1
- package/skills/seo-supervisor/site-types/local-business.md +96 -6
- package/skills/seo-supervisor/site-types/services.md +46 -0
- package/skills/seo-supervisor/site-types/tools.md +3 -3
- package/skills/seo-supervisor/strategy.md +232 -0
- package/skills/seo-supervisor/troubleshooting.md +56 -0
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Fills data the audit JSON lacks from the result files the tools write beside it, so no panel depends on the audit
|
|
3
|
+
// copying them. Findings, passed rules, notChecked and notes are never read from here, so no file changes the score.
|
|
4
|
+
// - The audit wins: a group (the fields one panel reads) comes from the audit if it has any of them, never mixed.
|
|
5
|
+
// - A file for another site, or over 30 days older than the crawl, is skipped with a note.
|
|
6
|
+
// - An unreadable file gets a note; a missing one stays quiet, as the tool wasn't run.
|
|
7
|
+
import { readFileSync, statSync } from "node:fs";
|
|
8
|
+
import { join } from "node:path";
|
|
9
|
+
import { isPublic } from "../lib/net.mjs";
|
|
10
|
+
import { fmtDate, obj } from "./format.mjs";
|
|
11
|
+
|
|
12
|
+
const STALE_DAYS = 30; // local threshold
|
|
13
|
+
// [file, what it is, groups]. A group lists the audit fields one panel reads; "to=from" is the file's `from` field read
|
|
14
|
+
// as the audit's `to`, and "to=*" the whole file.
|
|
15
|
+
const SOURCES = /** @type {[string, string, string[][]][]} */ ([
|
|
16
|
+
[
|
|
17
|
+
"seo-crawl.json",
|
|
18
|
+
"the crawl",
|
|
19
|
+
[
|
|
20
|
+
["speed", "labSpeed", "lighthouse", "media", "images"],
|
|
21
|
+
["trustSignals"],
|
|
22
|
+
["agents", "aiBots", "trainingOptOut", "contentUsage", "botPreferenceSync", "aiBotPaid", "landmarks"],
|
|
23
|
+
["writingNotes"],
|
|
24
|
+
["hstsPreload"],
|
|
25
|
+
["sections", "siteSize", "indexing"],
|
|
26
|
+
["templatedDescriptions", "keywordUse"],
|
|
27
|
+
["productFields"],
|
|
28
|
+
["renderSample", "renderedPage"],
|
|
29
|
+
["localBusiness"],
|
|
30
|
+
["linkedOnce", "linkStrength"],
|
|
31
|
+
["linksToOtherSites"],
|
|
32
|
+
["appLinks", "pdfLinks"],
|
|
33
|
+
["pages"],
|
|
34
|
+
],
|
|
35
|
+
],
|
|
36
|
+
["seo-diff.json", "the history check", [["diff=*"]]],
|
|
37
|
+
[
|
|
38
|
+
"google.json",
|
|
39
|
+
"Google Search Console",
|
|
40
|
+
[
|
|
41
|
+
["traffic", "trafficPeriod=period", "analytics"],
|
|
42
|
+
["trafficChange", "searchTypes", "byDevice", "byCountry", "anomalies", "positions"],
|
|
43
|
+
["queries"],
|
|
44
|
+
["brandSplit"],
|
|
45
|
+
["inspection"],
|
|
46
|
+
["siteTotals", "analyticsDetail"],
|
|
47
|
+
["newQueries"],
|
|
48
|
+
],
|
|
49
|
+
],
|
|
50
|
+
[
|
|
51
|
+
"keys.json",
|
|
52
|
+
"your connected services",
|
|
53
|
+
[["bing"], ["authority", "attribution"], ["moz"], ["youtube"], ["matomo"], ["posthog"], ["clarity"]],
|
|
54
|
+
],
|
|
55
|
+
["log-scan.json", "your server logs", [["logScan=*"]]],
|
|
56
|
+
["keyword-ideas.json", "keyword ideas", [["keywordIdeas=*"], ["linkIdeas"], ["queryGaps"]]],
|
|
57
|
+
["keyword-data.json", "keyword data", [["keywordData=*"]]],
|
|
58
|
+
["geo-grid.json", "the local rank grid", [["geoGrid=*"]]],
|
|
59
|
+
["ai-answers.json", "the AI answer check", [["aiAnswers=*"]]],
|
|
60
|
+
["change-check.json", "the change check", [["changeCheck=*"]]],
|
|
61
|
+
]);
|
|
62
|
+
|
|
63
|
+
// Where a file-supplied field came from. json is the whole file, for a panel that needs a companion field from it.
|
|
64
|
+
const FROM = Symbol("result files");
|
|
65
|
+
/** @param {any} raw @param {string} field */
|
|
66
|
+
export const fromFile = (raw, field) => raw?.[FROM]?.[field] ?? null;
|
|
67
|
+
/**
|
|
68
|
+
* `field` from wherever `of` came from: that file's `key`, else the audit's own `field`. A file's value never sits
|
|
69
|
+
* beside the audit's own data (google.json's traffic period beside the audit's searches, say).
|
|
70
|
+
* @param {any} raw @param {string} of @param {string} field
|
|
71
|
+
* @param {string} [key] the field's name in the file
|
|
72
|
+
*/
|
|
73
|
+
export const sameSource = (raw, of, field, key = field) => {
|
|
74
|
+
const f = fromFile(raw, of);
|
|
75
|
+
return f ? f.json[key] : fromFile(raw, field) ? undefined : raw[field];
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* The Search Console period from the same source as `of` (google.json names it `period`).
|
|
79
|
+
* @param {any} raw @param {string} of
|
|
80
|
+
*/
|
|
81
|
+
export const periodOf = (raw, of) => sameSource(raw, of, "trafficPeriod", "period");
|
|
82
|
+
/** "From your server logs (log-scan.json, 12 Nov 2026)." when a file supplied the field, else "". An undated file
|
|
83
|
+
* says "file saved 12 Nov 2026" instead. @param {any} raw @param {string} field */
|
|
84
|
+
export const fromLine = (raw, field) => {
|
|
85
|
+
const f = fromFile(raw, field);
|
|
86
|
+
return f ? `From ${f.what} (${f.file}, ${f.saved ? "file saved " : ""}${fmtDate(f.date)}).` : "";
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// The site a URL names, www or not; null for a local or missing address, which can't be compared.
|
|
90
|
+
const hostOf = u =>
|
|
91
|
+
typeof u === "string" && isPublic(u) ? new URL(u).hostname.toLowerCase().replace(/^www\./, "") : null;
|
|
92
|
+
// log-scan.json falls back to the first address in its findings. Files that name no site are taken as this folder's;
|
|
93
|
+
// give them a `site` field if folders get shared between sites.
|
|
94
|
+
const siteOf = j => (typeof j.site === "string" ? j.site : (j.siteOrigin ?? j.findings?.[0]?.evidence?.[0]?.url));
|
|
95
|
+
const isDate = d => typeof d === "string" && !isNaN(Date.parse(d));
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* notShown has a note for each file that had data but couldn't be used. Raw tool output (a crawl or content scan
|
|
99
|
+
* rendered on its own) is returned as it is.
|
|
100
|
+
* @param {any} raw the audit JSON
|
|
101
|
+
* @param {string} dir the audit file's folder
|
|
102
|
+
* @returns {{ raw: any, notShown: { what: string, why: string }[] }}
|
|
103
|
+
*/
|
|
104
|
+
export function loadSources(raw, dir) {
|
|
105
|
+
if (raw.tool) return { raw, notShown: [] };
|
|
106
|
+
const out = { ...raw },
|
|
107
|
+
from = {},
|
|
108
|
+
notShown = [];
|
|
109
|
+
const site = hostOf(raw.site?.url ?? raw.siteOrigin),
|
|
110
|
+
crawled = isDate(raw.run?.date) ? raw.run.date : null;
|
|
111
|
+
for (const [file, what, groups] of SOURCES) {
|
|
112
|
+
// Only the groups the audit has none of; a file that would add nothing isn't read.
|
|
113
|
+
const want = groups.map(g => g.map(f => f.split("="))).filter(g => g.every(([to]) => raw[to] === undefined));
|
|
114
|
+
if (!want.length) continue;
|
|
115
|
+
const path = join(dir, file),
|
|
116
|
+
note = why => notShown.push({ what: `${what[0].toUpperCase()}${what.slice(1)} (${file})`, why });
|
|
117
|
+
let j, mtime;
|
|
118
|
+
try {
|
|
119
|
+
mtime = statSync(path).mtime;
|
|
120
|
+
j = JSON.parse(readFileSync(path, "utf8"));
|
|
121
|
+
} catch (e) {
|
|
122
|
+
if (e.code !== "ENOENT")
|
|
123
|
+
note(
|
|
124
|
+
`It couldn't be read (${e.code === "EISDIR" ? "it's a folder" : e.code || "it isn't valid JSON"}), so its data isn't shown. Run the tool again to rewrite it.`,
|
|
125
|
+
);
|
|
126
|
+
continue;
|
|
127
|
+
}
|
|
128
|
+
if (!obj(j) || Array.isArray(j)) {
|
|
129
|
+
note(
|
|
130
|
+
"It couldn't be read (it isn't one JSON object), so its data isn't shown. Run the tool again to rewrite it.",
|
|
131
|
+
);
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
// A file with nothing for the missing groups loses nothing, so it needs no note either.
|
|
135
|
+
if (!want.some(g => g.some(([to, key = to]) => key === "*" || j[key] != null))) continue;
|
|
136
|
+
const theirs = hostOf(siteOf(j));
|
|
137
|
+
if (site && theirs && site !== theirs) {
|
|
138
|
+
note(
|
|
139
|
+
`It's for ${new URL(siteOf(j)).hostname}, and this audit is for ${new URL(raw.site?.url ?? raw.siteOrigin).hostname}, so its data isn't shown.`,
|
|
140
|
+
);
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
// An undated file is dated by when it was saved, and fromLine says so.
|
|
144
|
+
const own = [j.crawledAt, j.when, j.date].find(isDate),
|
|
145
|
+
date = own ?? mtime.toISOString(),
|
|
146
|
+
saved = !own;
|
|
147
|
+
if (crawled && Date.parse(crawled) - Date.parse(date) > STALE_DAYS * 864e5) {
|
|
148
|
+
note(
|
|
149
|
+
`${saved ? `The file was saved on ${fmtDate(date)} (it has no date of its own)` : `It's from ${fmtDate(date)}`}, more than ${STALE_DAYS} days before this audit's crawl (${fmtDate(crawled)}; our own line), so it's out of date and isn't shown. Run the tool again.`,
|
|
150
|
+
);
|
|
151
|
+
continue;
|
|
152
|
+
}
|
|
153
|
+
for (const g of want)
|
|
154
|
+
for (const [to, key = to] of g) {
|
|
155
|
+
const v = key === "*" ? j : j[key];
|
|
156
|
+
if (v !== undefined) {
|
|
157
|
+
out[to] = v;
|
|
158
|
+
from[to] = { file, what, date, saved, json: j };
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
}
|
|
162
|
+
return { raw: Object.assign(out, { [FROM]: { ...raw[FROM], ...from } }), notShown };
|
|
163
|
+
}
|
|
@@ -0,0 +1,223 @@
|
|
|
1
|
+
:root{--bg:#f4f6f9;--panel:#fff;--ink:#1c2a39;--ink2:#3a4757;--mute:#5d6878;--line:#e2e6ec;--line2:#cfd6df;--blue:#2459c9;--blue-soft:#e9effc;--sel:#cfe0ff;
|
|
2
|
+
--b1:#d64040;--b2:#e9772e;--b3:#e3a21a;--b4:#6fb35a;--b5:#238a52;
|
|
3
|
+
--blocker:#c93636;--high:#e0702b;--decision:#7b52c7;--medium:#d99a12;--low:#7d8a9c;--pass:#238a52;--fixed:#238a52;
|
|
4
|
+
--ok-soft:#e6f4ec;--warn-soft:#fdf3dc;--dec-soft:#f0eafb;
|
|
5
|
+
--b1-ink:#c03030;--b2-ink:#b5541a;--b5-ink:#1d7444;--chip-ink:#fff;
|
|
6
|
+
--display:"Bricolage Grotesque","Geist",system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;--sans:"Geist",system-ui,-apple-system,"Segoe UI",Roboto,Arial,sans-serif;--mono:"Geist Mono",ui-monospace,"SFMono-Regular",Menlo,Consolas,monospace;
|
|
7
|
+
--r:10px;--shadow:none;--neutral:#8a95a5;color-scheme:light}
|
|
8
|
+
@media screen{:root:not([data-theme="light"]){--bg:#0e131a;--panel:#151c26;--ink:#e6ebf2;--ink2:#c3ccd8;--mute:#98a3b3;--line:#232c39;--line2:#323d4d;--blue:#7ea2ff;--blue-soft:#1b2640;--sel:#2a3d66;
|
|
9
|
+
--b1:#ef6464;--b2:#f38b4a;--b3:#efb93b;--b4:#86c873;--b5:#45b97a;--blocker:#ef6464;--high:#f38b4a;--decision:#a587ec;--medium:#efb93b;--low:#8c99ab;--pass:#45b97a;--fixed:#45b97a;
|
|
10
|
+
--ok-soft:#14291e;--warn-soft:#2c2412;--dec-soft:#231c38;--neutral:#6b7788;--b1-ink:#ef6464;--b2-ink:#f38b4a;--b5-ink:#45b97a;--chip-ink:#0e131a;--shadow:0 1px 2px rgba(0,0,0,.3),0 6px 18px rgba(0,0,0,.25);color-scheme:dark}}
|
|
11
|
+
*{box-sizing:border-box}
|
|
12
|
+
html{scrollbar-color:var(--line2) transparent;-webkit-text-size-adjust:100%}
|
|
13
|
+
body{margin:0;background:var(--bg);color:var(--ink);font:15px/1.55 var(--sans);font-variant-numeric:tabular-nums;caret-color:var(--blue)}
|
|
14
|
+
::selection{background:var(--sel)}
|
|
15
|
+
a{color:var(--blue);text-underline-offset:3px;text-decoration-thickness:1px}
|
|
16
|
+
:focus-visible{outline:2px solid var(--blue);outline-offset:2px;border-radius:6px}
|
|
17
|
+
h1,h2,h3,h4{margin:0;text-wrap:balance;font-weight:600}
|
|
18
|
+
p{margin:0}
|
|
19
|
+
code{font:.86em/1.4 var(--mono);background:var(--bg);border:1px solid var(--line);padding:.05em .35em;border-radius:5px;overflow-wrap:anywhere}
|
|
20
|
+
.mono{font-family:var(--mono);font-size:.86em}
|
|
21
|
+
.quiet{color:var(--mute);font-size:13.5px}
|
|
22
|
+
.sr{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap}
|
|
23
|
+
.wrap{max-width:1240px;margin:0 auto;padding-left:max(20px,env(safe-area-inset-left));padding-right:max(20px,env(safe-area-inset-right))}
|
|
24
|
+
header.top{background:var(--panel);border-bottom:1px solid var(--line)}
|
|
25
|
+
header.top .wrap{padding-block:26px 0}
|
|
26
|
+
h1{font-family:var(--display);font-weight:700;font-size:clamp(26px,3.4vw,34px);line-height:1.1;letter-spacing:-.02em}
|
|
27
|
+
.title-row{display:flex;align-items:flex-start;justify-content:space-between;gap:16px}
|
|
28
|
+
.theme-btn{flex:none;display:inline-flex;align-items:center;gap:7px;height:36px;margin-top:1px;padding:0 14px 0 12px;border:1px solid var(--line2);border-radius:999px;background:var(--panel);color:var(--ink2);font:500 13.5px var(--sans);cursor:pointer}
|
|
29
|
+
.theme-btn[hidden]{display:none}.theme-btn:hover{color:var(--ink);border-color:var(--mute)}.theme-btn:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
|
|
30
|
+
.theme-btn svg{width:16px;height:16px;fill:none;stroke:currentColor;stroke-width:2;stroke-linecap:round;stroke-linejoin:round}
|
|
31
|
+
:root[data-theme="light"] .i-sun,:root:not([data-theme="light"]) .i-moon{display:none}
|
|
32
|
+
.meta{display:flex;flex-wrap:wrap;gap:4px 14px;color:var(--mute);font-size:13.5px;margin-top:6px}
|
|
33
|
+
.meta>*+*::before{content:"·";margin-right:14px;color:var(--line2)}
|
|
34
|
+
.lede{max-width:78ch;margin-top:14px;color:var(--ink2)}
|
|
35
|
+
.lede-more summary{cursor:pointer;color:var(--blue);font-size:13.5px;font-weight:600;margin-top:6px;list-style:none}
|
|
36
|
+
.lede-more summary::-webkit-details-marker{display:none}
|
|
37
|
+
.lede-more p{margin-top:6px}
|
|
38
|
+
.tabs{display:flex;flex-wrap:wrap;gap:0 26px;margin-top:20px}
|
|
39
|
+
.tab{appearance:none;background:none;border:0;border-bottom:2px solid transparent;padding:10px 0 12px;font:600 14.5px var(--sans);color:var(--mute);cursor:pointer;white-space:nowrap;display:flex;gap:8px;align-items:center}
|
|
40
|
+
.tab:hover{color:var(--ink)}
|
|
41
|
+
.tab[aria-selected=true]{color:var(--ink);border-bottom-color:var(--blue)}
|
|
42
|
+
.tab .cnt{font:500 12px var(--mono);color:var(--mute);background:var(--bg);border:1px solid var(--line);border-radius:999px;padding:0 7px}
|
|
43
|
+
html:not(.js) .tabs{display:none}
|
|
44
|
+
main{padding-block:26px 56px}
|
|
45
|
+
.tp{display:grid;gap:18px}
|
|
46
|
+
html.js .tp[hidden]{display:none}
|
|
47
|
+
html:not(.js) .tp+.tp{margin-top:40px}
|
|
48
|
+
html:not(.js) .tp::before{content:attr(data-title);font:600 20px var(--sans)}
|
|
49
|
+
.panel{background:var(--panel);border:1px solid var(--line);border-radius:var(--r);padding:22px 24px;box-shadow:var(--shadow)}
|
|
50
|
+
.panel h2{font-size:16.5px}
|
|
51
|
+
.ph{display:flex;justify-content:space-between;align-items:baseline;gap:12px;flex-wrap:wrap}
|
|
52
|
+
.sub{color:var(--mute);font-size:13px}
|
|
53
|
+
.ov-top{display:grid;grid-template-columns:minmax(0,5fr) minmax(0,7fr);gap:18px;align-items:start}
|
|
54
|
+
.ov-left{display:grid;gap:18px;align-content:start}
|
|
55
|
+
.score-panel{display:grid;gap:12px;align-content:start}
|
|
56
|
+
.factors{align-self:start}
|
|
57
|
+
.big{display:flex;align-items:baseline;gap:6px;margin-top:6px}
|
|
58
|
+
.big .n{font:700 clamp(80px,10vw,124px)/.86 var(--display);letter-spacing:-.04em;font-variant-numeric:lining-nums}
|
|
59
|
+
.big .of{font:500 22px var(--mono);color:var(--mute)}
|
|
60
|
+
.b1-t{color:var(--b1-ink)}.b2-t{color:var(--b2-ink)}.b3-t{color:var(--ink)}.b4-t{color:var(--ink)}.b5-t{color:var(--b5-ink)}
|
|
61
|
+
.big.b3-t .n,.big.b4-t .n{color:var(--ink)}
|
|
62
|
+
.band{display:flex;flex-wrap:wrap;gap:10px;align-items:center;font-size:15.5px;font-weight:600}
|
|
63
|
+
.chip{font:600 12.5px var(--sans);padding:3px 10px;border-radius:999px;color:var(--chip-ink)}
|
|
64
|
+
.chip.b1{background:var(--b1-ink)}.chip.b2{background:var(--b2-ink)}.chip.b3{background:var(--b3);color:#2b2000}.chip.b4{background:var(--b4);color:#0f2a12}.chip.b5{background:var(--b5-ink)}
|
|
65
|
+
.scale{position:relative;margin:22px 0 18px}
|
|
66
|
+
.track{display:flex;gap:2px;height:12px;border-radius:6px;overflow:hidden}
|
|
67
|
+
.track span.b1{background:var(--b1)}.track span.b2{background:var(--b2)}.track span.b3{background:var(--b3)}.track span.b4{background:var(--b4)}.track span.b5{background:var(--b5)}
|
|
68
|
+
.marker{position:absolute;top:-8px;width:3px;height:28px;margin-left:-1.5px;background:var(--ink);border-radius:2px;box-shadow:0 0 0 2px var(--panel)}
|
|
69
|
+
.marker b{position:absolute;bottom:calc(100% + 4px);left:50%;transform:translateX(-50%);font:600 12px var(--mono);background:var(--ink);color:var(--panel);padding:1px 6px;border-radius:4px}
|
|
70
|
+
.ticks{position:relative;height:16px;margin-top:6px;font:12px var(--mono);color:var(--mute)}
|
|
71
|
+
.ticks span{position:absolute;transform:translateX(-50%)}.ticks span:first-child{transform:none}.ticks span:last-child{transform:translateX(-100%)}
|
|
72
|
+
.cap{color:var(--ink2)}
|
|
73
|
+
.unlock{display:grid;gap:6px;padding:14px 16px;border:1px solid var(--line2);border-radius:8px;background:var(--bg)}
|
|
74
|
+
.u-k{font-size:13.5px;font-weight:600;color:var(--ink2)}
|
|
75
|
+
.u-v{display:flex;flex-wrap:wrap;align-items:center;gap:6px 12px}
|
|
76
|
+
.u-v .from{font:600 20px var(--mono);color:var(--mute);text-decoration:line-through;text-decoration-thickness:1.5px}
|
|
77
|
+
.u-v .arrow{color:var(--mute);font-size:18px}
|
|
78
|
+
.u-v .to{font:700 46px/1 var(--display);letter-spacing:-.03em;font-variant-numeric:lining-nums}
|
|
79
|
+
.u-v .to.b3-t,.u-v .to.b4-t{color:var(--ink)}
|
|
80
|
+
.u-s{font-size:13.5px;color:var(--mute)}
|
|
81
|
+
.own{display:inline-block;font:600 11.5px/1.6 var(--sans);color:var(--ink);background:var(--panel);border:1px solid var(--line2);border-radius:999px;padding:0 8px;white-space:nowrap;vertical-align:1px}
|
|
82
|
+
.how summary{cursor:pointer;color:var(--blue);font-size:13.5px;font-weight:600;list-style:none}
|
|
83
|
+
.how summary::-webkit-details-marker{display:none}
|
|
84
|
+
.how p{margin-top:8px;font-size:13.5px;color:var(--mute);max-width:70ch}
|
|
85
|
+
.geogrid .gg-legend{display:flex;flex-wrap:wrap;gap:6px 16px;font-size:12.5px}
|
|
86
|
+
.gg-legend span{display:inline-flex;align-items:center;gap:6px}
|
|
87
|
+
.gg-legend i{width:12px;height:12px;border-radius:3px;flex:none}
|
|
88
|
+
.gg-list{display:grid;grid-template-columns:repeat(auto-fit,minmax(min(100%,240px),1fr));gap:22px 32px;margin-top:16px}
|
|
89
|
+
.gg{margin:0;display:grid;gap:6px;align-content:start;max-width:340px}
|
|
90
|
+
.gg figcaption{display:grid;gap:2px;margin-bottom:4px}
|
|
91
|
+
.gg figcaption b{font-size:14px;color:var(--ink);overflow-wrap:anywhere}
|
|
92
|
+
.gg figcaption span{font-size:12.5px;color:var(--mute)}
|
|
93
|
+
.gg-north{font-size:12px;color:var(--mute);text-align:center}
|
|
94
|
+
.gg-grid{container-type:inline-size;display:grid;grid-template-columns:repeat(var(--n),1fr);gap:3px}
|
|
95
|
+
.gg-c,.gg-legend i{background:color-mix(in srgb,var(--c,var(--neutral)) var(--k,30%),var(--panel));-webkit-print-color-adjust:exact;print-color-adjust:exact}
|
|
96
|
+
.gg-c{aspect-ratio:1;display:grid;place-items:center;border-radius:4px;font-size:clamp(9.5px,4.4cqi,14px);font-weight:600;line-height:1;color:var(--ink)}
|
|
97
|
+
.gg-top3{--c:var(--b5);--k:54%}.gg-top10{--c:var(--b4);--k:34%}.gg-top20{--c:var(--b3);--k:30%}.gg-out{--c:var(--b1);--k:26%}
|
|
98
|
+
.gg-c.gg-err,.gg-legend i.gg-err{background:transparent;border:1px dashed var(--line2);color:var(--mute)}
|
|
99
|
+
.gg-c.gg-centre{box-shadow:inset 0 0 0 2px var(--ink)}
|
|
100
|
+
.how .gg-credit{margin-top:2px;font-size:11.5px}
|
|
101
|
+
.area-list{list-style:none;margin:14px 0 0;padding:0}
|
|
102
|
+
.area{display:grid;grid-template-columns:14px minmax(0,1fr) minmax(80px,160px) 64px;gap:14px;align-items:center;padding:11px 8px;margin:0 -8px;border-top:1px solid var(--line);color:inherit;text-decoration:none;border-radius:6px}
|
|
103
|
+
.area-list li:first-child .area{border-top:0}
|
|
104
|
+
.area:hover{background:var(--bg)}
|
|
105
|
+
.an{min-width:0}.an b{display:block;font-weight:600}.an>span{display:block;color:var(--mute);font-size:13.5px;white-space:nowrap;overflow:hidden;text-overflow:ellipsis}
|
|
106
|
+
.an>span.reason{white-space:normal}
|
|
107
|
+
.more{display:inline!important;color:var(--mute)}
|
|
108
|
+
.meter{height:8px;background:var(--line);border-radius:4px;overflow:hidden}
|
|
109
|
+
.meter i{display:block;height:100%;border-radius:4px;background:var(--neutral)}
|
|
110
|
+
.as{font:600 16px var(--mono);text-align:right}
|
|
111
|
+
.dot{display:inline-block;border-radius:50%;flex:none;justify-self:center}
|
|
112
|
+
.d-blocker{width:12px;height:12px;background:var(--blocker)}.d-high{width:10px;height:10px;background:var(--high)}.d-needs-decision{width:10px;height:10px;background:var(--decision)}.d-medium{width:8px;height:8px;background:var(--medium)}.d-low{width:7px;height:7px;background:var(--low)}.d-pass{width:8px;height:8px;background:var(--pass)}
|
|
113
|
+
.ov-right{display:grid;gap:18px;align-content:start}
|
|
114
|
+
.panel.stats{display:flex;flex-wrap:wrap;padding:0;overflow:hidden}
|
|
115
|
+
.stat{flex:1 1 150px;display:grid;gap:8px;align-content:start;padding:16px 18px;margin:-1px 0 0 -1px;border-top:1px solid var(--line);border-left:1px solid var(--line)}
|
|
116
|
+
.scope{color:var(--ink2);font-size:13.5px}
|
|
117
|
+
.topic{display:grid;gap:12px;align-content:start}
|
|
118
|
+
.topic>details+details{border-top:1px solid var(--line);padding-top:12px}
|
|
119
|
+
.stat h3{font-size:13.5px;font-weight:600;color:var(--ink2)}
|
|
120
|
+
.stat-n{color:var(--mute);font-size:13.5px}.stat-n .n{font:600 26px/1 var(--mono);color:var(--ink);margin-right:4px}
|
|
121
|
+
.key{display:inline-block;width:10px;height:10px;border-radius:2px;margin-right:6px;vertical-align:-1px}.k-fail{background:var(--ink2)}
|
|
122
|
+
.delta{font-size:13.5px;color:var(--mute)}.delta b{font:600 14px var(--mono)}.delta.up b{color:var(--b5-ink)}.delta.down b{color:var(--b1-ink)}
|
|
123
|
+
.ascore{font:500 12.5px var(--mono);color:var(--mute);margin-left:6px}
|
|
124
|
+
.as small{font:500 11px var(--sans);color:var(--mute);margin-left:2px}
|
|
125
|
+
.as.ok{color:var(--b5-ink)}
|
|
126
|
+
.stack{display:flex;gap:2px;height:10px;border-radius:5px;overflow:hidden;background:var(--line)}
|
|
127
|
+
.s-blocker{background:var(--blocker)}.s-high{background:var(--high)}.s-needs-decision{background:var(--decision)}.s-medium{background:var(--medium)}.s-low{background:var(--low)}
|
|
128
|
+
.s-fixed,.s-pass{background:var(--pass)}.s-rest{background:var(--line2)}.s-fail{background:var(--ink2)}
|
|
129
|
+
.legend{list-style:none;margin:2px 0 0;padding:0;display:flex;flex-wrap:wrap;gap:4px 12px;font-size:13px}
|
|
130
|
+
.legend li{display:inline-flex;gap:6px;align-items:center}.legend b{font:600 12.5px var(--mono)}
|
|
131
|
+
.fixfirst ol{list-style:none;margin:10px 0 0;padding:0}
|
|
132
|
+
.fixfirst ol a{display:grid;grid-template-columns:14px 64px minmax(0,1fr) 16px;gap:12px;align-items:center;padding:11px 8px;margin:0 -8px;border-top:1px solid var(--line);color:inherit;text-decoration:none;border-radius:6px}
|
|
133
|
+
.fixfirst li:first-child a{border-top:0}
|
|
134
|
+
.fixfirst ol a:hover{background:var(--bg)}
|
|
135
|
+
.fixfirst .t{font-weight:600;min-width:0}.fixfirst .c{display:none}
|
|
136
|
+
.fixfirst .sub{margin-top:4px}
|
|
137
|
+
.fixfirst .next{margin:-6px 0 10px 102px}
|
|
138
|
+
.fixfirst svg,.link svg{width:15px;height:15px;color:var(--mute)}
|
|
139
|
+
.sev-t{font-size:12.5px;font-weight:600;color:var(--mute);letter-spacing:.01em}
|
|
140
|
+
.link{display:inline-flex;gap:6px;align-items:center;font-weight:600;font-size:13.5px;color:var(--blue);text-decoration:none;background:none;border:0;padding:0;cursor:pointer;font-family:inherit}
|
|
141
|
+
.toolbar{display:flex;flex-wrap:wrap;gap:10px 12px;align-items:center;position:sticky;top:0;z-index:3;background:var(--bg);padding:10px 0;border-bottom:1px solid var(--line)}
|
|
142
|
+
.search{display:flex;align-items:center;gap:8px;background:var(--panel);border:1px solid var(--line2);border-radius:8px;padding:0 10px;flex:1 1 220px;max-width:340px}
|
|
143
|
+
.search svg{width:15px;height:15px;color:var(--mute)}
|
|
144
|
+
.search input{border:0;background:none;color:var(--ink);font:14px var(--sans);padding:8px 0;width:100%;outline:none}
|
|
145
|
+
.search:focus-within{outline:2px solid var(--blue);outline-offset:1px}
|
|
146
|
+
.seg{display:flex;flex-wrap:wrap;gap:4px}
|
|
147
|
+
.segb{display:inline-flex;gap:6px;align-items:center;font:500 13.5px var(--sans);color:var(--ink2);background:var(--panel);border:1px solid var(--line2);border-radius:8px;padding:6px 10px;cursor:pointer}
|
|
148
|
+
.segb:hover{border-color:var(--mute)}
|
|
149
|
+
.segb[aria-pressed=true]{background:var(--ink);color:var(--panel);border-color:var(--ink)}
|
|
150
|
+
.segb .mono{color:inherit;opacity:.7}
|
|
151
|
+
.sel select{font:14px var(--sans);color:var(--ink);background:var(--panel);border:1px solid var(--line2);border-radius:8px;padding:7px 10px}
|
|
152
|
+
.showing{margin-left:auto;color:var(--mute);font-size:13.5px}
|
|
153
|
+
.flist{display:grid;gap:8px}
|
|
154
|
+
.f{background:var(--panel);border:1px solid var(--line);border-radius:var(--r);box-shadow:var(--shadow);transition:opacity .25s cubic-bezier(.2,.8,.2,1)}
|
|
155
|
+
.flist.focus .f:not(.open){background:var(--bg);border-color:var(--line)}
|
|
156
|
+
.flist.focus .f:not(.open) .dot{opacity:.55}
|
|
157
|
+
.flist.focus .f:not(.open):hover{background:var(--panel)}
|
|
158
|
+
.f.open{border-color:var(--blue);box-shadow:0 0 0 1px var(--blue)}
|
|
159
|
+
.f:has(.f-head:focus-visible){outline:2px solid var(--blue);outline-offset:2px}
|
|
160
|
+
.f h3{font-size:inherit}
|
|
161
|
+
.f-head{all:unset;box-sizing:border-box;width:100%;cursor:pointer;display:grid;grid-template-columns:14px minmax(0,1fr) auto auto 16px;gap:4px 14px;align-items:center;padding:14px 18px;border-radius:var(--r)}
|
|
162
|
+
.f-head:focus-visible{outline:none}
|
|
163
|
+
.f-title{font-weight:600;font-size:15.5px;line-height:1.4;min-width:0}
|
|
164
|
+
.f-meta{grid-column:2;grid-row:2;display:flex;flex-wrap:wrap;gap:4px 12px;color:var(--mute);font-size:13px}
|
|
165
|
+
.f-head .st,.f-head .stamp{grid-row:1/3;grid-column:4}
|
|
166
|
+
.chev{width:16px;height:16px;color:var(--mute);grid-row:1/3;grid-column:5;transition:transform .2s cubic-bezier(.2,.8,.2,1)}
|
|
167
|
+
.f.open .chev{transform:rotate(90deg)}
|
|
168
|
+
.f .dot{grid-row:1;align-self:center}
|
|
169
|
+
.st{font:600 12px var(--sans);color:var(--ink2);border:1px solid var(--line2);border-radius:999px;padding:2px 9px;white-space:nowrap}
|
|
170
|
+
.st-needs-decision{color:var(--decision);border-color:currentColor}
|
|
171
|
+
.stamp{display:inline-flex;gap:5px;align-items:center;font:700 11.5px var(--sans);letter-spacing:.08em;text-transform:uppercase;color:var(--fixed);border:1.5px solid currentColor;border-radius:5px;padding:2px 8px;transform:rotate(-2deg);white-space:nowrap}
|
|
172
|
+
.stamp svg{width:12px;height:12px}
|
|
173
|
+
.f.is-fixed .f-title{color:var(--ink2)}
|
|
174
|
+
.f-body{display:none;padding:4px 18px 20px 46px}
|
|
175
|
+
.f.open .f-body,html:not(.js) .f-body{display:grid;gap:18px}
|
|
176
|
+
.f-cols{display:grid;grid-template-columns:minmax(0,1fr) minmax(0,1fr);gap:22px}
|
|
177
|
+
.f-cols>div{display:grid;gap:8px;align-content:start}
|
|
178
|
+
.f-body h4,.ev h4{font-size:12.5px;font-weight:600;color:var(--mute);letter-spacing:.02em;margin-top:4px}
|
|
179
|
+
.f-body p{max-width:70ch}
|
|
180
|
+
.howfix{background:var(--blue-soft);border-radius:8px;padding:12px 14px;display:grid;gap:6px}
|
|
181
|
+
.howfix h4{color:var(--blue);margin:0}
|
|
182
|
+
.dec-inline{background:var(--dec-soft);border-radius:8px;padding:12px 14px;display:grid;gap:6px}.dec-inline h4{color:var(--decision);margin:0}
|
|
183
|
+
.dec-inline ul,.opts{margin:0;padding-left:18px}
|
|
184
|
+
.donebox{background:var(--ok-soft);border-radius:8px;padding:12px 14px;display:grid;gap:6px}.donebox h4{color:var(--fixed);margin:0}
|
|
185
|
+
.donebox svg,.quiet svg{width:13px;height:13px;vertical-align:-2px;color:var(--fixed)}
|
|
186
|
+
.files{display:flex;flex-wrap:wrap;gap:6px}
|
|
187
|
+
.ev{display:grid;gap:8px}
|
|
188
|
+
.tablewrap{overflow-x:auto;border:1px solid var(--line);border-radius:8px}
|
|
189
|
+
table{border-collapse:collapse;width:100%;font-size:13.5px}
|
|
190
|
+
th,td{text-align:left;vertical-align:top;padding:8px 12px;border-top:1px solid var(--line)}
|
|
191
|
+
thead th{border-top:0;font-size:12px;font-weight:600;color:var(--mute);background:var(--bg)}
|
|
192
|
+
td:first-child{width:52%;overflow-wrap:anywhere}
|
|
193
|
+
.empty{color:var(--mute);text-align:center;padding:30px}
|
|
194
|
+
.cards{display:grid;grid-template-columns:repeat(auto-fill,minmax(340px,1fr));gap:18px}
|
|
195
|
+
.dcard{display:grid;gap:10px;align-content:start}
|
|
196
|
+
.dcard h3{font-size:16.5px}
|
|
197
|
+
.idlink{text-decoration:none;color:var(--mute)}
|
|
198
|
+
.rec{background:var(--dec-soft);border-radius:8px;padding:10px 12px}.rec strong{display:block;color:var(--decision);font-size:12.5px}
|
|
199
|
+
.changes{list-style:none;margin:0;padding:0;display:grid;gap:10px}
|
|
200
|
+
.changes li{display:grid;grid-template-columns:auto minmax(0,1fr) auto;gap:16px;align-items:start}
|
|
201
|
+
.changes h3{font-size:15.5px}.changes h3 a{color:inherit;text-decoration:none}.changes h3 a:hover{text-decoration:underline}
|
|
202
|
+
.changes li>div{display:grid;gap:6px}
|
|
203
|
+
.pgrid{display:grid;grid-template-columns:repeat(auto-fill,minmax(360px,1fr));gap:18px}
|
|
204
|
+
.pgroup h3{font-size:15px;display:flex;justify-content:space-between}
|
|
205
|
+
.pgroup ul{list-style:none;margin:10px 0 0;padding:0;display:grid;gap:8px;font-size:14px}
|
|
206
|
+
.pgroup li{display:grid;grid-template-columns:16px 1fr;gap:8px}
|
|
207
|
+
.pgroup li svg{width:15px;height:15px;color:var(--pass);margin-top:3px}
|
|
208
|
+
.limits{display:grid;gap:18px}
|
|
209
|
+
.limits .panel{display:grid;gap:10px}
|
|
210
|
+
.lim{list-style:none;margin:0;padding:0;display:grid}
|
|
211
|
+
.lim li{display:grid;grid-template-columns:minmax(0,260px) minmax(0,1fr);gap:16px;padding:10px 0;border-top:1px solid var(--line)}
|
|
212
|
+
.lim li:first-child{border-top:0}.lim li span{color:var(--ink2)}
|
|
213
|
+
.lim li:not(:has(b)){grid-template-columns:1fr}
|
|
214
|
+
.empty-state{display:grid;gap:8px;text-align:center;padding:48px 24px}.empty-state p{color:var(--mute);max-width:56ch;margin:0 auto}
|
|
215
|
+
footer{border-top:1px solid var(--line);color:var(--mute);font-size:13px}
|
|
216
|
+
footer .wrap{padding-block:20px 40px;display:flex;flex-wrap:wrap;gap:6px 18px;justify-content:space-between}
|
|
217
|
+
@media (max-width:900px){.ov-top{grid-template-columns:1fr}.f-cols{grid-template-columns:1fr}}
|
|
218
|
+
@media (max-width:560px){.stat{flex-basis:130px}.tabs{gap:0 18px}.tab{padding:8px 0 9px}.panel{padding:18px}.meta{gap:2px 12px}.meta>*+*::before{display:none}.ticks span:nth-child(5){display:none}.area{grid-template-columns:14px minmax(0,1fr) 56px}.meter{display:none}
|
|
219
|
+
.f-head{grid-template-columns:14px minmax(0,1fr) 16px;padding:14px}.f-head .st,.f-head .stamp{grid-column:2;grid-row:3;justify-self:start}.chev{grid-column:3}
|
|
220
|
+
.f-body{padding:4px 14px 18px}.fixfirst ol a{grid-template-columns:14px minmax(0,1fr) 16px}.fixfirst .sev-t,.fixfirst .c{display:none}.fixfirst .next{margin-left:26px}
|
|
221
|
+
.lim li{grid-template-columns:1fr;gap:4px}.showing{margin-left:0;width:100%}.cards,.pgrid{grid-template-columns:1fr}.changes li{grid-template-columns:1fr}}
|
|
222
|
+
@media (prefers-reduced-motion:reduce){*{transition:none!important}}
|
|
223
|
+
@media print{body{background:#fff}.tabs,.toolbar,.theme-btn,footer .wrap>:last-child{display:none}html.js .tp[hidden]{display:grid}.tp+.tp{margin-top:28px}.f-body{display:grid!important}.chev{display:none}.panel,.f{box-shadow:none;break-inside:avoid}.flist.focus .f{background:#fff}}
|
|
@@ -0,0 +1,264 @@
|
|
|
1
|
+
// @ts-check
|
|
2
|
+
// Search and analytics lines for findings, plan rows and the search panels.
|
|
3
|
+
import { esc, fmtDate, num, obj, plural } from "./format.mjs";
|
|
4
|
+
import { periodOf } from "./sources.mjs";
|
|
5
|
+
|
|
6
|
+
// Matomo and PostHog: a page counts only with visits above zero, and dates show only when they are dates.
|
|
7
|
+
export const visitsOf = t => {
|
|
8
|
+
const n = Number(t?.visits);
|
|
9
|
+
return n > 0 ? n : 0;
|
|
10
|
+
};
|
|
11
|
+
export const isoDates = x =>
|
|
12
|
+
[x?.period?.from, x?.period?.to].every(d => /^\d{4}-\d{2}-\d{2}$/.test(d))
|
|
13
|
+
? `${x.period.from} to ${x.period.to}`
|
|
14
|
+
: "";
|
|
15
|
+
// A row by page: path and query exactly, else the path, else both compared without tracking parameters or the
|
|
16
|
+
// trailing slash, so /pricing/?utm_source=x finds /pricing/. TRACKING is CRAWL-10's list (checks/coverage.mjs) plus
|
|
17
|
+
// srsltid, which Merchant Center auto-tagging adds to free listing links.
|
|
18
|
+
const TRACKING = /^(utm_\w+|gclid|gbraid|wbraid|dclid|fbclid|msclkid|yclid|igshid|mc_cid|mc_eid|_gl|_ga|srsltid)$/i;
|
|
19
|
+
const looseKey = (x, query = true) => {
|
|
20
|
+
const q = query ? [...x.searchParams].filter(([k]) => !TRACKING.test(k)) : [];
|
|
21
|
+
return x.pathname.replace(/(.)\/$/, "$1") + (q.length ? "?" + new URLSearchParams(q) : "");
|
|
22
|
+
};
|
|
23
|
+
const loose = new WeakMap(); // each map's rows by loose key, the first row of a key kept
|
|
24
|
+
const looseRows = map => {
|
|
25
|
+
if (!loose.has(map)) {
|
|
26
|
+
const rows = new Map();
|
|
27
|
+
for (const [k, v] of Object.entries(map)) {
|
|
28
|
+
try {
|
|
29
|
+
const key = looseKey(new URL(k, "https://site.invalid"));
|
|
30
|
+
if (!rows.has(key)) rows.set(key, v);
|
|
31
|
+
} catch {}
|
|
32
|
+
}
|
|
33
|
+
loose.set(map, rows);
|
|
34
|
+
}
|
|
35
|
+
return loose.get(map);
|
|
36
|
+
};
|
|
37
|
+
export const byPath = (map, u) => {
|
|
38
|
+
if (!obj(map) || !u) return null;
|
|
39
|
+
let x;
|
|
40
|
+
try {
|
|
41
|
+
x = new URL(u, "https://site.invalid");
|
|
42
|
+
} catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
const rows = () => looseRows(map);
|
|
46
|
+
return (
|
|
47
|
+
obj(map[x.pathname + x.search] || map[x.pathname]) || obj(rows().get(looseKey(x)) || rows().get(looseKey(x, false)))
|
|
48
|
+
);
|
|
49
|
+
};
|
|
50
|
+
const sum = (map, k) => Object.values(obj(map) || {}).reduce((s, t) => s + (Number(t?.[k]) || 0), 0);
|
|
51
|
+
const visitsLine = (name, x) => {
|
|
52
|
+
const counts = Object.values(obj(x?.traffic) || {})
|
|
53
|
+
.map(visitsOf)
|
|
54
|
+
.filter(Boolean),
|
|
55
|
+
d = isoDates(x);
|
|
56
|
+
return (
|
|
57
|
+
counts.length &&
|
|
58
|
+
`${name}: ${plural(
|
|
59
|
+
counts.reduce((s, n) => s + n, 0),
|
|
60
|
+
"organic visit",
|
|
61
|
+
)} to ${plural(counts.length, "landing page")}${d ? ` (${d})` : ""}`
|
|
62
|
+
);
|
|
63
|
+
};
|
|
64
|
+
const GTYPE = {
|
|
65
|
+
discover: "Discover",
|
|
66
|
+
image: "Google Images",
|
|
67
|
+
video: "Video search",
|
|
68
|
+
news: "the News tab",
|
|
69
|
+
googleNews: "Google News",
|
|
70
|
+
webMultimodal: "Google Lens and Circle to Search",
|
|
71
|
+
};
|
|
72
|
+
// Google's own brand label from the Search Analytics API: numbers only, both sides or nothing.
|
|
73
|
+
const brandSide = x => (obj(x) && Number.isFinite(x.clicks) && Number.isFinite(x.impressions) ? x : null);
|
|
74
|
+
|
|
75
|
+
// One traffic line per path, from every source that has the page.
|
|
76
|
+
export function searchTraffic({ raw }, { linked }) {
|
|
77
|
+
const traffic = obj(raw.traffic),
|
|
78
|
+
bing = obj(raw.bing),
|
|
79
|
+
analytics = obj(raw.analytics),
|
|
80
|
+
matomo = obj(raw.matomo),
|
|
81
|
+
posthog = obj(raw.posthog);
|
|
82
|
+
const bingDates = bing?.period?.from ? `${bing.period.from} to ${bing.period.to}` : "";
|
|
83
|
+
// plain: Search Console alone reads unlabelled, to match the plan's "Search traffic" field.
|
|
84
|
+
const trafficFor = (u, plain = false) => {
|
|
85
|
+
const g = byPath(traffic, u),
|
|
86
|
+
b = byPath(bing?.traffic, u),
|
|
87
|
+
a = byPath(analytics, u),
|
|
88
|
+
m = visitsOf(byPath(matomo?.traffic, u)),
|
|
89
|
+
p = visitsOf(byPath(posthog?.traffic, u));
|
|
90
|
+
const parts = [
|
|
91
|
+
g &&
|
|
92
|
+
`${plain && !b && !a && !m && !p ? "" : "Search Console: "}${num(g.clicks)} clicks · ${num(g.impressions)} impressions`,
|
|
93
|
+
b && `Bing: ${num(b.clicks)} clicks · ${num(b.impressions)} impressions`,
|
|
94
|
+
a && `Google Analytics: ${plural(a.sessions, "organic visit")}`,
|
|
95
|
+
m && `Matomo: ${plural(m, "organic visit")}`,
|
|
96
|
+
p && `PostHog: ${plural(p, "organic visit")}`,
|
|
97
|
+
].filter(Boolean);
|
|
98
|
+
// One period per line: Google's, shared by Search Console and GA4 (connect-keys reads Matomo and PostHog for the
|
|
99
|
+
// same days), else Matomo's or PostHog's. Bing's dates are on its own search line.
|
|
100
|
+
const when = g || a ? raw.trafficPeriod : m ? isoDates(matomo) : p ? isoDates(posthog) : bingDates;
|
|
101
|
+
return parts.length ? `${parts.join(" · ")}${when ? ` (${String(when).toLowerCase()})` : ""}` : null;
|
|
102
|
+
};
|
|
103
|
+
// The first evidence page with traffic.
|
|
104
|
+
const trafficOf = f => {
|
|
105
|
+
const e = (f.evidence || []).find(x => x.url && trafficFor(x.url));
|
|
106
|
+
return e && { text: trafficFor(e.url), path: new URL(e.url, "https://site.invalid").pathname };
|
|
107
|
+
};
|
|
108
|
+
const trafficHtml = f => {
|
|
109
|
+
const t = trafficOf(f);
|
|
110
|
+
return t ? `<p class="quiet">${esc(t.text)} on <code>${esc(t.path)}</code></p>` : "";
|
|
111
|
+
};
|
|
112
|
+
// Clarity covers only the last 1 to 3 days, so it gets its own line under the traffic line. A share shows only when
|
|
113
|
+
// it's above zero.
|
|
114
|
+
const clarity = obj(raw.clarity),
|
|
115
|
+
share = v => typeof v === "number" && v >= 0 && v <= 100;
|
|
116
|
+
const sharePct = v => `${v > 0 && v < 1 ? "under 1" : Math.round(v)}%`;
|
|
117
|
+
const clarityWhen = () => {
|
|
118
|
+
const n = [1, 2, 3].includes(clarity?.days) ? clarity.days : 3,
|
|
119
|
+
d = /^\d{4}-\d{2}-\d{2}$/.test(clarity?.read) ? fmtDate(clarity.read) : "";
|
|
120
|
+
return d ? `the ${n === 1 ? "day" : `${n} days`} before ${d}` : `last ${n === 1 ? "day" : `${n} days`}`;
|
|
121
|
+
};
|
|
122
|
+
const clarityPages = () =>
|
|
123
|
+
Object.entries(obj(clarity?.traffic) || {}).filter(
|
|
124
|
+
([, c]) => obj(c) && Number.isInteger(c.sessions) && c.sessions > 0,
|
|
125
|
+
);
|
|
126
|
+
const clarityFor = u => {
|
|
127
|
+
const c = byPath(clarity?.traffic, u);
|
|
128
|
+
if (!c || !Number.isInteger(c.sessions) || c.sessions <= 0) return null;
|
|
129
|
+
const of = (k, w) => share(c[k]) && c[k] > 0 && `${w} in ${sharePct(c[k])} of sessions`;
|
|
130
|
+
return `Microsoft Clarity (${clarityWhen()}): ${[plural(c.sessions, "session"), share(c.scrollDepth) && `average scroll depth ${sharePct(c.scrollDepth)}`, of("quickBacks", "quick backs"), of("rageClicks", "rage clicks"), of("deadClicks", "dead clicks"), of("excessiveScroll", "excessive scrolling")].filter(Boolean).join(" · ")}`;
|
|
131
|
+
};
|
|
132
|
+
const clarityOf = f => {
|
|
133
|
+
const e = (f.evidence || []).find(x => x.url && clarityFor(x.url));
|
|
134
|
+
return e && { text: clarityFor(e.url), path: new URL(e.url, "https://site.invalid").pathname };
|
|
135
|
+
};
|
|
136
|
+
const clarityHtml = f => {
|
|
137
|
+
const t = clarityOf(f);
|
|
138
|
+
return t ? `<p class="quiet">${esc(t.text)} on <code>${esc(t.path)}</code></p>` : "";
|
|
139
|
+
};
|
|
140
|
+
// Top pages need 10 or more sessions, a local cut-off, so one visit's quick back can't top the list.
|
|
141
|
+
const clarityLine = () => {
|
|
142
|
+
const pages = clarityPages();
|
|
143
|
+
if (!pages.length) return null;
|
|
144
|
+
const most = (k, w) => {
|
|
145
|
+
const top = pages
|
|
146
|
+
.filter(([, c]) => c.sessions >= 10 && share(c[k]) && c[k] > 0)
|
|
147
|
+
.sort((a, b) => b[1][k] - a[1][k])
|
|
148
|
+
.slice(0, 3);
|
|
149
|
+
return top.length && `most ${w}: ${top.map(([p, c]) => `${p} ${sharePct(c[k])}`).join(", ")}`;
|
|
150
|
+
};
|
|
151
|
+
const tops = [most("quickBacks", "quick backs"), most("rageClicks", "rage clicks")].filter(Boolean);
|
|
152
|
+
return `Microsoft Clarity (${clarityWhen()}): ${plural(
|
|
153
|
+
pages.reduce((s, [, c]) => s + c.sessions, 0),
|
|
154
|
+
"session",
|
|
155
|
+
)} on ${plural(pages.length, "page")}${tops.length ? ` · ${tops.join(" · ")} (pages with 10 or more sessions)` : ""}`;
|
|
156
|
+
};
|
|
157
|
+
// Site-wide search lines. Third-party data, escaped where shown.
|
|
158
|
+
function googleLines() {
|
|
159
|
+
// Each line's period from its own data's source: the search splits', the brand split's.
|
|
160
|
+
const n = (x, k) => Number(x?.[k]) || 0,
|
|
161
|
+
isDay = s => /^\d{4}-\d{2}-\d{2}$/.test(s),
|
|
162
|
+
perOf = of => {
|
|
163
|
+
const p = periodOf(raw, of);
|
|
164
|
+
return p ? ` (${String(p).toLowerCase()})` : "";
|
|
165
|
+
},
|
|
166
|
+
per = perOf("searchTypes");
|
|
167
|
+
const ch = obj(raw.trafficChange),
|
|
168
|
+
was = obj(ch?.previous),
|
|
169
|
+
now = obj(ch?.current),
|
|
170
|
+
days = was && isDay(was.from) && isDay(was.to) ? (Date.parse(was.to) - Date.parse(was.from)) / 864e5 + 1 : 0;
|
|
171
|
+
const move = k =>
|
|
172
|
+
`${num(n(was, k))} → ${num(n(now, k))}${n(was, k) ? ` (${n(now, k) >= n(was, k) ? "+" : "−"}${Math.abs(Math.round((100 * (n(now, k) - n(was, k))) / n(was, k)))}%)` : ""}`;
|
|
173
|
+
const drops = (Array.isArray(ch?.drops) ? ch.drops.filter(d => obj(d) && d.path) : []).slice(0, 5);
|
|
174
|
+
const byClicks = (m, k = "clicks") =>
|
|
175
|
+
Object.entries(obj(m) || {})
|
|
176
|
+
.filter(([, v]) => n(v, k) > 0)
|
|
177
|
+
.sort((a, b) => n(b[1], "clicks") - n(a[1], "clicks"));
|
|
178
|
+
const types = byClicks(raw.searchTypes).filter(([k]) => GTYPE[k]),
|
|
179
|
+
devices = byClicks(raw.byDevice, "impressions"),
|
|
180
|
+
countries = byClicks(raw.byCountry).slice(0, 10);
|
|
181
|
+
const anomalies = (Array.isArray(raw.anomalies) ? raw.anomalies : []).filter(
|
|
182
|
+
a => obj(a) && isDay(a.from) && isDay(a.to) && a.what && a.url,
|
|
183
|
+
);
|
|
184
|
+
return [
|
|
185
|
+
now &&
|
|
186
|
+
days > 0 &&
|
|
187
|
+
`Search clicks: ${move("clicks")} · impressions: ${move("impressions")} vs the previous ${days} days`,
|
|
188
|
+
drops.length &&
|
|
189
|
+
`Biggest drops in search clicks: ${drops.map(d => `${d.path} ${num(n(d, "before"))} → ${num(n(d, "after"))}`).join(" · ")}`,
|
|
190
|
+
types.length &&
|
|
191
|
+
`Clicks from other Google results: ${types.map(([k, v]) => `${GTYPE[k]} ${num(n(v, "clicks"))}`).join(" · ")}${per}`,
|
|
192
|
+
devices.length &&
|
|
193
|
+
`Search by device: ${devices.map(([k, v]) => `${k.toLowerCase()} ${num(n(v, "clicks"))} clicks · ${num(n(v, "impressions"))} impressions`).join("; ")}${per}`,
|
|
194
|
+
brandSide(raw.brandSplit?.branded) &&
|
|
195
|
+
brandSide(raw.brandSplit?.nonBranded) &&
|
|
196
|
+
`Brand searches, as Google labels them: ${num(raw.brandSplit.branded.clicks)} clicks · ${num(raw.brandSplit.branded.impressions)} impressions; other searches: ${num(raw.brandSplit.nonBranded.clicks)} clicks · ${num(raw.brandSplit.nonBranded.impressions)} impressions${perOf("brandSplit")}`,
|
|
197
|
+
countries.length &&
|
|
198
|
+
`Search clicks by country: ${countries.map(([k, v]) => `${k.toUpperCase()} ${num(n(v, "clicks"))}`).join(" · ")}${per}`,
|
|
199
|
+
anomalies.length &&
|
|
200
|
+
`Google's data anomalies page (${anomalies[0].url}) lists problems in this period: ${anomalies.map(a => `${a.from === a.to ? a.from : `${a.from} to ${a.to}`}: ${a.what}`).join("; ")}. A change in these numbers may not be real.`,
|
|
201
|
+
];
|
|
202
|
+
}
|
|
203
|
+
function searchLines() {
|
|
204
|
+
const pages = Object.keys(obj(bing?.traffic) || {}).length,
|
|
205
|
+
ga = Object.keys(analytics || {}).length;
|
|
206
|
+
const bits = [
|
|
207
|
+
pages && `${num(sum(bing.traffic, "clicks"))} clicks · ${num(sum(bing.traffic, "impressions"))} impressions`,
|
|
208
|
+
linked.length &&
|
|
209
|
+
`${plural(linked.length, "page")} ${linked.length === 1 ? "has" : "have"} links from other sites`,
|
|
210
|
+
].filter(Boolean);
|
|
211
|
+
return [
|
|
212
|
+
...googleLines(),
|
|
213
|
+
bits.length && `Bing${bingDates ? ` (${bingDates})` : ""}: ${bits.join(" · ")}`,
|
|
214
|
+
ga &&
|
|
215
|
+
`Google Analytics: ${plural(sum(analytics, "sessions"), "organic visit")} to ${plural(ga, "landing page")}${raw.trafficPeriod ? ` (${String(raw.trafficPeriod).toLowerCase()})` : ""}`,
|
|
216
|
+
visitsLine("Matomo", matomo),
|
|
217
|
+
visitsLine("PostHog", posthog),
|
|
218
|
+
clarityLine(),
|
|
219
|
+
].filter(Boolean);
|
|
220
|
+
}
|
|
221
|
+
// positions holds shares of queries (0 to 1) by average position.
|
|
222
|
+
const positionsText = () => {
|
|
223
|
+
const p = obj(raw.positions),
|
|
224
|
+
ok = ["top3", "top10", "beyond"].every(k => typeof p?.[k] === "number" && p[k] >= 0 && p[k] <= 1);
|
|
225
|
+
if (!ok || !(Number.isInteger(p.queries) && p.queries > 0)) return "";
|
|
226
|
+
const pct = k => `${Math.round(100 * p[k])}%`;
|
|
227
|
+
const period = periodOf(raw, "positions");
|
|
228
|
+
return `Search Console queries by average position: ${pct("top3")} in the top 3 · ${pct("top10")} in the top 10 · ${pct("beyond")} beyond, of ${plural(p.queries, "query", "queries")}${period ? ` (${String(period).toLowerCase()})` : ""}`;
|
|
229
|
+
};
|
|
230
|
+
// Matomo and PostHog device and country splits ({ name: { visits } }), top 10. The callers escape the names.
|
|
231
|
+
const analyticsSplitLines = () =>
|
|
232
|
+
[
|
|
233
|
+
["Matomo", matomo],
|
|
234
|
+
["PostHog", posthog],
|
|
235
|
+
]
|
|
236
|
+
.flatMap(([name, x]) =>
|
|
237
|
+
[
|
|
238
|
+
["device", x?.byDevice, k => k.toLowerCase()],
|
|
239
|
+
["country", x?.byCountry, k => k.toUpperCase()],
|
|
240
|
+
].map(([by, map, label]) => {
|
|
241
|
+
const rows = Object.entries(obj(map) || {})
|
|
242
|
+
.map(([k, v]) => /** @type {[string, number]} */ ([k, visitsOf(v)]))
|
|
243
|
+
.filter(([, n]) => n)
|
|
244
|
+
.sort((a, b) => b[1] - a[1])
|
|
245
|
+
.slice(0, 10),
|
|
246
|
+
d = isoDates(x);
|
|
247
|
+
return (
|
|
248
|
+
rows.length &&
|
|
249
|
+
`${name} organic visits by ${by}: ${rows.map(([k, n]) => `${label(k)} ${num(n)}`).join(" · ")}${d ? ` (${d})` : ""}`
|
|
250
|
+
);
|
|
251
|
+
}),
|
|
252
|
+
)
|
|
253
|
+
.filter(Boolean);
|
|
254
|
+
return {
|
|
255
|
+
trafficFor,
|
|
256
|
+
trafficOf,
|
|
257
|
+
trafficHtml,
|
|
258
|
+
clarityOf,
|
|
259
|
+
clarityHtml,
|
|
260
|
+
searchLines,
|
|
261
|
+
positionsText,
|
|
262
|
+
analyticsSplitLines,
|
|
263
|
+
};
|
|
264
|
+
}
|