PageSourceSearch

https://omni-smart.ai/static/js/4860.6cd94146.chunk.js

js omni-smart.ai collected 2026-10-05 13:17:50 UTC 13,012 bytes, 2 lines download raw bytes

1"use strict";(globalThis.webpackChunkfrontend=globalThis.webpackChunkfrontend||[]).push([[4860],{4860(e,s,a){a.r(s),a.d(s,{default:()=>A});var t=a(5043),l=a(9364),r=a(6328),n=a(2580),i=a(4537),c=a(7104),d=a(5087),o=a(5731),x=a(516),h=a(9292),m=a(9855),p=a(4919),g=a(7118),u=a(3072),v=a(7879),b=a(7734),y=a(9327),j=a(2185),f=a(6026),N=a(8689),w=a(579);const k=[{v:"24h",label:"24h"},{v:"7d",label:"7d"},{v:"30d",label:"30d"},{v:"90d",label:"90d"},{v:"12m",label:"12m"}];function A(){var e,s,a,A,F,S,R,_,T;const[$,D]=(0,t.useState)(null),[P,U]=(0,t.useState)(null),[L,O]=(0,t.useState)([]),[I,z]=(0,t.useState)(!1),[E,G]=(0,t.useState)("30d"),[M,V]=(0,t.useState)({path:"",search:"",bot:""}),[q,B]=(0,t.useState)(!1),[H,K]=(0,t.useState)(0),W=(0,t.useRef)(null),J=(0,t.useCallback)(async()=>{try{const{data:e}=await l.Ay.get("/admin/analytics/realtime");D(e)}catch{}},[]),Q=(0,t.useCallback)(async()=>{try{const{data:e}=await l.Ay.get(`/admin/analytics/overview?range=${E}`);U(e)}catch{}},[E]),X=(0,t.useCallback)(async()=>{z(!0);try{const e=new URLSearchParams;M.path&&e.set("path",M.path),M.search&&e.set("search",M.search),e.set("range",E),""!==M.bot&&e.set("bot","true"===M.bot);const{data:s}=await l.Ay.get(`/admin/analytics/events?${e.toString()}`);O(s)}catch{r.oR.error("Failed to load traffic events")}finally{z(!1)}},[M,E]);(0,t.useEffect)(()=>(J(),Q(),X(),W.current=setInterval(J,5e3),()=>clearInterval(W.current)),[J,Q,X]);const Y=async e=>{const s=new URLSearchParams;M.path&&s.set("path",M.path),M.search&&s.set("search",M.search),s.set("range",E),""!==M.bot&&s.set("bot","true"===M.bot),s.set("fmt",e);try{const a=await l.Ay.get(`/admin/analytics/report?${s.toString()}`,{responseType:"blob"}),t=URL.createObjectURL(a.data),n=document.createElement("a");n.href=t,n.download=`traffic-${E}.${e}`,n.click(),URL.revokeObjectURL(t),r.oR.success(`Downloaded ${e.toUpperCase()} report`)}catch{r.oR.error("Download failed")}},Z="24h"===E,ee=Z?(null===$||void 0===$||null===(e=$.series)||void 0===e?void 0:e.map(e=>({t:e.t.slice(11,16),views:e.views,visitors:e.visitors})))||[]:(null===P||void 0===P||null===(s=P.series)||void 0===s?void 0:s.map(e=>({t:e.date.slice(5),views:e.views,visitors:e.visitors})))||[],se=Z?"Traffic \u2014 last 30 minutes":`Daily traffic \u2014 ${E}`;return(0,w.jsxs)("div",{className:"space-y-6",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between",children:[(0,w.jsxs)("div",{children:[(0,w.jsxs)("h1",{className:"font-display text-2xl font-black text-[#0A1128] flex items-center gap-2",children:[(0,w.jsx)(i.A,{className:"w-6 h-6 text-[#0052FF]"})," Real-time Traffic & Analytics"]}),(0,w.jsx)("p",{className:"text-sm text-gray-500",children:"First-party analytics \u2014 live visitor data captured on every page view, up to 12 months. No third-party scripts."})]}),(0,w.jsxs)("div",{className:"flex items-center gap-2",children:[(0,w.jsxs)("button",{onClick:X,className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-gray-200 text-sm hover:bg-gray-50",children:[(0,w.jsx)(x.A,{className:"w-4 h-4"})," Refresh"]}),(0,w.jsxs)("button",{onClick:()=>Y("csv"),className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-gray-200 text-sm hover:bg-gray-50",children:[(0,w.jsx)(c.A,{className:"w-4 h-4"})," CSV"]}),(0,w.jsxs)("button",{onClick:()=>Y("json"),className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-gray-200 text-sm hover:bg-gray-50",children:[(0,w.jsx)(c.A,{className:"w-4 h-4"})," JSON"]})]})]}),(0,w.jsxs)("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4",children:[(0,w.jsx)(C,{icon:(0,w.jsx)(g.A,{className:"w-5 h-5"}),label:"Active Visitors (5 min)",value:null!==(a=null===$||void 0===$?void 0:$.active_visitors)&&void 0!==a?a:"\u2014",accent:"text-[#0052FF]",pulse:!0}),(0,w.jsx)(C,{icon:(0,w.jsx)(d.A,{className:"w-5 h-5"}),label:"Pageviews Today",value:null!==(A=null===$||void 0===$?void 0:$.pageviews_today)&&void 0!==A?A:"\u2014"}),(0,w.jsx)(C,{icon:(0,w.jsx)(p.A,{className:"w-5 h-5"}),label:Z?"Peak (30 min)":`Views (${E})`,value:Z?Math.max(0,...ee.map(e=>e.views)):null!==(F=null===P||void 0===P?void 0:P.total_views)&&void 0!==F?F:"\u2014"}),(0,w.jsx)(C,{icon:(0,w.jsx)(g.A,{className:"w-5 h-5"}),label:Z?"Bot Hits Today":`Unique (${E})`,value:Z?null!==(S=null===$||void 0===$?void 0:$.bots_today)&&void 0!==S?S:"\u2014":null!==(R=null===P||void 0===P?void 0:P.unique_visitors)&&void 0!==R?R:"\u2014"})]}),(0,w.jsxs)("div",{className:"bg-white rounded-xl border border-gray-100 p-5",children:[(0,w.jsxs)("div",{className:"flex items-center justify-between mb-3",children:[(0,w.jsx)("h2",{className:"font-semibold text-[#0A1128]",children:se}),(0,w.jsxs)("div",{className:"flex items-center gap-3",children:[(0,w.jsxs)("span",{className:"flex items-center gap-1 text-xs text-green-600",children:[(0,w.jsx)("span",{className:"w-2 h-2 rounded-full bg-green-500 animate-pulse"})," live"]}),(0,w.jsx)("div",{className:"flex gap-1 bg-gray-100 rounded-lg p-1",children:k.map(e=>(0,w.jsx)("button",{onClick:()=>G(e.v),className:"px-3 py-1 rounded-md text-xs font-medium transition "+(E===e.v?"bg-[#0052FF] text-white":"text-gray-600 hover:bg-white"),children:e.label},e.v))})]})]}),(0,w.jsx)("div",{className:"h-64",children:(0,w.jsx)(v.u,{width:"100%",height:"100%",children:(0,w.jsxs)(N.Q,{data:ee,margin:{top:5,right:10,left:-20,bottom:0},children:[(0,w.jsx)("defs",{children:(0,w.jsxs)("linearGradient",{id:"g1",x1:"0",y1:"0",x2:"0",y2:"1",children:[(0,w.jsx)("stop",{offset:"5%",
1stopColor:"#0052FF",stopOpacity:.4}),(0,w.jsx)("stop",{offset:"95%",stopColor:"#0052FF",stopOpacity:0})]})}),(0,w.jsx)(b.d,{strokeDasharray:"3 3",stroke:"#eef2f7"}),(0,w.jsx)(j.W,{dataKey:"t",tick:{fontSize:11},stroke:"#9ca3af",interval:"preserveStartEnd",minTickGap:24}),(0,w.jsx)(f.h,{tick:{fontSize:11},stroke:"#9ca3af",allowDecimals:!1}),(0,w.jsx)(u.m,{}),(0,w.jsx)(y.Gk,{type:"monotone",dataKey:"views",stroke:"#0052FF",strokeWidth:2,fill:"url(#g1)"})]})})})]}),(0,w.jsxs)("div",{className:"grid md:grid-cols-2 gap-4",children:[(0,w.jsxs)("div",{className:"bg-white rounded-xl border border-gray-100 p-5",children:[(0,w.jsxs)("h2",{className:"font-semibold text-[#0A1128] mb-3 flex items-center gap-2",children:[(0,w.jsx)(o.A,{className:"w-4 h-4 text-[#0052FF]"})," Top Pages"]}),(0,w.jsx)("ul",{className:"space-y-2",children:null!==(_=Z?null===$||void 0===$?void 0:$.top_pages:null===P||void 0===P?void 0:P.top_pages)&&void 0!==_&&_.length?(Z?$.top_pages:P.top_pages).map(e=>(0,w.jsxs)("li",{className:"flex items-center justify-between text-sm",children:[(0,w.jsx)("span",{className:"font-mono text-gray-700 truncate",children:e.path}),(0,w.jsx)("span",{className:"text-gray-400 ml-2",children:e.views})]},e.path)):(0,w.jsx)("li",{className:"text-sm text-gray-400",children:"No data yet"})})]}),(0,w.jsxs)("div",{className:"bg-white rounded-xl border border-gray-100 p-5",children:[(0,w.jsxs)("h2",{className:"font-semibold text-[#0A1128] mb-3 flex items-center gap-2",children:[(0,w.jsx)(p.A,{className:"w-4 h-4 text-[#0052FF]"})," Top Referrers"]}),(0,w.jsx)("ul",{className:"space-y-2",children:null!==(T=Z?null===$||void 0===$?void 0:$.top_referrers:null===P||void 0===P?void 0:P.top_referrers)&&void 0!==T&&T.length?(Z?$.top_referrers:P.top_referrers).map(e=>(0,w.jsxs)("li",{className:"flex items-center justify-between text-sm",children:[(0,w.jsx)("span",{className:"font-mono text-gray-700 truncate",children:e.referrer}),(0,w.jsx)("span",{className:"text-gray-400 ml-2",children:e.views})]},e.referrer)):(0,w.jsx)("li",{className:"text-sm text-gray-400",children:"No referrers yet"})})]})]}),(0,w.jsxs)("div",{className:"bg-white rounded-xl border border-gray-100 p-5",children:[(0,w.jsxs)("div",{className:"flex flex-wrap items-end gap-3 mb-4",children:[(0,w.jsxs)("div",{className:"flex-1 min-w-[200px]",children:[(0,w.jsx)("label",{className:"text-xs text-gray-500 block mb-1",children:"Search (path, referrer or IP)"}),(0,w.jsxs)("div",{className:"relative",children:[(0,w.jsx)(h.A,{className:"w-4 h-4 absolute left-3 top-1/2 -translate-y-1/2 text-gray-400"}),(0,w.jsx)("input",{value:M.search,onChange:e=>V({...M,search:e.target.value}),placeholder:"e.g. /aria or google.com or 1.2.3.4",className:"w-full pl-9 pr-3 py-2 border border-gray-200 rounded-lg text-sm"})]})]}),(0,w.jsxs)("div",{className:"min-w-[160px]",children:[(0,w.jsx)("label",{className:"text-xs text-gray-500 block mb-1",children:"Path contains"}),(0,w.jsx)("input",{value:M.path,onChange:e=>V({...M,path:e.target.value}),placeholder:"/aria",className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm"})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-gray-500 block mb-1",children:"Range"}),(0,w.jsx)("select",{value:E,onChange:e=>G(e.target.value),className:"px-3 py-2 border border-gray-200 rounded-lg text-sm",children:k.map(e=>(0,w.jsx)("option",{value:e.v,children:e.label},e.v))})]}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-gray-500 block mb-1",children:"Type"}),(0,w.jsxs)("select",{value:M.bot,onChange:e=>V({...M,bot:e.target.value}),className:"px-3 py-2 border border-gray-200 rounded-lg text-sm",children:[(0,w.jsx)("option",{value:"",children:"All"}),(0,w.jsx)("option",{value:"false",children:"Human"}),(0,w.jsx)("option",{value:"true",children:"Bot"})]})]}),(0,w.jsxs)("button",{onClick:X,className:"flex items-center gap-2 px-3 py-2 rounded-lg bg-[#0052FF] text-white text-sm hover:bg-[#0040cc]",children:[(0,w.jsx)(n.A,{className:"w-4 h-4"})," Apply"]}),(0,w.jsxs)("button",{onClick:()=>B(!0),className:"flex items-center gap-2 px-3 py-2 rounded-lg border border-red-200 text-red-600 text-sm hover:bg-red-50",children:[(0,w.jsx)(m.A,{className:"w-4 h-4"})," Manage Data"]})]}),(0,w.jsx)("div",{className:"overflow-auto max-h-96 border border-gray-100 rounded-lg",children:(0,w.jsxs)("table",{className:"w-full text-sm",children:[(0,w.jsx)("thead",{className:"bg-gray-50 sticky top-0",children:(0,w.jsxs)("tr",{className:"text-left text-gray-500",children:[(0,w.jsx)("th",{className:"px-3 py-2",children:"Time"}),(0,w.jsx)("th",{className:"px-3 py-2",children:"Path"}),(0,w.jsx)("th",{className:"px-3 py-2",children:"Referrer"}),(0,w.jsx)("th",{className:"px-3 py-2",children:"IP"}),(0,w.jsx)("th",{className:"px-3 py-2",children:"Type"})]})}),(0,w.jsxs)("tbody",{children:[0===L.length&&(0,w.jsx)("tr",{children:(0,w.jsx)("td",{colSpan:5,className:"px-3 py-6 text-center text-gray-400",children:I?"Loading\u2026":"No traffic events in this window"})}),L.map((e,s)=>(0,w.jsxs)("tr",{className:"border-t border-gray-50",children:[(0,w.jsx)("td",{className:"px-3 py-2 font-mono text-xs text-gray-500",children:e.ts}),(0,w.jsx)("td",{className:"px-3 py-2 font-mono",children:e.path}),(0,w.jsx)("td",{className:"px-3 py-2 text-gray-500 truncate max-w-[220px]",children:e.referrer||"\u2014"}),(0,w.jsx)("td",{className:"px-3 py-2 font-mono text-xs text-gray-500",children:e.ip}),(0,w.jsx)("td",{className:"px-3 py-2",children:e.is_bot?(0,w.jsx)("span",{className:"text-amber-600 text-xs",children:"bot"}):(0,w.jsx)("span",{className:"text-green-600 text-xs",children:"human"})})]},s))]})]})})]}),q&&(0,w.jsx)("div",{className:"fixed inset-0 bg-black/40 flex items-center justify-center z-50",children:(0,w.jsxs)("div",{className:"bg-white rounded-xl p-6 w-full max-w-md 
1space-y-4",children:[(0,w.jsx)("h3",{className:"font-display text-lg font-bold text-[#0A1128]",children:"Manage Traffic Data"}),(0,w.jsx)("p",{className:"text-sm text-gray-500",children:"Delete all recorded traffic, or only events older than a chosen age."}),(0,w.jsxs)("div",{children:[(0,w.jsx)("label",{className:"text-xs text-gray-500 block mb-1",children:"Delete events older than (hours) \u2014 0 = all"}),(0,w.jsx)("input",{type:"number",min:0,value:H,onChange:e=>K(Number(e.target.value)),className:"w-full px-3 py-2 border border-gray-200 rounded-lg text-sm"})]}),(0,w.jsxs)("div",{className:"flex justify-end gap-2",children:[(0,w.jsx)("button",{onClick:()=>B(!1),className:"px-3 py-2 border border-gray-200 rounded-lg text-sm",children:"Cancel"}),(0,w.jsx)("button",{onClick:async()=>{try{await l.Ay.delete(`/admin/analytics/data?older_than_hours=${H}`),r.oR.success(H>0?`Cleared events older than ${H}h`:"All traffic data cleared"),B(!1),J(),Q(),X()}catch{r.oR.error("Failed to clear data")}},className:"px-3 py-2 rounded-lg bg-red-600 text-white text-sm hover:bg-red-700",children:"Delete Data"})]})]})})]})}function C(e){let{icon:s,label:a,value:t,accent:l="text-[#0A1128]",pulse:r}=e;return(0,w.jsxs)("div",{className:"bg-white rounded-xl border border-gray-100 p-4",children:[(0,w.jsxs)("div",{className:`flex items-center gap-2 ${l}`,children:[s,(0,w.jsx)("span",{className:"text-xs text-gray-500",children:a})]}),(0,w.jsxs)("div",{className:`mt-2 text-2xl font-black ${l}`,children:[r&&(0,w.jsx)("span",{className:"inline-block w-2 h-2 rounded-full bg-green-500 animate-pulse mr-1 align-middle"}),t]})]})}}}]);
2//# sourceMappingURL=4860.6cd94146.chunk.js.map

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.