@mparticle/web-rokt-kit 3.6.1 → 3.7.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/Rokt-Kit.common.js +1 -1
- package/dist/Rokt-Kit.esm.js +216 -183
- package/dist/Rokt-Kit.iife.js +1 -1
- package/package.json +1 -1
package/dist/Rokt-Kit.common.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Le=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],Oe=new Set(Le);function me(i){return Oe.has(i.toLowerCase())}function v(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];me(s)||(e[s]=t[s])}return e}function m(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function g(i){return typeof i=="string"}function U(i){return typeof i=="function"}function w(i){return i==null?!0:typeof i=="string"?i.length===0:typeof i=="object"?Object.keys(i).length===0:!1}function z(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function Ee(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}const h="mp-rokt-kit",ee="__rokt_ls_probe__";function H(){try{return window.localStorage.setItem(ee,"1"),window.localStorage.removeItem(ee),!0}catch{return!1}}const A=()=>window.localStorage;function $(i,e=A){try{const t=e().getItem(i);return t===null?null:JSON.parse(t)}catch{return null}}function _e(i,e,t=A){try{return t().setItem(i,JSON.stringify(e)),!0}catch{return!1}}function Ne(i,e=A){try{e().removeItem(i)}catch{}}function O(i,e,t=A){const n=$(i,t);return m(n)?n[e]:void 0}function x(i,e,t,n=A){const r=$(i,n),s=m(r)?{...r}:{};return s[e]=t,_e(i,s,n)}function Y(i,e,t=A){const n=$(i,t);if(!m(n)||!(e in n))return;const r={...n};delete r[e],Object.keys(r).length===0?Ne(i,t):_e(i,r,t)}const q="pageViews",D="utmParams",Ie=25,Ue=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function ye(i){return i.slice(-Ie)}function te(){const i=O(h,q);return Array.isArray(i)?i:[]}function Ce(i){const e=ye(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(x(h,q,n))return n.length}return 0}function ie(){Y(h,q)}function Ke(i){const e=ye(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=s&&u?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function De(i){if(O(h,D)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ue){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!x(h,D,t)){const r=H()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function Me(){const i=O(h,D);return m(i)?i:null}function ne(){Y(h,D)}function Fe(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return z(e)}const J=[{accountId:"2919171670744024290",pathname:"/checkout",targetPageIdentifier:"prod.rokt.conf",attributeKeys:["email","amount","customertype","eventvenue","firstname","lastname","member_status","billingzipcode","currency"],optionalAttributeKeys:["firstname","lastname"]},{accountId:"2550745407543340151",pathname:"/checkout",targetPageIdentifier:"RoktExperience",attributeKeys:["email","amount","firstname","lastname","cartItems","customertype","loyaltytier","paymenttype","ccbin"],optionalAttributeKeys:["loyaltytier","paymenttype","ccbin"]},{accountId:"3236704179315511296",pathname:"/check-out/pay",targetPageIdentifier:"confirmation_page",attributeKeys:["email","totalprice","firstname","lastname","loyaltytier"],optionalAttributeKeys:["firstname","lastname","loyaltytier"]}],xe=6e4;function Ye(i){return m(i)&&typeof i.expiresAt=="number"&&m(i.attributes)}function Ge(i,e){return`activePreselect:${i}:${e}`}function je(i){const e=O(h,i);return Ye(e)?e:null}function He(i,e){x(h,i,{expiresAt:Date.now()+xe,attributes:e})}const Ve=5*6e4;function M(){return window.sessionStorage}function We(i){return m(i)&&typeof i.expiresAt=="number"&&g(i.pathname)&&g(i.identifier)&&m(i.attributes)&&g(i.mpid)}function B(i){return`pendingPreselect:${i}`}function ze(i){const e=B(i),t=O(h,e,M);return We(t)?t.expiresAt<=Date.now()?(Y(h,e,M),null):t:null}function $e(i,e,t,n,r){return x(h,B(i),{expiresAt:Date.now()+Ve,pathname:e,identifier:t,attributes:n,mpid:r},M)}function T(i){Y(h,B(i),M)}function L(i,e){const t={fired:"PRESELECT_FIRED",missed:"PRESELECT_MISSED",queued:"PRESELECT_QUEUED",skipped:"PRESELECT_SKIPPED"};return{message:`Rokt Kit: preselect ${i} [reason=${e}]`,code:t[i]}}function qe(i,e){if(i)return J.find(t=>t.accountId===i&&t.pathname===e)}function Je(i,e){if(!(!i||!g(e)))return J.find(t=>t.accountId===i&&t.targetPageIdentifier===e)}function Be(i,e){return i?J.some(t=>t.accountId===i&&t.attributeKeys.includes(e)):!1}function Qe(){return{pending:[]}}function j(i,e){const t=i.pending.findIndex(n=>n.pathname===e.pathname);if(t>=0){i.pending[t]=e;return}i.pending.push(e)}function V(i){if(!i?.getUserIdentities)return!1;const e=i.getUserIdentities().userIdentities;return e?Object.keys(e).some(t=>{const n=e[t];return g(n)&&n.length>0}):!1}function Se(i){const e=i?.getMPID?.();return e==null?null:String(e)}function re(i,e,t){const n=i.filteredUser?.getAllUserAttributes?.()||{},r=new Set((t.optionalAttributeKeys??[]).map(c=>c.toLowerCase())),s={},o=[];for(const c of t.attributeKeys){const u=i.getEventAttributeValue(e,c),l=w(u)?i.userAttributes[c]??n[c]:u;if(w(l)){r.has(c.toLowerCase())||o.push(c);continue}s[c]=l}return{collected:s,missingKeys:o}}function Xe(i,e){Promise.resolve(i.selectPlacements(e)).catch(t=>{const n=t instanceof Error?t.message:String(t);i.log({message:`Rokt Kit: Preselect selectPlacements call failed: ${n}`,code:"PRESELECT_DISPATCH_FAILED"})})}function Ae(i,e,t,n,r,s){const o=Ge(e,t),c=je(o),u=!!c&&JSON.stringify(c.attributes)===JSON.stringify(r);if(c&&c.expiresAt>Date.now()&&u){i.logPlacementDiagnostic(L("skipped","active_preselection"));return}He(o,r),i.logPlacementDiagnostic(L("fired",s)),Xe(i,{attributes:r,preselect:!0,identifier:n,omitUrl:!0})}function Ze(i,e){if(!e.accountId||!e.isKitReady())return;const t=ze(e.accountId);if(t){if(i.pending.some(n=>n.pathname===t.pathname)){T(e.accountId);return}if(!e.isPreselectionEnabled()){T(e.accountId);return}V(e.filteredUser)&&(T(e.accountId),Se(e.filteredUser)===t.mpid&&Ae(e,e.accountId,t.identifier,t.identifier,t.attributes,"recovered"))}}function Pe(i,e,t,n=window.location.pathname){const r=qe(e.accountId,n);if(!r)return;if(!e.isKitReady()){const c=[],u=Se(e.filteredUser);if(e.accountId&&u&&V(e.filteredUser)){const{collected:l,missingKeys:f}=re(e,t,r);if(f.length===0){const P=v(l);$e(e.accountId,n,r.targetPageIdentifier,P,u)||c.push(L("queued","persist_failed"))}}j(i,{event:t,pathname:n,storedDiagnostics:c});return}if(!e.isPreselectionEnabled())return;if(!V(e.filteredUser)){e.logPlacementDiagnostic(L("missed","no_valid_identity")),j(i,{event:t,pathname:n});return}const{collected:s,missingKeys:o}=re(e,t,r);if(o.length>0){for(const c of o)e.logPlacementDiagnostic(L("missed",`missing_attribute:${c}`));j(i,{event:t,pathname:n});return}Ae(e,e.accountId||"",n,r.targetPageIdentifier,s,"fired")}function et(i,e,t=window.location.pathname){if(Ze(i,e),i.pending.length===0)return;const n=i.pending;i.pending=[],n.forEach(({event:r,pathname:s,storedDiagnostics:o})=>{s===t&&(e.isKitReady()&&e.isPreselectionEnabled()&&o?.forEach(c=>e.logPlacementDiagnostic(c)),Pe(i,e,r,s))})}function tt(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function it(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function nt(i){i.lifecycle="attached"}function rt(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function st(i){i.lifecycle="terminated"}function ot(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function ct(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const d="Rokt",C=181,at="selectPlacements",lt="apps.roktecommerce.com",ut=.1,dt="ThankYouPageJourney",ht="rokt-launcher",gt="rokt-thank-you-element",ft="userIdentifiedInWorkspace",pt=3,mt=2,Et="page_events",_t="page_view_attributes",It="mparticle_session_id",yt="mparticle_device_id",se=500,Q={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},y={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},St="apps.rokt-api.com",At="/v1/log",Pt="/v1/errors",bt=10;function a(){return window.mParticle}function oe(i,e){const n=[G(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function ce(i){return[G(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function G(i){const e=i!==void 0?i:St;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function be(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return G(r)+t}function ae(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function K(i){if(!i)return[];try{return JSON.parse(i.replace(/"/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function le(i){const e=i?K(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(dt)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Rt(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function ue(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function de(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!g(n.value)||!g(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function he(i,e,t){return a().generateHash([i,e,t].join(""))}function kt(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"3.6.1";return i&&(n+="_"+i),n}function W(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function ge(i,e){const t=Ee(window.location.origin);if(S._allowedOriginHashes.indexOf(t)===-1||Math.random()>=ut)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?G(i):"https://apps.rokt.com";W(c+"/v1/wsdk-init/index.html?"+o),W("https://"+lt+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function vt(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function wt(){return typeof window<"u"?window.location?.href:void 0}function Tt(){return typeof window<"u"?window.navigator?.userAgent:void 0}class Re{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>bt}}class F{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new Re,this._isEnabled=vt()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||Q.UNKNOWN_ERROR,url:wt(),deviceInfo:Tt(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const f=new Error("HTTP "+l.status+" from log endpoint");throw f.statusCode=l.status,f}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class fe{constructor(e,t,n,r,s){this._transport=new F(e,t,n,r,s),this._errorUrl=be(e?.errorUrl,e?.integrationDomain,Pt)}report(e){if(!e)return;const t=e.severity||y.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class pe{constructor(e,t,n,r,s,o){this._transport=new F(e,n,r,s,o),this._placementDiagnosticTransport=new F(e,n,r,s),this._loggingUrl=be(e?.loggingUrl,e?.integrationDomain,At),this._errorReportingService=t}log(e){e&&this._send(this._transport,e)}logPlacementDiagnostic(e){e&&this._send(this._placementDiagnosticTransport,e)}_send(e,t){e.send(this._loggingUrl,y.INFO,t.message,t.code,void 0,n=>{if(this._errorReportingService){const r=typeof n.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+n.message,code:Q.LOG_DELIVERY_FAILURE,severity:r?y.ERROR:y.WARNING})}})}}function Lt(i){const e=z(window.location.href),t=i.EventAttributes?.title||document.title,n=Fe(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const _=class _{constructor(){this.name=d,this.id=C,this.moduleId=C,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null,this._launcherAttachState=tt(),this.accountId=null,this._preselectState=Qe()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||n[t]===void 0?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!g(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!g(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(w(s))continue;let o=!0;for(let c=0;c<s.length;c++)if(!this.doesEventMatchRule(e,s[c])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=z(window.location.href);const n=te(),r=Lt(e);n.push(r);const s=Math.min(n.length,Ie),o=Ce(n);if(o===0){const c=H()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else o<s&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${s} to ${o} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=H()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isPreselectionEnabled(){return this.launcher?.enablePreselection===!0}buildCacheMatchKeys(e){if(!this.isPreselectionEnabled())return;const t=Je(this.accountId,e);if(t)return t.attributeKeys}buildPreselectHost(){return{accountId:this.accountId,filteredUser:this.filters.filteredUser,userAttributes:this.userAttributes,isKitReady:()=>this.isKitReady(),isPreselectionEnabled:()=>this.isPreselectionEnabled(),getEventAttributeValue:(e,t)=>this.getEventAttributeValue(e,t),logPlacementDiagnostic:e=>this.loggingService?.logPlacementDiagnostic(e),log:e=>this.loggingService?.log(e),selectPlacements:e=>this.selectPlacements(e)}}flushPendingPreselectDispatches(){et(this._preselectState,this.buildPreselectHost())}isLauncherReadyToAttach(){return!!window.Rokt&&U(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[_.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!m(e))return;const t=a().EventType.Other;a().logEvent(at,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&U(t.setIntegrationAttribute)&&t.setIntegrationAttribute(C,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(U(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){it(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let s;return this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await Rt([...n],o),this.initRoktLauncher(o)}).catch(o=>{const c=this._launcherAttachState.lifecycle==="attached";if(st(this._launcherAttachState),!c){const u=o instanceof Error?o.message:String(o);this.loggingService?.log({message:`Rokt Kit: Failed to attach Rokt launcher: ${u}`,code:"LAUNCHER_ATTACH_FAILED"})}console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return ct(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,nt(this._launcherAttachState);const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,ge(this.domain,this.integrationName),a().Rokt.attachKit(this),this.flushPendingPreselectDispatches()}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=t.getVariationMap()[o].id,s),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,s){const o=e,c=o.accountId;this.accountId=c||null,this.userAttributes=v(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=K(o.placementEventMapping);this.placementEventMappingLookup=ue(u);const l=K(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=de(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const f=a().Rokt?.domain,{roktExtensionsQueryParams:P,legacyRoktExtensions:b,loadThankYouElement:N}=le(o.roktExtensions),E={...a().Rokt?.launcherOptions||{}};this.integrationName=kt(E.integrationName),E.integrationName=this.integrationName,this.domain=f;const R={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:f,isLoggingEnabled:a().config?.isLoggingEnabled===!0},I=new fe(R,this.integrationName,window.__rokt_li_guid__,o.accountId),k=new pe(R,I,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=I,this.loggingService=k,this.isTargetingDisabled())try{ie(),ne()}catch(p){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:y.INFO,stackTrace:p instanceof Error?p.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(I),a()._registerLoggingService&&a()._registerLoggingService(k),n?(this.testHelpers={generateLauncherScript:oe,generateThankYouElementScript:ce,extractRoktExtensionConfig:le,hashEventMessage:he,parseSettingsString:K,generateMappedEventLookup:ue,generateMappedEventAttributeLookup:de,sendAdBlockMeasurementSignals:ge,createAutoRemovedIframe:W,djb2:Ee,setAllowedOriginHashes:p=>{_._allowedOriginHashes=p},ReportingTransport:F,ErrorReportingService:fe,LoggingService:pe,RateLimiter:Re,ErrorCodes:Q,WSDKErrorSeverity:y,resetLauncherAttachState:()=>ot(this._launcherAttachState)},this.attachLauncher(c,E),"Successfully initialized: "+d):(N&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),ae(gt,ce(f),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:p=>{console.error("Error loading Rokt Thank You Element script:",p)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,E,b):(ae(ht,oe(f,P),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,E,b):console.error("Rokt object is not available after script load.")},onError:p=>{console.error("Error loading Rokt launcher script:",p)}}),this.captureTiming(_.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===pt&&(De(this.loggingService),this.capturePageView(e),Pe(this._preselectState,this.buildPreselectHost(),e)),e.EventDataType===mt&&(ie(),ne(),this.accountId&&T(this.accountId))),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(U(a().Rokt?.setLocalSessionAttribute)&&(w(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!w(this.placementEventMappingLookup))){const t=he(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return me(e)||(this.userAttributes[e]=t),Be(this.accountId,e)&&this.flushPendingPreselectDispatches(),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=v(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t);const n=this.handleIdentityComplete(e,"onUserIdentified");return this.flushPendingPreselectDispatches(),n}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const l=r[u];g(l)&&l.length>0&&(s[u]=l)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(u=>`${u}=${s[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,s,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.accountId&&T(this.accountId),this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(s=>setTimeout(s,se))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,se))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...v(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,u=c?c.getMPID():null;let l;s?s.filterUserAttributes?l=s.filterUserAttributes(r,o):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=v(l);const f=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},P=this.returnUserIdentities(c),b=this.returnLocalSessionAttributes(),N=Ke(te()),E=Me(),R=this.readMpSessionId(),I=this.readMpDeviceId(),k={...P,...l,...f,...b,...N.length?{[Et]:JSON.stringify(N)}:{},...E?{[_t]:E}:{},...this.userIdentifiedInWorkspace?{[ft]:!0}:{},...R?{[It]:R}:{},...I?{[yt]:I}:{},mpid:u},p=this.buildCacheMatchKeys(typeof e.identifier=="string"?e.identifier:void 0),ke={...e,attributes:k,...p!==void 0?{cacheMatchKeys:p}:{}},X=this.launcher.selectPlacements(ke),Z=e.preselect===!0,ve=()=>{Z||this.logSelectPlacementsEvent(k)};return Promise.resolve(X).then(we=>{if(!Z)return we?.context?.sessionId?.then(Te=>this.setRoktSessionId(Te))}).catch(()=>{}).finally(ve),X}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!g(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}terminate(){return this.isKitReady()?(rt(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};_._allowedOriginHashes=[-553112570,549508659],_.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},_.EMAIL_SHA256_KEY="emailsha256";let S=_;function Ot(){return C}function Nt(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!m(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}m(i.kits)?i.kits[d]={constructor:S}:(i.kits={},i.kits[d]={constructor:S}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:S,getId:Ot});exports.register=Nt;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ne=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],Ue=new Set(Ne);function me(i){return Ue.has(i.toLowerCase())}function y(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];me(s)||(e[s]=t[s])}return e}function m(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function g(i){return typeof i=="string"}function U(i){return typeof i=="function"}function S(i){return i==null?!0:typeof i=="string"?i.length===0:typeof i=="object"?Object.keys(i).length===0:!1}function z(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function Ee(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}const h="mp-rokt-kit",ee="__rokt_ls_probe__";function H(){try{return window.localStorage.setItem(ee,"1"),window.localStorage.removeItem(ee),!0}catch{return!1}}const R=()=>window.localStorage;function $(i,e=R){try{const t=e().getItem(i);return t===null?null:JSON.parse(t)}catch{return null}}function _e(i,e,t=R){try{return t().setItem(i,JSON.stringify(e)),!0}catch{return!1}}function Ke(i,e=R){try{e().removeItem(i)}catch{}}function O(i,e,t=R){const n=$(i,t);return m(n)?n[e]:void 0}function x(i,e,t,n=R){const r=$(i,n),s=m(r)?{...r}:{};return s[e]=t,_e(i,s,n)}function Y(i,e,t=R){const n=$(i,t);if(!m(n)||!(e in n))return;const r={...n};delete r[e],Object.keys(r).length===0?Ke(i,t):_e(i,r,t)}const q="pageViews",D="utmParams",Ie=25,Ce=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function ye(i){return i.slice(-Ie)}function te(){const i=O(h,q);return Array.isArray(i)?i:[]}function De(i){const e=ye(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(x(h,q,n))return n.length}return 0}function ie(){Y(h,q)}function Me(i){const e=ye(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=s&&u?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function Fe(i){if(O(h,D)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ce){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!x(h,D,t)){const r=H()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function xe(){const i=O(h,D);return m(i)?i:null}function ne(){Y(h,D)}function Ye(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return z(e)}const J=[{accountId:"2919171670744024290",pathname:"/checkout",targetPageIdentifier:"prod.rokt.conf",attributeKeys:["email","customertype","eventvenue","firstname","lastname","member_status","billingzipcode","currency"],optionalAttributeKeys:["firstname","lastname"]},{accountId:"2550745407543340151",pathname:"/checkout",targetPageIdentifier:"RoktExperience",attributeKeys:["email","firstname","lastname","customertype","loyaltytier","paymenttype","ccbin"],optionalAttributeKeys:["loyaltytier","paymenttype","ccbin"]},{accountId:"3236704179315511296",pathname:"/check-out/pay",targetPageIdentifier:"confirmation_page",attributeKeys:["email","firstname","lastname","loyaltytier"],optionalAttributeKeys:["firstname","lastname","loyaltytier"]},{accountId:"2192288523645376337",pathname:"/checkout/*/review",targetPageIdentifier:"ppx-ad-view-prod",attributeKeys:["email","firstname","lastname"],optionalAttributeKeys:["email"]}],Ge=6e4;function je(i){return m(i)&&typeof i.expiresAt=="number"&&m(i.attributes)}function He(i,e){return`activePreselect:${i}:${e}`}function Ve(i){const e=O(h,i);return je(e)?e:null}function We(i,e){x(h,i,{expiresAt:Date.now()+Ge,attributes:e})}const ze=5*6e4;function M(){return window.sessionStorage}function $e(i){return m(i)&&typeof i.expiresAt=="number"&&g(i.pathname)&&g(i.identifier)&&m(i.attributes)&&g(i.mpid)}function B(i){return`pendingPreselect:${i}`}function qe(i){const e=B(i),t=O(h,e,M);return $e(t)?t.expiresAt<=Date.now()?(Y(h,e,M),null):t:null}function Je(i,e,t,n,r){return x(h,B(i),{expiresAt:Date.now()+ze,pathname:e,identifier:t,attributes:n,mpid:r},M)}function L(i){Y(h,B(i),M)}function A(i,e){const t={fired:"PRESELECT_FIRED",missed:"PRESELECT_MISSED",queued:"PRESELECT_QUEUED",skipped:"PRESELECT_SKIPPED"};return{message:`Rokt Kit: preselect ${i} [reason=${e}]`,code:t[i]}}function Be(i,e){if(!i.includes("*"))return i===e;const t=i.split("/"),n=e.split("/");return t.length!==n.length?!1:t.every((r,s)=>r==="*"?n[s]!=="":r===n[s])}function Se(i,e){if(i)return J.find(t=>t.accountId===i&&Be(t.pathname,e))}function Qe(i,e){if(!(!i||!g(e)))return J.find(t=>t.accountId===i&&t.targetPageIdentifier===e)}function Xe(i,e){return i?J.some(t=>t.accountId===i&&t.attributeKeys.includes(e)):!1}function Ze(){return{pending:[]}}function j(i,e){const t=i.pending.findIndex(n=>n.pathname===e.pathname);if(t>=0){i.pending[t]=e;return}i.pending.push(e)}function V(i){if(!i?.getUserIdentities)return!1;const e=i.getUserIdentities().userIdentities;return e?Object.keys(e).some(t=>{const n=e[t];return g(n)&&n.length>0}):!1}function Ae(i){const e=i?.getMPID?.();return e==null?null:String(e)}function Pe(i,e){const t=new Set((i.optionalAttributeKeys??[]).map(n=>n.toLowerCase()));return i.attributeKeys.filter(n=>!t.has(n.toLowerCase())&&S(e[n]))}function re(i,e,t){const n=i.filteredUser?.getAllUserAttributes?.()||{},r={};for(const s of t.attributeKeys){const o=i.getEventAttributeValue(e,s),c=S(o)?i.userAttributes[s]??n[s]:o;S(c)||(r[s]=c)}return{collected:r,missingKeys:Pe(t,r)}}function et(i,e){Promise.resolve(i.selectPlacements(e)).catch(t=>{const n=t instanceof Error?t.message:String(t);i.log({message:`Rokt Kit: Preselect selectPlacements call failed: ${n}`,code:"PRESELECT_DISPATCH_FAILED"})})}function be(i,e,t,n,r,s){const o=He(e,t),c=Ve(o),u=!!c&&JSON.stringify(c.attributes)===JSON.stringify(r);if(c&&c.expiresAt>Date.now()&&u){i.logPlacementDiagnostic(A("skipped","active_preselection"));return}We(o,r),i.logPlacementDiagnostic(A("fired",s)),et(i,{attributes:r,preselect:!0,identifier:n,omitUrl:!0})}function tt(i,e){if(!e.accountId||!e.isKitReady())return;const t=qe(e.accountId);if(!t)return;if(i.pending.some(o=>o.pathname===t.pathname)){L(e.accountId);return}if(!e.isPreselectionEnabled()){L(e.accountId);return}if(!V(e.filteredUser)||(L(e.accountId),Ae(e.filteredUser)!==t.mpid))return;const n=Se(e.accountId,t.pathname);if(!n||n.targetPageIdentifier!==t.identifier)return;const r=y(t.attributes),s=Pe(n,r);if(s.length>0){for(const o of s)e.logPlacementDiagnostic(A("missed",`missing_persisted_attribute:${o}`));return}be(e,e.accountId,t.identifier,t.identifier,r,"recovered")}function Re(i,e,t,n=window.location.pathname){const r=Se(e.accountId,n);if(!r)return;if(!e.isKitReady()){const c=[],u=Ae(e.filteredUser);if(e.accountId&&u&&V(e.filteredUser)){const{collected:l,missingKeys:f}=re(e,t,r);if(f.length===0){const k=y(l);Je(e.accountId,n,r.targetPageIdentifier,k,u)||c.push(A("queued","persist_failed"))}}j(i,{event:t,pathname:n,storedDiagnostics:c});return}if(!e.isPreselectionEnabled())return;if(!V(e.filteredUser)){e.logPlacementDiagnostic(A("missed","no_valid_identity")),j(i,{event:t,pathname:n});return}const{collected:s,missingKeys:o}=re(e,t,r);if(o.length>0){for(const c of o)e.logPlacementDiagnostic(A("missed",`missing_attribute:${c}`));j(i,{event:t,pathname:n});return}be(e,e.accountId||"",n,r.targetPageIdentifier,s,"fired")}function it(i,e,t=window.location.pathname){if(tt(i,e),i.pending.length===0)return;const n=i.pending;i.pending=[],n.forEach(({event:r,pathname:s,storedDiagnostics:o})=>{s===t&&(e.isKitReady()&&e.isPreselectionEnabled()&&o?.forEach(c=>e.logPlacementDiagnostic(c)),Re(i,e,r,s))})}function nt(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function rt(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function st(i){i.lifecycle="attached"}function ot(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function ct(i){i.lifecycle="terminated"}function at(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function lt(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const d="Rokt",K=181,ut="selectPlacements",dt="apps.roktecommerce.com",ht=.1,gt="ThankYouPageJourney",ft="rokt-launcher",pt="rokt-thank-you-element",mt="userIdentifiedInWorkspace",Et=3,_t=2,It="page_events",yt="page_view_attributes",St="mparticle_session_id",At="mparticle_device_id",se=500,Q={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},P={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},Pt="apps.rokt-api.com",bt="/v1/log",Rt="/v1/errors",kt=10;function a(){return window.mParticle}function oe(i,e){const n=[G(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function ce(i){return[G(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function G(i){const e=i!==void 0?i:Pt;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function ke(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return G(r)+t}function ae(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function C(i){if(!i)return[];try{return JSON.parse(i.replace(/"/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function le(i){const e=i?C(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(gt)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function vt(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function ue(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function de(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!g(n.value)||!g(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function he(i,e,t){return a().generateHash([i,e,t].join(""))}function wt(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"3.7.0";return i&&(n+="_"+i),n}function W(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function ge(i,e){const t=Ee(window.location.origin);if(b._allowedOriginHashes.indexOf(t)===-1||Math.random()>=ht)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?G(i):"https://apps.rokt.com";W(c+"/v1/wsdk-init/index.html?"+o),W("https://"+dt+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Tt(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Lt(){return typeof window<"u"?window.location?.href:void 0}function Ot(){return typeof window<"u"?window.navigator?.userAgent:void 0}class ve{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>kt}}class F{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new ve,this._isEnabled=Tt()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||Q.UNKNOWN_ERROR,url:Lt(),deviceInfo:Ot(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const f=new Error("HTTP "+l.status+" from log endpoint");throw f.statusCode=l.status,f}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class fe{constructor(e,t,n,r,s){this._transport=new F(e,t,n,r,s),this._errorUrl=ke(e?.errorUrl,e?.integrationDomain,Rt)}report(e){if(!e)return;const t=e.severity||P.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class pe{constructor(e,t,n,r,s,o){this._transport=new F(e,n,r,s,o),this._placementDiagnosticTransport=new F(e,n,r,s),this._loggingUrl=ke(e?.loggingUrl,e?.integrationDomain,bt),this._errorReportingService=t}log(e){e&&this._send(this._transport,e)}logPlacementDiagnostic(e){e&&this._send(this._placementDiagnosticTransport,e)}_send(e,t){e.send(this._loggingUrl,P.INFO,t.message,t.code,void 0,n=>{if(this._errorReportingService){const r=typeof n.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+n.message,code:Q.LOG_DELIVERY_FAILURE,severity:r?P.ERROR:P.WARNING})}})}}function Nt(i){const e=z(window.location.href),t=i.EventAttributes?.title||document.title,n=Ye(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const _=class _{constructor(){this.name=d,this.id=K,this.moduleId=K,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null,this._launcherAttachState=nt(),this.accountId=null,this._preselectState=Ze()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||n[t]===void 0?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!g(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!g(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(S(s))continue;let o=!0;for(let c=0;c<s.length;c++)if(!this.doesEventMatchRule(e,s[c])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=z(window.location.href);const n=te(),r=Nt(e);n.push(r);const s=Math.min(n.length,Ie),o=De(n);if(o===0){const c=H()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else o<s&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${s} to ${o} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=H()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isPreselectionEnabled(){return this.launcher?.enablePreselection===!0}buildCacheMatchKeys(e){if(!this.isPreselectionEnabled())return;const t=Qe(this.accountId,e);if(t)return t.attributeKeys}buildPreselectHost(){return{accountId:this.accountId,filteredUser:this.filters.filteredUser,userAttributes:this.userAttributes,isKitReady:()=>this.isKitReady(),isPreselectionEnabled:()=>this.isPreselectionEnabled(),getEventAttributeValue:(e,t)=>this.getEventAttributeValue(e,t),logPlacementDiagnostic:e=>this.loggingService?.logPlacementDiagnostic(e),log:e=>this.loggingService?.log(e),selectPlacements:e=>this.selectPlacements(e)}}flushPendingPreselectDispatches(){it(this._preselectState,this.buildPreselectHost())}isLauncherReadyToAttach(){return!!window.Rokt&&U(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[_.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!m(e))return;const t=a().EventType.Other;a().logEvent(ut,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&U(t.setIntegrationAttribute)&&t.setIntegrationAttribute(K,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(U(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){rt(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let s;return this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await vt([...n],o),this.initRoktLauncher(o)}).catch(o=>{const c=this._launcherAttachState.lifecycle==="attached";if(ct(this._launcherAttachState),!c){const u=o instanceof Error?o.message:String(o);this.loggingService?.log({message:`Rokt Kit: Failed to attach Rokt launcher: ${u}`,code:"LAUNCHER_ATTACH_FAILED"})}console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return lt(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,st(this._launcherAttachState);const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,ge(this.domain,this.integrationName),a().Rokt.attachKit(this),this.flushPendingPreselectDispatches()}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=t.getVariationMap()[o].id,s),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,s){const o=e,c=o.accountId;this.accountId=c||null,this.userAttributes=y(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=C(o.placementEventMapping);this.placementEventMappingLookup=ue(u);const l=C(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=de(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const f=a().Rokt?.domain,{roktExtensionsQueryParams:k,legacyRoktExtensions:v,loadThankYouElement:N}=le(o.roktExtensions),E={...a().Rokt?.launcherOptions||{}};this.integrationName=wt(E.integrationName),E.integrationName=this.integrationName,this.domain=f;const w={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:f,isLoggingEnabled:a().config?.isLoggingEnabled===!0},I=new fe(w,this.integrationName,window.__rokt_li_guid__,o.accountId),T=new pe(w,I,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=I,this.loggingService=T,this.isTargetingDisabled())try{ie(),ne()}catch(p){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:P.INFO,stackTrace:p instanceof Error?p.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(I),a()._registerLoggingService&&a()._registerLoggingService(T),n?(this.testHelpers={generateLauncherScript:oe,generateThankYouElementScript:ce,extractRoktExtensionConfig:le,hashEventMessage:he,parseSettingsString:C,generateMappedEventLookup:ue,generateMappedEventAttributeLookup:de,sendAdBlockMeasurementSignals:ge,createAutoRemovedIframe:W,djb2:Ee,setAllowedOriginHashes:p=>{_._allowedOriginHashes=p},ReportingTransport:F,ErrorReportingService:fe,LoggingService:pe,RateLimiter:ve,ErrorCodes:Q,WSDKErrorSeverity:P,resetLauncherAttachState:()=>at(this._launcherAttachState)},this.attachLauncher(c,E),"Successfully initialized: "+d):(N&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),ae(pt,ce(f),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:p=>{console.error("Error loading Rokt Thank You Element script:",p)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,E,v):(ae(ft,oe(f,k),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,E,v):console.error("Rokt object is not available after script load.")},onError:p=>{console.error("Error loading Rokt launcher script:",p)}}),this.captureTiming(_.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===Et&&(Fe(this.loggingService),this.capturePageView(e),Re(this._preselectState,this.buildPreselectHost(),e)),e.EventDataType===_t&&(ie(),ne(),this.accountId&&L(this.accountId))),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(U(a().Rokt?.setLocalSessionAttribute)&&(S(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!S(this.placementEventMappingLookup))){const t=he(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return me(e)||(this.userAttributes[e]=t),Xe(this.accountId,e)&&this.flushPendingPreselectDispatches(),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=y(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t);const n=this.handleIdentityComplete(e,"onUserIdentified");return this.flushPendingPreselectDispatches(),n}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const l=r[u];g(l)&&l.length>0&&(s[u]=l)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(u=>`${u}=${s[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,s,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.accountId&&L(this.accountId),this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(s=>setTimeout(s,se))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,se))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...y(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,u=c?c.getMPID():null;let l;s?s.filterUserAttributes?l=s.filterUserAttributes(r,o):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=y(l);const f=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},k=this.returnUserIdentities(c),v=this.returnLocalSessionAttributes(),N=Me(te()),E=xe(),w=this.readMpSessionId(),I=this.readMpDeviceId(),T={...k,...l,...f,...v,...N.length?{[It]:JSON.stringify(N)}:{},...E?{[yt]:E}:{},...this.userIdentifiedInWorkspace?{[mt]:!0}:{},...w?{[St]:w}:{},...I?{[At]:I}:{},mpid:u},p=this.buildCacheMatchKeys(typeof e.identifier=="string"?e.identifier:void 0),we={...e,attributes:T,...p!==void 0?{cacheMatchKeys:p}:{}},X=this.launcher.selectPlacements(we),Z=e.preselect===!0,Te=()=>{Z||this.logSelectPlacementsEvent(T)};return Promise.resolve(X).then(Le=>{if(!Z)return Le?.context?.sessionId?.then(Oe=>this.setRoktSessionId(Oe))}).catch(()=>{}).finally(Te),X}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!g(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}terminate(){return this.isKitReady()?(ot(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};_._allowedOriginHashes=[-553112570,549508659],_.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},_.EMAIL_SHA256_KEY="emailsha256";let b=_;function Ut(){return K}function Kt(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!m(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}m(i.kits)?i.kits[d]={constructor:b}:(i.kits={},i.kits[d]={constructor:b}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:b,getId:Ut});exports.register=Kt;
|
|
2
2
|
//# sourceMappingURL=Rokt-Kit.common.js.map
|
package/dist/Rokt-Kit.esm.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const Ne = [
|
|
2
2
|
"active_time_on_site_ms",
|
|
3
3
|
"billingaddress1",
|
|
4
4
|
"billingaddress2",
|
|
@@ -23,11 +23,11 @@ const Le = [
|
|
|
23
23
|
"shippingstate",
|
|
24
24
|
"shippingzipcode",
|
|
25
25
|
"totalprice"
|
|
26
|
-
],
|
|
26
|
+
], Ue = new Set(Ne);
|
|
27
27
|
function me(i) {
|
|
28
|
-
return
|
|
28
|
+
return Ue.has(i.toLowerCase());
|
|
29
29
|
}
|
|
30
|
-
function
|
|
30
|
+
function y(i) {
|
|
31
31
|
const e = {}, t = i || {}, n = Object.keys(t);
|
|
32
32
|
for (let r = 0; r < n.length; r++) {
|
|
33
33
|
const s = n[r];
|
|
@@ -44,7 +44,7 @@ function g(i) {
|
|
|
44
44
|
function U(i) {
|
|
45
45
|
return typeof i == "function";
|
|
46
46
|
}
|
|
47
|
-
function
|
|
47
|
+
function S(i) {
|
|
48
48
|
return i == null ? !0 : typeof i == "string" ? i.length === 0 : typeof i == "object" ? Object.keys(i).length === 0 : !1;
|
|
49
49
|
}
|
|
50
50
|
function z(i) {
|
|
@@ -69,8 +69,8 @@ function H() {
|
|
|
69
69
|
return !1;
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
|
-
const
|
|
73
|
-
function $(i, e =
|
|
72
|
+
const R = () => window.localStorage;
|
|
73
|
+
function $(i, e = R) {
|
|
74
74
|
try {
|
|
75
75
|
const t = e().getItem(i);
|
|
76
76
|
return t === null ? null : JSON.parse(t);
|
|
@@ -78,35 +78,35 @@ function $(i, e = A) {
|
|
|
78
78
|
return null;
|
|
79
79
|
}
|
|
80
80
|
}
|
|
81
|
-
function _e(i, e, t =
|
|
81
|
+
function _e(i, e, t = R) {
|
|
82
82
|
try {
|
|
83
83
|
return t().setItem(i, JSON.stringify(e)), !0;
|
|
84
84
|
} catch {
|
|
85
85
|
return !1;
|
|
86
86
|
}
|
|
87
87
|
}
|
|
88
|
-
function
|
|
88
|
+
function Ke(i, e = R) {
|
|
89
89
|
try {
|
|
90
90
|
e().removeItem(i);
|
|
91
91
|
} catch {
|
|
92
92
|
}
|
|
93
93
|
}
|
|
94
|
-
function O(i, e, t =
|
|
94
|
+
function O(i, e, t = R) {
|
|
95
95
|
const n = $(i, t);
|
|
96
96
|
return m(n) ? n[e] : void 0;
|
|
97
97
|
}
|
|
98
|
-
function x(i, e, t, n =
|
|
98
|
+
function x(i, e, t, n = R) {
|
|
99
99
|
const r = $(i, n), s = m(r) ? { ...r } : {};
|
|
100
100
|
return s[e] = t, _e(i, s, n);
|
|
101
101
|
}
|
|
102
|
-
function Y(i, e, t =
|
|
102
|
+
function Y(i, e, t = R) {
|
|
103
103
|
const n = $(i, t);
|
|
104
104
|
if (!m(n) || !(e in n))
|
|
105
105
|
return;
|
|
106
106
|
const r = { ...n };
|
|
107
|
-
delete r[e], Object.keys(r).length === 0 ?
|
|
107
|
+
delete r[e], Object.keys(r).length === 0 ? Ke(i, t) : _e(i, r, t);
|
|
108
108
|
}
|
|
109
|
-
const q = "pageViews", D = "utmParams", Ie = 25,
|
|
109
|
+
const q = "pageViews", D = "utmParams", Ie = 25, Ce = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
|
|
110
110
|
function ye(i) {
|
|
111
111
|
return i.slice(-Ie);
|
|
112
112
|
}
|
|
@@ -114,7 +114,7 @@ function te() {
|
|
|
114
114
|
const i = O(h, q);
|
|
115
115
|
return Array.isArray(i) ? i : [];
|
|
116
116
|
}
|
|
117
|
-
function
|
|
117
|
+
function De(i) {
|
|
118
118
|
const e = ye(i);
|
|
119
119
|
for (let t = 0; t < e.length; t++) {
|
|
120
120
|
const n = e.slice(t);
|
|
@@ -126,7 +126,7 @@ function Ce(i) {
|
|
|
126
126
|
function ie() {
|
|
127
127
|
Y(h, q);
|
|
128
128
|
}
|
|
129
|
-
function
|
|
129
|
+
function Me(i) {
|
|
130
130
|
const e = ye(i);
|
|
131
131
|
return e.map((t, n) => {
|
|
132
132
|
const r = t.activeTimeOnSite, s = r !== void 0 && Number.isFinite(r), c = e[n + 1]?.activeTimeOnSite, u = c !== void 0 && Number.isFinite(c), l = s && u ? c - r : void 0;
|
|
@@ -141,11 +141,11 @@ function Ke(i) {
|
|
|
141
141
|
};
|
|
142
142
|
});
|
|
143
143
|
}
|
|
144
|
-
function
|
|
144
|
+
function Fe(i) {
|
|
145
145
|
if (O(h, D) !== void 0)
|
|
146
146
|
return;
|
|
147
147
|
const e = new URLSearchParams(window.location.search), t = {};
|
|
148
|
-
for (const r of
|
|
148
|
+
for (const r of Ce) {
|
|
149
149
|
const s = e.get(r);
|
|
150
150
|
s && (t[r] = s);
|
|
151
151
|
}
|
|
@@ -165,14 +165,14 @@ function De(i) {
|
|
|
165
165
|
code: "UTM_CAPTURE_SUCCESS"
|
|
166
166
|
});
|
|
167
167
|
}
|
|
168
|
-
function
|
|
168
|
+
function xe() {
|
|
169
169
|
const i = O(h, D);
|
|
170
170
|
return m(i) ? i : null;
|
|
171
171
|
}
|
|
172
172
|
function ne() {
|
|
173
173
|
Y(h, D);
|
|
174
174
|
}
|
|
175
|
-
function
|
|
175
|
+
function Ye() {
|
|
176
176
|
const e = document.querySelector('link[rel="canonical"]')?.href;
|
|
177
177
|
if (e)
|
|
178
178
|
return z(e);
|
|
@@ -184,7 +184,6 @@ const J = [
|
|
|
184
184
|
targetPageIdentifier: "prod.rokt.conf",
|
|
185
185
|
attributeKeys: [
|
|
186
186
|
"email",
|
|
187
|
-
"amount",
|
|
188
187
|
"customertype",
|
|
189
188
|
"eventvenue",
|
|
190
189
|
"firstname",
|
|
@@ -201,10 +200,8 @@ const J = [
|
|
|
201
200
|
targetPageIdentifier: "RoktExperience",
|
|
202
201
|
attributeKeys: [
|
|
203
202
|
"email",
|
|
204
|
-
"amount",
|
|
205
203
|
"firstname",
|
|
206
204
|
"lastname",
|
|
207
|
-
"cartItems",
|
|
208
205
|
"customertype",
|
|
209
206
|
"loyaltytier",
|
|
210
207
|
"paymenttype",
|
|
@@ -218,7 +215,6 @@ const J = [
|
|
|
218
215
|
targetPageIdentifier: "confirmation_page",
|
|
219
216
|
attributeKeys: [
|
|
220
217
|
"email",
|
|
221
|
-
"totalprice",
|
|
222
218
|
"firstname",
|
|
223
219
|
"lastname",
|
|
224
220
|
"loyaltytier"
|
|
@@ -228,44 +224,57 @@ const J = [
|
|
|
228
224
|
"lastname",
|
|
229
225
|
"loyaltytier"
|
|
230
226
|
]
|
|
227
|
+
},
|
|
228
|
+
{
|
|
229
|
+
accountId: "2192288523645376337",
|
|
230
|
+
pathname: "/checkout/*/review",
|
|
231
|
+
targetPageIdentifier: "ppx-ad-view-prod",
|
|
232
|
+
attributeKeys: [
|
|
233
|
+
"email",
|
|
234
|
+
"firstname",
|
|
235
|
+
"lastname"
|
|
236
|
+
],
|
|
237
|
+
optionalAttributeKeys: [
|
|
238
|
+
"email"
|
|
239
|
+
]
|
|
231
240
|
}
|
|
232
|
-
],
|
|
233
|
-
function
|
|
241
|
+
], Ge = 6e4;
|
|
242
|
+
function je(i) {
|
|
234
243
|
return m(i) && typeof i.expiresAt == "number" && m(i.attributes);
|
|
235
244
|
}
|
|
236
|
-
function
|
|
245
|
+
function He(i, e) {
|
|
237
246
|
return `activePreselect:${i}:${e}`;
|
|
238
247
|
}
|
|
239
|
-
function
|
|
248
|
+
function Ve(i) {
|
|
240
249
|
const e = O(h, i);
|
|
241
|
-
return
|
|
250
|
+
return je(e) ? e : null;
|
|
242
251
|
}
|
|
243
|
-
function
|
|
252
|
+
function We(i, e) {
|
|
244
253
|
x(h, i, {
|
|
245
|
-
expiresAt: Date.now() +
|
|
254
|
+
expiresAt: Date.now() + Ge,
|
|
246
255
|
attributes: e
|
|
247
256
|
});
|
|
248
257
|
}
|
|
249
|
-
const
|
|
258
|
+
const ze = 5 * 6e4;
|
|
250
259
|
function M() {
|
|
251
260
|
return window.sessionStorage;
|
|
252
261
|
}
|
|
253
|
-
function
|
|
262
|
+
function $e(i) {
|
|
254
263
|
return m(i) && typeof i.expiresAt == "number" && g(i.pathname) && g(i.identifier) && m(i.attributes) && g(i.mpid);
|
|
255
264
|
}
|
|
256
265
|
function B(i) {
|
|
257
266
|
return `pendingPreselect:${i}`;
|
|
258
267
|
}
|
|
259
|
-
function
|
|
268
|
+
function qe(i) {
|
|
260
269
|
const e = B(i), t = O(h, e, M);
|
|
261
|
-
return
|
|
270
|
+
return $e(t) ? t.expiresAt <= Date.now() ? (Y(h, e, M), null) : t : null;
|
|
262
271
|
}
|
|
263
|
-
function
|
|
272
|
+
function Je(i, e, t, n, r) {
|
|
264
273
|
return x(
|
|
265
274
|
h,
|
|
266
275
|
B(i),
|
|
267
276
|
{
|
|
268
|
-
expiresAt: Date.now() +
|
|
277
|
+
expiresAt: Date.now() + ze,
|
|
269
278
|
pathname: e,
|
|
270
279
|
identifier: t,
|
|
271
280
|
attributes: n,
|
|
@@ -274,10 +283,10 @@ function $e(i, e, t, n, r) {
|
|
|
274
283
|
M
|
|
275
284
|
);
|
|
276
285
|
}
|
|
277
|
-
function
|
|
286
|
+
function L(i) {
|
|
278
287
|
Y(h, B(i), M);
|
|
279
288
|
}
|
|
280
|
-
function
|
|
289
|
+
function A(i, e) {
|
|
281
290
|
const t = {
|
|
282
291
|
fired: "PRESELECT_FIRED",
|
|
283
292
|
missed: "PRESELECT_MISSED",
|
|
@@ -289,18 +298,28 @@ function L(i, e) {
|
|
|
289
298
|
code: t[i]
|
|
290
299
|
};
|
|
291
300
|
}
|
|
292
|
-
function
|
|
301
|
+
function Be(i, e) {
|
|
302
|
+
if (!i.includes("*"))
|
|
303
|
+
return i === e;
|
|
304
|
+
const t = i.split("/"), n = e.split("/");
|
|
305
|
+
return t.length !== n.length ? !1 : t.every(
|
|
306
|
+
(r, s) => r === "*" ? n[s] !== "" : r === n[s]
|
|
307
|
+
);
|
|
308
|
+
}
|
|
309
|
+
function Se(i, e) {
|
|
293
310
|
if (i)
|
|
294
|
-
return J.find(
|
|
311
|
+
return J.find(
|
|
312
|
+
(t) => t.accountId === i && Be(t.pathname, e)
|
|
313
|
+
);
|
|
295
314
|
}
|
|
296
|
-
function
|
|
315
|
+
function Qe(i, e) {
|
|
297
316
|
if (!(!i || !g(e)))
|
|
298
317
|
return J.find((t) => t.accountId === i && t.targetPageIdentifier === e);
|
|
299
318
|
}
|
|
300
|
-
function
|
|
319
|
+
function Xe(i, e) {
|
|
301
320
|
return i ? J.some((t) => t.accountId === i && t.attributeKeys.includes(e)) : !1;
|
|
302
321
|
}
|
|
303
|
-
function
|
|
322
|
+
function Ze() {
|
|
304
323
|
return { pending: [] };
|
|
305
324
|
}
|
|
306
325
|
function j(i, e) {
|
|
@@ -320,23 +339,26 @@ function V(i) {
|
|
|
320
339
|
return g(n) && n.length > 0;
|
|
321
340
|
}) : !1;
|
|
322
341
|
}
|
|
323
|
-
function
|
|
342
|
+
function Ae(i) {
|
|
324
343
|
const e = i?.getMPID?.();
|
|
325
344
|
return e == null ? null : String(e);
|
|
326
345
|
}
|
|
346
|
+
function Pe(i, e) {
|
|
347
|
+
const t = new Set((i.optionalAttributeKeys ?? []).map((n) => n.toLowerCase()));
|
|
348
|
+
return i.attributeKeys.filter((n) => !t.has(n.toLowerCase()) && S(e[n]));
|
|
349
|
+
}
|
|
327
350
|
function re(i, e, t) {
|
|
328
|
-
const n = i.filteredUser?.getAllUserAttributes?.() || {}, r =
|
|
329
|
-
for (const
|
|
330
|
-
const
|
|
331
|
-
|
|
332
|
-
r.has(c.toLowerCase()) || o.push(c);
|
|
333
|
-
continue;
|
|
334
|
-
}
|
|
335
|
-
s[c] = l;
|
|
351
|
+
const n = i.filteredUser?.getAllUserAttributes?.() || {}, r = {};
|
|
352
|
+
for (const s of t.attributeKeys) {
|
|
353
|
+
const o = i.getEventAttributeValue(e, s), c = S(o) ? i.userAttributes[s] ?? n[s] : o;
|
|
354
|
+
S(c) || (r[s] = c);
|
|
336
355
|
}
|
|
337
|
-
return {
|
|
356
|
+
return {
|
|
357
|
+
collected: r,
|
|
358
|
+
missingKeys: Pe(t, r)
|
|
359
|
+
};
|
|
338
360
|
}
|
|
339
|
-
function
|
|
361
|
+
function et(i, e) {
|
|
340
362
|
Promise.resolve(i.selectPlacements(e)).catch((t) => {
|
|
341
363
|
const n = t instanceof Error ? t.message : String(t);
|
|
342
364
|
i.log({
|
|
@@ -345,47 +367,58 @@ function Xe(i, e) {
|
|
|
345
367
|
});
|
|
346
368
|
});
|
|
347
369
|
}
|
|
348
|
-
function
|
|
349
|
-
const o =
|
|
370
|
+
function be(i, e, t, n, r, s) {
|
|
371
|
+
const o = He(e, t), c = Ve(o), u = !!c && JSON.stringify(c.attributes) === JSON.stringify(r);
|
|
350
372
|
if (c && c.expiresAt > Date.now() && u) {
|
|
351
|
-
i.logPlacementDiagnostic(
|
|
373
|
+
i.logPlacementDiagnostic(A("skipped", "active_preselection"));
|
|
352
374
|
return;
|
|
353
375
|
}
|
|
354
|
-
|
|
376
|
+
We(o, r), i.logPlacementDiagnostic(A("fired", s)), et(i, { attributes: r, preselect: !0, identifier: n, omitUrl: !0 });
|
|
355
377
|
}
|
|
356
|
-
function
|
|
378
|
+
function tt(i, e) {
|
|
357
379
|
if (!e.accountId || !e.isKitReady())
|
|
358
380
|
return;
|
|
359
|
-
const t =
|
|
360
|
-
if (t)
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
381
|
+
const t = qe(e.accountId);
|
|
382
|
+
if (!t)
|
|
383
|
+
return;
|
|
384
|
+
if (i.pending.some((o) => o.pathname === t.pathname)) {
|
|
385
|
+
L(e.accountId);
|
|
386
|
+
return;
|
|
387
|
+
}
|
|
388
|
+
if (!e.isPreselectionEnabled()) {
|
|
389
|
+
L(e.accountId);
|
|
390
|
+
return;
|
|
391
|
+
}
|
|
392
|
+
if (!V(e.filteredUser) || (L(e.accountId), Ae(e.filteredUser) !== t.mpid))
|
|
393
|
+
return;
|
|
394
|
+
const n = Se(e.accountId, t.pathname);
|
|
395
|
+
if (!n || n.targetPageIdentifier !== t.identifier)
|
|
396
|
+
return;
|
|
397
|
+
const r = y(t.attributes), s = Pe(n, r);
|
|
398
|
+
if (s.length > 0) {
|
|
399
|
+
for (const o of s)
|
|
400
|
+
e.logPlacementDiagnostic(A("missed", `missing_persisted_attribute:${o}`));
|
|
401
|
+
return;
|
|
370
402
|
}
|
|
403
|
+
be(e, e.accountId, t.identifier, t.identifier, r, "recovered");
|
|
371
404
|
}
|
|
372
|
-
function
|
|
373
|
-
const r =
|
|
405
|
+
function Re(i, e, t, n = window.location.pathname) {
|
|
406
|
+
const r = Se(e.accountId, n);
|
|
374
407
|
if (!r)
|
|
375
408
|
return;
|
|
376
409
|
if (!e.isKitReady()) {
|
|
377
|
-
const c = [], u =
|
|
410
|
+
const c = [], u = Ae(e.filteredUser);
|
|
378
411
|
if (e.accountId && u && V(e.filteredUser)) {
|
|
379
412
|
const { collected: l, missingKeys: f } = re(e, t, r);
|
|
380
413
|
if (f.length === 0) {
|
|
381
|
-
const
|
|
382
|
-
|
|
414
|
+
const k = y(l);
|
|
415
|
+
Je(
|
|
383
416
|
e.accountId,
|
|
384
417
|
n,
|
|
385
418
|
r.targetPageIdentifier,
|
|
386
|
-
|
|
419
|
+
k,
|
|
387
420
|
u
|
|
388
|
-
) || c.push(
|
|
421
|
+
) || c.push(A("queued", "persist_failed"));
|
|
389
422
|
}
|
|
390
423
|
}
|
|
391
424
|
j(i, { event: t, pathname: n, storedDiagnostics: c });
|
|
@@ -394,53 +427,53 @@ function Pe(i, e, t, n = window.location.pathname) {
|
|
|
394
427
|
if (!e.isPreselectionEnabled())
|
|
395
428
|
return;
|
|
396
429
|
if (!V(e.filteredUser)) {
|
|
397
|
-
e.logPlacementDiagnostic(
|
|
430
|
+
e.logPlacementDiagnostic(A("missed", "no_valid_identity")), j(i, { event: t, pathname: n });
|
|
398
431
|
return;
|
|
399
432
|
}
|
|
400
433
|
const { collected: s, missingKeys: o } = re(e, t, r);
|
|
401
434
|
if (o.length > 0) {
|
|
402
435
|
for (const c of o)
|
|
403
|
-
e.logPlacementDiagnostic(
|
|
436
|
+
e.logPlacementDiagnostic(A("missed", `missing_attribute:${c}`));
|
|
404
437
|
j(i, { event: t, pathname: n });
|
|
405
438
|
return;
|
|
406
439
|
}
|
|
407
|
-
|
|
440
|
+
be(e, e.accountId || "", n, r.targetPageIdentifier, s, "fired");
|
|
408
441
|
}
|
|
409
|
-
function
|
|
410
|
-
if (
|
|
442
|
+
function it(i, e, t = window.location.pathname) {
|
|
443
|
+
if (tt(i, e), i.pending.length === 0)
|
|
411
444
|
return;
|
|
412
445
|
const n = i.pending;
|
|
413
446
|
i.pending = [], n.forEach(({ event: r, pathname: s, storedDiagnostics: o }) => {
|
|
414
|
-
s === t && (e.isKitReady() && e.isPreselectionEnabled() && o?.forEach((c) => e.logPlacementDiagnostic(c)),
|
|
447
|
+
s === t && (e.isKitReady() && e.isPreselectionEnabled() && o?.forEach((c) => e.logPlacementDiagnostic(c)), Re(i, e, r, s));
|
|
415
448
|
});
|
|
416
449
|
}
|
|
417
|
-
function
|
|
450
|
+
function nt() {
|
|
418
451
|
return {
|
|
419
452
|
context: null,
|
|
420
453
|
lifecycle: "idle",
|
|
421
454
|
recreateInFlight: null
|
|
422
455
|
};
|
|
423
456
|
}
|
|
424
|
-
function
|
|
457
|
+
function rt(i, e) {
|
|
425
458
|
i.context = {
|
|
426
459
|
accountId: e.accountId,
|
|
427
460
|
launcherOptions: { ...e.launcherOptions },
|
|
428
461
|
legacyRoktExtensions: [...e.legacyRoktExtensions]
|
|
429
462
|
};
|
|
430
463
|
}
|
|
431
|
-
function
|
|
464
|
+
function st(i) {
|
|
432
465
|
i.lifecycle = "attached";
|
|
433
466
|
}
|
|
434
|
-
function
|
|
467
|
+
function ot(i) {
|
|
435
468
|
i.lifecycle !== "idle" && (i.lifecycle = "terminated");
|
|
436
469
|
}
|
|
437
|
-
function
|
|
470
|
+
function ct(i) {
|
|
438
471
|
i.lifecycle = "terminated";
|
|
439
472
|
}
|
|
440
|
-
function
|
|
473
|
+
function at(i) {
|
|
441
474
|
i.context = null, i.lifecycle = "idle", i.recreateInFlight = null;
|
|
442
475
|
}
|
|
443
|
-
function
|
|
476
|
+
function lt(i, e, t) {
|
|
444
477
|
if (i.recreateInFlight)
|
|
445
478
|
return i.recreateInFlight;
|
|
446
479
|
if (i.lifecycle !== "terminated" || !i.context || !e)
|
|
@@ -451,16 +484,16 @@ function ct(i, e, t) {
|
|
|
451
484
|
i.recreateInFlight = null;
|
|
452
485
|
}), i.recreateInFlight;
|
|
453
486
|
}
|
|
454
|
-
const d = "Rokt",
|
|
487
|
+
const d = "Rokt", K = 181, ut = "selectPlacements", dt = "apps.roktecommerce.com", ht = 0.1, gt = "ThankYouPageJourney", ft = "rokt-launcher", pt = "rokt-thank-you-element", mt = "userIdentifiedInWorkspace", Et = 3, _t = 2, It = "page_events", yt = "page_view_attributes", St = "mparticle_session_id", At = "mparticle_device_id", se = 500, Q = {
|
|
455
488
|
UNKNOWN_ERROR: "UNKNOWN_ERROR",
|
|
456
489
|
UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
|
|
457
490
|
IDENTITY_REQUEST: "IDENTITY_REQUEST",
|
|
458
491
|
LOG_DELIVERY_FAILURE: "LOG_DELIVERY_FAILURE"
|
|
459
|
-
},
|
|
492
|
+
}, P = {
|
|
460
493
|
ERROR: "ERROR",
|
|
461
494
|
INFO: "INFO",
|
|
462
495
|
WARNING: "WARNING"
|
|
463
|
-
},
|
|
496
|
+
}, Pt = "apps.rokt-api.com", bt = "/v1/log", Rt = "/v1/errors", kt = 10;
|
|
464
497
|
function a() {
|
|
465
498
|
return window.mParticle;
|
|
466
499
|
}
|
|
@@ -472,10 +505,10 @@ function ce(i) {
|
|
|
472
505
|
return [G(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
|
|
473
506
|
}
|
|
474
507
|
function G(i) {
|
|
475
|
-
const e = i !== void 0 ? i :
|
|
508
|
+
const e = i !== void 0 ? i : Pt;
|
|
476
509
|
return e.includes("://") ? e.replace(/\/+$/, "") : ["https://", e].join("");
|
|
477
510
|
}
|
|
478
|
-
function
|
|
511
|
+
function ke(i, e, t) {
|
|
479
512
|
if (i)
|
|
480
513
|
return i.startsWith("http://") || i.startsWith("https://") ? i : "https://" + i;
|
|
481
514
|
const r = e?.includes("://") && !/^https?:\/\//i.test(e) ? void 0 : e;
|
|
@@ -486,7 +519,7 @@ function ae(i, e, t) {
|
|
|
486
519
|
const n = document.head || document.body, r = document.createElement("script");
|
|
487
520
|
r.id = i, r.type = "text/javascript", r.src = e, r.async = !0, r.crossOrigin = "anonymous", r.fetchPriority = "high", t?.onLoad && (r.onload = t.onLoad), t?.onError && (r.onerror = t.onError), n.appendChild(r);
|
|
488
521
|
}
|
|
489
|
-
function
|
|
522
|
+
function C(i) {
|
|
490
523
|
if (!i)
|
|
491
524
|
return [];
|
|
492
525
|
try {
|
|
@@ -497,11 +530,11 @@ function K(i) {
|
|
|
497
530
|
return [];
|
|
498
531
|
}
|
|
499
532
|
function le(i) {
|
|
500
|
-
const e = i ?
|
|
533
|
+
const e = i ? C(i) : [], t = [], n = [];
|
|
501
534
|
let r = !1;
|
|
502
535
|
for (let s = 0; s < e.length; s++) {
|
|
503
536
|
const o = e[s].value;
|
|
504
|
-
o === "thank-you-journey" ? (r = !0, n.push(
|
|
537
|
+
o === "thank-you-journey" ? (r = !0, n.push(gt)) : t.push(o);
|
|
505
538
|
}
|
|
506
539
|
return {
|
|
507
540
|
roktExtensionsQueryParams: t,
|
|
@@ -509,7 +542,7 @@ function le(i) {
|
|
|
509
542
|
loadThankYouElement: r
|
|
510
543
|
};
|
|
511
544
|
}
|
|
512
|
-
async function
|
|
545
|
+
async function vt(i, e) {
|
|
513
546
|
const t = [];
|
|
514
547
|
if (e)
|
|
515
548
|
for (const n of i)
|
|
@@ -545,8 +578,8 @@ function de(i) {
|
|
|
545
578
|
function he(i, e, t) {
|
|
546
579
|
return a().generateHash([i, e, t].join(""));
|
|
547
580
|
}
|
|
548
|
-
function
|
|
549
|
-
let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "3.
|
|
581
|
+
function wt(i) {
|
|
582
|
+
let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "3.7.0";
|
|
550
583
|
return i && (n += "_" + i), n;
|
|
551
584
|
}
|
|
552
585
|
function W(i) {
|
|
@@ -559,39 +592,39 @@ function W(i) {
|
|
|
559
592
|
}
|
|
560
593
|
function ge(i, e) {
|
|
561
594
|
const t = Ee(window.location.origin);
|
|
562
|
-
if (
|
|
595
|
+
if (b._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= ht)
|
|
563
596
|
return;
|
|
564
597
|
const r = window.__rokt_li_guid__;
|
|
565
598
|
if (!r || i && i.includes("://") && !/^https:\/\//i.test(i))
|
|
566
599
|
return;
|
|
567
600
|
const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s), c = i ? G(i) : "https://apps.rokt.com";
|
|
568
601
|
W(c + "/v1/wsdk-init/index.html?" + o), W(
|
|
569
|
-
"https://" +
|
|
602
|
+
"https://" + dt + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
|
|
570
603
|
);
|
|
571
604
|
}
|
|
572
|
-
function
|
|
605
|
+
function Tt() {
|
|
573
606
|
return typeof window < "u" && !!window.location?.search?.toLowerCase().includes("mp_enable_logging=true");
|
|
574
607
|
}
|
|
575
|
-
function
|
|
608
|
+
function Lt() {
|
|
576
609
|
return typeof window < "u" ? window.location?.href : void 0;
|
|
577
610
|
}
|
|
578
|
-
function
|
|
611
|
+
function Ot() {
|
|
579
612
|
return typeof window < "u" ? window.navigator?.userAgent : void 0;
|
|
580
613
|
}
|
|
581
|
-
class
|
|
614
|
+
class ve {
|
|
582
615
|
constructor() {
|
|
583
616
|
this._logCount = {};
|
|
584
617
|
}
|
|
585
618
|
incrementAndCheck(e) {
|
|
586
619
|
const n = (this._logCount[e] || 0) + 1;
|
|
587
|
-
return this._logCount[e] = n, n >
|
|
620
|
+
return this._logCount[e] = n, n > kt;
|
|
588
621
|
}
|
|
589
622
|
}
|
|
590
623
|
class F {
|
|
591
624
|
constructor(e, t, n, r, s) {
|
|
592
625
|
this._reporter = "mp-wsdk";
|
|
593
626
|
const o = e.isLoggingEnabled;
|
|
594
|
-
this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new
|
|
627
|
+
this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new ve(), this._isEnabled = Tt() || o;
|
|
595
628
|
}
|
|
596
629
|
send(e, t, n, r, s, o) {
|
|
597
630
|
if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(t)))
|
|
@@ -603,8 +636,8 @@ class F {
|
|
|
603
636
|
},
|
|
604
637
|
severity: t,
|
|
605
638
|
code: r || Q.UNKNOWN_ERROR,
|
|
606
|
-
url:
|
|
607
|
-
deviceInfo:
|
|
639
|
+
url: Lt(),
|
|
640
|
+
deviceInfo: Ot(),
|
|
608
641
|
stackTrace: s,
|
|
609
642
|
reporter: this._reporter,
|
|
610
643
|
integration: this._integrationName
|
|
@@ -633,11 +666,11 @@ class F {
|
|
|
633
666
|
}
|
|
634
667
|
class fe {
|
|
635
668
|
constructor(e, t, n, r, s) {
|
|
636
|
-
this._transport = new F(e, t, n, r, s), this._errorUrl =
|
|
669
|
+
this._transport = new F(e, t, n, r, s), this._errorUrl = ke(e?.errorUrl, e?.integrationDomain, Rt);
|
|
637
670
|
}
|
|
638
671
|
report(e) {
|
|
639
672
|
if (!e) return;
|
|
640
|
-
const t = e.severity ||
|
|
673
|
+
const t = e.severity || P.ERROR;
|
|
641
674
|
this._transport.send(this._errorUrl, t, e.message, e.code, e.stackTrace);
|
|
642
675
|
}
|
|
643
676
|
}
|
|
@@ -648,7 +681,7 @@ class pe {
|
|
|
648
681
|
n,
|
|
649
682
|
r,
|
|
650
683
|
s
|
|
651
|
-
), this._loggingUrl =
|
|
684
|
+
), this._loggingUrl = ke(e?.loggingUrl, e?.integrationDomain, bt), this._errorReportingService = t;
|
|
652
685
|
}
|
|
653
686
|
log(e) {
|
|
654
687
|
e && this._send(this._transport, e);
|
|
@@ -659,7 +692,7 @@ class pe {
|
|
|
659
692
|
_send(e, t) {
|
|
660
693
|
e.send(
|
|
661
694
|
this._loggingUrl,
|
|
662
|
-
|
|
695
|
+
P.INFO,
|
|
663
696
|
t.message,
|
|
664
697
|
t.code,
|
|
665
698
|
void 0,
|
|
@@ -669,15 +702,15 @@ class pe {
|
|
|
669
702
|
this._errorReportingService.report({
|
|
670
703
|
message: "LoggingService: Failed to send log: " + n.message,
|
|
671
704
|
code: Q.LOG_DELIVERY_FAILURE,
|
|
672
|
-
severity: r ?
|
|
705
|
+
severity: r ? P.ERROR : P.WARNING
|
|
673
706
|
});
|
|
674
707
|
}
|
|
675
708
|
}
|
|
676
709
|
);
|
|
677
710
|
}
|
|
678
711
|
}
|
|
679
|
-
function
|
|
680
|
-
const e = z(window.location.href), t = i.EventAttributes?.title || document.title, n =
|
|
712
|
+
function Nt(i) {
|
|
713
|
+
const e = z(window.location.href), t = i.EventAttributes?.title || document.title, n = Ye(), r = i.ActiveTimeOnSite;
|
|
681
714
|
return {
|
|
682
715
|
pageUrl: e,
|
|
683
716
|
sourceMessageId: i.SourceMessageId,
|
|
@@ -689,7 +722,7 @@ function Lt(i) {
|
|
|
689
722
|
}
|
|
690
723
|
const _ = class _ {
|
|
691
724
|
constructor() {
|
|
692
|
-
this.name = d, this.id =
|
|
725
|
+
this.name = d, this.id = K, this.moduleId = K, this.isInitialized = !1, this.launcher = null, this.filters = {}, this.userAttributes = {}, this.userIdentifiedInWorkspace = !1, this.testHelpers = null, this.placementEventMappingLookup = {}, this.placementEventAttributeMappingLookup = {}, this.integrationName = null, this.errorReportingService = null, this.loggingService = null, this._thankYouElementOnLoadCallback = null, this._isThankYouElementLoaded = !1, this._workspaceSearchInFlightPromise = null, this._launcherAttachState = nt(), this.accountId = null, this._preselectState = Ze();
|
|
693
726
|
}
|
|
694
727
|
// ---- Private helpers ----
|
|
695
728
|
getEventAttributeValue(e, t) {
|
|
@@ -720,7 +753,7 @@ const _ = class _ {
|
|
|
720
753
|
const t = Object.keys(this.placementEventAttributeMappingLookup);
|
|
721
754
|
for (let n = 0; n < t.length; n++) {
|
|
722
755
|
const r = t[n], s = this.placementEventAttributeMappingLookup[r];
|
|
723
|
-
if (
|
|
756
|
+
if (S(s))
|
|
724
757
|
continue;
|
|
725
758
|
let o = !0;
|
|
726
759
|
for (let c = 0; c < s.length; c++)
|
|
@@ -735,9 +768,9 @@ const _ = class _ {
|
|
|
735
768
|
let t;
|
|
736
769
|
try {
|
|
737
770
|
t = z(window.location.href);
|
|
738
|
-
const n = te(), r =
|
|
771
|
+
const n = te(), r = Nt(e);
|
|
739
772
|
n.push(r);
|
|
740
|
-
const s = Math.min(n.length, Ie), o =
|
|
773
|
+
const s = Math.min(n.length, Ie), o = De(n);
|
|
741
774
|
if (o === 0) {
|
|
742
775
|
const c = H() ? "quota" : "ls_unavailable";
|
|
743
776
|
this.loggingService?.log({
|
|
@@ -762,7 +795,7 @@ const _ = class _ {
|
|
|
762
795
|
buildCacheMatchKeys(e) {
|
|
763
796
|
if (!this.isPreselectionEnabled())
|
|
764
797
|
return;
|
|
765
|
-
const t =
|
|
798
|
+
const t = Qe(this.accountId, e);
|
|
766
799
|
if (t)
|
|
767
800
|
return t.attributeKeys;
|
|
768
801
|
}
|
|
@@ -780,7 +813,7 @@ const _ = class _ {
|
|
|
780
813
|
};
|
|
781
814
|
}
|
|
782
815
|
flushPendingPreselectDispatches() {
|
|
783
|
-
|
|
816
|
+
it(this._preselectState, this.buildPreselectHost());
|
|
784
817
|
}
|
|
785
818
|
isLauncherReadyToAttach() {
|
|
786
819
|
return !!window.Rokt && U(window.Rokt.createLauncher);
|
|
@@ -805,13 +838,13 @@ const _ = class _ {
|
|
|
805
838
|
if (!window.mParticle || typeof a().logEvent != "function" || !m(e))
|
|
806
839
|
return;
|
|
807
840
|
const t = a().EventType.Other;
|
|
808
|
-
a().logEvent(
|
|
841
|
+
a().logEvent(ut, t, e);
|
|
809
842
|
}
|
|
810
843
|
setRoktSessionId(e) {
|
|
811
844
|
if (!(!e || typeof e != "string"))
|
|
812
845
|
try {
|
|
813
846
|
const t = a().getInstance();
|
|
814
|
-
t && U(t.setIntegrationAttribute) && t.setIntegrationAttribute(
|
|
847
|
+
t && U(t.setIntegrationAttribute) && t.setIntegrationAttribute(K, {
|
|
815
848
|
roktSessionId: e
|
|
816
849
|
});
|
|
817
850
|
} catch {
|
|
@@ -826,7 +859,7 @@ const _ = class _ {
|
|
|
826
859
|
return a()?.getDeviceId?.() || void 0;
|
|
827
860
|
}
|
|
828
861
|
attachLauncher(e, t, n = []) {
|
|
829
|
-
|
|
862
|
+
rt(this._launcherAttachState, {
|
|
830
863
|
accountId: e,
|
|
831
864
|
launcherOptions: t || {},
|
|
832
865
|
legacyRoktExtensions: n
|
|
@@ -837,10 +870,10 @@ const _ = class _ {
|
|
|
837
870
|
};
|
|
838
871
|
let s;
|
|
839
872
|
return this.isPartnerInLocalLauncherTestGroup() ? s = Promise.resolve(window.Rokt.createLocalLauncher(r)) : s = window.Rokt.createLauncher(r), s.then(async (o) => {
|
|
840
|
-
await
|
|
873
|
+
await vt([...n], o), this.initRoktLauncher(o);
|
|
841
874
|
}).catch((o) => {
|
|
842
875
|
const c = this._launcherAttachState.lifecycle === "attached";
|
|
843
|
-
if (
|
|
876
|
+
if (ct(this._launcherAttachState), !c) {
|
|
844
877
|
const u = o instanceof Error ? o.message : String(o);
|
|
845
878
|
this.loggingService?.log({
|
|
846
879
|
message: `Rokt Kit: Failed to attach Rokt launcher: ${u}`,
|
|
@@ -851,14 +884,14 @@ const _ = class _ {
|
|
|
851
884
|
});
|
|
852
885
|
}
|
|
853
886
|
recreateLauncherIfTerminated() {
|
|
854
|
-
return
|
|
887
|
+
return lt(
|
|
855
888
|
this._launcherAttachState,
|
|
856
889
|
this.isLauncherReadyToAttach(),
|
|
857
890
|
(e) => this.attachLauncher(e.accountId, e.launcherOptions, e.legacyRoktExtensions)
|
|
858
891
|
);
|
|
859
892
|
}
|
|
860
893
|
initRoktLauncher(e) {
|
|
861
|
-
window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e,
|
|
894
|
+
window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e, st(this._launcherAttachState);
|
|
862
895
|
const t = a().Rokt?.filters;
|
|
863
896
|
t ? (this.filters = t, t.filteredUser ? this._workspaceSearchInFlightPromise = this.search(t.filteredUser) : console.warn("Rokt Kit: No filtered user has been set.")) : console.warn("Rokt Kit: No filters have been set."), this.isInitialized = !0, ge(this.domain, this.integrationName), a().Rokt.attachKit(this), this.flushPendingPreselectDispatches();
|
|
864
897
|
}
|
|
@@ -897,53 +930,53 @@ const _ = class _ {
|
|
|
897
930
|
*/
|
|
898
931
|
init(e, t, n, r, s) {
|
|
899
932
|
const o = e, c = o.accountId;
|
|
900
|
-
this.accountId = c || null, this.userAttributes =
|
|
901
|
-
const u =
|
|
933
|
+
this.accountId = c || null, this.userAttributes = y(s), this._onboardingExpProvider = o.onboardingExpProvider;
|
|
934
|
+
const u = C(o.placementEventMapping);
|
|
902
935
|
this.placementEventMappingLookup = ue(u);
|
|
903
|
-
const l =
|
|
936
|
+
const l = C(
|
|
904
937
|
o.placementEventAttributeMapping
|
|
905
938
|
);
|
|
906
939
|
this.placementEventAttributeMappingLookup = de(l), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = g(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
|
|
907
|
-
const f = a().Rokt?.domain, { roktExtensionsQueryParams:
|
|
940
|
+
const f = a().Rokt?.domain, { roktExtensionsQueryParams: k, legacyRoktExtensions: v, loadThankYouElement: N } = le(
|
|
908
941
|
o.roktExtensions
|
|
909
942
|
), E = {
|
|
910
943
|
...a().Rokt?.launcherOptions || {}
|
|
911
944
|
};
|
|
912
|
-
this.integrationName =
|
|
913
|
-
const
|
|
945
|
+
this.integrationName = wt(E.integrationName), E.integrationName = this.integrationName, this.domain = f;
|
|
946
|
+
const w = {
|
|
914
947
|
loggingUrl: o.loggingUrl,
|
|
915
948
|
errorUrl: o.errorUrl,
|
|
916
949
|
integrationDomain: f,
|
|
917
950
|
isLoggingEnabled: a().config?.isLoggingEnabled === !0
|
|
918
951
|
}, I = new fe(
|
|
919
|
-
|
|
952
|
+
w,
|
|
920
953
|
this.integrationName,
|
|
921
954
|
window.__rokt_li_guid__,
|
|
922
955
|
o.accountId
|
|
923
|
-
),
|
|
924
|
-
|
|
956
|
+
), T = new pe(
|
|
957
|
+
w,
|
|
925
958
|
I,
|
|
926
959
|
this.integrationName,
|
|
927
960
|
window.__rokt_li_guid__,
|
|
928
961
|
o.accountId
|
|
929
962
|
);
|
|
930
|
-
if (this.errorReportingService = I, this.loggingService =
|
|
963
|
+
if (this.errorReportingService = I, this.loggingService = T, this.isTargetingDisabled())
|
|
931
964
|
try {
|
|
932
965
|
ie(), ne();
|
|
933
966
|
} catch (p) {
|
|
934
967
|
this.errorReportingService?.report({
|
|
935
968
|
message: "Rokt Kit: Failed to clear page views when targeting is disabled",
|
|
936
969
|
code: "PAGE_VIEW_CAPTURE_FAILED",
|
|
937
|
-
severity:
|
|
970
|
+
severity: P.INFO,
|
|
938
971
|
stackTrace: p instanceof Error ? p.stack : void 0
|
|
939
972
|
});
|
|
940
973
|
}
|
|
941
|
-
return a()._registerErrorReportingService && a()._registerErrorReportingService(I), a()._registerLoggingService && a()._registerLoggingService(
|
|
974
|
+
return a()._registerErrorReportingService && a()._registerErrorReportingService(I), a()._registerLoggingService && a()._registerLoggingService(T), n ? (this.testHelpers = {
|
|
942
975
|
generateLauncherScript: oe,
|
|
943
976
|
generateThankYouElementScript: ce,
|
|
944
977
|
extractRoktExtensionConfig: le,
|
|
945
978
|
hashEventMessage: he,
|
|
946
|
-
parseSettingsString:
|
|
979
|
+
parseSettingsString: C,
|
|
947
980
|
generateMappedEventLookup: ue,
|
|
948
981
|
generateMappedEventAttributeLookup: de,
|
|
949
982
|
sendAdBlockMeasurementSignals: ge,
|
|
@@ -955,20 +988,20 @@ const _ = class _ {
|
|
|
955
988
|
ReportingTransport: F,
|
|
956
989
|
ErrorReportingService: fe,
|
|
957
990
|
LoggingService: pe,
|
|
958
|
-
RateLimiter:
|
|
991
|
+
RateLimiter: ve,
|
|
959
992
|
ErrorCodes: Q,
|
|
960
|
-
WSDKErrorSeverity:
|
|
961
|
-
resetLauncherAttachState: () =>
|
|
962
|
-
}, this.attachLauncher(c, E), "Successfully initialized: " + d) : (N && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), ae(
|
|
993
|
+
WSDKErrorSeverity: P,
|
|
994
|
+
resetLauncherAttachState: () => at(this._launcherAttachState)
|
|
995
|
+
}, this.attachLauncher(c, E), "Successfully initialized: " + d) : (N && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), ae(pt, ce(f), {
|
|
963
996
|
onLoad: () => {
|
|
964
997
|
this._isThankYouElementLoaded = !0, this._thankYouElementOnLoadCallback && this._thankYouElementOnLoadCallback();
|
|
965
998
|
},
|
|
966
999
|
onError: (p) => {
|
|
967
1000
|
console.error("Error loading Rokt Thank You Element script:", p);
|
|
968
1001
|
}
|
|
969
|
-
})), this.isLauncherReadyToAttach() ? this.attachLauncher(c, E,
|
|
1002
|
+
})), this.isLauncherReadyToAttach() ? this.attachLauncher(c, E, v) : (ae(ft, oe(f, k), {
|
|
970
1003
|
onLoad: () => {
|
|
971
|
-
this.isLauncherReadyToAttach() ? this.attachLauncher(c, E,
|
|
1004
|
+
this.isLauncherReadyToAttach() ? this.attachLauncher(c, E, v) : console.error("Rokt object is not available after script load.");
|
|
972
1005
|
},
|
|
973
1006
|
onError: (p) => {
|
|
974
1007
|
console.error("Error loading Rokt launcher script:", p);
|
|
@@ -976,9 +1009,9 @@ const _ = class _ {
|
|
|
976
1009
|
}), this.captureTiming(_.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + d);
|
|
977
1010
|
}
|
|
978
1011
|
process(e) {
|
|
979
|
-
if (this.isTargetingDisabled() || (e.EventDataType ===
|
|
1012
|
+
if (this.isTargetingDisabled() || (e.EventDataType === Et && (Fe(this.loggingService), this.capturePageView(e), Re(this._preselectState, this.buildPreselectHost(), e)), e.EventDataType === _t && (ie(), ne(), this.accountId && L(this.accountId))), !this.isKitReady())
|
|
980
1013
|
return "Kit not ready for forwarder: " + d;
|
|
981
|
-
if (U(a().Rokt?.setLocalSessionAttribute) && (
|
|
1014
|
+
if (U(a().Rokt?.setLocalSessionAttribute) && (S(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !S(this.placementEventMappingLookup))) {
|
|
982
1015
|
const t = he(e.EventDataType, e.EventCategory, e.EventName ?? "");
|
|
983
1016
|
this.placementEventMappingLookup[String(t)] && a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)], !0);
|
|
984
1017
|
}
|
|
@@ -992,13 +1025,13 @@ const _ = class _ {
|
|
|
992
1025
|
window.Rokt.setExtensionData(e);
|
|
993
1026
|
}
|
|
994
1027
|
setUserAttribute(e, t) {
|
|
995
|
-
return me(e) || (this.userAttributes[e] = t),
|
|
1028
|
+
return me(e) || (this.userAttributes[e] = t), Xe(this.accountId, e) && this.flushPendingPreselectDispatches(), "Successfully set user attribute for forwarder: " + d;
|
|
996
1029
|
}
|
|
997
1030
|
removeUserAttribute(e) {
|
|
998
1031
|
return delete this.userAttributes[e], "Successfully removed user attribute for forwarder: " + d;
|
|
999
1032
|
}
|
|
1000
1033
|
handleIdentityComplete(e, t) {
|
|
1001
|
-
return this.userAttributes =
|
|
1034
|
+
return this.userAttributes = y(e.getAllUserAttributes()), "Successfully called " + t + " for forwarder: " + d;
|
|
1002
1035
|
}
|
|
1003
1036
|
onUserIdentified(e) {
|
|
1004
1037
|
const t = e;
|
|
@@ -1037,7 +1070,7 @@ const _ = class _ {
|
|
|
1037
1070
|
return this.handleIdentityComplete(e, "onLoginComplete");
|
|
1038
1071
|
}
|
|
1039
1072
|
onLogoutComplete(e, t) {
|
|
1040
|
-
return this.userIdentifiedInWorkspace = !1, this._workspaceSearchInFlightPromise = null, this._workspaceLastSearchedIdentitiesKey = void 0, this.accountId &&
|
|
1073
|
+
return this.userIdentifiedInWorkspace = !1, this._workspaceSearchInFlightPromise = null, this._workspaceLastSearchedIdentitiesKey = void 0, this.accountId && L(this.accountId), this.handleIdentityComplete(e, "onLogoutComplete");
|
|
1041
1074
|
}
|
|
1042
1075
|
onModifyComplete(e, t) {
|
|
1043
1076
|
return this.handleIdentityComplete(e, "onModifyComplete");
|
|
@@ -1087,32 +1120,32 @@ const _ = class _ {
|
|
|
1087
1120
|
return this._dispatchPlacements(e);
|
|
1088
1121
|
}
|
|
1089
1122
|
_dispatchPlacements(e) {
|
|
1090
|
-
const t = e && e.attributes || {}, r = { ...
|
|
1123
|
+
const t = e && e.attributes || {}, r = { ...y(this.userAttributes), ...t }, s = this.filters || {}, o = s.userAttributeFilters || [], c = s.filteredUser || null, u = c ? c.getMPID() : null;
|
|
1091
1124
|
let l;
|
|
1092
|
-
s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes =
|
|
1093
|
-
const f = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {},
|
|
1094
|
-
...
|
|
1125
|
+
s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes = y(l);
|
|
1126
|
+
const f = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, k = this.returnUserIdentities(c), v = this.returnLocalSessionAttributes(), N = Me(te()), E = xe(), w = this.readMpSessionId(), I = this.readMpDeviceId(), T = {
|
|
1127
|
+
...k,
|
|
1095
1128
|
...l,
|
|
1096
1129
|
...f,
|
|
1097
|
-
...
|
|
1098
|
-
...N.length ? { [
|
|
1099
|
-
...E ? { [
|
|
1100
|
-
...this.userIdentifiedInWorkspace ? { [
|
|
1101
|
-
...
|
|
1102
|
-
...I ? { [
|
|
1130
|
+
...v,
|
|
1131
|
+
...N.length ? { [It]: JSON.stringify(N) } : {},
|
|
1132
|
+
...E ? { [yt]: E } : {},
|
|
1133
|
+
...this.userIdentifiedInWorkspace ? { [mt]: !0 } : {},
|
|
1134
|
+
...w ? { [St]: w } : {},
|
|
1135
|
+
...I ? { [At]: I } : {},
|
|
1103
1136
|
mpid: u
|
|
1104
|
-
}, p = this.buildCacheMatchKeys(typeof e.identifier == "string" ? e.identifier : void 0),
|
|
1137
|
+
}, p = this.buildCacheMatchKeys(typeof e.identifier == "string" ? e.identifier : void 0), we = {
|
|
1105
1138
|
...e,
|
|
1106
|
-
attributes:
|
|
1139
|
+
attributes: T,
|
|
1107
1140
|
...p !== void 0 ? { cacheMatchKeys: p } : {}
|
|
1108
|
-
}, X = this.launcher.selectPlacements(
|
|
1109
|
-
Z || this.logSelectPlacementsEvent(
|
|
1141
|
+
}, X = this.launcher.selectPlacements(we), Z = e.preselect === !0, Te = () => {
|
|
1142
|
+
Z || this.logSelectPlacementsEvent(T);
|
|
1110
1143
|
};
|
|
1111
|
-
return Promise.resolve(X).then((
|
|
1144
|
+
return Promise.resolve(X).then((Le) => {
|
|
1112
1145
|
if (!Z)
|
|
1113
|
-
return
|
|
1146
|
+
return Le?.context?.sessionId?.then((Oe) => this.setRoktSessionId(Oe));
|
|
1114
1147
|
}).catch(() => {
|
|
1115
|
-
}).finally(
|
|
1148
|
+
}).finally(Te), X;
|
|
1116
1149
|
}
|
|
1117
1150
|
/**
|
|
1118
1151
|
* Passes attributes to the Rokt Web SDK for client-side hashing.
|
|
@@ -1138,7 +1171,7 @@ const _ = class _ {
|
|
|
1138
1171
|
* here would flip the kit to not-ready with no drain path for queued calls.
|
|
1139
1172
|
*/
|
|
1140
1173
|
terminate() {
|
|
1141
|
-
return this.isKitReady() ? (
|
|
1174
|
+
return this.isKitReady() ? (ot(this._launcherAttachState), this.launcher.terminate()) : (console.error("Rokt Kit: Not initialized"), Promise.resolve());
|
|
1142
1175
|
}
|
|
1143
1176
|
/**
|
|
1144
1177
|
* Registers a callback to be invoked once rokt-thank-you-element.js becomes available.
|
|
@@ -1150,11 +1183,11 @@ const _ = class _ {
|
|
|
1150
1183
|
_._allowedOriginHashes = [-553112570, 549508659], _.PERFORMANCE_MARKS = {
|
|
1151
1184
|
RoktScriptAppended: "mp:RoktScriptAppended"
|
|
1152
1185
|
}, _.EMAIL_SHA256_KEY = "emailsha256";
|
|
1153
|
-
let
|
|
1154
|
-
function
|
|
1155
|
-
return
|
|
1186
|
+
let b = _;
|
|
1187
|
+
function Ut() {
|
|
1188
|
+
return K;
|
|
1156
1189
|
}
|
|
1157
|
-
function
|
|
1190
|
+
function Kt(i) {
|
|
1158
1191
|
if (!i) {
|
|
1159
1192
|
window.console.log("You must pass a config object to register the kit " + d);
|
|
1160
1193
|
return;
|
|
@@ -1164,17 +1197,17 @@ function Nt(i) {
|
|
|
1164
1197
|
return;
|
|
1165
1198
|
}
|
|
1166
1199
|
m(i.kits) ? i.kits[d] = {
|
|
1167
|
-
constructor:
|
|
1200
|
+
constructor: b
|
|
1168
1201
|
} : (i.kits = {}, i.kits[d] = {
|
|
1169
|
-
constructor:
|
|
1202
|
+
constructor: b
|
|
1170
1203
|
}), window.console.log("Successfully registered " + d + " to your mParticle configuration");
|
|
1171
1204
|
}
|
|
1172
1205
|
typeof window < "u" && window.mParticle && a().addForwarder && a().addForwarder({
|
|
1173
1206
|
name: d,
|
|
1174
|
-
constructor:
|
|
1175
|
-
getId:
|
|
1207
|
+
constructor: b,
|
|
1208
|
+
getId: Ut
|
|
1176
1209
|
});
|
|
1177
1210
|
export {
|
|
1178
|
-
|
|
1211
|
+
Kt as register
|
|
1179
1212
|
};
|
|
1180
1213
|
//# sourceMappingURL=Rokt-Kit.esm.js.map
|
package/dist/Rokt-Kit.iife.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
var RoktKit=(function(j){"use strict";const ve=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],we=new Set(ve);function Z(i){return we.has(i.toLowerCase())}function P(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];Z(s)||(e[s]=t[s])}return e}function f(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function g(i){return typeof i=="string"}function N(i){return typeof i=="function"}function b(i){return i==null?!0:typeof i=="string"?i.length===0:typeof i=="object"?Object.keys(i).length===0:!1}function H(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function ee(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}const d="mp-rokt-kit",te="__rokt_ls_probe__";function V(){try{return window.localStorage.setItem(te,"1"),window.localStorage.removeItem(te),!0}catch{return!1}}const I=()=>window.localStorage;function W(i,e=I){try{const t=e().getItem(i);return t===null?null:JSON.parse(t)}catch{return null}}function ie(i,e,t=I){try{return t().setItem(i,JSON.stringify(e)),!0}catch{return!1}}function Te(i,e=I){try{e().removeItem(i)}catch{}}function R(i,e,t=I){const n=W(i,t);return f(n)?n[e]:void 0}function U(i,e,t,n=I){const r=W(i,n),s=f(r)?{...r}:{};return s[e]=t,ie(i,s,n)}function C(i,e,t=I){const n=W(i,t);if(!f(n)||!(e in n))return;const r={...n};delete r[e],Object.keys(r).length===0?Te(i,t):ie(i,r,t)}const z="pageViews",K="utmParams",ne=25,Le=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function re(i){return i.slice(-ne)}function se(){const i=R(d,z);return Array.isArray(i)?i:[]}function Oe(i){const e=re(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(U(d,z,n))return n.length}return 0}function oe(){C(d,z)}function Ne(i){const e=re(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=s&&u?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function Ue(i){if(R(d,K)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Le){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!U(d,K,t)){const r=V()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function Ce(){const i=R(d,K);return f(i)?i:null}function ce(){C(d,K)}function Ke(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return H(e)}const $=[{accountId:"2919171670744024290",pathname:"/checkout",targetPageIdentifier:"prod.rokt.conf",attributeKeys:["email","amount","customertype","eventvenue","firstname","lastname","member_status","billingzipcode","currency"],optionalAttributeKeys:["firstname","lastname"]},{accountId:"2550745407543340151",pathname:"/checkout",targetPageIdentifier:"RoktExperience",attributeKeys:["email","amount","firstname","lastname","cartItems","customertype","loyaltytier","paymenttype","ccbin"],optionalAttributeKeys:["loyaltytier","paymenttype","ccbin"]},{accountId:"3236704179315511296",pathname:"/check-out/pay",targetPageIdentifier:"confirmation_page",attributeKeys:["email","totalprice","firstname","lastname","loyaltytier"],optionalAttributeKeys:["firstname","lastname","loyaltytier"]}],De=6e4;function Me(i){return f(i)&&typeof i.expiresAt=="number"&&f(i.attributes)}function Fe(i,e){return`activePreselect:${i}:${e}`}function xe(i){const e=R(d,i);return Me(e)?e:null}function Ye(i,e){U(d,i,{expiresAt:Date.now()+De,attributes:e})}const Ge=5*6e4;function D(){return window.sessionStorage}function je(i){return f(i)&&typeof i.expiresAt=="number"&&g(i.pathname)&&g(i.identifier)&&f(i.attributes)&&g(i.mpid)}function q(i){return`pendingPreselect:${i}`}function He(i){const e=q(i),t=R(d,e,D);return je(t)?t.expiresAt<=Date.now()?(C(d,e,D),null):t:null}function Ve(i,e,t,n,r){return U(d,q(i),{expiresAt:Date.now()+Ge,pathname:e,identifier:t,attributes:n,mpid:r},D)}function k(i){C(d,q(i),D)}function v(i,e){const t={fired:"PRESELECT_FIRED",missed:"PRESELECT_MISSED",queued:"PRESELECT_QUEUED",skipped:"PRESELECT_SKIPPED"};return{message:`Rokt Kit: preselect ${i} [reason=${e}]`,code:t[i]}}function We(i,e){if(i)return $.find(t=>t.accountId===i&&t.pathname===e)}function ze(i,e){if(!(!i||!g(e)))return $.find(t=>t.accountId===i&&t.targetPageIdentifier===e)}function $e(i,e){return i?$.some(t=>t.accountId===i&&t.attributeKeys.includes(e)):!1}function qe(){return{pending:[]}}function J(i,e){const t=i.pending.findIndex(n=>n.pathname===e.pathname);if(t>=0){i.pending[t]=e;return}i.pending.push(e)}function B(i){if(!i?.getUserIdentities)return!1;const e=i.getUserIdentities().userIdentities;return e?Object.keys(e).some(t=>{const n=e[t];return g(n)&&n.length>0}):!1}function ae(i){const e=i?.getMPID?.();return e==null?null:String(e)}function le(i,e,t){const n=i.filteredUser?.getAllUserAttributes?.()||{},r=new Set((t.optionalAttributeKeys??[]).map(c=>c.toLowerCase())),s={},o=[];for(const c of t.attributeKeys){const u=i.getEventAttributeValue(e,c),l=b(u)?i.userAttributes[c]??n[c]:u;if(b(l)){r.has(c.toLowerCase())||o.push(c);continue}s[c]=l}return{collected:s,missingKeys:o}}function Je(i,e){Promise.resolve(i.selectPlacements(e)).catch(t=>{const n=t instanceof Error?t.message:String(t);i.log({message:`Rokt Kit: Preselect selectPlacements call failed: ${n}`,code:"PRESELECT_DISPATCH_FAILED"})})}function ue(i,e,t,n,r,s){const o=Fe(e,t),c=xe(o),u=!!c&&JSON.stringify(c.attributes)===JSON.stringify(r);if(c&&c.expiresAt>Date.now()&&u){i.logPlacementDiagnostic(v("skipped","active_preselection"));return}Ye(o,r),i.logPlacementDiagnostic(v("fired",s)),Je(i,{attributes:r,preselect:!0,identifier:n,omitUrl:!0})}function Be(i,e){if(!e.accountId||!e.isKitReady())return;const t=He(e.accountId);if(t){if(i.pending.some(n=>n.pathname===t.pathname)){k(e.accountId);return}if(!e.isPreselectionEnabled()){k(e.accountId);return}B(e.filteredUser)&&(k(e.accountId),ae(e.filteredUser)===t.mpid&&ue(e,e.accountId,t.identifier,t.identifier,t.attributes,"recovered"))}}function de(i,e,t,n=window.location.pathname){const r=We(e.accountId,n);if(!r)return;if(!e.isKitReady()){const c=[],u=ae(e.filteredUser);if(e.accountId&&u&&B(e.filteredUser)){const{collected:l,missingKeys:p}=le(e,t,r);if(p.length===0){const w=P(l);Ve(e.accountId,n,r.targetPageIdentifier,w,u)||c.push(v("queued","persist_failed"))}}J(i,{event:t,pathname:n,storedDiagnostics:c});return}if(!e.isPreselectionEnabled())return;if(!B(e.filteredUser)){e.logPlacementDiagnostic(v("missed","no_valid_identity")),J(i,{event:t,pathname:n});return}const{collected:s,missingKeys:o}=le(e,t,r);if(o.length>0){for(const c of o)e.logPlacementDiagnostic(v("missed",`missing_attribute:${c}`));J(i,{event:t,pathname:n});return}ue(e,e.accountId||"",n,r.targetPageIdentifier,s,"fired")}function Qe(i,e,t=window.location.pathname){if(Be(i,e),i.pending.length===0)return;const n=i.pending;i.pending=[],n.forEach(({event:r,pathname:s,storedDiagnostics:o})=>{s===t&&(e.isKitReady()&&e.isPreselectionEnabled()&&o?.forEach(c=>e.logPlacementDiagnostic(c)),de(i,e,r,s))})}function Xe(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function Ze(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function et(i){i.lifecycle="attached"}function tt(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function it(i){i.lifecycle="terminated"}function nt(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function rt(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const h="Rokt",M=181,st="selectPlacements",ot="apps.roktecommerce.com",ct=.1,at="ThankYouPageJourney",lt="rokt-launcher",ut="rokt-thank-you-element",dt="userIdentifiedInWorkspace",ht=3,gt=2,ft="page_events",pt="page_view_attributes",mt="mparticle_session_id",Et="mparticle_device_id",he=500,Q={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},y={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},_t="apps.rokt-api.com",It="/v1/log",yt="/v1/errors",St=10;function a(){return window.mParticle}function ge(i,e){const n=[F(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function fe(i){return[F(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function F(i){const e=i!==void 0?i:_t;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function pe(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return F(r)+t}function me(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function x(i){if(!i)return[];try{return JSON.parse(i.replace(/"/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function Ee(i){const e=i?x(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(at)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function At(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function _e(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function Ie(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!g(n.value)||!g(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function ye(i,e,t){return a().generateHash([i,e,t].join(""))}function Pt(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"3.6.1";return i&&(n+="_"+i),n}function X(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function Se(i,e){const t=ee(window.location.origin);if(S._allowedOriginHashes.indexOf(t)===-1||Math.random()>=ct)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?F(i):"https://apps.rokt.com";X(c+"/v1/wsdk-init/index.html?"+o),X("https://"+ot+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function bt(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Rt(){return typeof window<"u"?window.location?.href:void 0}function kt(){return typeof window<"u"?window.navigator?.userAgent:void 0}class Ae{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>St}}class Y{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new Ae,this._isEnabled=bt()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||Q.UNKNOWN_ERROR,url:Rt(),deviceInfo:kt(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const p=new Error("HTTP "+l.status+" from log endpoint");throw p.statusCode=l.status,p}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class Pe{constructor(e,t,n,r,s){this._transport=new Y(e,t,n,r,s),this._errorUrl=pe(e?.errorUrl,e?.integrationDomain,yt)}report(e){if(!e)return;const t=e.severity||y.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class be{constructor(e,t,n,r,s,o){this._transport=new Y(e,n,r,s,o),this._placementDiagnosticTransport=new Y(e,n,r,s),this._loggingUrl=pe(e?.loggingUrl,e?.integrationDomain,It),this._errorReportingService=t}log(e){e&&this._send(this._transport,e)}logPlacementDiagnostic(e){e&&this._send(this._placementDiagnosticTransport,e)}_send(e,t){e.send(this._loggingUrl,y.INFO,t.message,t.code,void 0,n=>{if(this._errorReportingService){const r=typeof n.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+n.message,code:Q.LOG_DELIVERY_FAILURE,severity:r?y.ERROR:y.WARNING})}})}}function vt(i){const e=H(window.location.href),t=i.EventAttributes?.title||document.title,n=Ke(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const E=class E{constructor(){this.name=h,this.id=M,this.moduleId=M,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null,this._launcherAttachState=Xe(),this.accountId=null,this._preselectState=qe()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||n[t]===void 0?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!g(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!g(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(b(s))continue;let o=!0;for(let c=0;c<s.length;c++)if(!this.doesEventMatchRule(e,s[c])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=H(window.location.href);const n=se(),r=vt(e);n.push(r);const s=Math.min(n.length,ne),o=Oe(n);if(o===0){const c=V()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else o<s&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${s} to ${o} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=V()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isPreselectionEnabled(){return this.launcher?.enablePreselection===!0}buildCacheMatchKeys(e){if(!this.isPreselectionEnabled())return;const t=ze(this.accountId,e);if(t)return t.attributeKeys}buildPreselectHost(){return{accountId:this.accountId,filteredUser:this.filters.filteredUser,userAttributes:this.userAttributes,isKitReady:()=>this.isKitReady(),isPreselectionEnabled:()=>this.isPreselectionEnabled(),getEventAttributeValue:(e,t)=>this.getEventAttributeValue(e,t),logPlacementDiagnostic:e=>this.loggingService?.logPlacementDiagnostic(e),log:e=>this.loggingService?.log(e),selectPlacements:e=>this.selectPlacements(e)}}flushPendingPreselectDispatches(){Qe(this._preselectState,this.buildPreselectHost())}isLauncherReadyToAttach(){return!!window.Rokt&&N(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[E.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!f(e))return;const t=a().EventType.Other;a().logEvent(st,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&N(t.setIntegrationAttribute)&&t.setIntegrationAttribute(M,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(N(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){Ze(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let s;return this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await At([...n],o),this.initRoktLauncher(o)}).catch(o=>{const c=this._launcherAttachState.lifecycle==="attached";if(it(this._launcherAttachState),!c){const u=o instanceof Error?o.message:String(o);this.loggingService?.log({message:`Rokt Kit: Failed to attach Rokt launcher: ${u}`,code:"LAUNCHER_ATTACH_FAILED"})}console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return rt(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,et(this._launcherAttachState);const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,Se(this.domain,this.integrationName),a().Rokt.attachKit(this),this.flushPendingPreselectDispatches()}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=t.getVariationMap()[o].id,s),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,s){const o=e,c=o.accountId;this.accountId=c||null,this.userAttributes=P(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=x(o.placementEventMapping);this.placementEventMappingLookup=_e(u);const l=x(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=Ie(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const p=a().Rokt?.domain,{roktExtensionsQueryParams:w,legacyRoktExtensions:T,loadThankYouElement:G}=Ee(o.roktExtensions),_={...a().Rokt?.launcherOptions||{}};this.integrationName=Pt(_.integrationName),_.integrationName=this.integrationName,this.domain=p;const L={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:p,isLoggingEnabled:a().config?.isLoggingEnabled===!0},A=new Pe(L,this.integrationName,window.__rokt_li_guid__,o.accountId),O=new be(L,A,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=A,this.loggingService=O,this.isTargetingDisabled())try{oe(),ce()}catch(m){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:y.INFO,stackTrace:m instanceof Error?m.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(A),a()._registerLoggingService&&a()._registerLoggingService(O),n?(this.testHelpers={generateLauncherScript:ge,generateThankYouElementScript:fe,extractRoktExtensionConfig:Ee,hashEventMessage:ye,parseSettingsString:x,generateMappedEventLookup:_e,generateMappedEventAttributeLookup:Ie,sendAdBlockMeasurementSignals:Se,createAutoRemovedIframe:X,djb2:ee,setAllowedOriginHashes:m=>{E._allowedOriginHashes=m},ReportingTransport:Y,ErrorReportingService:Pe,LoggingService:be,RateLimiter:Ae,ErrorCodes:Q,WSDKErrorSeverity:y,resetLauncherAttachState:()=>nt(this._launcherAttachState)},this.attachLauncher(c,_),"Successfully initialized: "+h):(G&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),me(ut,fe(p),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:m=>{console.error("Error loading Rokt Thank You Element script:",m)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,_,T):(me(lt,ge(p,w),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,_,T):console.error("Rokt object is not available after script load.")},onError:m=>{console.error("Error loading Rokt launcher script:",m)}}),this.captureTiming(E.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+h)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===ht&&(Ue(this.loggingService),this.capturePageView(e),de(this._preselectState,this.buildPreselectHost(),e)),e.EventDataType===gt&&(oe(),ce(),this.accountId&&k(this.accountId))),!this.isKitReady())return"Kit not ready for forwarder: "+h;if(N(a().Rokt?.setLocalSessionAttribute)&&(b(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!b(this.placementEventMappingLookup))){const t=ye(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+h}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return Z(e)||(this.userAttributes[e]=t),$e(this.accountId,e)&&this.flushPendingPreselectDispatches(),"Successfully set user attribute for forwarder: "+h}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+h}handleIdentityComplete(e,t){return this.userAttributes=P(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+h}onUserIdentified(e){const t=e;this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t);const n=this.handleIdentityComplete(e,"onUserIdentified");return this.flushPendingPreselectDispatches(),n}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const l=r[u];g(l)&&l.length>0&&(s[u]=l)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(u=>`${u}=${s[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,s,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.accountId&&k(this.accountId),this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(s=>setTimeout(s,he))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,he))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...P(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,u=c?c.getMPID():null;let l;s?s.filterUserAttributes?l=s.filterUserAttributes(r,o):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=P(l);const p=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},w=this.returnUserIdentities(c),T=this.returnLocalSessionAttributes(),G=Ne(se()),_=Ce(),L=this.readMpSessionId(),A=this.readMpDeviceId(),O={...w,...l,...p,...T,...G.length?{[ft]:JSON.stringify(G)}:{},..._?{[pt]:_}:{},...this.userIdentifiedInWorkspace?{[dt]:!0}:{},...L?{[mt]:L}:{},...A?{[Et]:A}:{},mpid:u},m=this.buildCacheMatchKeys(typeof e.identifier=="string"?e.identifier:void 0),Lt={...e,attributes:O,...m!==void 0?{cacheMatchKeys:m}:{}},Re=this.launcher.selectPlacements(Lt),ke=e.preselect===!0,Ot=()=>{ke||this.logSelectPlacementsEvent(O)};return Promise.resolve(Re).then(Nt=>{if(!ke)return Nt?.context?.sessionId?.then(Ut=>this.setRoktSessionId(Ut))}).catch(()=>{}).finally(Ot),Re}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!g(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}terminate(){return this.isKitReady()?(tt(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};E._allowedOriginHashes=[-553112570,549508659],E.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},E.EMAIL_SHA256_KEY="emailsha256";let S=E;function wt(){return M}function Tt(i){if(!i){window.console.log("You must pass a config object to register the kit "+h);return}if(!f(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}f(i.kits)?i.kits[h]={constructor:S}:(i.kits={},i.kits[h]={constructor:S}),window.console.log("Successfully registered "+h+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:h,constructor:S,getId:wt}),j.register=Tt,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"}),j})({});
|
|
1
|
+
var RoktKit=(function(j){"use strict";const Te=["active_time_on_site_ms","billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],Le=new Set(Te);function Z(i){return Le.has(i.toLowerCase())}function I(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];Z(s)||(e[s]=t[s])}return e}function f(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function g(i){return typeof i=="string"}function N(i){return typeof i=="function"}function y(i){return i==null?!0:typeof i=="string"?i.length===0:typeof i=="object"?Object.keys(i).length===0:!1}function H(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}function ee(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}const d="mp-rokt-kit",te="__rokt_ls_probe__";function V(){try{return window.localStorage.setItem(te,"1"),window.localStorage.removeItem(te),!0}catch{return!1}}const S=()=>window.localStorage;function W(i,e=S){try{const t=e().getItem(i);return t===null?null:JSON.parse(t)}catch{return null}}function ie(i,e,t=S){try{return t().setItem(i,JSON.stringify(e)),!0}catch{return!1}}function Oe(i,e=S){try{e().removeItem(i)}catch{}}function k(i,e,t=S){const n=W(i,t);return f(n)?n[e]:void 0}function U(i,e,t,n=S){const r=W(i,n),s=f(r)?{...r}:{};return s[e]=t,ie(i,s,n)}function K(i,e,t=S){const n=W(i,t);if(!f(n)||!(e in n))return;const r={...n};delete r[e],Object.keys(r).length===0?Oe(i,t):ie(i,r,t)}const z="pageViews",C="utmParams",ne=25,Ne=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function re(i){return i.slice(-ne)}function se(){const i=k(d,z);return Array.isArray(i)?i:[]}function Ue(i){const e=re(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(U(d,z,n))return n.length}return 0}function oe(){K(d,z)}function Ke(i){const e=re(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,s=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=s&&u?c-r:void 0;return{pageUrl:t.pageUrl,sourceMessageId:t.sourceMessageId,timestamp:t.timestamp,...t.pageTitle!==void 0?{pageTitle:t.pageTitle}:{},...t.canonicalUrl!==void 0?{canonicalUrl:t.canonicalUrl}:{},...s?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function Ce(i){if(k(d,C)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ne){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!U(d,C,t)){const r=V()?"quota":"ls_unavailable";i?.log({message:`Rokt Kit: Failed to persist UTM params [reason: ${r}]`,code:"UTM_CAPTURE_FAILED"});return}i?.log({message:`Rokt Kit: Captured UTM params [${n}]`,code:"UTM_CAPTURE_SUCCESS"})}function De(){const i=k(d,C);return f(i)?i:null}function ce(){K(d,C)}function Me(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return H(e)}const $=[{accountId:"2919171670744024290",pathname:"/checkout",targetPageIdentifier:"prod.rokt.conf",attributeKeys:["email","customertype","eventvenue","firstname","lastname","member_status","billingzipcode","currency"],optionalAttributeKeys:["firstname","lastname"]},{accountId:"2550745407543340151",pathname:"/checkout",targetPageIdentifier:"RoktExperience",attributeKeys:["email","firstname","lastname","customertype","loyaltytier","paymenttype","ccbin"],optionalAttributeKeys:["loyaltytier","paymenttype","ccbin"]},{accountId:"3236704179315511296",pathname:"/check-out/pay",targetPageIdentifier:"confirmation_page",attributeKeys:["email","firstname","lastname","loyaltytier"],optionalAttributeKeys:["firstname","lastname","loyaltytier"]},{accountId:"2192288523645376337",pathname:"/checkout/*/review",targetPageIdentifier:"ppx-ad-view-prod",attributeKeys:["email","firstname","lastname"],optionalAttributeKeys:["email"]}],Fe=6e4;function xe(i){return f(i)&&typeof i.expiresAt=="number"&&f(i.attributes)}function Ye(i,e){return`activePreselect:${i}:${e}`}function Ge(i){const e=k(d,i);return xe(e)?e:null}function je(i,e){U(d,i,{expiresAt:Date.now()+Fe,attributes:e})}const He=5*6e4;function D(){return window.sessionStorage}function Ve(i){return f(i)&&typeof i.expiresAt=="number"&&g(i.pathname)&&g(i.identifier)&&f(i.attributes)&&g(i.mpid)}function q(i){return`pendingPreselect:${i}`}function We(i){const e=q(i),t=k(d,e,D);return Ve(t)?t.expiresAt<=Date.now()?(K(d,e,D),null):t:null}function ze(i,e,t,n,r){return U(d,q(i),{expiresAt:Date.now()+He,pathname:e,identifier:t,attributes:n,mpid:r},D)}function v(i){K(d,q(i),D)}function A(i,e){const t={fired:"PRESELECT_FIRED",missed:"PRESELECT_MISSED",queued:"PRESELECT_QUEUED",skipped:"PRESELECT_SKIPPED"};return{message:`Rokt Kit: preselect ${i} [reason=${e}]`,code:t[i]}}function $e(i,e){if(!i.includes("*"))return i===e;const t=i.split("/"),n=e.split("/");return t.length!==n.length?!1:t.every((r,s)=>r==="*"?n[s]!=="":r===n[s])}function ae(i,e){if(i)return $.find(t=>t.accountId===i&&$e(t.pathname,e))}function qe(i,e){if(!(!i||!g(e)))return $.find(t=>t.accountId===i&&t.targetPageIdentifier===e)}function Je(i,e){return i?$.some(t=>t.accountId===i&&t.attributeKeys.includes(e)):!1}function Be(){return{pending:[]}}function J(i,e){const t=i.pending.findIndex(n=>n.pathname===e.pathname);if(t>=0){i.pending[t]=e;return}i.pending.push(e)}function B(i){if(!i?.getUserIdentities)return!1;const e=i.getUserIdentities().userIdentities;return e?Object.keys(e).some(t=>{const n=e[t];return g(n)&&n.length>0}):!1}function le(i){const e=i?.getMPID?.();return e==null?null:String(e)}function ue(i,e){const t=new Set((i.optionalAttributeKeys??[]).map(n=>n.toLowerCase()));return i.attributeKeys.filter(n=>!t.has(n.toLowerCase())&&y(e[n]))}function de(i,e,t){const n=i.filteredUser?.getAllUserAttributes?.()||{},r={};for(const s of t.attributeKeys){const o=i.getEventAttributeValue(e,s),c=y(o)?i.userAttributes[s]??n[s]:o;y(c)||(r[s]=c)}return{collected:r,missingKeys:ue(t,r)}}function Qe(i,e){Promise.resolve(i.selectPlacements(e)).catch(t=>{const n=t instanceof Error?t.message:String(t);i.log({message:`Rokt Kit: Preselect selectPlacements call failed: ${n}`,code:"PRESELECT_DISPATCH_FAILED"})})}function he(i,e,t,n,r,s){const o=Ye(e,t),c=Ge(o),u=!!c&&JSON.stringify(c.attributes)===JSON.stringify(r);if(c&&c.expiresAt>Date.now()&&u){i.logPlacementDiagnostic(A("skipped","active_preselection"));return}je(o,r),i.logPlacementDiagnostic(A("fired",s)),Qe(i,{attributes:r,preselect:!0,identifier:n,omitUrl:!0})}function Xe(i,e){if(!e.accountId||!e.isKitReady())return;const t=We(e.accountId);if(!t)return;if(i.pending.some(o=>o.pathname===t.pathname)){v(e.accountId);return}if(!e.isPreselectionEnabled()){v(e.accountId);return}if(!B(e.filteredUser)||(v(e.accountId),le(e.filteredUser)!==t.mpid))return;const n=ae(e.accountId,t.pathname);if(!n||n.targetPageIdentifier!==t.identifier)return;const r=I(t.attributes),s=ue(n,r);if(s.length>0){for(const o of s)e.logPlacementDiagnostic(A("missed",`missing_persisted_attribute:${o}`));return}he(e,e.accountId,t.identifier,t.identifier,r,"recovered")}function ge(i,e,t,n=window.location.pathname){const r=ae(e.accountId,n);if(!r)return;if(!e.isKitReady()){const c=[],u=le(e.filteredUser);if(e.accountId&&u&&B(e.filteredUser)){const{collected:l,missingKeys:p}=de(e,t,r);if(p.length===0){const w=I(l);ze(e.accountId,n,r.targetPageIdentifier,w,u)||c.push(A("queued","persist_failed"))}}J(i,{event:t,pathname:n,storedDiagnostics:c});return}if(!e.isPreselectionEnabled())return;if(!B(e.filteredUser)){e.logPlacementDiagnostic(A("missed","no_valid_identity")),J(i,{event:t,pathname:n});return}const{collected:s,missingKeys:o}=de(e,t,r);if(o.length>0){for(const c of o)e.logPlacementDiagnostic(A("missed",`missing_attribute:${c}`));J(i,{event:t,pathname:n});return}he(e,e.accountId||"",n,r.targetPageIdentifier,s,"fired")}function Ze(i,e,t=window.location.pathname){if(Xe(i,e),i.pending.length===0)return;const n=i.pending;i.pending=[],n.forEach(({event:r,pathname:s,storedDiagnostics:o})=>{s===t&&(e.isKitReady()&&e.isPreselectionEnabled()&&o?.forEach(c=>e.logPlacementDiagnostic(c)),ge(i,e,r,s))})}function et(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function tt(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function it(i){i.lifecycle="attached"}function nt(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function rt(i){i.lifecycle="terminated"}function st(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function ot(i,e,t){if(i.recreateInFlight)return i.recreateInFlight;if(i.lifecycle!=="terminated"||!i.context||!e)return;i.lifecycle="recreating";const n=i.context;return i.recreateInFlight=t(n).finally(()=>{i.recreateInFlight=null}),i.recreateInFlight}const h="Rokt",M=181,ct="selectPlacements",at="apps.roktecommerce.com",lt=.1,ut="ThankYouPageJourney",dt="rokt-launcher",ht="rokt-thank-you-element",gt="userIdentifiedInWorkspace",ft=3,pt=2,mt="page_events",Et="page_view_attributes",_t="mparticle_session_id",It="mparticle_device_id",fe=500,Q={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},P={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},yt="apps.rokt-api.com",St="/v1/log",At="/v1/errors",Pt=10;function a(){return window.mParticle}function pe(i,e){const n=[F(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function me(i){return[F(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function F(i){const e=i!==void 0?i:yt;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function Ee(i,e,t){if(i)return i.startsWith("http://")||i.startsWith("https://")?i:"https://"+i;const r=e?.includes("://")&&!/^https?:\/\//i.test(e)?void 0:e;return F(r)+t}function _e(i,e,t){if(document.getElementById(i))return;const n=document.head||document.body,r=document.createElement("script");r.id=i,r.type="text/javascript",r.src=e,r.async=!0,r.crossOrigin="anonymous",r.fetchPriority="high",t?.onLoad&&(r.onload=t.onLoad),t?.onError&&(r.onerror=t.onError),n.appendChild(r)}function x(i){if(!i)return[];try{return JSON.parse(i.replace(/"/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function Ie(i){const e=i?x(i):[],t=[],n=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,n.push(ut)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function bt(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function ye(i){if(!i)return{};const e={};for(let t=0;t<i.length;t++){const n=i[t];e[n.jsmap]=n.value}return e}function Se(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!g(n.value)||!g(n.map))continue;const r=n.value,s=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function Ae(i,e,t){return a().generateHash([i,e,t].join(""))}function Rt(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"3.7.0";return i&&(n+="_"+i),n}function X(i){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=i,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function Pe(i,e){const t=ee(window.location.origin);if(b._allowedOriginHashes.indexOf(t)===-1||Math.random()>=lt)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s),c=i?F(i):"https://apps.rokt.com";X(c+"/v1/wsdk-init/index.html?"+o),X("https://"+at+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function kt(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function vt(){return typeof window<"u"?window.location?.href:void 0}function wt(){return typeof window<"u"?window.navigator?.userAgent:void 0}class be{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Pt}}class Y{constructor(e,t,n,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=s||new be,this._isEnabled=kt()||o}send(e,t,n,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||Q.UNKNOWN_ERROR,url:vt(),deviceInfo:wt(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},u={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(u["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(u["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:u,body:JSON.stringify(c)}).then(l=>{if(!l.ok){const p=new Error("HTTP "+l.status+" from log endpoint");throw p.statusCode=l.status,p}}).catch(l=>{console.error("ReportingTransport: Failed to send log",l),o&&o(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class Re{constructor(e,t,n,r,s){this._transport=new Y(e,t,n,r,s),this._errorUrl=Ee(e?.errorUrl,e?.integrationDomain,At)}report(e){if(!e)return;const t=e.severity||P.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class ke{constructor(e,t,n,r,s,o){this._transport=new Y(e,n,r,s,o),this._placementDiagnosticTransport=new Y(e,n,r,s),this._loggingUrl=Ee(e?.loggingUrl,e?.integrationDomain,St),this._errorReportingService=t}log(e){e&&this._send(this._transport,e)}logPlacementDiagnostic(e){e&&this._send(this._placementDiagnosticTransport,e)}_send(e,t){e.send(this._loggingUrl,P.INFO,t.message,t.code,void 0,n=>{if(this._errorReportingService){const r=typeof n.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+n.message,code:Q.LOG_DELIVERY_FAILURE,severity:r?P.ERROR:P.WARNING})}})}}function Tt(i){const e=H(window.location.href),t=i.EventAttributes?.title||document.title,n=Me(),r=i.ActiveTimeOnSite;return{pageUrl:e,sourceMessageId:i.SourceMessageId,timestamp:i.Timestamp,...t?{pageTitle:t}:{},...n!==void 0?{canonicalUrl:n}:{},...Number.isFinite(r)?{activeTimeOnSite:r}:{}}}const E=class E{constructor(){this.name=h,this.id=M,this.moduleId=M,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null,this._launcherAttachState=et(),this.accountId=null,this._preselectState=Be()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||n[t]===void 0?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!g(e.operator))return!1;const n=e.operator.toLowerCase(),r=e.attributeValue;return n==="exists"?t!==null:t==null?!1:n==="equals"?String(t)===String(r):n==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!g(t.eventAttributeKey))return!1;const n=t.conditions;if(!Array.isArray(n))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(n.length===0)return r!==null;for(let s=0;s<n.length;s++)if(!this.doesEventAttributeConditionMatch(n[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let n=0;n<t.length;n++){const r=t[n],s=this.placementEventAttributeMappingLookup[r];if(y(s))continue;let o=!0;for(let c=0;c<s.length;c++)if(!this.doesEventMatchRule(e,s[c])){o=!1;break}o&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=H(window.location.href);const n=se(),r=Tt(e);n.push(r);const s=Math.min(n.length,ne),o=Ue(n);if(o===0){const c=V()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else o<s&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${s} to ${o} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=V()?"exception":"ls_unavailable",s=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isPreselectionEnabled(){return this.launcher?.enablePreselection===!0}buildCacheMatchKeys(e){if(!this.isPreselectionEnabled())return;const t=qe(this.accountId,e);if(t)return t.attributeKeys}buildPreselectHost(){return{accountId:this.accountId,filteredUser:this.filters.filteredUser,userAttributes:this.userAttributes,isKitReady:()=>this.isKitReady(),isPreselectionEnabled:()=>this.isPreselectionEnabled(),getEventAttributeValue:(e,t)=>this.getEventAttributeValue(e,t),logPlacementDiagnostic:e=>this.loggingService?.logPlacementDiagnostic(e),log:e=>this.loggingService?.log(e),selectPlacements:e=>this.selectPlacements(e)}}flushPendingPreselectDispatches(){Ze(this._preselectState,this.buildPreselectHost())}isLauncherReadyToAttach(){return!!window.Rokt&&N(window.Rokt.createLauncher)}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!a().Rokt||typeof a().Rokt.getLocalSessionAttributes!="function"?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},n=this._mappedEmailSha256Key;return n&&e[n]&&(t[E.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!f(e))return;const t=a().EventType.Other;a().logEvent(ct,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&N(t.setIntegrationAttribute)&&t.setIntegrationAttribute(M,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(N(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){tt(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let s;return this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(r)):s=window.Rokt.createLauncher(r),s.then(async o=>{await bt([...n],o),this.initRoktLauncher(o)}).catch(o=>{const c=this._launcherAttachState.lifecycle==="attached";if(rt(this._launcherAttachState),!c){const u=o instanceof Error?o.message:String(o);this.loggingService?.log({message:`Rokt Kit: Failed to attach Rokt launcher: ${u}`,code:"LAUNCHER_ATTACH_FAILED"})}console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return ot(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,it(this._launcherAttachState);const t=a().Rokt?.filters;t?(this.filters=t,t.filteredUser?this._workspaceSearchInFlightPromise=this.search(t.filteredUser):console.warn("Rokt Kit: No filtered user has been set.")):console.warn("Rokt Kit: No filters have been set."),this.isInitialized=!0,Pe(this.domain,this.integrationName),a().Rokt.attachKit(this),this.flushPendingPreselectDispatches()}fetchOptimizely(){const e=a()._getActiveForwarders().filter(t=>t.name==="Optimizely");try{if(e.length>0&&window.optimizely){const t=window.optimizely.get("state");return!t||!t.getActiveExperimentIds?{}:t.getActiveExperimentIds().reduce((s,o)=>(s["rokt.custom.optimizely.experiment."+o+".variationId"]=t.getVariationMap()[o].id,s),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isTargetingDisabled(){return a().Rokt?.launcherOptions?.noTargeting===!0}isPartnerInLocalLauncherTestGroup(){return!!(a().config&&a().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&a()&&a().captureTiming&&e&&a().captureTiming(e)}init(e,t,n,r,s){const o=e,c=o.accountId;this.accountId=c||null,this.userAttributes=I(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=x(o.placementEventMapping);this.placementEventMappingLookup=ye(u);const l=x(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=Se(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const p=a().Rokt?.domain,{roktExtensionsQueryParams:w,legacyRoktExtensions:T,loadThankYouElement:G}=Ie(o.roktExtensions),_={...a().Rokt?.launcherOptions||{}};this.integrationName=Rt(_.integrationName),_.integrationName=this.integrationName,this.domain=p;const L={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:p,isLoggingEnabled:a().config?.isLoggingEnabled===!0},R=new Re(L,this.integrationName,window.__rokt_li_guid__,o.accountId),O=new ke(L,R,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=R,this.loggingService=O,this.isTargetingDisabled())try{oe(),ce()}catch(m){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:P.INFO,stackTrace:m instanceof Error?m.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(R),a()._registerLoggingService&&a()._registerLoggingService(O),n?(this.testHelpers={generateLauncherScript:pe,generateThankYouElementScript:me,extractRoktExtensionConfig:Ie,hashEventMessage:Ae,parseSettingsString:x,generateMappedEventLookup:ye,generateMappedEventAttributeLookup:Se,sendAdBlockMeasurementSignals:Pe,createAutoRemovedIframe:X,djb2:ee,setAllowedOriginHashes:m=>{E._allowedOriginHashes=m},ReportingTransport:Y,ErrorReportingService:Re,LoggingService:ke,RateLimiter:be,ErrorCodes:Q,WSDKErrorSeverity:P,resetLauncherAttachState:()=>st(this._launcherAttachState)},this.attachLauncher(c,_),"Successfully initialized: "+h):(G&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),_e(ht,me(p),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:m=>{console.error("Error loading Rokt Thank You Element script:",m)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,_,T):(_e(dt,pe(p,w),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,_,T):console.error("Rokt object is not available after script load.")},onError:m=>{console.error("Error loading Rokt launcher script:",m)}}),this.captureTiming(E.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+h)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===ft&&(Ce(this.loggingService),this.capturePageView(e),ge(this._preselectState,this.buildPreselectHost(),e)),e.EventDataType===pt&&(oe(),ce(),this.accountId&&v(this.accountId))),!this.isKitReady())return"Kit not ready for forwarder: "+h;if(N(a().Rokt?.setLocalSessionAttribute)&&(y(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!y(this.placementEventMappingLookup))){const t=Ae(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+h}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return Z(e)||(this.userAttributes[e]=t),Je(this.accountId,e)&&this.flushPendingPreselectDispatches(),"Successfully set user attribute for forwarder: "+h}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+h}handleIdentityComplete(e,t){return this.userAttributes=I(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+h}onUserIdentified(e){const t=e;this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t);const n=this.handleIdentityComplete(e,"onUserIdentified");return this.flushPendingPreselectDispatches(),n}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const n=a().Identity?.search;if(typeof n!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const u of Object.keys(r)){const l=r[u];g(l)&&l.length>0&&(s[u]=l)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(u=>`${u}=${s[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,s,l=>{l?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(l){console.error("Rokt Kit: Workspace IDSync search failed",l),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.accountId&&v(this.accountId),this.handleIdentityComplete(e,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,"onModifyComplete")}selectPlacements(e){const t=this.recreateLauncherIfTerminated();if(t){const n=this._workspaceSearchInFlightPromise,r=n?Promise.race([n,new Promise(s=>setTimeout(s,fe))]):Promise.resolve();return Promise.all([t,r]).then(()=>this._dispatchPlacements(e))}if(this._workspaceSearchInFlightPromise){const n=this._workspaceSearchInFlightPromise;return Promise.race([n,new Promise(r=>setTimeout(r,fe))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...I(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,u=c?c.getMPID():null;let l;s?s.filterUserAttributes?l=s.filterUserAttributes(r,o):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=I(l);const p=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},w=this.returnUserIdentities(c),T=this.returnLocalSessionAttributes(),G=Ke(se()),_=De(),L=this.readMpSessionId(),R=this.readMpDeviceId(),O={...w,...l,...p,...T,...G.length?{[mt]:JSON.stringify(G)}:{},..._?{[Et]:_}:{},...this.userIdentifiedInWorkspace?{[gt]:!0}:{},...L?{[_t]:L}:{},...R?{[It]:R}:{},mpid:u},m=this.buildCacheMatchKeys(typeof e.identifier=="string"?e.identifier:void 0),Nt={...e,attributes:O,...m!==void 0?{cacheMatchKeys:m}:{}},ve=this.launcher.selectPlacements(Nt),we=e.preselect===!0,Ut=()=>{we||this.logSelectPlacementsEvent(O)};return Promise.resolve(ve).then(Kt=>{if(!we)return Kt?.context?.sessionId?.then(Ct=>this.setRoktSessionId(Ct))}).catch(()=>{}).finally(Ut),ve}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!g(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}terminate(){return this.isKitReady()?(nt(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};E._allowedOriginHashes=[-553112570,549508659],E.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},E.EMAIL_SHA256_KEY="emailsha256";let b=E;function Lt(){return M}function Ot(i){if(!i){window.console.log("You must pass a config object to register the kit "+h);return}if(!f(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}f(i.kits)?i.kits[h]={constructor:b}:(i.kits={},i.kits[h]={constructor:b}),window.console.log("Successfully registered "+h+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:h,constructor:b,getId:Lt}),j.register=Ot,Object.defineProperty(j,Symbol.toStringTag,{value:"Module"}),j})({});
|
|
2
2
|
//# sourceMappingURL=Rokt-Kit.iife.js.map
|