PageSourceSearch

https://trakkr.ai/assets/AnalyticsConnectFlow-B3_iXXyN.js

js trakkr.ai collected 2026-09-28 08:32:41 UTC 14,170 bytes, 3 lines download raw bytes

1import{j as e,u as de}from"./vendor-query-DvnPdOMX.js";import{r as p}from"./vendor-react-woJBpfBI.js";import{bk as pe,bt as ue,bp as N,U as me,R as he,a as _,bC as w}from"./index-1YQNuixL.js";import{a as F,f as xe,P as z,g as ye,b as fe}from"./SetupFrame-CKYdXbt3.js";import{I as ge}from"./IntegrationStatus-CoTzgu1B.js";import{M as R}from"./visuals-CE9Gcapm.js";import{u as je}from"./useSamplePaths-CE_sxA-J.js";import{c as be,e as ve,f as Ce,p as ke}from"./google-analytics-BG4u1yZW.js";import{u as Ae}from"./index-SZJD4SDQ.js";import{c as G}from"./vendor-utils-BNe0Xlio.js";import{L as Ne,C as M,T as we,i as Ge,J as U,a4 as Pe,R as Se,e as H,s as Te}from"./vendor-icons-BLMEbmRV.js";import{u as _e,C as ze}from"./CopyButton-DJeaB_-Q.js";import"./vendor-supabase-DaZXgOw0.js";import"./vendor-motion-ZmH_6coE.js";import"./StateNotice-CUVE_HHP.js";import"./brand-compare-types-CFvImvcp.js";import"./sample-paths-CY-jQt3i.js";function W(r){return r.toLowerCase().replace(/^https?:\/\//,"").replace(/^www\./,"").replace(/[^a-z0-9]+/g," ").trim()}function Re(r,a,o){const n=W(`${r.displayName} ${r.accountDisplayName}`),h=W(a),t=W(o||"").split(" ")[0];let u=0;t&&n.includes(t)&&(u+=100),h&&n.includes(h)&&(u+=60);for(const c of h.split(" ").filter(f=>f.length>=4))n.includes(c)&&(u+=10);return u}function We({data:r,loading:a,error:o,query:n,onQueryChange:h,selectedId:t,onSelect:u,brandName:c,brandDomain:f}){const C=p.useRef(null),g=p.useDeferredValue(n.trim().toLowerCase()),d=p.useMemo(()=>r?.properties??[],[r?.properties]),v=p.useMemo(()=>{const x=g?d.filter(s=>`${s.displayName} ${s.accountDisplayName} ${s.name}`.toLowerCase().includes(g)):d;if(g)return x.map(s=>({kind:"property",key:s.name,property:s}));const j=d.map(s=>({property:s,score:Re(s,c,f)})).sort((s,m)=>m.score-s.score).filter(s=>s.score>0).slice(0,3).map(s=>s.property),b=new Set(j.map(s=>s.name)),y=d.filter(s=>!b.has(s.name)),l=[];return j.length>0&&(l.push({kind:"heading",key:"suggested",label:"Suggested"}),l.push(...j.map(s=>({kind:"property",key:s.name,property:s})))),y.length>0&&(l.push({kind:"heading",key:"all",label:j.length>0?"All properties":"Properties"}),l.push(...y.map(s=>({kind:"property",key:s.name,property:s})))),l},[f,c,g,d]),k=Ae({count:v.length,getScrollElement:()=>C.current,estimateSize:x=>v[x]?.kind==="heading"?34:58,overscan:8}),A=o?"Couldn't load properties from this Google account. Connect it again and retry.":r?.account_count===0?"This Google account has no Analytics accounts.":d.length===0?"No GA4 properties are available in this Google account.":g?"No properties match this search.":null;return e.jsxs("div",{className:"rounded border border-default bg-surface overflow-hidden",children:[e.jsx("div",{className:"border-b border-default px-4 py-3 sm:px-5",children:e.jsx(pe,{label:"Find a GA4 property",helpText:!a&&d.length>0?`${d.length.toLocaleString()} properties across ${r?.account_count.toLocaleString()??0} accounts`:void 0,children:e.jsx(ue,{value:n,onValueChange:h,placeholder:"Search properties, accounts or IDs...",size:"comfortable"})})}),e.jsx("div",{ref:C,className:"h-[340px] overflow-y-auto overscroll-contain",children:a?e.jsx("div",{className:"flex h-full items-center justify-center",role:"status","aria-label":"Loading GA4 properties",children:e.jsx(Ne,{size:16,strokeWidth:1.5,className:"animate-spin text-muted"})}):A?e.jsx("div",{className:"flex h-full items-center justify-center px-8 text-center",children:e.jsx("p",{className:"max-w-[44ch] text-body leading-relaxed text-secondary",children:A})}):e.jsx("div",{role:"listbox","aria-label":"GA4 properties",className:"relative w-full",style:{height:k.getTotalSize()},children:k.getVirtualItems().map(x=>{const i=v[x.index];return i?e.jsx("div",{className:"absolute left-0 top-0 w-full",style:{transform:`translateY(${x.start}px)`},children:i.kind==="heading"?e.jsx("div",{className:"section-label border-b border-subtle bg-surface px-5 py-2",children:i.label}):e.jsxs("button",{type:"button",role:"option","aria-selected":t===i.property.name,onClick:()=>u(i.property),className:G("focus-ring flex w-full items-center gap-4 border-b border-subtle px-5 py-3 text-left transition-colors duration-150",t===i.property.name?"bg-accent-subtle":"hover:bg-muted"),children:[e.jsxs("span",{className:"min-w-0 flex-1",children:[e.jsx("span",{className:"block truncate text-body font-medium text-primary",children:i.property.displayName}),e.jsxs("span",{className:"block truncate text-data text-muted",children:[i.property.accountDisplayName," · ",i.property.name.replace("properties/","Property ")]})]}),t===i.property.name&&e.jsx(M,{size:14,strokeWidth:2,className:"shrink-0 text-accent","aria-hidden":!0})]})},i.key):null})})})]})}const Ee="Google says your admin needs to approve this?",Le="Blocked by your Google admin?",Q='Google did n
1ot send you back last time. If it said "Access blocked", a Workspace admin needs to allow Trakkr first.',q="Security > Access and data control > API controls";function Ie(r){const a=r?`Search for this client ID and set it to Trusted:
2${r}`:"Search for Trakkr and set it to Trusted.";return["Please allow the Trakkr app in Google Workspace so we can connect Google Analytics.","",`Google Admin console > ${q} > Manage App Access > Configure new app`,"",a].join(`
3`)}const K="focus-ring rounded text-secondary underline-offset-2 transition-colors hover:text-primary hover:underline";function Oe({children:r,unfinished:a=!1,onOpen:o,className:n}){return a?e.jsxs("p",{role:"status",className:G("flex items-start gap-2 text-left text-body leading-relaxed text-secondary",n),children:[e.jsx(we,{size:14,strokeWidth:1.75,"aria-hidden":"true",className:"mt-0.5 shrink-0 text-warning"}),e.jsxs("span",{children:[Q," ",e.jsx("button",{type:"button",onClick:o,className:G(K,"text-primary underline"),children:"See what to send them"})]})]}):e.jsxs("p",{className:G("text-caption text-muted",n),children:[r,e.jsx("span",{"aria-hidden":"true",className:"mx-2",children:"·"}),e.jsx("button",{type:"button",onClick:o,className:K,children:Ee})]})}function E({number:r,title:a,detail:o}){return e.jsxs("li",{className:"flex gap-3 px-5 py-3.5",children:[e.jsx("span",{className:"pt-px font-mono text-caption tabular-nums text-accent",children:r}),e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsx("p",{className:"text-body text-primary",children:a}),o&&e.jsx("div",{className:"mt-1 text-caption text-secondary",children:o})]})]})}function De({isOpen:r,onClose:a,clientId:o}){const{copied:n,copy:h}=_e(),t=async()=>{await h(Ie(o))||me.error("Couldn't copy to clipboard")};return e.jsxs(N,{isOpen:r,onClose:a,size:"md",children:[e.jsx(N.Header,{title:"Ask your Google admin to allow Trakkr",description:"Google Workspace blocks apps an admin has not reviewed yet.",onClose:a}),e.jsxs(N.Body,{padded:!1,children:[e.jsxs("ol",{className:"divide-y divide-subtle",children:[e.jsx(E,{number:1,title:"Open the Google Admin console",detail:q}),e.jsx(E,{number:2,title:"Choose Manage App Access, then Configure new app"}),e.jsx(E,{number:3,title:o?"Search for this client ID and set Trakkr to Trusted":"Search for Trakkr by name and set it to Trusted",detail:o?e.jsxs("div",{className:"mt-0.5 flex items-center gap-1.5",children:[e.jsx("code",{className:"min-w-0 flex-1 truncate rounded border border-default bg-surface px-2 py-1 font-mono text-caption text-primary",children:o}),e.jsx(ze,{text:o,variant:"secondary"})]}):void 0})]}),e.jsx("p",{className:"border-t border-subtle px-5 py-3 text-caption text-muted",children:"Once that is done, come back here and connect again."})]}),e.jsx(N.Footer,{cancel:{label:"Close",onClick:a},primary:{label:n?"Copied":"Copy for your admin",onClick:()=>{t()},icon:n?e.jsx(M,{size:12,strokeWidth:2}):e.jsx(Ge,{size:12,strokeWidth:1.5})}})]})}function rs({brandId:r,brandName:a,brandDomain:o,userId:n,userHasCredentials:h,connectionState:t,resumeStep:u,canManage:c,isClientViewer:f=!1,skipToPropertySelect:C,oauthClientId:g,unfinishedOAuthAttempt:d=!1,onConnected:v,onStatusRetry:k}){const A=C||t==="setup_incomplete"&&u==="property",x=t==="needs_reauth"||t==="permission_missing"||t==="degraded"||t==="setup_incomplete"&&u==="authorize"||!c,[i,j]=p.useState(A&&c?"select":x?"repair":"connect"),[b,y]=p.useState(!1),[l,s]=p.useState(null),[m,B]=p.useState(null),[V,Y]=p.useState(""),[L,I]=p.useState(!1),[J,P]=p.useState(!1),O=c&&t!=="degraded",D=e.jsx(De,{isOpen:J,onClose:()=>P(!1),clientId:g}),{paths:$}=je(r||void 0),{data:X,isLoading:Z,error:ee}=de({queryKey:["ga-property-options",n,r],queryFn:()=>ke(r),enabled:i==="select"&&c,retry:1}),S=async()=>{y(!0),s(null);try{const{url:T}=await be(r);window.location.href=T}catch{s("Couldn't start the connection. Try again."),y(!1)}},se=async()=>{y(!0),s(null);try{await ve(r,n),j("select"),y(!1)}catch{s("Couldn't use the saved account. Connect with Google instead."),y(!1)}},te=async()=>{if(m){I(!0),s(null);try{await Ce({brandId:r,userId:n,accountId:m.accountName,accountName:m.accountDisplayName,propertyId:m.name,propertyName:m.displayName}),v()}catch{s("Couldn't connect the property. Try again."),I(!1)}}};if(i==="repair"){const T=t==="not_connected"?f?"Google Analytics is not connected. Contact your account manager to connect it."
3:"Google Analytics is not connected. An owner or editor needs to connect it.":f?"Analytics updates are paused. Contact your account manager to restore them.":"Analytics updates are paused. An owner or editor needs to reconnect Google Analytics.",ae=t==="permission_missing"?"permission-failed":t==="degraded"?"degraded":t==="setup_incomplete"?"callback-failed":"revoked",oe=t==="not_connected"?"Google Analytics is not connected":t==="setup_incomplete"?"Finish connecting Google Analytics":t==="degraded"?"Google Analytics could not be checked":"Google Analytics needs to be reconnected",ne=c?l||(t==="setup_incomplete"?"Connect Google again, then choose the GA4 property for this brand.":t==="degraded"?"Google is temporarily unavailable. Your saved visitor data has not been removed.":t==="permission_missing"?"This Google account can no longer read the selected GA4 property. Use an account with access.":"Google no longer authorizes this connection. Reconnect to resume visitor updates."):T,ie=O&&d&&!l?` ${Q}`:"",le=O?{label:Le,onClick:()=>P(!0),variant:"ghost"}:void 0,ce=c?t==="degraded"?{label:"Try again",onClick:k,variant:"secondary"}:{label:t==="setup_incomplete"?"Continue with Google":"Reconnect Google Analytics",onClick:()=>{S()},disabled:b,variant:"primary"}:void 0;return e.jsxs("div",{className:"flex min-h-[60vh] items-center justify-center px-4 py-12 sm:px-8",children:[e.jsx("div",{className:"w-full max-w-2xl",children:e.jsx(ge,{status:ae,provider:"Google Analytics",title:oe,description:ne+ie,action:ce,secondaryAction:le})}),D]})}if(i==="connect")return e.jsxs("div",{className:"min-h-[60vh] flex justify-center px-4 py-10 sm:px-8 sm:py-12",children:[e.jsx(he,{children:e.jsxs("div",{className:"w-full max-w-2xl flex flex-col items-center",children:[e.jsx(_,{delay:.04,className:"w-full",children:e.jsx(F,{icon:U,align:"start",question:"Who's arriving from AI?",description:"We read your Google Analytics and separate the sessions that start inside an AI answer from everything else. Connect Google, then choose your site."})}),e.jsx(_,{delay:.1,className:"w-full",children:e.jsx("div",{className:"mt-8 w-full",children:e.jsx(xe,{stats:[{label:"AI sessions",value:e.jsx(z,{spark:!0,children:"412"})},{label:"Top assistant",value:e.jsx(ye,{mark:e.jsx(R,{model:"ChatGPT",size:14}),name:"ChatGPT"})},{label:"AI landing pages",value:e.jsx(z,{children:"37"})},{label:"Conversions",value:e.jsx(z,{children:"18"})}],rows:[{mark:e.jsx(R,{model:"ChatGPT",size:14}),name:"ChatGPT",detail:$[0]??"/pricing",time:"4 min ago"},{mark:e.jsx(R,{model:"Perplexity",size:14}),name:"Perplexity",detail:$[1]??"/blog",time:"11 min ago"}],footer:"Example data. Yours appears about a minute after connecting."})})}),e.jsx(_,{delay:.16,className:"w-full",children:e.jsxs("div",{className:"mt-5 text-left",children:[e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsx(w,{variant:"primary",onClick:()=>{S()},loading:b,leadingIcon:e.jsx(Pe,{size:14,strokeWidth:1.5}),children:"Connect Google Analytics"}),h&&e.jsx(w,{variant:"secondary",onClick:()=>{se()},disabled:b,leadingIcon:e.jsx(Se,{size:14,strokeWidth:1.5}),children:"Use previously connected account"})]}),l?e.jsxs("p",{role:"alert",className:"mt-3 flex items-start gap-2 text-body text-error",children:[e.jsx(H,{size:14,className:"mt-0.5 shrink-0","aria-hidden":!0}),e.jsx("span",{children:l})]}):e.jsx(Oe,{className:"mt-3",unfinished:d,onOpen:()=>P(!0),children:"First data in about a minute"}),e.jsxs("p",{className:"mt-3 text-caption leading-relaxed text-muted",children:["Read-only access. We never change your analytics."," ",e.jsx("a",{href:"/learn/docs/features/traffic/visitors",className:"focus-ring text-secondary underline-offset-2 hover:underline",children:"Read how it works"})]})]})})]})}),D]});const re=t==="setup_incomplete";return e.jsx("div",{className:"flex min-h-[60vh] items-center justify-center px-4 py-12 sm:px-8",children:e.jsxs("div",{className:"w-full max-w-3xl",children:[e.jsxs("div",{className:"mb-8",children:[e.jsx(F,{icon:U,align:"start",register:"section",question:re?"Finish connecting Google Analytics":"Cho
3ose your site",description:`Choose the GA4 property that represents ${a}.`}),e.jsx(fe,{steps:["Connect Google","Choose property"],active:1,className:"mt-5"})]}),l&&e.jsxs("div",{role:"alert",className:"mb-4 flex items-start gap-2 text-body text-error",children:[e.jsx(H,{size:14}),l]}),e.jsx(We,{data:X,loading:Z,error:ee,query:V,onQueryChange:Y,selectedId:m?.name??null,onSelect:B,brandName:a,brandDomain:o}),e.jsxs("div",{className:"mt-6 flex flex-wrap items-center gap-3 border-t border-default pt-5",children:[e.jsx(w,{variant:"secondary",size:"comfortable",onClick:()=>{S()},loading:b,children:"Use another Google account"}),e.jsx(w,{variant:"primary",size:"comfortable",onClick:()=>{te()},disabled:!m||L,loading:L,trailingIcon:e.jsx(Te,{size:14}),children:"Connect property"})]})]})})}export{rs as AnalyticsConnectFlow};

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.