PageSourceSearch

https://trueresume.ai/_next/static/chunks/pages/admin/resume-generation-analytics-4e762bcf11845fcb.js

js trueresume.ai collected 2026-10-02 01:12:53 UTC 17,051 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[288],{82068:function(e,s,a){(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/resume-generation-analytics",function(){return a(67719)}])},39200:function(e,s,a){"use strict";a.d(s,{Z:function(){return t}});let t=(0,a(63759).Z)("AlertTriangle",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3Z",key:"c3ski4"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},28562:function(e,s,a){"use strict";a.d(s,{Z:function(){return t}});let t=(0,a(63759).Z)("BarChart3",[["path",{d:"M3 3v18h18",key:"1s2lah"}],["path",{d:"M18 17V9",key:"2bz60n"}],["path",{d:"M13 17V5",key:"1frdt8"}],["path",{d:"M8 17v-3",key:"17ska0"}]])},60493:function(e,s,a){"use strict";a.d(s,{Z:function(){return t}});let t=(0,a(63759).Z)("CheckCircle",[["path",{d:"M22 11.08V12a10 10 0 1 1-5.93-9.14",key:"g774vq"}],["path",{d:"m9 11 3 3L22 4",key:"1pflzl"}]])},46111:function(e,s,a){"use strict";a.d(s,{Z:function(){return t}});let t=(0,a(63759).Z)("DollarSign",[["line",{x1:"12",x2:"12",y1:"2",y2:"22",key:"7eqyqh"}],["path",{d:"M17 5H9.5a3.5 3.5 0 0 0 0 7h5a3.5 3.5 0 0 1 0 7H6",key:"1b0p4s"}]])},70095:function(e,s,a){"use strict";a.d(s,{Z:function(){return t}});let t=(0,a(63759).Z)("Layers",[["path",{d:"m12.83 2.18a2 2 0 0 0-1.66 0L2.6 6.08a1 1 0 0 0 0 1.83l8.58 3.91a2 2 0 0 0 1.66 0l8.58-3.9a1 1 0 0 0 0-1.83Z",key:"8b97xw"}],["path",{d:"m22 17.65-9.17 4.16a2 2 0 0 1-1.66 0L2 17.65",key:"dd6zsq"}],["path",{d:"m22 12.65-9.17 4.16a2 2 0 0 1-1.66 0L2 12.65",key:"ep9fru"}]])},44976:function(e,s,a){"use strict";a.d(s,{Z:function(){return t}});let t=(0,a(63759).Z)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])},90437:function(e,s,a){"use strict";a.d(s,{Z:function(){return t}});let t=(0,a(63759).Z)("TrendingUp",[["polyline",{points:"22 7 13.5 15.5 8.5 10.5 2 17",key:"126l90"}],["polyline",{points:"16 7 22 7 22 13",key:"kwv8wd"}]])},67719:function(e,s,a){"use strict";a.r(s),a.d(s,{default:function(){return w}});var t=a(85893),l=a(67294),n=a(9008),c=a.n(n),r=a(11163),i=a(85412),d=a(67694),o=a(92761),x=a(28562),m=a(44976),h=a(39200),p=a(90437),g=a(46111),u=a(47379),j=a(70095),y=a(60493);function f(e){return null==e||Number.isNaN(e)?"—":1e-4>Math.abs(e)&&0!==e?"<$0.0001":"$".concat(e.toFixed(4))}function N(e){let s=Math.max(...e.daily.map(e=>e.generations),1),a=Math.max(...e.daily.map(e=>e.estimatedUsd),1e-6),l="dark"===e.theme;return(0,t.jsxs)("div",{className:"w-full overflow-x-auto pt-4",children:[(0,t.jsx)("div",{className:"flex items-end gap-1 min-w-[560px]",style:{height:220},children:e.daily.map(e=>(0,t.jsxs)("div",{className:"flex-1 flex flex-col items-center gap-1 min-w-[12px]",children:[(0,t.jsxs)("div",{className:"w-full flex flex-col justify-end items-center gap-0.5",style:{height:170},children:[(0,t.jsx)("div",{className:"w-[70%] rounded-t-md bg-orange-500/90",style:{height:"".concat(e.cacheHits/s*100,"%"),minHeight:e.cacheHits?4:0},title:"Cache hits: ".concat(e.cacheHits)}),(0,t.jsx)("div",{className:"w-[70%] rounded-sm bg-[#0079D3]",style:{height:"".concat((e.generations-e.cacheHits)/s*100,"%"),minHeight:e.generations>e.cacheHits?6:0},title:"Fresh generations: ".concat(e.generations-e.cacheHits)})]}),(0,t.jsx)("div",{className:"w-[50%] rounded-full opacity-70",style:{height:"".concat(Math.min(42,Math.max(e.estimatedUsd/a*40,e.estimatedUsd>0?3:0)),"px"),background:l?"#16a34a":"#22c55e"},title:"Est. marginal OpenAI USD: ".concat(e.estimatedUsd.toFixed(4))}),(0,t.jsx)("span",{className:"text-[9px] truncate max-w-[48px] ".concat(l?"text-[#818384]":"text-gray-500"),title:e.date,children:e.date.slice(5)})]},e.date))}),(0,t.jsxs)("div",{className:"mt-4 flex flex-wrap gap-4 text-xs ".concat(l?"text-[#818384]":"text-gray-600"),children:[(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,t.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm bg-orange-500"})," Cache-hit events (usage log row)"]}),(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,t.jsx)("span",{className:"inline-block w-3 h-3 rounded-sm bg-[#0079D3]"})," Fresh generation rows"]}),(0,t.jsxs)("span",{className:"inline-flex items-center gap-2",children:[(0,t.jsx)("span",{className:"inline-block w-2 h-4 rounded-full bg-green-600"})," Daily marginal USD (stacked tall = higher)"]})]})]})}function b(e){let s=e.rows.reduce((e,s)=>e+s.count,0)||1,a="dark"===e.theme?["#0079D3","#22c55e","#eab308"]:["#0079D3","#16a34a","#ca8a04"],l=0,n=e.rows.map((e,t)=>{let n=e.count/s,c=100*l;return l+=n,"".concat(a[t%a.length]," ").concat(c,"% ").concat(100*l,"%")}),c=n.length?"conic-gradient(".concat(n.join(", "),")"):"#334155";return(0,t.jsxs)("div",{className:"flex flex-col md:flex-row items-center gap-6",children:[(0,t.jsx)("div",{className:"w-40 h-40 rounded-full shrink-0 border-4 border-white/10",style:{background:c},title:"Shares of resume_generation usage logs"}),(0,t.jsx)("ul",{className:"space-y-2 text-sm w-full",children:e.rows.map((e,l)=>(0,t.jsxs)("li",{className:"flex justify-between gap-2",children:[(0,t.jsxs)("span",{className:"flex items-center gap-2 truncate",children:[(0,t.jsx)("span",{className:"w-3 h-3 rounded-sm shrink-0",style:{background:a[l%a.length]}}),(0,t.jsx)("span",{children:e.plan})]}),(0,t.jsxs)("span",{className:"font-mono text-xs opacity-90",children:[e.count," (",Math.round(e.count/s*100),"%)"]})]},e.plan))})]})}function w(){var e;let{theme:s}=(0,d.F)(),a=(0,r.useRouter)(),[n,w]=(0,l.useState)(30),[v,k]=(0,l.useState)(!0),[S,Z]=(0,l.useState)(""),[M,T]=(0,l.useState)(null),A=async e=>{let s=localStorage.getItem("admin_key");if(s){k(!0),Z("");try{let t=await fetch("/api/admin/resume-generation-analytics?days=".concat(e),{headers:{"x-admin-key":s}});if(401===t.status||403===t.status){a.push("/admin");return}if(!t.ok){let e=await t.json().catch(()=>({}));throw Error(e.message||e.error||"Request failed")}let l=await t.json();
1T(l)}catch(e){Z(e instanceof Error?e.message:String(e))}finally{k(!1)}}};(0,l.useEffect)(()=>{if(!localStorage.getItem("admin_key")){a.push("/admin");return}A(n)},[a]);let L=(0,l.useMemo)(()=>"Cost fields are persisted on new usage logs (`marginalEstimatedUsd`) from the JD resume API. Cache-hit rows intentionally record marginal ≈ $0 (OpenAI spend for that HTTP request only). Older logs without telemetry show $0 in sums — totals become more accurate after deploy.",[]),F="dark"===s;return(0,t.jsxs)(t.Fragment,{children:[(0,t.jsx)(c(),{children:(0,t.jsx)("title",{children:"Resume cost & failures — Admin"})}),(0,t.jsx)(i.Z,{}),(0,t.jsxs)("div",{className:"min-h-screen pt-16 ".concat(F?"bg-[#030303]":"bg-gray-50"),children:[(0,t.jsx)("div",{className:"border-b ".concat(F?"bg-[#1A1A1B] border-[#343536]":"bg-white border-[#EDEFF1]"),children:(0,t.jsxs)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-6 flex flex-wrap items-center justify-between gap-4",children:[(0,t.jsxs)("div",{className:"flex items-center gap-3",children:[(0,t.jsx)("button",{type:"button",onClick:()=>a.push("/admin"),className:"p-2 rounded-lg ".concat(F?"hover:bg-[#343536]":"hover:bg-gray-100"),children:(0,t.jsx)(o.Z,{className:"w-5 h-5"})}),(0,t.jsxs)("div",{children:[(0,t.jsxs)("h1",{className:"text-sharp text-2xl md:text-3xl font-bold flex items-center gap-2 flex-wrap",children:[(0,t.jsx)(x.Z,{className:"w-8 h-8 text-[#FF4500]"}),"Resume generation analytics"]}),(0,t.jsx)("p",{className:"text-sm mt-1 ".concat(F?"text-[#818384]":"text-gray-600"),children:"OpenAI-ish spend (telemetry), ATS averages, volumes, and async job failures"})]})]}),(0,t.jsxs)("div",{className:"flex items-center gap-2 flex-wrap",children:[(0,t.jsxs)("label",{className:"text-xs ".concat(F?"text-[#818384]":"text-gray-600"),children:["Range"," ",(0,t.jsx)("select",{value:n,onChange:e=>{let s=Number(e.target.value);w(s),A(s)},className:"ml-1 rounded-lg px-2 py-1 text-sm ".concat(F?"bg-[#272729] border border-[#343536]":"border"),children:[7,14,30,60,90].map(e=>(0,t.jsxs)("option",{value:e,children:[e," days"]},e))})]}),(0,t.jsxs)("button",{type:"button",onClick:()=>A(n),disabled:v,className:"btn-premium flex items-center gap-2 px-4 py-2 rounded-lg text-sm font-semibold",children:[(0,t.jsx)(m.Z,{className:"w-4 h-4 ".concat(v?"animate-spin":"")}),"Refresh"]})]})]})}),(0,t.jsxs)("div",{className:"max-w-7xl mx-auto px-4 sm:px-6 lg:px-8 py-8 space-y-8",children:[(0,t.jsx)("p",{className:"text-xs ".concat(F?"text-[#818384]":"text-gray-600"),children:L}),S&&(0,t.jsxs)("div",{className:"flex items-start gap-2 rounded-xl bg-red-500/10 border border-red-500/30 p-4 text-red-500 text-sm",children:[(0,t.jsx)(h.Z,{className:"w-5 h-5 shrink-0 mt-0.5"}),(0,t.jsx)("span",{children:S})]}),v&&!M?(0,t.jsx)("div",{className:"flex justify-center py-24",children:(0,t.jsx)("div",{className:"animate-spin rounded-full h-14 w-14 border-b-2 border-[#FF4500]"})}):M?(0,t.jsxs)(t.Fragment,{children:[(0,t.jsxs)("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-4",children:[(0,t.jsxs)("div",{className:"glass rounded-2xl p-6 ".concat(F?"glass-dark":""),children:[(0,t.jsx)(p.Z,{className:"w-8 h-8 text-blue-500 mb-3"}),(0,t.jsx)("div",{className:"text-3xl font-bold tabular-nums",children:M.usageLogs.totalGenerations.toLocaleString()}),(0,t.jsx)("p",{className:"text-sm ".concat(F?"text-[#818384]":"text-gray-600"),children:"Generation events logged"}),(0,t.jsxs)("p",{className:"text-xs mt-2 opacity-80",children:[M.usageLogs.cacheHits," cache-hit rows \xb7 ",M.usageLogs.freshGenerations," fresh"]})]}),(0,t.jsxs)("div",{className:"glass rounded-2xl p-6 ".concat(F?"glass-dark":""),children:[(0,t.jsx)(g.Z,{className:"w-8 h-8 text-green-500 mb-3"}),(0,t.jsx)("div",{className:"text-2xl font-bold tabular-nums",children:f(M.usageLogs.totalEstimatedUsd)}),(0,t.jsx)("p",{className:"text-sm ".concat(F?"text-[#818384]":"text-gray-600"),children:"Sum marginal USD (telemetry)"}),(0,t.jsxs)("p",{className:"text-xs mt-2 opacity-80",children:["Avg overall ",f(M.usageLogs.avgEstimatedUsdOverall)," \xb7 ","avg fresh-run ",f(M.usageLogs.avgEstimatedUsdFresh)]})]}),(0,t.jsxs)("div",{className:"glass rounded-2xl p-6 ".concat(F?"glass-dark":""),children:[(0,t.jsx)(u.Z,{className:"w-8 h-8 text-amber-500 mb-3"}),(0,t.jsx)("div",{className:"text-3xl font-bold tabular-nums",children:null!==(e=M.usageLogs.avgAtsScore)&&void 0!==e?e:"—"}),(0,t.jsx)("p",{className:"text-sm ".concat(F?"text-[#818384]":"text-gray-600"),children:"Mean ATS score (logged)"}),(0,t.jsxs)("p",{className:"text-xs mt-2 opacity-80",children:[M.usageLogs.withCostTelemetryRows," logs with marginal USD field set"]})]}),(0,t.jsxs)("div",{className:"glass rounded-2xl p-6 ".concat(F?"glass-dark":""),children:[(0,t.jsx)(j.Z,{className:"w-8 h-8 text-[#FF4500] mb-3"}),(0,t.jsx)("div",{className:"text-3xl font-bold tabular-nums",children:M.byQualityTier.length}),(0,t.jsx)("p",{className:"text-sm ".concat(F?"text-[#818384]":"text-gray-600"),children:"Quality tiers seen"}),(0,t.jsx)("div",{className:"text-xs mt-2 space-y-1 max-h-24 overflow-auto",children:M.byQualityTier.slice(0,4).map(e=>(0,t.jsxs)("div",{className:"flex justify-between gap-2 opacity-90",children:[(0,t.jsx)("span",{className:"truncate",children:e.tier}),(0,t.jsx)("span",{children:e.count})]},e.tier))})]})]}
1),(0,t.jsxs)("div",{className:"grid lg:grid-cols-5 gap-6",children:[(0,t.jsxs)("div",{className:"lg:col-span-3 glass rounded-2xl p-6 ".concat(F?"glass-dark":""),children:[(0,t.jsxs)("h2",{className:"text-lg font-bold mb-2 flex items-center gap-2",children:[(0,t.jsx)(p.Z,{className:"w-5 h-5 text-[#FF4500]"}),"Daily volume & marginal spend (UTC buckets)"]}),0===M.daily.length?(0,t.jsx)("p",{className:"text-sm ".concat(F?"text-[#818384]":"text-gray-600"),children:"No usage in range."}):(0,t.jsx)(N,{daily:M.daily,theme:s})]}),(0,t.jsxs)("div",{className:"lg:col-span-2 glass rounded-2xl p-6 ".concat(F?"glass-dark":""),children:[(0,t.jsx)("h2",{className:"text-lg font-bold mb-4",children:"Plan mix"}),M.bySubscriptionPlan.length?(0,t.jsx)(b,{rows:M.bySubscriptionPlan,theme:s}):(0,t.jsx)("p",{className:"text-sm opacity-70",children:"No data."})]})]}),(0,t.jsxs)("div",{className:"grid lg:grid-cols-2 gap-6",children:[(0,t.jsxs)("div",{className:"glass rounded-2xl p-6 ".concat(F?"glass-dark":""),children:[(0,t.jsxs)("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2 text-red-400",children:[(0,t.jsx)(h.Z,{className:"w-5 h-5"}),"Recent async job failures"]}),0===M.asyncJobs.failedRecent.length?(0,t.jsxs)("div",{className:"flex items-center gap-2 text-green-500",children:[(0,t.jsx)(y.Z,{className:"w-5 h-5"}),"No failed jobs in the recent window matched from DB."]}):(0,t.jsx)("div",{className:"overflow-auto max-h-[340px] text-sm space-y-3",children:M.asyncJobs.failedRecent.map(e=>(0,t.jsxs)("div",{className:"rounded-xl p-4 border ".concat(F?"bg-[#1A1A1B] border-[#343536]":"bg-gray-50 border-gray-200"),children:[(0,t.jsxs)("div",{className:"flex justify-between gap-2 font-mono text-xs",children:[(0,t.jsx)("span",{className:"font-bold truncate",children:e.jobId}),e.completedAt?(0,t.jsx)("span",{className:"opacity-70 shrink-0",children:new Date(e.completedAt).toLocaleString()}):null]}),(0,t.jsx)("div",{className:"text-xs opacity-80 truncate mt-1",children:e.userEmail}),(0,t.jsxs)("pre",{className:"mt-2 text-xs whitespace-pre-wrap break-all max-h-24 overflow-auto ".concat(F?"text-red-300":"text-red-700"),children:[e.message||"(no message)"," ",e.code?" • code: ".concat(e.code):""]})]},e.jobId))})]}),(0,t.jsxs)("div",{className:"glass rounded-2xl p-6 ".concat(F?"glass-dark":""),children:[(0,t.jsxs)("h2",{className:"text-lg font-bold mb-4 flex items-center gap-2",children:[(0,t.jsx)(y.Z,{className:"w-5 h-5 text-green-500"}),"Completed async jobs (latency + telemetry sample)"]}),(0,t.jsx)("div",{className:"overflow-auto max-h-[340px] text-sm space-y-2",children:0===M.asyncJobs.completedSamples.length?(0,t.jsx)("p",{className:"opacity-70",children:"No completed samples in TTL window (~60 days lookback)."}):M.asyncJobs.completedSamples.map(e=>{var s;return(0,t.jsxs)("div",{className:"rounded-lg px-3 py-2 flex flex-wrap gap-x-4 gap-y-1 justify-between ".concat(F?"bg-[#1A1A1B]":"bg-gray-50"),children:[(0,t.jsx)("span",{className:"font-mono text-xs",children:e.jobId}),(0,t.jsx)("span",{className:"text-xs",children:null!=e.processingTimeMs?"".concat((e.processingTimeMs/1e3).toFixed(1),"s"):"—"}),(0,t.jsx)("span",{className:"text-xs",children:null!=e.matchScore?"".concat(e.matchScore,"% ATS"):"—"}),(0,t.jsx)("span",{className:"text-xs",children:f(null!==(s=e.estimatedUsdApprox)&&void 0!==s?s:null)}),(0,t.jsx)("span",{className:"text-[10px] uppercase opacity-70",children:e.surgicalInvoked?"surgical LLM invoked":"no surgical"})]},e.jobId)})}),(0,t.jsxs)("div",{className:"mt-4 text-xs ".concat(F?"text-[#818384]":"text-gray-600"),children:["Async job statuses (last ~60 days min of range/job ttl):"," ",(0,t.jsx)("span",{className:"font-mono",children:M.asyncJobs.byStatus.map(e=>"".concat(e.status,":").concat(e.count)).join(", ")||"—"})]})]})]}),(0,t.jsxs)("div",{className:"glass rounded-2xl p-6 ".concat(F?"glass-dark":""),children:[(0,t.jsx)("h2",{className:"text-lg font-bold mb-4",children:"Recent usage log rows"}),(0,t.jsx)("div",{className:"overflow-auto max-h-[360px]",children:(0,t.jsxs)("table",{className:"min-w-full text-sm",children:[(0,t.jsx)("thead",{children:(0,t.jsxs)("tr",{className:"text-left opacity-75 border-b ".concat(F?"border-[#343536]":"border-gray-200"),children:[(0,t.jsx)("th",{className:"py-2 pr-4",children:"Time"}),(0,t.jsx)("th",{className:"py-2 pr-4",children:"Plan"}),(0,t.jsx)("th",{className:"py-2 pr-4",children:"Cache"}),(0,t.jsx)("th",{className:"py-2 pr-4",children:"Tier"}),(0,t.jsx)("th",{className:"py-2 pr-4",children:"Marginal USD"}),(0,t.jsx)("th",{className:"py-2 pr-4",children:"ATS"}),(0,t.jsx)("th",{className:"py-2",children:"Title"})]})}),(0,t.jsx)("tbody",{children:M.recentGenerationRows.map((e,s)=>{var a;return(0,t.jsxs)("tr",{className:"border-b ".concat(F?"border-[#272729]":"border-gray-100"),children:[(0,t.jsx)("td",{className:"py-2 pr-4 whitespace-nowrap text-xs font-mono",children:new Date(e.timestamp).toLocaleStr
1ing()}),(0,t.jsx)("td",{className:"py-2 pr-4",children:e.plan}),(0,t.jsx)("td",{className:"py-2 pr-4",children:e.fromCache?"yes":"no"}),(0,t.jsx)("td",{className:"py-2 pr-4",children:e.qualityTier||"—"}),(0,t.jsx)("td",{className:"py-2 pr-4 font-mono",children:f(e.marginalUsd)}),(0,t.jsx)("td",{className:"py-2 pr-4",children:null!==(a=e.atsScore)&&void 0!==a?a:"—"}),(0,t.jsx)("td",{className:"py-2 max-w-[200px] truncate",title:e.jobTitle,children:e.jobTitle||"—"})]},"".concat(e.timestamp,"-").concat(s))})})]})})]})]}):null]})]})]})}}},function(e){e.O(0,[4968,1296,5412,2888,9774,179],function(){return e(e.s=82068)}),_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.