veza/apps/web/dist_verification/assets/AnalyticsView-DOCH2HDI.js
senke 04c25aa24f Phase 2 stabilisation: code mort, Modal→Dialog, feature flags, tests, router split, Rust legacy
Bloc A - Code mort:
- Suppression Studio (components, views, features)
- Suppression gamification + services mock (projectService, storageService, gamificationService)
- Mise à jour Sidebar, Navbar, locales

Bloc B - Frontend:
- Suppression modal.tsx deprecated, Modal.stories (doublon Dialog)
- Feature flags: PLAYLIST_SEARCH, PLAYLIST_RECOMMENDATIONS, ROLE_MANAGEMENT = true
- Suppression 19 tests orphelins, retrait exclusions vitest.config

Bloc C - Backend:
- Extraction routes_auth.go depuis router.go

Bloc D - Rust:
- Suppression security_legacy.rs (code mort, patterns déjà dans security/)
2026-02-14 17:23:32 +01:00

1 line
14 KiB
JavaScript

import{a as l,j as e}from"./vendor-react-yWUy5XPk.js";import{g as E,l as A,u as M,c as D,B as f,C as v,S as o,i as U}from"./index-CYK_b1Uz.js";import{h as V,aa as F,r as G,F as $,U as B,T as z,G as K,at as R,au as Y,j as H,k as J,n as q}from"./vendor-icons-DJFb1Tiw.js";import{S as h}from"./StatCard-D6gRz6p3.js";import"./vendor-CveO81sn.js";import"./vendor-security-DsrNJhpn.js";import"./vendor-router-BNNHboN9.js";import"./vendor-tanstack-kPY9uK0s.js";import"./vendor-http-Cz8wfb0q.js";import"./vendor-utils-DtoSyhX2.js";import"./vendor-motion-B3XPS3Jc.js";import"./vendor-i18n-CMcqpBLz.js";import"./AnimatedNumber-e5YD_LEJ.js";const T={total_users:12500,total_tracks:3420,total_plays:1205430,total_revenue:14250.5,followers:24500,profile_views:45200,trends:{plays:8.2,revenue:12.5,followers:2.1,views:-2.4},sparklines:{plays:[40,35,50,60,55,70,80,75,90],revenue:[10,12,15,14,18,20,22,25,28],followers:[20,21,21,22,22,23,23,24,24],views:[50,48,45,42,40,43,41,40,38]}},L=[{id:"t1",title:"Neon Nights",plays:15420,change:12,revenue:145.5},{id:"t2",title:"Cyber City",plays:12100,change:-5,revenue:98.2},{id:"t3",title:"System Failure",plays:8500,change:24,revenue:65},{id:"t4",title:"Mainframe",plays:6200,change:8,revenue:42.1}],g={recordEvent:async(s,a)=>{try{await E.post("/analytics/events",{event_name:s,payload:a||{}})}catch{}},getGlobalStats:async(s="30d")=>{try{const a=await E.get("/analytics",{params:{days:s.replace("d","")}});return!a.data||Object.keys(a.data).length===0?T:{...T,...a.data}}catch(a){return A.error("[Analytics] Failed to fetch global stats",{error:a}),T}},getTopTracks:async(s="30d")=>{try{const a=await E.get("/analytics/tracks/top",{params:{days:s.replace("d","")}});return!a.data||a.data.length===0?L:a.data}catch(a){return A.error("[Analytics] Failed to fetch top tracks",{error:a}),L}},getTrafficSources:async()=>[{label:"Direct",val:45,color:"bg-primary"},{label:"Social Media",val:30,color:"bg-destructive"},{label:"Search",val:15,color:"bg-success"},{label:"Referral",val:10,color:"bg-warning"}],getDeviceBreakdown:async()=>({mobile:65,desktop:35})};function Q(s="30d"){const{addToast:a}=M(),[r,i]=l.useState(s),[t,c]=l.useState({}),[d,b]=l.useState([]),[m,j]=l.useState([]),[N,p]=l.useState({mobile:0,desktop:0}),[y,u]=l.useState(!0),[O,C]=l.useState(null),[P,I]=l.useState(null),w=l.useCallback(async()=>{u(!0),C(null);try{const[n,S,k,x]=await Promise.all([g.getGlobalStats(r),g.getTopTracks(r),g.getTrafficSources(),g.getDeviceBreakdown()]);c(n),b(S??[]),j(k??[]),p(x??{mobile:0,desktop:0})}catch(n){A.error("Error loading analytics",{error:n}),C(n instanceof Error?n:new Error(String(n)))}finally{u(!1)}},[r]);l.useEffect(()=>{w()},[w]);const _=l.useCallback(n=>{a(`Building ${n.toUpperCase()} archive...`,"info"),setTimeout(()=>{const S=new Blob([JSON.stringify(t,null,2)],{type:"application/json"}),k=URL.createObjectURL(S),x=document.createElement("a");x.href=k,x.download=`veza-analytics-${r}-${new Date().toISOString().split("T")[0]}.${n}`,x.click(),a("Data packet exported successfully","success")},1500)},[t,r,a]);return{dateRange:r,setDateRange:i,stats:t,topTracks:d,trafficSources:m,deviceStats:N,loading:y,error:O,hoveredData:P,setHoveredData:I,handleExport:_,retry:w}}const W=["7d","30d","90d","ytd"];function X({dateRange:s,onDateRangeChange:a,onExportCsv:r,onExportJson:i}){return e.jsxs("div",{className:"flex flex-col lg:flex-row justify-between items-start lg:items-end gap-6 border-b border-white/5 pb-8",children:[e.jsxs("div",{children:[e.jsxs("h1",{className:"text-4xl font-heading font-bold text-foreground mb-2 flex items-center gap-3",children:[e.jsx(V,{className:"text-primary w-8 h-8"})," NEURAL ANALYTICS"]}),e.jsx("p",{className:"text-muted-foreground font-mono text-xs tracking-wide",children:"DEEP PACKET INSPECTION • AUDIENCE METRICS"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx("div",{className:"bg-black/40 p-1 rounded-xl border border-white/10 backdrop-blur-md flex",children:W.map(t=>e.jsx("button",{type:"button",onClick:()=>a(t),className:D("px-4 py-2 rounded-lg text-xs font-bold uppercase tracking-widest transition-all",s===t?"bg-primary text-black shadow-glow-cyan":"text-muted-foreground hover:text-foreground"),children:t},t))}),e.jsxs("div",{className:"flex gap-2",children:[e.jsxs(f,{variant:"outline",size:"sm",onClick:r,className:"border-white/10 hover:border-primary/50",children:[e.jsx(F,{className:"w-4 h-4 mr-2"})," CSV"]}),e.jsx(f,{variant:"primary",size:"sm",onClick:i,className:"shadow-glow-cyan",children:"REPORT"})]})]})]})}function Z({stats:s}){return e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[e.jsx(h,{label:"Network Plays",value:s.total_plays?.toLocaleString()??"—",icon:e.jsx(G,{className:"w-4 h-4"}),trend:s.trends?.plays,color:"cyan",sparklineData:s.sparklines?.plays}),e.jsx(h,{label:"Gross Revenue",value:s.total_revenue!=null?`$${s.total_revenue.toLocaleString()}`:"—",icon:e.jsx($,{className:"w-4 h-4"}),trend:s.trends?.revenue,color:"gold",sparklineData:s.sparklines?.revenue}),e.jsx(h,{label:"Active Nodes",value:s.followers?.toLocaleString()??"—",icon:e.jsx(B,{className:"w-4 h-4"}),trend:s.trends?.followers,color:"magenta",sparklineData:s.sparklines?.followers}),e.jsx(h,{label:"Profile Pulse",value:s.profile_views?.toLocaleString()??"—",icon:e.jsx(z,{className:"w-4 h-4"}),trend:s.trends?.views,color:"red",sparklineData:s.sparklines?.views})]})}function ee({dateRange:s,hoveredData:a,onHover:r}){return e.jsxs(v,{variant:"glass",className:"lg:col-span-2 p-8 bg-black/40 border-white/5 relative overflow-hidden group",children:[e.jsxs("div",{className:"flex justify-between items-center mb-8 relative z-10",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold text-foreground mb-1",children:"Performance Dynamics"}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:"SCALAR TEMPORAL RESOLUTION"})]}),e.jsxs("div",{className:"flex gap-6 text-xs font-mono uppercase tracking-widest",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-primary"})," Plays"]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-2 h-2 rounded-full bg-gold-500"})," Revenue"]})]})]}),e.jsxs("div",{className:"h-64 relative flex items-end",children:[e.jsx("div",{className:"absolute inset-0 grid grid-rows-4 w-full h-full pointer-events-none opacity-20",children:[...Array(5)].map((i,t)=>e.jsx("div",{className:"border-b border-white/10 w-full"},t))}),e.jsx("div",{className:"flex-1 flex items-end gap-1 h-full z-10 px-2",children:Array.from({length:30}).map((i,t)=>{const c=Math.random()*60+20,d=Math.random()*40+10;return e.jsxs("div",{className:"flex-1 group/bar relative h-full flex flex-col justify-end gap-0.5 cursor-pointer",onMouseEnter:()=>r({index:t,val1:c,val2:d}),onMouseLeave:()=>r(null),children:[e.jsx("div",{className:"w-full bg-gold-500/20 group-hover/bar:bg-gold-500/60 rounded-t-sm transition-all",style:{height:`${d}%`}}),e.jsx("div",{className:"w-full bg-primary/20 group-hover/bar:bg-primary/60 rounded-t-sm transition-all shadow-glow-cyan",style:{height:`${c}%`}}),a?.index===t&&e.jsxs("div",{className:"absolute bottom-full left-1/2 -translate-x-1/2 mb-4 bg-black/90 border border-white/20 p-2 rounded text-xs font-mono whitespace-nowrap z-50 animate-fadeIn backdrop-blur-xl",children:[e.jsxs("div",{className:"text-primary",children:["PLAYS: ",Math.floor(c*1230)]}),e.jsxs("div",{className:"text-gold-500",children:["REV: $",(d*42).toFixed(2)]})]})]},t)})})]}),e.jsxs("div",{className:"flex justify-between text-xs font-mono text-muted-foreground mt-4 px-2 uppercase tracking-tighter",children:[e.jsxs("span",{children:[s," AGO"]}),e.jsx("span",{children:"REALTIME FEED"}),e.jsx("span",{children:"PRESENT"})]})]})}function se({sources:s}){return e.jsxs(v,{variant:"glass",className:"p-6 bg-black/40 border-white/5",children:[e.jsxs("h3",{className:"font-bold text-foreground mb-6 text-sm uppercase tracking-widest flex items-center gap-2",children:[e.jsx(K,{className:"w-4 h-4 text-destructive"})," Origins"]}),e.jsx("div",{className:"space-y-5",children:s.map(a=>e.jsxs("div",{className:"group cursor-default",children:[e.jsxs("div",{className:"flex justify-between text-xs mb-2",children:[e.jsx("span",{className:"text-muted-foreground group-hover:text-foreground transition-colors uppercase font-mono",children:a.label}),e.jsxs("span",{className:"text-foreground font-bold",children:[a.val,"%"]})]}),e.jsx("div",{className:"h-1.5 bg-white/5 rounded-full overflow-hidden",children:e.jsx("div",{className:D("h-full transition-all duration-1000",a.color),style:{width:`${a.val}%`}})})]},a.label))})]})}function ae({deviceStats:s}){return e.jsxs(v,{variant:"glass",className:"p-6 bg-black/40 border-white/5",children:[e.jsxs("h3",{className:"font-bold text-foreground mb-6 text-sm uppercase tracking-widest flex items-center gap-2",children:[e.jsx(R,{className:"w-4 h-4 text-primary"})," Platforms"]}),e.jsxs("div",{className:"flex items-center justify-between gap-8 px-4",children:[e.jsxs("div",{className:"text-center group flex-1",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-white/5 flex items-center justify-center mx-auto mb-3 group-hover:bg-primary/10 transition-all border border-transparent group-hover:border-primary/20",children:e.jsx(R,{className:"w-6 h-6 text-muted-foreground group-hover:text-primary transition-colors"})}),e.jsxs("div",{className:"text-2xl font-bold text-foreground",children:[s.mobile,"%"]}),e.jsx("div",{className:"text-xs text-muted-foreground uppercase font-mono mt-1",children:"MOBILE"})]}),e.jsx("div",{className:"w-px h-12 bg-white/10"}),e.jsxs("div",{className:"text-center group flex-1",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-white/5 flex items-center justify-center mx-auto mb-3 group-hover:bg-destructive/10 transition-all border border-transparent group-hover:border-destructive/20",children:e.jsx(Y,{className:"w-6 h-6 text-muted-foreground group-hover:text-destructive transition-colors"})}),e.jsxs("div",{className:"text-2xl font-bold text-foreground",children:[s.desktop,"%"]}),e.jsx("div",{className:"text-xs text-muted-foreground uppercase font-mono mt-1",children:"NODE"})]})]})]})}function re({tracks:s,onNavigateTrack:a}){return e.jsxs(v,{variant:"glass",className:"bg-black/40 border-white/5 overflow-hidden p-0 relative group",children:[e.jsx("div",{className:"absolute inset-x-0 bottom-0 h-px bg-gradient-to-r from-transparent via-primary/40 to-transparent group-hover:via-primary transition-all opacity-50"}),e.jsxs("div",{className:"flex justify-between items-center p-6 border-b border-white/5 bg-white/2",children:[e.jsxs("div",{children:[e.jsx("h3",{className:"text-xl font-bold text-foreground",children:"Top Frequency Nodes"}),e.jsx("p",{className:"text-xs text-muted-foreground font-mono",children:"SORTED BY PEAK VOLTAGE"})]}),e.jsx(f,{variant:"ghost",size:"sm",className:"hover:bg-white/5",children:"FULL FEED"})]}),e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full text-left",children:[e.jsx("thead",{children:e.jsxs("tr",{className:"text-xs text-muted-foreground uppercase tracking-wider border-b border-white/5 bg-black/20",children:[e.jsx("th",{className:"py-4 pl-8",children:"SIGNAL IDENTITY"}),e.jsx("th",{className:"py-4",children:"PLAYS"}),e.jsx("th",{className:"py-4",children:"DELTA"}),e.jsx("th",{className:"py-4",children:"REVENUE"}),e.jsx("th",{className:"py-4 text-right pr-8",children:"PROTOCOL"})]})}),e.jsx("tbody",{className:"text-sm divide-y divide-white/5",children:s.map(r=>e.jsxs("tr",{className:"hover:bg-white/5 transition-all group",children:[e.jsxs("td",{className:"py-5 pl-8",children:[e.jsx("div",{className:"font-bold text-foreground group-hover:text-primary transition-colors",children:r.title}),e.jsxs("div",{className:"text-xs text-muted-foreground font-mono",children:["TRACK_ID: ",r.id.toUpperCase()]})]}),e.jsx("td",{className:"py-5 text-foreground font-mono",children:r.plays.toLocaleString()}),e.jsx("td",{className:"py-5",children:e.jsxs("span",{className:D("inline-flex items-center gap-1.5 px-2 py-0.5 rounded text-xs font-bold uppercase tracking-wider border",r.change>=0?"text-success border-success/20 bg-success/10":"text-destructive border-destructive/20 bg-destructive/10"),children:[r.change>=0?e.jsx(H,{className:"w-3 h-3"}):e.jsx(J,{className:"w-3 h-3"}),Math.abs(r.change),"%"]})}),e.jsxs("td",{className:"py-5 font-bold text-gold-500",children:["$",r.revenue.toFixed(2)]}),e.jsx("td",{className:"py-5 text-right pr-8",children:e.jsxs(f,{variant:"outline",size:"sm",onClick:()=>a(r.id),className:"bg-black/40 border-white/10 hover:border-primary/50 group-hover:shadow-glow-cyan transition-all",children:["INSPECT ",e.jsx(q,{className:"w-4 h-4 ml-1"})]})})]},r.id))})]})})]})}function te(){return e.jsxs("div",{className:"space-y-8 pb-24 container py-8 animate-fadeIn",children:[e.jsxs("div",{className:"flex flex-col lg:flex-row justify-between items-start lg:items-end gap-6 border-b border-white/5 pb-8",children:[e.jsxs("div",{children:[e.jsx(o,{className:"h-10 w-64 mb-2"}),e.jsx(o,{className:"h-4 w-80"})]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(o,{className:"h-10 w-48 rounded-xl"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(o,{className:"h-9 w-20"}),e.jsx(o,{className:"h-9 w-20"})]})]})]}),e.jsx("div",{className:"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6",children:[1,2,3,4].map(s=>e.jsx(o,{className:"h-28 w-full rounded-xl"},s))}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsx(o,{className:"lg:col-span-2 h-80 rounded-xl"}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(o,{className:"h-56 rounded-xl"}),e.jsx(o,{className:"h-44 rounded-xl"})]})]}),e.jsx(o,{className:"h-96 w-full rounded-xl"})]})}function ve({onNavigateTrack:s}){const{dateRange:a,setDateRange:r,stats:i,topTracks:t,trafficSources:c,deviceStats:d,loading:b,error:m,hoveredData:j,setHoveredData:N,handleExport:p,retry:y}=Q("30d");return b?e.jsx(te,{}):m?e.jsx("div",{className:"container py-8 min-h-layout-page",children:e.jsx(U,{error:m,onRetry:y,title:"Failed to load analytics",context:{action:"loading",resource:"analytics"},variant:"card"})}):e.jsxs("div",{className:"space-y-8 pb-24 animate-fadeIn container py-8 min-h-layout-page",children:[e.jsx(X,{dateRange:a,onDateRangeChange:u=>r(u),onExportCsv:()=>p("csv"),onExportJson:()=>p("json")}),e.jsx(Z,{stats:i}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-8",children:[e.jsx(ee,{dateRange:a,hoveredData:j,onHover:N}),e.jsxs("div",{className:"space-y-6",children:[e.jsx(se,{sources:c}),e.jsx(ae,{deviceStats:d})]})]}),e.jsx(re,{tracks:t,onNavigateTrack:s})]})}export{ve as AnalyticsView};