@sentientui/core 0.21.2 → 0.22.0
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.
- package/dist/chunk-2RH7I6AP.mjs +2 -0
- package/dist/chunk-2RH7I6AP.mjs.map +1 -0
- package/dist/chunk-QNEYUJJJ.mjs +2 -0
- package/dist/chunk-QNEYUJJJ.mjs.map +1 -0
- package/dist/{index-BvHshOSe.d.ts → index-BbrtAtrY.d.ts} +29 -4
- package/dist/{index-BheP9F8h.d.cts → index-CXxvWxCB.d.cts} +29 -4
- package/dist/index-engagement.js +1 -1
- package/dist/index-engagement.js.map +1 -1
- package/dist/index-engagement.mjs +1 -1
- package/dist/index-engagement.mjs.map +1 -1
- package/dist/index-graph.d.cts +4 -4
- package/dist/index-graph.d.ts +4 -4
- package/dist/index-graph.js +1 -1
- package/dist/index-graph.js.map +1 -1
- package/dist/index-graph.mjs +1 -1
- package/dist/index-graph.mjs.map +1 -1
- package/dist/index-local.d.cts +1 -1
- package/dist/index-local.d.ts +1 -1
- package/dist/index-server.d.cts +8 -1
- package/dist/index-server.d.ts +8 -1
- package/dist/index-server.js +1 -1
- package/dist/index-server.js.map +1 -1
- package/dist/index-server.mjs +1 -1
- package/dist/index-server.mjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/package.json +2 -2
- package/dist/chunk-MYT7OJBV.mjs +0 -2
- package/dist/chunk-MYT7OJBV.mjs.map +0 -1
- package/dist/chunk-NA6AFNTM.mjs +0 -2
- package/dist/chunk-NA6AFNTM.mjs.map +0 -1
|
@@ -207,7 +207,7 @@ type Assignment = {
|
|
|
207
207
|
type AssignmentCache = {
|
|
208
208
|
get(componentId: string, segment: string): Assignment | null;
|
|
209
209
|
set(componentId: string, segment: string, assignment: Assignment): void;
|
|
210
|
-
|
|
210
|
+
/** Drops every entry, memory and localStorage — the forget-me path. */
|
|
211
211
|
clear(): void;
|
|
212
212
|
};
|
|
213
213
|
|
|
@@ -242,8 +242,6 @@ type GraphClient = {
|
|
|
242
242
|
/** One-shot batch sync of all current page nodes to the backend. */
|
|
243
243
|
syncOnce(): void;
|
|
244
244
|
snapshot(): GraphSnapshot;
|
|
245
|
-
serialize(): string;
|
|
246
|
-
restore(data: string): void;
|
|
247
245
|
destroy(): void;
|
|
248
246
|
};
|
|
249
247
|
/**
|
|
@@ -339,6 +337,24 @@ declare function renderPrePaintScript(apiKey: string): string;
|
|
|
339
337
|
declare const PROD_KEYLESS_ERROR = "[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.";
|
|
340
338
|
declare const LOCAL_MODE_BANNER = "[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.";
|
|
341
339
|
|
|
340
|
+
/**
|
|
341
|
+
* The bare, pre-namespacing session cookie name. Still read as a FALLBACK
|
|
342
|
+
* everywhere the suffixed name is read, so visitors who got their identity
|
|
343
|
+
* before per-project namespacing keep it instead of being minted a fresh one.
|
|
344
|
+
*/
|
|
345
|
+
declare const LEGACY_SESSION_COOKIE_NAME = "_snt_uid";
|
|
346
|
+
/**
|
|
347
|
+
* The one place the session cookie's name is decided. The writer (session.ts)
|
|
348
|
+
* and every reader (core/server.ts SSR helper, graph sync, react devtools) must
|
|
349
|
+
* call THIS — when namespacing landed, the writer moved to the suffixed name
|
|
350
|
+
* while three readers kept the bare `_snt_uid`, so every SSR request for a
|
|
351
|
+
* returning visitor missed the cookie and minted a fresh orphan session (quota
|
|
352
|
+
* inflation, broken sticky assignments and persona continuity), and graph sync
|
|
353
|
+
* sent `sessionId: undefined`. Deriving both sides from one function makes that
|
|
354
|
+
* drift impossible, and index.test.ts pins the reader against the writer.
|
|
355
|
+
*/
|
|
356
|
+
declare function sessionCookieName(apiKey?: string): string;
|
|
357
|
+
|
|
342
358
|
type MicroSignalEmitter = (signalType: 'rage_click' | 'text_copy' | 'scroll_hesitation' | 'tab_loss', extra?: Record<string, unknown>) => void;
|
|
343
359
|
type MicroSignalType = Parameters<MicroSignalEmitter>[0];
|
|
344
360
|
/**
|
|
@@ -350,6 +366,15 @@ declare function attachMicroSignalDetectors(emit: MicroSignalEmitter, node: Elem
|
|
|
350
366
|
tabLoss?: boolean;
|
|
351
367
|
}): () => void;
|
|
352
368
|
|
|
369
|
+
/**
|
|
370
|
+
* @internal Wires an alternate entry point's init as grantConsent()'s upgrade
|
|
371
|
+
* path for `apiKey`. The /graph entry calls this when its init is gated on
|
|
372
|
+
* consent: without it, grantConsent() upgraded through the LEAN init, so a
|
|
373
|
+
* graph-configured page granted consent but never mounted the scanner (the
|
|
374
|
+
* graph resources exist only in the /graph entry). No-op unless the entry is
|
|
375
|
+
* actually upgradeable — DNT-blocked and local entries register no hook.
|
|
376
|
+
*/
|
|
377
|
+
declare function _registerConsentUpgradeInit(apiKey: string, reinit: (config: SentientConfig) => SentientClient): void;
|
|
353
378
|
type SentientConfig = {
|
|
354
379
|
apiKey: string;
|
|
355
380
|
context: 'landing' | 'ecommerce' | 'saas' | 'marketplace';
|
|
@@ -594,4 +619,4 @@ declare function grantConsent(apiKey?: string): void;
|
|
|
594
619
|
*/
|
|
595
620
|
declare function init(config: SentientConfig): SentientClient;
|
|
596
621
|
|
|
597
|
-
export {
|
|
622
|
+
export { type MicroSignalType as $, type AssignResult as A, BLOCK_ALIGNS as B, type ComponentGoalOptions as C, type ComponentWeightEntry as D, type CompoundLocator as E, type DecideInput as F, type DecideOutcome as G, type DecisionSnapshot as H, type EventQueue as I, type EventType as J, type GoalDefinition as K, type GoalOptions as L, type GraphClient as M, type GraphConfig as N, type GraphSnapshot as O, type GridBlock as P, type HeadingBlock as Q, type ImageBlock as R, LEGACY_SESSION_COOKIE_NAME as S, LOCAL_MODE_BANNER as T, type LinkBlock as U, MAX_BLOCK_ARMS as V, MAX_BLOCK_CHILDREN as W, MAX_BLOCK_DEPTH as X, MAX_BLOCK_NODES as Y, MAX_BLOCK_TEXT_LEN as Z, type MicroSignalEmitter as _, type Assignment as a, PROD_KEYLESS_ERROR as a0, type PageNode as a1, type QueueConfig as a2, SNAPSHOT_STORAGE_KEY_PREFIX as a3, type SectionMapEntry as a4, type SentientClient as a5, type SentientConfig as a6, type SentientEvent as a7, type SessionConfig as a8, type SessionManager as a9, type SitePalette as aa, type SlotConfigEntry as ab, type SlotOps as ac, type SpacerBlock as ad, type StackBlock as ae, type TextBlock as af, type WeightEntry as ag, _registerConsentUpgradeInit as ah, attachMicroSignalDetectors as ai, grantConsent as aj, init as ak, isDoNotTrackEnabled as al, readSnapshot as am, renderPrePaintScript as an, sanitizePageUrl as ao, sessionCookieName as ap, writeSnapshot as aq, type AssignmentCache as b, BLOCK_EMPHASES as c, BLOCK_FITS as d, BLOCK_GAPS as e, BLOCK_GRID_COLUMNS as f, BLOCK_HEADING_LEVELS as g, BLOCK_JUSTIFIES as h, BLOCK_RATIOS as i, BLOCK_SIZES as j, BLOCK_TEXT_ALIGNS as k, BLOCK_TONES as l, BLOCK_WEIGHTS as m, type BadgeBlock as n, type BlockAlign as o, type BlockEmphasis as p, type BlockFit as q, type BlockGap as r, type BlockJustify as s, type BlockNode as t, type BlockRatio as u, type BlockSize as v, type BlockTextAlign as w, type BlockTone as x, type BlockWeight as y, type ButtonBlock as z };
|
|
@@ -207,7 +207,7 @@ type Assignment = {
|
|
|
207
207
|
type AssignmentCache = {
|
|
208
208
|
get(componentId: string, segment: string): Assignment | null;
|
|
209
209
|
set(componentId: string, segment: string, assignment: Assignment): void;
|
|
210
|
-
|
|
210
|
+
/** Drops every entry, memory and localStorage — the forget-me path. */
|
|
211
211
|
clear(): void;
|
|
212
212
|
};
|
|
213
213
|
|
|
@@ -242,8 +242,6 @@ type GraphClient = {
|
|
|
242
242
|
/** One-shot batch sync of all current page nodes to the backend. */
|
|
243
243
|
syncOnce(): void;
|
|
244
244
|
snapshot(): GraphSnapshot;
|
|
245
|
-
serialize(): string;
|
|
246
|
-
restore(data: string): void;
|
|
247
245
|
destroy(): void;
|
|
248
246
|
};
|
|
249
247
|
/**
|
|
@@ -339,6 +337,24 @@ declare function renderPrePaintScript(apiKey: string): string;
|
|
|
339
337
|
declare const PROD_KEYLESS_ERROR = "[sentient] No API key configured \u2014 nothing is being learned. Set NEXT_PUBLIC_SENTIENT_API_KEY or pass localMode: true for local development.";
|
|
340
338
|
declare const LOCAL_MODE_BANNER = "[sentient] Local mode \u2014 decisions are simulated on-device and nothing is sent over the network. Add an API key to learn from real traffic.";
|
|
341
339
|
|
|
340
|
+
/**
|
|
341
|
+
* The bare, pre-namespacing session cookie name. Still read as a FALLBACK
|
|
342
|
+
* everywhere the suffixed name is read, so visitors who got their identity
|
|
343
|
+
* before per-project namespacing keep it instead of being minted a fresh one.
|
|
344
|
+
*/
|
|
345
|
+
declare const LEGACY_SESSION_COOKIE_NAME = "_snt_uid";
|
|
346
|
+
/**
|
|
347
|
+
* The one place the session cookie's name is decided. The writer (session.ts)
|
|
348
|
+
* and every reader (core/server.ts SSR helper, graph sync, react devtools) must
|
|
349
|
+
* call THIS — when namespacing landed, the writer moved to the suffixed name
|
|
350
|
+
* while three readers kept the bare `_snt_uid`, so every SSR request for a
|
|
351
|
+
* returning visitor missed the cookie and minted a fresh orphan session (quota
|
|
352
|
+
* inflation, broken sticky assignments and persona continuity), and graph sync
|
|
353
|
+
* sent `sessionId: undefined`. Deriving both sides from one function makes that
|
|
354
|
+
* drift impossible, and index.test.ts pins the reader against the writer.
|
|
355
|
+
*/
|
|
356
|
+
declare function sessionCookieName(apiKey?: string): string;
|
|
357
|
+
|
|
342
358
|
type MicroSignalEmitter = (signalType: 'rage_click' | 'text_copy' | 'scroll_hesitation' | 'tab_loss', extra?: Record<string, unknown>) => void;
|
|
343
359
|
type MicroSignalType = Parameters<MicroSignalEmitter>[0];
|
|
344
360
|
/**
|
|
@@ -350,6 +366,15 @@ declare function attachMicroSignalDetectors(emit: MicroSignalEmitter, node: Elem
|
|
|
350
366
|
tabLoss?: boolean;
|
|
351
367
|
}): () => void;
|
|
352
368
|
|
|
369
|
+
/**
|
|
370
|
+
* @internal Wires an alternate entry point's init as grantConsent()'s upgrade
|
|
371
|
+
* path for `apiKey`. The /graph entry calls this when its init is gated on
|
|
372
|
+
* consent: without it, grantConsent() upgraded through the LEAN init, so a
|
|
373
|
+
* graph-configured page granted consent but never mounted the scanner (the
|
|
374
|
+
* graph resources exist only in the /graph entry). No-op unless the entry is
|
|
375
|
+
* actually upgradeable — DNT-blocked and local entries register no hook.
|
|
376
|
+
*/
|
|
377
|
+
declare function _registerConsentUpgradeInit(apiKey: string, reinit: (config: SentientConfig) => SentientClient): void;
|
|
353
378
|
type SentientConfig = {
|
|
354
379
|
apiKey: string;
|
|
355
380
|
context: 'landing' | 'ecommerce' | 'saas' | 'marketplace';
|
|
@@ -594,4 +619,4 @@ declare function grantConsent(apiKey?: string): void;
|
|
|
594
619
|
*/
|
|
595
620
|
declare function init(config: SentientConfig): SentientClient;
|
|
596
621
|
|
|
597
|
-
export {
|
|
622
|
+
export { type MicroSignalType as $, type AssignResult as A, BLOCK_ALIGNS as B, type ComponentGoalOptions as C, type ComponentWeightEntry as D, type CompoundLocator as E, type DecideInput as F, type DecideOutcome as G, type DecisionSnapshot as H, type EventQueue as I, type EventType as J, type GoalDefinition as K, type GoalOptions as L, type GraphClient as M, type GraphConfig as N, type GraphSnapshot as O, type GridBlock as P, type HeadingBlock as Q, type ImageBlock as R, LEGACY_SESSION_COOKIE_NAME as S, LOCAL_MODE_BANNER as T, type LinkBlock as U, MAX_BLOCK_ARMS as V, MAX_BLOCK_CHILDREN as W, MAX_BLOCK_DEPTH as X, MAX_BLOCK_NODES as Y, MAX_BLOCK_TEXT_LEN as Z, type MicroSignalEmitter as _, type Assignment as a, PROD_KEYLESS_ERROR as a0, type PageNode as a1, type QueueConfig as a2, SNAPSHOT_STORAGE_KEY_PREFIX as a3, type SectionMapEntry as a4, type SentientClient as a5, type SentientConfig as a6, type SentientEvent as a7, type SessionConfig as a8, type SessionManager as a9, type SitePalette as aa, type SlotConfigEntry as ab, type SlotOps as ac, type SpacerBlock as ad, type StackBlock as ae, type TextBlock as af, type WeightEntry as ag, _registerConsentUpgradeInit as ah, attachMicroSignalDetectors as ai, grantConsent as aj, init as ak, isDoNotTrackEnabled as al, readSnapshot as am, renderPrePaintScript as an, sanitizePageUrl as ao, sessionCookieName as ap, writeSnapshot as aq, type AssignmentCache as b, BLOCK_EMPHASES as c, BLOCK_FITS as d, BLOCK_GAPS as e, BLOCK_GRID_COLUMNS as f, BLOCK_HEADING_LEVELS as g, BLOCK_JUSTIFIES as h, BLOCK_RATIOS as i, BLOCK_SIZES as j, BLOCK_TEXT_ALIGNS as k, BLOCK_TONES as l, BLOCK_WEIGHTS as m, type BadgeBlock as n, type BlockAlign as o, type BlockEmphasis as p, type BlockFit as q, type BlockGap as r, type BlockJustify as s, type BlockNode as t, type BlockRatio as u, type BlockSize as v, type BlockTextAlign as w, type BlockTone as x, type BlockWeight as y, type ButtonBlock as z };
|
package/dist/index-engagement.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var b=Object.defineProperty;var Q=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames,W=Object.getOwnPropertySymbols;var j=Object.prototype.hasOwnProperty,Y=Object.prototype.propertyIsEnumerable;var B=(t,e,n)=>e in t?b(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,T=(t,e)=>{for(var n in e||(e={}))j.call(e,n)&&B(t,n,e[n]);if(W)for(var n of W(e))Y.call(e,n)&&B(t,n,e[n]);return t};var z=(t,e)=>{for(var n in e)b(t,n,{get:e[n],enumerable:!0})},J=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of V(e))!j.call(t,a)&&a!==n&&b(t,a,{get:()=>e[a],enumerable:!(r=Q(e,a))||r.enumerable});return t};var X=t=>J(b({},"__esModule",{value:!0}),t);var ae={};z(ae,{SEMANTIC_TYPES:()=>E,classifyFeatures:()=>R,classifySection:()=>C,featuresFromElement:()=>I,startEngagementCapture:()=>H});module.exports=X(ae);var E=["pricing","hero","social_proof","cta","features","faq","comparison","trust","navigation","generic"],Z=[["pricing",/\b(pricing|price|plans?|subscriptions?|per month|\/mo|tier)\b/i],["faq",/\b(faq|frequently asked|common questions?)\b/i],["comparison",/\b(compare|comparison|versus|vs\.)\b/i],["social_proof",/\b(testimonial|reviews?|trusted by|loved by|customers?|logos|rated|case stud)\b/i],["trust",/\b(security|guarantee|privacy|compliance|secure|gdpr|soc ?2|encrypt)\b/i],["features",/\b(features?|how it works|benefits?|capabilit|what you get)\b/i]],ee=[["pricing",/(?:[$€£]\s?\d[\d,.]*\s*(?:\/|per\s)\s*(?:mo|month|yr|year|seat|user))|(?:\b(?:starter|basic|pro|growth|premium|enterprise)\b[^.]{0,60}[$€£]\s?\d)/i],["social_proof",/(?:★{2,})|(?:\b\d(?:\.\d)?\s*(?:out of|\/)\s*5\b)|(?:\brated\b)|(?:["“][^"”]{20,160}["”]\s*[—–-]\s*[A-Z][a-z]+)/],["trust",/\b(?:money[- ]back guarantee|refund(?:s)? within|encrypted|soc ?2|iso ?27001|gdpr[- ]compliant|cancel anytime)\b/i],["comparison",/\b(?:vs|versus)\b\.?[^.!?]{0,80}\b(?:compare|comparison|plans?|features?|alternative)\b|\bhow (?:we|it) compares?\b/i]];function te(t){var n;let e=t.querySelector("h1, h2, h3");return((n=e==null?void 0:e.textContent)!=null?n:"").slice(0,160)}function R(t){if(t.tag==="nav"||t.tag==="footer")return{type:"navigation",strength:"weak"};let e=`${t.idClass} ${t.headingText}`.toLowerCase();for(let[n,r]of Z)if(r.test(e))return{type:n,strength:"strong"};for(let[n,r]of ee)if(r.test(t.bodyText))return{type:n,strength:"strong"};return t.actionCount>=1&&t.textLength>0&&t.textLength<200?{type:"cta",strength:"weak"}:t.tag==="header"?{type:"hero",strength:"weak"}:/\b(hero|headline|banner)\b/i.test(e)?{type:"hero",strength:"weak"}:{type:"generic",strength:"weak"}}function I(t){var n,r;let e=((n=t.textContent)!=null?n:"").replace(/\s+/g," ").trim();return{tag:t.tagName.toLowerCase(),idClass:`${t.id} ${String((r=t.className)!=null?r:"")}`,headingText:te(t),bodyText:e.slice(0,2e3),actionCount:t.querySelectorAll('a, button, [role="button"]').length,textLength:e.length}}function C(t){return R(I(t)).type}var ne=require("@sentientui/policy");function U(t,e,n,r){let a=[];{let l=!1,c=[],p=()=>{if(l)return;let m=Date.now();for(c.push(m);c.length>0&&m-c[0]>500;)c.shift();c.length>=3&&(l=!0,t("rage_click"))};e.addEventListener("click",p),a.push(()=>e.removeEventListener("click",p))}{let d=!1,g=l=>{if(d||!(l.target instanceof Node)||!e.contains(l.target)&&e!==l.target)return;d=!0;let c=typeof window!="undefined"?window.getSelection():null,p=c?c.toString().length:0;t("text_copy",{selectionLength:p})};document.addEventListener("copy",g),a.push(()=>document.removeEventListener("copy",g))}{let d=!1,g=!1,l=null,c=()=>{l!==null&&(clearTimeout(l),l=null)},p=()=>{d||!g||(c(),l=setTimeout(()=>{!d&&g&&(d=!0,t("scroll_hesitation"))},3e3))},m=()=>{c(),p()},w=v=>{for(let S of v)g=S.intersectionRatio>.3,g?p():c()},y=new IntersectionObserver(w,{threshold:[.3]});y.observe(e),window.addEventListener("scroll",m,{passive:!0}),a.push(()=>{y.disconnect(),window.removeEventListener("scroll",m),c()})}if((r==null?void 0:r.tabLoss)!==!1){let d=!1,g=n!=null?n:Date.now(),l=()=>{if(d||document.visibilityState!=="hidden")return;let c=Date.now()-g;c<15e3&&(d=!0,t("tab_loss",{timeOnPage:c}))};document.addEventListener("visibilitychange",l),a.push(()=>document.removeEventListener("visibilitychange",l))}return()=>{for(let d of a)d()}}function F(){return typeof navigator!="undefined"&&navigator.globalPrivacyControl===!0?!0:[typeof navigator!="undefined"?navigator.doNotTrack:void 0,typeof window!="undefined"?window.doNotTrack:void 0,typeof navigator!="undefined"?navigator.msDoNotTrack:void 0].some(e=>e==="1"||e==="yes")}var se="section, header, footer, nav, main > div, [data-sentient-section]",oe=2e4;function ie(t){let e=Array.from(t.querySelectorAll(se)),n=e.filter(r=>e.filter(a=>a!==r&&r.contains(a)).length<2);return n.filter(r=>!n.some(a=>a!==r&&a.contains(r)))}function re(t,e,n,r){try{fetch(`${e}/v1/section-map`,{method:"POST",keepalive:!0,headers:{"content-type":"application/json",authorization:`Bearer ${t}`},body:JSON.stringify({pageUrl:n,sections:r})}).catch(()=>{})}catch(a){}}var k=()=>{};function H(t,e){var O,D,P,M,N,K,L,G,$;let n=(O=e.doc)!=null?O:typeof document!="undefined"?document:void 0;if(!n||typeof IntersectionObserver=="undefined"||F()||!e.apiKey||!e.apiKey.startsWith("pk_"))return k;let r=((D=e.apiBase)!=null?D:"https://api.sentient-ui.com").replace(/\/+$/,"").replace(/\/v1$/,""),a=ie(n);if(a.length===0)return k;let d=new Map,g=new Map,l=new Map;for(let s of a){let o=s.getAttribute("data-sentient-type"),i=o&&E.includes(o)?o:null,u=(M=i!=null?i:(P=e.typeOf)==null?void 0:P.call(e,s))!=null?M:C(s),h=`nc-${u}`;d.set(s,h),g.set(h,u),i?l.set(h,"markup"):l.has(h)||l.set(h,"auto")}let c=(G=(L=(K=(N=n.defaultView)!=null?N:typeof window!="undefined"?window:void 0)==null?void 0:K.location)==null?void 0:L.pathname)!=null?G:"/";re(e.apiKey,r,c,[...g.entries()].map(([s,o])=>{var i;return{componentId:s,semanticType:o,source:(i=l.get(s))!=null?i:"auto"}}));let p=new Map,m=s=>{let o=p.get(s);return o||(o={ms:0,scroll:0,enterAt:null,intersecting:!1},p.set(s,o)),o},w=new IntersectionObserver(s=>{for(let o of s){let i=d.get(o.target);if(!i)continue;let u=m(i);o.isIntersecting?(u.intersecting=!0,u.enterAt=Date.now(),o.intersectionRatio>u.scroll&&(u.scroll=o.intersectionRatio)):(u.intersecting=!1,u.enterAt!=null&&(u.ms+=Date.now()-u.enterAt,u.enterAt=null))}},{threshold:[0,.25,.5,.75,1]});for(let s of d.keys())w.observe(s);let y=()=>{let s=Date.now();for(let[o,i]of p)if(i.enterAt!=null&&(i.ms+=s-i.enterAt,i.enterAt=null),!(i.ms<=0)){try{t.track({projectId:e.apiKey,componentId:o,eventType:"dwell",payload:{dwell_time:Math.round(i.ms),scroll_depth:Number(i.scroll.toFixed(2))}})}catch(u){}i.ms=0}},v=()=>{if(n.hidden)y();else{let s=Date.now();for(let o of p.values())o.intersecting&&(o.enterAt=s)}},S=!1,x=s=>{if(y(),s!=null&&s.persisted){S=!0;return}try{w.disconnect()}catch(o){}},_=s=>{if(!(s!=null&&s.persisted)||!S)return;S=!1;let o=Date.now();for(let i of p.values())i.enterAt=i.intersecting&&!n.hidden?o:null};n.addEventListener("visibilitychange",v);let f=($=n.defaultView)!=null?$:typeof window!="undefined"?window:void 0;f==null||f.addEventListener("pagehide",x),f==null||f.addEventListener("pageshow",_);let q=setInterval(()=>{if(n.hidden||S)return;y();let s=Date.now();for(let o of p.values())o.intersecting&&(o.enterAt=s)},oe),A=[];return e.microSignals&&[...d.entries()].forEach(([s,o],i)=>{A.push(U((u,h={})=>{try{t.track({projectId:e.apiKey,componentId:o,eventType:"micro_signal",payload:T({signalType:u},h)})}catch(le){}},s,void 0,{tabLoss:i===0}))}),()=>{y(),clearInterval(q),n.removeEventListener("visibilitychange",v),f==null||f.removeEventListener("pagehide",x),f==null||f.removeEventListener("pageshow",_);for(let s of A)s();try{w.disconnect()}catch(s){}}}0&&(module.exports={SEMANTIC_TYPES,classifyFeatures,classifySection,featuresFromElement,startEngagementCapture});
|
|
2
2
|
//# sourceMappingURL=index-engagement.js.map
|