@canonry/canonry 4.150.0 → 4.150.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (24) hide show
  1. package/assets/assets/{AuditHistoryPanel-DRZk9o6L.js → AuditHistoryPanel-CXjIBlWZ.js} +1 -1
  2. package/assets/assets/{BacklinksPage-Dqkq_a-l.js → BacklinksPage-oVeQiyZ9.js} +1 -1
  3. package/assets/assets/ChartPrimitives-DXVLCdBi.js +1 -0
  4. package/assets/assets/{HistoryPage-BWoRO7wp.js → HistoryPage-B6mWz25S.js} +1 -1
  5. package/assets/assets/MeasurementPropertyPage-Wa-JWWlY.js +1 -0
  6. package/assets/assets/{ProjectPage-IZcPVJDc.js → ProjectPage-s2Sp2gWd.js} +9 -9
  7. package/assets/assets/{RunRow-DOZDMB1T.js → RunRow-ag3MckGi.js} +1 -1
  8. package/assets/assets/{RunsPage-BTEUz9dP.js → RunsPage-CQhfk-U6.js} +1 -1
  9. package/assets/assets/{SettingsPage-CtFaqFam.js → SettingsPage-C4LOqjjm.js} +1 -1
  10. package/assets/assets/{TrafficPage-P-T5se9o.js → TrafficPage-BrQ6ByXb.js} +1 -1
  11. package/assets/assets/TrafficSourceDetailPage-CAiCsj3u.js +1 -0
  12. package/assets/assets/{arrow-left-DzZGGujh.js → arrow-left-CPOYDEc0.js} +1 -1
  13. package/assets/assets/{extract-error-message-Dftl6C6Y.js → extract-error-message-gHKEV_z-.js} +1 -1
  14. package/assets/assets/{index-BMymPeRH.js → index-XkpXQYKF.js} +68 -68
  15. package/assets/assets/refresh-cw-BEX_iTPE.js +1 -0
  16. package/assets/assets/{trash-2-DHAtpDut.js → trash-2-NEiQsVBH.js} +1 -1
  17. package/assets/index.html +1 -1
  18. package/dist/{chunk-6XY6MRPN.js → chunk-CETLBKTX.js} +75 -54
  19. package/dist/cli.js +1 -1
  20. package/dist/index.js +1 -1
  21. package/package.json +5 -5
  22. package/assets/assets/ChartPrimitives-CithLZJb.js +0 -1
  23. package/assets/assets/MeasurementPropertyPage-DUDpWj6i.js +0 -1
  24. package/assets/assets/TrafficSourceDetailPage-DUjwNhWm.js +0 -1
