PageSourceSearch

https://app.snapto.ai/assets/ChatbotFunnelInsights-DUMXwkMZ.js

js snapto.ai collected 2026-10-05 15:07:40 UTC 7,509 bytes, 1 lines download raw bytes

1import{br as Q,J as U,r as i,ac as Y,C as Z,p as t,L as c,B as ee,T as a,ak as te,a0 as z,a1 as L,S as w,b2 as se,a_ as oe,y as ie,w as O}from"./index-C9IH3k-2.js";import{r as re,g as le,p as u,a as ne,I as ae,i as ce}from"./InsightsRangePicker-DTTxSfj6.js";import{R as de}from"./ArrowLeftOutlined-Bixtqyn1.js";import{I as k,T as j,a1 as pe}from"./TemplateUtil-D1DzmWLm.js";import{S as D}from"./index-BNG9Amsm.js";import{F as he}from"./Table-isZ0WXp4.js";import{L as S}from"./index-DNqpjC0Z.js";import"./AuditConstant-C6syQHOu.js";import"./index-CmSVNJzc.js";import"./index-Bv3SRNsl.js";import"./CalendarOutlined-DyzsKNdO.js";import"./ClockCircleOutlined-Cym7vptW.js";import"./Wrapper-ChjuDa3w.js";import"./HelperMethods-C-ewwU_x.js";import"./index-BOwvFOZJ.js";import"./Pagination-D1z-xPUv.js";import"./HolderOutlined-YOHjCGKZ.js";const v=d=>d.name||`unnamed · ${(d.nodeId||"").slice(0,8)}`,Me=()=>{const{chatbotId:d}=Q(),{token:s}=U.useToken(),[n,b]=i.useState(null),[B,C]=i.useState(!1),[r,T]=i.useState(null),P=Y(),[m,V]=i.useState(()=>re(P.state)||le()),W=Z();i.useEffect(()=>{(async()=>{C(!0),T(null);try{const o=await ie(`/api/v1/chatbot/${d}/insights/funnel`,ce(m));b(o?.data||null)}catch(o){console.error("Error fetching chatbot funnel insights:",o),b(null)}finally{C(!1)}})()},[d,m]);const p=n?.statusTotals||{},h=n?.totalEntries||0,l=i.useMemo(()=>n?.nodes||[],[n]),[g,I]=i.useState([]),[y,E]=i.useState([]),[x,R]=i.useState(null),[f,M]=i.useState("all");i.useEffect(()=>{I([]),E([]),R(null),M("all")},[d]);const $=i.useMemo(()=>l.map(e=>({value:e.nodeId,label:v(e)})),[l]),_=i.useMemo(()=>[...new Set(l.map(e=>e.nodeType).filter(Boolean))].sort().map(e=>({value:e,label:e})),[l]),A=i.useMemo(()=>l.filter(e=>(g.length===0||g.includes(e.nodeId))&&(y.length===0||y.includes(e.nodeType))&&(x==null||(e.visits||0)>=x)&&(f==="all"||(f==="revisited"?(e.revisitors||0)>0:(e.revisitors||0)===0))),[l,g,y,x,f]),H=e=>e.reached?e.errors/e.reached>.2?s.colorError:e.waiting/e.reached>.5?s.colorWarning:s.colorSuccess:s.colorTextDisabled,G=i.useMemo(()=>Object.fromEntries(l.map((e,o)=>[e.nodeId,o+1])),[l]),J=i.useMemo(()=>Object.fromEntries(l.map(e=>[e.nodeId,v(e)])),[l]),F=i.useMemo(()=>(n?.transitions||[]).filter(e=>e.fromNodeId===r?.nodeId),[n,r]),N=(p.TERMINATED||0)+(p.EXPIRED||0),K=[{key:"landed",title:"Chats Started",value:h},{key:"completed",title:"Completed",value:p.COMPLETED||0,pct:u(p.COMPLETED||0,h),color:s.colorSuccess},{key:"dropped",title:"Dropped Off",value:N,pct:u(N,h),color:s.colorWarning},{key:"errors",title:"Errors",value:p.ERROR||0,pct:u(p.ERROR||0,h),color:s.colorError}],X=[{title:"#",key:"step",width:48,align:"right",render:(e,o)=>t.jsx(a.Text,{type:"secondary",children:G[o.nodeId]})},{title:"Node",key:"node",width:200,ellipsis:!0,render:(e,o)=>t.jsx(O,{title:o.nodeType||"unknown",children:t.jsx(a.Text,{style:{fontFamily:s.fontFamilyCode},children:v(o)})})},{title:"How far chats get",key:"reach",render:(e,o)=>t.jsx("div",{style:{background:s.colorFillSecondary,borderRadius:s.borderRadiusSM,height:10},children:t.jsx("div",{style:{width:`${Math.max(u(o.reached,h),2)}%`,height:"100%",borderRadius:s.borderRadiusSM,background:H(o)}})})},{title:"Chats",dataIndex:"reached",key:"reached",width:120,align:"right",sorter:(e,o)=>(e.reached||0)-(o.reached||0),render:e=>t.jsxs(t.Fragment,{children:[(e||0).toLocaleString()," ",t.jsxs(a.Text,{type:"secondary",style:{fontSize:s.fontSizeSM},children:["(",u(e,h),"%)"]})]})},{title:"Visits",dataIndex:"visits",key:"visits",width:90,align:"right",sorter:(e,o)=>(e.visits||0)-(o.visits||0),render:(e,o)=>t.jsx(O,{title:o.revisitors?`${o.revisitors.toLocaleString()} chats came back to this node (most in one chat: ${o.maxVisitsInOneChat}x)`:"No chat visited this node twice",children:(e||0).toLocaleString()})}],q=[{key:"reached",title:"Chats Reached"},{key:"visits",title:"Total Visits"},{key:"revisitors",title:"Chats That Came Back"},{key:"maxVisitsInOneChat",title:"Most Visits in One Chat"},{key:"completed",title:"Completed"},{key:"waiting",title:"Still Waiting Reply"},{key:"errors",title:"Errors",color:s.colorError},{key:"dropOffs",title:"Dropped Off Here",color:s.colorWarning}];return t.jsxs(c,{vertical:!0,gap:"middle",style:{padding:s.paddingLG},children:[t.jsxs(c,{justify:"space-between",align:"center",children:[t.jsxs(c,{align:"center",gap:"small",children:[t.jsx(ee,{icon:t.jsx(de,{}),onClick:()=>W("/Chatbot/Insights",{state:ne(m)})}),t.jsxs(a.Title,{level:4,style:{margin:0},children:["Funnel — ",n?.chatbotName||d]})]}),t.jsx(ae,{value:m,onChange:V})]}),t.jsxs(te,{spinning:B,children:[t.jsx(z,{gutter:[16,16],children:K.map(e=>t.jsx(L,{xs:12,md:6,flex:"auto",children:t.jsx(k,{size:"small",children:t.jsx(D,{title:e.title,value:e.value,suffix:e.pct!=null&&t.jsxs(a.Text,{type:"secondary",style:{fontSize:s.fontSize},children:["(",e.pct,"%)"]}),styles:e.color?{content:{color:e.color}}:void 0})})},e.key))}),t.jsxs(k,{size:"small",title:"How far do chats get? (click a node for details)",style:{marginTop:s.marginMD},children:[t.jsxs(c,{gap:"small",wrap:!0,style:{marginBottom:s.marginSM},children:[t.jsx(w,{mode:"multiple",allowClear:!0,showSearch:!0,optionFilterProp:"label",placeholder:"Filter by node",options:$,value:g,onChange:I,style:{minWidth:240,flex:1},maxTagCount:"responsive"}),t.jsx(w,{mode:"multiple",allowClear:!0,placeholder:"Filter by node type",options:_,value:y,onChange:E,style:{minWidth:200},maxTagCount:"responsive"}),t.jsx(se,{min:1,placeholder:"Min visits",value:x,onChange:R,style:{width:110}}),t.jsx(w,{value:f,onChange:M,options:[{value:"all",label:"Any revisits"},{value:"revisited",label:"Revisited nodes"},{value:"notRevisited",label:"Not revisited"}],style:{width:150}})]}),t.jsx(he,{rowKey:"nodeId",columns:X,dataSource:A,pagination:!1,size:"small",showSorterTooltip:!1,scroll:{y:420}
1,locale:{emptyText:t.jsx(oe,{description:l.length===0?"No executions in this period":"No nodes match the selected filters"})},onRow:e=>({onClick:()=>T(e),style:{cursor:"pointer"}})})]}),(n?.topErrors||[]).length>0&&t.jsx(k,{size:"small",title:"Top errors",style:{marginTop:s.marginMD},children:t.jsx(S,{size:"small",dataSource:n.topErrors,renderItem:e=>t.jsx(S.Item,{children:t.jsxs(c,{justify:"space-between",style:{width:"100%"},gap:s.marginSM,children:[t.jsx(a.Text,{style:{fontSize:s.fontSizeSM},ellipsis:{tooltip:e.message},children:e.message}),t.jsx(j,{color:"error",children:(e.count||0).toLocaleString()})]})})})})]}),t.jsx(pe,{title:r?v(r):"",open:!!r,onClose:()=>T(null),width:420,children:r&&t.jsxs(c,{vertical:!0,gap:"middle",children:[t.jsxs(c,{gap:"small",wrap:!0,children:[t.jsx(j,{children:r.nodeType||"unknown"}),r.startNode&&t.jsx(j,{color:"blue",children:"start node"}),r.userReply&&t.jsx(j,{color:"purple",children:"waits for reply"})]}),t.jsx(z,{gutter:[12,12],children:q.map(e=>t.jsx(L,{span:12,children:t.jsx(D,{title:e.title,value:r[e.key]||0,styles:e.color&&r[e.key]?{content:{color:e.color}}:void 0})},e.key))}),F.length>0&&t.jsxs(t.Fragment,{children:[t.jsx(a.Text,{strong:!0,children:"Where people went next"}),t.jsx(S,{size:"small",dataSource:F,renderItem:e=>t.jsx(S.Item,{children:t.jsxs(c,{justify:"space-between",style:{width:"100%"},gap:s.marginSM,children:[t.jsxs(a.Text,{style:{fontSize:s.fontSizeSM},ellipsis:!0,children:["→ ",J[e.toNodeId]||e.toNodeId]}),t.jsxs(a.Text,{type:"secondary",style:{fontSize:s.fontSizeSM,whiteSpace:"nowrap"},children:[(e.count||0).toLocaleString()," (",u(e.count,r.reached),"%)"]})]})})})]})]})})]})};export{Me 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.