PageSourceSearch

https://speltips.ai/_nuxt/kVQ5avAZ.js

js speltips.ai collected 2026-10-05 14:28:00 UTC 13,781 bytes, 1 lines download raw bytes

1import{_ as f,c as a,a as t,A as w,B as C,z as k,t as o,e as c,F as g,r as v,H as _,f as b,ah as E,m as S,j as L,o as n,d as m}from"./BwjkGPNs.js";const T={name:"AdminAiAssistantStats",setup(){L({meta:[{name:"robots",content:"noindex, nofollow"}]})},data(){return{password:"",authenticated:!1,loading:!1,error:"",period:"30d",customDate:"",periods:[{value:"today",label:"Today"},{value:"yesterday",label:"Yesterday"},{value:"7d",label:"7 Days"},{value:"30d",label:"30 Days"}],requestSeq:0,overview:null,overviewError:!1,daily:null,dailyError:!1,activityChart:null,byLanguage:null,byLanguageError:!1,byPageType:null,byPageTypeError:!1,byErrorType:null,byErrorTypeError:!1,recentSessions:null,recentSessionsError:!1,expandedSessions:{},transcripts:{},transcriptLoading:{},transcriptErrors:{}}},computed:{todayIso(){return new Date().toISOString().slice(0,10)},periodLabel(){if(this.period==="custom")return this.customDate||"custom";var s=this.period,e=this.periods.find(function(u){return u.value===s});return e?e.label:this.period},byLanguageEnriched(){return this.byLanguage?this.byLanguage.map(function(s){var e=E[s.lang]||{};return Object.assign({},s,{displayName:e.name||s.lang,flag:e.flag||"",domain:S(s.lang)})}):[]},errorTypeLabels(){return{minimax_unavailable:"Model unavailable / quota",json_parse_failed:"Malformed response (recovered or not)"}}},mounted(){var s=localStorage.getItem("admin_ai_assistant_password");
1s&&(this.password=s,this.login())},methods:{async login(){this.loading=!0,this.error="";var{getAdminAiAssistantStats:s}=b(),e=await s({password:this.password,action:"overview",period:this.period});if(e===null){this.error="Wrong password or server error",this.authenticated=!1,localStorage.removeItem("admin_ai_assistant_password"),this.loading=!1;return}this.authenticated=!0,localStorage.setItem("admin_ai_assistant_password",this.password),await this.loadAll()},setPeriod(s){this.period=s,this.customDate="",this.loadAll()},setCustomDate(s){s&&(this.customDate=s,this.period="custom",this.loadAll())},refresh(){this.loadAll()},logout(){this.authenticated=!1,this.password="",this.overview=null,localStorage.removeItem("admin_ai_assistant_password")},async loadAll(){var s=++this.requestSeq;this.loading=!0;var{getAdminAiAssistantStats:e}=b(),u=this.period==="custom"?{date:this.customDate}:{},h=Object.assign({password:this.password,period:this.period},u),i=await e(Object.assign({action:"overview"},h));if(s===this.requestSeq){this.overview=i,this.overviewError=i===null;var l=await e(Object.assign({action:"daily"},h));if(s===this.requestSeq){this.daily=l?l.daily:null,this.dailyError=l===null,this.$nextTick((function(){s===this.requestSeq&&this.renderActivityChart()}).bind(this));var r=await e(Object.assign({action:"by_language"},h));if(s===this.requestSeq){this.byLanguage=r?r.by_language:null,this.byLanguageError=r===null;var d=await e(Object.assign({action:"by_page_type"},h));if(s===this.requestSeq){this.byPageType=d?d.by_page_type:null,this.byPageTypeError=d===null;var p=await e(Object.assign({action:"by_error_type"},h));if(s===this.requestSeq){this.byErrorType=p,this.byErrorTypeError=p===null;var y=await e(Object.assign({action:"recent_sessions"},h));s===this.requestSeq&&(this.recentSessions=y?y.recent_sessions:null,this.recentSessionsError=y===null,this.expandedSessions={},this.transcripts={},this.transcriptErrors={},s===this.requestSeq&&(this.loading=!1))}}}}}},formatNum(s){return!s&&s!==0?"0":Number(s).toLocaleString()},errorTypeLabel(s){return this.errorTypeLabels[s]||s},formatTime(s){if(!s)return"—";var e=new Date(s);return isNaN(e.getTime())?s:e.toLocaleString([],{month:"short",day:"numeric",hour:"2-digit",minute:"2-digit"})},truncateSessionId(s){return s&&s.length>8?s.slice(0,8)+"…":s},async toggleSession(s){if(this.expandedSessions=Object.assign({},this.expandedSessions,{[s]:!this.expandedSessions[s]}),this.expandedSessions[s]&&!this.transcripts[s]){this.transcriptLoading=Object.assign({},this.transcriptLoading,{[s]:!0}),this.transcriptErrors=Object.assign({},this.transcriptErrors,{[s]:!1});var{getAdminAiAssistantStats:e}=b(),u=await e({password:this.password,action:"transcript",session_id:s});u===null?this.transcriptErrors=Object.assign({},this.transcriptErrors,{[s]:!0}):this.transcripts=Object.assign({},this.transcripts,{[s]:u.turns}),this.transcriptLoading=Object.assign({},this.transcriptLoading,{[s]:!1})}},turnContextChanged(s,e){if(e===0)return!0;var u=s[e-1],h=s[e],i=u.page||{},l=h.page||{};return i.type!==l.type||i.id!==l.id||i.lang!==l.lang},loadChartJs(){return new Promise(function(s,e){if(window.Chart)return s();var u=document.createElement("script");u.src="https://cdn.jsdelivr.net/npm/chart.js@4/dist/chart.umd.min.js",u.onload=s,u.onerror=e,document.head.appendChild(u)})},async renderActivityChart(){if(!(!this.daily||!this.daily.length||!this.$refs.activityCanvas)){window.Chart||await this.loadChartJs(),this.activityChart&&this.activityChart.destroy();var s=this.$refs.activityCanvas.getContext("2d");this.activityChart=new window.Chart(s,{type:"line",data:{labels:this.daily.map(function(e){return e.date.slice(5)}),datasets:[{label:"Messages",data:this.daily.map(function(e){return e.messages}),borderColor:"#00d4ff",backgroundColor:"rgba(0,212,255,0.1)",fill:!0,tension:.3,pointRadius:2},{label:"Conversations",data:this.daily.map(function(e){return e.conversations}),borderColor:"#34d399",backgroundColor:"transparent",tension:.3,pointRadius:2},{label:"Errors",data:this.daily.map(function(e){return e.errors}),borderColor:"#f87171",backgroundColor:"transparent",tension:.3,pointRadius:2}]},options:{animation:!1,responsive:!0,maintainAspectRatio:!1,interaction:{mode:"index",intersect:!1},plugins:{legend:{labels:{color:"#b0b0c8",font:{size:12}}}},scales:{x:{ticks:{color:"#6b6b7b",font:{size:11}},grid:{color:"rgba(255,255,255,0.05)"}},y:{beginAtZero:!0,ticks:{color:"#6b6b7b",font:{size:11}},grid:{color:"rgba(255,255,255,0.05)"}}}}})}}},beforeUnmount(){this.activityChart&&this.activityChart.destroy()}},A={class:"ai-assistant-stats"},x={key:0,class:"login-box"},q=["disabled"],j={key:0,class:"error-msg"},N={key:1},D={class:"header-bar"},P={class:"header-actions"},O={class:"period-selector"},R=["onClick"],M=["value","max"],B=["disabled"],z={class:"section"},V={key:0,class:"section-error"}
1,F={key:1,class:"cards"},I={class:"card"},U={class:"card-value"},H={class:"card"},J={class:"card-value card-value-blue"},W={class:"card"},Y={class:"card-value card-value-green"},Z={class:"card"},G={class:"card"},K={class:"card-value card-value-purple"},Q={class:"section"},X={key:0,class:"section-error"},$={key:1,class:"chart-wrap"},tt={ref:"activityCanvas"},et={class:"two-col"},st={class:"section"},rt={key:0,class:"section-error"},it={key:1,class:"table-scroll"},at={class:"data-table"},nt={class:"section"},ot={key:0,class:"section-error"},lt={key:1,class:"table-scroll"},dt={class:"data-table"},ut={class:"section"},ct={key:0,class:"section-error"},ht={key:1,class:"table-scroll"},gt={class:"data-table"},vt={key:0},pt={class:"section"},yt={key:0,class:"section-error"},_t={key:1,class:"table-scroll"},bt={class:"data-table"},mt={key:0},ft=["onClick"],wt={class:"expand-icon"},Ct={key:0,class:"transcript-row"},kt={colspan:"7"},Et={key:0},St={key:1,class:"section-error"},Lt={key:2},Tt={key:0,class:"transcript-page-context"},At={class:"transcript-user-msg"},xt={class:"transcript-assistant-msg"},qt={key:1,class:"error-badge"};function jt(s,e,u,h,i,l){return n(),a("div",A,[i.authenticated?(n(),a("div",N,[t("div",D,[e[6]||(e[6]=t("h1",null,"AI Assistant Analytics",-1)),t("div",P,[t("div",O,[(n(!0),a(g,null,v(i.periods,r=>(n(),a("button",{key:r.value,class:_({active:i.period===r.value}),onClick:d=>l.setPeriod(r.value)},o(r.label),11,R))),128)),t("input",{type:"date",class:_(["period-date-input",{active:i.period==="custom"}]),value:i.customDate,max:l.todayIso,onChange:e[2]||(e[2]=r=>l.setCustomDate(r.target.value))},null,42,M)]),t("button",{onClick:e[3]||(e[3]=(...r)=>l.refresh&&l.refresh(...r)),disabled:i.loading},o(i.loading?"Loading...":"Refresh"),9,B),t("button",{onClick:e[4]||(e[4]=(...r)=>l.logout&&l.logout(...r)),class:"btn-logout"},"Logout")])]),t("section",z,[t("h2",null,"Overview ("+o(l.periodLabel)+")",1),i.overviewError?(n(),a("div",V,"Couldn't load this section.")):i.overview?(n(),a("div",F,[t("div",I,[t("div",U,o(l.formatNum(i.overview.total_conversations)),1),e[7]||(e[7]=t("div",{class:"card-label"},"Total Conversations",-1))]),t("div",H,[t("div",J,o(l.formatNum(i.overview.total_messages)),1),e[8]||(e[8]=t("div",{class:"card-label"},"Total Messages",-1))]),t("div",W,[t("div",Y,o(i.overview.avg_messages_per_conversation),1),e[9]||(e[9]=t("div",{class:"card-label"},"Avg Messages / Conversation",-1))]),t("div",Z,[t("div",{class:_(["card-value",i.overview.error_rate_pct>0?"card-value-orange":""])},o(i.overview.error_rate_pct)+"%",3),e[10]||(e[10]=t("div",{class:"card-label"},"Error Rate",-1))]),t("div",G,[t("div",K,o(i.overview.days_with_activity)+" / "+o(i.overview.days_in_period),1),e[11]||(e[11]=t("div",{class:"card-label"},"Active Days",-1))])])):c("",!0)]),t("section",Q,[t("h2",null,"Activity ("+o(l.periodLabel)+")",1),i.dailyError?(n(),a("div",X,"Couldn't load this section.")):(n(),a("div",$,[t("canvas",tt,null,512)]))]),t("div",et,[t("section",st,[e[13]||(e[13]=t("h2",null,"By Language & Domain",-1)),i.byLanguageError?(n(),a("div",rt,"Couldn't load this section.")):(n(),a("div",it,[t("table",at,[e[12]||(e[12]=t("thead",null,[t("tr",null,[t("th",null,"Language"),t("th",null,"Domain"),t("th",null,"Messages"),t("th",null,"Conversations")])],-1)),t("tbody",null,[(n(!0),a(g,null,v(l.byLanguageEnriched,r=>(n(),a("tr",{key:r.lang},[t("td",null,o(r.flag)+" "+o(r.displayName),1),t("td",null,o(r.domain),1),t("td",null,o(l.formatNum(r.messages)),1),t("td",null,o(l.formatNum(r.conversations)),1)]))),128))])])]))]),t("section",nt,[e[15]||(e[15]=t("h2",null,"By Page Type",-1)),i.byPageTypeError?(n(),a("div",ot,"Couldn't load this section.")):(n(),a("div",lt,[t("table",dt,[e[14]||(e[14]=t("thead",null,[t("tr",null,[t("th",null,"Page Type"),t("th",null,"Messages"),t("th",null,"Conversations")])],-1)),t("tbody",null,[(n(!0),a(g,null,v(i.byPageType||[],r=>(n(),a("tr",{key:r.page_type},[t("td",null,o(r.page_type),1),t("td",null,o(l.formatNum(r.messages)),1),t("td",null,o(l.formatNum(r.conversations)),1)]))),128))])])]))])]),t("section",ut,[t("h2",null,"LLM Errors ("+o(l.periodLabel)+")",1),i.byErrorTypeError?(n(),a("div",ct,"Couldn't load this 
1section.")):i.byErrorType?(n(),a("div",ht,[t("table",gt,[e[17]||(e[17]=t("thead",null,[t("tr",null,[t("th",null,"Error Type"),t("th",null,"Count"),t("th",null,"% of Total Messages")])],-1)),t("tbody",null,[i.byErrorType.by_error_type.length?c("",!0):(n(),a("tr",vt,[...e[16]||(e[16]=[t("td",{colspan:"3"},"No errors in this period.",-1)])])),(n(!0),a(g,null,v(i.byErrorType.by_error_type,r=>(n(),a("tr",{key:r.error_type},[t("td",null,o(l.errorTypeLabel(r.error_type)),1),t("td",null,o(l.formatNum(r.count)),1),t("td",null,o(i.byErrorType.total_messages>0?(r.count/i.byErrorType.total_messages*100).toFixed(1):"0.0")+"%",1)]))),128))])])])):c("",!0)]),t("section",pt,[e[24]||(e[24]=t("h2",null,"Recent Conversations",-1)),i.recentSessionsError?(n(),a("div",yt,"Couldn't load this section.")):i.recentSessions?(n(),a("div",_t,[t("table",bt,[e[23]||(e[23]=t("thead",null,[t("tr",null,[t("th",null,"Session"),t("th",null,"Page"),t("th",null,"Language"),t("th",null,"Messages"),t("th",null,"Last Activity"),t("th",null,"Error"),t("th")])],-1)),t("tbody",null,[i.recentSessions.length?c("",!0):(n(),a("tr",mt,[...e[18]||(e[18]=[t("td",{colspan:"7"},"No conversations in this period.",-1)])])),(n(!0),a(g,null,v(i.recentSessions,r=>(n(),a(g,{key:r.session_id},[t("tr",{class:"row-expandable",onClick:d=>l.toggleSession(r.session_id)},[t("td",null,[m(o(l.truncateSessionId(r.session_id)),1),t("span",wt,o(i.expandedSessions[r.session_id]?"▾":"▸"),1)]),t("td",null,o(r.page_type)+o(r.page_id?" / "+r.page_id:""),1),t("td",null,o(r.page_lang),1),t("td",null,o(l.formatNum(r.message_count)),1),t("td",null,o(l.formatTime(r.last_activity)),1),t("td",null,[(n(!0),a(g,null,v(r.error_types,d=>(n(),a("span",{key:d,class:"error-badge"},o(l.errorTypeLabel(d)),1))),128))]),e[19]||(e[19]=t("td",null,"View",-1))],8,ft),i.expandedSessions[r.session_id]?(n(),a("tr",Ct,[t("td",kt,[i.transcriptLoading[r.session_id]?(n(),a("div",Et,"Loading transcript…")):i.transcriptErrors[r.session_id]?(n(),a("div",St,"Couldn't load transcript.")):i.transcripts[r.session_id]?(n(),a("div",Lt,[e[22]||(e[22]=t("p",{class:"transcript-caption"},"Shown to improve prompts and catch model errors — not for tracking individual visitors.",-1)),(n(!0),a(g,null,v(i.transcripts[r.session_id],(d,p)=>(n(),a("div",{key:p,class:"transcript-turn"},[l.turnContextChanged(i.transcripts[r.session_id],p)?(n(),a("div",Tt,o((d.page||{}).type)+o((d.page||{}).id?" / "+(d.page||{}).id:"")+" ("+o((d.page||{}).lang)+") ",1)):c("",!0),t("div",At,[e[20]||(e[20]=t("strong",null,"User:",-1)),m(" "+o(d.user_message),1)]),t("div",xt,[e[21]||(e[21]=t("strong",null,"Assistant:",-1)),m(" "+o(d.assistant_reply),1)]),d.had_error?(n(),a("div",qt,o(l.errorTypeLabel(d.error_type)),1)):c("",!0)]))),128))])):c("",!0)])])):c("",!0)],64))),128))])])])):c("",!0)])])):(n(),a("div",x,[e[5]||(e[5]=t("h2",null,"AI Assistant Analytics",-1)),t("form",{onSubmit:e[1]||(e[1]=k((...r)=>l.login&&l.login(...r),["prevent"]))},[w(t("input",{"onUpdate:modelValue":e[0]||(e[0]=r=>i.password=r),type:"password",placeholder:"Password",autofocus:""},null,512),[[C,i.password]]),t("button",{type:"submit",disabled:i.loading},"Login",8,q)],32),i.error?(n(),a("p",j,o(i.error),1)):c("",!0)]))])}const Dt=f(T,[["render",jt]]);export{Dt 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.