@@ -0,0 +1 @@
1
+ import{c as e}from"./index-XkpXQYKF.js";const o=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],a=e("chevron-left",o);const t=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],h=e("refresh-cw",t);export{a as C,h as R};
@@ -1 +1 @@
1
- import{c as a}from"./index-BMymPeRH.js";const t=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],h=a("circle-question-mark",t);const e=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],d=a("download",e);const o=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],p=a("external-link",o);const c=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],s=a("trash-2",c);export{h as C,d as D,p as E,s as T};
1
+ import{c as a}from"./index-XkpXQYKF.js";const t=[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M9.09 9a3 3 0 0 1 5.83 1c0 2-3 3-3 3",key:"1u773s"}],["path",{d:"M12 17h.01",key:"p32p05"}]],h=a("circle-question-mark",t);const e=[["path",{d:"M12 15V3",key:"m9g1x1"}],["path",{d:"M21 15v4a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-4",key:"ih7n3h"}],["path",{d:"m7 10 5 5 5-5",key:"brsn70"}]],d=a("download",e);const o=[["path",{d:"M15 3h6v6",key:"1q9fwt"}],["path",{d:"M10 14 21 3",key:"gplh6r"}],["path",{d:"M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6",key:"a6xqqp"}]],p=a("external-link",o);const c=[["path",{d:"M10 11v6",key:"nco0om"}],["path",{d:"M14 11v6",key:"outv1u"}],["path",{d:"M19 6v14a2 2 0 0 1-2 2H7a2 2 0 0 1-2-2V6",key:"miytrc"}],["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M8 6V4a2 2 0 0 1 2-2h4a2 2 0 0 1 2 2v2",key:"e791ji"}]],s=a("trash-2",c);export{h as C,d as D,p as E,s as T};
package/assets/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <link rel="icon" type="image/png" sizes="32x32" href="./favicon-32.png" />
13
13
  <link rel="apple-touch-icon" href="./apple-touch-icon.png" />
14
14
  <title>Canonry</title>
15
- <script type="module" crossorigin src="./assets/index-BMymPeRH.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-XkpXQYKF.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="./assets/vendor-tanstack-BjS7iY3g.js">
17
17
  <link rel="modulepreload" crossorigin href="./assets/vendor-radix-DnzzbllM.js">
18
18
  <link rel="modulepreload" crossorigin href="./assets/vendor-recharts-33ACLxsD.js">
@@ -5674,6 +5674,7 @@ async function inspectUrlsPaced(urls, cb, deps = {}) {
5674
5674
  const sleep3 = deps.sleep ?? defaultSleep;
5675
5675
  const jitter = deps.jitter ?? Math.random;
5676
5676
  const concurrency = Math.max(1, Math.min(deps.concurrency ?? INSPECT_MAX_CONCURRENCY, urls.length || 1));
5677
+ const isRetryable = deps.isRetryable ?? isRetryableGscInspectError;
5677
5678
  let inspected = 0;
5678
5679
  let errors = 0;
5679
5680
  let consecutiveRetryableFailures = 0;
@@ -5699,7 +5700,7 @@ async function inspectUrlsPaced(urls, cb, deps = {}) {
5699
5700
  maxRetries: INSPECT_MAX_RETRIES,
5700
5701
  baseDelayMs: INSPECT_BASE_DELAY_MS,
5701
5702
  maxDelayMs: INSPECT_MAX_BACKOFF_MS,
5702
- isRetryable: isRetryableGscInspectError,
5703
+ isRetryable,
5703
5704
  sleep: sleep3,
5704
5705
  onRetry: ({ attempt, delayMs, err }) => deps.log?.info("inspect.retry", {
5705
5706
  url,
@@ -5714,7 +5715,7 @@ async function inspectUrlsPaced(urls, cb, deps = {}) {
5714
5715
  } catch (err) {
5715
5716
  errors++;
5716
5717
  cb.onError(url, err, index);
5717
- if (isRetryableGscInspectError(err)) {
5718
+ if (isRetryable(err)) {
5718
5719
  consecutiveRetryableFailures++;
5719
5720
  if (consecutiveRetryableFailures >= INSPECT_FAILFAST_THRESHOLD) {
5720
5721
  deps.log?.error("inspect.circuit-break", {
@@ -5918,61 +5919,81 @@ async function executeBingInspectSitemap(db, runId, projectId, opts) {
5918
5919
  });
5919
5920
  blockedUrls = /* @__PURE__ */ new Set();
5920
5921
  }
5922
+ const skipped = Math.max(0, sitemapUrls.length - INSPECT_SWEEP_MAX_URLS);
5923
+ const targetUrls = skipped > 0 ? sitemapUrls.slice(0, INSPECT_SWEEP_MAX_URLS) : sitemapUrls;
5924
+ if (skipped > 0) {
5925
+ log7.warn("sitemap.over-budget", {
5926
+ runId,
5927
+ projectId,
5928
+ sitemapUrls: sitemapUrls.length,
5929
+ inspecting: targetUrls.length,
5930
+ skipped,
5931
+ dailyQuota: INSPECT_DAILY_QUOTA,
5932
+ note: `Sitemap has ${sitemapUrls.length} pages; inspecting the first ${targetUrls.length}. ${skipped} pages will not have a verdict from this run.`
5933
+ });
5934
+ }
5935
+ const siteUrl = conn.siteUrl;
5921
5936
  let inspected = 0;
5922
5937
  let errors = 0;
5923
- for (const pageUrl of sitemapUrls) {
5924
- try {
5925
- const result = await getUrlInfo(conn.apiKey, conn.siteUrl, pageUrl);
5926
- const inspectedAt = (/* @__PURE__ */ new Date()).toISOString();
5927
- const httpCode = result.HttpStatus ?? result.HttpCode ?? null;
5928
- const lastCrawledDate = parseBingDate(result.LastCrawledDate);
5929
- const inIndexDate = parseBingDate(result.InIndexDate);
5930
- const discoveryDate = parseBingDate(result.DiscoveryDate);
5931
- let derivedInIndex = null;
5932
- if (result.DocumentSize != null && result.DocumentSize > 0) {
5933
- derivedInIndex = true;
5934
- } else if (lastCrawledDate != null) {
5935
- derivedInIndex = httpCode != null && httpCode >= 400 ? false : true;
5936
- } else if (discoveryDate != null) {
5937
- derivedInIndex = false;
5938
- }
5939
- if (derivedInIndex === true && blockedUrls.has(pageUrl)) {
5940
- derivedInIndex = false;
5938
+ const outcome = await inspectUrlsPaced(
5939
+ targetUrls,
5940
+ {
5941
+ inspectOne: (pageUrl) => getUrlInfo(conn.apiKey, siteUrl, pageUrl),
5942
+ onResult: (pageUrl, result) => {
5943
+ const inspectedAt = (/* @__PURE__ */ new Date()).toISOString();
5944
+ const httpCode = result.HttpStatus ?? result.HttpCode ?? null;
5945
+ const lastCrawledDate = parseBingDate(result.LastCrawledDate);
5946
+ const inIndexDate = parseBingDate(result.InIndexDate);
5947
+ const discoveryDate = parseBingDate(result.DiscoveryDate);
5948
+ let derivedInIndex = null;
5949
+ if (result.DocumentSize != null && result.DocumentSize > 0) {
5950
+ derivedInIndex = true;
5951
+ } else if (lastCrawledDate != null) {
5952
+ derivedInIndex = httpCode != null && httpCode >= 400 ? false : true;
5953
+ } else if (discoveryDate != null) {
5954
+ derivedInIndex = false;
5955
+ }
5956
+ if (derivedInIndex === true && blockedUrls.has(pageUrl)) {
5957
+ derivedInIndex = false;
5958
+ }
5959
+ db.insert(bingUrlInspections).values({
5960
+ id: crypto10.randomUUID(),
5961
+ projectId,
5962
+ url: pageUrl,
5963
+ httpCode,
5964
+ inIndex: derivedInIndex,
5965
+ lastCrawledDate,
5966
+ inIndexDate,
5967
+ inspectedAt,
5968
+ syncRunId: runId,
5969
+ createdAt: inspectedAt,
5970
+ documentSize: result.DocumentSize ?? null,
5971
+ anchorCount: result.AnchorCount ?? null,
5972
+ discoveryDate
5973
+ }).run();
5974
+ inspected++;
5975
+ log7.info("inspect.url-done", { runId, projectId, url: pageUrl, progress: `${inspected}/${targetUrls.length}` });
5976
+ },
5977
+ onError: (pageUrl, err) => {
5978
+ errors++;
5979
+ log7.error("inspect.url-failed", {
5980
+ runId,
5981
+ projectId,
5982
+ url: pageUrl,
5983
+ error: err instanceof Error ? err.message : String(err)
5984
+ });
5941
5985
  }
5942
- db.insert(bingUrlInspections).values({
5943
- id: crypto10.randomUUID(),
5944
- projectId,
5945
- url: pageUrl,
5946
- httpCode,
5947
- inIndex: derivedInIndex,
5948
- lastCrawledDate,
5949
- inIndexDate,
5950
- inspectedAt,
5951
- syncRunId: runId,
5952
- createdAt: inspectedAt,
5953
- documentSize: result.DocumentSize ?? null,
5954
- anchorCount: result.AnchorCount ?? null,
5955
- discoveryDate
5956
- }).run();
5957
- inspected++;
5958
- log7.info("inspect.url-done", {
5959
- runId,
5960
- projectId,
5961
- url: pageUrl,
5962
- progress: `${inspected}/${sitemapUrls.length}`
5963
- });
5964
- } catch (err) {
5965
- errors++;
5966
- log7.error("inspect.url-failed", {
5967
- runId,
5968
- projectId,
5969
- url: pageUrl,
5970
- error: err instanceof Error ? err.message : String(err)
5971
- });
5972
- }
5973
- if (inspected + errors < sitemapUrls.length) {
5974
- await new Promise((r) => setTimeout(r, 1e3));
5975
- }
5986
+ },
5987
+ { isRetryable: isRetryableHttpError, concurrency: 1, log: log7, ...opts.pacedDeps }
5988
+ );
5989
+ if (outcome.aborted) {
5990
+ log7.error("inspect.circuit-break", {
5991
+ runId,
5992
+ projectId,
5993
+ inspected,
5994
+ errors,
5995
+ note: "Bing inspection stopped early after sustained failures; the remaining pages were not attempted."
5996
+ });
5976
5997
  }
5977
5998
  const allInspections = db.select().from(bingUrlInspections).where(eq8(bingUrlInspections.projectId, projectId)).orderBy(desc3(bingUrlInspections.inspectedAt)).all();
5978
5999
  const latestByUrl = /* @__PURE__ */ new Map();
package/dist/cli.js CHANGED
@@ -30,7 +30,7 @@ import {
30
30
  showFirstRunNotice,
31
31
  trackCliCommandFinished,
32
32
  trackEvent
33
- } from "./chunk-6XY6MRPN.js";
33
+ } from "./chunk-CETLBKTX.js";
34
34
  import {
35
35
  CliError,
36
36
  EXIT_SYSTEM_ERROR,
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  createServer
3
- } from "./chunk-6XY6MRPN.js";
3
+ } from "./chunk-CETLBKTX.js";
4
4
  import {
5
5
  loadConfig
6
6
  } from "./chunk-TS3AHKZG.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canonry/canonry",
3
- "version": "4.150.0",
3
+ "version": "4.150.1",
4
4
  "type": "module",
5
5
  "description": "Agent-first open-source AEO operating platform - track how answer engines cite your domain",
6
6
  "license": "FSL-1.1-ALv2",
@@ -72,20 +72,20 @@
72
72
  "@ainyc/canonry-contracts": "0.0.0",
73
73
  "@ainyc/canonry-db": "0.0.0",
74
74
  "@ainyc/canonry-integration-bing": "0.0.0",
75
- "@ainyc/canonry-integration-openai-ads": "0.0.0",
76
75
  "@ainyc/canonry-integration-cloud-run": "0.0.0",
77
76
  "@ainyc/canonry-integration-commoncrawl": "0.0.0",
78
77
  "@ainyc/canonry-integration-google": "0.0.0",
78
+ "@ainyc/canonry-integration-openai-ads": "0.0.0",
79
79
  "@ainyc/canonry-integration-google-business-profile": "0.0.0",
80
- "@ainyc/canonry-integration-traffic": "0.0.0",
81
80
  "@ainyc/canonry-integration-google-places": "0.0.0",
81
+ "@ainyc/canonry-integration-traffic": "0.0.0",
82
82
  "@ainyc/canonry-integration-wordpress": "0.0.0",
83
83
  "@ainyc/canonry-intelligence": "0.0.0",
84
+ "@ainyc/canonry-provider-cdp": "0.0.0",
84
85
  "@ainyc/canonry-provider-claude": "0.0.0",
86
+ "@ainyc/canonry-provider-gemini": "0.0.0",
85
87
  "@ainyc/canonry-provider-local": "0.0.0",
86
- "@ainyc/canonry-provider-cdp": "0.0.0",
87
88
  "@ainyc/canonry-provider-openai": "0.0.0",
88
- "@ainyc/canonry-provider-gemini": "0.0.0",
89
89
  "@ainyc/canonry-provider-perplexity": "0.0.0"
90
90
  },
91
91
  "scripts": {
@@ -1 +0,0 @@
1
- import{c as n}from"./index-BMymPeRH.js";const c=[["path",{d:"m15 18-6-6 6-6",key:"1wnfg3"}]],d=n("chevron-left",c);const i=[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]],v=n("refresh-cw",i),f={contentStyle:{backgroundColor:"var(--chart-tooltip-bg, #18181b)",border:"1px solid var(--chart-tooltip-border, #3f3f46)",borderRadius:8,fontSize:12},labelStyle:{color:"var(--chart-tooltip-label, #e4e4e7)"},itemStyle:{color:"var(--chart-tooltip-item, #a1a1aa)"}},u={fill:"var(--chart-neutral-text-dim, #71717a)",fontSize:11},l="var(--chart-grid, #27272a)",b="var(--chart-axis, #27272a)",r=["var(--chart-series-1, #34d399)","var(--chart-series-2, #60a5fa)","var(--chart-series-3, #f472b6)","var(--chart-series-4, #facc15)","var(--chart-series-5, #a78bfa)","var(--chart-series-6, #fb923c)","var(--chart-series-7, #22d3ee)","var(--chart-series-8, #f87171)"],s={gemini:"#60a5fa",openai:"#34d399",claude:"#fb923c",perplexity:"#22d3ee",local:"#a78bfa"};function m(a,t=0){return s[a]??r[t%r.length]}const p={text:"var(--chart-neutral-text, #a1a1aa)",textDim:"var(--chart-neutral-text-dim, #71717a)",textFaint:"var(--chart-neutral-text-faint, #52525b)",surface:"var(--chart-neutral-surface, #27272a)",trackSubtle:"var(--chart-neutral-track-subtle, rgb(255 255 255 / 0.04))",gridLine:"var(--chart-neutral-grid-line, rgb(255 255 255 / 0.06))"},S={positive:"var(--chart-tone-positive, #34d399)",positiveDeep:"var(--chart-tone-positive-deep, #10b981)",caution:"var(--chart-tone-caution, #fbbf24)",negative:"var(--chart-tone-negative, #fb7185)"};function g(a){return a}function o(a){const t=/^(\d{4})-(\d{2})-(\d{2})/.exec(a);return t?{year:Number(t[1]),month:Number(t[2]),day:Number(t[3])}:null}function R(a){const t=String(a),e=o(t);return e?new Date(Date.UTC(e.year,e.month-1,e.day)).toLocaleDateString(void 0,{timeZone:"UTC",month:"short",day:"numeric",year:"numeric"}):t}function C(a){const t=o(String(a));return t?`${t.month}/${t.day}`:String(a)}function T(a){return new Date(a).toLocaleDateString(void 0,{month:"short",day:"numeric",year:"numeric"})}function y(a){const t=new Date(a);return`${t.getMonth()+1}/${t.getDate()}`}export{d as C,v as R,b as a,u as b,R as c,f as d,p as e,C as f,r as g,S as h,l as i,y as j,T as k,g as o,m as p};
@@ -1 +0,0 @@
1
- import{C as te,r as v,u as T,D as ne,j as e,L as q}from"./vendor-tanstack-BjS7iY3g.js";import{bL as ae,bS as re,d2 as ie,d3 as oe,bY as le,bM as de,B as b,T as g,I as C,d4 as ce,m as B}from"./index-BMymPeRH.js";import{m as he}from"./v2-overview-adapter-BHmxTmCf.js";import{A as xe}from"./arrow-left-DzZGGujh.js";import"./vendor-radix-DnzzbllM.js";import"./vendor-recharts-33ACLxsD.js";import"./vendor-markdown-CpDJch4G.js";const F=50,l={branded:{headline:"When they know your name",technical:"Branded questions"},"non-brand":{headline:"When they don't",technical:"Non-brand questions"}},me={plan_v1:"Setup update required",no_completed_run:"No completed measurement yet",no_population:"No questions of this type are assigned",evidence_incomplete:"Source evidence is incomplete",not_applicable:"Not applicable for this Property"},O={complete:{label:"Measured",tone:"positive"},partial:{label:"Partly measured",tone:"caution"},running:{label:"Measuring now",tone:"neutral"},queued:{label:"Measurement queued",tone:"neutral"},failed:{label:"Measurement failed",tone:"negative"},not_measured:{label:"Not measured",tone:"neutral"}},V={assigned:{label:"Matches this Property",tone:"positive"},sibling:{label:"Matches another Property",tone:"caution"},ownedUnmapped:{label:"Site URL not in a Property",tone:"caution"},external:{label:"External URL",tone:"neutral"},ambiguous:{label:"Matches multiple Properties",tone:"caution"},invalid:{label:"Invalid URL",tone:"negative"}};function pe(s){return[...s].sort((n,a)=>+(a.classification==="assigned")-+(n.classification==="assigned"))}function ue(s){return`${s.expectedSlotId}:${s.usageEdgeId}`}function je({row:s}){return s.mentioned===null?e.jsxs("span",{className:"inline-flex flex-col items-start gap-0.5",children:[e.jsx(g,{tone:"neutral",children:"Not measured"}),e.jsx("span",{className:"text-xs text-muted",children:"No mention signal for this Property"})]}):e.jsx(g,{tone:s.mentioned?"positive":"neutral",children:s.mentioned?"Mentioned":"Not mentioned"})}const ye="—";function be({row:s}){return s.cited===null?e.jsxs("span",{className:"inline-flex flex-col items-start gap-0.5",children:[e.jsx(g,{tone:"neutral",children:"Not measured"}),e.jsx("span",{className:"text-xs text-muted",children:"Sources were not fully captured"})]}):e.jsx(g,{tone:s.cited?"positive":"neutral",children:s.cited?"Cited":"Not cited"})}function ge({row:s}){return s.cited===null&&s.sources.length===0?e.jsx("p",{className:"py-2 text-sm text-secondary",children:"The sources for this answer were not fully captured, so none can be shown."}):s.sources.length===0?e.jsx("p",{className:"py-2 text-sm text-secondary",children:"This answer returned no source URLs at all."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"evidence-table min-w-[420px]",children:[e.jsxs("caption",{className:"sr-only",children:["Source URLs for ",s.queryText]}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Match"}),e.jsx("th",{children:"URL"})]})}),e.jsx("tbody",{children:pe(s.sources).map(n=>e.jsxs("tr",{children:[e.jsx("td",{children:e.jsx(g,{tone:V[n.classification].tone,children:V[n.classification].label})}),e.jsx("td",{className:"break-all text-secondary",children:n.sourceUrl})]},n.sourceUrl))})]})})}function K(s){return me[s.reason]??"Not measured"}function L({metric:s,emphasis:n=!1}){if(s.state==="unavailable")return e.jsxs("span",{className:"inline-flex flex-col gap-0.5",children:[e.jsx("span",{className:n?"text-lg font-semibold text-secondary":"text-sm font-medium text-secondary",children:"Not measured"}),e.jsx("span",{className:"text-sm text-secondary",children:K(s)})]});const a=`${Math.round(s.value*100)}%`,c=s.numerator===void 0||s.denominator===void 0?null:`${s.numerator} of ${s.denominator}`;return e.jsxs("span",{className:"inline-flex flex-col gap-0.5 tabular-nums",children:[e.jsx("span",{className:n?"text-lg font-semibold text-heading":"text-sm font-medium text-primary",children:a}),c?e.jsx("span",{className:"text-xs text-muted",children:c}):null]})}function z(s,n,a){return ce({client:B,path:{name:s},query:{scope:"property",targetKey:n,queryClass:a}})}function D(s){return s?.properties.items.at(0)}function fe({branded:s,nonBrand:n,brandedError:a,nonBrandError:c,onRetry:w}){const S=[{queryClass:"branded",row:s,isError:a},{queryClass:"non-brand",row:n,isError:c}];return e.jsxs("section",{"aria-labelledby":"property-brand-contrast",children:[e.jsx("div",{className:"section-head section-head-inline",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"The gap"}),e.jsxs("h2",{id:"property-brand-contrast",className:"text-base font-semibold text-heading",children:["Named versus not named",e.jsx(C,{text:"Branded questions already contain your name, so an answer engine has an easy path back to you. Non-brand questions describe the need instead, and that is the demand you have to earn. Each row is measured only over the questions assigned to this Property in that class; a class with no assigned question reads Not measured rather than 0%."})]})]})}),e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[560px]",children:[e.jsx("caption",{className:"sr-only",children:"Mention and citation coverage for this Property, split by question class"}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Question type"}),e.jsx("th",{children:"Mentioned in the answer"}),e.jsx("th",{children:"Cited as a source"})]})}),e.jsx("tbody",{children:S.map(({queryClass:r,row:d,isError:x})=>e.jsxs("tr",{children:[e.jsxs("td",{children:[e.jsx("span",{className:"block font-medium text-heading",children:l[r].headline}),e.jsx("span",{className:"mt-0.5 block text-xs text-muted",children:l[r].technical}),d&&x?e.jsxs("span",{className:"mt-2 flex flex-wrap items-center gap-2 text-sm text-caution",children:[e.jsx("span",{role:"status",children:"Refresh failed."}),e.jsxs(b,{type:"button",size:"sm",variant:"ghost",className:"h-11 px-3 text-sm md:h-11",onClick:()=>w(r),children:["Retry ",l[r].technical.toLocaleLowerCase()]})]}):null]}),d?e.jsxs(e.Fragment,{children:[e.jsx("td",{children:e.jsx(L,{metric:d.mentionCoverage,emphasis:!0})}),e.jsx("td",{children:e.jsx(L,{metric:d.citationCoverage,emphasis:!0})})]}):x?e.jsx("td",{colSpan:2,children:e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-secondary",children:[e.jsxs("span",{role:"alert",children:["Could not load ",l[r].technical.toLocaleLowerCase(),"."]}),e.jsxs(b,{type:"button",size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",onClick:()=>w(r),children:["Retry ",l[r].technical.toLocaleLowerCase()]})]})}):e.jsxs(e.Fragment,{children:[e.jsx("td",{children:e.jsx("span",{className:"text-sm text-secondary",children:"Loading…"})}),e.jsx("td",{children:e.jsx("span",{className:"text-sm text-secondary",children:"Loading…"})})]})]},r))})]})})]})}function ve({row:s,queryClass:n,isError:a}){return e.jsxs("section",{"aria-labelledby":"property-providers",className:"page-section-divider",children:[e.jsx("div",{className:"section-head section-head-inline",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"By answer engine"}),e.jsxs("h2",{id:"property-providers",className:"text-base font-semibold text-heading",children:["Which engines answer for this Property",e.jsx(C,{text:"Each row is measured over the questions that engine actually answered for this Property, so the rows are a split of the same population rather than parts that add up to the Property total. An engine that answered nothing for this Property is absent instead of shown at 0%."})]})]})}),s===void 0&&a?e.jsxs("p",{className:"text-sm text-secondary",children:["Details for ",l[n].technical.toLocaleLowerCase()," are unavailable. Retry that question type above."]}):s===void 0?e.jsx("p",{className:"text-sm text-secondary",children:"Loading…"}):s.providers.length===0?e.jsxs("p",{className:"text-sm text-secondary",children:["No answer engine has measured ",l[n].technical.toLocaleLowerCase()," for this Property.",s.mentionCoverage.state==="unavailable"?` ${K(s.mentionCoverage)}.`:""]}):e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[520px]",children:[e.jsx("caption",{className:"sr-only",children:"Per-engine mention and citation coverage"}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Engine"}),e.jsx("th",{children:"Mentioned"}),e.jsx("th",{children:"Cited"})]})}),e.jsx("tbody",{children:s.providers.map(c=>e.jsxs("tr",{children:[e.jsx("td",{className:"font-medium text-heading",children:c.provider}),e.jsx("td",{children:e.jsx(L,{metric:c.mentionCoverage})}),e.jsx("td",{children:e.jsx(L,{metric:c.citationCoverage})})]},c.provider))})]})})]})}function Ne({questions:s,queryClass:n}){return e.jsxs("section",{"aria-labelledby":"property-questions",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Questions"}),e.jsxs("h2",{id:"property-questions",className:"text-base font-semibold text-heading",children:[l[n].technical," assigned to this Property"]})]}),e.jsxs("p",{className:"supporting-copy",children:[s.length," assigned"]})]}),s.length===0?e.jsxs("p",{className:"text-sm text-secondary",children:["No ",l[n].technical.toLocaleLowerCase()," are assigned. Add one in advanced measurement setup to measure this class."]}):e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[420px]",children:[e.jsx("caption",{className:"sr-only",children:"Questions assigned to this Property"}),e.jsx("thead",{children:e.jsx("tr",{children:e.jsx("th",{children:"Question"})})}),e.jsx("tbody",{children:s.map(a=>e.jsx("tr",{children:e.jsx("td",{className:"text-secondary",children:a})},a))})]})})]})}function we({urls:s}){return e.jsxs("section",{"aria-labelledby":"property-urls",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Pages"}),e.jsxs("h2",{id:"property-urls",className:"text-base font-semibold text-heading",children:["URLs that count as this Property",e.jsx(C,{text:"A cited source URL is credited to this Property when it matches one of these. The most specific matcher wins, so a URL covered by two Properties at the same specificity is flagged for review instead of being credited to either."})]})]}),e.jsxs("p",{className:"supporting-copy",children:[s.length," configured"]})]}),s.length===0?e.jsx("p",{className:"text-sm text-secondary",children:"No URLs are configured for this Property."}):e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[420px]",children:[e.jsx("caption",{className:"sr-only",children:"URL matchers configured for this Property"}),e.jsx("thead",{children:e.jsx("tr",{children:e.jsx("th",{children:"URL"})})}),e.jsx("tbody",{children:s.map(n=>e.jsx("tr",{children:e.jsx("td",{className:"break-all text-secondary",children:n})},n))})]})})]})}function ke(){const{projectName:s,targetKey:n}=te({strict:!1}),[a,c]=v.useState("non-brand"),[w,S]=v.useState(new Set),r=s??"",d=n??"",x=!!r&&!!d,{canWrite:M}=ae(),f=T({...re({client:B,path:{name:r}}),enabled:x}),m=T({...z(r,d,"branded"),enabled:x}),p=T({...z(r,d,"non-brand"),enabled:x}),U=D(m.data),I=D(p.data),u=a==="branded"?m.data:p.data,N=a==="branded"?U:I,_=(a==="branded"?m.isError:p.isError)&&N===void 0,Q=u?.measurement.displayedRunId,P={client:B,path:{name:r},query:{targetKey:d,queryClass:a,shape:ie.answers,limit:F,...Q?{runId:Q}:{}}},i=ne({...oe(P),enabled:x&&u!==void 0,initialPageParam:P,getNextPageParam:t=>t.answers?.nextCursor?{path:P.path,query:{...P.query,cursor:t.answers.nextCursor}}:void 0}),R=f.data?.active??null,j=R?.plan.schemaVersion===2?R.plan:null,W=R!==null&&j===null,E=j?.targets.find(t=>t.stableKey===d)??null,H=v.useMemo(()=>{if(!j)return[];const t=new Map(j.querySnapshots.map(o=>[o.queryId,o.queryText]));return[...new Set(j.assignments.filter(o=>o.targetKey===d&&o.queryClass===a).flatMap(o=>{const h=t.get(o.queryId);return h===void 0?[]:[h]}))].sort((o,h)=>o.localeCompare(h))},[j,d,a]),G=v.useMemo(()=>E?.urlMatchers.map(he)??[],[E]),y=v.useMemo(()=>(i.data?.pages??[]).flatMap(h=>h.answers?.items??[]),[i.data]),$=i.data?.pages[0]?.answers?.totalEstimate??y.length,Y=(i.data?.pages??[]).length>0&&(i.data?.pages??[]).every(t=>t.answers===void 0),Z=i.data?.pages[0]?.measurement.state,A=e.jsxs(q,{to:"/projects/$projectName",params:{projectName:r},className:"inline-flex items-center gap-1 text-xs text-muted hover:text-strong",children:[e.jsx(xe,{className:"size-3.5","aria-hidden":"true"}),"Back to measurement overview"]});if(!x)return e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-muted",children:"Missing project name or Property key in URL."})});if(!le("portfolio",de()?.projectTabs))return e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-muted",children:"This view is not available here."})});if(f.isPending&&!f.isError)return e.jsx("div",{className:"page-container",children:e.jsxs("div",{role:"status","aria-live":"polite",children:[e.jsx("span",{className:"sr-only",children:"Loading Property"}),e.jsx("div",{className:"h-32 animate-pulse rounded-md bg-surface-subtle","aria-hidden":"true"})]})});const J=f.isError&&f.data===void 0,X=m.isError&&m.data===void 0,ee=p.isError&&p.data===void 0;return J||X&&ee?e.jsxs("div",{className:"page-container space-y-3",children:[A,e.jsx("p",{role:"alert",className:"text-sm text-negative",children:"Could not load this Property."}),e.jsx(b,{type:"button",size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",onClick:()=>{f.refetch(),m.refetch(),p.refetch()},children:"Try again"})]}):!j||!E?e.jsxs("div",{className:"page-container space-y-3",children:[A,e.jsx("p",{role:"status",className:"text-sm text-secondary",children:j?"This Property is not in the published setup. It may have been renamed or removed.":"A Property page needs a published advanced measurement setup. Republish setup from the project Portfolio tab."}),e.jsx(b,{asChild:!0,type:"button",variant:"outline",className:"h-11 px-4 text-sm md:h-11",children:e.jsx(q,{to:"/projects/$projectName/portfolio",params:{projectName:r},children:M?W?"Republish setup":"Open measurement setup":"View measurement setup"})})]}):e.jsxs("div",{className:"page-container space-y-8",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[A,e.jsx("h1",{className:"page-title mt-2",children:E.label}),e.jsxs("p",{className:"page-subtitle",children:["Property in ",r]})]}),e.jsxs("div",{className:"page-header-right",children:[u?e.jsx(g,{tone:O[u.measurement.state].tone,children:O[u.measurement.state].label}):null,N&&N.flags>0?e.jsxs(g,{tone:"caution",children:[N.flags," flagged"]}):null]})]}),e.jsx(fe,{branded:U,nonBrand:I,brandedError:m.isError,nonBrandError:p.isError,onRetry:t=>{t==="branded"?m.refetch():p.refetch()}}),u&&(u.measurement.state==="not_measured"||u.nextAction.kind==="run_measurement")?e.jsxs("section",{className:"flex flex-wrap items-center justify-between gap-3 border-y border-default py-4","aria-label":"Measurement next step",children:[e.jsx("p",{className:"text-sm text-secondary",children:M?"Run a measurement from the project overview to collect this Property’s coverage and source evidence.":"This Property needs a new measurement before coverage and source evidence are available."}),e.jsx(b,{asChild:!0,type:"button",className:"h-11 px-4 text-sm md:h-11",children:e.jsx(q,{to:"/projects/$projectName",params:{projectName:r},children:M?"Go to measurement overview":"View measurement overview"})})]}):null,e.jsxs("div",{className:"flex flex-wrap items-end gap-4 border-y border-default py-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("label",{htmlFor:"property-query-class",className:"block text-sm font-medium text-heading",children:"Question type"}),e.jsxs("select",{id:"property-query-class",value:a,onChange:t=>c(t.target.value==="branded"?"branded":"non-brand"),className:"h-11 rounded-md border border-default bg-surface px-3 text-sm text-primary focus:outline-none focus:ring-2 focus:ring-mono-400",children:[e.jsx("option",{value:"non-brand",children:l["non-brand"].technical}),e.jsx("option",{value:"branded",children:l.branded.technical})]})]}),e.jsxs("p",{className:"supporting-copy",children:["Everything below is measured over ",l[a].technical.toLocaleLowerCase()," only."]})]}),e.jsx(ve,{row:N,queryClass:a,isError:_}),e.jsx(Ne,{questions:H,queryClass:a}),e.jsx(we,{urls:G}),e.jsxs("section",{"aria-labelledby":"property-evidence",className:"page-section-divider",children:[e.jsxs("div",{className:"section-head section-head-inline",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Evidence"}),e.jsxs("h2",{id:"property-evidence",className:"text-base font-semibold text-heading",children:["Answers the engines gave",e.jsx(C,{text:"One row per answer an engine gave for the questions assigned to this Property in the displayed measurement. Mentioned and cited are independent: an answer can name this Property without linking it, or link it without naming it. Answers that did neither are listed first, because those are what a gap is made of. Where the answer text was not stored the mention reads Not measured, never a zero. Expand a row for the source URLs the engine returned, this Property's own first."})]})]}),y.length>0?e.jsxs("p",{className:"supporting-copy",children:[y.length," of ",$]}):null]}),_?e.jsxs("p",{className:"text-sm text-secondary",children:["Evidence for ",l[a].technical.toLocaleLowerCase()," is unavailable. Retry that question type above."]}):i.isPending&&y.length===0?e.jsx("p",{className:"text-sm text-secondary",children:"Loading evidence…"}):i.isError&&y.length===0?e.jsxs("div",{className:"flex flex-wrap items-center gap-3 text-sm text-secondary",children:[e.jsx("span",{role:"alert",children:"Evidence could not be loaded."}),e.jsx(b,{type:"button",size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",onClick:()=>{i.refetch()},children:"Retry evidence"})]}):Z==="not_measured"?e.jsx("p",{className:"text-sm text-secondary",children:"Not measured yet. Run a measurement to collect the answers for this Property."}):Y?e.jsx("p",{role:"alert",className:"text-sm text-caution",children:"This measurement was returned in an older format, so the answers cannot be shown here. The numbers above are unaffected."}):y.length===0?e.jsx("p",{className:"text-sm text-secondary",children:"No answers matched this Property in the displayed measurement."}):e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"overflow-x-auto rounded-md border border-default",children:e.jsxs("table",{className:"evidence-table min-w-[720px]",children:[e.jsx("caption",{className:"sr-only",children:"Answers measured for this Property"}),e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{children:"Question"}),e.jsx("th",{children:"Mentioned in the answer"}),e.jsx("th",{children:"Cited as a source"}),e.jsx("th",{children:"Sources"}),e.jsx("th",{children:e.jsx("span",{className:"sr-only",children:"Sources detail"})})]})}),e.jsx("tbody",{children:y.map(t=>{const o=ue(t),h=w.has(o);return e.jsxs(v.Fragment,{children:[e.jsxs("tr",{children:[e.jsxs("td",{className:"text-secondary",children:[e.jsx("span",{className:"block",children:t.queryText}),e.jsx("span",{className:"mt-1 block text-xs text-muted",children:[t.provider,t.location].filter(Boolean).join(" · ")}),t.historical||t.bridged?e.jsx("span",{className:"mt-1 flex",children:e.jsx(g,{tone:"caution",children:"Historical"})}):null]}),e.jsx("td",{children:e.jsx(je,{row:t})}),e.jsx("td",{children:e.jsx(be,{row:t})}),e.jsx("td",{className:"tabular-nums text-secondary",children:t.cited===null?ye:t.sources.length}),e.jsx("td",{className:"text-right",children:e.jsx(b,{type:"button",size:"sm",variant:"ghost","aria-expanded":h,onClick:()=>S(se=>{const k=new Set(se);return k.delete(o)||k.add(o),k}),children:h?`Hide sources for ${t.queryText}`:`Show sources for ${t.queryText}`})})]}),h?e.jsx("tr",{children:e.jsx("td",{colSpan:5,className:"bg-surface-subtle px-4",children:e.jsx(ge,{row:t})})}):null]},o)})})]})}),i.hasNextPage?e.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-3 text-sm text-secondary",children:[e.jsxs("span",{children:["Showing ",y.length," of ",$]}),i.isFetchNextPageError?e.jsx("span",{role:"alert",children:"Could not load more evidence."}):null,e.jsx(b,{size:"sm",variant:"outline",className:"h-11 px-4 text-sm md:h-11",disabled:i.isFetchingNextPage,onClick:()=>{i.fetchNextPage()},children:i.isFetchingNextPage?"Loading…":i.isFetchNextPageError?"Retry more evidence":`Show ${F} more`})]}):null]})]})]})}export{ke as MeasurementPropertyPage};
@@ -1 +0,0 @@
1
- import{j as e,C as Re,E as Ee,r as o,L as $e}from"./vendor-tanstack-BjS7iY3g.js";import{cT as V,cU as i,I as U,T as Fe,i as ae,B as He,f as H,C as Ue,cV as Pe,X as Oe}from"./index-BMymPeRH.js";import{g as Me,h as _e,i as De,t as Be,a as Ke}from"./extract-error-message-Dftl6C6Y.js";import{R as ze,g as Y,i as Ge,a as re,b as ne,d as Ve,C as We}from"./ChartPrimitives-CithLZJb.js";import{R as qe,B as Xe,a as Qe,X as Ye,Y as Ze,T as Je,f as W,g as q}from"./vendor-recharts-33ACLxsD.js";import{A as le}from"./arrow-left-DzZGGujh.js";import"./vendor-radix-DnzzbllM.js";import"./vendor-markdown-CpDJch4G.js";const et=[{value:"all",label:"All status"},{value:"2xx",label:"2xx success"},{value:"3xx",label:"3xx redirect"},{value:"4xx",label:"4xx client error"},{value:"5xx",label:"5xx server error"}],he=[{value:"all",label:"All claims"},{value:V.verified,label:"Verified"},{value:V.claimed_unverified,label:"Claimed unverified"},{value:V.unknown_ai_like,label:"Unknown AI-like"}];function tt(s){return s==="all"?null:Number.parseInt(s[0],10)}function fe(s){switch(s.kind){case i.crawler:case i["ai-user-fetch"]:return s.botId;case i["ai-referral"]:return s.product}}function pe(s){switch(s.kind){case i.crawler:case i["ai-user-fetch"]:return s.pathNormalized;case i["ai-referral"]:return s.landingPathNormalized}}function st(s){switch(s.kind){case i.crawler:case i["ai-user-fetch"]:return s.verificationStatus;case i["ai-referral"]:return null}}function at(s,a){if(a==="hour")return s;const r=new Date(s),n=r.getFullYear(),u=String(r.getMonth()+1).padStart(2,"0"),h=String(r.getDate()).padStart(2,"0");return`${n}-${u}-${h}`}function rt(s,a,r){const n=a.pathQuery.trim().toLowerCase(),u=tt(a.statusClass);return s.filter(h=>!(a.selectedBucket&&at(h.tsHour,r)!==a.selectedBucket||a.identity&&fe(h)!==a.identity||a.operator&&h.operator!==a.operator||n&&!pe(h).toLowerCase().includes(n)||u!==null&&Math.floor(h.status/100)!==u||a.verification!=="all"&&st(h)!==a.verification))}function nt(s,a){if(!s||typeof s!="object")return null;const r=s.activeTooltipIndex;let n;if(typeof r=="number")n=r;else if(typeof r=="string"&&r!=="")n=Number(r);else return null;return!Number.isInteger(n)||n<0||n>=a.length?null:a[n]?.bucket??null}const P=[{value:60,label:"1h",granularity:"hour",fetchLimit:500},{value:360,label:"6h",granularity:"hour",fetchLimit:500},{value:1440,label:"24h",granularity:"hour",fetchLimit:500},{value:10080,label:"7d",granularity:"hour",fetchLimit:1e3},{value:720*60,label:"30d",granularity:"day",fetchLimit:2e3},{value:2160*60,label:"90d",granularity:"day",fetchLimit:5e3}],ie=P.find(s=>s.label==="24h")??P[2],L=50,oe=Y[0],ce=Y[2],de=Y[1],ue=Pe();function be(s){const a=new Date(s);return`${a.getMonth()+1}/${a.getDate()} ${String(a.getHours()).padStart(2,"0")}:00`}function lt(s){const a=new Date(`${s}T00:00:00`);return`${a.getMonth()+1}/${a.getDate()}`}function xe(s){if(!s)return"never";const a=Date.now()-new Date(s).getTime(),r=Math.floor(a/6e4);if(r<1)return"just now";if(r<60)return`${r}m ago`;const n=Math.floor(r/60);return n<24?`${n}h ago`:`${Math.floor(n/24)}d ago`}function me({canGoBack:s,className:a}){const r="inline-flex items-center gap-1";if(s){const n=()=>{window.history.back()};return e.jsxs("button",{type:"button",onClick:n,className:`${r} ${a??""}`,children:[e.jsx(le,{className:"size-3"})," Back"]})}return e.jsxs($e,{to:"/traffic",className:`${r} ${a??""}`,children:[e.jsx(le,{className:"size-3"})," All sources"]})}function vt(){const s=Re({strict:!1}),a=s.projectName??"",r=Ee(),n=s.sourceId??"",[u,h]=o.useState(ie.value),[f,ye]=o.useState(()=>new Set(["crawler","ai-user-fetch","ai-referral"])),[c,I]=o.useState(null),[p,O]=o.useState(""),[b,M]=o.useState(""),[v,_]=o.useState(""),[N,D]=o.useState("all"),[S,B]=o.useState("all"),[je,K]=o.useState(1),[Z,J]=o.useState(null),[ee,te]=o.useState(null),x=o.useMemo(()=>P.find(t=>t.value===u)??ie,[u]),z=Me(a||null,n||null),g=_e(a||null,{kind:"all",sourceId:n||void 0,sinceMinutes:u,limit:x.fetchLimit,granularity:x.granularity}),A=De(a||null,n||null),l=z.data,w=g.data?.events??[],y=g.data?.totals,R=g.data?.eventRows,E=o.useMemo(()=>w.filter(t=>{switch(t.kind){case i.crawler:return f.has("crawler");case i["ai-user-fetch"]:return f.has("ai-user-fetch");case i["ai-referral"]:return f.has("ai-referral")}}),[w,f]),ve=o.useMemo(()=>{const t=new Set;for(const d of w)t.add(fe(d));return p&&t.add(p),[...t].sort((d,m)=>d.localeCompare(m))},[w,p]),Ne=o.useMemo(()=>{const t=new Set;for(const d of w)t.add(d.operator);return b&&t.add(b),[...t].sort((d,m)=>d.localeCompare(m))},[w,b]),j=o.useMemo(()=>rt(E,{selectedBucket:c,identity:p,operator:b,pathQuery:v,statusClass:N,verification:S},x.granularity),[E,c,p,b,v,N,S,x.granularity]);o.useEffect(()=>{K(1)},[E,c,p,b,v,N,S]);const $=Math.max(1,Math.ceil(j.length/L)),F=Math.min(Math.max(1,je),$),T=(F-1)*L,Se=o.useMemo(()=>j.slice(T,T+L),[j,T]),we=j.length>L,Ce=j.length===0?0:T+1,ke=Math.min(T+L,j.length),se=o.useMemo(()=>c?ge(c,x.granularity):null,[c,x.granularity]),C=o.useMemo(()=>it(g.data?.series.points??[],x.granularity),[g.data?.series.points,x.granularity]),G=t=>{ye(d=>{const m=new Set(d);return m.has(t)?m.size>1&&m.delete(t):m.add(t),m})},Te=t=>{const d=nt(t,C);d&&I(m=>m===d?null:d)},Le=()=>{I(null),O(""),M(""),_(""),D("all"),B("all")},Ie=!!(c||p||b||v.trim()||N!=="all"||S!=="all"),Ae=async()=>{J(null),te(null);try{const t=await A.mutateAsync({sinceMinutes:60});te(`Pulled ${t.pulledEvents} entries · ${t.crawlerHits} crawler · ${t.aiUserFetchHits} AI user fetch · ${t.aiReferralHits} AI referral · ${t.unknownHits} unknown`)}catch(t){J(Ke(t))}};return!a||!n?e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-muted",children:"Missing project name or source id in URL."})}):z.isLoading?e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-muted",children:"Loading source…"})}):z.isError||!l?e.jsxs("div",{className:"page-container",children:[e.jsx("p",{className:"text-sm text-negative",children:"Could not load this source."}),e.jsx(me,{canGoBack:r,className:"mt-2 text-xs text-secondary hover:text-strong"})]}):e.jsxs("div",{className:"page-container space-y-8",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[e.jsx(me,{canGoBack:r,className:"text-xs text-muted hover:text-strong"}),e.jsx("h1",{className:"page-title mt-2",children:l.displayName}),e.jsxs("p",{className:"page-subtitle",children:[l.sourceType," source for ",a]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Fe,{tone:Be(l.status),children:l.status}),!ae()&&e.jsxs(He,{type:"button",variant:"outline",size:"sm",disabled:A.isPending,onClick:()=>{Ae()},children:[e.jsx(ze,{className:`size-3.5 ${A.isPending?"animate-spin":""}`}),A.isPending?"Syncing…":"Sync now"]})]})]}),Z?e.jsx("div",{className:"rounded-md border border-negative-800/50 bg-negative-950/30 px-3 py-2 text-sm text-negative-200",children:Z}):null,ee?e.jsx("div",{className:"rounded-md border border-positive-800/50 bg-positive-950/30 px-3 py-2 text-sm text-positive-200",children:ee}):null,e.jsxs("section",{"aria-labelledby":"traffic-24h-heading",children:[e.jsx("h2",{id:"traffic-24h-heading",className:"mb-3 text-sm font-medium text-heading",children:"Last 24 hours"}),e.jsxs("div",{className:"grid grid-cols-1 divide-y divide-default border-y border-default sm:grid-cols-3 sm:divide-x sm:divide-y-0",children:[e.jsx(Q,{label:"Content crawls",value:l.totals24h.crawlerContentHits,tooltip:`Content and document paths only. Excludes sitemap ${l.totals24h.crawlerSegments.sitemap.toLocaleString("en-US")}, robots ${l.totals24h.crawlerSegments.robots.toLocaleString("en-US")}, assets ${l.totals24h.crawlerSegments.asset.toLocaleString("en-US")}, and ${l.totals24h.crawlerSegments.other.toLocaleString("en-US")} other requests such as feeds, API paths, or downloads. Total crawler hits: ${l.totals24h.crawlerHits.toLocaleString("en-US")}.`}),e.jsx(Q,{label:"AI user fetches",value:l.totals24h.aiUserFetchHits,tooltip:"ChatGPT-User/Perplexity-User fetches initiated by a real user in an AI surface."}),e.jsx(Q,{label:"AI referral sessions",value:l.totals24h.aiReferralHits,tooltip:"Browser click-throughs from AI surfaces, identified by Referer or UTM evidence."})]})]}),e.jsxs("section",{children:[e.jsx("p",{className:"eyebrow mb-4",children:"Latest sync run"}),l.latestRun?e.jsxs(H,{className:"p-4 text-sm",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-x-6 gap-y-1.5",children:[e.jsxs("span",{className:"text-heading",children:["Status: ",e.jsx("span",{className:"font-medium",children:l.latestRun.status})]}),e.jsxs("span",{className:"text-muted",children:["Started: ",xe(l.latestRun.startedAt)]}),l.latestRun.finishedAt?e.jsxs("span",{className:"text-muted",children:["Finished: ",xe(l.latestRun.finishedAt)]}):null]}),e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-secondary hover:text-strong",children:"Run details"}),e.jsx("code",{className:"mt-2 block text-xs text-muted",children:l.latestRun.runId})]}),l.latestRun.error?e.jsx("p",{className:"mt-2 rounded border border-negative-900/40 bg-negative-950/30 px-3 py-2 text-xs text-negative",children:l.latestRun.error}):null]}):e.jsx(H,{className:"px-4 py-3 text-sm text-muted",children:ae()?"No traffic-sync runs recorded yet.":'No traffic-sync runs recorded yet. Hit "Sync now" above to create one.'})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-x-4 gap-y-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted",children:"Events"}),e.jsx("h2",{className:"mt-1 text-base font-semibold text-primary",children:x.granularity==="day"?"Daily rollups":"Hourly rollups"}),y?e.jsxs("p",{className:"mt-1.5 text-xs text-muted",children:[y.crawlerContentHits.toLocaleString("en-US")," content crawls ·"," ",y.crawlerInfraHits.toLocaleString("en-US")," infra (sitemap/robots/assets) ·"," ",y.aiUserFetchHits.toLocaleString("en-US")," AI user fetches ·"," ",y.aiReferralHits.toLocaleString("en-US")," AI referral sessions · last ",x.label," · ",ue]}):null]}),e.jsx("div",{className:"inline-flex rounded-md border border-base p-0.5",role:"toolbar","aria-label":"Window",children:P.map(t=>e.jsx("button",{type:"button",className:`rounded px-2.5 py-1 text-xs ${u===t.value?"bg-bg-elevated text-heading":"text-secondary hover:text-strong"}`,"aria-pressed":u===t.value,onClick:()=>{h(t.value),I(null)},children:t.label},t.value))})]}),e.jsxs(H,{className:"p-4",children:[e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",role:"toolbar","aria-label":"Series",children:[e.jsx(X,{label:"Crawler",color:oe,count:y?.crawlerHits??0,active:f.has("crawler"),onToggle:()=>G("crawler")}),e.jsx(X,{label:"AI user fetches",color:ce,count:y?.aiUserFetchHits??0,active:f.has("ai-user-fetch"),onToggle:()=>G("ai-user-fetch")}),e.jsx(X,{label:"AI referral sessions",color:de,count:y?.aiReferralHits??0,active:f.has("ai-referral"),onToggle:()=>G("ai-referral")})]}),g.isError?e.jsxs("p",{className:"py-12 text-center text-xs text-negative-400",children:["Failed to load events: ",g.error instanceof Error?g.error.message:"Unknown error"]}):g.isLoading?e.jsx("p",{className:"py-12 text-center text-xs text-muted",children:"Loading events…"}):C.length===0?e.jsx("p",{className:"py-12 text-center text-xs text-muted",children:"No events in this window."}):e.jsx("div",{className:"h-72",children:e.jsx(qe,{children:e.jsxs(Xe,{data:C,margin:{top:4,right:4,bottom:0,left:0},onClick:Te,style:{cursor:"pointer"},children:[e.jsx(Qe,{stroke:Ge,strokeDasharray:"3 3"}),e.jsx(Ye,{dataKey:"label",tick:ne,stroke:re,interval:"preserveStartEnd",minTickGap:x.granularity==="day"?24:32}),e.jsx(Ze,{tick:ne,stroke:re,allowDecimals:!1}),e.jsx(Je,{...Ve}),f.has("crawler")?e.jsx(W,{dataKey:"crawler",name:"Crawler",fill:oe,stackId:"a",children:C.map(t=>e.jsx(q,{fillOpacity:c&&c!==t.bucket?.25:1},t.bucket))}):null,f.has("ai-user-fetch")?e.jsx(W,{dataKey:"aiUserFetch",name:"AI user fetch",fill:ce,stackId:"a",children:C.map(t=>e.jsx(q,{fillOpacity:c&&c!==t.bucket?.25:1},t.bucket))}):null,f.has("ai-referral")?e.jsx(W,{dataKey:"aiReferral",name:"AI referral",fill:de,stackId:"a",children:C.map(t=>e.jsx(q,{fillOpacity:c&&c!==t.bucket?.25:1},t.bucket))}):null]})})})]})]}),e.jsxs("section",{children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-end justify-between gap-x-4 gap-y-2",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-[10px] font-semibold uppercase tracking-wider text-muted",children:"Event rows"}),e.jsxs("p",{className:"mt-1 text-xs text-muted",children:["Showing ",e.jsx("span",{className:"tabular-nums text-neutral",children:j.length.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"tabular-nums text-muted",children:E.length.toLocaleString("en-US")})," ",R?.truncated?"loaded events":"events",R?.truncated?e.jsxs(e.Fragment,{children:[" ","· loaded ",e.jsx("span",{className:"tabular-nums text-neutral",children:R.returned.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"tabular-nums text-muted",children:R.total.toLocaleString("en-US")})," rows"]}):null," ","· ",ue]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("span",{className:"inline-flex items-center text-secondary",children:[e.jsxs("select",{"aria-label":"Filter by identity",value:p,onChange:t=>O(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:[e.jsx("option",{value:"",children:"All identities"}),ve.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(U,{text:"The specific bot or AI product making the request (e.g., GPTBot, ChatGPT-User, Perplexity). One operator usually runs several identities."})]}),e.jsxs("span",{className:"inline-flex items-center text-secondary",children:[e.jsxs("select",{"aria-label":"Filter by operator",value:b,onChange:t=>M(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:[e.jsx("option",{value:"",children:"All operators"}),Ne.map(t=>e.jsx("option",{value:t,children:t},t))]}),e.jsx(U,{text:"The company that runs the bot or product (e.g., OpenAI, Anthropic, Perplexity). Filtering by operator includes every identity under that company."})]}),e.jsx("select",{"aria-label":"Filter by HTTP status class",value:N,onChange:t=>D(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:et.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsx("select",{"aria-label":"Filter by verification claim",value:S,onChange:t=>B(t.target.value),className:"rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:he.map(t=>e.jsx("option",{value:t.value,children:t.label},t.value))}),e.jsx("input",{type:"search","aria-label":"Filter by path",placeholder:"path contains…",value:v,onChange:t=>_(t.target.value),className:"w-44 rounded-md border border-base bg-bg px-2.5 py-1.5 text-xs text-strong placeholder:text-faint focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600"})]})]}),Ie?e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[se?e.jsx(k,{label:`Bucket: ${se}`,onClear:()=>I(null)}):null,p?e.jsx(k,{label:`Identity: ${p}`,onClear:()=>O("")}):null,b?e.jsx(k,{label:`Operator: ${b}`,onClear:()=>M("")}):null,v.trim()?e.jsx(k,{label:`Path: ${v.trim()}`,onClear:()=>_("")}):null,N!=="all"?e.jsx(k,{label:`Status: ${N}`,onClear:()=>D("all")}):null,S!=="all"?e.jsx(k,{label:`Claim: ${ot(S)}`,onClear:()=>B("all")}):null,e.jsx("button",{type:"button",onClick:Le,className:"text-xs text-muted underline-offset-4 hover:text-strong hover:underline",children:"Clear all"})]}):null,e.jsx(xt,{events:Se}),we?e.jsxs("div",{className:"mt-3 flex flex-wrap items-center justify-between gap-x-4 gap-y-2 text-xs text-secondary",children:[e.jsxs("p",{className:"tabular-nums",children:["Showing ",e.jsx("span",{className:"text-neutral",children:Ce.toLocaleString("en-US")}),"–",e.jsx("span",{className:"text-neutral",children:ke.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"text-neutral",children:j.length.toLocaleString("en-US")})," events"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("button",{type:"button",onClick:()=>K(t=>Math.max(1,t-1)),disabled:F<=1,"aria-label":"Previous page",className:"inline-flex items-center gap-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-strong transition hover:border-strong hover:text-primary disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-base disabled:hover:text-strong",children:[e.jsx(We,{className:"size-3.5"}),"Prev"]}),e.jsxs("span",{className:"tabular-nums",children:["Page ",e.jsx("span",{className:"text-strong",children:F})," of"," ",e.jsx("span",{className:"text-strong",children:$})]}),e.jsxs("button",{type:"button",onClick:()=>K(t=>Math.min($,t+1)),disabled:F>=$,"aria-label":"Next page",className:"inline-flex items-center gap-1 rounded-md border border-base bg-bg px-2.5 py-1.5 text-strong transition hover:border-strong hover:text-primary disabled:cursor-not-allowed disabled:opacity-40 disabled:hover:border-base disabled:hover:text-strong",children:["Next",e.jsx(Ue,{className:"size-3.5"})]})]})]}):null]}),e.jsxs("details",{className:"border-t border-default pt-4",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-secondary hover:text-strong",children:"How traffic is classified"}),e.jsx("p",{className:"mt-2 max-w-3xl text-sm text-secondary",children:"Crawler requests, AI user fetches, and referrals are recorded separately. Filters expose the underlying evidence."})]})]})}function ge(s,a){return a==="day"?lt(s):be(s)}function it(s,a){return s.map(r=>({bucket:r.bucket,label:ge(r.bucket,a),crawler:r.crawlerHits,aiUserFetch:r.aiUserFetchHits,aiReferral:r.aiReferralHits}))}function ot(s){return he.find(a=>a.value===s)?.label??s}function k({label:s,onClear:a}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded border border-strong bg-surface-inset px-2.5 py-1 text-sm text-strong",children:[s,e.jsx("button",{type:"button",onClick:a,"aria-label":`Clear ${s}`,className:"rounded p-0.5 text-secondary hover:bg-mono-700/60 hover:text-heading",children:e.jsx(Oe,{className:"size-3"})})]})}function X({label:s,color:a,count:r,active:n,onToggle:u}){return e.jsxs("button",{type:"button",onClick:u,"aria-pressed":n,className:`inline-flex items-center gap-2 rounded border px-3 py-1.5 text-xs font-medium transition ${n?"border-strong bg-surface-inset text-heading":"border-base bg-transparent text-muted hover:text-neutral"}`,children:[e.jsx("span",{"aria-hidden":"true",className:`flex size-3 items-center justify-center rounded-sm border transition-opacity ${n?"border-transparent opacity-100":"border-strong opacity-60"}`,style:n?{backgroundColor:a}:void 0,children:n?"✓":""}),e.jsx("span",{children:s}),e.jsx("span",{className:`tabular-nums ${n?"text-secondary":"text-faint"}`,children:r.toLocaleString("en-US")})]})}function Q({label:s,value:a,tooltip:r}){return e.jsxs("div",{className:"px-4 py-3",children:[e.jsxs("p",{className:"flex items-center gap-1 text-sm text-secondary",children:[s,r?e.jsx(U,{text:r}):null]}),e.jsx("p",{className:"mt-1 text-2xl font-semibold tabular-nums text-heading",children:a.toLocaleString("en-US")})]})}function ct(s){switch(s){case i.crawler:return"Crawler";case i["ai-user-fetch"]:return"AI hit";case i["ai-referral"]:return"AI referral"}}function dt(s){switch(s.kind){case i.crawler:case i["ai-user-fetch"]:return s.botId;case i["ai-referral"]:return s.product}}function ut(s){switch(s.kind){case i.crawler:case i["ai-user-fetch"]:return`${s.verificationStatus} · HTTP ${s.status}`;case i["ai-referral"]:return`${s.evidenceType} · ${s.sourceDomain}`}}function xt({events:s}){return s.length===0?e.jsx(H,{className:"p-6 text-center text-sm text-muted",children:"No event rows match the current filters."}):e.jsx("div",{className:"rounded-xl border border-default bg-surface overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-bg-elevated/50 text-[10px] font-semibold uppercase tracking-wider text-muted",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left",children:"Hour"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Kind"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Identity"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Evidence / status"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Path"}),e.jsx("th",{className:"px-4 py-2 text-right",children:e.jsxs("span",{className:"inline-flex items-center",children:["Hits",e.jsx(U,{text:"Each row is one hour-bucket, not one request. Hits is the number of requests in that hour that shared the same identity, path, HTTP status, and verification claim."})]})})]})}),e.jsx("tbody",{className:"divide-y divide-mono-800/60",children:s.map((a,r)=>e.jsxs("tr",{className:"hover:bg-bg-elevated/40 transition-colors",children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs text-neutral",children:be(a.tsHour)}),e.jsx("td",{className:"px-4 py-2 text-neutral",children:ct(a.kind)}),e.jsxs("td",{className:"px-4 py-2 text-heading",children:[dt(a),e.jsx("span",{className:"ml-2 text-[11px] text-muted",children:a.operator})]}),e.jsx("td",{className:"px-4 py-2 text-neutral",children:ut(a)}),e.jsx("td",{className:"px-4 py-2 truncate font-mono text-xs text-neutral",children:pe(a)}),e.jsx("td",{className:"px-4 py-2 text-right tabular-nums text-heading",children:a.hits})]},`${a.kind}:${a.tsHour}:${r}`))})]})})}export{Q as TrafficKpi,vt as TrafficSourceDetailPage};