PageSourceSearch

https://shifi.ai/build/assets/Analytics-CXgf822b.js

js shifi.ai collected 2026-10-05 15:25:40 UTC 11,565 bytes, 1 lines download raw bytes

1import{j as e,H as L,L as h,b as D}from"./app-CdWZ-TqC.js";import{B as M}from"./badge-DaFgMb1f.js";import{B as u}from"./button-BAiLVXNj.js";import{A}from"./AdminLayout-TjvhgQ7x.js";import{L as T}from"./list-CWLppBX-.js";import{R as j,T as f,x as g}from"./generateCategoricalChart-O645i07o.js";import{L as b,a as i}from"./LineChart-Dcn4eQVi.js";import{C as y}from"./CartesianGrid-CocuJMBK.js";import{X as N,Y as v}from"./YAxis-Dt2EC3W7.js";import{M as z}from"./mail-CA85L6E5.js";import{f as S}from"./format-DXeuSQL-.js";import"./app-0XN2XBOc.js";import"./index-CdM08Z7g.js";import"./index-Ci6F6MGZ.js";import"./utils-W0zqx4UN.js";import"./index-CA1Q4WcR.js";import"./CfoAssistantSheet-cOAhJXaI.js";import"./sheet-X3pTfVvw.js";import"./dialog-DQyHKjdn.js";import"./index-q-N_U4wO.js";import"./index-CHpCgICh.js";import"./Combination-C3mKrg6h.js";import"./index-IqNdgLNb.js";import"./index-CIc8T9B1.js";import"./index-Drf94EY5.js";import"./x-JgTLEcbz.js";import"./MarkdownContent-D-CApPKA.js";import"./index-B_9zfXDT.js";import"./card-CjQch57N.js";import"./textarea-BPeZ5dgG.js";import"./useQuery-CpSPXgqy.js";import"./index-C9_z3gxO.js";import"./plus-CeuujmNF.js";import"./loader-circle-C48owIN0.js";import"./proxy-DnTnLdBl.js";import"./arrow-down-DeoaWT9a.js";import"./send-k6VBoj35.js";import"./circle-alert-keAWZZhx.js";import"./rotate-ccw-3BNv9vTU.js";import"./check-D2esu3pV.js";import"./copy-CeGNbXbp.js";import"./sparkles-DbDicYbG.js";import"./index-CscXLC4j.js";import"./useMutation-nvKea2U0.js";import"./phone-B-0usCnL.js";import"./AnnouncementModal-BPb2ZN7J.js";import"./SidebarDropdownMenu-DmYITgC0.js";import"./bell-TApj2qGN.js";import"./dropdown-menu-eSQf8CIT.js";import"./index-BDeTckWN.js";import"./index-CYf2rV4M.js";import"./index-DKGRtURc.js";import"./index-C3h-N4nv.js";import"./chevron-right-_8CkCpeF.js";import"./chevron-down-B9reUq3M.js";import"./users-D8omv4QV.js";import"./phone-call-uEbMy2lS.js";import"./sidebar-Cd7ZrxWk.js";import"./useChatUnreadCount-6Fc9xdgO.js";import"./useUnreadMessageCount-D6vQHaee.js";import"./message-square-Co1ZQPG2.js";import"./message-circle-DCFXj8oc.js";import"./smartphone-B_DIdQmW.js";import"./debounce-DoT9CFXq.js";import"./tiny-invariant-CopsF_GD.js";const E=[{label:"7d",value:7},{label:"30d",value:30},{label:"90d",value:90},{label:"All",value:"all"}],K={bounced:"bg-red-100 text-red-800",dropped:"bg-rose-100 text-rose-800",failed:"bg-red-100 text-red-800",spam_reported:"bg-orange-100 text-orange-800"};function R(s){if(!s)return"Unknown";const r=s.split("\\");return r[r.length-1]}function c(s){return S(new Date(`${s}T00:00:00`),"MMM d")}function G(s){try{return S(new Date(s),"MMM d, yyyy HH:mm")}catch{return s}}function k(s){return s===null?"—":`${s}%`}function _(s){if(s===null)return"—";if(s<60)return`${Math.round(s)}s`;if(s<3600)return`${Math.round(s/60)}m`;const r=Math.floor(s/3600),a=Math.round(s%3600/60);return a>0?`${r}h ${a}m`:`${r}h`}function x(s,r,a,n){if(s===null)return;const l=`${s>0?"+":""}${s}${r} vs prior ${n}`;if(a==="neutral"||s===0)return{text:l,className:"text-gray-400"};const d=a==="up"?s>0:s<0;return{text:l,className:d?"text-green-600":"text-red-600"}}function Ye({stats:s,trends:r,series:a,byMailable:n,problemDomains:p,latency:l,recentFailures:d,range:o}){const m=`${o}d`,w=[{label:"Total sent",value:s.total,accent:"text-gray-900",trend:r?x(r.sent,"%","neutral",m):void 0},{label:"Delivered",value:s.delivered,accent:"text-green-600",sub:s.delivered_rate!==null?`${s.delivered_rate}% of total`:void 0,trend:r?x(r.delivered_rate," pts","up",m):void 0},{label:"Opened",value:s.opened,accent:"text-emerald-600",sub:s.open_rate!==null?`${s.open_rate}% of delivered`:void 0,trend:r?x(r.open_rate," pts","up",m):void 0},{label:"Bounced / Dropped",value:s.bounced,accent:"text-red-600",trend:r?x(r.bounced,"%","down",m):void 0},{label:"Marked as Spam",value:s.spam_reported,accent:"text-orange-600"},{label:"Failed",value:s.failed,accent:"text-red-600"}],$=t=>{D.get(route("admin.email-logs.analytics"),t===30?{}:{range:t},{preserveScroll:!0,preserveState:!0})};return e.jsxs(A,{children:[e.jsx(L,{title:"Email Analytics"}),e.jsxs("div",{className:"space-y-6 p-6",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Email Analytics"}),e.jsxs("p",{className:"text-sm text-gray-500",children:["Delivery and engagement trends from SendGrid, ",o==="all"?"all time":`last ${o} days`,"."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[E.map(t=>e.jsx(u,{size:"sm",variant:o===t.value?"default":"outline",onClick:()=>$(t.value),children:t.label},t.label)),e.jsx(h,{href:route("admin.email-logs.index"),children:e.jsxs(u,{size:"sm",variant:"outline",children:[e.jsx(T,{className:"mr-1 h-4 w-4"}),"View logs"]})})]})]}),e.jsx("div",{className:"grid grid-cols-2 gap-4 md:grid-cols-3 lg:grid-cols-6",children:w.map(t=>e.jsxs("div",{className:"rounded-lg bg-white p-4 shadow",children:[e.jsx("p",{className:"text-xs font-medium text-gray-500",children:t.label}),e.jsx("p",{className:`mt-1 text-2xl font-semibold ${t.accent}
1`,children:t.value.toLocaleString()}),t.sub&&e.jsx("p",{className:"mt-0.5 text-xs text-gray-400",children:t.sub}),t.trend&&e.jsx("p",{className:`mt-0.5 text-xs ${t.trend.className}`,children:t.trend.text})]},t.label))}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 xl:grid-cols-2",children:[e.jsxs("div",{className:"rounded-lg bg-white p-6 shadow",children:[e.jsx("h2",{className:"mb-4 text-sm font-semibold text-gray-700",children:"Volume per day"}),e.jsx("div",{className:"h-72",children:e.jsx(j,{width:"100%",height:"100%",children:e.jsxs(b,{data:a,margin:{top:4,right:8,left:-16,bottom:0},children:[e.jsx(y,{strokeDasharray:"3 3",stroke:"#f0f0f0"}),e.jsx(N,{dataKey:"day",tickFormatter:c,tick:{fontSize:11},minTickGap:24}),e.jsx(v,{allowDecimals:!1,tick:{fontSize:11}}),e.jsx(f,{labelFormatter:t=>c(String(t))}),e.jsx(g,{wrapperStyle:{fontSize:12}}),e.jsx(i,{type:"monotone",dataKey:"sent",name:"Sent",stroke:"#3b82f6",strokeWidth:2,dot:!1}),e.jsx(i,{type:"monotone",dataKey:"delivered",name:"Delivered",stroke:"#22c55e",strokeWidth:2,dot:!1}),e.jsx(i,{type:"monotone",dataKey:"opened",name:"Opened",stroke:"#10b981",strokeWidth:2,dot:!1}),e.jsx(i,{type:"monotone",dataKey:"undelivered",name:"Undelivered",stroke:"#ef4444",strokeWidth:2,dot:!1})]})})})]}),e.jsxs("div",{className:"rounded-lg bg-white p-6 shadow",children:[e.jsxs("div",{className:"mb-4 flex flex-wrap items-center justify-between gap-2",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-700",children:"Delivery and open rates"}),e.jsxs("p",{className:"text-xs text-gray-500",children:["median delivery ",_(l.median_delivery_seconds)," · median time to open"," ",_(l.median_open_seconds)]})]}),e.jsx("div",{className:"h-72",children:e.jsx(j,{width:"100%",height:"100%",children:e.jsxs(b,{data:a,margin:{top:4,right:8,left:-16,bottom:0},children:[e.jsx(y,{strokeDasharray:"3 3",stroke:"#f0f0f0"}),e.jsx(N,{dataKey:"day",tickFormatter:c,tick:{fontSize:11},minTickGap:24}),e.jsx(v,{domain:[0,100],unit:"%",tick:{fontSize:11}}),e.jsx(f,{labelFormatter:t=>c(String(t)),formatter:t=>[`${t}%`,void 0]}),e.jsx(g,{wrapperStyle:{fontSize:12}}),e.jsx(i,{type:"monotone",dataKey:"delivered_rate",name:"Delivery rate",stroke:"#22c55e",strokeWidth:2,dot:!1,connectNulls:!0}),e.jsx(i,{type:"monotone",dataKey:"open_rate",name:"Open rate",stroke:"#0ea5e9",strokeWidth:2,dot:!1,connectNulls:!0})]})})})]})]}),e.jsxs("div",{className:"rounded-lg bg-white p-6 shadow",children:[e.jsx("h2",{className:"mb-4 text-sm font-semibold text-gray-700",children:"Performance by email type"}),n.length===0?e.jsx("p",{className:"py-6 text-center text-sm text-gray-500",children:"No emails in this period."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-xs font-medium text-gray-500",children:[e.jsx("th",{className:"pr-4 pb-2",children:"Email type"}),e.jsx("th",{className:"pr-4 pb-2 text-right",children:"Sent"}),e.jsx("th",{className:"pr-4 pb-2 text-right",children:"Delivered"}),e.jsx("th",{className:"pr-4 pb-2 text-right",children:"Delivery rate"}),e.jsx("th",{className:"pr-4 pb-2 text-right",children:"Open rate"}),e.jsx("th",{className:"pb-2 text-right",children:"Undelivered"})]})}),e.jsx("tbody",{children:n.map(t=>e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsx("td",{className:"py-2 pr-4 font-medium",title:t.mailable??"",children:R(t.mailable)}),e.jsx("td",{className:"py-2 pr-4 text-right",children:t.sent.toLocaleString()}),e.jsx("td",{className:"py-2 pr-4 text-right",children:t.delivered.toLocaleString()}),e.jsx("td",{className:"py-2 pr-4 text-right",children:k(t.delivered_rate)}),e.jsx("td",{className:"py-2 pr-4 text-right",children:k(t.open_rate)}),e.jsx("td",{className:`py-2 text-right ${t.undelivered>0?"font-medium text-red-600":""}`,children:t.undelivered.toLocaleString()})]},t.mailable??"unknown"))})]})})]}),e.jsxs("div",{className:"grid grid-cols-1 gap-6 xl:grid-cols-3",children:[e.jsxs("div",{className:"rounded-lg bg-white p-6 shadow",children:[e.jsx("h2",{className:"mb-4 text-sm font-semibold text-gray-700",children:"Failures by domain"}),p.length===0?e.jsx("p",{className:"py-6 text-center text-sm text-gray-500",children:"No delivery failures in this period."}):e.jsx("ul",{className:"space-y-2",children:p.map(t=>e.jsxs("li",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"truncate pr-2 font-medium",title:t.domain,children:t.domain||"unknown"}),e.jsx("span",{className:"font-semibold text-red-600",children:t.count.toLocaleStr
1ing()})]},t.domain))})]}),e.jsxs("div",{className:"rounded-lg bg-white p-6 shadow xl:col-span-2",children:[e.jsxs("div",{className:"mb-4 flex items-center justify-between",children:[e.jsx("h2",{className:"text-sm font-semibold text-gray-700",children:"Recent delivery problems"}),e.jsx(h,{href:route("admin.email-logs.index",{status:"bounced"}),className:"text-xs text-blue-600 hover:underline",children:"View all in logs"})]}),d.length===0?e.jsxs("p",{className:"py-6 text-center text-sm text-gray-500",children:[e.jsx(z,{className:"mx-auto mb-2 h-5 w-5 text-gray-400"}),"No bounces, drops, or spam reports in this period."]}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-sm",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"border-b text-left text-xs font-medium text-gray-500",children:[e.jsx("th",{className:"pr-4 pb-2",children:"When"}),e.jsx("th",{className:"pr-4 pb-2",children:"To"}),e.jsx("th",{className:"pr-4 pb-2",children:"Subject"}),e.jsx("th",{className:"pr-4 pb-2",children:"Status"}),e.jsx("th",{className:"pb-2",children:"Reason"})]})}),e.jsx("tbody",{children:d.map(t=>e.jsxs("tr",{className:"border-b last:border-0",children:[e.jsx("td",{className:"py-2 pr-4 whitespace-nowrap text-gray-600",children:G(t.created_at)}),e.jsx("td",{className:"max-w-[14rem] truncate py-2 pr-4",title:t.to_email,children:t.to_email}),e.jsx("td",{className:"max-w-xs truncate py-2 pr-4",title:t.subject??"",children:t.subject||"—"}),e.jsx("td",{className:"py-2 pr-4",children:e.jsx(M,{className:K[t.status]??"bg-gray-100 text-gray-700",children:t.status.replace(/_/g," ")})}),e.jsx("td",{className:"max-w-sm truncate py-2 text-gray-500",title:t.status_reason??"",children:t.status_reason||"—"})]},t.id))})]})})]})]})]})]})}export{Ye 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.