@fynd-design-engineering/fynd-one-v2 3.1.32 → 3.1.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";(()=>{function U(e,t){return t.platform!=="none"?t:e}function D(){let t="https://gemini.google.com/".toLowerCase(),n=new URL(window.location.href),a=n.searchParams.get("utm_source")?.toLowerCase()||"",i=n.searchParams.get("utm_medium")?.toLowerCase()||"",s=n.searchParams.get("utm_campaign")?.toLowerCase()||"",g=n.searchParams.get("utm_content")?.toLowerCase()||"",y=`${t} ${a} ${i} ${s} ${g}`,d={platform:"none",type:"unknown",context:"unknown",confidence:"low",detectionMethod:"none",detectedAt:new Date().toISOString()},c=[{keywords:["chatgpt","openai","chat.openai"],platform:"ChatGPT",type:"ai_chat",context:"conversational_query",confidence:"high"},{keywords:["perplexity"],platform:"Perplexity",type:"ai_search",context:"research_query",confidence:"high"},{keywords:["claude","anthropic"],platform:"Claude",type:"ai_chat",context:"conversational_query",confidence:"high"},{keywords:["bing","copilot","microsoft-copilot"],platform:"Bing_Copilot",type:"ai_chat",context:"conversational_query",confidence:"medium"},{keywords:["gemini","bard","google-ai"],platform:"Google_Gemini",type:"ai_chat",context:"conversational_query",confidence:"high"},{keywords:["you.com","you-ai"],platform:"You_AI",type:"ai_search",context:"search_query",confidence:"medium"},{keywords:["character.ai","character"],platform:"Character_AI",type:"ai_chat",context:"character_interaction",confidence:"high"},{keywords:["poe","quora-poe"],platform:"Poe",type:"ai_chat",context:"conversational_query",confidence:"high"},{keywords:["huggingface","hf-chat"],platform:"HuggingFace",type:"ai_chat",context:"technical_query",confidence:"medium"},{keywords:["replika"],platform:"Replika",type:"ai_chat",context:"personal_assistant",confidence:"high"}];for(let h of c){let r=h.keywords.find(u=>y.includes(u));if(r){d={platform:h.platform,type:h.type,context:h.context,confidence:h.confidence,detectionMethod:x(r,t,a,i),detectedAt:new Date().toISOString()};break}}return d.platform==="none"&&(d=b(a,i,s,g)),d}function x(e,t,n,a){return t.includes(e)?"referrer":n.includes(e)?"utm_source":a.includes(e)?"utm_medium":"utm_other"}function b(e,t,n,a){let i=[{condition:t.includes("ai")||t.includes("chat"),platform:"AI_Generic",type:"ai_unknown",context:"utm_tagged",confidence:"medium"},{condition:n.includes("ai-assistant")||n.includes("chatbot"),platform:"AI_Campaign",type:"ai_chat",context:"campaign_driven",confidence:"medium"},{condition:a.includes("ai-generated")||a.includes("llm"),platform:"AI_Content",type:"ai_content",context:"content_discovery",confidence:"medium"}];for(let s of i)if(s.condition)return{platform:s.platform,type:s.type,context:s.context,confidence:s.confidence,detectionMethod:"utm_pattern",detectedAt:new Date().toISOString()};return{platform:"none",type:"unknown",context:"unknown",confidence:"low",detectionMethod:"none",detectedAt:new Date().toISOString()}}function J(e,t){let n=t.platform!=="none";if(!n)return{isAIUser:!1,aiTouchPoints:0,aiEntryPage:null,behaviorPatterns:{skipsBranding:!1,researchIntensive:!1,quickDecision:!1,technicalFocus:!1},platformInsights:{expectedJourney:"n/a",actualVsPredicted:"matched",platformTypicalBehavior:"n/a"}};let a=e.userJourney.find(c=>c.aiContext?.isAIReferral)?.page||e.userJourney[0]?.page||null,i=e.userJourney.filter(c=>c.aiContext?.aiInfluenced).length,s=e.userJourney.map(c=>c.page.toLowerCase()),g=e.userJourney.map(c=>c.type.toLowerCase()),y={skipsBranding:!s.some(c=>c.includes("about")||c==="/")&&s.length>1,researchIntensive:e.userJourney.length>5||g.filter(c=>c.includes("solution")||c.includes("blog")).length>2,quickDecision:s.some(c=>c.includes("contact")||c.includes("demo")||c.includes("pricing"))&&e.userJourney.length<=3,technicalFocus:g.some(c=>c.toLowerCase().includes("api")||c.toLowerCase().includes("developer"))||s.some(c=>c.includes("api")||c.includes("developer"))},d={expectedJourney:k(t.platform,a),actualVsPredicted:F(e,t.platform),platformTypicalBehavior:M(t.platform)};return{isAIUser:n,aiTouchPoints:i,aiEntryPage:a,aiConversionPath:s,aiSessionDuration:N(e),aiPageDepth:e.userJourney.length,behaviorPatterns:y,platformInsights:d}}function k(e,t){return{ChatGPT:"solutions_exploration",Perplexity:"research_deep_dive",Claude:"technical_evaluation",Bing_Copilot:"quick_overview",Google_Gemini:"comparative_analysis"}[e]||"general_exploration"}function F(e,t){let n=e.userJourney.length;return e.userJourney.some(i=>i.page.includes("contact")||i.page.includes("demo")||i.page.includes("pricing"))&&n>=3?"exceeded":n>=2?"matched":"underperformed"}function M(e){return{ChatGPT:"Direct to solutions, conversion-focused",Perplexity:"Research-heavy, multiple page views",Claude:"Technical documentation focus",Bing_Copilot:"Quick overview, efficiency-focused",Google_Gemini:"Comparative analysis, thorough evaluation"}[e]||"General exploration pattern"}function N(e){if(e.userJourney.length<2)return 0;let t=new Date(e.userJourney[0].time),n=new Date(e.userJourney[e.userJourney.length-1].time);return Math.floor((n.getTime()-t.getTime())/1e3)}async function A(){let e="userJourney";function n(){let r=navigator.userAgent;return/tablet|ipad|playbook|silk/i.test(r)?"Tablet":/mobile|iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(r)?"Mobile":"Desktop"}function a(){let r=navigator.userAgent;return r.includes("Chrome")&&!r.includes("Edg")?"Chrome":r.includes("Firefox")?"Firefox":r.includes("Safari")&&!r.includes("Chrome")?"Safari":r.includes("Edg")?"Edge":r.includes("Opera")?"Opera":"Unknown"}function i(){let r=navigator.userAgent;if(/iPhone/.test(r)){let o=r.match(/iPhone\s*([^;]*)/);return o?`iPhone ${o[1].trim()}`:"iPhone"}if(/iPad/.test(r)){let o=r.match(/iPad\s*([^;]*)/);return o?`iPad ${o[1].trim()}`:"iPad"}if(/Android/.test(r)){let o=r.match(/;\s*([^)]*)\s*\)/);return o&&o[1].trim().replace(/wv/g,"").replace(/Build\/.*$/g,"").replace(/\s+/g," ").trim()||"Android Device"}return/Windows/.test(r)?/Windows NT 10/.test(r)?"Windows 10/11 PC":/Windows NT 6\.3/.test(r)?"Windows 8.1 PC":/Windows NT 6\.2/.test(r)?"Windows 8 PC":/Windows NT 6\.1/.test(r)?"Windows 7 PC":"Windows PC":/Macintosh/.test(r)?/Intel/.test(r)?"Mac (Intel)":/Apple Silicon|ARM64/.test(r)?"Mac (Apple Silicon)":"Mac":/Linux/.test(r)?"Linux PC":/BlackBerry/.test(r)?"BlackBerry":/Windows Phone/.test(r)?"Windows Phone":n().charAt(0).toUpperCase()}function s(r){if(!r)return"Unknown";try{let m=new URL(r).hostname.replace(/^www\./,""),f=m.split(".");return f.length>=2?f[0]:m||"Unknown"}catch{return"Unknown"}}function g(r,u){let o=new URLSearchParams(window.location.search),m=o.has("utm_source")||o.has("utm_medium")||o.has("utm_campaign");return r||m?m?{source:o.get("utm_source")||"",medium:o.get("utm_medium")||"",campaign:o.get("utm_campaign")||"",content:o.get("utm_content")||"",term:o.get("utm_term")||""}:{source:s(document.referrer),medium:"organic",campaign:"unknown"}:u||{source:"Unknown",medium:"organic",campaign:"unknown"}}function y(){try{return typeof window.pageCategories<"u"&&Array.isArray(window.pageCategories)&&window.pageCategories.length>0?window.pageCategories:["Not applicable"]}catch(r){return console.warn("Error accessing pageCategories:",r),["Not applicable"]}}function d(){let r=new URLSearchParams(window.location.search);return r.has("utm_source")||r.has("utm_medium")||r.has("utm_campaign")}function c(r){let u=r.split("?")[0].toLowerCase(),o={exactMatches:{"/":"Home","/home":"Home","/blog":"Blog listing","/about-us":"About us","/contact-us":"Contact","/privacy-policy":"Privacy policy","/terms-of-service":"Terms of service","/careers":"Careers","/customer-stories":"Customer stories listing","/events":"Events listing","/infographics":"Infographics listing","/newsroom":"Newsroom","/releases":"Releases listing"},pathStartsWith:[{pattern:"/blog/",type:"Blog"},{pattern:"/customer-stories/",type:"Customer story"},{pattern:"/case-studies/",type:"Case study"},{pattern:"/solutions/",type:"Solution"},{pattern:"/events/",type:"Event"},{pattern:"/news/",type:"News"},{pattern:"/press-releases/",type:"Press release"},{pattern:"/releases/",type:"Release"}]};if(o.exactMatches[u])return o.exactMatches[u];for(let m of o.pathStartsWith)if(u.startsWith(m.pattern))return m.type;return"Other"}function h(r){if(!r.userJourney||r.userJourney.length===0)return!1;let u=new Date(r.userJourney[r.userJourney.length-1].time);return new Date().getTime()-u.getTime()<18e5}return new Promise(r=>{setTimeout(()=>{try{let u=D(),o=null,m=sessionStorage.getItem(e);if(m){let p=JSON.parse(m);h(p)&&(o=p)}if(!o)o={userJourney:[],origin:window.location.hostname,deviceCategory:n(),browser:a(),device:i(),formDetails:{formId:"",formName:"",firstName:"",lastName:"",email:"",phone:""},aiData:u,aiJourneyAnalytics:{isAIUser:!1,aiTouchPoints:0,aiEntryPage:null,behaviorPatterns:{skipsBranding:!1,researchIntensive:!1,quickDecision:!1,technicalFocus:!1},platformInsights:{expectedJourney:"n/a",actualVsPredicted:"matched",platformTypicalBehavior:"n/a"}}};else{let p=U(o.aiData||{platform:"none",type:"unknown",context:"unknown",confidence:"low",detectionMethod:"none",detectedAt:new Date().toISOString()},u);o.aiData=p,o.aiJourneyAnalytics=J(o,p)}if(o.formDetails||(o.formDetails={formId:"",formName:"",firstName:"",lastName:"",email:"",phone:""}),o.device||(o.device=i()),!o){console.error("Journey initialization failed"),r(null);return}let f=window.location.pathname,P=new Date().toISOString(),I=o.userJourney[o.userJourney.length-1];if(I&&I.page===f)I.time=P;else{let p=o.userJourney.length===0,T=p?void 0:o.userJourney[0].utm,C=p&&u.platform!=="none",v=o.aiData.platform!=="none",S={touchPoint:o.userJourney.length+1,page:f,title:document.title||"Untitled",type:c(f),category:y(),time:P,utmVisibility:d()?"visible":"hidden",utm:g(p,T),aiContext:{isAIReferral:C,aiPlatform:v?u.platform:void 0,aiInfluenced:v,aiJourneyStage:C?"entry":o.userJourney.length===0?"exploration":f.includes("pricing")||f.includes("contact")?"decision":"consideration"}};o.userJourney.push(S)}o.aiJourneyAnalytics=J(o,o.aiData),sessionStorage.setItem(e,JSON.stringify(o)),_(),o.aiData.platform!=="none"&&E(o,f),r(o)}catch(u){console.error("Error tracking user journey:",u),r(null)}},200)})}function E(e,t){let n=e.aiData,a=new URL(window.location.href),i={ai_platform:n.platform,ai_type:n.type,ai_context:n.context,ai_confidence:n.confidence,detection_method:n.detectionMethod,landing_page:t,page_category:L(t),utm_source:a.searchParams.get("utm_source")||"",utm_medium:a.searchParams.get("utm_medium")||"",utm_campaign:a.searchParams.get("utm_campaign")||"",utm_content:a.searchParams.get("utm_content")||"",utm_term:a.searchParams.get("utm_term")||"",is_ai_user:e.aiJourneyAnalytics.isAIUser,ai_touchpoints:e.aiJourneyAnalytics.aiTouchPoints,session_start:n.detectedAt};console.debug("AI tracking event data:",i)}function L(e){return e==="/"?"Homepage":e.includes("/platform")?"Platform":e.includes("/solutions")?"Solutions":e.includes("/blog")?"Blog":e.includes("/developers")||e.includes("/api")?"Developer":e.includes("/contact")||e.includes("/demo")?"Contact":e.includes("/pricing")?"Pricing":e.includes("/about")||e.includes("/company")?"Company":"Other"}function _(){document.querySelectorAll("input[ph-form-field], textarea[ph-form-field], select[ph-form-field]").forEach(n=>{n.removeEventListener("input",w),n.removeEventListener("change",w)}),document.querySelectorAll("input[ph-form-field], textarea[ph-form-field], select[ph-form-field]").forEach(n=>{n.addEventListener("input",w),n.addEventListener("change",w)}),O()}function O(){let e=l();if(!e)return;let t=document.querySelector("[ph-form-name]");if(!t)return;let n=t.getAttribute("ph-form-name"),a=t.getAttribute("ph-form-id")||"form-1";n&&(e.formDetails.formName||(e.formDetails.formId=a,e.formDetails.formName=n),sessionStorage.setItem("userJourney",JSON.stringify(e)))}function w(e){let t=e.target,n=t.getAttribute("ph-form-field");if(!n)return;let a=t.closest("[ph-form-name]");if(!a)return;let i=a.getAttribute("ph-form-name"),s=a.getAttribute("ph-form-id")||"form-1";i&&V(i,s,n,t.value)}function V(e,t,n,a){try{let i=l();if(!i)return!1;switch(i.formDetails.formId=t,i.formDetails.formName=e,n){case"firstName":i.formDetails.firstName=a;break;case"lastName":i.formDetails.lastName=a;break;case"email":i.formDetails.email=a;break;case"phone":i.formDetails.phone=a;break;default:return console.warn(`Unknown field: ${n}`),!1}return sessionStorage.setItem("userJourney",JSON.stringify(i)),!0}catch(i){return console.error("Error updating form data:",i),!1}}function l(){try{let e=sessionStorage.getItem("userJourney");return e?JSON.parse(e):null}catch(e){return console.error("Error getting user journey:",e),null}}function R(){sessionStorage.removeItem("userJourney")}function B(e){try{let t=l();if(!t||t.userJourney.length===0)return!1;let n=t.userJourney[t.userJourney.length-1];return n.category=e.length>0?e:["Not applicable"],sessionStorage.setItem("userJourney",JSON.stringify(t)),!0}catch(t){return console.error("Error updating page categories:",t),!1}}function q(e){try{let t=l();if(!t||t.userJourney.length===0)return!1;let n=t.userJourney[t.userJourney.length-1];return n.type=e,sessionStorage.setItem("userJourney",JSON.stringify(t)),!0}catch(t){return console.error("Error updating page type:",t),!1}}function W(){let e=l();if(!e||e.userJourney.length===0)return null;let t=e.userJourney[0],n=e.userJourney[e.userJourney.length-1],a=new Date(n.time).getTime()-new Date(t.time).getTime(),i;if(e.aiJourneyAnalytics.isAIUser){let s=e.userJourney.find(c=>c.aiContext?.isAIReferral),g=s?new Date(s.time):new Date(t.time),y=new Date(n.time).getTime()-g.getTime(),d=e.userJourney.some(c=>c.page.includes("contact")||c.page.includes("demo")||c.page.includes("pricing"));i={aiSessionDuration:Math.floor(y/1e3),aiPages:e.aiJourneyAnalytics.aiTouchPoints,aiConversionTime:d?Math.floor(y/1e3):void 0,aiEngagementScore:G(e),aiValueScore:H(e)}}return{totalPages:e.userJourney.length,sessionDuration:Math.floor(a/1e3),firstPage:t.page,lastPage:n.page,aiStats:i}}function G(e){let t=0;e.aiJourneyAnalytics.isAIUser&&(t+=20);let n=e.userJourney.length;n>=5?t+=30:n>=3?t+=20:n>=2&&(t+=10);let a=e.aiJourneyAnalytics.behaviorPatterns;return a.researchIntensive&&(t+=25),a.technicalFocus&&(t+=20),a.quickDecision&&(t+=15),e.userJourney.some(s=>s.type.toLowerCase().includes("solution")||s.type.toLowerCase().includes("pricing")||s.type.toLowerCase().includes("demo"))&&(t+=15),Math.min(t,100)}function H(e){let t=0;e.aiData.confidence==="high"?t+=20:e.aiData.confidence==="medium"&&(t+=10),["ChatGPT","Claude","Google_Gemini"].includes(e.aiData.platform)&&(t+=15);let a=e.userJourney.map(s=>s.page.toLowerCase());return a.some(s=>s.includes("pricing"))&&(t+=25),a.some(s=>s.includes("contact")||s.includes("demo"))&&(t+=30),a.some(s=>s.includes("api")||s.includes("developer"))&&(t+=20),(e.formDetails.email||e.formDetails.firstName)&&(t+=20),Math.min(t,100)}function $(){let e=l();return e?e.formDetails:null}function z(e){let t=l();return t&&t.formDetails[e]||null}function Y(e,t){try{let n=l();return n?(n.formDetails[e]=t,sessionStorage.setItem("userJourney",JSON.stringify(n)),!0):!1}catch(n){return console.error("Error setting form data:",n),!1}}function Q(e,t){try{let n=l();return n?(n.formDetails.formId=e,n.formDetails.formName=t,sessionStorage.setItem("userJourney",JSON.stringify(n)),!0):!1}catch(n){return console.error("Error setting form details:",n),!1}}function K(){_()}function X(){let e=l();return e?e.aiData:null}function Z(){let e=l();return e?e.aiJourneyAnalytics:null}function j(){let e=l();return e?e.aiJourneyAnalytics.isAIUser:!1}function ee(){let e=l();return e&&e.aiData.platform!=="none"?e.aiData.platform:null}function te(){let e=D(),t=l();return t&&(t.aiData=e,t.aiJourneyAnalytics=J(t,e),sessionStorage.setItem("userJourney",JSON.stringify(t))),e}document.addEventListener("DOMContentLoaded",()=>{A()});document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{A()}):A();window.trackUserJourney=A;window.getUserJourney=l;window.clearUserJourney=R;window.updatePageType=q;window.updatePageCategories=B;window.getJourneyStats=W;window.getFormData=$;window.getFormFieldValue=z;window.setFormData=Y;window.setFormDetails=Q;window.reinitializeFormTracking=K;window.getAIData=X;window.getAIJourneyAnalytics=Z;window.isAIUser=j;window.getAIPlatform=ee;window.forceAIDetection=te;window.detectAIPlatform=D;})();
|
|
1
|
+
"use strict";(()=>{function U(e,t){return t.platform!=="none"?t:e}function D(){let t=document.referrer.toLowerCase(),n=new URL(window.location.href),a=n.searchParams.get("utm_source")?.toLowerCase()||"",i=n.searchParams.get("utm_medium")?.toLowerCase()||"",s=n.searchParams.get("utm_campaign")?.toLowerCase()||"",g=n.searchParams.get("utm_content")?.toLowerCase()||"",p=`${t} ${a} ${i} ${s} ${g}`,d={platform:"none",type:"unknown",context:"unknown",confidence:"low",detectionMethod:"none",detectedAt:new Date().toISOString()},c=[{keywords:["chatgpt","openai","chat.openai"],platform:"ChatGPT",type:"ai_chat",context:"conversational_query",confidence:"high"},{keywords:["perplexity"],platform:"Perplexity",type:"ai_search",context:"research_query",confidence:"high"},{keywords:["claude","anthropic"],platform:"Claude",type:"ai_chat",context:"conversational_query",confidence:"high"},{keywords:["bing","copilot","microsoft-copilot"],platform:"Bing_Copilot",type:"ai_chat",context:"conversational_query",confidence:"medium"},{keywords:["gemini","bard","google-ai"],platform:"Google_Gemini",type:"ai_chat",context:"conversational_query",confidence:"high"},{keywords:["you.com","you-ai"],platform:"You_AI",type:"ai_search",context:"search_query",confidence:"medium"},{keywords:["character.ai","character"],platform:"Character_AI",type:"ai_chat",context:"character_interaction",confidence:"high"},{keywords:["poe","quora-poe"],platform:"Poe",type:"ai_chat",context:"conversational_query",confidence:"high"},{keywords:["huggingface","hf-chat"],platform:"HuggingFace",type:"ai_chat",context:"technical_query",confidence:"medium"},{keywords:["replika"],platform:"Replika",type:"ai_chat",context:"personal_assistant",confidence:"high"}];for(let h of c){let r=h.keywords.find(u=>p.includes(u));if(r){d={platform:h.platform,type:h.type,context:h.context,confidence:h.confidence,detectionMethod:x(r,t,a,i),detectedAt:new Date().toISOString()};break}}return d.platform==="none"&&(d=b(a,i,s,g)),d}function x(e,t,n,a){return t.includes(e)?"referrer":n.includes(e)?"utm_source":a.includes(e)?"utm_medium":"utm_other"}function b(e,t,n,a){let i=[{condition:t.includes("ai")||t.includes("chat"),platform:"AI_Generic",type:"ai_unknown",context:"utm_tagged",confidence:"medium"},{condition:n.includes("ai-assistant")||n.includes("chatbot"),platform:"AI_Campaign",type:"ai_chat",context:"campaign_driven",confidence:"medium"},{condition:a.includes("ai-generated")||a.includes("llm"),platform:"AI_Content",type:"ai_content",context:"content_discovery",confidence:"medium"}];for(let s of i)if(s.condition)return{platform:s.platform,type:s.type,context:s.context,confidence:s.confidence,detectionMethod:"utm_pattern",detectedAt:new Date().toISOString()};return{platform:"none",type:"unknown",context:"unknown",confidence:"low",detectionMethod:"none",detectedAt:new Date().toISOString()}}function J(e,t){let n=t.platform!=="none";if(!n)return{isAIUser:!1,aiTouchPoints:0,aiEntryPage:null,behaviorPatterns:{skipsBranding:!1,researchIntensive:!1,quickDecision:!1,technicalFocus:!1},platformInsights:{expectedJourney:"n/a",actualVsPredicted:"matched",platformTypicalBehavior:"n/a"}};let a=e.userJourney.find(c=>c.aiContext?.isAIReferral)?.page||e.userJourney[0]?.page||null,i=e.userJourney.filter(c=>c.aiContext?.aiInfluenced).length,s=e.userJourney.map(c=>c.page.toLowerCase()),g=e.userJourney.map(c=>c.type.toLowerCase()),p={skipsBranding:!s.some(c=>c.includes("about")||c==="/")&&s.length>1,researchIntensive:e.userJourney.length>5||g.filter(c=>c.includes("solution")||c.includes("blog")).length>2,quickDecision:s.some(c=>c.includes("contact")||c.includes("demo")||c.includes("pricing"))&&e.userJourney.length<=3,technicalFocus:g.some(c=>c.toLowerCase().includes("api")||c.toLowerCase().includes("developer"))||s.some(c=>c.includes("api")||c.includes("developer"))},d={expectedJourney:k(t.platform,a),actualVsPredicted:F(e,t.platform),platformTypicalBehavior:M(t.platform)};return{isAIUser:n,aiTouchPoints:i,aiEntryPage:a,aiConversionPath:s,aiSessionDuration:N(e),aiPageDepth:e.userJourney.length,behaviorPatterns:p,platformInsights:d}}function k(e,t){return{ChatGPT:"solutions_exploration",Perplexity:"research_deep_dive",Claude:"technical_evaluation",Bing_Copilot:"quick_overview",Google_Gemini:"comparative_analysis"}[e]||"general_exploration"}function F(e,t){let n=e.userJourney.length;return e.userJourney.some(i=>i.page.includes("contact")||i.page.includes("demo")||i.page.includes("pricing"))&&n>=3?"exceeded":n>=2?"matched":"underperformed"}function M(e){return{ChatGPT:"Direct to solutions, conversion-focused",Perplexity:"Research-heavy, multiple page views",Claude:"Technical documentation focus",Bing_Copilot:"Quick overview, efficiency-focused",Google_Gemini:"Comparative analysis, thorough evaluation"}[e]||"General exploration pattern"}function N(e){if(e.userJourney.length<2)return 0;let t=new Date(e.userJourney[0].time),n=new Date(e.userJourney[e.userJourney.length-1].time);return Math.floor((n.getTime()-t.getTime())/1e3)}async function A(){let e="userJourney";function n(){let r=navigator.userAgent;return/tablet|ipad|playbook|silk/i.test(r)?"Tablet":/mobile|iphone|ipod|android|blackberry|opera|mini|windows\sce|palm|smartphone|iemobile/i.test(r)?"Mobile":"Desktop"}function a(){let r=navigator.userAgent;return r.includes("Chrome")&&!r.includes("Edg")?"Chrome":r.includes("Firefox")?"Firefox":r.includes("Safari")&&!r.includes("Chrome")?"Safari":r.includes("Edg")?"Edge":r.includes("Opera")?"Opera":"Unknown"}function i(){let r=navigator.userAgent;if(/iPhone/.test(r)){let o=r.match(/iPhone\s*([^;]*)/);return o?`iPhone ${o[1].trim()}`:"iPhone"}if(/iPad/.test(r)){let o=r.match(/iPad\s*([^;]*)/);return o?`iPad ${o[1].trim()}`:"iPad"}if(/Android/.test(r)){let o=r.match(/;\s*([^)]*)\s*\)/);return o&&o[1].trim().replace(/wv/g,"").replace(/Build\/.*$/g,"").replace(/\s+/g," ").trim()||"Android Device"}return/Windows/.test(r)?/Windows NT 10/.test(r)?"Windows 10/11 PC":/Windows NT 6\.3/.test(r)?"Windows 8.1 PC":/Windows NT 6\.2/.test(r)?"Windows 8 PC":/Windows NT 6\.1/.test(r)?"Windows 7 PC":"Windows PC":/Macintosh/.test(r)?/Intel/.test(r)?"Mac (Intel)":/Apple Silicon|ARM64/.test(r)?"Mac (Apple Silicon)":"Mac":/Linux/.test(r)?"Linux PC":/BlackBerry/.test(r)?"BlackBerry":/Windows Phone/.test(r)?"Windows Phone":n().charAt(0).toUpperCase()}function s(r){if(!r)return"Unknown";try{let m=new URL(r).hostname.replace(/^www\./,""),f=m.split(".");return f.length>=2?f[0]:m||"Unknown"}catch{return"Unknown"}}function g(r,u){let o=new URLSearchParams(window.location.search),m=o.has("utm_source")||o.has("utm_medium")||o.has("utm_campaign");return r||m?m?{source:o.get("utm_source")||"",medium:o.get("utm_medium")||"",campaign:o.get("utm_campaign")||"",content:o.get("utm_content")||"",term:o.get("utm_term")||""}:{source:s(document.referrer),medium:"organic",campaign:"unknown"}:u||{source:"Unknown",medium:"organic",campaign:"unknown"}}function p(){try{return typeof window.pageCategories<"u"&&Array.isArray(window.pageCategories)&&window.pageCategories.length>0?window.pageCategories:["Not applicable"]}catch(r){return console.warn("Error accessing pageCategories:",r),["Not applicable"]}}function d(){let r=new URLSearchParams(window.location.search);return r.has("utm_source")||r.has("utm_medium")||r.has("utm_campaign")}function c(r){let u=r.split("?")[0].toLowerCase(),o={exactMatches:{"/":"Home","/home":"Home","/blog":"Blog listing","/about-us":"About us","/contact-us":"Contact","/privacy-policy":"Privacy policy","/terms-of-service":"Terms of service","/careers":"Careers","/customer-stories":"Customer stories listing","/events":"Events listing","/infographics":"Infographics listing","/newsroom":"Newsroom","/releases":"Releases listing"},pathStartsWith:[{pattern:"/blog/",type:"Blog"},{pattern:"/customer-stories/",type:"Customer story"},{pattern:"/case-studies/",type:"Case study"},{pattern:"/solutions/",type:"Solution"},{pattern:"/events/",type:"Event"},{pattern:"/news/",type:"News"},{pattern:"/press-releases/",type:"Press release"},{pattern:"/releases/",type:"Release"}]};if(o.exactMatches[u])return o.exactMatches[u];for(let m of o.pathStartsWith)if(u.startsWith(m.pattern))return m.type;return"Other"}function h(r){if(!r.userJourney||r.userJourney.length===0)return!1;let u=new Date(r.userJourney[r.userJourney.length-1].time);return new Date().getTime()-u.getTime()<18e5}return new Promise(r=>{setTimeout(()=>{try{let u=D(),o=null,m=sessionStorage.getItem(e);if(m){let y=JSON.parse(m);h(y)&&(o=y)}if(!o)o={userJourney:[],origin:window.location.hostname,deviceCategory:n(),browser:a(),device:i(),formDetails:{formId:"",formName:"",firstName:"",lastName:"",email:"",phone:""},aiData:u,aiJourneyAnalytics:{isAIUser:!1,aiTouchPoints:0,aiEntryPage:null,behaviorPatterns:{skipsBranding:!1,researchIntensive:!1,quickDecision:!1,technicalFocus:!1},platformInsights:{expectedJourney:"n/a",actualVsPredicted:"matched",platformTypicalBehavior:"n/a"}}};else{let y=U(o.aiData||{platform:"none",type:"unknown",context:"unknown",confidence:"low",detectionMethod:"none",detectedAt:new Date().toISOString()},u);o.aiData=y,o.aiJourneyAnalytics=J(o,y)}if(o.formDetails||(o.formDetails={formId:"",formName:"",firstName:"",lastName:"",email:"",phone:""}),o.device||(o.device=i()),!o){console.error("Journey initialization failed"),r(null);return}let f=window.location.pathname,P=new Date().toISOString(),I=o.userJourney[o.userJourney.length-1];if(I&&I.page===f)I.time=P;else{let y=o.userJourney.length===0,T=y?void 0:o.userJourney[0].utm,C=y&&u.platform!=="none",v=o.aiData.platform!=="none",S={touchPoint:o.userJourney.length+1,page:f,title:document.title||"Untitled",type:c(f),category:p(),time:P,utmVisibility:d()?"visible":"hidden",utm:g(y,T),aiContext:{isAIReferral:C,aiPlatform:v?u.platform:void 0,aiInfluenced:v,aiJourneyStage:C?"entry":o.userJourney.length===0?"exploration":f.includes("pricing")||f.includes("contact")?"decision":"consideration"}};o.userJourney.push(S)}o.aiJourneyAnalytics=J(o,o.aiData),sessionStorage.setItem(e,JSON.stringify(o)),_(),o.aiData.platform!=="none"&&E(o,f),r(o)}catch(u){console.error("Error tracking user journey:",u),r(null)}},200)})}function E(e,t){let n=e.aiData,a=new URL(window.location.href),i={ai_platform:n.platform,ai_type:n.type,ai_context:n.context,ai_confidence:n.confidence,detection_method:n.detectionMethod,landing_page:t,page_category:L(t),utm_source:a.searchParams.get("utm_source")||"",utm_medium:a.searchParams.get("utm_medium")||"",utm_campaign:a.searchParams.get("utm_campaign")||"",utm_content:a.searchParams.get("utm_content")||"",utm_term:a.searchParams.get("utm_term")||"",is_ai_user:e.aiJourneyAnalytics.isAIUser,ai_touchpoints:e.aiJourneyAnalytics.aiTouchPoints,session_start:n.detectedAt};console.debug("AI tracking event data:",i)}function L(e){return e==="/"?"Homepage":e.includes("/platform")?"Platform":e.includes("/solutions")?"Solutions":e.includes("/blog")?"Blog":e.includes("/developers")||e.includes("/api")?"Developer":e.includes("/contact")||e.includes("/demo")?"Contact":e.includes("/pricing")?"Pricing":e.includes("/about")||e.includes("/company")?"Company":"Other"}function _(){document.querySelectorAll("input[ph-form-field], textarea[ph-form-field], select[ph-form-field]").forEach(n=>{n.removeEventListener("input",w),n.removeEventListener("change",w)}),document.querySelectorAll("input[ph-form-field], textarea[ph-form-field], select[ph-form-field]").forEach(n=>{n.addEventListener("input",w),n.addEventListener("change",w)}),O()}function O(){let e=l();if(!e)return;let t=document.querySelector("[ph-form-name]");if(!t)return;let n=t.getAttribute("ph-form-name"),a=t.getAttribute("ph-form-id")||"form-1";n&&(e.formDetails.formName||(e.formDetails.formId=a,e.formDetails.formName=n),sessionStorage.setItem("userJourney",JSON.stringify(e)))}function w(e){let t=e.target,n=t.getAttribute("ph-form-field");if(!n)return;let a=t.closest("[ph-form-name]");if(!a)return;let i=a.getAttribute("ph-form-name"),s=a.getAttribute("ph-form-id")||"form-1";i&&V(i,s,n,t.value)}function V(e,t,n,a){try{let i=l();if(!i)return!1;switch(i.formDetails.formId=t,i.formDetails.formName=e,n){case"firstName":i.formDetails.firstName=a;break;case"lastName":i.formDetails.lastName=a;break;case"email":i.formDetails.email=a;break;case"phone":i.formDetails.phone=a;break;default:return console.warn(`Unknown field: ${n}`),!1}return sessionStorage.setItem("userJourney",JSON.stringify(i)),!0}catch(i){return console.error("Error updating form data:",i),!1}}function l(){try{let e=sessionStorage.getItem("userJourney");return e?JSON.parse(e):null}catch(e){return console.error("Error getting user journey:",e),null}}function R(){sessionStorage.removeItem("userJourney")}function B(e){try{let t=l();if(!t||t.userJourney.length===0)return!1;let n=t.userJourney[t.userJourney.length-1];return n.category=e.length>0?e:["Not applicable"],sessionStorage.setItem("userJourney",JSON.stringify(t)),!0}catch(t){return console.error("Error updating page categories:",t),!1}}function q(e){try{let t=l();if(!t||t.userJourney.length===0)return!1;let n=t.userJourney[t.userJourney.length-1];return n.type=e,sessionStorage.setItem("userJourney",JSON.stringify(t)),!0}catch(t){return console.error("Error updating page type:",t),!1}}function W(){let e=l();if(!e||e.userJourney.length===0)return null;let t=e.userJourney[0],n=e.userJourney[e.userJourney.length-1],a=new Date(n.time).getTime()-new Date(t.time).getTime(),i;if(e.aiJourneyAnalytics.isAIUser){let s=e.userJourney.find(c=>c.aiContext?.isAIReferral),g=s?new Date(s.time):new Date(t.time),p=new Date(n.time).getTime()-g.getTime(),d=e.userJourney.some(c=>c.page.includes("contact")||c.page.includes("demo")||c.page.includes("pricing"));i={aiSessionDuration:Math.floor(p/1e3),aiPages:e.aiJourneyAnalytics.aiTouchPoints,aiConversionTime:d?Math.floor(p/1e3):void 0,aiEngagementScore:G(e),aiValueScore:H(e)}}return{totalPages:e.userJourney.length,sessionDuration:Math.floor(a/1e3),firstPage:t.page,lastPage:n.page,aiStats:i}}function G(e){let t=0;e.aiJourneyAnalytics.isAIUser&&(t+=20);let n=e.userJourney.length;n>=5?t+=30:n>=3?t+=20:n>=2&&(t+=10);let a=e.aiJourneyAnalytics.behaviorPatterns;return a.researchIntensive&&(t+=25),a.technicalFocus&&(t+=20),a.quickDecision&&(t+=15),e.userJourney.some(s=>s.type.toLowerCase().includes("solution")||s.type.toLowerCase().includes("pricing")||s.type.toLowerCase().includes("demo"))&&(t+=15),Math.min(t,100)}function H(e){let t=0;e.aiData.confidence==="high"?t+=20:e.aiData.confidence==="medium"&&(t+=10),["ChatGPT","Claude","Google_Gemini"].includes(e.aiData.platform)&&(t+=15);let a=e.userJourney.map(s=>s.page.toLowerCase());return a.some(s=>s.includes("pricing"))&&(t+=25),a.some(s=>s.includes("contact")||s.includes("demo"))&&(t+=30),a.some(s=>s.includes("api")||s.includes("developer"))&&(t+=20),(e.formDetails.email||e.formDetails.firstName)&&(t+=20),Math.min(t,100)}function $(){let e=l();return e?e.formDetails:null}function z(e){let t=l();return t&&t.formDetails[e]||null}function Y(e,t){try{let n=l();return n?(n.formDetails[e]=t,sessionStorage.setItem("userJourney",JSON.stringify(n)),!0):!1}catch(n){return console.error("Error setting form data:",n),!1}}function Q(e,t){try{let n=l();return n?(n.formDetails.formId=e,n.formDetails.formName=t,sessionStorage.setItem("userJourney",JSON.stringify(n)),!0):!1}catch(n){return console.error("Error setting form details:",n),!1}}function K(){_()}function X(){let e=l();return e?e.aiData:null}function Z(){let e=l();return e?e.aiJourneyAnalytics:null}function j(){let e=l();return e?e.aiJourneyAnalytics.isAIUser:!1}function ee(){let e=l();return e&&e.aiData.platform!=="none"?e.aiData.platform:null}function te(){let e=D(),t=l();return t&&(t.aiData=e,t.aiJourneyAnalytics=J(t,e),sessionStorage.setItem("userJourney",JSON.stringify(t))),e}document.addEventListener("DOMContentLoaded",()=>{A()});document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>{A()}):A();window.trackUserJourney=A;window.getUserJourney=l;window.clearUserJourney=R;window.updatePageType=q;window.updatePageCategories=B;window.getJourneyStats=W;window.getFormData=$;window.getFormFieldValue=z;window.setFormData=Y;window.setFormDetails=Q;window.reinitializeFormTracking=K;window.getAIData=X;window.getAIJourneyAnalytics=Z;window.isAIUser=j;window.getAIPlatform=ee;window.forceAIDetection=te;window.detectAIPlatform=D;})();
|
package/package.json
CHANGED