PageSourceSearch

https://langbuddy.ai/_next/static/chunks/pages/admin/stats-69f6de0d39db6bad.js

js langbuddy.ai collected 2026-10-05 12:09:59 UTC 10,730 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[2144],{41244:function(e,a,t){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/stats",function(){return t(12094)}])},20684:function(e,a,t){"use strict";t.d(a,{u:function(){return l}});var r=t(85893);function l(e){let{title:a,description:t}=e;return(0,r.jsxs)("div",{className:"rounded-xl border border-dashed border-gray-200 bg-white px-6 py-12 text-center",children:[(0,r.jsx)("p",{className:"text-sm font-medium text-gray-900",children:a}),t?(0,r.jsx)("p",{className:"mt-1 text-sm text-gray-500",children:t}):null]})}},29776:function(e,a,t){"use strict";t.d(a,{h:function(){return l}});var r=t(85893);function l(e){let{label:a,value:t,hint:l,delta:s,accent:n="indigo"}=e,i={indigo:"text-indigo-600",blue:"text-blue-600",green:"text-green-600",amber:"text-amber-600",gray:"text-gray-900"},d=null,c="text-gray-400";if("number"==typeof s&&!Number.isNaN(s)){let e=s>0?"+":"";d="".concat(e).concat(s,"%"),c=s>0?"text-green-600":s<0?"text-red-500":"text-gray-400"}return(0,r.jsxs)("div",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[(0,r.jsx)("p",{className:"text-xs font-medium uppercase tracking-wide text-gray-500",children:a}),(0,r.jsx)("p",{className:"mt-1 text-3xl font-bold tabular-nums ".concat(i[n]||i.indigo),children:t}),(0,r.jsxs)("div",{className:"mt-1 flex items-center gap-2 text-xs text-gray-400",children:[l?(0,r.jsx)("span",{children:l}):null,d?(0,r.jsxs)("span",{className:c,children:[d," vs prior"]}):null]})]})}},68748:function(e,a,t){"use strict";t.d(a,{m:function(){return l}});var r=t(85893);function l(e){let{title:a,description:t,actions:l}=e;return(0,r.jsxs)("div",{className:"mb-6 flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between",children:[(0,r.jsxs)("div",{children:[(0,r.jsx)("h1",{className:"text-xl font-semibold text-gray-900 sm:text-2xl",children:a}),t?(0,r.jsx)("div",{className:"mt-1 text-sm text-gray-500",children:t}):null]}),l?(0,r.jsx)("div",{className:"flex shrink-0 flex-wrap items-center gap-2",children:l}):null]})}},26757:function(e,a,t){"use strict";t.d(a,{u:function(){return s}});var r=t(85893),l=t(72761);function s(e){let{value:a,onChange:t,options:s=l.vq}=e;return(0,r.jsx)("div",{className:"inline-flex flex-wrap rounded-lg border border-gray-200 bg-white p-0.5",children:s.map(e=>{let l=a===e.value;return(0,r.jsx)("button",{type:"button",onClick:()=>t(e.value),className:l?"rounded-md bg-indigo-600 px-3 py-1.5 text-xs font-semibold text-white":"rounded-md px-3 py-1.5 text-xs font-medium text-gray-600 hover:text-gray-900",children:e.label},e.value)})})}},12918:function(e,a,t){"use strict";t.d(a,{Aw:function(){return n},MQ:function(){return i},tv:function(){return d}});var r=t(85893);function l(){for(var e=arguments.length,a=Array(e),t=0;t<e;t++)a[t]=arguments[t];
1return a.filter(Boolean).join(" ")}function s(e){let{className:a=""}=e;return(0,r.jsx)("div",{className:l("animate-pulse rounded-md bg-gray-200/80",a)})}function n(){return(0,r.jsxs)("div",{className:"rounded-xl border border-gray-200 bg-white p-4",children:[(0,r.jsx)(s,{className:"mb-3 h-3 w-20"}),(0,r.jsx)(s,{className:"h-8 w-24"}),(0,r.jsx)(s,{className:"mt-2 h-3 w-16"})]})}function i(e){let{className:a="h-[280px]"}=e;return(0,r.jsxs)("div",{className:l("rounded-xl border border-gray-200 bg-white p-4",a),children:[(0,r.jsx)(s,{className:"mb-4 h-4 w-32"}),(0,r.jsx)(s,{className:"h-[220px] w-full rounded-lg"})]})}function d(e){let{cols:a=5}=e;return(0,r.jsx)("div",{className:"flex gap-3 border-b border-gray-100 px-4 py-3",children:Array.from({length:a}).map((e,a)=>(0,r.jsx)(s,{className:"h-4 flex-1"},a))})}},72761:function(e,a,t){"use strict";t.d(a,{Ce:function(){return n},Pn:function(){return l},_5:function(){return s},vq:function(){return r}});let r=[{value:"7d",label:"7d"},{value:"30d",label:"30d"},{value:"90d",label:"90d"},{value:"ytd",label:"YTD"},{value:"1y",label:"1y"},{value:"all",label:"All"}],l=[{value:"day",label:"Day"},{value:"week",label:"Week"},{value:"month",label:"Month"},{value:"quarter",label:"Quarter"}];function s(e){return"7d"===e||"30d"===e?"day":"90d"===e?"week":"ytd"===e||"1y"===e?"month":"quarter"}function n(e){let a=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"day";return"quarter"===a||"month"===a?e:"week"===a?e.slice(5):e.length>7?e.slice(5):e}},12094:function(e,a,t){"use strict";t.r(a),t.d(a,{__N_SSP:function(){return p},default:function(){return g}});var r=t(85893),l=t(67294),s=t(33934),n=t(24139),i=t(77905),d=t(72761),c=t(68748),o=t(26757),u=t(29776),x=t(12918),m=t(20684);async function h(e,a){let t=await fetch("/api/admin/stats?range=".concat(e,"&group=").concat(a));if(!t.ok)throw Error("Failed to load stats");return t.json()}var p=!0;function g(){var e,a,t,p,g,y,b;let[j,v]=(0,l.useState)("30d"),[f,N]=(0,l.useState)((0,d._5)("30d")),{data:w,isLoading:k,isFetching:S,isError:T}=(0,s.a)({queryKey:["admin-stats",j,f],queryFn:()=>h(j,f),placeholderData:n.Wk}),_=k&&!w,M=(null==w?void 0:w.series)||[],P=null==w?void 0:w.summary,A=M.map(e=>e.date),C=Math.max(1,Math.ceil(A.length/6)),E="day"===f?"day":f;return(0,r.jsxs)("div",{className:S&&!k?"opacity-70 transition-opacity":"",children:[(0,r.jsx)(c.m,{title:"Signup stats",description:"Cohort funnel: signup → trial started → still paying. Grouped by signup date.",actions:(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(o.u,{value:j,onChange:function(e){v(e),N((0,d._5)(e))}}),(0,r.jsx)(o.u,{value:f,onChange:N,options:d.Pn})]})}),T?(0,r.jsx)(m.u,{title:"Couldn’t load stats",description:"Refresh and try again."}):null,(0,r.jsx)("div",{className:"mb-3 grid grid-cols-2 gap-3 sm:grid-cols-4",children:_?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(x.Aw,{}),(0,r.jsx)(x.Aw,{}),(0,r.jsx)(x.Aw,{}),(0,r.jsx)(x.Aw,{})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.h,{label:"Signups",value:null!==(e=null==P?void 0:P.totalSignups)&&void 0!==e?e:0,accent:"indigo"}),(0,r.jsx)(u.h,{label:"Trials started",value:null!==(a=null==P?void 0:P.totalTrialsStarted)&&void 0!==a?a:0,hint:"opened a subscription",accent:"amber"}),(0,r.jsx)(u.h,{label:"Still paying",value:null!==(t=null==P?void 0:P.totalPaying)&&void 0!==t?t:0,hint:"stripe: active now",accent:"green"}),(0,r.jsx)(u.h,{label:"Trial → paying",value:"".concat(null!==(p=null==P?void 0:P.trialToPayingRate)&&void 0!==p?p:0,"%"),hint:"of trials started",accent:"green"})]})}),(0,r.jsx)("div",{className:"mb-6 grid grid-cols-2 gap-3 sm:grid-cols-3",children:_?(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(x.Aw,{}),(0,r.jsx)(x.Aw,{}),(0,r.jsx)(x.Aw,{})]}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(u.h,{label:"Signup → trial",value:"".concat(null!==(g=null==P?void 0:P.trialRate)&&void 0!==g?g:0,"%"),hint:"started a trial",accent:"amber"}),(0,r.jsx)(u.h,{label:"Signup → paying",value:"".concat(null!==(y=null==P?void 0:P.payingRate)&&void 0!==y?y:0,"%"),hint:"still active",accent:"green"}),(0,r.jsx)(u.h,{label:"Past due",value:null!==(b=null==P?void 0:P.totalPastDue)&&void 0!==b?b:0,hint:"payment failed",accent:"gray"})]})}),_?(0,r.jsxs)("div",{className:"mb-6 grid grid-cols-1 gap-4",children:[(0,r.jsx)(x.MQ,{}),(0,r.jsx)(x.MQ,{})]}):M.every(e=>0===e.total)?(0,r.jsx)(m.u,{title:"No signups in this range",description:"Try a wider range."}):(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)("div",{className:"mb-6 rounded-xl border border-gray-200 bg-white p-4",children:[(0,r.jsxs)("h2",{className:"mb-2 text-sm font-semibold text-gray-900",children:["Signups by ",E]}),(0,r.jsx)("div",{className:"h-[300px]",children:(0,r.jsx)(i.w,{margin:{top:12,right:25,bottom:25,left:35},series:[{data:M.map(e=>e.total),label:"Signups",area:!0,showMark:!1,color:"#6366f1"},{data:M.map(e=>e.trialsStarted),label:"Trials started",area:!0,showMark:!1,color:"#f59e0b"},{data:M.map(e=>e.paying),label:"Still paying",area:!0,showMark:!1,color:"#22c55e"},{data:M.map(e=>e.pastDue),label:"Past due",area:!0,showMark:!1,color:"#ef4444"}],xAxis:[{scaleType:"point",data:A,tickLabelInterval:(e,a)=>a%C==0,valueFormatter:e=>(0,d.Ce)(e,f)}],sx:{"& .MuiLineElement-root":{strokeWidth:2},"& .MuiAreaElement-root":{opacity:.15}}})})]}),(0,r.jsxs)("div",{className:"mb-6 rounded-xl border border-gray-200 bg-white p-4",children:[(0,r.jsx)("h2",{className:"mb-2 text-sm font-semibold text-gray-900",children:"Conversion rate (%)"}),(0,r.jsx)("div",{className:"h-[300px]",children:(0,r.jsx)(i.w,{margin:{top:12,right:25,bottom:25,left:35},series:[{data:M.map(e=>e.trialRate),label:"Trial start %",area:!0,showMark:!1,color:"#f59e0b"},{data:M.map(e=>e.payingRate),label:"Paying %",area:!0,showMark:!1,color:"#22c55e"},{data:M.map(e=>e.trialToPayingRate),label:"Trial → paying %",area:!0,showMark:!1,color:"#10b981"}],xAxis:[{scaleType:"point",data:A,tickLabelInterval:(e,a)=>a%C==0,valueFormatter:e=>(0,d.Ce)(e,f)}],sx:{"& .MuiLineElement-root":{strokeWidth:2},"& .MuiAreaElement-root":{opacity:.15}}})})]}),(0,r.jsxs)("div",{className:"overflow-hidden rounded-xl border border-gray-200 bg-white",children:[(0,r.jsx)("div",{className:"border-b border-gray-100 px-4 py-3",children:(0,r.jsxs)("h2",{className:"text-sm font-semibold text-gray-900",children:["Per-",E," breakdown"]})}),(0,r.jsx)("div",{className:"max-h-[420px] overflow-auto",children:(0,r.jsxs)("table",{className:"min-w-full divide-y divide-gray-100 text-sm",children:[(0,r.jsx)("thead",{className:"sticky top-0 bg-gray-50 text-left text-xs uppercase tracking-wide text-gray-500",children:(0,r.jsxs)("tr",{children:[(0,r.jsx)("th",{className:"px-4 py-2",children:"Period"}),(0,r.jsx)("th",{className:"px-4 py-2",children:"Signups"}),(0,r.jsx)("th",{className:"px-4 py-2",children:"Trials started"}),(0,r.jsx)("th",{className:"px-4 py-2",children:"Still paying"}),(0,r.jsx)("th",{className:"px-4 py-2",children:"Past due"}),(0,r.jsx)("th",{className:"px-4 py-2",children:"Trial %"}),(0,r.jsx)("th",{className:"px-4 py-2",children:"Paying %"}),(0,r.jsx)("th",{className:"px-4 py-2",children:"Trial → pay %"})]})}),(0,r.jsx)("tbody",{className:"divide-y divide-gray-100",children:[...M].reverse().map(e=>(0,r.jsxs)("tr",{className:"tabular-nums text-gray-700",children:[(0,r.jsx)("td",{className:"px-4 py-2",children:e.date}),(0,r.jsx)("td",{className:"px-4 py-2",children:e.total}),(0,r.jsx)("td",{className:"px-4 py-2",children:e.trialsStarted}),(0,r.jsx)("td",{className:"px-4 py-2",children:e.paying}),(0,r.jsx)("td",{className:"px-4 py-2",children:e.pastDue}),(0,r.jsxs)("td",{className:"px-4 py-2",children:[e.trialRate,"%"]}),(0,r.jsxs)("td",{className:"px-4 py-2",children:[e.payingRate,"%"]}),(0,r.jsxs)("td",{className:"px-4 py-2",children:[e.trialToPayingRate,"%"]})]},e.date))})]})})]})]})]})}}},function(e){e.O(0,[3934,7905,2888,9774,179],function(){return e(e.s=41244)}),_N_E=e.O()}]);

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.