@canonry/canonry 4.180.0 → 4.180.2
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/assets/agent-workspace/skills/canonry/references/canonry-cli.md +11 -6
- package/assets/assets/{AuditHistoryPanel-DI6iXS0J.js → AuditHistoryPanel-Cf-jEEKZ.js} +1 -1
- package/assets/assets/{BacklinksPage-DiwTMJTp.js → BacklinksPage-oMcS6Hc_.js} +1 -1
- package/assets/assets/{HistoryPage-BWODoEok.js → HistoryPage-CDQOpxi0.js} +1 -1
- package/assets/assets/{MeasurementPropertyPage-C1uZ9LEl.js → MeasurementPropertyPage-MoKFTmrS.js} +1 -1
- package/assets/assets/{ProjectPage-C-fk0Jja.js → ProjectPage-CtD1AwXE.js} +8 -8
- package/assets/assets/{RunRow-CMSISg-I.js → RunRow-CPekiscK.js} +1 -1
- package/assets/assets/{RunsPage-HZwwLQDE.js → RunsPage-hn05ImCv.js} +1 -1
- package/assets/assets/{SettingsPage-3eoRO4ze.js → SettingsPage-BOTYXtfF.js} +1 -1
- package/assets/assets/{SiteHealthSection-CATUc26x.js → SiteHealthSection-FwMZ11F8.js} +3 -3
- package/assets/assets/{TrafficPage-Cw8AM5VR.js → TrafficPage-f2v6A_uk.js} +1 -1
- package/assets/assets/{TrafficSourceDetailPage-ChFDAstr.js → TrafficSourceDetailPage-nhWRLHiu.js} +1 -1
- package/assets/assets/{extract-error-message-CG_IQ_9c.js → extract-error-message-Cp1YeVEr.js} +1 -1
- package/assets/assets/{index-Dz0ju3qg.js → index-VmxEHABq.js} +22 -22
- package/assets/assets/{react-sigma_core.esm.min-BvgsCKLZ.js → react-sigma_core.esm.min-fnm2MkMi.js} +1 -1
- package/assets/index.html +1 -1
- package/dist/{chunk-QPJC2H6J.js → chunk-44LVINXQ.js} +39 -20
- package/dist/{chunk-A6XDLCKF.js → chunk-4XHQ2GCN.js} +2 -2
- package/dist/{chunk-UD3YJQOV.js → chunk-665YENL2.js} +4 -10
- package/dist/{chunk-3JW762Q4.js → chunk-6IR32MIH.js} +5 -7
- package/dist/{chunk-NFALEGSZ.js → chunk-DA25LOTW.js} +2 -2
- package/dist/cli.js +5 -5
- package/dist/index.js +4 -4
- package/dist/{intelligence-service-WQPUIJO6.js → intelligence-service-RNBODYMZ.js} +2 -2
- package/dist/mcp.js +3 -3
- package/package.json +10 -10
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e,h as V,u as L,f as E,L as U}from"./vendor-tanstack-Dock0eH1.js";import{cV as O,cW as W,cX as I,cY as F,cZ as A,B as N,l as $,c_ as z,bW as B,i as D,j as w,f as S,c$ as H,T as G}from"./index-Dz0ju3qg.js";import{d as J,f as M,g as _,c as T,a as Q,t as K}from"./extract-error-message-CG_IQ_9c.js";import{G as Y,w as X,x as Z,y as ee,p as q,A as te}from"./vendor-lucide-nYKv-BB7.js";import"./vendor-radix-4UOaVWza.js";import"./vendor-recharts-D8rt5lKn.js";import"./vendor-markdown-Bn7fRwrx.js";import"./vendor-yaml-GWJz5H2G.js";function re({open:t,onOpenChange:a,projectName:n}){const[r,s]=c.useState("pick");c.useEffect(()=>{t&&s("pick")},[t]);const o=()=>{a(!1),s("pick")};return e.jsx(O,{open:t,onOpenChange:i=>{i?a(!0):o()},children:e.jsx(W,{children:r==="pick"?e.jsx(ne,{onPick:s}):r==="wordpress"?e.jsx(ie,{projectName:n,onBack:()=>s("pick"),onClose:o}):r==="vercel"?e.jsx(ce,{projectName:n,onBack:()=>s("pick"),onClose:o}):e.jsx(le,{projectName:n,onBack:()=>s("pick"),onClose:o})})})}const se=[{type:"wordpress",name:"WordPress",action:"Install the traffic plugin",icon:Y},{type:"cloud-run",name:"Google Cloud Run",action:"Read request logs",icon:X},{type:"vercel",name:"Vercel",action:"Read request logs",icon:Z}];function ne({onPick:t}){return e.jsxs(e.Fragment,{children:[e.jsxs(I,{children:[e.jsx(F,{children:"Connect a traffic source"}),e.jsx(A,{children:"Choose where Canonry should read traffic logs."})]}),e.jsx("div",{className:"mt-6 flex flex-col gap-3",children:se.map(({type:a,name:n,action:r,icon:s})=>e.jsxs("button",{type:"button",onClick:()=>t(a),className:"group flex items-center gap-3 rounded-md border border-base bg-bg-elevated/30 px-3 py-3 text-left transition-colors hover:border-mono-600 hover:bg-bg-elevated/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[e.jsx("span",{className:"mt-0.5 inline-flex size-9 shrink-0 items-center justify-center rounded-md border border-base bg-bg text-neutral group-hover:text-heading",children:e.jsx(s,{className:"size-4"})}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline justify-between gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-heading",children:n}),e.jsx("span",{className:"text-sm text-secondary",children:r})]})]},a))})]})}function oe({title:t,description:a,onBack:n}){return e.jsxs(I,{children:[e.jsxs("button",{type:"button",onClick:n,className:"mb-1 inline-flex w-fit items-center gap-1 rounded text-sm text-secondary transition-colors hover:text-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[e.jsx(ee,{className:"size-3"}),"Choose a different source"]}),e.jsx(F,{children:t}),e.jsx(A,{children:a})]})}function ae(t,a){const n=V();return async(r,s)=>{await z(t,r),s?.(),a(),n({to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:r}})}}function P(t,a){const[n,r]=c.useState(null),s=ae(t,a);return{error:n,runConnect:async i=>{r(null);const d=i.validate();if(d){r(d);return}let u;try{u=await i.mutate()}catch(l){r(T(l));return}try{await s(u.id,i.onConnected)}catch(l){r(`Source connected, but starting the initial backfill failed: ${T(l)}`)}}}}function k({title:t,description:a,projectName:n,onBack:r,onClose:s,onSubmit:o,isPending:i,error:d,children:u}){return e.jsxs(e.Fragment,{children:[e.jsx(oe,{title:t,description:a,onBack:r}),e.jsxs("form",{onSubmit:$(async l=>{l.preventDefault(),await o()}),className:"mt-6 flex flex-col gap-5 overflow-y-auto pr-1",children:[e.jsx(p,{label:"Project",description:"Canonry project this source attaches to.",children:e.jsx("input",{type:"text",value:n,disabled:!0,className:"w-full rounded border border-strong bg-bg-elevated/50 px-2 py-1.5 text-sm text-neutral"})}),u,d?e.jsx("p",{className:"rounded-md border border-negative-800/50 bg-negative-950/30 px-3 py-2 text-xs text-negative-200",children:d}):null,e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2 border-t border-default pt-4",children:[e.jsx(N,{type:"button",variant:"ghost",size:"sm",onClick:s,children:"Close"}),e.jsx(N,{type:"submit",disabled:i,size:"sm",children:i?"Connecting…":"Connect"})]})]})]})}function ie({projectName:t,onBack:a,onClose:n}){const[r,s]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState(""),f=J(t||null),{error:g,runConnect:b}=P(t,n),y=()=>b({validate:()=>r.trim()?o.trim()?d.trim()?null:"Application Password is required.":"Username is required.":"WordPress site URL is required.",mutate:()=>f.mutateAsync({baseUrl:r.trim(),username:o.trim(),applicationPassword:d.trim(),displayName:l.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(k,{title:"Connect a WordPress site",description:e.jsxs(e.Fragment,{children:["Pulls request events from the Canonry Traffic Logger plugin. The Application Password is stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:y,isPending:f.isPending,error:g,children:[e.jsx(p,{label:"WordPress site URL",description:"Base URL of the site running the Canonry Traffic Logger plugin.",required:!0,children:e.jsx("input",{type:"url",value:r,onChange:x=>s(x.target.value),required:!0,autoComplete:"url",placeholder:"https://example.com",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Username",description:"WordPress user that owns the Application Password.",required:!0,children:e.jsx("input",{type:"text",value:o,onChange:x=>i(x.target.value),required:!0,autoComplete:"username",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Application Password",description:"Create one in wp-admin under Users -> Profile -> Application Passwords.",required:!0,children:e.jsx("input",{type:"password",value:d,onChange:x=>u(x.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the WordPress host.",children:e.jsx("input",{type:"text",value:l,onChange:x=>j(x.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})})]})}function le({projectName:t,onBack:a,onClose:n}){const[r,s]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState(""),[f,g]=c.useState(""),b=_(t||null),{error:y,runConnect:x}=P(t,n),C=()=>x({validate:()=>r.trim()?f.trim()?null:"Service-account JSON content is required.":"GCP project ID is required.",mutate:()=>b.mutateAsync({gcpProjectId:r.trim(),serviceName:o.trim()||void 0,location:d.trim()||void 0,displayName:l.trim()||void 0,keyJson:f.trim()}),onConnected:()=>g("")}),h=async m=>{if(!m)return;const R=await m.text();g(R)};return e.jsxs(k,{title:"Connect a Cloud Run service",description:e.jsxs(e.Fragment,{children:["v1 supports service-account JSON only. The private key is stored in"," ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:C,isPending:b.isPending,error:y,children:[e.jsx(p,{label:"GCP project ID",description:"The Google Cloud project hosting the Cloud Run service (e.g. my-prod-foo).",required:!0,children:e.jsx("input",{type:"text",value:r,onChange:m=>s(m.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Service name (optional)",description:"Restrict log pulls to a specific Cloud Run service. Omit to pull all services in the project.",children:e.jsx("input",{type:"text",value:o,onChange:m=>i(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Location (optional)",description:"Region of the Cloud Run service (e.g. us-central1). Helpful when multiple regions emit logs.",children:e.jsx("input",{type:"text",value:d,onChange:m=>u(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the project + service combo.",children:e.jsx("input",{type:"text",value:l,onChange:m=>j(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsxs(p,{label:"Service-account JSON",description:"Paste the contents of the SA key (JSON). The SA needs roles/logging.viewer (or any role granting logging.logEntries.list).",required:!0,children:[e.jsx("textarea",{value:f,onChange:m=>g(m.target.value),rows:6,spellCheck:!1,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 font-mono text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:'{"type":"service_account","project_id":"…","private_key":"…"}',required:!0}),e.jsxs("label",{className:"mt-2 inline-flex cursor-pointer items-center gap-2 text-sm text-secondary hover:text-strong",children:[e.jsx("input",{type:"file",accept:"application/json,.json",className:"hidden",onChange:m=>{h(m.target.files?.[0]??null)}}),e.jsx("span",{className:"rounded-md border border-base px-2 py-1",children:"Or upload a key file"})]})]})]})}function ce({projectName:t,onBack:a,onClose:n}){const[r,s]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState("production"),[f,g]=c.useState(""),b=M(t||null),{error:y,runConnect:x}=P(t,n),C=()=>x({validate:()=>r.trim()?o.trim()?d.trim()?null:"Vercel personal access token is required.":"Vercel team / account ID is required.":"Vercel project ID is required.",mutate:()=>b.mutateAsync({projectId:r.trim(),teamId:o.trim(),token:d.trim(),environment:l,displayName:f.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(k,{title:"Connect a Vercel project",description:e.jsxs(e.Fragment,{children:["Pulls request logs straight from Vercel, no in-app instrumentation needed. The personal access token is stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:C,isPending:b.isPending,error:y,children:[e.jsx(p,{label:"Vercel project ID",description:"The prj_… id from the Vercel dashboard or .vercel/project.json.",required:!0,children:e.jsx("input",{type:"text",value:r,onChange:h=>s(h.target.value),required:!0,autoComplete:"off",placeholder:"prj_…",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Vercel team / account ID",description:"The Vercel team or personal account that owns the project. Find it as orgId in your .vercel/project.json.",required:!0,children:e.jsx("input",{type:"text",value:o,onChange:h=>i(h.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Personal access token",description:"Create a Vercel personal access token under Account Settings → Tokens. Tokens can expire, so use a long-lived one.",required:!0,children:e.jsx("input",{type:"password",value:d,onChange:h=>u(h.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Environment",description:"Which deployment environment's request logs to pull.",children:e.jsxs("select",{value:l,onChange:h=>j(h.target.value),className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong focus:border-mono-500 focus:outline-none",children:[e.jsx("option",{value:"production",children:"production"}),e.jsx("option",{value:"preview",children:"preview"})]})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the Vercel project ID.",children:e.jsx("input",{type:"text",value:f,onChange:h=>g(h.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})})]})}function p({label:t,description:a,required:n,children:r}){return e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"text-sm font-medium text-strong",children:[t,n?e.jsx("span",{className:"ml-1 text-negative-400",children:"*"}):null]}),r,e.jsx("span",{className:"text-[13px] leading-5 text-secondary",children:a})]})}function de(t){if(!t)return"never";const a=Date.now()-new Date(t).getTime(),n=Math.floor(a/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function v(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toLocaleString()}function ye(){const[t,a]=c.useState(""),[n,r]=c.useState(!1),o=L(B({client:D})).data??[],i=c.useMemo(()=>t||(o[0]?.name??""),[t,o]),d=Q(i||null),u=d.data?.sources??[];return e.jsxs("div",{className:"page-container",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[e.jsx("h1",{className:"page-title",children:"Traffic sources"}),e.jsx("p",{className:"page-subtitle",children:"AI crawler hits and referral sessions from your server logs."})]}),!w()&&e.jsx("div",{className:"flex flex-wrap items-center justify-end gap-2",children:e.jsxs(N,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!0),disabled:!i,children:[e.jsx(q,{className:"size-3.5"}),"Connect a source"]})})]}),e.jsxs("section",{children:[o.length>1&&e.jsxs("label",{className:"mb-4 flex w-fit items-center gap-2 text-sm font-medium text-secondary",htmlFor:"traffic-project",children:["Project",e.jsx("select",{id:"traffic-project",className:"h-8 min-w-44 rounded-md border border-base bg-bg px-2 text-sm text-heading outline-none transition focus:border-mono-500 focus:ring-1 focus:ring-mono-500",value:i,onChange:l=>a(l.target.value),children:o.map(l=>e.jsx("option",{value:l.name,children:l.displayName??l.name},l.id))})]}),i?d.isLoading?e.jsx(S,{className:"p-6 text-center text-sm text-muted",children:"Loading sources…"}):u.length===0?e.jsxs(S,{className:"p-8 text-center",children:[e.jsxs("p",{className:"text-sm text-neutral",children:["No traffic sources connected for ",i,"."]}),!w()&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Connect a source to start collecting traffic."}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-2",children:e.jsxs(N,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!0),children:[e.jsx(q,{className:"size-3.5"}),"Connect a source"]})})]})]}):e.jsx(ue,{projectName:i,sources:u}):e.jsx(S,{className:"p-6 text-center text-sm text-muted",children:"No projects yet."})]}),!w()&&e.jsx(re,{open:n,onOpenChange:r,projectName:i})]})}function ue({projectName:t,sources:a}){const n=E({queries:a.map(s=>({...H({client:D,path:{name:t,id:s.id}}),staleTime:3e4}))}),r=a.map((s,o)=>({source:s,detail:n[o]?.data,isLoading:n[o]?.isLoading??!1}));return 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:"Source"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Status"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Last sync"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Content crawls"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Infra crawls"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"AI fetches"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"AI referrals"}),e.jsx("th",{className:"px-4 py-2 text-right"})]})}),e.jsx("tbody",{className:"divide-y divide-mono-800/60",children:r.map(({source:s,detail:o,isLoading:i})=>e.jsxs("tr",{className:"hover:bg-bg-elevated/40 transition-colors",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"font-medium text-heading",children:s.displayName})}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx(G,{tone:K(s.status),children:s.status}),s.lastError?e.jsx("p",{className:"mt-1 max-w-[18rem] truncate text-sm text-negative-400",title:s.lastError,children:s.lastError}):null]}),e.jsx("td",{className:"px-4 py-3 text-neutral",children:de(s.lastSyncedAt)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",title:o?`${o.totals24h.crawlerHits.toLocaleString("en-US")} total crawler hits`:void 0,children:i?"—":v(o?.totals24h.crawlerContentHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-muted",children:i?"—":v(o?.totals24h.crawlerInfraHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",children:i?"—":v(o?.totals24h.aiUserFetchHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",children:i?"—":v(o?.totals24h.aiReferralLandedHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsxs(U,{to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:s.id},className:"inline-flex items-center gap-1 text-sm text-secondary hover:text-heading",children:["View",e.jsx(te,{className:"size-3.5"})]})})]},s.id))})]})})}export{ye as TrafficPage};
|
|
1
|
+
import{r as c,j as e,h as V,u as B,f as L,L as E}from"./vendor-tanstack-Dock0eH1.js";import{cV as U,cW as O,cX as I,cY as F,cZ as A,B as C,l as W,c_ as $,bW as z,i as D,j as w,f as S,c$ as H,T as G}from"./index-VmxEHABq.js";import{d as J,f as M,g as _,c as T,a as Q,t as K}from"./extract-error-message-Cp1YeVEr.js";import{G as Y,w as X,x as Z,y as ee,p as q,A as te}from"./vendor-lucide-nYKv-BB7.js";import"./vendor-radix-4UOaVWza.js";import"./vendor-recharts-D8rt5lKn.js";import"./vendor-markdown-Bn7fRwrx.js";import"./vendor-yaml-GWJz5H2G.js";function re({open:t,onOpenChange:a,projectName:n}){const[r,s]=c.useState("pick");c.useEffect(()=>{t&&s("pick")},[t]);const o=()=>{a(!1),s("pick")};return e.jsx(U,{open:t,onOpenChange:i=>{i?a(!0):o()},children:e.jsx(O,{children:r==="pick"?e.jsx(ne,{onPick:s}):r==="wordpress"?e.jsx(ie,{projectName:n,onBack:()=>s("pick"),onClose:o}):r==="vercel"?e.jsx(ce,{projectName:n,onBack:()=>s("pick"),onClose:o}):e.jsx(le,{projectName:n,onBack:()=>s("pick"),onClose:o})})})}const se=[{type:"wordpress",name:"WordPress",action:"Install the traffic plugin",icon:Y},{type:"cloud-run",name:"Google Cloud Run",action:"Read request logs",icon:X},{type:"vercel",name:"Vercel",action:"Read request logs",icon:Z}];function ne({onPick:t}){return e.jsxs(e.Fragment,{children:[e.jsxs(I,{children:[e.jsx(F,{children:"Connect a traffic source"}),e.jsx(A,{children:"Choose where Canonry should read traffic logs."})]}),e.jsx("div",{className:"mt-6 flex flex-col gap-3",children:se.map(({type:a,name:n,action:r,icon:s})=>e.jsxs("button",{type:"button",onClick:()=>t(a),className:"group flex items-center gap-3 rounded-md border border-base bg-bg-elevated/30 px-3 py-3 text-left transition-colors hover:border-mono-600 hover:bg-bg-elevated/60 focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[e.jsx("span",{className:"mt-0.5 inline-flex size-9 shrink-0 items-center justify-center rounded-md border border-base bg-bg text-neutral group-hover:text-heading",children:e.jsx(s,{className:"size-4"})}),e.jsxs("span",{className:"flex min-w-0 flex-1 items-baseline justify-between gap-3",children:[e.jsx("span",{className:"text-sm font-medium text-heading",children:n}),e.jsx("span",{className:"text-sm text-secondary",children:r})]})]},a))})]})}function oe({title:t,description:a,onBack:n}){return e.jsxs(I,{children:[e.jsxs("button",{type:"button",onClick:n,className:"mb-1 inline-flex w-fit items-center gap-1 rounded text-sm text-secondary transition-colors hover:text-strong focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[e.jsx(ee,{className:"size-3"}),"Choose a different source"]}),e.jsx(F,{children:t}),e.jsx(A,{children:a})]})}function ae(t,a){const n=V();return async(r,s)=>{s.startInitialBackfill&&await $(t,r),s.afterConnected?.(),a(),n({to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:r}})}}function k(t,a){const[n,r]=c.useState(null),s=ae(t,a);return{error:n,runConnect:async i=>{r(null);const d=i.validate();if(d){r(d);return}let u;try{u=await i.mutate()}catch(l){r(T(l));return}try{await s(u.id,{startInitialBackfill:i.startInitialBackfill??!0,afterConnected:i.onConnected})}catch(l){r(`Source connected, but starting the initial backfill failed: ${T(l)}`)}}}}function P({title:t,description:a,projectName:n,onBack:r,onClose:s,onSubmit:o,isPending:i,error:d,children:u}){return e.jsxs(e.Fragment,{children:[e.jsx(oe,{title:t,description:a,onBack:r}),e.jsxs("form",{onSubmit:W(async l=>{l.preventDefault(),await o()}),className:"mt-6 flex flex-col gap-5 overflow-y-auto pr-1",children:[e.jsx(p,{label:"Project",description:"Canonry project this source attaches to.",children:e.jsx("input",{type:"text",value:n,disabled:!0,className:"w-full rounded border border-strong bg-bg-elevated/50 px-2 py-1.5 text-sm text-neutral"})}),u,d?e.jsx("p",{className:"rounded-md border border-negative-800/50 bg-negative-950/30 px-3 py-2 text-xs text-negative-200",children:d}):null,e.jsxs("div",{className:"mt-2 flex items-center justify-end gap-2 border-t border-default pt-4",children:[e.jsx(C,{type:"button",variant:"ghost",size:"sm",onClick:s,children:"Close"}),e.jsx(C,{type:"submit",disabled:i,size:"sm",children:i?"Connecting…":"Connect"})]})]})]})}function ie({projectName:t,onBack:a,onClose:n}){const[r,s]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState(""),f=J(t||null),{error:g,runConnect:b}=k(t,n),y=()=>b({validate:()=>r.trim()?o.trim()?d.trim()?null:"Application Password is required.":"Username is required.":"WordPress site URL is required.",mutate:()=>f.mutateAsync({baseUrl:r.trim(),username:o.trim(),applicationPassword:d.trim(),displayName:l.trim()||void 0}),onConnected:()=>u("")});return e.jsxs(P,{title:"Connect a WordPress site",description:e.jsxs(e.Fragment,{children:["Pulls request events from the Canonry Traffic Logger plugin. The Application Password is stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:y,isPending:f.isPending,error:g,children:[e.jsx(p,{label:"WordPress site URL",description:"Base URL of the site running the Canonry Traffic Logger plugin.",required:!0,children:e.jsx("input",{type:"url",value:r,onChange:x=>s(x.target.value),required:!0,autoComplete:"url",placeholder:"https://example.com",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Username",description:"WordPress user that owns the Application Password.",required:!0,children:e.jsx("input",{type:"text",value:o,onChange:x=>i(x.target.value),required:!0,autoComplete:"username",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Application Password",description:"Create one in wp-admin under Users -> Profile -> Application Passwords.",required:!0,children:e.jsx("input",{type:"password",value:d,onChange:x=>u(x.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the WordPress host.",children:e.jsx("input",{type:"text",value:l,onChange:x=>j(x.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})})]})}function le({projectName:t,onBack:a,onClose:n}){const[r,s]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState(""),[f,g]=c.useState(""),b=_(t||null),{error:y,runConnect:x}=k(t,n),N=()=>x({validate:()=>r.trim()?f.trim()?null:"Service-account JSON content is required.":"GCP project ID is required.",mutate:()=>b.mutateAsync({gcpProjectId:r.trim(),serviceName:o.trim()||void 0,location:d.trim()||void 0,displayName:l.trim()||void 0,keyJson:f.trim()}),onConnected:()=>g("")}),h=async m=>{if(!m)return;const R=await m.text();g(R)};return e.jsxs(P,{title:"Connect a Cloud Run service",description:e.jsxs(e.Fragment,{children:["v1 supports service-account JSON only. The private key is stored in"," ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:N,isPending:b.isPending,error:y,children:[e.jsx(p,{label:"GCP project ID",description:"The Google Cloud project hosting the Cloud Run service (e.g. my-prod-foo).",required:!0,children:e.jsx("input",{type:"text",value:r,onChange:m=>s(m.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Service name (optional)",description:"Restrict log pulls to a specific Cloud Run service. Omit to pull all services in the project.",children:e.jsx("input",{type:"text",value:o,onChange:m=>i(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Location (optional)",description:"Region of the Cloud Run service (e.g. us-central1). Helpful when multiple regions emit logs.",children:e.jsx("input",{type:"text",value:d,onChange:m=>u(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the project + service combo.",children:e.jsx("input",{type:"text",value:l,onChange:m=>j(m.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsxs(p,{label:"Service-account JSON",description:"Paste the contents of the SA key (JSON). The SA needs roles/logging.viewer (or any role granting logging.logEntries.list).",required:!0,children:[e.jsx("textarea",{value:f,onChange:m=>g(m.target.value),rows:6,spellCheck:!1,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 font-mono text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none",placeholder:'{"type":"service_account","project_id":"…","private_key":"…"}',required:!0}),e.jsxs("label",{className:"mt-2 inline-flex cursor-pointer items-center gap-2 text-sm text-secondary hover:text-strong",children:[e.jsx("input",{type:"file",accept:"application/json,.json",className:"hidden",onChange:m=>{h(m.target.files?.[0]??null)}}),e.jsx("span",{className:"rounded-md border border-base px-2 py-1",children:"Or upload a key file"})]})]})]})}function ce({projectName:t,onBack:a,onClose:n}){const[r,s]=c.useState(""),[o,i]=c.useState(""),[d,u]=c.useState(""),[l,j]=c.useState("production"),[f,g]=c.useState(""),b=M(t||null),{error:y,runConnect:x}=k(t,n),N=()=>x({validate:()=>r.trim()?o.trim()?d.trim()?null:"Vercel personal access token is required.":"Vercel team / account ID is required.":"Vercel project ID is required.",mutate:()=>b.mutateAsync({projectId:r.trim(),teamId:o.trim(),token:d.trim(),environment:l,displayName:f.trim()||void 0}),startInitialBackfill:!1,onConnected:()=>u("")});return e.jsxs(P,{title:"Connect a Vercel project",description:e.jsxs(e.Fragment,{children:["Pulls request logs straight from Vercel, no in-app instrumentation needed. The personal access token is stored in ",e.jsx("code",{children:"~/.canonry/config.yaml"})," on the server and never echoed back to the dashboard."]}),projectName:t,onBack:a,onClose:n,onSubmit:N,isPending:b.isPending,error:y,children:[e.jsx(p,{label:"Vercel project ID",description:"The prj_… id from the Vercel dashboard or .vercel/project.json.",required:!0,children:e.jsx("input",{type:"text",value:r,onChange:h=>s(h.target.value),required:!0,autoComplete:"off",placeholder:"prj_…",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Vercel team / account ID",description:"The Vercel team or personal account that owns the project. Find it as orgId in your .vercel/project.json.",required:!0,children:e.jsx("input",{type:"text",value:o,onChange:h=>i(h.target.value),required:!0,autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Personal access token",description:"Create a Vercel personal access token under Account Settings → Tokens. Tokens can expire, so use a long-lived one.",required:!0,children:e.jsx("input",{type:"password",value:d,onChange:h=>u(h.target.value),required:!0,autoComplete:"new-password",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})}),e.jsx(p,{label:"Environment",description:"Which deployment environment's request logs to pull.",children:e.jsxs("select",{value:l,onChange:h=>j(h.target.value),className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong focus:border-mono-500 focus:outline-none",children:[e.jsx("option",{value:"production",children:"production"}),e.jsx("option",{value:"preview",children:"preview"})]})}),e.jsx(p,{label:"Display name (optional)",description:"Friendly label shown in the dashboard. Defaults to the Vercel project ID.",children:e.jsx("input",{type:"text",value:f,onChange:h=>g(h.target.value),autoComplete:"off",className:"w-full rounded border border-strong bg-transparent px-2 py-1.5 text-sm text-strong placeholder-mono-600 focus:border-mono-500 focus:outline-none"})})]})}function p({label:t,description:a,required:n,children:r}){return e.jsxs("label",{className:"flex flex-col gap-1",children:[e.jsxs("span",{className:"text-sm font-medium text-strong",children:[t,n?e.jsx("span",{className:"ml-1 text-negative-400",children:"*"}):null]}),r,e.jsx("span",{className:"text-[13px] leading-5 text-secondary",children:a})]})}function de(t){if(!t)return"never";const a=Date.now()-new Date(t).getTime(),n=Math.floor(a/6e4);if(n<1)return"just now";if(n<60)return`${n}m ago`;const r=Math.floor(n/60);return r<24?`${r}h ago`:`${Math.floor(r/24)}d ago`}function v(t){return t>=1e6?`${(t/1e6).toFixed(1)}M`:t>=1e3?`${(t/1e3).toFixed(1)}K`:t.toLocaleString()}function ye(){const[t,a]=c.useState(""),[n,r]=c.useState(!1),o=B(z({client:D})).data??[],i=c.useMemo(()=>t||(o[0]?.name??""),[t,o]),d=Q(i||null),u=d.data?.sources??[];return e.jsxs("div",{className:"page-container",children:[e.jsxs("div",{className:"page-header",children:[e.jsxs("div",{className:"page-header-left",children:[e.jsx("h1",{className:"page-title",children:"Traffic sources"}),e.jsx("p",{className:"page-subtitle",children:"AI crawler hits and referral sessions from your server logs."})]}),!w()&&e.jsx("div",{className:"flex flex-wrap items-center justify-end gap-2",children:e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!0),disabled:!i,children:[e.jsx(q,{className:"size-3.5"}),"Connect a source"]})})]}),e.jsxs("section",{children:[o.length>1&&e.jsxs("label",{className:"mb-4 flex w-fit items-center gap-2 text-sm font-medium text-secondary",htmlFor:"traffic-project",children:["Project",e.jsx("select",{id:"traffic-project",className:"h-8 min-w-44 rounded-md border border-base bg-bg px-2 text-sm text-heading outline-none transition focus:border-mono-500 focus:ring-1 focus:ring-mono-500",value:i,onChange:l=>a(l.target.value),children:o.map(l=>e.jsx("option",{value:l.name,children:l.displayName??l.name},l.id))})]}),i?d.isLoading?e.jsx(S,{className:"p-6 text-center text-sm text-muted",children:"Loading sources…"}):u.length===0?e.jsxs(S,{className:"p-8 text-center",children:[e.jsxs("p",{className:"text-sm text-neutral",children:["No traffic sources connected for ",i,"."]}),!w()&&e.jsxs(e.Fragment,{children:[e.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Connect a source to start collecting traffic."}),e.jsx("div",{className:"mt-4 flex flex-wrap items-center justify-center gap-2",children:e.jsxs(C,{type:"button",variant:"outline",size:"sm",onClick:()=>r(!0),children:[e.jsx(q,{className:"size-3.5"}),"Connect a source"]})})]})]}):e.jsx(ue,{projectName:i,sources:u}):e.jsx(S,{className:"p-6 text-center text-sm text-muted",children:"No projects yet."})]}),!w()&&e.jsx(re,{open:n,onOpenChange:r,projectName:i})]})}function ue({projectName:t,sources:a}){const n=L({queries:a.map(s=>({...H({client:D,path:{name:t,id:s.id}}),staleTime:3e4}))}),r=a.map((s,o)=>({source:s,detail:n[o]?.data,isLoading:n[o]?.isLoading??!1}));return 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:"Source"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Status"}),e.jsx("th",{className:"px-4 py-2 text-left",children:"Last sync"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Content crawls"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"Infra crawls"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"AI fetches"}),e.jsx("th",{className:"px-4 py-2 text-right",children:"AI referrals"}),e.jsx("th",{className:"px-4 py-2 text-right"})]})}),e.jsx("tbody",{className:"divide-y divide-mono-800/60",children:r.map(({source:s,detail:o,isLoading:i})=>e.jsxs("tr",{className:"hover:bg-bg-elevated/40 transition-colors",children:[e.jsx("td",{className:"px-4 py-3",children:e.jsx("div",{className:"font-medium text-heading",children:s.displayName})}),e.jsxs("td",{className:"px-4 py-3",children:[e.jsx(G,{tone:K(s.status),children:s.status}),s.lastError?e.jsx("p",{className:"mt-1 max-w-[18rem] truncate text-sm text-negative-400",title:s.lastError,children:s.lastError}):null]}),e.jsx("td",{className:"px-4 py-3 text-neutral",children:de(s.lastSyncedAt)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",title:o?`${o.totals24h.crawlerHits.toLocaleString("en-US")} total crawler hits`:void 0,children:i?"—":v(o?.totals24h.crawlerContentHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-muted",children:i?"—":v(o?.totals24h.crawlerInfraHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",children:i?"—":v(o?.totals24h.aiUserFetchHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right tabular-nums text-heading",children:i?"—":v(o?.totals24h.aiReferralLandedHits??0)}),e.jsx("td",{className:"px-4 py-3 text-right",children:e.jsxs(E,{to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:s.id},className:"inline-flex items-center gap-1 text-sm text-secondary hover:text-heading",children:["View",e.jsx(te,{className:"size-3.5"})]})})]},s.id))})]})})}export{ye as TrafficPage};
|
package/assets/assets/{TrafficSourceDetailPage-ChFDAstr.js → TrafficSourceDetailPage-nhWRLHiu.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,C as Ee,E as $e,r as i,L as Fe}from"./vendor-tanstack-Dock0eH1.js";import{d0 as W,d1 as o,f as H,I as U,T as He,j as ae,B as Ue,d2 as Pe}from"./index-Dz0ju3qg.js";import{h as Oe,u as Me,i as _e,t as De,c as Be}from"./extract-error-message-CG_IQ_9c.js";import{e as Y,C as Ke,a as re,b as ne,d as ze}from"./ChartPrimitives-DG35TyhH.js";import{q as Ge,z as We,e as qe,y as le,X as Ve}from"./vendor-lucide-nYKv-BB7.js";import{R as Xe,B as Qe,a as Ye,X as Ze,Y as Je,T as et,f as q,g as V}from"./vendor-recharts-D8rt5lKn.js";import"./vendor-radix-4UOaVWza.js";import"./vendor-markdown-Bn7fRwrx.js";import"./vendor-yaml-GWJz5H2G.js";const tt=[{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"}],me=[{value:"all",label:"All claims"},{value:W.verified,label:"Verified"},{value:W.claimed_unverified,label:"Claimed unverified"},{value:W.unknown_ai_like,label:"Unknown AI-like"}];function st(s){return s==="all"?null:Number.parseInt(s[0],10)}function fe(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return s.botId;case o["ai-referral"]:return s.product}}function pe(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return s.pathNormalized;case o["ai-referral"]:return s.landingPathNormalized}}function at(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return s.verificationStatus;case o["ai-referral"]:return null}}function rt(s,a){if(a==="hour")return s;const r=new Date(s),n=r.getFullYear(),u=String(r.getMonth()+1).padStart(2,"0"),f=String(r.getDate()).padStart(2,"0");return`${n}-${u}-${f}`}function nt(s,a,r){const n=a.pathQuery.trim().toLowerCase(),u=st(a.statusClass);return s.filter(f=>!(a.selectedBucket&&rt(f.tsHour,r)!==a.selectedBucket||a.identity&&fe(f)!==a.identity||a.operator&&f.operator!==a.operator||n&&!pe(f).toLowerCase().includes(n)||u!==null&&Math.floor(f.status/100)!==u||a.verification!=="all"&&at(f)!==a.verification))}function lt(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],I=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 it(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 ot(s){return s.size===1?[...s][0]:"all"}function he({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(Fe,{to:"/traffic",className:`${r} ${a??""}`,children:[e.jsx(le,{className:"size-3"})," All sources"]})}function wt(){const s=Ee({strict:!1}),a=s.projectName??"",r=$e(),n=s.sourceId??"",[u,f]=i.useState(ie.value),[x,ye]=i.useState(()=>new Set(["crawler","ai-user-fetch","ai-referral"])),[c,R]=i.useState(null),[p,O]=i.useState(""),[b,M]=i.useState(""),[v,_]=i.useState(""),[N,D]=i.useState("all"),[S,B]=i.useState("all"),[je,K]=i.useState(1),[Z,J]=i.useState(null),[ee,te]=i.useState(null),h=i.useMemo(()=>P.find(t=>t.value===u)??ie,[u]),ve=i.useMemo(()=>ot(x),[x]),z=Oe(a||null,n||null),g=Me(a||null,{kind:ve,sourceId:n||void 0,sinceMinutes:u,limit:h.fetchLimit,granularity:h.granularity}),A=_e(a||null,n||null),l=z.data,w=g.data?.events??[],y=g.data?.totals,L=g.data?.eventRows,E=i.useMemo(()=>w.filter(t=>{switch(t.kind){case o.crawler:return x.has("crawler");case o["ai-user-fetch"]:return x.has("ai-user-fetch");case o["ai-referral"]:return x.has("ai-referral")}}),[w,x]),Ne=i.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]),Se=i.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=i.useMemo(()=>nt(E,{selectedBucket:c,identity:p,operator:b,pathQuery:v,statusClass:N,verification:S},h.granularity),[E,c,p,b,v,N,S,h.granularity]);i.useEffect(()=>{K(1)},[E,c,p,b,v,N,S]);const $=Math.max(1,Math.ceil(j.length/I)),F=Math.min(Math.max(1,je),$),T=(F-1)*I,we=i.useMemo(()=>j.slice(T,T+I),[j,T]),Ce=j.length>I,ke=j.length===0?0:T+1,Le=Math.min(T+I,j.length),se=i.useMemo(()=>c?ge(c,h.granularity):null,[c,h.granularity]),C=i.useMemo(()=>ct(g.data?.series.points??[],h.granularity),[g.data?.series.points,h.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=lt(t,C);d&&R(m=>m===d?null:d)},Ie=()=>{R(null),O(""),M(""),_(""),D("all"),B("all")},Re=!!(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(Be(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(he,{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(he,{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(He,{tone:De(l.status),children:l.status}),!ae()&&e.jsxs(Ue,{type:"button",variant:"outline",size:"sm",disabled:A.isPending,onClick:()=>{Ae()},children:[e.jsx(Ge,{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.aiReferralLandedHits,tooltip:`Browser click-throughs from AI surfaces, identified by Referer or UTM evidence. Excludes ${l.totals24h.aiReferralRedirectedHits.toLocaleString("en-US")} request(s) answered with a redirect: a hop is not an arrival. Total including hops: ${l.totals24h.aiReferralHits.toLocaleString("en-US")}.`})]})]}),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:h.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.aiReferralLandedHits.toLocaleString("en-US")," AI referral sessions · last ",h.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:()=>{f(t.value),R(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:x.has("crawler"),onToggle:()=>G("crawler")}),e.jsx(X,{label:"AI user fetches",color:ce,count:y?.aiUserFetchHits??0,active:x.has("ai-user-fetch"),onToggle:()=>G("ai-user-fetch")}),e.jsx(X,{label:"AI referral sessions",color:de,count:y?.aiReferralLandedHits??0,active:x.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(Xe,{children:e.jsxs(Qe,{data:C,margin:{top:4,right:4,bottom:0,left:0},onClick:Te,style:{cursor:"pointer"},children:[e.jsx(Ye,{stroke:Ke,strokeDasharray:"3 3"}),e.jsx(Ze,{dataKey:"label",tick:ne,stroke:re,interval:"preserveStartEnd",minTickGap:h.granularity==="day"?24:32}),e.jsx(Je,{tick:ne,stroke:re,allowDecimals:!1}),e.jsx(et,{...ze}),x.has("crawler")?e.jsx(q,{dataKey:"crawler",name:"Crawler",fill:oe,stackId:"a",children:C.map(t=>e.jsx(V,{fillOpacity:c&&c!==t.bucket?.25:1},t.bucket))}):null,x.has("ai-user-fetch")?e.jsx(q,{dataKey:"aiUserFetch",name:"AI user fetch",fill:ce,stackId:"a",children:C.map(t=>e.jsx(V,{fillOpacity:c&&c!==t.bucket?.25:1},t.bucket))}):null,x.has("ai-referral")?e.jsx(q,{dataKey:"aiReferral",name:"AI referral",fill:de,stackId:"a",children:C.map(t=>e.jsx(V,{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")})," ",L?.truncated?"loaded events":"events",L?.truncated?e.jsxs(e.Fragment,{children:[" ","· loaded ",e.jsx("span",{className:"tabular-nums text-neutral",children:L.returned.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"tabular-nums text-muted",children:L.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"}),Ne.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"}),Se.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:tt.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:me.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"})]})]}),Re?e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[se?e.jsx(k,{label:`Bucket: ${se}`,onClear:()=>R(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: ${dt(S)}`,onClear:()=>B("all")}):null,e.jsx("button",{type:"button",onClick:Ie,className:"text-xs text-muted underline-offset-4 hover:text-strong hover:underline",children:"Clear all"})]}):null,e.jsx(mt,{events:we,truncated:L?.truncated??!1}),Ce?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:ke.toLocaleString("en-US")}),"–",e.jsx("span",{className:"text-neutral",children:Le.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(qe,{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"?it(s):be(s)}function ct(s,a){return s.map(r=>({bucket:r.bucket,label:ge(r.bucket,a),crawler:r.crawlerHits,aiUserFetch:r.aiUserFetchHits,aiReferral:r.aiReferralLandedHits}))}function dt(s){return me.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(Ve,{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 ut(s){switch(s){case o.crawler:return"Crawler";case o["ai-user-fetch"]:return"AI hit";case o["ai-referral"]:return"AI referral"}}function xt(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return s.botId;case o["ai-referral"]:return s.product}}function ht(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return`${s.verificationStatus} · HTTP ${s.status}`;case o["ai-referral"]:return`${s.evidenceType} · ${s.sourceDomain}`}}function mt({events:s,truncated:a=!1}){return s.length===0?e.jsx(H,{className:"p-6 text-center text-sm text-muted",children:a?"No matches in the rows loaded so far. More rows exist beyond the load limit, so narrow the time window to search them.":"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((r,n)=>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(r.tsHour)}),e.jsx("td",{className:"px-4 py-2 text-neutral",children:ut(r.kind)}),e.jsxs("td",{className:"px-4 py-2 text-heading",children:[xt(r),e.jsx("span",{className:"ml-2 text-[11px] text-muted",children:r.operator})]}),e.jsx("td",{className:"px-4 py-2 text-neutral",children:ht(r)}),e.jsx("td",{className:"px-4 py-2 truncate font-mono text-xs text-neutral",children:pe(r)}),e.jsx("td",{className:"px-4 py-2 text-right tabular-nums text-heading",children:r.hits})]},`${r.kind}:${r.tsHour}:${n}`))})]})})}export{mt as EventsTable,Q as TrafficKpi,wt as TrafficSourceDetailPage,ot as trafficFetchKind};
|
|
1
|
+
import{j as e,C as Ee,E as $e,r as i,L as Fe}from"./vendor-tanstack-Dock0eH1.js";import{d0 as W,d1 as o,f as H,I as U,T as He,j as ae,B as Ue,d2 as Pe}from"./index-VmxEHABq.js";import{h as Oe,u as Me,i as _e,t as De,c as Be}from"./extract-error-message-Cp1YeVEr.js";import{e as Y,C as Ke,a as re,b as ne,d as ze}from"./ChartPrimitives-DG35TyhH.js";import{q as Ge,z as We,e as qe,y as le,X as Ve}from"./vendor-lucide-nYKv-BB7.js";import{R as Xe,B as Qe,a as Ye,X as Ze,Y as Je,T as et,f as q,g as V}from"./vendor-recharts-D8rt5lKn.js";import"./vendor-radix-4UOaVWza.js";import"./vendor-markdown-Bn7fRwrx.js";import"./vendor-yaml-GWJz5H2G.js";const tt=[{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"}],me=[{value:"all",label:"All claims"},{value:W.verified,label:"Verified"},{value:W.claimed_unverified,label:"Claimed unverified"},{value:W.unknown_ai_like,label:"Unknown AI-like"}];function st(s){return s==="all"?null:Number.parseInt(s[0],10)}function fe(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return s.botId;case o["ai-referral"]:return s.product}}function pe(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return s.pathNormalized;case o["ai-referral"]:return s.landingPathNormalized}}function at(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return s.verificationStatus;case o["ai-referral"]:return null}}function rt(s,a){if(a==="hour")return s;const r=new Date(s),n=r.getFullYear(),u=String(r.getMonth()+1).padStart(2,"0"),f=String(r.getDate()).padStart(2,"0");return`${n}-${u}-${f}`}function nt(s,a,r){const n=a.pathQuery.trim().toLowerCase(),u=st(a.statusClass);return s.filter(f=>!(a.selectedBucket&&rt(f.tsHour,r)!==a.selectedBucket||a.identity&&fe(f)!==a.identity||a.operator&&f.operator!==a.operator||n&&!pe(f).toLowerCase().includes(n)||u!==null&&Math.floor(f.status/100)!==u||a.verification!=="all"&&at(f)!==a.verification))}function lt(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],I=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 it(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 ot(s){return s.size===1?[...s][0]:"all"}function he({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(Fe,{to:"/traffic",className:`${r} ${a??""}`,children:[e.jsx(le,{className:"size-3"})," All sources"]})}function wt(){const s=Ee({strict:!1}),a=s.projectName??"",r=$e(),n=s.sourceId??"",[u,f]=i.useState(ie.value),[x,ye]=i.useState(()=>new Set(["crawler","ai-user-fetch","ai-referral"])),[c,R]=i.useState(null),[p,O]=i.useState(""),[b,M]=i.useState(""),[v,_]=i.useState(""),[N,D]=i.useState("all"),[S,B]=i.useState("all"),[je,K]=i.useState(1),[Z,J]=i.useState(null),[ee,te]=i.useState(null),h=i.useMemo(()=>P.find(t=>t.value===u)??ie,[u]),ve=i.useMemo(()=>ot(x),[x]),z=Oe(a||null,n||null),g=Me(a||null,{kind:ve,sourceId:n||void 0,sinceMinutes:u,limit:h.fetchLimit,granularity:h.granularity}),A=_e(a||null,n||null),l=z.data,w=g.data?.events??[],y=g.data?.totals,L=g.data?.eventRows,E=i.useMemo(()=>w.filter(t=>{switch(t.kind){case o.crawler:return x.has("crawler");case o["ai-user-fetch"]:return x.has("ai-user-fetch");case o["ai-referral"]:return x.has("ai-referral")}}),[w,x]),Ne=i.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]),Se=i.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=i.useMemo(()=>nt(E,{selectedBucket:c,identity:p,operator:b,pathQuery:v,statusClass:N,verification:S},h.granularity),[E,c,p,b,v,N,S,h.granularity]);i.useEffect(()=>{K(1)},[E,c,p,b,v,N,S]);const $=Math.max(1,Math.ceil(j.length/I)),F=Math.min(Math.max(1,je),$),T=(F-1)*I,we=i.useMemo(()=>j.slice(T,T+I),[j,T]),Ce=j.length>I,ke=j.length===0?0:T+1,Le=Math.min(T+I,j.length),se=i.useMemo(()=>c?ge(c,h.granularity):null,[c,h.granularity]),C=i.useMemo(()=>ct(g.data?.series.points??[],h.granularity),[g.data?.series.points,h.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=lt(t,C);d&&R(m=>m===d?null:d)},Ie=()=>{R(null),O(""),M(""),_(""),D("all"),B("all")},Re=!!(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(Be(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(he,{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(he,{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(He,{tone:De(l.status),children:l.status}),!ae()&&e.jsxs(Ue,{type:"button",variant:"outline",size:"sm",disabled:A.isPending,onClick:()=>{Ae()},children:[e.jsx(Ge,{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.aiReferralLandedHits,tooltip:`Browser click-throughs from AI surfaces, identified by Referer or UTM evidence. Excludes ${l.totals24h.aiReferralRedirectedHits.toLocaleString("en-US")} request(s) answered with a redirect: a hop is not an arrival. Total including hops: ${l.totals24h.aiReferralHits.toLocaleString("en-US")}.`})]})]}),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:h.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.aiReferralLandedHits.toLocaleString("en-US")," AI referral sessions · last ",h.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:()=>{f(t.value),R(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:x.has("crawler"),onToggle:()=>G("crawler")}),e.jsx(X,{label:"AI user fetches",color:ce,count:y?.aiUserFetchHits??0,active:x.has("ai-user-fetch"),onToggle:()=>G("ai-user-fetch")}),e.jsx(X,{label:"AI referral sessions",color:de,count:y?.aiReferralLandedHits??0,active:x.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(Xe,{children:e.jsxs(Qe,{data:C,margin:{top:4,right:4,bottom:0,left:0},onClick:Te,style:{cursor:"pointer"},children:[e.jsx(Ye,{stroke:Ke,strokeDasharray:"3 3"}),e.jsx(Ze,{dataKey:"label",tick:ne,stroke:re,interval:"preserveStartEnd",minTickGap:h.granularity==="day"?24:32}),e.jsx(Je,{tick:ne,stroke:re,allowDecimals:!1}),e.jsx(et,{...ze}),x.has("crawler")?e.jsx(q,{dataKey:"crawler",name:"Crawler",fill:oe,stackId:"a",children:C.map(t=>e.jsx(V,{fillOpacity:c&&c!==t.bucket?.25:1},t.bucket))}):null,x.has("ai-user-fetch")?e.jsx(q,{dataKey:"aiUserFetch",name:"AI user fetch",fill:ce,stackId:"a",children:C.map(t=>e.jsx(V,{fillOpacity:c&&c!==t.bucket?.25:1},t.bucket))}):null,x.has("ai-referral")?e.jsx(q,{dataKey:"aiReferral",name:"AI referral",fill:de,stackId:"a",children:C.map(t=>e.jsx(V,{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")})," ",L?.truncated?"loaded events":"events",L?.truncated?e.jsxs(e.Fragment,{children:[" ","· loaded ",e.jsx("span",{className:"tabular-nums text-neutral",children:L.returned.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"tabular-nums text-muted",children:L.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"}),Ne.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"}),Se.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:tt.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:me.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"})]})]}),Re?e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[se?e.jsx(k,{label:`Bucket: ${se}`,onClear:()=>R(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: ${dt(S)}`,onClear:()=>B("all")}):null,e.jsx("button",{type:"button",onClick:Ie,className:"text-xs text-muted underline-offset-4 hover:text-strong hover:underline",children:"Clear all"})]}):null,e.jsx(mt,{events:we,truncated:L?.truncated??!1}),Ce?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:ke.toLocaleString("en-US")}),"–",e.jsx("span",{className:"text-neutral",children:Le.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(qe,{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"?it(s):be(s)}function ct(s,a){return s.map(r=>({bucket:r.bucket,label:ge(r.bucket,a),crawler:r.crawlerHits,aiUserFetch:r.aiUserFetchHits,aiReferral:r.aiReferralLandedHits}))}function dt(s){return me.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(Ve,{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 ut(s){switch(s){case o.crawler:return"Crawler";case o["ai-user-fetch"]:return"AI hit";case o["ai-referral"]:return"AI referral"}}function xt(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return s.botId;case o["ai-referral"]:return s.product}}function ht(s){switch(s.kind){case o.crawler:case o["ai-user-fetch"]:return`${s.verificationStatus} · HTTP ${s.status}`;case o["ai-referral"]:return`${s.evidenceType} · ${s.sourceDomain}`}}function mt({events:s,truncated:a=!1}){return s.length===0?e.jsx(H,{className:"p-6 text-center text-sm text-muted",children:a?"No matches in the rows loaded so far. More rows exist beyond the load limit, so narrow the time window to search them.":"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((r,n)=>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(r.tsHour)}),e.jsx("td",{className:"px-4 py-2 text-neutral",children:ut(r.kind)}),e.jsxs("td",{className:"px-4 py-2 text-heading",children:[xt(r),e.jsx("span",{className:"ml-2 text-[11px] text-muted",children:r.operator})]}),e.jsx("td",{className:"px-4 py-2 text-neutral",children:ht(r)}),e.jsx("td",{className:"px-4 py-2 truncate font-mono text-xs text-neutral",children:pe(r)}),e.jsx("td",{className:"px-4 py-2 text-right tabular-nums text-heading",children:r.hits})]},`${r.kind}:${r.tsHour}:${n}`))})]})})}export{mt as EventsTable,Q as TrafficKpi,wt as TrafficSourceDetailPage,ot as trafficFetchKind};
|
package/assets/assets/{extract-error-message-CG_IQ_9c.js → extract-error-message-Cp1YeVEr.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as s,r as m,n as o,o as u}from"./vendor-tanstack-Dock0eH1.js";import{d as c,d3 as l,c$ as g,d4 as S,aJ as y,i as t,d5 as v,d6 as i,k as T,d7 as p,d8 as C,d9 as h,da as q}from"./index-
|
|
1
|
+
import{u as s,r as m,n as o,o as u}from"./vendor-tanstack-Dock0eH1.js";import{d as c,d3 as l,c$ as g,d4 as S,aJ as y,i as t,d5 as v,d6 as i,k as T,d7 as p,d8 as C,d9 as h,da as q}from"./index-VmxEHABq.js";function F(e){switch(e){case i.connected:return"positive";case i.paused:return"caution";case i.error:return"negative";case i.archived:return"neutral"}}function w(e){const n={};return e.kind&&e.kind!=="all"&&(n.kind=e.kind),e.sourceId&&(n.sourceId=e.sourceId),e.sinceMinutes!==void 0&&(n.since=new Date(Date.now()-e.sinceMinutes*6e4).toISOString()),e.limit!==void 0&&(n.limit=String(e.limit)),e.granularity!==void 0&&(n.granularity=e.granularity),n}function f(e){T(e,"traffic")}function A(e){return s({...l({client:t,path:{name:e??""}}),enabled:!!e,staleTime:c})}function M(e){return s({...q({client:t,path:{name:e??""}}),enabled:!!e,staleTime:c})}function V(e,n){return s({...g({client:t,path:{name:e??"",id:n??""}}),enabled:!!(e&&n),staleTime:c})}function b(e,n){const r=m.useMemo(()=>w(n),[n.kind,n.sourceId,n.sinceMinutes,n.limit,n.granularity]);return s({...S({client:t,path:{name:e??""},query:r}),enabled:!!e,staleTime:c})}function I(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a Cloud Run source");return h(e,r)},onSuccess:()=>{e&&f(n)}})}function Q(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a WordPress source");return p(e,r)},onSuccess:()=>{e&&f(n)}})}function R(e){const n=o();return u({mutationFn:r=>{if(!e)throw new Error("Project is required to connect a Vercel source");return C(e,r)},onSuccess:()=>{e&&f(n)}})}function k(e,n){const r=o();return u({mutationFn:d=>{if(!e||!n)throw new Error("Project and sourceId are required to sync");return v(e,n,d??void 0)},onSuccess:()=>{e&&(f(r),r.invalidateQueries({queryKey:y({client:t})}))}})}function a(e){return typeof e=="object"&&e!==null}function E(e){if(e instanceof Error){const n=e;return{message:e.message,code:typeof n.code=="string"?n.code:void 0,details:a(n.details)?n.details:void 0}}if(a(e)){const n=e.error;if(a(n))return{message:typeof n.message=="string"?n.message:"Request failed",code:typeof n.code=="string"?n.code:void 0,details:a(n.details)?n.details:void 0};if(typeof n=="string")return{message:n};const r=e.message;if(typeof r=="string")return{message:r}}return typeof e=="string"?{message:e}:{message:String(e)}}function O(e){return E(e).message}export{A as a,M as b,O as c,Q as d,E as e,R as f,I as g,V as h,k as i,F as t,b as u};
|