PageSourceSearch

https://app.teedians.in/assets/BotAnalytics-BlmMG4JV.js

js teedians.in collected 2026-10-09 17:44:21 UTC 5,133 bytes, 2 lines download raw bytes

1import{r as N,n as k,a8 as _,l as w,b2 as C,a2 as S,c8 as A,bX as L,j as e,C as t,f as r,c as i,d as n,s as B}from"./index-DocaPeAE.js";import{S as z,a as K,b as R,c as T,d}from"./select-NtMFeCwO.js";import{R as m,T as h,B as p}from"./generateCategoricalChart-DsHi35-O.js";import{L as D,a as j}from"./LineChart-DrfYZb0K.js";import{C as u}from"./CartesianGrid-B0cQn6jH.js";import{X as g,Y as f}from"./YAxis-CyoUUM3a.js";import{B as E}from"./BarChart-B-WhhF20.js";const $="https://nckhxdfdalrpvwpzyjbr.supabase.co/functions/v1/bot-analytics";function H(){const[l,v]=N.useState("7"),{data:s,isLoading:y}=k({queryKey:["bot-analytics",l],queryFn:async()=>{var x;const o=(x=(await B.auth.getSession()).data.session)==null?void 0:x.access_token;if(!o)return null;const c=await fetch(`${$}?days=${l}`,{headers:{Authorization:`Bearer ${o}`}});if(!c.ok)throw new Error("Failed to fetch analytics");return c.json()}}),b=[{label:"Chat Opens",value:(s==null?void 0:s.total_chat_opens)||0,icon:_,color:"text-primary"},{label:"Unique Users",value:(s==null?void 0:s.unique_chat_users)||0,icon:w,color:"text-blue-500"},{label:"Popup → Open Rate",value:`${(s==null?void 0:s.popup_to_open_rate)||0}%`,icon:C,color:"text-green-500"},{label:"Avg Msgs/Session",value:(s==null?void 0:s.avg_messages_per_session)||0,icon:S,color:"text-orange-500"},{label:"Reflections",value:(s==null?void 0:s.total_reflections)||0,icon:A,color:"text-purple-500"},{label:"Active Memories",value:(s==null?void 0:s.active_memories)||0,icon:L,color:"text-yellow-500"}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-2xl font-bold",children:"YCS Bot Analytics"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Your College Senior engagement metrics"})]}),e.jsxs(z,{value:l,onValueChange:v,children:[e.jsx(K,{className:"w-[140px]",children:e.jsx(R,{})}),e.jsxs(T,{children:[e.jsx(d,{value:"7",children:"Last 7 days"}),e.jsx(d,{value:"14",children:"Last 14 days"}),e.jsx(d,{value:"30",children:"Last 30 days"})]})]})]}),y?e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4",children:[1,2,3,4,5,6].map(a=>e.jsx(t,{children:e.jsx(r,{className:"p-4",children:e.jsxs("div",{className:"animate-pulse space-y-2",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-2/3"}),e.jsx("div",{className:"h-8 bg-muted rounded w-1/2"})]})})},a))}):e.jsx("div",{className:"grid grid-cols-2 md:grid-cols-3 lg:grid-cols-6 gap-4",children:b.map(a=>e.jsx(t,{children:e.jsxs(r,{className:"p-4",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(a.icon,{className:`h-4 w-4 ${a.color}`}),e.jsx("span",{className:"text-xs text-muted-foreground",children:a.label})]}),e.jsx("div",{className:"text-2xl font-bold",children:a.value})]})},a.label))}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(t,{children:[e.jsx(i,{children:e.jsx(n,{className:"text-base",children:"Daily Engagement"})}),e.jsx(r,{children:s!=null&&s.daily_breakdown&&s.daily_breakdown.length>0?e.jsx(m,{width:"100%",height:250,children:e.jsxs(D,{data:s.daily_breakdown,children:[e.jsx(u,{strokeDasharray:"3 3",className:"stroke-border"}),e.jsx(g,{dataKey:"date",tick:{fontSize:11},tickFormatter:a=>new Date(a).toLocaleDateString("en",{month:"short",day:"numeric"})}),e.jsx(f,{tick:{fontSize:11}}),e.jsx(h,{}),e.jsx(j,{type:"monotone",dataKey:"opens",name:"Chat Opens",stroke:"hsl(var(--primary))",strokeWidth:2}),e.jsx(j,{type:"monotone",dataKey:"reflections",name:"Reflections",stroke:"hsl(var(--chart-2))",strokeWidth:2})]})}):e.jsx("p",{className:"text-muted-foreground text-sm text-center py-8",children:"No data yet"})})]}),e.jsxs(t,{children:[e.jsx(i,{children:e.jsx(n,{className:"text-base",children:"Popup Hook Effectiveness"})}),e.jsx(r,{children:s!=null&&s.hook_effectiveness&&s.hook_effectiveness.length>0?e.jsx(m,{width:"100%",height:250,children:e.jsxs(E,{data:s.hook_effectiveness,children:[e.jsx(u,{strokeDasharray:"3 3",className:"stroke-border"}),e.jsx(g,{dataKey:"hook_type",tick:{fontSize:11}}),e.jsx(f,{tick:{fontSize:11}}),e.jsx(h,{}),e.jsx(p,{dataKey:"shown",name:"Shown",fill:"hsl(var(--muted-foreground))",radius:[4,4,0,0]}),e.jsx(p,{dataKey:"clicked",name:"Clicked",fill:"hsl(var(--primary))",radius:[4,4,0,0]})]})}):e.jsx("p",{className:"text-muted-foreground text-sm text-center py-8",children:"No popup data yet"})})]})]}),(s==null?void 0:s.memory_types)&&Object.keys(s.memory_types).length>0&&e.jsxs(t,{children:[e.jsx(i,{children:e.jsx(n,{className:"text-base",children:"Active Memory Types"})}),e.jsx(r,{children:e.jsx("div",{className:"flex flex-wrap gap-3",children:Object.entries(s.memory_types).map(([a,o])=>e.jsxs("div",{className:"inline-flex items-center gap-2 bg-muted rounded-full px-4 py-2",children:[e.jsx("span",{className:"text-sm font-medium capitalize",children:a}),e.jsx("span",{className:"text-xs bg-primary/10 text-primary rounded-full px-2 py-0.5",children:o})]},a))})})]})]})}export{H as default};
2//# sourceMappingURL=BotAnalytics-BlmMG4JV.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.