PageSourceSearch

https://thedeepbrief.co.uk/assets/AdminEmailAnalytics-Cnwwzace.js

js thedeepbrief.co.uk collected 2026-09-24 15:15:15 UTC 10,683 bytes, 1 lines download raw bytes

1import{r as w,j as e}from"./vendor-react-CUX7D0C7.js";import{t as N,B as b,f as y,C as r,d as i,e as n,c,g as o}from"./index-CKW83pDQ.js";import{a3 as S,A as E,U as k,M as A,m as T,C,T as _}from"./vendor-icons-kZFcvpIB.js";import"./vendor-pdf-CFaLvvvW.js";import"./vendor-ui-DV1JMX9G.js";import"./vendor-charts-Dis8PKHX.js";function L(){var h,p,j,u;const{data:t,isLoading:f}=N.admin.emailAnalytics.useQuery(),{data:a}=N.admin.getTrialDripStats.useQuery();return w.useEffect(()=>{document.title="Email Analytics | Admin | The Deep Brief"},[]),f?e.jsxs("div",{className:"p-6 space-y-6",children:[e.jsx("div",{className:"h-8 w-48 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-3 gap-6",children:[...Array(3)].map((s,d)=>e.jsxs("div",{className:"p-6 border rounded-lg space-y-4",children:[e.jsx("div",{className:"h-4 w-20 bg-muted rounded animate-pulse"}),e.jsx("div",{className:"h-8 w-16 bg-muted rounded animate-pulse"})]},d))}),e.jsx("div",{className:"h-48 bg-muted rounded-lg animate-pulse"})]}):t?e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex gap-6 mb-4",children:[e.jsx(b,{asChild:!0,variant:"ghost",size:"sm",children:e.jsxs(y,{href:"/",children:[e.jsx(S,{className:"h-4 w-4 mr-2"}),"Home"]})}),e.jsx(b,{asChild:!0,variant:"ghost",size:"sm",children:e.jsxs(y,{href:"/admin",children:[e.jsx(E,{className:"h-4 w-4 mr-2"}),"Back to Admin"]})})]}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-serif text-gold mb-2",children:"Email Analytics"}),e.jsx("p",{className:"text-text-secondary",children:"Monitor email subscription and engagement metrics"})]}),e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[e.jsxs(r,{className:"bg-navy-mid border-gold-dim/30",children:[e.jsxs(i,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(n,{className:"text-sm font-medium text-text-secondary",children:"Total Subscribers"}),e.jsx(k,{className:"h-4 w-4 text-gold"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold text-text-primary",children:t.totalSubscribers}),e.jsxs("p",{className:"text-xs text-text-secondary mt-1",children:[t.activeSubscribers," active"]})]})]}),e.jsxs(r,{className:"bg-navy-mid border-gold-dim/30",children:[e.jsxs(i,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(n,{className:"text-sm font-medium text-text-secondary",children:"Emails Sent"}),e.jsx(A,{className:"h-4 w-4 text-gold"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold text-text-primary",children:t.totalEmailsSent}),e.jsx("p",{className:"text-xs text-text-secondary mt-1",children:"All time"})]})]}),e.jsxs(r,{className:"bg-navy-mid border-gold-dim/30",children:[e.jsxs(i,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(n,{className:"text-sm font-medium text-text-secondary",children:"This Week"}),e.jsx(T,{className:"h-4 w-4 text-gold"})]}),e.jsxs(c,{children:[e.jsx("div",{className:"text-2xl font-bold text-text-primary",children:t.subscribersThisWeek}),e.jsx("p",{className:"text-xs text-text-secondary mt-1",children:"New subscribers"})]})]}),e.jsxs(r,{className:"bg-navy-mid border-gold-dim/30",children:[e.jsxs(i,{className:"flex flex-row items-center justify-between space-y-0 pb-2",children:[e.jsx(n,{className:"text-sm font-medium text-text-secondary",children:"Success Rate"}),e.jsx(C,{className:"h-4 w-4 text-gold"})]}),e.jsxs(c,{children:[e.jsxs("div",{className:"text-2xl font-bold text-text-primary",children:[t.totalEmailsSent>0?Math.round(t.successfulEmails/t.totalEmailsSent*100):0,"%"]}),e.jsxs("p",{className:"text-xs text-text-secondary mt-1",children:[t.successfulEmails," successful"]})]})]})]}),a&&a.totalTrialUsers>0&&e.jsxs(r,{className:"bg-navy-mid border-gold-dim/30",children:[e.jsxs(i,{children:[e.jsxs(n,{className:"text-gold flex items-center gap-2",children:[e.jsx(_,{className:"h-5 w-5"})," Trial Email Drip"]}),e.jsxs(o,{children:[a.totalTrialUsers," trial users · ",((h=a.emailsSent)==null?void 0:h.reduce((s,d)=>s+d.count,0))||0," emails sent"]})]}),e.jsxs(c,{children:[e.jsxs("div",{className:"grid grid-cols-2 md:grid-cols-4 gap-4 mb-6",children:[e.jsxs("div",{className:"bg-blue-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-xl font-bold text-blue-400",children:a.totalTrialUsers}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Trial Users"})]}),e.jsxs("div",{className:"bg-orange-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-xl font-bold text-orange-400",children:((p=a.engagement)==null?void 0:p.zeroSessions)||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"0 Sessions"})]}),e.jsxs("div",{className:"bg-purple-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-xl font-bold text-purple-400",children:((j=a.engagement)==null?void 0:j.exhaustedSessions)||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Used All 3"})]}),e.jsxs("div",{className:"bg-green-500/10 rounded-lg p-3 text-center",children:[e.jsx("div",{className:"text-xl font-bold text-green-400",children:((u=a.engagement)==null?void 0:u.converted)||0}),e.jsx("div",{className:"text-xs text-muted-foreground",children:"Converted"})]})]}),(()=>{const s=[{key:"welcome",label:"Welcome",when:"On signup"},{key:"nudge_24h",label:"24h Activation Nudge",when:"20–44h · 0 sessions"},{key:"nudge",label:"Day 1–3 Nudge",when:"Day 1–3 · 0 sessions"},{key:"session_1_complete",label:"Session 1 Complete",when:"After session 1"},{key:"session_1_followup",label:"Session 1 Follow-up",when:"Day 3+ · stuck at 1"},{key:"session_2_complete",label:"Session 2 Complete",when:"After session 2"},{key:"budget_exhausted",label:"Budget Exhausted",when:"After session 3"},{key:"expiry_7d",label:"Expiry Warning (7 days)",when:"Day 7 before expiry"},{key:"expiry_1d",label:"Expiry Warning (1 day)",when:"Day before expiry"}
1],d=Object.fromEntries((a.emailsSent||[]).map(l=>[l.type,l])),g=a.totalTrialUsers||1;return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"grid grid-cols-12 text-xs text-muted-foreground px-2 pb-1 border-b border-border/30",children:[e.jsx("span",{className:"col-span-5",children:"Stage"}),e.jsx("span",{className:"col-span-3",children:"Fires when"}),e.jsx("span",{className:"col-span-2 text-right",children:"Sent"}),e.jsx("span",{className:"col-span-2 text-right",children:"% users"})]}),s.map(l=>{const x=d[l.key],m=(x==null?void 0:x.count)||0,v=g>0?Math.round(m/g*100):0;return e.jsxs("div",{className:`grid grid-cols-12 text-sm p-2 rounded items-center ${m>0?"bg-navy-deep/50":"opacity-40"}`,children:[e.jsx("span",{className:"col-span-5 font-medium text-text-primary",children:l.label}),e.jsx("span",{className:"col-span-3 text-xs text-muted-foreground",children:l.when}),e.jsx("span",{className:"col-span-2 text-right text-text-secondary",children:m>0?m:"—"}),e.jsx("span",{className:"col-span-2 text-right text-xs text-muted-foreground",children:m>0?`${v}%`:"—"})]},l.key)}),(a.emailsSent||[]).filter(l=>!s.find(x=>x.key===l.type)).map(l=>e.jsxs("div",{className:"grid grid-cols-12 text-sm p-2 rounded bg-yellow-500/10 items-center",children:[e.jsx("span",{className:"col-span-5 font-medium text-yellow-400",children:l.type.replace(/_/g," ")}),e.jsx("span",{className:"col-span-3 text-xs text-muted-foreground",children:"unknown stage"}),e.jsx("span",{className:"col-span-2 text-right text-text-secondary",children:l.count}),e.jsx("span",{className:"col-span-2 text-right text-xs text-muted-foreground",children:"—"})]},l.type))]})})(),(!a.emailsSent||a.emailsSent.length===0)&&e.jsx("p",{className:"text-text-secondary text-sm mt-4",children:"No trial drip emails sent yet. Emails fire via daily cron."})]})]}),e.jsxs(r,{className:"bg-navy-mid border-gold-dim/30",children:[e.jsxs(i,{children:[e.jsx(n,{className:"text-gold",children:"Subscription Sources"}),e.jsx(o,{children:"Where subscribers are coming from"})]}),e.jsx(c,{children:e.jsx("div",{className:"space-y-4",children:t.subscriptionsBySource.map(s=>e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsx("div",{className:"w-2 h-2 rounded-lg bg-gold"}),e.jsx("span",{className:"text-text-primary capitalize",children:s.source.replace(/_/g," ")})]}),e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("span",{className:"text-text-secondary text-sm",children:[Math.round(s.count/t.totalSubscribers*100),"%"]}),e.jsx("span",{className:"text-text-primary font-semibold min-w-[3rem] text-right",children:s.count})]})]},s.source))})})]}),e.jsxs(r,{className:"bg-navy-mid border-gold-dim/30",children:[e.jsxs(i,{children:[e.jsx(n,{className:"text-gold",children:"Email Sequence Performance"}),e.jsx(o,{children:"Delivery status by email sequence"})]}),e.jsx(c,{children:e.jsx("div",{className:"space-y-4",children:t.emailsBySequence.map(s=>e.jsxs("div",{className:"border-l-4 border-gold-dim/50 pl-4 py-2",children:[e.jsxs("div",{className:"flex items-center justify-between mb-2",children:[e.jsx("h3",{className:"font-medium text-text-primary",children:s.sequenceName}),e.jsxs("span",{className:"text-text-secondary text-sm",children:[s.totalSent," sent"]})]}),e.jsxs("div",{className:"flex gap-6 text-sm",children:[e.jsxs("span",{className:"text-green-500",children:["✓ ",s.successful," successful"]}),s.failed>0&&e.jsxs("span",{className:"text-red-500",children:["✗ ",s.failed," failed"]})]})]},s.sequenceName))})})]}),e.jsxs(r,{className:"bg-navy-mid border-gold-dim/30",children:[e.jsxs(i,{children:[e.jsx(n,{className:"text-gold",children:"Recent Subscribers"}),e.jsx(o,{children:"Latest email subscriptions"})]}),e.jsx(c,{children:e.jsx("div",{className:"space-y-4",children:t.recentSubscribers.map(s=>e.jsxs("div",{className:"flex items-center justify-between py-2 border-b border-gold-dim/20 last:border-0",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-text-primary font-medium",children:s.email}),e.jsx("p",{className:"text-text-secondary text-sm capitalize",children:s.source.replace(/_/g," ")})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-text-secondary text-sm",children:new Date(s.createdAt).toLocaleDateString()}),e.jsx("p",{className:`text-xs ${s.subscribed?"text-green-500":"text-red-500"}`,children:s.subscribed?"Active":"Unsubscribed"})]})]},s.id))})})]})]}):e.jsx("div",{className:"text-center py-12",children:e.jsx("p",{className:"text-text-secondary",children:"No anal
1ytics data available"})})}export{L as default};

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.