@canonry/canonry 4.151.0 → 4.152.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/assets/assets/{AuditHistoryPanel-OMu-hEqT.js → AuditHistoryPanel-DK52bxkQ.js} +1 -1
- package/assets/assets/{BacklinksPage-qadojXWF.js → BacklinksPage-DYApSbsM.js} +1 -1
- package/assets/assets/{HistoryPage-DJQbxQr4.js → HistoryPage-CksKbEHx.js} +1 -1
- package/assets/assets/{MeasurementPropertyPage-3-oL5JIi.js → MeasurementPropertyPage-Ds5A7BiY.js} +1 -1
- package/assets/assets/{ProjectPage-D300FAEv.js → ProjectPage-LzCmnrO2.js} +9 -9
- package/assets/assets/{RunRow-CaCdexBB.js → RunRow-C0oX3797.js} +1 -1
- package/assets/assets/{RunsPage-Cx_sLTg5.js → RunsPage-0qr4V3pn.js} +1 -1
- package/assets/assets/{SettingsPage-Y1J2OIpj.js → SettingsPage-BLMy_cfR.js} +1 -1
- package/assets/assets/{TrafficPage-O4oT28EH.js → TrafficPage-CZj9XGfC.js} +1 -1
- package/assets/assets/{TrafficSourceDetailPage-De6Yq1Dk.js → TrafficSourceDetailPage-BfQAuIQM.js} +1 -1
- package/assets/assets/{arrow-left-PM9P2PAY.js → arrow-left-DdovB6GZ.js} +1 -1
- package/assets/assets/{extract-error-message-RWIQhk6G.js → extract-error-message-yI0U8t_A.js} +1 -1
- package/assets/assets/{index-CLt6zzLW.css → index-CiidhUL0.css} +1 -1
- package/assets/assets/{index-bcpm37b9.js → index-DP74nMja.js} +2 -2
- package/assets/assets/{refresh-cw-qn1tCFGx.js → refresh-cw-SR8k0mBu.js} +1 -1
- package/assets/assets/{trash-2-Bbp_L6NV.js → trash-2-DQF9iFSX.js} +1 -1
- package/assets/assets/v2-overview-adapter-Dz0UmhmS.js +1 -0
- package/assets/index.html +2 -2
- package/package.json +8 -8
- package/assets/assets/v2-overview-adapter-BHmxTmCf.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as s}from"./vendor-tanstack-BjS7iY3g.js";import{u as r,co as t,B as a}from"./index-
|
|
1
|
+
import{j as s}from"./vendor-tanstack-BjS7iY3g.js";import{u as r,co as t,B as a}from"./index-DP74nMja.js";function n({run:e}){const{openRun:i}=r();return s.jsxs("article",{className:"run-row",children:[s.jsxs("div",{className:"run-row-main",children:[s.jsxs("div",{className:"run-row-head",children:[s.jsxs("div",{children:[s.jsx("p",{className:"run-row-title",children:e.summary}),s.jsxs("p",{className:"run-row-subtitle",children:[e.projectName,e.location?` · ${e.location}`:""," · ",e.kindLabel]})]}),s.jsx(t,{status:e.status})]}),s.jsx("p",{className:"run-row-detail",children:e.statusDetail})]}),s.jsxs("dl",{className:"run-row-meta",children:[s.jsxs("div",{children:[s.jsx("dt",{children:"Started"}),s.jsx("dd",{children:e.startedAt})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Duration"}),s.jsx("dd",{children:e.duration})]}),s.jsxs("div",{children:[s.jsx("dt",{children:"Trigger"}),s.jsx("dd",{children:e.triggerLabel})]})]}),s.jsx(a,{variant:"outline",size:"sm",type:"button",onClick:()=>i(e.id),children:"View run"})]})}export{n as R};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{l as L,k as O,r as p,u as v,j as s}from"./vendor-tanstack-BjS7iY3g.js";import{bI as E,bX as Q,aa as f,bJ as P,m as y,ck as N,cl as _,cm as M,cn as W,i as K,B as w,t as R,f as k}from"./index-
|
|
1
|
+
import{l as L,k as O,r as p,u as v,j as s}from"./vendor-tanstack-BjS7iY3g.js";import{bI as E,bX as Q,aa as f,bJ as P,m as y,ck as N,cl as _,cm as M,cn as W,i as K,B as w,t as R,f as k}from"./index-DP74nMja.js";import{R as T}from"./RunRow-C0oX3797.js";import"./vendor-radix-DnzzbllM.js";import"./vendor-recharts-33ACLxsD.js";import"./vendor-markdown-CpDJch4G.js";const g={"30d":{label:"Last 30 days",days:30},"90d":{label:"Last 90 days",days:90},"365d":{label:"Last year",days:365}};function U(l){return new Date(Date.now()-g[l].days*24*60*60*1e3).toISOString()}function X(){const l=E()?.dashboard,a=L({strict:!1}),S=O(),i=Object.values(Q).includes(a.runStatus)?a.runStatus:"all",o=Object.values(f).includes(a.runKind)?a.runKind:"all",d=a.runProject??"all",c=Object.hasOwn(g,a.runWindow??"")?a.runWindow:"30d",m=a.runQuery??"",C=p.useMemo(()=>U(c),[c]),u=v({...P({client:y}),initialData:l?.projects.map(({project:e})=>e),initialDataUpdatedAt:0}),t=v({..._({client:y,query:{limit:1e3,since:C}}),initialData:l?.runs,initialDataUpdatedAt:0,staleTime:N,refetchInterval:e=>e.state.data?.some(r=>r.status==="queued"||r.status==="running")?3e3:N}),h=M(),b=p.useMemo(()=>new Map((u.data??[]).map(e=>[e.id,e.displayName||e.name])),[u.data]),A=p.useMemo(()=>(t.data??[]).map(e=>"projectName"in e?e:W(e,b.get(e.projectId)??"Unknown project")),[b,t.data]),x=m.trim().toLowerCase(),j=A.filter(e=>i!=="all"&&e.status!==i||o!=="all"&&e.kind!==o||d!=="all"&&e.projectId!==d?!1:x?[e.summary,e.projectName,e.kindLabel,e.statusDetail].some(r=>r.toLowerCase().includes(x)):!0),D=i!=="all"||o!=="all"||d!=="all"||m.trim()!==""||c!=="30d",n=e=>{S({to:"/runs",search:r=>({...r,...e}),replace:!0})};if(u.isLoading||t.isLoading)return s.jsxs("div",{className:"page-skeleton",children:[s.jsxs("div",{className:"page-skeleton-header",children:[s.jsx("div",{className:"skeleton-text h-6 w-20"}),s.jsx("div",{className:"skeleton-text-sm w-72"})]}),s.jsx("div",{className:"space-y-2",children:[1,2,3,4].map(e=>s.jsxs("div",{className:"rounded-xl border border-default bg-surface p-3 flex items-center gap-3",children:[s.jsxs("div",{className:"flex-1 space-y-1.5",children:[s.jsx("div",{className:"skeleton-text w-40"}),s.jsx("div",{className:"skeleton-text-sm w-56"})]}),s.jsx("div",{className:"skeleton h-5 w-16 rounded-full"})]},e))})]});const I=async()=>{try{await h.mutateAsync(void 0)}catch{}};return s.jsxs("div",{className:"page-container",children:[s.jsxs("div",{className:"page-header",children:[s.jsxs("div",{className:"page-header-left",children:[s.jsx("h1",{className:"page-title",children:"Runs"}),s.jsx("p",{className:"page-subtitle",children:"Recent jobs across all projects."})]}),!K()&&s.jsx(w,{type:"button",variant:"outline",size:"sm",disabled:h.isPending,onClick:()=>{I()},children:h.isPending?"Queueing…":"Run all projects"})]}),s.jsxs("section",{children:[s.jsx("div",{className:"filter-row",role:"toolbar","aria-label":"Run filters",children:["all","queued","running","completed","partial","failed","cancelled"].map(e=>s.jsx("button",{className:`filter-chip ${i===e?"filter-chip-active":""}`,type:"button","aria-pressed":i===e,onClick:()=>n({runStatus:e==="all"?void 0:e}),children:e==="all"?"All runs":R(e)},e))}),s.jsxs("div",{className:"mb-4 grid gap-2 sm:grid-cols-2 lg:grid-cols-[minmax(12rem,1fr)_minmax(10rem,0.7fr)_minmax(9rem,0.6fr)_minmax(9rem,0.6fr)_auto]",children:[s.jsx("input",{type:"search","aria-label":"Search runs",value:m,onChange:e=>n({runQuery:e.target.value||void 0}),placeholder:"Search runs or projects",className:"min-h-11 rounded-md border border-base bg-bg px-3 text-sm text-strong placeholder-mono-600 focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600"}),s.jsxs("select",{"aria-label":"Filter runs by project",value:d,onChange:e=>n({runProject:e.target.value==="all"?void 0:e.target.value}),className:"min-h-11 rounded-md border border-base bg-bg px-3 text-sm text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:[s.jsx("option",{value:"all",children:"All projects"}),(u.data??[]).map(e=>s.jsx("option",{value:e.id,children:e.displayName||e.name},e.id))]}),s.jsxs("select",{"aria-label":"Filter runs by type",value:o,onChange:e=>n({runKind:e.target.value==="all"?void 0:e.target.value}),className:"min-h-11 rounded-md border border-base bg-bg px-3 text-sm text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:[s.jsx("option",{value:"all",children:"All run types"}),Object.values(f).map(e=>s.jsx("option",{value:e,children:R(e.replaceAll("-"," "))},e))]}),s.jsx("select",{"aria-label":"Filter runs by date range",value:c,onChange:e=>n({runWindow:e.target.value==="30d"?void 0:e.target.value}),className:"min-h-11 rounded-md border border-base bg-bg px-3 text-sm text-strong focus:outline-none focus-visible:ring-1 focus-visible:ring-mono-600",children:Object.entries(g).map(([e,r])=>s.jsx("option",{value:e,children:r.label},e))}),D?s.jsx(w,{type:"button",variant:"ghost",size:"sm",onClick:()=>n({runStatus:void 0,runKind:void 0,runProject:void 0,runWindow:void 0,runQuery:void 0}),children:"Clear"}):s.jsx("span",{})]}),t.isError?s.jsxs(k,{className:"surface-card empty-card",children:[s.jsx("h2",{children:"Run history unavailable"}),s.jsx("p",{children:t.error instanceof Error?t.error.message:"Could not load run history."})]}):null,s.jsx("div",{className:"run-list",children:!t.isError&&j.length>0?j.map(e=>s.jsx(T,{run:e},e.id)):t.isError?null:s.jsxs(k,{className:"surface-card empty-card",children:[s.jsx("h2",{children:"No runs match this filter"}),s.jsx("p",{children:"Change the project, type, status, or date range to widen the history."})]})})]})]})}export{X as RunsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as n,j as e}from"./vendor-tanstack-BjS7iY3g.js";import{B as y,j as B,cr as K,O as I,cs as L,ct as T,cu as _,cv as F,f as k,T as v,cw as V,cx as Q,bI as W,cy as Y,cz as J,cA as X,cB as A,cC as R}from"./index-bcpm37b9.js";import"./vendor-radix-DnzzbllM.js";import"./vendor-recharts-33ACLxsD.js";import"./vendor-markdown-CpDJch4G.js";function Z({providerName:t,keyUrl:c,modelHint:r,onSaved:p}){const m=t.toLowerCase()==="local",[l,d]=n.useState(""),[x,u]=n.useState(""),[f,h]=n.useState(""),[j,a]=n.useState(""),[i,b]=n.useState(""),[g,N]=n.useState(""),[S,P]=n.useState(!1),[C,s]=n.useState(null),[$,M]=n.useState(!1),G=m?x.trim().length>0:l.trim().length>0;async function q(){if(G){P(!0),s(null),M(!1);try{const o=H=>{const O=parseInt(H.trim(),10);return Number.isFinite(O)&&O>0?O:void 0},w={},E=o(j);E!==void 0&&(w.maxConcurrency=E);const U=o(i);U!==void 0&&(w.maxRequestsPerMinute=U);const D=o(g);D!==void 0&&(w.maxRequestsPerDay=D),await K(t.toLowerCase(),{...l.trim()?{apiKey:l.trim()}:{},...x.trim()?{baseUrl:x.trim()}:{},...f.trim()?{model:f.trim()}:{},...Object.keys(w).length>0?{quota:w}:{}}),d(""),u(""),h(""),a(""),b(""),N(""),M(!0),I({title:"Provider updated",detail:`${t} configuration saved.`,tone:"positive",dedupeKey:`settings:provider:${t}`,dedupeMode:"replace"}),p()}catch(o){s(o instanceof Error?o.message:"Failed to update provider")}finally{P(!1)}}}const z=r??"Use default model";return e.jsxs("div",{className:"mt-3 rounded-lg border border-base bg-bg-elevated/40 p-3 space-y-2",children:[m&&e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-secondary",htmlFor:`base-url-${t}`,children:"Base URL"}),e.jsx("input",{id:`base-url-${t}`,type:"text",className:"mt-0.5 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",placeholder:"http://localhost:11434/v1",value:x,onChange:o=>u(o.target.value)}),e.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Use any OpenAI-compatible endpoint, such as Ollama or vLLM."})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"text-sm text-secondary",htmlFor:`api-key-${t}`,children:["API key",m?" (optional)":""]}),c&&e.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-secondary hover:text-neutral underline underline-offset-2",children:["Get API key ","↗"]})]}),e.jsx("input",{id:`api-key-${t}`,type:"password",className:"mt-0.5 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",placeholder:m?"Optional. Most local servers do not need one.":`Enter ${t} API key`,value:l,onChange:o=>d(o.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-secondary",htmlFor:`model-${t}`,children:"Model (optional)"}),e.jsx("input",{id:`model-${t}`,type:"text",className:"mt-0.5 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",placeholder:z,value:f,onChange:o=>h(o.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-secondary",children:"Quota (optional)"}),e.jsxs("div",{className:"mt-0.5 grid grid-cols-3 gap-1.5",children:[e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",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",placeholder:"Concurrent",value:j,onChange:o=>a(o.target.value)}),e.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Max concurrent"})]}),e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",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",placeholder:"/min",value:i,onChange:o=>b(o.target.value)}),e.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Per minute"})]}),e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",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",placeholder:"/day",value:g,onChange:o=>N(o.target.value)}),e.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Per day"})]})]})]}),C&&e.jsx("p",{className:"text-sm text-negative-400",children:C}),$&&e.jsx("p",{className:"text-sm text-positive-400",children:"Provider updated."}),e.jsx(y,{type:"button",size:"sm",disabled:!G||S,onClick:B(q),children:S?"Saving...":"Save"})]})}function ee({onSaved:t}){const[c,r]=n.useState(""),[p,m]=n.useState(""),[l,d]=n.useState(!1),[x,u]=n.useState(null),[f,h]=n.useState(!1),j=c.trim().length>0&&p.trim().length>0,a=typeof window>"u"?void 0:L(window.location,window.__CANONRY_CONFIG__?.basePath),i=a?T(a):void 0;async function b(){if(j){d(!0),u(null),h(!1);try{await _({clientId:c.trim(),clientSecret:p.trim()}),r(""),m(""),h(!0),I({title:"Google OAuth app updated",detail:"Dashboard Google credentials were saved.",tone:"positive",dedupeKey:"settings:google-oauth",dedupeMode:"replace"}),t()}catch(g){u(g instanceof Error?g.message:"Failed to update Google OAuth credentials")}finally{d(!1)}}}return e.jsxs("div",{className:"mt-3 rounded-lg border border-base bg-bg-elevated/40 p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm text-secondary",htmlFor:"google-client-id",children:"Client ID"}),e.jsxs("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-secondary hover:text-neutral underline underline-offset-2",children:["Google Cloud ","↗"]})]}),e.jsx("input",{id:"google-client-id",type:"text",className:"mt-0.5 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",placeholder:"Google OAuth client ID",value:c,onChange:g=>r(g.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-secondary",htmlFor:"google-client-secret",children:"Client secret"}),e.jsx("input",{id:"google-client-secret",type:"password",className:"mt-0.5 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",placeholder:"Google OAuth client secret",value:p,onChange:g=>m(g.target.value)})]}),i&&e.jsxs("div",{className:"rounded border border-default bg-surface px-3 py-2",children:[e.jsx("p",{className:"text-sm text-secondary",children:"Authorized redirect URI"}),e.jsx("code",{className:"mt-1 block break-all text-xs text-strong",children:i})]}),x&&e.jsx("p",{className:"text-sm text-negative-400",children:x}),f&&e.jsx("p",{className:"text-sm text-positive-400",children:"Google OAuth credentials updated."}),e.jsx(y,{type:"button",size:"sm",disabled:!j||l,onClick:B(b),children:l?"Saving...":"Save Google OAuth app"})]})}function se(t){const c=t.replace(/^Error:\s*/,"").replace(/\s+/g," ").trim();return c?c.length>140?`${c.slice(0,137)}...`:c:"Unknown error"}function te(){const[t,c]=n.useState(null),[r,p]=n.useState(null),[m,l]=n.useState(!1),[d,x]=n.useState("localhost"),[u,f]=n.useState("9222"),[h,j]=n.useState(!1);return n.useEffect(()=>{F().then(a=>{c(a),p(null)}).catch(a=>{const i=a instanceof Error?a.message:String(a);i.includes("501")||p(i)})},[]),e.jsxs(k,{className:"surface-card",children:[e.jsxs("div",{className:"section-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Browser provider"}),e.jsx("h2",{children:"ChatGPT (CDP)"})]}),e.jsx(v,{tone:t?.connected?"positive":"caution",children:t?.connected?"Connected":"Not connected"})]}),e.jsx("p",{className:`mt-2 text-sm ${r?"text-negative":"text-secondary"}`,role:r?"alert":void 0,children:r?e.jsxs(e.Fragment,{children:["Could not check Chrome: ",se(r),". Check that Chrome is running with remote debugging, then configure the endpoint."]}):t?.connected?"Chrome is available for this provider.":"Connect Chrome to enable this provider."}),e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-secondary hover:text-strong",children:"Advanced"}),e.jsxs("dl",{className:"definition-list mt-2",children:[t?.endpoint&&e.jsxs("div",{children:[e.jsx("dt",{children:"Endpoint"}),e.jsx("dd",{className:"font-mono text-xs",children:t.endpoint})]}),t?.browserVersion&&e.jsxs("div",{children:[e.jsx("dt",{children:"Browser"}),e.jsx("dd",{className:"text-xs",children:t.browserVersion})]}),t?.targets&&t.targets.length>0&&e.jsxs("div",{children:[e.jsx("dt",{children:"Tabs"}),e.jsx("dd",{children:t.targets.map(a=>e.jsxs("span",{className:"mr-2",children:[a.name,": ",a.alive?"● alive":"○ idle"]},a.name))})]})]})]}),e.jsx("div",{className:"mt-2",children:e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:()=>l(!m),children:m?"Cancel":t?.connected?"Update endpoint":"Configure"})}),m&&e.jsxs("form",{className:"mt-3 flex flex-col gap-2",onSubmit:B(async a=>{a.preventDefault(),j(!0);try{await V(d,parseInt(u,10)||9222);const i=await F();c(i),p(null),l(!1),I({title:"CDP endpoint saved",detail:`${d}:${parseInt(u,10)||9222} is now configured.`,tone:"positive",dedupeKey:"settings:cdp",dedupeMode:"replace"})}catch(i){p(i instanceof Error?i.message:String(i))}finally{j(!1)}}),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 rounded border border-strong bg-bg-elevated px-2 py-1 text-sm text-heading placeholder-mono-500 focus:outline-none focus:ring-1 focus:ring-mono-500",placeholder:"localhost",value:d,onChange:a=>x(a.target.value),"aria-label":"CDP host"}),e.jsx("input",{className:"w-24 rounded border border-strong bg-bg-elevated px-2 py-1 text-sm text-heading placeholder-mono-500 focus:outline-none focus:ring-1 focus:ring-mono-500",placeholder:"9222",value:u,onChange:a=>f(a.target.value),"aria-label":"CDP port"})]}),e.jsx("div",{children:e.jsx(y,{type:"submit",size:"sm",disabled:h,children:h?"Saving…":"Save endpoint"})})]})]})}const ne={apiStatus:{state:"checking",detail:"Checking service health"},workerStatus:{state:"checking",detail:"Checking service health"}};function de(){return e.jsx(Q,{title:"Settings",children:e.jsx(ae,{})})}function ae(){const t=W(),{dashboard:c}=Y(),r=c?.settings??t?.dashboard?.settings,l=J(!t,t?.health).data??t?.health??ne,[d,x]=n.useState(null),[u,f]=n.useState(!1),[h,j]=n.useState(!1),[a,i]=n.useState(""),[b,g]=n.useState(!1),[N,S]=n.useState(null),[P,C]=n.useState(!1);return r?e.jsxs("div",{className:"page-container",children:[e.jsx("div",{className:"page-header",children:e.jsxs("div",{className:"page-header-left",children:[e.jsx("h1",{className:"page-title",children:"Settings"}),e.jsx("p",{className:"page-subtitle",children:"Connections and answer engines."})]})}),e.jsxs("section",{className:"space-y-6",children:[e.jsxs("section",{children:[e.jsx("div",{className:"section-head",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Answer engines"}),e.jsx("h2",{children:"Providers"})]})}),e.jsx("div",{className:"divide-y divide-default border-y border-default",children:r.providerStatuses.map(s=>e.jsxs("div",{className:"py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-heading",children:s.displayName??s.name}),e.jsx("p",{className:"text-sm text-secondary",children:s.detail})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{tone:s.state==="ready"?"positive":"caution",children:s.state==="ready"?"Ready":"Needs config"}),e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:()=>x(d===s.name?null:s.name),children:d===s.name?"Cancel":s.state==="ready"?"Update":"Configure"})]})]}),e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-secondary hover:text-strong",children:"Advanced"}),e.jsxs("dl",{className:"definition-list mt-2",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsxs("dd",{className:"font-mono text-xs",children:[s.model??s.defaultModel??"unknown",!s.model&&s.defaultModel&&e.jsx("span",{className:"ml-1 font-sans text-muted",children:"(default)"})]})]}),s.quota&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Concurrency"}),e.jsx("dd",{children:s.quota.maxConcurrency})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Rate limit"}),e.jsxs("dd",{children:[s.quota.maxRequestsPerMinute,"/min · ",s.quota.maxRequestsPerDay,"/day"]})]})]})]})]}),d===s.name&&e.jsx(Z,{providerName:s.name,keyUrl:s.keyUrl,modelHint:s.modelHint,onSaved:()=>{x(null)}})]},s.name))})]}),e.jsxs("section",{children:[e.jsx("div",{className:"section-head",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Connections"}),e.jsx("h2",{children:"Search and browser"})]})}),e.jsxs("div",{className:"settings-grid",children:[e.jsxs(k,{className:"surface-card",children:[e.jsxs("div",{className:"section-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Google"}),e.jsx("h2",{children:"Search Console OAuth"})]}),e.jsx(v,{tone:r.google.state==="ready"?"positive":"caution",children:r.google.state==="ready"?"Ready":"Needs config"})]}),e.jsx("p",{className:"mt-2 text-sm text-secondary",children:r.google.detail}),e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-secondary hover:text-strong",children:"Advanced"}),e.jsxs("dl",{className:"definition-list mt-2",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Auth model"}),e.jsx("dd",{children:"One app credential set, then one OAuth connection per project domain"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Storage"}),e.jsx("dd",{className:"font-mono text-xs",children:"~/.canonry/config.yaml"})]})]})]}),e.jsx("div",{className:"mt-2",children:e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:()=>f(!u),children:u?"Cancel":r.google.state==="ready"?"Update OAuth app":"Configure Google OAuth"})}),u&&e.jsx(ee,{onSaved:()=>{f(!1)}})]}),e.jsxs(k,{className:"surface-card",children:[e.jsxs("div",{className:"section-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Bing"}),e.jsx("h2",{children:"Webmaster Tools"})]}),e.jsx(v,{tone:r.bing.state==="ready"?"positive":"caution",children:r.bing.state==="ready"?"Ready":"Needs config"})]}),e.jsx("p",{className:"mt-2 text-sm text-secondary",children:r.bing.detail}),e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-secondary hover:text-strong",children:"Advanced"}),e.jsxs("dl",{className:"definition-list mt-2",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Auth model"}),e.jsx("dd",{children:"API key authentication. OAuth is not required."})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Storage"}),e.jsx("dd",{className:"font-mono text-xs",children:"~/.canonry/config.yaml"})]})]})]}),e.jsx("div",{className:"mt-2",children:e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:()=>j(!h),children:h?"Cancel":r.bing.state==="ready"?"Update API key":"Configure Bing"})}),h&&e.jsxs("div",{className:"mt-3 rounded-lg border border-base bg-bg-elevated/40 p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm text-secondary",htmlFor:"bing-api-key",children:"API key"}),e.jsx("a",{href:"https://www.bing.com/webmasters/",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-secondary hover:text-neutral underline underline-offset-2",children:"Bing Webmaster Tools"})]}),e.jsx("input",{id:"bing-api-key",type:"password",className:"mt-0.5 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",placeholder:"Bing Webmaster Tools API key",value:a,onChange:s=>i(s.target.value)})]}),e.jsx("p",{className:"text-sm text-secondary",children:"Used for project-level Bing connections."}),N&&e.jsx("p",{className:"text-sm text-negative-400",children:N}),P&&e.jsx("p",{className:"text-sm text-positive-400",children:"Bing API key updated."}),e.jsx(y,{type:"button",size:"sm",disabled:!a.trim()||b,onClick:B(async()=>{if(a.trim()){g(!0),S(null),C(!1);try{await X(a.trim()),i(""),C(!0),j(!1),I({title:"Bing API key updated",detail:"Dashboard Bing credentials were saved.",tone:"positive",dedupeKey:"settings:bing",dedupeMode:"replace"})}catch(s){S(s instanceof Error?s.message:"Failed to update Bing API key")}finally{g(!1)}}}),children:b?"Saving...":"Save Bing API key"})]})]}),e.jsx(te,{})]})]}),e.jsxs(k,{className:"surface-card",children:[e.jsx("div",{className:"section-head",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Service health"}),e.jsx("h2",{children:"API and worker"})]})}),e.jsxs("div",{className:"compact-stack",children:[e.jsxs("div",{className:"health-row",children:[e.jsxs("div",{children:[e.jsx("p",{className:"run-row-title",children:"API"}),l.apiStatus.state!=="ok"&&e.jsx("p",{className:"mt-1 text-sm text-secondary",children:A(l.apiStatus)})]}),e.jsx(v,{tone:R(l.apiStatus),title:A(l.apiStatus),children:l.apiStatus.state==="ok"?"Healthy":"Attention"})]}),e.jsxs("div",{className:"health-row",children:[e.jsxs("div",{children:[e.jsx("p",{className:"run-row-title",children:"Worker"}),l.workerStatus.state!=="ok"&&e.jsx("p",{className:"mt-1 text-sm text-secondary",children:A(l.workerStatus)})]}),e.jsx(v,{tone:R(l.workerStatus),title:A(l.workerStatus),children:l.workerStatus.state==="ok"?"Healthy":"Attention"})]})]})]})]}),e.jsxs("details",{className:"page-section",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-secondary hover:text-strong",children:"Self-hosting details"}),e.jsxs(k,{className:"surface-card mt-3",children:[e.jsx("ul",{className:"detail-list",children:r.selfHostNotes.map(s=>e.jsx("li",{children:s},s))}),e.jsx("p",{className:"supporting-copy",children:r.bootstrapNote})]})]})]}):null}export{de as SettingsPage};
|
|
1
|
+
import{r as n,j as e}from"./vendor-tanstack-BjS7iY3g.js";import{B as y,j as B,cr as K,O as I,cs as L,ct as T,cu as _,cv as F,f as k,T as v,cw as V,cx as Q,bI as W,cy as Y,cz as J,cA as X,cB as A,cC as R}from"./index-DP74nMja.js";import"./vendor-radix-DnzzbllM.js";import"./vendor-recharts-33ACLxsD.js";import"./vendor-markdown-CpDJch4G.js";function Z({providerName:t,keyUrl:c,modelHint:r,onSaved:p}){const m=t.toLowerCase()==="local",[l,d]=n.useState(""),[x,u]=n.useState(""),[f,h]=n.useState(""),[j,a]=n.useState(""),[i,b]=n.useState(""),[g,N]=n.useState(""),[S,P]=n.useState(!1),[C,s]=n.useState(null),[$,M]=n.useState(!1),G=m?x.trim().length>0:l.trim().length>0;async function q(){if(G){P(!0),s(null),M(!1);try{const o=H=>{const O=parseInt(H.trim(),10);return Number.isFinite(O)&&O>0?O:void 0},w={},E=o(j);E!==void 0&&(w.maxConcurrency=E);const U=o(i);U!==void 0&&(w.maxRequestsPerMinute=U);const D=o(g);D!==void 0&&(w.maxRequestsPerDay=D),await K(t.toLowerCase(),{...l.trim()?{apiKey:l.trim()}:{},...x.trim()?{baseUrl:x.trim()}:{},...f.trim()?{model:f.trim()}:{},...Object.keys(w).length>0?{quota:w}:{}}),d(""),u(""),h(""),a(""),b(""),N(""),M(!0),I({title:"Provider updated",detail:`${t} configuration saved.`,tone:"positive",dedupeKey:`settings:provider:${t}`,dedupeMode:"replace"}),p()}catch(o){s(o instanceof Error?o.message:"Failed to update provider")}finally{P(!1)}}}const z=r??"Use default model";return e.jsxs("div",{className:"mt-3 rounded-lg border border-base bg-bg-elevated/40 p-3 space-y-2",children:[m&&e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-secondary",htmlFor:`base-url-${t}`,children:"Base URL"}),e.jsx("input",{id:`base-url-${t}`,type:"text",className:"mt-0.5 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",placeholder:"http://localhost:11434/v1",value:x,onChange:o=>u(o.target.value)}),e.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Use any OpenAI-compatible endpoint, such as Ollama or vLLM."})]}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("label",{className:"text-sm text-secondary",htmlFor:`api-key-${t}`,children:["API key",m?" (optional)":""]}),c&&e.jsxs("a",{href:c,target:"_blank",rel:"noopener noreferrer",className:"text-sm text-secondary hover:text-neutral underline underline-offset-2",children:["Get API key ","↗"]})]}),e.jsx("input",{id:`api-key-${t}`,type:"password",className:"mt-0.5 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",placeholder:m?"Optional. Most local servers do not need one.":`Enter ${t} API key`,value:l,onChange:o=>d(o.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-secondary",htmlFor:`model-${t}`,children:"Model (optional)"}),e.jsx("input",{id:`model-${t}`,type:"text",className:"mt-0.5 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",placeholder:z,value:f,onChange:o=>h(o.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-secondary",children:"Quota (optional)"}),e.jsxs("div",{className:"mt-0.5 grid grid-cols-3 gap-1.5",children:[e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",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",placeholder:"Concurrent",value:j,onChange:o=>a(o.target.value)}),e.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Max concurrent"})]}),e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",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",placeholder:"/min",value:i,onChange:o=>b(o.target.value)}),e.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Per minute"})]}),e.jsxs("div",{children:[e.jsx("input",{type:"number",min:"1",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",placeholder:"/day",value:g,onChange:o=>N(o.target.value)}),e.jsx("p",{className:"mt-1 text-sm text-secondary",children:"Per day"})]})]})]}),C&&e.jsx("p",{className:"text-sm text-negative-400",children:C}),$&&e.jsx("p",{className:"text-sm text-positive-400",children:"Provider updated."}),e.jsx(y,{type:"button",size:"sm",disabled:!G||S,onClick:B(q),children:S?"Saving...":"Save"})]})}function ee({onSaved:t}){const[c,r]=n.useState(""),[p,m]=n.useState(""),[l,d]=n.useState(!1),[x,u]=n.useState(null),[f,h]=n.useState(!1),j=c.trim().length>0&&p.trim().length>0,a=typeof window>"u"?void 0:L(window.location,window.__CANONRY_CONFIG__?.basePath),i=a?T(a):void 0;async function b(){if(j){d(!0),u(null),h(!1);try{await _({clientId:c.trim(),clientSecret:p.trim()}),r(""),m(""),h(!0),I({title:"Google OAuth app updated",detail:"Dashboard Google credentials were saved.",tone:"positive",dedupeKey:"settings:google-oauth",dedupeMode:"replace"}),t()}catch(g){u(g instanceof Error?g.message:"Failed to update Google OAuth credentials")}finally{d(!1)}}}return e.jsxs("div",{className:"mt-3 rounded-lg border border-base bg-bg-elevated/40 p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm text-secondary",htmlFor:"google-client-id",children:"Client ID"}),e.jsxs("a",{href:"https://console.cloud.google.com/apis/credentials",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-secondary hover:text-neutral underline underline-offset-2",children:["Google Cloud ","↗"]})]}),e.jsx("input",{id:"google-client-id",type:"text",className:"mt-0.5 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",placeholder:"Google OAuth client ID",value:c,onChange:g=>r(g.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm text-secondary",htmlFor:"google-client-secret",children:"Client secret"}),e.jsx("input",{id:"google-client-secret",type:"password",className:"mt-0.5 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",placeholder:"Google OAuth client secret",value:p,onChange:g=>m(g.target.value)})]}),i&&e.jsxs("div",{className:"rounded border border-default bg-surface px-3 py-2",children:[e.jsx("p",{className:"text-sm text-secondary",children:"Authorized redirect URI"}),e.jsx("code",{className:"mt-1 block break-all text-xs text-strong",children:i})]}),x&&e.jsx("p",{className:"text-sm text-negative-400",children:x}),f&&e.jsx("p",{className:"text-sm text-positive-400",children:"Google OAuth credentials updated."}),e.jsx(y,{type:"button",size:"sm",disabled:!j||l,onClick:B(b),children:l?"Saving...":"Save Google OAuth app"})]})}function se(t){const c=t.replace(/^Error:\s*/,"").replace(/\s+/g," ").trim();return c?c.length>140?`${c.slice(0,137)}...`:c:"Unknown error"}function te(){const[t,c]=n.useState(null),[r,p]=n.useState(null),[m,l]=n.useState(!1),[d,x]=n.useState("localhost"),[u,f]=n.useState("9222"),[h,j]=n.useState(!1);return n.useEffect(()=>{F().then(a=>{c(a),p(null)}).catch(a=>{const i=a instanceof Error?a.message:String(a);i.includes("501")||p(i)})},[]),e.jsxs(k,{className:"surface-card",children:[e.jsxs("div",{className:"section-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Browser provider"}),e.jsx("h2",{children:"ChatGPT (CDP)"})]}),e.jsx(v,{tone:t?.connected?"positive":"caution",children:t?.connected?"Connected":"Not connected"})]}),e.jsx("p",{className:`mt-2 text-sm ${r?"text-negative":"text-secondary"}`,role:r?"alert":void 0,children:r?e.jsxs(e.Fragment,{children:["Could not check Chrome: ",se(r),". Check that Chrome is running with remote debugging, then configure the endpoint."]}):t?.connected?"Chrome is available for this provider.":"Connect Chrome to enable this provider."}),e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-secondary hover:text-strong",children:"Advanced"}),e.jsxs("dl",{className:"definition-list mt-2",children:[t?.endpoint&&e.jsxs("div",{children:[e.jsx("dt",{children:"Endpoint"}),e.jsx("dd",{className:"font-mono text-xs",children:t.endpoint})]}),t?.browserVersion&&e.jsxs("div",{children:[e.jsx("dt",{children:"Browser"}),e.jsx("dd",{className:"text-xs",children:t.browserVersion})]}),t?.targets&&t.targets.length>0&&e.jsxs("div",{children:[e.jsx("dt",{children:"Tabs"}),e.jsx("dd",{children:t.targets.map(a=>e.jsxs("span",{className:"mr-2",children:[a.name,": ",a.alive?"● alive":"○ idle"]},a.name))})]})]})]}),e.jsx("div",{className:"mt-2",children:e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:()=>l(!m),children:m?"Cancel":t?.connected?"Update endpoint":"Configure"})}),m&&e.jsxs("form",{className:"mt-3 flex flex-col gap-2",onSubmit:B(async a=>{a.preventDefault(),j(!0);try{await V(d,parseInt(u,10)||9222);const i=await F();c(i),p(null),l(!1),I({title:"CDP endpoint saved",detail:`${d}:${parseInt(u,10)||9222} is now configured.`,tone:"positive",dedupeKey:"settings:cdp",dedupeMode:"replace"})}catch(i){p(i instanceof Error?i.message:String(i))}finally{j(!1)}}),children:[e.jsxs("div",{className:"flex gap-2",children:[e.jsx("input",{className:"flex-1 rounded border border-strong bg-bg-elevated px-2 py-1 text-sm text-heading placeholder-mono-500 focus:outline-none focus:ring-1 focus:ring-mono-500",placeholder:"localhost",value:d,onChange:a=>x(a.target.value),"aria-label":"CDP host"}),e.jsx("input",{className:"w-24 rounded border border-strong bg-bg-elevated px-2 py-1 text-sm text-heading placeholder-mono-500 focus:outline-none focus:ring-1 focus:ring-mono-500",placeholder:"9222",value:u,onChange:a=>f(a.target.value),"aria-label":"CDP port"})]}),e.jsx("div",{children:e.jsx(y,{type:"submit",size:"sm",disabled:h,children:h?"Saving…":"Save endpoint"})})]})]})}const ne={apiStatus:{state:"checking",detail:"Checking service health"},workerStatus:{state:"checking",detail:"Checking service health"}};function de(){return e.jsx(Q,{title:"Settings",children:e.jsx(ae,{})})}function ae(){const t=W(),{dashboard:c}=Y(),r=c?.settings??t?.dashboard?.settings,l=J(!t,t?.health).data??t?.health??ne,[d,x]=n.useState(null),[u,f]=n.useState(!1),[h,j]=n.useState(!1),[a,i]=n.useState(""),[b,g]=n.useState(!1),[N,S]=n.useState(null),[P,C]=n.useState(!1);return r?e.jsxs("div",{className:"page-container",children:[e.jsx("div",{className:"page-header",children:e.jsxs("div",{className:"page-header-left",children:[e.jsx("h1",{className:"page-title",children:"Settings"}),e.jsx("p",{className:"page-subtitle",children:"Connections and answer engines."})]})}),e.jsxs("section",{className:"space-y-6",children:[e.jsxs("section",{children:[e.jsx("div",{className:"section-head",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Answer engines"}),e.jsx("h2",{children:"Providers"})]})}),e.jsx("div",{className:"divide-y divide-default border-y border-default",children:r.providerStatuses.map(s=>e.jsxs("div",{className:"py-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-heading",children:s.displayName??s.name}),e.jsx("p",{className:"text-sm text-secondary",children:s.detail})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(v,{tone:s.state==="ready"?"positive":"caution",children:s.state==="ready"?"Ready":"Needs config"}),e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:()=>x(d===s.name?null:s.name),children:d===s.name?"Cancel":s.state==="ready"?"Update":"Configure"})]})]}),e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-secondary hover:text-strong",children:"Advanced"}),e.jsxs("dl",{className:"definition-list mt-2",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Model"}),e.jsxs("dd",{className:"font-mono text-xs",children:[s.model??s.defaultModel??"unknown",!s.model&&s.defaultModel&&e.jsx("span",{className:"ml-1 font-sans text-muted",children:"(default)"})]})]}),s.quota&&e.jsxs(e.Fragment,{children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Concurrency"}),e.jsx("dd",{children:s.quota.maxConcurrency})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Rate limit"}),e.jsxs("dd",{children:[s.quota.maxRequestsPerMinute,"/min · ",s.quota.maxRequestsPerDay,"/day"]})]})]})]})]}),d===s.name&&e.jsx(Z,{providerName:s.name,keyUrl:s.keyUrl,modelHint:s.modelHint,onSaved:()=>{x(null)}})]},s.name))})]}),e.jsxs("section",{children:[e.jsx("div",{className:"section-head",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Connections"}),e.jsx("h2",{children:"Search and browser"})]})}),e.jsxs("div",{className:"settings-grid",children:[e.jsxs(k,{className:"surface-card",children:[e.jsxs("div",{className:"section-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Google"}),e.jsx("h2",{children:"Search Console OAuth"})]}),e.jsx(v,{tone:r.google.state==="ready"?"positive":"caution",children:r.google.state==="ready"?"Ready":"Needs config"})]}),e.jsx("p",{className:"mt-2 text-sm text-secondary",children:r.google.detail}),e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-secondary hover:text-strong",children:"Advanced"}),e.jsxs("dl",{className:"definition-list mt-2",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Auth model"}),e.jsx("dd",{children:"One app credential set, then one OAuth connection per project domain"})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Storage"}),e.jsx("dd",{className:"font-mono text-xs",children:"~/.canonry/config.yaml"})]})]})]}),e.jsx("div",{className:"mt-2",children:e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:()=>f(!u),children:u?"Cancel":r.google.state==="ready"?"Update OAuth app":"Configure Google OAuth"})}),u&&e.jsx(ee,{onSaved:()=>{f(!1)}})]}),e.jsxs(k,{className:"surface-card",children:[e.jsxs("div",{className:"section-head",children:[e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Bing"}),e.jsx("h2",{children:"Webmaster Tools"})]}),e.jsx(v,{tone:r.bing.state==="ready"?"positive":"caution",children:r.bing.state==="ready"?"Ready":"Needs config"})]}),e.jsx("p",{className:"mt-2 text-sm text-secondary",children:r.bing.detail}),e.jsxs("details",{className:"mt-3",children:[e.jsx("summary",{className:"cursor-pointer text-sm text-secondary hover:text-strong",children:"Advanced"}),e.jsxs("dl",{className:"definition-list mt-2",children:[e.jsxs("div",{children:[e.jsx("dt",{children:"Auth model"}),e.jsx("dd",{children:"API key authentication. OAuth is not required."})]}),e.jsxs("div",{children:[e.jsx("dt",{children:"Storage"}),e.jsx("dd",{className:"font-mono text-xs",children:"~/.canonry/config.yaml"})]})]})]}),e.jsx("div",{className:"mt-2",children:e.jsx(y,{type:"button",variant:"outline",size:"sm",onClick:()=>j(!h),children:h?"Cancel":r.bing.state==="ready"?"Update API key":"Configure Bing"})}),h&&e.jsxs("div",{className:"mt-3 rounded-lg border border-base bg-bg-elevated/40 p-3 space-y-2",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsx("label",{className:"text-sm text-secondary",htmlFor:"bing-api-key",children:"API key"}),e.jsx("a",{href:"https://www.bing.com/webmasters/",target:"_blank",rel:"noopener noreferrer",className:"text-sm text-secondary hover:text-neutral underline underline-offset-2",children:"Bing Webmaster Tools"})]}),e.jsx("input",{id:"bing-api-key",type:"password",className:"mt-0.5 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",placeholder:"Bing Webmaster Tools API key",value:a,onChange:s=>i(s.target.value)})]}),e.jsx("p",{className:"text-sm text-secondary",children:"Used for project-level Bing connections."}),N&&e.jsx("p",{className:"text-sm text-negative-400",children:N}),P&&e.jsx("p",{className:"text-sm text-positive-400",children:"Bing API key updated."}),e.jsx(y,{type:"button",size:"sm",disabled:!a.trim()||b,onClick:B(async()=>{if(a.trim()){g(!0),S(null),C(!1);try{await X(a.trim()),i(""),C(!0),j(!1),I({title:"Bing API key updated",detail:"Dashboard Bing credentials were saved.",tone:"positive",dedupeKey:"settings:bing",dedupeMode:"replace"})}catch(s){S(s instanceof Error?s.message:"Failed to update Bing API key")}finally{g(!1)}}}),children:b?"Saving...":"Save Bing API key"})]})]}),e.jsx(te,{})]})]}),e.jsxs(k,{className:"surface-card",children:[e.jsx("div",{className:"section-head",children:e.jsxs("div",{children:[e.jsx("p",{className:"eyebrow eyebrow-soft",children:"Service health"}),e.jsx("h2",{children:"API and worker"})]})}),e.jsxs("div",{className:"compact-stack",children:[e.jsxs("div",{className:"health-row",children:[e.jsxs("div",{children:[e.jsx("p",{className:"run-row-title",children:"API"}),l.apiStatus.state!=="ok"&&e.jsx("p",{className:"mt-1 text-sm text-secondary",children:A(l.apiStatus)})]}),e.jsx(v,{tone:R(l.apiStatus),title:A(l.apiStatus),children:l.apiStatus.state==="ok"?"Healthy":"Attention"})]}),e.jsxs("div",{className:"health-row",children:[e.jsxs("div",{children:[e.jsx("p",{className:"run-row-title",children:"Worker"}),l.workerStatus.state!=="ok"&&e.jsx("p",{className:"mt-1 text-sm text-secondary",children:A(l.workerStatus)})]}),e.jsx(v,{tone:R(l.workerStatus),title:A(l.workerStatus),children:l.workerStatus.state==="ok"?"Healthy":"Attention"})]})]})]})]}),e.jsxs("details",{className:"page-section",children:[e.jsx("summary",{className:"cursor-pointer text-sm font-medium text-secondary hover:text-strong",children:"Self-hosting details"}),e.jsxs(k,{className:"surface-card mt-3",children:[e.jsx("ul",{className:"detail-list",children:r.selfHostNotes.map(s=>e.jsx("li",{children:s},s))}),e.jsx("p",{className:"supporting-copy",children:r.bootstrapNote})]})]})]}):null}export{de as SettingsPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{r as c,j as e,k as L,u as E,h as O,L as U}from"./vendor-tanstack-BjS7iY3g.js";import{c as I,cK as $,cL as z,cM as A,cN as F,cO as D,cP as B,B as N,j as H,cQ as M,bJ as W,m as R,i as w,cR as T,f as S,cS as _,T as J,cT as Q}from"./index-bcpm37b9.js";import{b as G,c as K,d as Z,a as q,f as Y,t as X}from"./extract-error-message-RWIQhk6G.js";import{A as ee}from"./arrow-left-PM9P2PAY.js";import"./vendor-radix-DnzzbllM.js";import"./vendor-recharts-33ACLxsD.js";import"./vendor-markdown-CpDJch4G.js";const te=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],re=I("cloud",te);const se=[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]],ne=I("triangle",se);function oe({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($,{open:t,onOpenChange:i=>{i?a(!0):o()},children:e.jsx(z,{children:r==="pick"?e.jsx(ie,{onPick:s}):r==="wordpress"?e.jsx(de,{projectName:n,onBack:()=>s("pick"),onClose:o}):r==="vercel"?e.jsx(pe,{projectName:n,onBack:()=>s("pick"),onClose:o}):e.jsx(ue,{projectName:n,onBack:()=>s("pick"),onClose:o})})})}const ae=[{type:"wordpress",name:"WordPress",action:"Install the traffic plugin",icon:B},{type:"cloud-run",name:"Google Cloud Run",action:"Read request logs",icon:re},{type:"vercel",name:"Vercel",action:"Read request logs",icon:ne}];function ie({onPick:t}){return e.jsxs(e.Fragment,{children:[e.jsxs(A,{children:[e.jsx(F,{children:"Connect a traffic source"}),e.jsx(D,{children:"Choose where Canonry should read traffic logs."})]}),e.jsx("div",{className:"mt-6 flex flex-col gap-3",children:ae.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 le({title:t,description:a,onBack:n}){return e.jsxs(A,{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(D,{children:a})]})}function ce(t,a){const n=L();return async(r,s)=>{await M(t,r),s?.(),a(),n({to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:r}})}}function k(t,a){const[n,r]=c.useState(null),s=ce(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(q(l));return}try{await s(u.id,i.onConnected)}catch(l){r(`Source connected, but starting the initial backfill failed: ${q(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(le,{title:t,description:a,onBack:r}),e.jsxs("form",{onSubmit:H(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 de({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(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 ue({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=Z(t||null),{error:y,runConnect:x}=k(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 V=await m.text();g(V)};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: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 pe({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=K(t||null),{error:y,runConnect:x}=k(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(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: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 me(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 Ne(){const[t,a]=c.useState(""),[n,r]=c.useState(!1),o=E(W({client:R})).data??[],i=c.useMemo(()=>t||(o[0]?.name??""),[t,o]),d=Y(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(T,{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(T,{className:"size-3.5"}),"Connect a source"]})})]})]}):e.jsx(xe,{projectName:i,sources:u}):e.jsx(S,{className:"p-6 text-center text-sm text-muted",children:"No projects yet."})]}),!w()&&e.jsx(oe,{open:n,onOpenChange:r,projectName:i})]})}function xe({projectName:t,sources:a}){const n=O({queries:a.map(s=>({..._({client:R,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(J,{tone:X(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:me(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.aiReferralHits??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(Q,{className:"size-3.5"})]})})]},s.id))})]})})}export{Ne as TrafficPage};
|
|
1
|
+
import{r as c,j as e,k as L,u as E,h as O,L as U}from"./vendor-tanstack-BjS7iY3g.js";import{c as I,cK as $,cL as z,cM as A,cN as F,cO as D,cP as B,B as N,j as H,cQ as M,bJ as W,m as R,i as w,cR as T,f as S,cS as _,T as J,cT as Q}from"./index-DP74nMja.js";import{b as G,c as K,d as Z,a as q,f as Y,t as X}from"./extract-error-message-yI0U8t_A.js";import{A as ee}from"./arrow-left-DdovB6GZ.js";import"./vendor-radix-DnzzbllM.js";import"./vendor-recharts-33ACLxsD.js";import"./vendor-markdown-CpDJch4G.js";const te=[["path",{d:"M17.5 19H9a7 7 0 1 1 6.71-9h1.79a4.5 4.5 0 1 1 0 9Z",key:"p7xjir"}]],re=I("cloud",te);const se=[["path",{d:"M13.73 4a2 2 0 0 0-3.46 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"14u9p9"}]],ne=I("triangle",se);function oe({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($,{open:t,onOpenChange:i=>{i?a(!0):o()},children:e.jsx(z,{children:r==="pick"?e.jsx(ie,{onPick:s}):r==="wordpress"?e.jsx(de,{projectName:n,onBack:()=>s("pick"),onClose:o}):r==="vercel"?e.jsx(pe,{projectName:n,onBack:()=>s("pick"),onClose:o}):e.jsx(ue,{projectName:n,onBack:()=>s("pick"),onClose:o})})})}const ae=[{type:"wordpress",name:"WordPress",action:"Install the traffic plugin",icon:B},{type:"cloud-run",name:"Google Cloud Run",action:"Read request logs",icon:re},{type:"vercel",name:"Vercel",action:"Read request logs",icon:ne}];function ie({onPick:t}){return e.jsxs(e.Fragment,{children:[e.jsxs(A,{children:[e.jsx(F,{children:"Connect a traffic source"}),e.jsx(D,{children:"Choose where Canonry should read traffic logs."})]}),e.jsx("div",{className:"mt-6 flex flex-col gap-3",children:ae.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 le({title:t,description:a,onBack:n}){return e.jsxs(A,{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(D,{children:a})]})}function ce(t,a){const n=L();return async(r,s)=>{await M(t,r),s?.(),a(),n({to:"/traffic/$projectName/$sourceId",params:{projectName:t,sourceId:r}})}}function k(t,a){const[n,r]=c.useState(null),s=ce(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(q(l));return}try{await s(u.id,i.onConnected)}catch(l){r(`Source connected, but starting the initial backfill failed: ${q(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(le,{title:t,description:a,onBack:r}),e.jsxs("form",{onSubmit:H(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 de({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(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 ue({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=Z(t||null),{error:y,runConnect:x}=k(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 V=await m.text();g(V)};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: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 pe({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=K(t||null),{error:y,runConnect:x}=k(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(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: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 me(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 Ne(){const[t,a]=c.useState(""),[n,r]=c.useState(!1),o=E(W({client:R})).data??[],i=c.useMemo(()=>t||(o[0]?.name??""),[t,o]),d=Y(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(T,{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(T,{className:"size-3.5"}),"Connect a source"]})})]})]}):e.jsx(xe,{projectName:i,sources:u}):e.jsx(S,{className:"p-6 text-center text-sm text-muted",children:"No projects yet."})]}),!w()&&e.jsx(oe,{open:n,onOpenChange:r,projectName:i})]})}function xe({projectName:t,sources:a}){const n=O({queries:a.map(s=>({..._({client:R,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(J,{tone:X(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:me(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.aiReferralHits??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(Q,{className:"size-3.5"})]})})]},s.id))})]})})}export{Ne as TrafficPage};
|
package/assets/assets/{TrafficSourceDetailPage-De6Yq1Dk.js → TrafficSourceDetailPage-BfQAuIQM.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e,C as Re,E as Ee,r as o,L as $e}from"./vendor-tanstack-BjS7iY3g.js";import{cU as W,cV as i,I as U,T as Fe,i as ae,B as He,f as H,C as Ue,cW as Pe,X as Oe}from"./index-bcpm37b9.js";import{g as Me,h as _e,i as De,t as Be,a as Ke}from"./extract-error-message-RWIQhk6G.js";import{e as Y,h as ze,C as re,a as ne,c as Ge}from"./ChartPrimitives-DXVLCdBi.js";import{R as We,C as Ve}from"./refresh-cw-qn1tCFGx.js";import{R as qe,B as Xe,a as Qe,X as Ye,Y as Ze,T as Je,f as V,g as q}from"./vendor-recharts-33ACLxsD.js";import{A as le}from"./arrow-left-PM9P2PAY.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:W.verified,label:"Verified"},{value:W.claimed_unverified,label:"Claimed unverified"},{value:W.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 Nt(){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(We,{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:ze,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,{...Ge}),f.has("crawler")?e.jsx(V,{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(V,{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(V,{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(Ve,{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,Nt as TrafficSourceDetailPage};
|
|
1
|
+
import{j as e,C as Re,E as Ee,r as o,L as $e}from"./vendor-tanstack-BjS7iY3g.js";import{cU as W,cV as i,I as U,T as Fe,i as ae,B as He,f as H,C as Ue,cW as Pe,X as Oe}from"./index-DP74nMja.js";import{g as Me,h as _e,i as De,t as Be,a as Ke}from"./extract-error-message-yI0U8t_A.js";import{e as Y,h as ze,C as re,a as ne,c as Ge}from"./ChartPrimitives-DXVLCdBi.js";import{R as We,C as Ve}from"./refresh-cw-SR8k0mBu.js";import{R as qe,B as Xe,a as Qe,X as Ye,Y as Ze,T as Je,f as V,g as q}from"./vendor-recharts-33ACLxsD.js";import{A as le}from"./arrow-left-DdovB6GZ.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:W.verified,label:"Verified"},{value:W.claimed_unverified,label:"Claimed unverified"},{value:W.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 Nt(){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(We,{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:ze,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,{...Ge}),f.has("crawler")?e.jsx(V,{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(V,{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(V,{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(Ve,{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,Nt as TrafficSourceDetailPage};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as o}from"./index-
|
|
1
|
+
import{c as o}from"./index-DP74nMja.js";const e=[["path",{d:"m12 19-7-7 7-7",key:"1l729n"}],["path",{d:"M19 12H5",key:"x3x0zl"}]],r=o("arrow-left",e);export{r as A};
|
package/assets/assets/{extract-error-message-RWIQhk6G.js → extract-error-message-yI0U8t_A.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{u as s,r as m,o,p as c}from"./vendor-tanstack-BjS7iY3g.js";import{k as u,cX as l,cS as g,cY as S,aN as y,m as t,cZ as v,c_ as i,g as T,c$ as p,d0 as C,d1 as h,d2 as q}from"./index-
|
|
1
|
+
import{u as s,r as m,o,p as c}from"./vendor-tanstack-BjS7iY3g.js";import{k as u,cX as l,cS as g,cY as S,aN as y,m as t,cZ as v,c_ as i,g as T,c$ as p,d0 as C,d1 as h,d2 as q}from"./index-DP74nMja.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:u})}function M(e){return s({...q({client:t,path:{name:e??""}}),enabled:!!e,staleTime:u})}function V(e,n){return s({...g({client:t,path:{name:e??"",id:n??""}}),enabled:!!(e&&n),staleTime:u})}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:u})}function I(e){const n=o();return c({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 c({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 c({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 c({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 N(e){return E(e).message}export{N as a,Q as b,R as c,I as d,E as e,A as f,V as g,b as h,k as i,F as t,M as u};
|