PageSourceSearch

https://melodygenie.app/assets/GenieAdminTab-YoEpIYZb.js

js melodygenie.app collected 2026-10-04 16:29:30 UTC 8,784 bytes, 1 lines download raw bytes

1import{g as x,Q as $,j as e,Z as S}from"./index-CEq6EAUz.js";const o=(l,c=2)=>l==null||!Number.isFinite(Number(l))?"—":`$${Number(l).toLocaleString("en-US",{minimumFractionDigits:c,maximumFractionDigits:c})}`,n=l=>l==null?"—":Number(l).toLocaleString("en-US");function m({label:l,value:c,sub:s,cls:h=""}){return e.jsxs("div",{className:"rounded-2xl border border-black/[0.07] bg-white p-4",children:[e.jsx("p",{className:"font-mono text-[10px] font-semibold uppercase tracking-[0.14em] text-black/40",children:l}),e.jsx("p",{className:`mt-1 text-[24px] font-bold tracking-tight ${h}`,children:c}),s&&e.jsx("p",{className:"mt-0.5 text-[11px] text-black/45",children:s})]})}function p({title:l,hint:c,children:s}){return e.jsxs("section",{className:"rounded-2xl border border-black/[0.07] bg-white p-5",children:[e.jsx("h3",{className:"text-[14px] font-bold",children:l}),c&&e.jsx("p",{className:"mt-0.5 text-[11.5px] leading-5 text-black/50",children:c}),e.jsx("div",{className:"mt-3",children:s})]})}const A=[["opened","Opened Genie"],["wish_granted","Granted the wish of the day"],["photo_attached","Used a photo"],["hum_recorded","Hummed a melody"],["voice_input","Talked (mic)"],["make_song",'Pressed "Make my song"'],["stems","Split stems"],["credit_gate","Hit the credit gate"],["upsell_click","Clicked plans / packs"],["go","Sent to another tool"]];function T(){var f;const[l,c]=x.useState(14),[s,h]=x.useState(null),[b,j]=x.useState(""),[w,g]=x.useState(!1),u=x.useCallback(async()=>{g(!0),j("");try{const t=await $(),a=await fetch(`/api/admin/genie-summary?days=${l}`,{headers:t?{Authorization:`Bearer ${t}`}:{}}),d=await a.json().catch(()=>({}));if(!a.ok)throw new Error(d.error||`HTTP ${a.status}`);h(d)}catch(t){j(t.message)}finally{g(!1)}},[l]);x.useEffect(()=>{u()},[u]);const r=(s==null?void 0:s.totals)||{},i=(f=s==null?void 0:s.daily)==null?void 0:f[s.daily.length-1],N=Math.max(1,...((s==null?void 0:s.daily)||[]).map(t=>t.messages+t.blocked));return e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-[20px] font-bold tracking-tight",children:"Genie chat"}),e.jsxs("p",{className:"text-[12px] text-black/50",children:["Provider: ",e.jsx("b",{children:(s==null?void 0:s.provider)||"—"})," · daily brake ",o(s==null?void 0:s.budget_usd)," · buttons are free, only typed/spoken turns cost."]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[[7,14,30].map(t=>e.jsxs("button",{type:"button",onClick:()=>c(t),className:`rounded-full px-3 py-1.5 text-[12px] font-bold ${l===t?"bg-black text-white":"bg-black/[0.05] text-black/60"}`,children:[t,"d"]},t)),e.jsx("button",{type:"button",onClick:u,className:"grid h-8 w-8 place-items-center rounded-full bg-black/[0.05]",title:"Refresh",children:e.jsx(S,{className:`h-4 w-4 ${w?"animate-spin":""}`})})]})]}),b&&e.jsx("p",{className:"rounded-xl bg-rose-50 p-3 text-[12.5px] text-rose-700",children:b}),((s==null?void 0:s.warnings)||[]).length>0&&e.jsxs("p",{className:"rounded-xl bg-amber-50 p-3 text-[12px] text-amber-800",children:["Some data is missing (run the Genie migrations?): ",s.warnings.join(" · ")]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3 lg:grid-cols-4",children:[e.jsx(m,{label:`Real cost · ${l}d`,value:o(r.real_cost_usd,4),sub:`${n(r.turns)} AI turns · ${o(r.cost_per_turn_usd,5)} each`}),e.jsx(m,{label:"Today vs brake",value:o(i==null?void 0:i.real_cost_usd,4),sub:`${n(i==null?void 0:i.messages)} turns · brake ${o(s==null?void 0:s.budget_usd)}`,cls:i&&s&&i.est_cost_usd>=s.budget_usd*.8?"text-rose-600":"text-emerald-700"}),e.jsx(m,{label:"Opened → song",value:r.open_to_song_pct==null?"—":`${r.open_to_song_pct}%`,sub:`${n(r.song_users)} of ${n(r.opened_users)} people`}),e.jsx(m,{label:"Abuse stopped",value:n((r.blocked||0)+(r.off_topic_turns||0)),sub:`${n(r.blocked)} blocked free · ${n(r.off_topic_turns)} off-topic · ${n(r.burst)} too fast · ${n(r.limited)} at cap`})]}),e.jsx(p,{title:"Per day",hint:"Bars: AI turns (green) and turns refused before the model (red). Cost is the real ledger figure.",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full min-w-[640px] text-[12.5px]",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-left text-[10.5px] uppercase tracking-wide text-black/40",children:[e.jsx("th",{className:"py-1.5 pr-3",children:"Day"}),e.jsx("th",{className:"pr-3",children:"Turns"}),e.jsx("th",{className:"w-[30%] pr-3"}),e.jsx("th",{className:"pr-3",children:"Real $"}),e.jsx("th",{className:"pr-3",children:"Blocked"}),e.jsx("th",{className:"pr-3",children:"At cap"}),e.jsx("th",{className:"pr-3",children:"Burst"}),e.jsx("th",{className:"pr-3",children:"Brake"}),e.jsx("th",{children:"Errors"})]})}),e.jsx("tbody",{children:((s==null?void 0:s.daily)||[]).slice().reverse().map(t=>e.jsxs("tr",{className:"border-t border-black/[0.05] tabular-nums",children:[e.jsx("td",{className:"py-1.5 pr-3 font-mono text-[11.5px]",children:t.day.slice(5)}),e.jsx("td",{className:"pr-3",children:t.messages}),e.jsx("td",{className:"pr-3",children:e.jsxs("div",{className:"flex h-2 overflow-hidden rounded-full bg-black/[0.04]",children:[e.jsx("span",{className:"bg-emerald-500",style:{width:`${t.messages/N*100}%`}}),e.jsx("span",{className:"bg-rose-400",style:{width:`${t.blocked/N*100}%`}})]})}),e.jsx("td",{className:"pr-3",children:o(t.real_cost_usd,4)}),e.jsx("td",{className:`pr-3 ${t.blocked?"text-rose-600":"text-black/35"}`,children:t.blocked}),e.jsx("td",{className:`pr-3 ${t.limited?"text-amber-600":"text-black/35"}`,children:t.limited}),e.jsx("td",{className:`pr-3 ${t.burst?"text-amber-600":"text-black/35"}`,children:t.burst}),e.jsx("td",{className:`pr-3 ${t.braked?"font-bold text-rose-600":"text-black/35"}`,children:t.braked}),e.jsx("td",{className:t.errors?"text-rose-600":"text-black/35",children:t.errors})]},t.day))})]})})}),e.jsxs("div",{className:"grid gap-4 lg:grid-cols-2",children:[e.jsx(p,{title:"Funnel",hint:"Unique people per step in the window (from funnel_events).",children:A.map(([t,a])=>{var k,y,_;const d=((k=s==null?void 0:s.funnel)==null?void 0:k[t])||{users:0,events:0}
1,v=Math.max(1,((_=(y=s==null?void 0:s.funnel)==null?void 0:y.opened)==null?void 0:_.users)||0);return e.jsxs("div",{className:"flex items-center gap-3 border-t border-black/[0.05] py-1.5 text-[12.5px]",children:[e.jsx("span",{className:"w-[46%] shrink-0",children:a}),e.jsx("div",{className:"h-2 flex-1 overflow-hidden rounded-full bg-black/[0.04]",children:e.jsx("span",{className:"block h-full bg-emerald-500",style:{width:`${Math.min(100,d.users/v*100)}%`}})}),e.jsxs("span",{className:"w-16 text-right tabular-nums",children:[d.users," ",e.jsxs("span",{className:"text-black/35",children:["(",d.events,")"]})]})]},t)})}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs(p,{title:"Cost by plan",children:[Object.keys((s==null?void 0:s.by_plan)||{}).length===0&&e.jsx("p",{className:"text-[12px] text-black/40",children:"No AI turns yet."}),Object.entries((s==null?void 0:s.by_plan)||{}).map(([t,a])=>e.jsxs("div",{className:"flex justify-between border-t border-black/[0.05] py-1.5 text-[12.5px] tabular-nums",children:[e.jsx("span",{className:"capitalize",children:t}),e.jsxs("span",{children:[n(a.turns)," turns · ",o(a.cost,4)]})]},t)),e.jsxs("p",{className:"mt-2 text-[11px] text-black/40",children:[n(r.input_tokens)," tokens in · ",n(r.output_tokens),' out. Also counted in Finance → margin (source "genie").']})]}),e.jsxs(p,{title:"Where Genie sent people",children:[Object.keys((s==null?void 0:s.go_targets)||{}).length===0&&e.jsx("p",{className:"text-[12px] text-black/40",children:"Nothing yet."}),Object.entries((s==null?void 0:s.go_targets)||{}).sort((t,a)=>a[1]-t[1]).map(([t,a])=>e.jsxs("div",{className:"flex justify-between border-t border-black/[0.05] py-1.5 text-[12.5px]",children:[e.jsx("span",{className:"font-mono text-[11.5px]",children:t}),e.jsx("span",{className:"tabular-nums",children:a})]},t))]})]})]}),e.jsxs(p,{title:"Top users by AI turns",hint:"Watch for one account using the whole cap every day — that is either a fan or someone probing.",children:[((s==null?void 0:s.top_users)||[]).length===0&&e.jsx("p",{className:"text-[12px] text-black/40",children:"Nobody yet."}),((s==null?void 0:s.top_users)||[]).map(t=>e.jsxs("div",{className:"flex justify-between border-t border-black/[0.05] py-1.5 text-[12.5px]",children:[e.jsxs("span",{className:"truncate",children:[t.email||t.user_id," ",e.jsx("span",{className:"ml-1 rounded-full bg-black/[0.05] px-2 py-0.5 text-[10.5px] capitalize",children:t.plan})]}),e.jsx("span",{className:"tabular-nums",children:t.messages})]},t.user_id))]})]})}export{T 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.