@ainyc/canonry 4.51.1 → 4.51.3
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/{BacklinksPage-DIZCcqsP.js → BacklinksPage-9TlM08Wf.js} +1 -1
- package/assets/assets/ProjectPage-CD591qDz.js +6 -0
- package/assets/assets/{RunRow-DqezNIUy.js → RunRow-D7qdWWRl.js} +1 -1
- package/assets/assets/{RunsPage-CfvTJ9Ny.js → RunsPage-CvewepfU.js} +1 -1
- package/assets/assets/{SettingsPage-HfMGIa5v.js → SettingsPage-C7BvAhiB.js} +1 -1
- package/assets/assets/{TrafficPage-DV_Dvpl3.js → TrafficPage-DC3NhFOh.js} +1 -1
- package/assets/assets/TrafficSourceDetailPage-BvtTA6rs.js +1 -0
- package/assets/assets/{arrow-left-DpxpMUNt.js → arrow-left-Agb02DMK.js} +1 -1
- package/assets/assets/index-DTCZ93Ne.js +210 -0
- package/assets/assets/server-traffic-C-0Ndjpw.js +1 -0
- package/assets/assets/{trash-2-CnBiLbiZ.js → trash-2-lkrXVRRm.js} +1 -1
- package/assets/index.html +1 -1
- package/dist/{chunk-2ARCCG5E.js → chunk-FYGBW3SM.js} +4 -0
- package/dist/{chunk-GGXU5VKI.js → chunk-HMZKIOLG.js} +1 -1
- package/dist/{chunk-DLDLDWH4.js → chunk-QZ5XSM6C.js} +34 -1
- package/dist/{chunk-JOKPYAEL.js → chunk-WBO5S3IX.js} +3131 -277
- package/dist/cli.js +40 -8
- package/dist/index.js +4 -4
- package/dist/{intelligence-service-XMZEWLCW.js → intelligence-service-2XL2M7QP.js} +2 -2
- package/dist/mcp.js +2 -2
- package/package.json +11 -11
- package/assets/assets/ProjectPage-R2cxJb5Y.js +0 -6
- package/assets/assets/TrafficSourceDetailPage-lefreKBO.js +0 -1
- package/assets/assets/index-DKBPD33e.js +0 -210
- package/assets/assets/server-traffic-Bm8iKtXK.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,A as de,B as ue,r as h,L as xe}from"./vendor-tanstack-Dq7p98wZ.js";import{I as me,bA as N,T as he,B as pe,g as $,a0 as fe,bB as ge}from"./index-DKBPD33e.js";import{d as ee,e as be,C as W,a as K,c as je}from"./ChartPrimitives-9Kx3gzQL.js";import{e as ye,f as Ne,g as we,t as ve,R as Se}from"./server-traffic-Bm8iKtXK.js";import{R as ze,B as ke,a as Ce,X as Te,Y as Re,T as $e,b as G,d as Y}from"./vendor-recharts-DWvKDyBF.js";import{A as X}from"./arrow-left-DpxpMUNt.js";import"./vendor-radix-B57xfQbP.js";import"./vendor-markdown-DK7fbRNb.js";function H({value:a,label:t,delta:n,tone:r,description:i,tooltip:u,isNumeric:o=!0,progress:c,providerCoverage:d}){const b=2*Math.PI*48,x=Number.parseInt(a,10),S=typeof c=="number"&&Number.isFinite(c)?Math.min(Math.max(c,0),100)/100:o&&!Number.isNaN(x)?Math.min(x/100,1):.5,j=b*(1-S);return e.jsxs("div",{className:"score-gauge",children:[e.jsxs("div",{className:"gauge-ring-wrapper",children:[e.jsxs("svg",{className:"gauge-ring",viewBox:"0 0 120 120","aria-hidden":"true",children:[e.jsx("circle",{className:"gauge-bg",cx:"60",cy:"60",r:48,strokeWidth:6}),e.jsx("circle",{className:`gauge-fill gauge-fill-${r}`,cx:"60",cy:"60",r:48,strokeWidth:6,strokeDasharray:b,strokeDashoffset:j,transform:"rotate(-90 60 60)"})]}),e.jsx("div",{className:"gauge-center",children:e.jsx("span",{className:o?"gauge-value":"gauge-value-text",children:a.split(" / ")[0]})})]}),e.jsxs("p",{className:"gauge-label",children:[t,u&&e.jsx(me,{text:u})]}),e.jsx("p",{className:"gauge-delta",children:n}),d&&e.jsx("p",{className:"gauge-provider-coverage",children:d}),e.jsx("p",{className:"gauge-description",children:i})]})}function te(a){return a.kind===N.crawler?a.botId:a.product}function Ae(a){return a.kind===N.crawler?a.pathNormalized:a.landingPathNormalized}function se(a,t){if(t==="hour")return a;const n=new Date(a),r=n.getFullYear(),i=String(n.getMonth()+1).padStart(2,"0"),u=String(n.getDate()).padStart(2,"0");return`${r}-${i}-${u}`}function De(a,t,n){const r=t.pathQuery.trim().toLowerCase();return a.filter(i=>!(t.selectedBucket&&se(i.tsHour,n)!==t.selectedBucket||t.identity&&te(i)!==t.identity||t.operator&&i.operator!==t.operator||r&&!Ae(i).toLowerCase().includes(r)))}function Ie(a,t){if(!a||typeof a!="object")return null;const n=a.activeTooltipIndex;let r;if(typeof n=="number")r=n;else if(typeof n=="string"&&n!=="")r=Number(n);else return null;return!Number.isInteger(r)||r<0||r>=t.length?null:t[r]?.bucket??null}const D=[{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}],Q=D.find(a=>a.label==="7d")??D[2],q=ee[0],V=ee[1];function ae(a){const t=new Date(a);return`${t.getMonth()+1}/${t.getDate()} ${String(t.getHours()).padStart(2,"0")}:00`}function Le(a){const t=new Date(`${a}T00:00:00`);return`${t.getMonth()+1}/${t.getDate()}`}function T(a){if(!a)return"never";const t=Date.now()-new Date(a).getTime(),n=Math.floor(t/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 J({canGoBack:a,className:t}){const n="inline-flex items-center gap-1";if(a){const r=()=>{window.history.back()};return e.jsxs("button",{type:"button",onClick:r,className:`${n} ${t??""}`,children:[e.jsx(X,{className:"size-3"})," Back"]})}return e.jsxs(xe,{to:"/traffic",className:`${n} ${t??""}`,children:[e.jsx(X,{className:"size-3"})," All sources"]})}function Ke(){const a=de({strict:!1}),t=a.projectName??"",n=ue(),r=a.sourceId??"",[i,u]=h.useState(Q.value),[o,c]=h.useState(()=>new Set(["crawler","ai-referral"])),[d,w]=h.useState(null),[p,b]=h.useState(""),[x,S]=h.useState(""),[j,I]=h.useState(""),[E,B]=h.useState(null),[F,O]=h.useState(null),g=h.useMemo(()=>D.find(s=>s.value===i)??Q,[i]),L=ye(t||null,r||null),v=Ne(t||null,{sourceId:r||void 0,sinceMinutes:i,limit:g.fetchLimit}),C=we(t||null,r||null),l=L.data,y=v.data?.events??[],z=v.data?.totals,M=h.useMemo(()=>y.filter(s=>s.kind===N.crawler?o.has("crawler"):o.has("ai-referral")),[y,o]),re=h.useMemo(()=>{const s=new Set;for(const m of y)s.add(te(m));return p&&s.add(p),[...s].sort((m,f)=>m.localeCompare(f))},[y,p]),ne=h.useMemo(()=>{const s=new Set;for(const m of y)s.add(m.operator);return x&&s.add(x),[...s].sort((m,f)=>m.localeCompare(f))},[y,x]),U=h.useMemo(()=>De(M,{selectedBucket:d,identity:p,operator:x,pathQuery:j},g.granularity),[M,d,p,x,j,g.granularity]),P=h.useMemo(()=>d?A(d,g.granularity):null,[d,g.granularity]),k=h.useMemo(()=>Me(y,g.granularity,v.data?.windowStart,v.data?.windowEnd),[y,g.granularity,v.data?.windowStart,v.data?.windowEnd]),_=s=>{c(m=>{const f=new Set(m);return f.has(s)?f.size>1&&f.delete(s):f.add(s),f})},le=s=>{const m=Ie(s,k);m&&w(f=>f===m?null:m)},ie=()=>{w(null),b(""),S(""),I("")},ce=!!(d||p||x||j.trim()),oe=async()=>{B(null),O(null);try{const s=await C.mutateAsync({sinceMinutes:60});O(`Pulled ${s.pulledEvents} entries · ${s.crawlerHits} crawler · ${s.aiReferralHits} AI referral · ${s.unknownHits} unknown`)}catch(s){const m=s instanceof fe||s instanceof Error?s.message:String(s);B(m)}};return!t||!r?e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-zinc-500",children:"Missing project name or source id in URL."})}):L.isLoading?e.jsx("div",{className:"page-container",children:e.jsx("p",{className:"text-sm text-zinc-500",children:"Loading source…"})}):L.isError||!l?e.jsxs("div",{className:"page-container",children:[e.jsx("p",{className:"text-sm text-rose-300",children:"Could not load this source."}),e.jsx(J,{canGoBack:n,className:"mt-2 text-xs text-zinc-400 hover:text-zinc-200"})]}):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(J,{canGoBack:n,className:"text-xs text-zinc-500 hover:text-zinc-200"}),e.jsx("h1",{className:"page-title mt-2",children:l.displayName}),e.jsxs("p",{className:"page-subtitle",children:[l.sourceType," · project ",e.jsx("span",{className:"text-zinc-300",children:t})," ·",e.jsx("span",{className:"ml-1 font-mono text-zinc-400",children:l.id})]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(he,{tone:ve(l.status),children:l.status}),e.jsxs(pe,{type:"button",variant:"outline",size:"sm",disabled:C.isPending,onClick:()=>{oe()},children:[e.jsx(Se,{className:`size-3.5 ${C.isPending?"animate-spin":""}`}),C.isPending?"Syncing…":"Sync now"]})]})]}),E?e.jsx("div",{className:"rounded-md border border-rose-800/50 bg-rose-950/30 px-3 py-2 text-xs text-rose-200",children:E}):null,F?e.jsx("div",{className:"rounded-md border border-emerald-800/50 bg-emerald-950/30 px-3 py-2 text-xs text-emerald-200",children:F}):null,e.jsxs("section",{className:"grid grid-cols-1 gap-4 sm:grid-cols-3",children:[e.jsx(H,{label:"24h crawler hits",value:String(l.totals24h.crawlerHits),delta:l.lastSyncedAt?`last sync ${T(l.lastSyncedAt)}`:"never synced",tone:l.totals24h.crawlerHits>0?"positive":"neutral",description:"GPTBot, ChatGPT-User, PerplexityBot, etc. — verified crawler requests in the last 24h.",isNumeric:!0,progress:Math.min(100,Math.round(l.totals24h.crawlerHits/1e3*100))}),e.jsx(H,{label:"24h AI referral sessions",value:String(l.totals24h.aiReferralHits),delta:l.lastSyncedAt?`last sync ${T(l.lastSyncedAt)}`:"never synced",tone:l.totals24h.aiReferralHits>0?"positive":"neutral",description:"Sessionized visits arriving from chat.openai.com, perplexity.ai, etc. (Referer header evidence).",isNumeric:!0,progress:Math.min(100,Math.round(l.totals24h.aiReferralHits/1e3*100))}),e.jsx(H,{label:"24h sample rows",value:String(l.totals24h.sampleCount),delta:"bounded per sync",tone:"neutral",description:"Per-request samples retained for evidence (capped to keep storage bounded).",isNumeric:!0,progress:Math.min(100,Math.round(l.totals24h.sampleCount/100*100))})]}),e.jsxs("section",{children:[e.jsx("p",{className:"mb-4 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",children:"Latest sync run"}),l.latestRun?e.jsxs($,{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-zinc-100",children:["Status: ",e.jsx("span",{className:"font-medium",children:l.latestRun.status})]}),e.jsxs("span",{className:"text-zinc-500",children:["Started: ",T(l.latestRun.startedAt)]}),l.latestRun.finishedAt?e.jsxs("span",{className:"text-zinc-500",children:["Finished: ",T(l.latestRun.finishedAt)]}):null,e.jsx("span",{className:"font-mono text-[11px] text-zinc-600",children:l.latestRun.runId})]}),l.latestRun.error?e.jsx("p",{className:"mt-2 rounded border border-rose-900/40 bg-rose-950/30 px-3 py-2 text-xs text-rose-300",children:l.latestRun.error}):null]}):e.jsx($,{className:"px-4 py-3 text-sm text-zinc-500",children:'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-zinc-500",children:"Events"}),e.jsx("h2",{className:"mt-1 text-base font-semibold text-zinc-50",children:g.granularity==="day"?"Daily rollups":"Hourly rollups"}),z?e.jsxs("p",{className:"mt-1.5 text-xs text-zinc-500",children:[z.crawlerHits.toLocaleString("en-US")," crawler ·"," ",z.aiReferralHits.toLocaleString("en-US")," AI referral sessions · last ",g.label]}):null]}),e.jsx("div",{className:"filter-row mb-0",role:"toolbar","aria-label":"Window",children:D.map(s=>e.jsx("button",{type:"button",className:`filter-chip ${i===s.value?"filter-chip-active":""}`,"aria-pressed":i===s.value,onClick:()=>{u(s.value),w(null)},children:s.label},s.value))})]}),e.jsxs($,{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(Z,{label:"Crawler",color:q,count:z?.crawlerHits??0,active:o.has("crawler"),onToggle:()=>_("crawler")}),e.jsx(Z,{label:"AI referral sessions",color:V,count:z?.aiReferralHits??0,active:o.has("ai-referral"),onToggle:()=>_("ai-referral")})]}),k.length===0?e.jsx("p",{className:"py-12 text-center text-xs text-zinc-500",children:"No events in this window."}):e.jsx("div",{className:"h-72",children:e.jsx(ze,{children:e.jsxs(ke,{data:k,margin:{top:4,right:4,bottom:0,left:0},onClick:le,style:{cursor:"pointer"},children:[e.jsx(Ce,{stroke:be,strokeDasharray:"3 3"}),e.jsx(Te,{dataKey:"label",tick:K,stroke:W,interval:"preserveStartEnd",minTickGap:g.granularity==="day"?24:32}),e.jsx(Re,{tick:K,stroke:W,allowDecimals:!1}),e.jsx($e,{...je}),o.has("crawler")?e.jsx(G,{dataKey:"crawler",name:"Crawler",fill:q,stackId:"a",children:k.map(s=>e.jsx(Y,{fillOpacity:d&&d!==s.bucket?.25:1},s.bucket))}):null,o.has("ai-referral")?e.jsx(G,{dataKey:"aiReferral",name:"AI referral",fill:V,stackId:"a",children:k.map(s=>e.jsx(Y,{fillOpacity:d&&d!==s.bucket?.25:1},s.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-zinc-500",children:"Event rows"}),e.jsxs("p",{className:"mt-1 text-xs text-zinc-500",children:["Showing ",e.jsx("span",{className:"tabular-nums text-zinc-300",children:U.length.toLocaleString("en-US")})," of"," ",e.jsx("span",{className:"tabular-nums text-zinc-500",children:M.length.toLocaleString("en-US")})," events"]})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[e.jsxs("select",{"aria-label":"Filter by identity",value:p,onChange:s=>b(s.target.value),className:"rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-600",children:[e.jsx("option",{value:"",children:"All identities"}),re.map(s=>e.jsx("option",{value:s,children:s},s))]}),e.jsxs("select",{"aria-label":"Filter by operator",value:x,onChange:s=>S(s.target.value),className:"rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-xs text-zinc-200 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-600",children:[e.jsx("option",{value:"",children:"All operators"}),ne.map(s=>e.jsx("option",{value:s,children:s},s))]}),e.jsx("input",{type:"search","aria-label":"Filter by path",placeholder:"path contains…",value:j,onChange:s=>I(s.target.value),className:"w-44 rounded-md border border-zinc-800 bg-zinc-950 px-2.5 py-1.5 text-xs text-zinc-200 placeholder:text-zinc-600 focus:outline-none focus-visible:ring-1 focus-visible:ring-zinc-600"})]})]}),ce?e.jsxs("div",{className:"mb-3 flex flex-wrap items-center gap-2",children:[P?e.jsx(R,{label:`Bucket: ${P}`,onClear:()=>w(null)}):null,p?e.jsx(R,{label:`Identity: ${p}`,onClear:()=>b("")}):null,x?e.jsx(R,{label:`Operator: ${x}`,onClear:()=>S("")}):null,j.trim()?e.jsx(R,{label:`Path: ${j.trim()}`,onClear:()=>I("")}):null,e.jsx("button",{type:"button",onClick:ie,className:"text-xs text-zinc-500 underline-offset-4 hover:text-zinc-200 hover:underline",children:"Clear all"})]}):null,e.jsx(He,{events:U})]})]})}function A(a,t){return t==="day"?Le(a):ae(a)}function Me(a,t,n,r){const i=new Map;for(const u of a){const o=se(u.tsHour,t);let c=i.get(o);c||(c={bucket:o,label:A(o,t),crawler:0,aiReferral:0},i.set(o,c)),u.kind===N.crawler?c.crawler+=u.hits:c.aiReferral+=u.hits}if(n&&r){const u=new Date(n),o=new Date(r);if(t==="day"){const c=new Date(Date.UTC(u.getUTCFullYear(),u.getUTCMonth(),u.getUTCDate())),d=new Date(Date.UTC(o.getUTCFullYear(),o.getUTCMonth(),o.getUTCDate()));for(;c<=d;){const w=c.getUTCFullYear(),p=String(c.getUTCMonth()+1).padStart(2,"0"),b=String(c.getUTCDate()).padStart(2,"0"),x=`${w}-${p}-${b}`;i.has(x)||i.set(x,{bucket:x,label:A(x,t),crawler:0,aiReferral:0}),c.setUTCDate(c.getUTCDate()+1)}}else{const c=new Date(u);for(c.setUTCMinutes(0,0,0);c<=o;){const d=c.toISOString();i.has(d)||i.set(d,{bucket:d,label:A(d,t),crawler:0,aiReferral:0}),c.setUTCHours(c.getUTCHours()+1)}}}return[...i.values()].sort((u,o)=>u.bucket<o.bucket?-1:u.bucket>o.bucket?1:0)}function R({label:a,onClear:t}){return e.jsxs("span",{className:"inline-flex items-center gap-1.5 rounded-full border border-zinc-700 bg-zinc-800/60 px-2.5 py-1 text-[11px] text-zinc-200",children:[a,e.jsx("button",{type:"button",onClick:t,"aria-label":`Clear ${a}`,className:"rounded-full p-0.5 text-zinc-400 hover:bg-zinc-700/60 hover:text-zinc-100",children:e.jsx(ge,{className:"size-3"})})]})}function Z({label:a,color:t,count:n,active:r,onToggle:i}){return e.jsxs("button",{type:"button",onClick:i,"aria-pressed":r,className:`inline-flex items-center gap-2 rounded-full border px-3 py-1 text-xs font-medium transition ${r?"border-zinc-700 bg-zinc-800/60 text-zinc-100":"border-zinc-800 bg-transparent text-zinc-500 hover:text-zinc-300"}`,children:[e.jsx("span",{"aria-hidden":"true",className:`size-2 rounded-full transition-opacity ${r?"opacity-100":"opacity-30"}`,style:{backgroundColor:t}}),e.jsx("span",{children:a}),e.jsx("span",{className:`tabular-nums ${r?"text-zinc-400":"text-zinc-600"}`,children:n.toLocaleString("en-US")})]})}function He({events:a}){return a.length===0?e.jsx($,{className:"p-6 text-center text-sm text-zinc-500",children:"No event rows match the current filters."}):e.jsx("div",{className:"rounded-xl border border-zinc-800/60 bg-zinc-900/30 overflow-hidden",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{className:"bg-zinc-900/50 text-[10px] font-semibold uppercase tracking-wider text-zinc-500",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:"Hits"})]})}),e.jsx("tbody",{className:"divide-y divide-zinc-800/60",children:a.map((t,n)=>e.jsxs("tr",{className:"hover:bg-zinc-900/40 transition-colors",children:[e.jsx("td",{className:"px-4 py-2 font-mono text-xs text-zinc-300",children:ae(t.tsHour)}),e.jsx("td",{className:"px-4 py-2 text-zinc-300",children:t.kind===N.crawler?"Crawler":"AI referral"}),e.jsxs("td",{className:"px-4 py-2 text-zinc-100",children:[t.kind===N.crawler?t.botId:t.product,e.jsx("span",{className:"ml-2 text-[11px] text-zinc-500",children:t.operator})]}),e.jsx("td",{className:"px-4 py-2 text-zinc-300",children:t.kind===N.crawler?`${t.verificationStatus} · HTTP ${t.status}`:`${t.evidenceType} · ${t.sourceDomain}`}),e.jsx("td",{className:"px-4 py-2 truncate font-mono text-xs text-zinc-300",children:t.kind===N.crawler?t.pathNormalized:t.landingPathNormalized}),e.jsx("td",{className:"px-4 py-2 text-right tabular-nums text-zinc-100",children:t.hits})]},`${t.kind}:${t.tsHour}:${n}`))})]})})}export{Ke as TrafficSourceDetailPage};
|