PageSourceSearch

https://luxuryleasing.de/assets/TrafficAnalytics-CjU9lLMt.js

js luxuryleasing.de collected 2026-10-08 07:13:02 UTC 13,331 bytes, 1 lines download raw bytes

1import{u as H,j as e}from"./query-vendor-DVmmQ-ki.js";import{r as Q,L as W}from"./react-vendor-BURXZ51T.js";import{B as Y}from"./index-DpP3iEYK.js";import{C as u,b as g,c as j,a as x}from"./card-DwBoygcx.js";import{T as X,a as Z,b as J}from"./tabs-CH4KCsyR.js";import{S as h}from"./skeleton-CbBeDtzP.js";import{T as ee,a as se,b as R,c as N,d as te,e as b}from"./table-DGTNs8pb.js";import{supabase as re}from"./client-BXzYhP5O.js";import{s as L,n as A,m as ae,f as ne}from"./date-vendor-sl2uXp01.js";import{d as ce}from"./de-C5AT29KS.js";import{A as ie}from"./arrow-left-DrlG9OEE.js";import{E as le}from"./eye-BOQecZvW.js";import{C as oe}from"./calendar-days-Cak9fuuD.js";import{T as K}from"./trending-up-B_zRYNKG.js";import{F as de}from"./file-text-UJur6P3r.js";import{R as I,X as me,Y as ue,T as V,C as xe}from"./generateCategoricalChart-DjK0Wxmp.js";import{L as he,a as fe}from"./LineChart-CO_OQAwG.js";import{M as S,T as pe}from"./tablet-BMisIMWA.js";import{P as ge,a as je}from"./PieChart-CxoEKRUb.js";import{G as ye}from"./globe-cUt2UJxp.js";import{M as we}from"./megaphone-Jr7rAmxU.js";import{S as Ne}from"./smartphone-CyfinlCz.js";import"./radix-slot-BTvEbTmE.js";import"./ui-radix-LBOF5AHa.js";import"./supabase-DxfZiqN5.js";function B(s){return s==="7d"?7:s==="30d"?30:90}function be(s){const c=s.custom_data;if(c&&typeof c=="object"&&"page_path"in c)return c.page_path||"/";if(s.event_source_url)try{return new URL(s.event_source_url).pathname}catch{return"/"}return"/"}function ve(s){const c=s.custom_data;return c&&typeof c=="object"&&"page_title"in c&&c.page_title||""}function _e(s){return s?s.includes("Edg/")?"Edge":s.includes("OPR/")||s.includes("Opera")?"Opera":s.includes("Chrome/")&&!s.includes("Edg/")?"Chrome":s.includes("Safari/")&&!s.includes("Chrome")?"Safari":s.includes("Firefox/")?"Firefox":s.includes("MSIE")||s.includes("Trident")?"IE":"Sonstiges":"Unbekannt"}function Te(s){if(!s)return"Direkt";try{const c=new URL(s).hostname.replace("www.","");return c.includes("google")?"Google":c.includes("facebook")||c.includes("fb.com")?"Facebook":c.includes("instagram")?"Instagram":c.includes("tiktok")?"TikTok":c.includes("linkedin")?"LinkedIn":c.includes("youtube")?"YouTube":c.includes("bing")?"Bing":c}catch{return"Direkt"}}function ke(s,c){const t=new Date,l=B(c),a=L(t,l),i=A(t),m=s.filter(r=>new Date(r.created_at)>=i).length,f=Math.round(s.length/l*10)/10,$=ae({start:a,end:t}).map(r=>{const n=A(r),o=new Date(n.getTime()+24*60*60*1e3),d=s.filter(p=>{const y=new Date(p.created_at);return y>=n&&y<o}).length;return{day:ne(r,"dd.MM",{locale:ce}),count:d}}),w=new Map;s.forEach(r=>{const n=be(r),o=ve(r),d=w.get(n);d?(d.count++,!d.title&&o&&(d.title=o)):w.set(n,{title:o,count:1})});const O=w.size,U=Array.from(w.entries()).map(([r,{title:n,count:o}])=>({path:r,title:n,count:o})).sort((r,n)=>n.count-r.count).slice(0,10),k=new Map;s.forEach(r=>{var o;const n=r.device_type||((o=r.custom_data)==null?void 0:o.device_type)||"Unbekannt";k.set(n,(k.get(n)||0)+1)});const F=Array.from(k.entries()).map(([r,n])=>({type:r==="mobile"?"Mobile":r==="tablet"?"Tablet":r==="desktop"?"Desktop":r,count:n,percent:s.length?Math.round(n/s.length*1e3)/10:0})).sort((r,n)=>n.count-r.count),C=new Map;s.forEach(r=>{const n=Te(r.referrer||"");C.set(n,(C.get(n)||0)+1)});const q=Array.from(C.entries()).map(([r,n])=>({source:r,count:n})).sort((r,n)=>n.count-r.count).slice(0,10),M=new Map;s.forEach(r=>{var y,P,E;const n=r.utm_source||((y=r.custom_data)==null?void 0:y.utm_source);if(!n)return;const o=r.utm_medium||((P=r.custom_data)==null?void 0:P.utm_medium)||"",d=r.utm_campaign||((E=r.custom_data)==null?void 0:E.utm_campaign)||"",p=`${n}||${o}||${d}`;M.set(p,(M.get(p)||0)+1)});const G=Array.from(M.entries()).map(([r,n])=>{const[o,d,p]=r.split("||");return{source:o,medium:d,campaign:p,count:n}}).sort((r,n)=>n.count-r.count).slice(0,15),D=new Map;s.forEach(r=>{const n=_e(r.user_agent||"");D.set(n,(D.get(n)||0)+1)});const z=Array.from(D.entries()).map(([r,n])=>({browser:r,count:n,percent:s.length?Math.round(n/s.length*1e3)/10:0})).sort((r,n)=>n.count-r.count);return{totalPageViews:s.length,pageViewsToday:m,avgPerDay:f,uniquePages:O,pageViewsByDay:$,topPages:U,devices:F,referrers:q,utmCampaigns:G,browsers:z}}function Ce(s){return H({queryKey:["traffic-analytics",s],queryFn:async()=>{const c=L(new Date,B(s)),{data:t,error:l}=await re.from("tracking_events").select("event_source_url, custom_data, created_at, referrer, user_agent, device_type, screen_width, utm_source, utm_medium, utm_campaign").eq("event_name","PageView").gte("created_at",c.toISOString()).order("created_at",{ascending:!1});if(l)throw l;const a=(t||[]).map(i=>({event_source_url:i.event_source_url,custom_data:typeof i.custom_data=="object"?i.custom_data:null,created_at:i.created_at,referrer:i.referrer,user_agent:i.user_agent,device_type:i.device_type,screen_width:i.screen_width,utm_source:i.utm_source,utm_medium:i.utm_medium,utm_campaign:i.utm_campaign}));return ke(a,s)}})}const Me=[{value:"7d",label:"7 Tage"},{value:"30d",label:"30 Tage"},{value:"90d",label:"90 Tage"}],v=["hsl(var(--primary))","hsl(var(--accent))","hsl(var(--muted-foreground))"],De={Mobile:Ne,Tablet:pe,Desktop:S};function ts(){const[s,c]=Q.useState("30d"),{data:t,isLoading:l}=Ce(s);return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx(W,{to:"/admin/analytics",children:e.jsxs(Y,{variant:"ghost",size:"sm",className:"mb-4 -ml-2",children:[e.jsx(ie,{className:"h-4 w-4 mr-2"}),"Zurück zu Analytics"]})}),e.jsxs("div",{className:"flex items-center justify-between flex-wrap gap-4",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-3xl font-bold text-foreground mb-2",children:"Traffic"}),e.jsx("p",{className:"text-muted-foreground",children:"Website-Besucher, Geräte, Quellen und Kampagnen."})]}),e.jsx(X,{value:s,onValueChange:a=>c(a),children:e.jsx(Z,{children:Me.map(a=>e.jsx(J,{value:a.value,children:a.label},a.value))})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-4",children:[e.jsx(_,{icon:le,label:"Gesamt-Aufrufe",value:t==null?void 0:t.totalPageViews,loading:l}),e.jsx(_,{icon:oe,label:"Heute",value:t==null?void 0:t.pageViewsToday,loading:l}),e.jsx(_,{icon:K,label:"Ø pro Tag",value:t==null?void 0:t.avgPerDay,loading:l}),e.jsx(_,{icon:de,label:"Unique Seiten",value:t==null?void 0:t.uniquePages,loading:l})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(u,{className:"lg:col-span-2",children:[e.jsx(g,{children:e.jsxs(j,{className:"text-base flex items-center gap-2",children:[e.jsx(K,{className:"h-4 w-4"}),"PageViews pro Tag"]})}),e.jsx(x,{children:l?e.jsx(h,{className:"h-[250px] w-full"}):e.jsx(I,{width:"100%",height:250,children:e.jsxs(he,{data:(t==null?void 0:t.pageViewsByDay)||[],children:[e.jsx(me,{dataKey:"day",tick:{fontSize:11}
1,stroke:"hsl(var(--muted-foreground))",interval:"preserveStartEnd"}),e.jsx(ue,{allowDecimals:!1,tick:{fontSize:12},stroke:"hsl(var(--muted-foreground))"}),e.jsx(V,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px",color:"hsl(var(--foreground))"}}),e.jsx(fe,{type:"monotone",dataKey:"count",name:"PageViews",stroke:"hsl(var(--primary))",strokeWidth:2,dot:!1})]})})})]}),e.jsxs(u,{children:[e.jsx(g,{children:e.jsxs(j,{className:"text-base flex items-center gap-2",children:[e.jsx(S,{className:"h-4 w-4"}),"Geräte"]})}),e.jsx(x,{children:l?e.jsx(h,{className:"h-[250px] w-full"}):t!=null&&t.devices.length?e.jsxs("div",{className:"flex flex-col items-center gap-4",children:[e.jsx(I,{width:"100%",height:140,children:e.jsxs(ge,{children:[e.jsx(je,{data:t.devices,dataKey:"count",nameKey:"type",cx:"50%",cy:"50%",innerRadius:35,outerRadius:60,strokeWidth:2,children:t.devices.map((a,i)=>e.jsx(xe,{fill:v[i%v.length]},i))}),e.jsx(V,{contentStyle:{backgroundColor:"hsl(var(--card))",border:"1px solid hsl(var(--border))",borderRadius:"8px",color:"hsl(var(--foreground))"}})]})}),e.jsx("div",{className:"w-full space-y-2",children:t.devices.map((a,i)=>{const m=De[a.type]||S;return e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:"w-3 h-3 rounded-full",style:{backgroundColor:v[i%v.length]}}),e.jsx(m,{className:"h-3.5 w-3.5 text-muted-foreground"}),e.jsx("span",{className:"text-foreground",children:a.type})]}),e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a.percent,"%"]})]},a.type)})})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-12",children:"Keine Daten"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(u,{children:[e.jsx(g,{children:e.jsxs(j,{className:"text-base flex items-center gap-2",children:[e.jsx(ye,{className:"h-4 w-4"}),"Traffic-Quellen"]})}),e.jsx(x,{children:l?e.jsx(h,{className:"h-[200px] w-full"}):t!=null&&t.referrers.length?e.jsx("div",{className:"space-y-3",children:t.referrers.map((a,i)=>{var T;const m=((T=t.referrers[0])==null?void 0:T.count)||1,f=Math.max(a.count/m*100,4);return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsxs("span",{className:"text-xs font-bold text-muted-foreground w-5",children:[i+1,"."]}),e.jsx("span",{className:"text-foreground",children:a.source})]}),e.jsx("span",{className:"text-muted-foreground font-medium",children:a.count})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-primary/60 transition-all",style:{width:`${f}%`}})})]},a.source)})}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-12",children:"Keine Daten"})})]}),e.jsxs(u,{children:[e.jsx(g,{children:e.jsx(j,{className:"text-base",children:"Top 10 Seiten"})}),e.jsx(x,{children:l?e.jsx(h,{className:"h-[200px] w-full"}):t!=null&&t.topPages.length?e.jsx("div",{className:"space-y-2",children:t.topPages.map((a,i)=>e.jsxs("div",{className:"flex items-center justify-between gap-2",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsxs("span",{className:"text-xs font-bold text-muted-foreground w-5 shrink-0",children:[i+1,"."]}),e.jsx("span",{className:"text-sm text-foreground truncate",title:a.path,children:a.title||Se(a.path)})]}),e.jsx("span",{className:"text-sm font-medium text-muted-foreground shrink-0",children:a.count})]},a.path))}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-12",children:"Keine Daten"})})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(u,{children:[e.jsx(g,{children:e.jsxs(j,{className:"text-base flex items-center gap-2",children:[e.jsx(we,{className:"h-4 w-4"}),"UTM-Kampagnen"]})}),e.jsx(x,{children:l?e.jsx(h,{className:"h-[200px] w-full"}):t!=null&&t.utmCampaigns.length?e.jsxs(ee,{children:[e.jsx(se,{children:e.jsxs(R,{children:[e.jsx(N,{className:"text-xs",children:"Source"}),e.jsx(N,{className:"text-xs",children:"Medium"}),e.jsx(N,{className:"text-xs",children:"Kampagne"}),e.jsx(N,{className:"text-xs text-right",children:"Views"})]})}),e.jsx(te,{children:t.utmCampaigns.map(a=>e.jsxs(R,{children:[e.jsx(b,{className:"text-sm",children:a.source}),e.jsx(b,{className:"text-sm text-muted-foreground",children:a.medium||"–"}),e.jsx(b,{className:"text-sm text-muted-foreground truncate max-w-[150px]",children:a.campaign||"–"}),e.jsx(b,{className:"text-sm font-medium text-right",children:a.count})]},`${a.source}-${a.medium}-${a.campaign}`))})]}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-8",children:"Keine UTM-Daten vorhanden"})})]}),e.jsxs(u,{children:[e.jsx(g,{children:e.jsx(j,{className:"text-base",children:"Browser"})}),e.jsx(x,{children:l?e.jsx(h,{className:"h-[200px] w-full"}):t!=null&&t.browsers.length?e.jsx("div",{className:"space-y-3",children:t.browsers.map(a=>{var f;const i=((f=t.browsers[0])==null?void 0:f.percent)||1,m=Math.max(a.percent/i*100,4);return e.jsxs("div",{className:"space-y-1",children:[e.jsxs("div",{className:"flex items-center justify-between text-sm",children:[e.jsx("span",{className:"text-foreground",children:a.browser}),e.jsxs("span",{className:"text-muted-foreground font-medium",children:[a.percent,"% (",a.count,")"]})]}),e.jsx("div",{className:"h-1.5 rounded-full bg-muted overflow-hidden",children:e.jsx("div",{className:"h-full rounded-full bg-primary/40 transition-all",style:{width:`${m}%`}})})]},a.browser)}
1)}):e.jsx("p",{className:"text-sm text-muted-foreground text-center py-12",children:"Keine Daten"})})]})]})]})}function Se(s){if(s==="/")return"Startseite";const c=s.split("/").filter(Boolean);return c.length<=2?s:`/${c[0]}/…/${c[c.length-1]}`}function _({icon:s,label:c,value:t,loading:l}){return e.jsx(u,{children:e.jsxs(x,{className:"flex items-center gap-4 pt-6",children:[e.jsx("div",{className:"p-2 rounded-lg bg-primary/10",children:e.jsx(s,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm text-muted-foreground",children:c}),l?e.jsx(h,{className:"h-7 w-12 mt-1"}):e.jsx("p",{className:"text-2xl font-bold text-foreground",children:t??0})]})]})})}export{ts 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.