@mparticle/web-rokt-kit 1.36.1 → 3.1.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.
@@ -1,2 +1,2 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const me=["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"],Ee=new Set(me);function re(i){return Ee.has(i.toLowerCase())}function w(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];re(s)||(e[s]=t[s])}return e}function E(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function m(i){return typeof i=="string"}function b(i){return typeof i=="function"}function U(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function K(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}const W="__rokt_ls_probe__";function C(){try{return window.localStorage.setItem(W,"1"),window.localStorage.removeItem(W),!0}catch{return!1}}function F(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function se(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function _e(i){try{window.localStorage.removeItem(i)}catch{}}function D(i,e){const t=F(i);return E(t)?t[e]:void 0}function oe(i,e,t){const n=F(i),r=E(n)?{...n}:{};return r[e]=t,se(i,r)}function ae(i,e){const t=F(i);if(!E(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?_e(i):se(i,n)}const _="mp-rokt-kit",x="pageViews",P="utmParams",ce=25,Ie=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function le(i){return i.slice(-ce)}function H(){const i=D(_,x);return Array.isArray(i)?i:[]}function Se(i){const e=le(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(oe(_,x,n))return n.length}return 0}function V(){ae(_,x)}function ye(i){const e=le(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 Ae(i){if(D(_,P)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ie){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!oe(_,P,t)){const r=C()?"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 ke(){const i=D(_,P);return E(i)?i:null}function z(){ae(_,P)}function Re(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return K(e)}function ve(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function we(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function be(i){i.lifecycle="attached"}function Te(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function Le(i){i.lifecycle="terminated"}function Pe(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function Oe(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",T=181,Ne="selectPlacements",Ue="apps.roktecommerce.com",Ce=.1,Me="ThankYouPageJourney",Ke="rokt-launcher",Fe="rokt-thank-you-element",De="userIdentifiedInWorkspace",xe=3,Ye=2,je="page_events",Ge="page_view_attributes",We="mparticle_session_id",He="mparticle_device_id",q=500,Y={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},S={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},Ve="apps.rokt-api.com",ze="/v1/log",qe="/v1/errors",$e=10;function a(){return window.mParticle}function $(i,e){const n=[O(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function J(i){return[O(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function O(i){const e=typeof i<"u"?i:Ve;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function ue(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 O(r)+t}function B(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 L(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function Q(i){const e=i?L(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(Me)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Je(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function X(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 Z(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!m(n.value)||!m(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 ee(i,e,t){return a().generateHash([i,e,t].join(""))}function Be(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.36.1";return i&&(n+="_"+i),n}function de(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}function M(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 te(i,e){const t=de(window.location.origin);if(y._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ce)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?O(i):"https://apps.rokt.com";M(c+"/v1/wsdk-init/index.html?"+o),M("https://"+Ue+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Qe(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Xe(){return typeof window<"u"?window.location?.href:void 0}function Ze(){return typeof window<"u"?window.navigator?.userAgent:void 0}class he{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>$e}}class j{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 he,this._isEnabled=Qe()||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||Y.UNKNOWN_ERROR,url:Xe(),deviceInfo:Ze(),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 ie{constructor(e,t,n,r,s){this._transport=new j(e,t,n,r,s),this._errorUrl=ue(e?.errorUrl,e?.integrationDomain,qe)}report(e){if(!e)return;const t=e.severity||S.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class ne{constructor(e,t,n,r,s,o){this._transport=new j(e,n,r,s,o),this._loggingUrl=ue(e?.loggingUrl,e?.integrationDomain,ze),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,S.INFO,e.message,e.code,void 0,t=>{if(this._errorReportingService){const n=typeof t.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:Y.LOG_DELIVERY_FAILURE,severity:n?S.ERROR:S.WARNING})}})}}function et(i){const e=K(window.location.href),t=i.EventAttributes?.title||document.title,n=Re(),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 f=class f{constructor(){this.name=d,this.id=T,this.moduleId=T,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=ve()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||typeof n[t]>"u"?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!m(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||!m(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(U(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=K(window.location.href);const n=H(),r=et(e);n.push(r);const s=Math.min(n.length,ce),o=Se(n);if(o===0){const c=C()?"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=C()?"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"})}}isLauncherReadyToAttach(){return!!window.Rokt&&b(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[f.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!E(e))return;const t=a().EventType.Other;a().logEvent(Ne,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&b(t.setIntegrationAttribute)&&t.setIntegrationAttribute(T,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(b(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){we(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 Je([...n],o),this.initRoktLauncher(o)}).catch(o=>{Le(this._launcherAttachState),console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return Oe(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,be(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,te(this.domain,this.integrationName),a().Rokt.attachKit(this)}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.userAttributes=w(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=L(o.placementEventMapping);this.placementEventMappingLookup=X(u);const l=L(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=Z(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=m(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const p=a().Rokt?.domain,{roktExtensionsQueryParams:N,legacyRoktExtensions:R,loadThankYouElement:v}=Q(o.roktExtensions),g={...a().Rokt?.launcherOptions||{}};this.integrationName=Be(g.integrationName),g.integrationName=this.integrationName,this.domain=p;const A={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:p,isLoggingEnabled:a().config?.isLoggingEnabled===!0},I=new ie(A,this.integrationName,window.__rokt_li_guid__,o.accountId),k=new ne(A,I,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=I,this.loggingService=k,this.isTargetingDisabled())try{V(),z()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:S.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(I),a()._registerLoggingService&&a()._registerLoggingService(k),n?(this.testHelpers={generateLauncherScript:$,generateThankYouElementScript:J,extractRoktExtensionConfig:Q,hashEventMessage:ee,parseSettingsString:L,generateMappedEventLookup:X,generateMappedEventAttributeLookup:Z,sendAdBlockMeasurementSignals:te,createAutoRemovedIframe:M,djb2:de,setAllowedOriginHashes:h=>{f._allowedOriginHashes=h},ReportingTransport:j,ErrorReportingService:ie,LoggingService:ne,RateLimiter:he,ErrorCodes:Y,WSDKErrorSeverity:S,resetLauncherAttachState:()=>Pe(this._launcherAttachState)},this.attachLauncher(c,g),"Successfully initialized: "+d):(v&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),B(Fe,J(p),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:h=>{console.error("Error loading Rokt Thank You Element script:",h)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,g,R):(B(Ke,$(p,N),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,g,R):console.error("Rokt object is not available after script load.")},onError:h=>{console.error("Error loading Rokt launcher script:",h)}}),this.captureTiming(f.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===xe&&(Ae(this.loggingService),this.capturePageView(e)),e.EventDataType===Ye&&(V(),z())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(b(a().Rokt?.setLocalSessionAttribute)&&(U(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!U(this.placementEventMappingLookup))){const t=ee(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 re(e)||(this.userAttributes[e]=t),"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=w(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,"onUserIdentified")}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];m(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.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,q))]):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,q))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...w(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=w(l);const p=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},N=this.returnUserIdentities(c),R=this.returnLocalSessionAttributes(),v=ye(H()),g=ke(),A=this.readMpSessionId(),I=this.readMpDeviceId(),k={...N,...l,...p,...R,...v.length?{[je]:JSON.stringify(v)}:{},...g?{[Ge]:g}:{},...this.userIdentifiedInWorkspace?{[De]:!0}:{},...A?{[We]:A}:{},...I?{[He]:I}:{},mpid:u},h={...e,attributes:k},G=this.launcher.selectPlacements(h),pe=()=>this.logSelectPlacementsEvent(k);return Promise.resolve(G).then(ge=>ge?.context?.sessionId?.then(fe=>this.setRoktSessionId(fe))).catch(()=>{}).finally(pe),G}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!m(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()?(Te(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};f._allowedOriginHashes=[-553112570,549508659],f.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},f.EMAIL_SHA256_KEY="emailsha256";let y=f;function tt(){return T}function it(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!E(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}E(i.kits)?i.kits[d]={constructor:y}:(i.kits={},i.kits[d]={constructor:y}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:y,getId:tt});exports.register=it;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const Ee=["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"],_e=new Set(Ee);function se(i){return _e.has(i.toLowerCase())}function T(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const s=n[r];se(s)||(e[s]=t[s])}return e}function E(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function m(i){return typeof i=="string"}function b(i){return typeof i=="function"}function C(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function F(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}const H="__rokt_ls_probe__";function K(){try{return window.localStorage.setItem(H,"1"),window.localStorage.removeItem(H),!0}catch{return!1}}function x(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function oe(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function Se(i){try{window.localStorage.removeItem(i)}catch{}}function Y(i,e){const t=x(i);return E(t)?t[e]:void 0}function ae(i,e,t){const n=x(i),r=E(n)?{...n}:{};return r[e]=t,oe(i,r)}function ce(i,e){const t=x(i);if(!E(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?Se(i):oe(i,n)}const _="mp-rokt-kit",j="pageViews",O="utmParams",le=25,Ie=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function ue(i){return i.slice(-le)}function V(){const i=Y(_,j);return Array.isArray(i)?i:[]}function Ae(i){const e=ue(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(ae(_,j,n))return n.length}return 0}function z(){ce(_,j)}function ye(i){const e=ue(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 ke(i){if(Y(_,O)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ie){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!ae(_,O,t)){const r=K()?"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 Re(){const i=Y(_,O);return E(i)?i:null}function $(){ce(_,O)}function ve(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return F(e)}function M(i,e){return{message:`Rokt Kit: ${i} called [attributeKeys=${e.join(",")}]`,code:"ATTRIBUTE_SETTER_CALLED"}}function we(i){return{message:`Rokt Kit: selectPlacements dispatched [placementAttributeKeys=${i.join(",")}]`,code:"SELECT_PLACEMENTS_DISPATCHED"}}function Te(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function be(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function Le(i){i.lifecycle="attached"}function Pe(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function Oe(i){i.lifecycle="terminated"}function Ne(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function Ue(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",L=181,Ce="selectPlacements",Me="apps.roktecommerce.com",Ke=.1,De="ThankYouPageJourney",Fe="rokt-launcher",xe="rokt-thank-you-element",Ye="userIdentifiedInWorkspace",je=3,We=2,Ge="page_events",He="page_view_attributes",Ve="mparticle_session_id",ze="mparticle_device_id",q=500,W={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},A={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},$e="apps.rokt-api.com",qe="/v1/log",Be="/v1/errors",Je=10;function a(){return window.mParticle}function B(i,e){const n=[N(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function J(i){return[N(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function N(i){const e=typeof i<"u"?i:$e;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function de(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 N(r)+t}function Q(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 P(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function X(i){const e=i?P(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(De)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Qe(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function Z(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 ee(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!m(n.value)||!m(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 te(i,e,t){return a().generateHash([i,e,t].join(""))}function Xe(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"3.1.0";return i&&(n+="_"+i),n}function he(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}function D(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 ie(i,e){const t=he(window.location.origin);if(y._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ke)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?N(i):"https://apps.rokt.com";D(c+"/v1/wsdk-init/index.html?"+o),D("https://"+Me+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Ze(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function et(){return typeof window<"u"?window.location?.href:void 0}function tt(){return typeof window<"u"?window.navigator?.userAgent:void 0}class ge{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>Je}}class R{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 ge,this._isEnabled=Ze()||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||W.UNKNOWN_ERROR,url:et(),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 g=new Error("HTTP "+l.status+" from log endpoint");throw g.statusCode=l.status,g}}).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 ne{constructor(e,t,n,r,s){this._transport=new R(e,t,n,r,s),this._errorUrl=de(e?.errorUrl,e?.integrationDomain,Be)}report(e){if(!e)return;const t=e.severity||A.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class re{constructor(e,t,n,r,s,o){this._transport=new R(e,n,r,s,o),this._diagnosticTransport=new R(e,n,r,s),this._placementDiagnosticTransport=new R(e,n,r,s),this._loggingUrl=de(e?.loggingUrl,e?.integrationDomain,qe),this._errorReportingService=t}log(e){e&&this._send(this._transport,e)}logDiagnostic(e){e&&this._send(this._diagnosticTransport,e)}logPlacementDiagnostic(e){e&&this._send(this._placementDiagnosticTransport,e)}_send(e,t){e.send(this._loggingUrl,A.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:W.LOG_DELIVERY_FAILURE,severity:r?A.ERROR:A.WARNING})}})}}function it(i){const e=F(window.location.href),t=i.EventAttributes?.title||document.title,n=ve(),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 f=class f{constructor(){this.name=d,this.id=L,this.moduleId=L,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=Te()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||typeof n[t]>"u"?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!m(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||!m(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(C(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=F(window.location.href);const n=V(),r=it(e);n.push(r);const s=Math.min(n.length,le),o=Ae(n);if(o===0){const c=K()?"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=K()?"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"})}}isLauncherReadyToAttach(){return!!window.Rokt&&b(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[f.EMAIL_SHA256_KEY]=e[n]),n&&delete t[n],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!E(e))return;const t=a().EventType.Other;a().logEvent(Ce,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&b(t.setIntegrationAttribute)&&t.setIntegrationAttribute(L,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(b(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){be(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 Qe([...n],o),this.initRoktLauncher(o)}).catch(o=>{Oe(this._launcherAttachState),console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return Ue(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,Le(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,ie(this.domain,this.integrationName),a().Rokt.attachKit(this)}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.userAttributes=T(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=P(o.placementEventMapping);this.placementEventMappingLookup=Z(u);const l=P(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=ee(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=m(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const g=a().Rokt?.domain,{roktExtensionsQueryParams:U,legacyRoktExtensions:v,loadThankYouElement:w}=X(o.roktExtensions),p={...a().Rokt?.launcherOptions||{}};this.integrationName=Xe(p.integrationName),p.integrationName=this.integrationName,this.domain=g;const k={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:g,isLoggingEnabled:a().config?.isLoggingEnabled===!0},S=new ne(k,this.integrationName,window.__rokt_li_guid__,o.accountId),I=new re(k,S,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=S,this.loggingService=I,this.isTargetingDisabled())try{z(),$()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:A.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(S),a()._registerLoggingService&&a()._registerLoggingService(I),n?(this.testHelpers={generateLauncherScript:B,generateThankYouElementScript:J,extractRoktExtensionConfig:X,hashEventMessage:te,parseSettingsString:P,generateMappedEventLookup:Z,generateMappedEventAttributeLookup:ee,sendAdBlockMeasurementSignals:ie,createAutoRemovedIframe:D,djb2:he,setAllowedOriginHashes:h=>{f._allowedOriginHashes=h},ReportingTransport:R,ErrorReportingService:ne,LoggingService:re,RateLimiter:ge,ErrorCodes:W,WSDKErrorSeverity:A,resetLauncherAttachState:()=>Ne(this._launcherAttachState)},this.attachLauncher(c,p),"Successfully initialized: "+d):(w&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),Q(xe,J(g),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:h=>{console.error("Error loading Rokt Thank You Element script:",h)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,p,v):(Q(Fe,B(g,U),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,p,v):console.error("Rokt object is not available after script load.")},onError:h=>{console.error("Error loading Rokt launcher script:",h)}}),this.captureTiming(f.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===je&&(ke(this.loggingService),this.capturePageView(e)),e.EventDataType===We&&(z(),$())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(b(a().Rokt?.setLocalSessionAttribute)&&(C(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!C(this.placementEventMappingLookup))){const t=te(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 this.loggingService?.logDiagnostic(M("setUserAttribute",[e])),se(e)||(this.userAttributes[e]=t),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return this.loggingService?.logDiagnostic(M("removeUserAttribute",[e])),delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=T(e.getAllUserAttributes()),this.loggingService?.logDiagnostic(M(t,Object.keys(this.userAttributes))),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,"onUserIdentified")}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];m(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.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,q))]):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,q))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...T(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=T(l);const g=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},U=this.returnUserIdentities(c),v=this.returnLocalSessionAttributes(),w=ye(V()),p=Re(),k=this.readMpSessionId(),S=this.readMpDeviceId(),I={...U,...l,...g,...v,...w.length?{[Ge]:JSON.stringify(w)}:{},...p?{[He]:p}:{},...this.userIdentifiedInWorkspace?{[Ye]:!0}:{},...k?{[Ve]:k}:{},...S?{[ze]:S}:{},mpid:u},h={...e,attributes:I};this.loggingService?.logPlacementDiagnostic(we(Object.keys(I)));const G=this.launcher.selectPlacements(h),pe=()=>this.logSelectPlacementsEvent(I);return Promise.resolve(G).then(fe=>fe?.context?.sessionId?.then(me=>this.setRoktSessionId(me))).catch(()=>{}).finally(pe),G}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!m(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()?(Pe(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};f._allowedOriginHashes=[-553112570,549508659],f.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},f.EMAIL_SHA256_KEY="emailsha256";let y=f;function nt(){return L}function rt(i){if(!i){window.console.log("You must pass a config object to register the kit "+d);return}if(!E(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}E(i.kits)?i.kits[d]={constructor:y}:(i.kits={},i.kits[d]={constructor:y}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:y,getId:nt});exports.register=rt;
2
2
  //# sourceMappingURL=Rokt-Kit.common.js.map
@@ -11,13 +11,18 @@ declare interface LogEntry {
11
11
  }
12
12
 
13
13
  export declare class LoggingService {
14
- private _transport;
15
- private _loggingUrl;
16
- private _errorReportingService;
14
+ private readonly _transport;
15
+ private readonly _diagnosticTransport;
16
+ private readonly _placementDiagnosticTransport;
17
+ private readonly _loggingUrl;
18
+ private readonly _errorReportingService;
17
19
  constructor(config: ReportingConfig, errorReportingService: {
18
20
  report: (e: ErrorReport) => void;
19
21
  }, integrationName: string | null | undefined, launcherInstanceGuid?: string, accountId?: string | null, rateLimiter?: RateLimiter);
20
22
  log(entry: LogEntry | null | undefined): void;
23
+ logDiagnostic(entry: LogEntry | null | undefined): void;
24
+ logPlacementDiagnostic(entry: LogEntry | null | undefined): void;
25
+ private _send;
21
26
  }
22
27
 
23
28
  declare class RateLimiter {
@@ -1,4 +1,4 @@
1
- const me = [
1
+ const Ee = [
2
2
  "active_time_on_site_ms",
3
3
  "billingaddress1",
4
4
  "billingaddress2",
@@ -23,15 +23,15 @@ const me = [
23
23
  "shippingstate",
24
24
  "shippingzipcode",
25
25
  "totalprice"
26
- ], Ee = new Set(me);
27
- function re(i) {
28
- return Ee.has(i.toLowerCase());
26
+ ], _e = new Set(Ee);
27
+ function se(i) {
28
+ return _e.has(i.toLowerCase());
29
29
  }
30
- function w(i) {
30
+ function T(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];
34
- re(s) || (e[s] = t[s]);
34
+ se(s) || (e[s] = t[s]);
35
35
  }
36
36
  return e;
37
37
  }
@@ -44,10 +44,10 @@ function m(i) {
44
44
  function b(i) {
45
45
  return typeof i == "function";
46
46
  }
47
- function U(i) {
47
+ function C(i) {
48
48
  return i == null ? !0 : typeof i == "object" ? Object.keys(i).length === 0 : !1;
49
49
  }
50
- function K(i) {
50
+ function F(i) {
51
51
  try {
52
52
  const e = new URL(i);
53
53
  return e.search = "", e.toString();
@@ -55,15 +55,15 @@ function K(i) {
55
55
  return i;
56
56
  }
57
57
  }
58
- const W = "__rokt_ls_probe__";
59
- function C() {
58
+ const H = "__rokt_ls_probe__";
59
+ function K() {
60
60
  try {
61
- return window.localStorage.setItem(W, "1"), window.localStorage.removeItem(W), !0;
61
+ return window.localStorage.setItem(H, "1"), window.localStorage.removeItem(H), !0;
62
62
  } catch {
63
63
  return !1;
64
64
  }
65
65
  }
66
- function F(i) {
66
+ function x(i) {
67
67
  try {
68
68
  const e = window.localStorage.getItem(i);
69
69
  return e === null ? null : JSON.parse(e);
@@ -71,56 +71,56 @@ function F(i) {
71
71
  return null;
72
72
  }
73
73
  }
74
- function se(i, e) {
74
+ function oe(i, e) {
75
75
  try {
76
76
  return window.localStorage.setItem(i, JSON.stringify(e)), !0;
77
77
  } catch {
78
78
  return !1;
79
79
  }
80
80
  }
81
- function _e(i) {
81
+ function Se(i) {
82
82
  try {
83
83
  window.localStorage.removeItem(i);
84
84
  } catch {
85
85
  }
86
86
  }
87
- function D(i, e) {
88
- const t = F(i);
87
+ function Y(i, e) {
88
+ const t = x(i);
89
89
  return E(t) ? t[e] : void 0;
90
90
  }
91
- function oe(i, e, t) {
92
- const n = F(i), r = E(n) ? { ...n } : {};
93
- return r[e] = t, se(i, r);
91
+ function ae(i, e, t) {
92
+ const n = x(i), r = E(n) ? { ...n } : {};
93
+ return r[e] = t, oe(i, r);
94
94
  }
95
- function ae(i, e) {
96
- const t = F(i);
95
+ function ce(i, e) {
96
+ const t = x(i);
97
97
  if (!E(t) || !(e in t))
98
98
  return;
99
99
  const n = { ...t };
100
- delete n[e], Object.keys(n).length === 0 ? _e(i) : se(i, n);
100
+ delete n[e], Object.keys(n).length === 0 ? Se(i) : oe(i, n);
101
101
  }
102
- const _ = "mp-rokt-kit", x = "pageViews", P = "utmParams", ce = 25, Ie = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
103
- function le(i) {
104
- return i.slice(-ce);
102
+ const _ = "mp-rokt-kit", j = "pageViews", O = "utmParams", le = 25, Ie = ["utm_source", "utm_medium", "utm_campaign", "utm_term", "utm_content"];
103
+ function ue(i) {
104
+ return i.slice(-le);
105
105
  }
106
- function H() {
107
- const i = D(_, x);
106
+ function V() {
107
+ const i = Y(_, j);
108
108
  return Array.isArray(i) ? i : [];
109
109
  }
110
- function Se(i) {
111
- const e = le(i);
110
+ function Ae(i) {
111
+ const e = ue(i);
112
112
  for (let t = 0; t < e.length; t++) {
113
113
  const n = e.slice(t);
114
- if (oe(_, x, n))
114
+ if (ae(_, j, n))
115
115
  return n.length;
116
116
  }
117
117
  return 0;
118
118
  }
119
- function V() {
120
- ae(_, x);
119
+ function z() {
120
+ ce(_, j);
121
121
  }
122
122
  function ye(i) {
123
- const e = le(i);
123
+ const e = ue(i);
124
124
  return e.map((t, n) => {
125
125
  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;
126
126
  return {
@@ -134,8 +134,8 @@ function ye(i) {
134
134
  };
135
135
  });
136
136
  }
137
- function Ae(i) {
138
- if (D(_, P) !== void 0)
137
+ function ke(i) {
138
+ if (Y(_, O) !== void 0)
139
139
  return;
140
140
  const e = new URLSearchParams(window.location.search), t = {};
141
141
  for (const r of Ie) {
@@ -145,8 +145,8 @@ function Ae(i) {
145
145
  if (Object.keys(t).length === 0)
146
146
  return;
147
147
  const n = Object.keys(t).join(", ");
148
- if (!oe(_, P, t)) {
149
- const r = C() ? "quota" : "ls_unavailable";
148
+ if (!ae(_, O, t)) {
149
+ const r = K() ? "quota" : "ls_unavailable";
150
150
  i?.log({
151
151
  message: `Rokt Kit: Failed to persist UTM params [reason: ${r}]`,
152
152
  code: "UTM_CAPTURE_FAILED"
@@ -158,45 +158,57 @@ function Ae(i) {
158
158
  code: "UTM_CAPTURE_SUCCESS"
159
159
  });
160
160
  }
161
- function ke() {
162
- const i = D(_, P);
161
+ function Re() {
162
+ const i = Y(_, O);
163
163
  return E(i) ? i : null;
164
164
  }
165
- function z() {
166
- ae(_, P);
165
+ function $() {
166
+ ce(_, O);
167
167
  }
168
- function Re() {
168
+ function ve() {
169
169
  const e = document.querySelector('link[rel="canonical"]')?.href;
170
170
  if (e)
171
- return K(e);
171
+ return F(e);
172
172
  }
173
- function ve() {
173
+ function M(i, e) {
174
+ return {
175
+ message: `Rokt Kit: ${i} called [attributeKeys=${e.join(",")}]`,
176
+ code: "ATTRIBUTE_SETTER_CALLED"
177
+ };
178
+ }
179
+ function we(i) {
180
+ return {
181
+ message: `Rokt Kit: selectPlacements dispatched [placementAttributeKeys=${i.join(",")}]`,
182
+ code: "SELECT_PLACEMENTS_DISPATCHED"
183
+ };
184
+ }
185
+ function Te() {
174
186
  return {
175
187
  context: null,
176
188
  lifecycle: "idle",
177
189
  recreateInFlight: null
178
190
  };
179
191
  }
180
- function we(i, e) {
192
+ function be(i, e) {
181
193
  i.context = {
182
194
  accountId: e.accountId,
183
195
  launcherOptions: { ...e.launcherOptions },
184
196
  legacyRoktExtensions: [...e.legacyRoktExtensions]
185
197
  };
186
198
  }
187
- function be(i) {
199
+ function Le(i) {
188
200
  i.lifecycle = "attached";
189
201
  }
190
- function Te(i) {
202
+ function Pe(i) {
191
203
  i.lifecycle !== "idle" && (i.lifecycle = "terminated");
192
204
  }
193
- function Le(i) {
205
+ function Oe(i) {
194
206
  i.lifecycle = "terminated";
195
207
  }
196
- function Pe(i) {
208
+ function Ne(i) {
197
209
  i.context = null, i.lifecycle = "idle", i.recreateInFlight = null;
198
210
  }
199
- function Oe(i, e, t) {
211
+ function Ue(i, e, t) {
200
212
  if (i.recreateInFlight)
201
213
  return i.recreateInFlight;
202
214
  if (i.lifecycle !== "terminated" || !i.context || !e)
@@ -207,42 +219,42 @@ function Oe(i, e, t) {
207
219
  i.recreateInFlight = null;
208
220
  }), i.recreateInFlight;
209
221
  }
210
- const d = "Rokt", T = 181, Ne = "selectPlacements", Ue = "apps.roktecommerce.com", Ce = 0.1, Me = "ThankYouPageJourney", Ke = "rokt-launcher", Fe = "rokt-thank-you-element", De = "userIdentifiedInWorkspace", xe = 3, Ye = 2, Ge = "page_events", je = "page_view_attributes", We = "mparticle_session_id", He = "mparticle_device_id", q = 500, Y = {
222
+ const d = "Rokt", L = 181, Ce = "selectPlacements", Me = "apps.roktecommerce.com", Ke = 0.1, De = "ThankYouPageJourney", Fe = "rokt-launcher", xe = "rokt-thank-you-element", Ye = "userIdentifiedInWorkspace", je = 3, We = 2, Ge = "page_events", He = "page_view_attributes", Ve = "mparticle_session_id", ze = "mparticle_device_id", q = 500, W = {
211
223
  UNKNOWN_ERROR: "UNKNOWN_ERROR",
212
224
  UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
213
225
  IDENTITY_REQUEST: "IDENTITY_REQUEST",
214
226
  LOG_DELIVERY_FAILURE: "LOG_DELIVERY_FAILURE"
215
- }, S = {
227
+ }, A = {
216
228
  ERROR: "ERROR",
217
229
  INFO: "INFO",
218
230
  WARNING: "WARNING"
219
- }, Ve = "apps.rokt-api.com", ze = "/v1/log", qe = "/v1/errors", $e = 10;
231
+ }, $e = "apps.rokt-api.com", qe = "/v1/log", Be = "/v1/errors", Je = 10;
220
232
  function a() {
221
233
  return window.mParticle;
222
234
  }
223
- function $(i, e) {
224
- const n = [O(i), "/wsdk/integrations/launcher.js"].join("");
235
+ function B(i, e) {
236
+ const n = [N(i), "/wsdk/integrations/launcher.js"].join("");
225
237
  return !e || e.length === 0 ? n : n + "?extensions=" + e.join(",");
226
238
  }
227
239
  function J(i) {
228
- return [O(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
240
+ return [N(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
229
241
  }
230
- function O(i) {
231
- const e = typeof i < "u" ? i : Ve;
242
+ function N(i) {
243
+ const e = typeof i < "u" ? i : $e;
232
244
  return e.includes("://") ? e.replace(/\/+$/, "") : ["https://", e].join("");
233
245
  }
234
- function ue(i, e, t) {
246
+ function de(i, e, t) {
235
247
  if (i)
236
248
  return i.startsWith("http://") || i.startsWith("https://") ? i : "https://" + i;
237
249
  const r = e?.includes("://") && !/^https?:\/\//i.test(e) ? void 0 : e;
238
- return O(r) + t;
250
+ return N(r) + t;
239
251
  }
240
- function B(i, e, t) {
252
+ function Q(i, e, t) {
241
253
  if (document.getElementById(i)) return;
242
254
  const n = document.head || document.body, r = document.createElement("script");
243
255
  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);
244
256
  }
245
- function L(i) {
257
+ function P(i) {
246
258
  if (!i)
247
259
  return [];
248
260
  try {
@@ -252,12 +264,12 @@ function L(i) {
252
264
  }
253
265
  return [];
254
266
  }
255
- function Q(i) {
256
- const e = i ? L(i) : [], t = [], n = [];
267
+ function X(i) {
268
+ const e = i ? P(i) : [], t = [], n = [];
257
269
  let r = !1;
258
270
  for (let s = 0; s < e.length; s++) {
259
271
  const o = e[s].value;
260
- o === "thank-you-journey" ? (r = !0, n.push(Me)) : t.push(o);
272
+ o === "thank-you-journey" ? (r = !0, n.push(De)) : t.push(o);
261
273
  }
262
274
  return {
263
275
  roktExtensionsQueryParams: t,
@@ -265,14 +277,14 @@ function Q(i) {
265
277
  loadThankYouElement: r
266
278
  };
267
279
  }
268
- async function Je(i, e) {
280
+ async function Qe(i, e) {
269
281
  const t = [];
270
282
  if (e)
271
283
  for (const n of i)
272
284
  t.push(e.use(n));
273
285
  return Promise.all(t);
274
286
  }
275
- function X(i) {
287
+ function Z(i) {
276
288
  if (!i)
277
289
  return {};
278
290
  const e = {};
@@ -282,7 +294,7 @@ function X(i) {
282
294
  }
283
295
  return e;
284
296
  }
285
- function Z(i) {
297
+ function ee(i) {
286
298
  const e = {};
287
299
  if (!Array.isArray(i))
288
300
  return e;
@@ -298,20 +310,20 @@ function Z(i) {
298
310
  }
299
311
  return e;
300
312
  }
301
- function ee(i, e, t) {
313
+ function te(i, e, t) {
302
314
  return a().generateHash([i, e, t].join(""));
303
315
  }
304
- function Be(i) {
305
- let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "1.36.1";
316
+ function Xe(i) {
317
+ let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "3.1.0";
306
318
  return i && (n += "_" + i), n;
307
319
  }
308
- function de(i) {
320
+ function he(i) {
309
321
  let e = 5381;
310
322
  for (let t = 0; t < i.length; t++)
311
323
  e = (e << 5) + e + i.charCodeAt(t), e = e & e;
312
324
  return e;
313
325
  }
314
- function M(i) {
326
+ function D(i) {
315
327
  const e = document.createElement("iframe");
316
328
  e.style.display = "none", e.setAttribute("sandbox", "allow-scripts allow-same-origin"), e.src = i, e.onload = function() {
317
329
  e.onload = null, e.parentNode && e.parentNode.removeChild(e);
@@ -319,41 +331,41 @@ function M(i) {
319
331
  const t = document.body || document.head;
320
332
  t && t.appendChild(e);
321
333
  }
322
- function te(i, e) {
323
- const t = de(window.location.origin);
324
- if (y._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= Ce)
334
+ function ie(i, e) {
335
+ const t = he(window.location.origin);
336
+ if (y._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= Ke)
325
337
  return;
326
338
  const r = window.__rokt_li_guid__;
327
339
  if (!r || i && i.includes("://") && !/^https:\/\//i.test(i))
328
340
  return;
329
- const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s), c = i ? O(i) : "https://apps.rokt.com";
330
- M(c + "/v1/wsdk-init/index.html?" + o), M(
331
- "https://" + Ue + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
341
+ const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s), c = i ? N(i) : "https://apps.rokt.com";
342
+ D(c + "/v1/wsdk-init/index.html?" + o), D(
343
+ "https://" + Me + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
332
344
  );
333
345
  }
334
- function Qe() {
346
+ function Ze() {
335
347
  return typeof window < "u" && !!window.location?.search?.toLowerCase().includes("mp_enable_logging=true");
336
348
  }
337
- function Xe() {
349
+ function et() {
338
350
  return typeof window < "u" ? window.location?.href : void 0;
339
351
  }
340
- function Ze() {
352
+ function tt() {
341
353
  return typeof window < "u" ? window.navigator?.userAgent : void 0;
342
354
  }
343
- class he {
355
+ class ge {
344
356
  constructor() {
345
357
  this._logCount = {};
346
358
  }
347
359
  incrementAndCheck(e) {
348
360
  const n = (this._logCount[e] || 0) + 1;
349
- return this._logCount[e] = n, n > $e;
361
+ return this._logCount[e] = n, n > Je;
350
362
  }
351
363
  }
352
- class G {
364
+ class R {
353
365
  constructor(e, t, n, r, s) {
354
366
  this._reporter = "mp-wsdk";
355
367
  const o = e.isLoggingEnabled;
356
- this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new he(), this._isEnabled = Qe() || o;
368
+ this._integrationName = t || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = s || new ge(), this._isEnabled = Ze() || o;
357
369
  }
358
370
  send(e, t, n, r, s, o) {
359
371
  if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(t)))
@@ -364,9 +376,9 @@ class G {
364
376
  version: this._integrationName
365
377
  },
366
378
  severity: t,
367
- code: r || Y.UNKNOWN_ERROR,
368
- url: Xe(),
369
- deviceInfo: Ze(),
379
+ code: r || W.UNKNOWN_ERROR,
380
+ url: et(),
381
+ deviceInfo: tt(),
370
382
  stackTrace: s,
371
383
  reporter: this._reporter,
372
384
  integration: this._integrationName
@@ -382,8 +394,8 @@ class G {
382
394
  body: JSON.stringify(c)
383
395
  }).then((l) => {
384
396
  if (!l.ok) {
385
- const p = new Error("HTTP " + l.status + " from log endpoint");
386
- throw p.statusCode = l.status, p;
397
+ const g = new Error("HTTP " + l.status + " from log endpoint");
398
+ throw g.statusCode = l.status, g;
387
399
  }
388
400
  }).catch((l) => {
389
401
  console.error("ReportingTransport: Failed to send log", l), o && o(l);
@@ -393,42 +405,56 @@ class G {
393
405
  }
394
406
  }
395
407
  }
396
- class ie {
408
+ class ne {
397
409
  constructor(e, t, n, r, s) {
398
- this._transport = new G(e, t, n, r, s), this._errorUrl = ue(e?.errorUrl, e?.integrationDomain, qe);
410
+ this._transport = new R(e, t, n, r, s), this._errorUrl = de(e?.errorUrl, e?.integrationDomain, Be);
399
411
  }
400
412
  report(e) {
401
413
  if (!e) return;
402
- const t = e.severity || S.ERROR;
414
+ const t = e.severity || A.ERROR;
403
415
  this._transport.send(this._errorUrl, t, e.message, e.code, e.stackTrace);
404
416
  }
405
417
  }
406
- class ne {
418
+ class re {
407
419
  constructor(e, t, n, r, s, o) {
408
- this._transport = new G(e, n, r, s, o), this._loggingUrl = ue(e?.loggingUrl, e?.integrationDomain, ze), this._errorReportingService = t;
420
+ this._transport = new R(e, n, r, s, o), this._diagnosticTransport = new R(e, n, r, s), this._placementDiagnosticTransport = new R(
421
+ e,
422
+ n,
423
+ r,
424
+ s
425
+ ), this._loggingUrl = de(e?.loggingUrl, e?.integrationDomain, qe), this._errorReportingService = t;
409
426
  }
410
427
  log(e) {
411
- e && this._transport.send(
428
+ e && this._send(this._transport, e);
429
+ }
430
+ logDiagnostic(e) {
431
+ e && this._send(this._diagnosticTransport, e);
432
+ }
433
+ logPlacementDiagnostic(e) {
434
+ e && this._send(this._placementDiagnosticTransport, e);
435
+ }
436
+ _send(e, t) {
437
+ e.send(
412
438
  this._loggingUrl,
413
- S.INFO,
414
- e.message,
415
- e.code,
439
+ A.INFO,
440
+ t.message,
441
+ t.code,
416
442
  void 0,
417
- (t) => {
443
+ (n) => {
418
444
  if (this._errorReportingService) {
419
- const n = typeof t.statusCode == "number";
445
+ const r = typeof n.statusCode == "number";
420
446
  this._errorReportingService.report({
421
- message: "LoggingService: Failed to send log: " + t.message,
422
- code: Y.LOG_DELIVERY_FAILURE,
423
- severity: n ? S.ERROR : S.WARNING
447
+ message: "LoggingService: Failed to send log: " + n.message,
448
+ code: W.LOG_DELIVERY_FAILURE,
449
+ severity: r ? A.ERROR : A.WARNING
424
450
  });
425
451
  }
426
452
  }
427
453
  );
428
454
  }
429
455
  }
430
- function et(i) {
431
- const e = K(window.location.href), t = i.EventAttributes?.title || document.title, n = Re(), r = i.ActiveTimeOnSite;
456
+ function it(i) {
457
+ const e = F(window.location.href), t = i.EventAttributes?.title || document.title, n = ve(), r = i.ActiveTimeOnSite;
432
458
  return {
433
459
  pageUrl: e,
434
460
  sourceMessageId: i.SourceMessageId,
@@ -440,7 +466,7 @@ function et(i) {
440
466
  }
441
467
  const f = class f {
442
468
  constructor() {
443
- this.name = d, this.id = T, this.moduleId = T, 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 = ve();
469
+ this.name = d, this.id = L, this.moduleId = L, 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 = Te();
444
470
  }
445
471
  // ---- Private helpers ----
446
472
  getEventAttributeValue(e, t) {
@@ -471,7 +497,7 @@ const f = class f {
471
497
  const t = Object.keys(this.placementEventAttributeMappingLookup);
472
498
  for (let n = 0; n < t.length; n++) {
473
499
  const r = t[n], s = this.placementEventAttributeMappingLookup[r];
474
- if (U(s))
500
+ if (C(s))
475
501
  continue;
476
502
  let o = !0;
477
503
  for (let c = 0; c < s.length; c++)
@@ -485,12 +511,12 @@ const f = class f {
485
511
  capturePageView(e) {
486
512
  let t;
487
513
  try {
488
- t = K(window.location.href);
489
- const n = H(), r = et(e);
514
+ t = F(window.location.href);
515
+ const n = V(), r = it(e);
490
516
  n.push(r);
491
- const s = Math.min(n.length, ce), o = Se(n);
517
+ const s = Math.min(n.length, le), o = Ae(n);
492
518
  if (o === 0) {
493
- const c = C() ? "quota" : "ls_unavailable";
519
+ const c = K() ? "quota" : "ls_unavailable";
494
520
  this.loggingService?.log({
495
521
  message: `Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,
496
522
  code: "PAGE_VIEW_CAPTURE_FAILED"
@@ -500,7 +526,7 @@ const f = class f {
500
526
  code: "PAGE_VIEW_QUOTA_EVICTION"
501
527
  });
502
528
  } catch (n) {
503
- const r = C() ? "exception" : "ls_unavailable", s = n instanceof Error ? n.message : String(n);
529
+ const r = K() ? "exception" : "ls_unavailable", s = n instanceof Error ? n.message : String(n);
504
530
  this.loggingService?.log({
505
531
  message: `Rokt Kit: Failed to capture page view for ${t}: ${s} [reason: ${r}]`,
506
532
  code: "PAGE_VIEW_CAPTURE_FAILED"
@@ -530,13 +556,13 @@ const f = class f {
530
556
  if (!window.mParticle || typeof a().logEvent != "function" || !E(e))
531
557
  return;
532
558
  const t = a().EventType.Other;
533
- a().logEvent(Ne, t, e);
559
+ a().logEvent(Ce, t, e);
534
560
  }
535
561
  setRoktSessionId(e) {
536
562
  if (!(!e || typeof e != "string"))
537
563
  try {
538
564
  const t = a().getInstance();
539
- t && b(t.setIntegrationAttribute) && t.setIntegrationAttribute(T, {
565
+ t && b(t.setIntegrationAttribute) && t.setIntegrationAttribute(L, {
540
566
  roktSessionId: e
541
567
  });
542
568
  } catch {
@@ -551,7 +577,7 @@ const f = class f {
551
577
  return a()?.getDeviceId?.() || void 0;
552
578
  }
553
579
  attachLauncher(e, t, n = []) {
554
- we(this._launcherAttachState, {
580
+ be(this._launcherAttachState, {
555
581
  accountId: e,
556
582
  launcherOptions: t || {},
557
583
  legacyRoktExtensions: n
@@ -562,22 +588,22 @@ const f = class f {
562
588
  };
563
589
  let s;
564
590
  return this.isPartnerInLocalLauncherTestGroup() ? s = Promise.resolve(window.Rokt.createLocalLauncher(r)) : s = window.Rokt.createLauncher(r), s.then(async (o) => {
565
- await Je([...n], o), this.initRoktLauncher(o);
591
+ await Qe([...n], o), this.initRoktLauncher(o);
566
592
  }).catch((o) => {
567
- Le(this._launcherAttachState), console.error("Error creating Rokt launcher:", o);
593
+ Oe(this._launcherAttachState), console.error("Error creating Rokt launcher:", o);
568
594
  });
569
595
  }
570
596
  recreateLauncherIfTerminated() {
571
- return Oe(
597
+ return Ue(
572
598
  this._launcherAttachState,
573
599
  this.isLauncherReadyToAttach(),
574
600
  (e) => this.attachLauncher(e.accountId, e.launcherOptions, e.legacyRoktExtensions)
575
601
  );
576
602
  }
577
603
  initRoktLauncher(e) {
578
- window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e, be(this._launcherAttachState);
604
+ window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e, Le(this._launcherAttachState);
579
605
  const t = a().Rokt?.filters;
580
- 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, te(this.domain, this.integrationName), a().Rokt.attachKit(this);
606
+ 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, ie(this.domain, this.integrationName), a().Rokt.attachKit(this);
581
607
  }
582
608
  fetchOptimizely() {
583
609
  const e = a()._getActiveForwarders().filter((t) => t.name === "Optimizely");
@@ -614,78 +640,78 @@ const f = class f {
614
640
  */
615
641
  init(e, t, n, r, s) {
616
642
  const o = e, c = o.accountId;
617
- this.userAttributes = w(s), this._onboardingExpProvider = o.onboardingExpProvider;
618
- const u = L(o.placementEventMapping);
619
- this.placementEventMappingLookup = X(u);
620
- const l = L(
643
+ this.userAttributes = T(s), this._onboardingExpProvider = o.onboardingExpProvider;
644
+ const u = P(o.placementEventMapping);
645
+ this.placementEventMappingLookup = Z(u);
646
+ const l = P(
621
647
  o.placementEventAttributeMapping
622
648
  );
623
- this.placementEventAttributeMappingLookup = Z(l), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = m(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
624
- const p = a().Rokt?.domain, { roktExtensionsQueryParams: N, legacyRoktExtensions: R, loadThankYouElement: v } = Q(
649
+ this.placementEventAttributeMappingLookup = ee(l), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = m(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
650
+ const g = a().Rokt?.domain, { roktExtensionsQueryParams: U, legacyRoktExtensions: v, loadThankYouElement: w } = X(
625
651
  o.roktExtensions
626
- ), g = {
652
+ ), p = {
627
653
  ...a().Rokt?.launcherOptions || {}
628
654
  };
629
- this.integrationName = Be(g.integrationName), g.integrationName = this.integrationName, this.domain = p;
630
- const A = {
655
+ this.integrationName = Xe(p.integrationName), p.integrationName = this.integrationName, this.domain = g;
656
+ const k = {
631
657
  loggingUrl: o.loggingUrl,
632
658
  errorUrl: o.errorUrl,
633
- integrationDomain: p,
659
+ integrationDomain: g,
634
660
  isLoggingEnabled: a().config?.isLoggingEnabled === !0
635
- }, I = new ie(
636
- A,
661
+ }, S = new ne(
662
+ k,
637
663
  this.integrationName,
638
664
  window.__rokt_li_guid__,
639
665
  o.accountId
640
- ), k = new ne(
641
- A,
642
- I,
666
+ ), I = new re(
667
+ k,
668
+ S,
643
669
  this.integrationName,
644
670
  window.__rokt_li_guid__,
645
671
  o.accountId
646
672
  );
647
- if (this.errorReportingService = I, this.loggingService = k, this.isTargetingDisabled())
673
+ if (this.errorReportingService = S, this.loggingService = I, this.isTargetingDisabled())
648
674
  try {
649
- V(), z();
675
+ z(), $();
650
676
  } catch (h) {
651
677
  this.errorReportingService?.report({
652
678
  message: "Rokt Kit: Failed to clear page views when targeting is disabled",
653
679
  code: "PAGE_VIEW_CAPTURE_FAILED",
654
- severity: S.INFO,
680
+ severity: A.INFO,
655
681
  stackTrace: h instanceof Error ? h.stack : void 0
656
682
  });
657
683
  }
658
- return a()._registerErrorReportingService && a()._registerErrorReportingService(I), a()._registerLoggingService && a()._registerLoggingService(k), n ? (this.testHelpers = {
659
- generateLauncherScript: $,
684
+ return a()._registerErrorReportingService && a()._registerErrorReportingService(S), a()._registerLoggingService && a()._registerLoggingService(I), n ? (this.testHelpers = {
685
+ generateLauncherScript: B,
660
686
  generateThankYouElementScript: J,
661
- extractRoktExtensionConfig: Q,
662
- hashEventMessage: ee,
663
- parseSettingsString: L,
664
- generateMappedEventLookup: X,
665
- generateMappedEventAttributeLookup: Z,
666
- sendAdBlockMeasurementSignals: te,
667
- createAutoRemovedIframe: M,
668
- djb2: de,
687
+ extractRoktExtensionConfig: X,
688
+ hashEventMessage: te,
689
+ parseSettingsString: P,
690
+ generateMappedEventLookup: Z,
691
+ generateMappedEventAttributeLookup: ee,
692
+ sendAdBlockMeasurementSignals: ie,
693
+ createAutoRemovedIframe: D,
694
+ djb2: he,
669
695
  setAllowedOriginHashes: (h) => {
670
696
  f._allowedOriginHashes = h;
671
697
  },
672
- ReportingTransport: G,
673
- ErrorReportingService: ie,
674
- LoggingService: ne,
675
- RateLimiter: he,
676
- ErrorCodes: Y,
677
- WSDKErrorSeverity: S,
678
- resetLauncherAttachState: () => Pe(this._launcherAttachState)
679
- }, this.attachLauncher(c, g), "Successfully initialized: " + d) : (v && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), B(Fe, J(p), {
698
+ ReportingTransport: R,
699
+ ErrorReportingService: ne,
700
+ LoggingService: re,
701
+ RateLimiter: ge,
702
+ ErrorCodes: W,
703
+ WSDKErrorSeverity: A,
704
+ resetLauncherAttachState: () => Ne(this._launcherAttachState)
705
+ }, this.attachLauncher(c, p), "Successfully initialized: " + d) : (w && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), Q(xe, J(g), {
680
706
  onLoad: () => {
681
707
  this._isThankYouElementLoaded = !0, this._thankYouElementOnLoadCallback && this._thankYouElementOnLoadCallback();
682
708
  },
683
709
  onError: (h) => {
684
710
  console.error("Error loading Rokt Thank You Element script:", h);
685
711
  }
686
- })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, g, R) : (B(Ke, $(p, N), {
712
+ })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, v) : (Q(Fe, B(g, U), {
687
713
  onLoad: () => {
688
- this.isLauncherReadyToAttach() ? this.attachLauncher(c, g, R) : console.error("Rokt object is not available after script load.");
714
+ this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, v) : console.error("Rokt object is not available after script load.");
689
715
  },
690
716
  onError: (h) => {
691
717
  console.error("Error loading Rokt launcher script:", h);
@@ -693,10 +719,10 @@ const f = class f {
693
719
  }), this.captureTiming(f.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + d);
694
720
  }
695
721
  process(e) {
696
- if (this.isTargetingDisabled() || (e.EventDataType === xe && (Ae(this.loggingService), this.capturePageView(e)), e.EventDataType === Ye && (V(), z())), !this.isKitReady())
722
+ if (this.isTargetingDisabled() || (e.EventDataType === je && (ke(this.loggingService), this.capturePageView(e)), e.EventDataType === We && (z(), $())), !this.isKitReady())
697
723
  return "Kit not ready for forwarder: " + d;
698
- if (b(a().Rokt?.setLocalSessionAttribute) && (U(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !U(this.placementEventMappingLookup))) {
699
- const t = ee(e.EventDataType, e.EventCategory, e.EventName ?? "");
724
+ if (b(a().Rokt?.setLocalSessionAttribute) && (C(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !C(this.placementEventMappingLookup))) {
725
+ const t = te(e.EventDataType, e.EventCategory, e.EventName ?? "");
700
726
  this.placementEventMappingLookup[String(t)] && a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)], !0);
701
727
  }
702
728
  return "Successfully sent to forwarder: " + d;
@@ -709,13 +735,13 @@ const f = class f {
709
735
  window.Rokt.setExtensionData(e);
710
736
  }
711
737
  setUserAttribute(e, t) {
712
- return re(e) || (this.userAttributes[e] = t), "Successfully set user attribute for forwarder: " + d;
738
+ return this.loggingService?.logDiagnostic(M("setUserAttribute", [e])), se(e) || (this.userAttributes[e] = t), "Successfully set user attribute for forwarder: " + d;
713
739
  }
714
740
  removeUserAttribute(e) {
715
- return delete this.userAttributes[e], "Successfully removed user attribute for forwarder: " + d;
741
+ return this.loggingService?.logDiagnostic(M("removeUserAttribute", [e])), delete this.userAttributes[e], "Successfully removed user attribute for forwarder: " + d;
716
742
  }
717
743
  handleIdentityComplete(e, t) {
718
- return this.userAttributes = w(e.getAllUserAttributes()), "Successfully called " + t + " for forwarder: " + d;
744
+ return this.userAttributes = T(e.getAllUserAttributes()), this.loggingService?.logDiagnostic(M(t, Object.keys(this.userAttributes))), "Successfully called " + t + " for forwarder: " + d;
719
745
  }
720
746
  onUserIdentified(e) {
721
747
  const t = e;
@@ -802,23 +828,27 @@ const f = class f {
802
828
  return this._dispatchPlacements(e);
803
829
  }
804
830
  _dispatchPlacements(e) {
805
- const t = e && e.attributes || {}, r = { ...w(this.userAttributes), ...t }, s = this.filters || {}, o = s.userAttributeFilters || [], c = s.filteredUser || null, u = c ? c.getMPID() : null;
831
+ const t = e && e.attributes || {}, r = { ...T(this.userAttributes), ...t }, s = this.filters || {}, o = s.userAttributeFilters || [], c = s.filteredUser || null, u = c ? c.getMPID() : null;
806
832
  let l;
807
- s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes = w(l);
808
- const p = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, N = this.returnUserIdentities(c), R = this.returnLocalSessionAttributes(), v = ye(H()), g = ke(), A = this.readMpSessionId(), I = this.readMpDeviceId(), k = {
809
- ...N,
833
+ s ? s.filterUserAttributes ? l = s.filterUserAttributes(r, o) : l = r : (console.warn("Rokt Kit: No filters available, using user attributes"), l = r), this.userAttributes = T(l);
834
+ const g = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, U = this.returnUserIdentities(c), v = this.returnLocalSessionAttributes(), w = ye(V()), p = Re(), k = this.readMpSessionId(), S = this.readMpDeviceId(), I = {
835
+ ...U,
810
836
  ...l,
811
- ...p,
812
- ...R,
813
- ...v.length ? { [Ge]: JSON.stringify(v) } : {},
814
- ...g ? { [je]: g } : {},
815
- ...this.userIdentifiedInWorkspace ? { [De]: !0 } : {},
816
- ...A ? { [We]: A } : {},
817
- ...I ? { [He]: I } : {},
837
+ ...g,
838
+ ...v,
839
+ ...w.length ? { [Ge]: JSON.stringify(w) } : {},
840
+ ...p ? { [He]: p } : {},
841
+ ...this.userIdentifiedInWorkspace ? { [Ye]: !0 } : {},
842
+ ...k ? { [Ve]: k } : {},
843
+ ...S ? { [ze]: S } : {},
818
844
  mpid: u
819
- }, h = { ...e, attributes: k }, j = this.launcher.selectPlacements(h), pe = () => this.logSelectPlacementsEvent(k);
820
- return Promise.resolve(j).then((ge) => ge?.context?.sessionId?.then((fe) => this.setRoktSessionId(fe))).catch(() => {
821
- }).finally(pe), j;
845
+ }, h = { ...e, attributes: I };
846
+ this.loggingService?.logPlacementDiagnostic(
847
+ we(Object.keys(I))
848
+ );
849
+ const G = this.launcher.selectPlacements(h), pe = () => this.logSelectPlacementsEvent(I);
850
+ return Promise.resolve(G).then((fe) => fe?.context?.sessionId?.then((me) => this.setRoktSessionId(me))).catch(() => {
851
+ }).finally(pe), G;
822
852
  }
823
853
  /**
824
854
  * Passes attributes to the Rokt Web SDK for client-side hashing.
@@ -844,7 +874,7 @@ const f = class f {
844
874
  * here would flip the kit to not-ready with no drain path for queued calls.
845
875
  */
846
876
  terminate() {
847
- return this.isKitReady() ? (Te(this._launcherAttachState), this.launcher.terminate()) : (console.error("Rokt Kit: Not initialized"), Promise.resolve());
877
+ return this.isKitReady() ? (Pe(this._launcherAttachState), this.launcher.terminate()) : (console.error("Rokt Kit: Not initialized"), Promise.resolve());
848
878
  }
849
879
  /**
850
880
  * Registers a callback to be invoked once rokt-thank-you-element.js becomes available.
@@ -857,10 +887,10 @@ f._allowedOriginHashes = [-553112570, 549508659], f.PERFORMANCE_MARKS = {
857
887
  RoktScriptAppended: "mp:RoktScriptAppended"
858
888
  }, f.EMAIL_SHA256_KEY = "emailsha256";
859
889
  let y = f;
860
- function tt() {
861
- return T;
890
+ function nt() {
891
+ return L;
862
892
  }
863
- function it(i) {
893
+ function rt(i) {
864
894
  if (!i) {
865
895
  window.console.log("You must pass a config object to register the kit " + d);
866
896
  return;
@@ -878,9 +908,9 @@ function it(i) {
878
908
  typeof window < "u" && window.mParticle && a().addForwarder && a().addForwarder({
879
909
  name: d,
880
910
  constructor: y,
881
- getId: tt
911
+ getId: nt
882
912
  });
883
913
  export {
884
- it as register
914
+ rt as register
885
915
  };
886
916
  //# sourceMappingURL=Rokt-Kit.esm.js.map
@@ -1,2 +1,2 @@
1
- var RoktKit=(function(N){"use strict";const ge=["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"],fe=new Set(ge);function W(i){return fe.has(i.toLowerCase())}function R(i){const e={},t=i||{},n=Object.keys(t);for(let r=0;r<n.length;r++){const o=n[r];W(o)||(e[o]=t[o])}return e}function m(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function E(i){return typeof i=="string"}function v(i){return typeof i=="function"}function U(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function C(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}const H="__rokt_ls_probe__";function M(){try{return window.localStorage.setItem(H,"1"),window.localStorage.removeItem(H),!0}catch{return!1}}function K(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function V(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function me(i){try{window.localStorage.removeItem(i)}catch{}}function F(i,e){const t=K(i);return m(t)?t[e]:void 0}function z(i,e,t){const n=K(i),r=m(n)?{...n}:{};return r[e]=t,V(i,r)}function q(i,e){const t=K(i);if(!m(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?me(i):V(i,n)}const _="mp-rokt-kit",D="pageViews",w="utmParams",$=25,Ee=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function J(i){return i.slice(-$)}function B(){const i=F(_,D);return Array.isArray(i)?i:[]}function _e(i){const e=J(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if(z(_,D,n))return n.length}return 0}function Q(){q(_,D)}function Ie(i){const e=J(i);return e.map((t,n)=>{const r=t.activeTimeOnSite,o=r!==void 0&&Number.isFinite(r),c=e[n+1]?.activeTimeOnSite,u=c!==void 0&&Number.isFinite(c),l=o&&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}:{},...o?{activeTimeOnSite:r}:{},...l!==void 0&&l>=0?{activeTimeOnPage:l}:{}}})}function Se(i){if(F(_,w)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of Ee){const o=e.get(r);o&&(t[r]=o)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!z(_,w,t)){const r=M()?"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 ye(){const i=F(_,w);return m(i)?i:null}function X(){q(_,w)}function Ae(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return C(e)}function ke(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function Re(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function ve(i){i.lifecycle="attached"}function we(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function be(i){i.lifecycle="terminated"}function Te(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function Le(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",b=181,Pe="selectPlacements",Oe="apps.roktecommerce.com",Ne=.1,Ue="ThankYouPageJourney",Ce="rokt-launcher",Me="rokt-thank-you-element",Ke="userIdentifiedInWorkspace",Fe=3,De=2,xe="page_events",Ye="page_view_attributes",je="mparticle_session_id",Ge="mparticle_device_id",Z=500,x={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},I={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},We="apps.rokt-api.com",He="/v1/log",Ve="/v1/errors",ze=10;function a(){return window.mParticle}function ee(i,e){const n=[T(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function te(i){return[T(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function T(i){const e=typeof i<"u"?i:We;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function ie(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 T(r)+t}function ne(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 L(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function re(i){const e=i?L(i):[],t=[],n=[];let r=!1;for(let o=0;o<e.length;o++){const s=e[o].value;s==="thank-you-journey"?(r=!0,n.push(Ue)):t.push(s)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function qe(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function oe(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||!E(n.value)||!E(n.map))continue;const r=n.value,o=n.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:o,conditions:Array.isArray(n.conditions)?n.conditions:[]})}return e}function ae(i,e,t){return a().generateHash([i,e,t].join(""))}function $e(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.36.1";return i&&(n+="_"+i),n}function ce(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}function Y(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 le(i,e){const t=ce(window.location.origin);if(S._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ne)return;const r=window.__rokt_li_guid__;if(!r||i&&i.includes("://")&&!/^https:\/\//i.test(i))return;const o=window.location.href.split("?")[0].split("#")[0],s="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(o),c=i?T(i):"https://apps.rokt.com";Y(c+"/v1/wsdk-init/index.html?"+s),Y("https://"+Oe+"/v1/wsdk-init/index.html?"+s+"&isControl=true")}function Je(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Be(){return typeof window<"u"?window.location?.href:void 0}function Qe(){return typeof window<"u"?window.navigator?.userAgent:void 0}class ue{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>ze}}class j{constructor(e,t,n,r,o){this._reporter="mp-wsdk";const s=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=n,this._accountId=r||null,this._rateLimiter=o||new ue,this._isEnabled=Je()||s}send(e,t,n,r,o,s){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:t,code:r||x.UNKNOWN_ERROR,url:Be(),deviceInfo:Qe(),stackTrace:o,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),s&&s(l)})}catch(c){console.error("ReportingTransport: Failed to send log",c),s&&s(c)}}}class de{constructor(e,t,n,r,o){this._transport=new j(e,t,n,r,o),this._errorUrl=ie(e?.errorUrl,e?.integrationDomain,Ve)}report(e){if(!e)return;const t=e.severity||I.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class he{constructor(e,t,n,r,o,s){this._transport=new j(e,n,r,o,s),this._loggingUrl=ie(e?.loggingUrl,e?.integrationDomain,He),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,I.INFO,e.message,e.code,void 0,t=>{if(this._errorReportingService){const n=typeof t.statusCode=="number";this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:x.LOG_DELIVERY_FAILURE,severity:n?I.ERROR:I.WARNING})}})}}function Xe(i){const e=C(window.location.href),t=i.EventAttributes?.title||document.title,n=Ae(),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 g=class g{constructor(){this.name=d,this.id=b,this.moduleId=b,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=ke()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||typeof n[t]>"u"?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!E(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||!E(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 o=0;o<n.length;o++)if(!this.doesEventAttributeConditionMatch(n[o],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],o=this.placementEventAttributeMappingLookup[r];if(U(o))continue;let s=!0;for(let c=0;c<o.length;c++)if(!this.doesEventMatchRule(e,o[c])){s=!1;break}s&&a().Rokt.setLocalSessionAttribute?.(r,!0)}}capturePageView(e){let t;try{t=C(window.location.href);const n=B(),r=Xe(e);n.push(r);const o=Math.min(n.length,$),s=_e(n);if(s===0){const c=M()?"quota":"ls_unavailable";this.loggingService?.log({message:`Rokt Kit: Failed to persist page view for ${t} [reason: ${c}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}else s<o&&this.loggingService?.log({message:`Rokt Kit: Page view storage reduced from ${o} to ${s} record(s) under quota pressure [reason: quota_eviction]`,code:"PAGE_VIEW_QUOTA_EVICTION"})}catch(n){const r=M()?"exception":"ls_unavailable",o=n instanceof Error?n.message:String(n);this.loggingService?.log({message:`Rokt Kit: Failed to capture page view for ${t}: ${o} [reason: ${r}]`,code:"PAGE_VIEW_CAPTURE_FAILED"})}}isLauncherReadyToAttach(){return!!window.Rokt&&v(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[g.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(Pe,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&v(t.setIntegrationAttribute)&&t.setIntegrationAttribute(b,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(v(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){Re(this._launcherAttachState,{accountId:e,launcherOptions:t||{},legacyRoktExtensions:n});const r={accountId:e,...t||{}};let o;return this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(r)):o=window.Rokt.createLauncher(r),o.then(async s=>{await qe([...n],s),this.initRoktLauncher(s)}).catch(s=>{be(this._launcherAttachState),console.error("Error creating Rokt launcher:",s)})}recreateLauncherIfTerminated(){return Le(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,ve(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,le(this.domain,this.integrationName),a().Rokt.attachKit(this)}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((o,s)=>(o["rokt.custom.optimizely.experiment."+s+".variationId"]=t.getVariationMap()[s].id,o),{})}}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,o){const s=e,c=s.accountId;this.userAttributes=R(o),this._onboardingExpProvider=s.onboardingExpProvider;const u=L(s.placementEventMapping);this.placementEventMappingLookup=oe(u);const l=L(s.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=se(l),s.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=s.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=E(s.workspaceIdSyncApiKey)?s.workspaceIdSyncApiKey:void 0;const p=a().Rokt?.domain,{roktExtensionsQueryParams:G,legacyRoktExtensions:P,loadThankYouElement:O}=re(s.roktExtensions),f={...a().Rokt?.launcherOptions||{}};this.integrationName=$e(f.integrationName),f.integrationName=this.integrationName,this.domain=p;const A={loggingUrl:s.loggingUrl,errorUrl:s.errorUrl,integrationDomain:p,isLoggingEnabled:a().config?.isLoggingEnabled===!0},y=new de(A,this.integrationName,window.__rokt_li_guid__,s.accountId),k=new he(A,y,this.integrationName,window.__rokt_li_guid__,s.accountId);if(this.errorReportingService=y,this.loggingService=k,this.isTargetingDisabled())try{Q(),X()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:I.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(y),a()._registerLoggingService&&a()._registerLoggingService(k),n?(this.testHelpers={generateLauncherScript:ee,generateThankYouElementScript:te,extractRoktExtensionConfig:re,hashEventMessage:ae,parseSettingsString:L,generateMappedEventLookup:oe,generateMappedEventAttributeLookup:se,sendAdBlockMeasurementSignals:le,createAutoRemovedIframe:Y,djb2:ce,setAllowedOriginHashes:h=>{g._allowedOriginHashes=h},ReportingTransport:j,ErrorReportingService:de,LoggingService:he,RateLimiter:ue,ErrorCodes:x,WSDKErrorSeverity:I,resetLauncherAttachState:()=>Te(this._launcherAttachState)},this.attachLauncher(c,f),"Successfully initialized: "+d):(O&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),ne(Me,te(p),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:h=>{console.error("Error loading Rokt Thank You Element script:",h)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,f,P):(ne(Ce,ee(p,G),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,f,P):console.error("Rokt object is not available after script load.")},onError:h=>{console.error("Error loading Rokt launcher script:",h)}}),this.captureTiming(g.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===Fe&&(Se(this.loggingService),this.capturePageView(e)),e.EventDataType===De&&(Q(),X())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(v(a().Rokt?.setLocalSessionAttribute)&&(U(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!U(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: "+d}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return W(e)||(this.userAttributes[e]=t),"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=R(e.getAllUserAttributes()),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,"onUserIdentified")}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,o={};if(r)for(const u of Object.keys(r)){const l=r[u];E(l)&&l.length>0&&(o[u]=l)}const s=Object.keys(o);if(s.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=s.sort().map(u=>`${u}=${o[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{n(t,o,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.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(o=>setTimeout(o,Z))]):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,Z))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...R(this.userAttributes),...t},o=this.filters||{},s=o.userAttributeFilters||[],c=o.filteredUser||null,u=c?c.getMPID():null;let l;o?o.filterUserAttributes?l=o.filterUserAttributes(r,s):l=r:(console.warn("Rokt Kit: No filters available, using user attributes"),l=r),this.userAttributes=R(l);const p=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},G=this.returnUserIdentities(c),P=this.returnLocalSessionAttributes(),O=Ie(B()),f=ye(),A=this.readMpSessionId(),y=this.readMpDeviceId(),k={...G,...l,...p,...P,...O.length?{[xe]:JSON.stringify(O)}:{},...f?{[Ye]:f}:{},...this.userIdentifiedInWorkspace?{[Ke]:!0}:{},...A?{[je]:A}:{},...y?{[Ge]:y}:{},mpid:u},h={...e,attributes:k},pe=this.launcher.selectPlacements(h),tt=()=>this.logSelectPlacementsEvent(k);return Promise.resolve(pe).then(it=>it?.context?.sessionId?.then(nt=>this.setRoktSessionId(nt))).catch(()=>{}).finally(tt),pe}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!E(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()?(we(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};g._allowedOriginHashes=[-553112570,549508659],g.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},g.EMAIL_SHA256_KEY="emailsha256";let S=g;function Ze(){return b}function et(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")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:S,getId:Ze}),N.register=et,Object.defineProperty(N,Symbol.toStringTag,{value:"Module"}),N})({});
1
+ var RoktKit=(function(U){"use strict";const fe=["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"],me=new Set(fe);function H(i){return me.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];H(s)||(e[s]=t[s])}return e}function m(i){return typeof i=="object"&&i!==null&&!Array.isArray(i)}function E(i){return typeof i=="string"}function w(i){return typeof i=="function"}function C(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:!1}function M(i){try{const e=new URL(i);return e.search="",e.toString()}catch{return i}}const V="__rokt_ls_probe__";function K(){try{return window.localStorage.setItem(V,"1"),window.localStorage.removeItem(V),!0}catch{return!1}}function D(i){try{const e=window.localStorage.getItem(i);return e===null?null:JSON.parse(e)}catch{return null}}function z(i,e){try{return window.localStorage.setItem(i,JSON.stringify(e)),!0}catch{return!1}}function Ee(i){try{window.localStorage.removeItem(i)}catch{}}function F(i,e){const t=D(i);return m(t)?t[e]:void 0}function $(i,e,t){const n=D(i),r=m(n)?{...n}:{};return r[e]=t,z(i,r)}function q(i,e){const t=D(i);if(!m(t)||!(e in t))return;const n={...t};delete n[e],Object.keys(n).length===0?Ee(i):z(i,n)}const _="mp-rokt-kit",x="pageViews",T="utmParams",B=25,_e=["utm_source","utm_medium","utm_campaign","utm_term","utm_content"];function J(i){return i.slice(-B)}function Q(){const i=F(_,x);return Array.isArray(i)?i:[]}function Se(i){const e=J(i);for(let t=0;t<e.length;t++){const n=e.slice(t);if($(_,x,n))return n.length}return 0}function X(){q(_,x)}function Ie(i){const e=J(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 Ae(i){if(F(_,T)!==void 0)return;const e=new URLSearchParams(window.location.search),t={};for(const r of _e){const s=e.get(r);s&&(t[r]=s)}if(Object.keys(t).length===0)return;const n=Object.keys(t).join(", ");if(!$(_,T,t)){const r=K()?"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 ye(){const i=F(_,T);return m(i)?i:null}function Z(){q(_,T)}function ke(){const e=document.querySelector('link[rel="canonical"]')?.href;if(e)return M(e)}function Y(i,e){return{message:`Rokt Kit: ${i} called [attributeKeys=${e.join(",")}]`,code:"ATTRIBUTE_SETTER_CALLED"}}function Re(i){return{message:`Rokt Kit: selectPlacements dispatched [placementAttributeKeys=${i.join(",")}]`,code:"SELECT_PLACEMENTS_DISPATCHED"}}function ve(){return{context:null,lifecycle:"idle",recreateInFlight:null}}function we(i,e){i.context={accountId:e.accountId,launcherOptions:{...e.launcherOptions},legacyRoktExtensions:[...e.legacyRoktExtensions]}}function Te(i){i.lifecycle="attached"}function be(i){i.lifecycle!=="idle"&&(i.lifecycle="terminated")}function Le(i){i.lifecycle="terminated"}function Pe(i){i.context=null,i.lifecycle="idle",i.recreateInFlight=null}function Oe(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",b=181,Ne="selectPlacements",Ue="apps.roktecommerce.com",Ce=.1,Me="ThankYouPageJourney",Ke="rokt-launcher",De="rokt-thank-you-element",Fe="userIdentifiedInWorkspace",xe=3,Ye=2,je="page_events",We="page_view_attributes",Ge="mparticle_session_id",He="mparticle_device_id",ee=500,j={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",LOG_DELIVERY_FAILURE:"LOG_DELIVERY_FAILURE"},S={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},Ve="apps.rokt-api.com",ze="/v1/log",$e="/v1/errors",qe=10;function a(){return window.mParticle}function te(i,e){const n=[L(i),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?n:n+"?extensions="+e.join(",")}function ie(i){return[L(i),"/rokt-elements/rokt-element-thank-you.js"].join("")}function L(i){const e=typeof i<"u"?i:Ve;return e.includes("://")?e.replace(/\/+$/,""):["https://",e].join("")}function ne(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 L(r)+t}function re(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 P(i){if(!i)return[];try{return JSON.parse(i.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function se(i){const e=i?P(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(Me)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:n,loadThankYouElement:r}}async function Be(i,e){const t=[];if(e)for(const n of i)t.push(e.use(n));return Promise.all(t)}function oe(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 ae(i){const e={};if(!Array.isArray(i))return e;for(let t=0;t<i.length;t++){const n=i[t];if(!n||!E(n.value)||!E(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 ce(i,e,t){return a().generateHash([i,e,t].join(""))}function Je(i){let n="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"3.1.0";return i&&(n+="_"+i),n}function le(i){let e=5381;for(let t=0;t<i.length;t++)e=(e<<5)+e+i.charCodeAt(t),e=e&e;return e}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 ue(i,e){const t=le(window.location.origin);if(I._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Ce)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?L(i):"https://apps.rokt.com";W(c+"/v1/wsdk-init/index.html?"+o),W("https://"+Ue+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function Qe(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function Xe(){return typeof window<"u"?window.location?.href:void 0}function Ze(){return typeof window<"u"?window.navigator?.userAgent:void 0}class de{constructor(){this._logCount={}}incrementAndCheck(e){const n=(this._logCount[e]||0)+1;return this._logCount[e]=n,n>qe}}class k{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 de,this._isEnabled=Qe()||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||j.UNKNOWN_ERROR,url:Xe(),deviceInfo:Ze(),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 g=new Error("HTTP "+l.status+" from log endpoint");throw g.statusCode=l.status,g}}).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 he{constructor(e,t,n,r,s){this._transport=new k(e,t,n,r,s),this._errorUrl=ne(e?.errorUrl,e?.integrationDomain,$e)}report(e){if(!e)return;const t=e.severity||S.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class ge{constructor(e,t,n,r,s,o){this._transport=new k(e,n,r,s,o),this._diagnosticTransport=new k(e,n,r,s),this._placementDiagnosticTransport=new k(e,n,r,s),this._loggingUrl=ne(e?.loggingUrl,e?.integrationDomain,ze),this._errorReportingService=t}log(e){e&&this._send(this._transport,e)}logDiagnostic(e){e&&this._send(this._diagnosticTransport,e)}logPlacementDiagnostic(e){e&&this._send(this._placementDiagnosticTransport,e)}_send(e,t){e.send(this._loggingUrl,S.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:j.LOG_DELIVERY_FAILURE,severity:r?S.ERROR:S.WARNING})}})}}function et(i){const e=M(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 p=class p{constructor(){this.name=d,this.id=b,this.moduleId=b,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=ve()}getEventAttributeValue(e,t){const n=e&&e.EventAttributes;return!n||typeof n[t]>"u"?null:n[t]}doesEventAttributeConditionMatch(e,t){if(!e||!E(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||!E(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(C(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=M(window.location.href);const n=Q(),r=et(e);n.push(r);const s=Math.min(n.length,B),o=Se(n);if(o===0){const c=K()?"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=K()?"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"})}}isLauncherReadyToAttach(){return!!window.Rokt&&w(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[p.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(Ne,t,e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&w(t.setIntegrationAttribute)&&t.setIntegrationAttribute(b,{roktSessionId:e})}catch{}}readMpSessionId(){const e=a()?.sessionManager,t=e?.getSessionId??e?.getSession;if(w(t))return t.call(e)||void 0}readMpDeviceId(){return a()?.getDeviceId?.()||void 0}attachLauncher(e,t,n=[]){we(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 Be([...n],o),this.initRoktLauncher(o)}).catch(o=>{Le(this._launcherAttachState),console.error("Error creating Rokt launcher:",o)})}recreateLauncherIfTerminated(){return Oe(this._launcherAttachState,this.isLauncherReadyToAttach(),e=>this.attachLauncher(e.accountId,e.launcherOptions,e.legacyRoktExtensions))}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e,Te(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,ue(this.domain,this.integrationName),a().Rokt.attachKit(this)}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.userAttributes=v(s),this._onboardingExpProvider=o.onboardingExpProvider;const u=P(o.placementEventMapping);this.placementEventMappingLookup=oe(u);const l=P(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=ae(l),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=E(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const g=a().Rokt?.domain,{roktExtensionsQueryParams:G,legacyRoktExtensions:O,loadThankYouElement:N}=se(o.roktExtensions),f={...a().Rokt?.launcherOptions||{}};this.integrationName=Je(f.integrationName),f.integrationName=this.integrationName,this.domain=g;const R={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,integrationDomain:g,isLoggingEnabled:a().config?.isLoggingEnabled===!0},A=new he(R,this.integrationName,window.__rokt_li_guid__,o.accountId),y=new ge(R,A,this.integrationName,window.__rokt_li_guid__,o.accountId);if(this.errorReportingService=A,this.loggingService=y,this.isTargetingDisabled())try{X(),Z()}catch(h){this.errorReportingService?.report({message:"Rokt Kit: Failed to clear page views when targeting is disabled",code:"PAGE_VIEW_CAPTURE_FAILED",severity:S.INFO,stackTrace:h instanceof Error?h.stack:void 0})}return a()._registerErrorReportingService&&a()._registerErrorReportingService(A),a()._registerLoggingService&&a()._registerLoggingService(y),n?(this.testHelpers={generateLauncherScript:te,generateThankYouElementScript:ie,extractRoktExtensionConfig:se,hashEventMessage:ce,parseSettingsString:P,generateMappedEventLookup:oe,generateMappedEventAttributeLookup:ae,sendAdBlockMeasurementSignals:ue,createAutoRemovedIframe:W,djb2:le,setAllowedOriginHashes:h=>{p._allowedOriginHashes=h},ReportingTransport:k,ErrorReportingService:he,LoggingService:ge,RateLimiter:de,ErrorCodes:j,WSDKErrorSeverity:S,resetLauncherAttachState:()=>Pe(this._launcherAttachState)},this.attachLauncher(c,f),"Successfully initialized: "+d):(N&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),re(De,ie(g),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:h=>{console.error("Error loading Rokt Thank You Element script:",h)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,f,O):(re(Ke,te(g,G),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,f,O):console.error("Rokt object is not available after script load.")},onError:h=>{console.error("Error loading Rokt launcher script:",h)}}),this.captureTiming(p.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(this.isTargetingDisabled()||(e.EventDataType===xe&&(Ae(this.loggingService),this.capturePageView(e)),e.EventDataType===Ye&&(X(),Z())),!this.isKitReady())return"Kit not ready for forwarder: "+d;if(w(a().Rokt?.setLocalSessionAttribute)&&(C(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!C(this.placementEventMappingLookup))){const t=ce(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 this.loggingService?.logDiagnostic(Y("setUserAttribute",[e])),H(e)||(this.userAttributes[e]=t),"Successfully set user attribute for forwarder: "+d}removeUserAttribute(e){return this.loggingService?.logDiagnostic(Y("removeUserAttribute",[e])),delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+d}handleIdentityComplete(e,t){return this.userAttributes=v(e.getAllUserAttributes()),this.loggingService?.logDiagnostic(Y(t,Object.keys(this.userAttributes))),"Successfully called "+t+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,"onUserIdentified")}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];E(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.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,ee))]):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,ee))]).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 g=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},G=this.returnUserIdentities(c),O=this.returnLocalSessionAttributes(),N=Ie(Q()),f=ye(),R=this.readMpSessionId(),A=this.readMpDeviceId(),y={...G,...l,...g,...O,...N.length?{[je]:JSON.stringify(N)}:{},...f?{[We]:f}:{},...this.userIdentifiedInWorkspace?{[Fe]:!0}:{},...R?{[Ge]:R}:{},...A?{[He]:A}:{},mpid:u},h={...e,attributes:y};this.loggingService?.logPlacementDiagnostic(Re(Object.keys(y)));const pe=this.launcher.selectPlacements(h),nt=()=>this.logSelectPlacementsEvent(y);return Promise.resolve(pe).then(rt=>rt?.context?.sessionId?.then(st=>this.setRoktSessionId(st))).catch(()=>{}).finally(nt),pe}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!E(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()?(be(this._launcherAttachState),this.launcher.terminate()):(console.error("Rokt Kit: Not initialized"),Promise.resolve())}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};p._allowedOriginHashes=[-553112570,549508659],p.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},p.EMAIL_SHA256_KEY="emailsha256";let I=p;function tt(){return b}function it(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:I}:(i.kits={},i.kits[d]={constructor:I}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:I,getId:tt}),U.register=it,Object.defineProperty(U,Symbol.toStringTag,{value:"Module"}),U})({});
2
2
  //# sourceMappingURL=Rokt-Kit.iife.js.map
package/package.json CHANGED
@@ -1,63 +1,62 @@
1
1
  {
2
- "name": "@mparticle/web-rokt-kit",
3
- "version": "1.36.1",
4
- "description": "mParticle integration kit for Rokt",
5
- "main": "dist/Rokt-Kit.common.js",
6
- "module": "dist/Rokt-Kit.esm.js",
7
- "types": "dist/Rokt-Kit.d.ts",
8
- "exports": {
9
- ".": {
10
- "types": "./dist/Rokt-Kit.d.ts",
11
- "import": "./dist/Rokt-Kit.esm.js",
12
- "require": "./dist/Rokt-Kit.common.js"
13
- }
14
- },
15
- "files": [
16
- "dist/Rokt-Kit.common.js",
17
- "dist/Rokt-Kit.esm.js",
18
- "dist/Rokt-Kit.iife.js",
19
- "dist/Rokt-Kit.d.ts"
20
- ],
21
- "repository": "https://github.com/mparticle-integrations/mparticle-javascript-integration-rokt",
22
- "scripts": {
23
- "build": "vite build",
24
- "build:watch": "vite build --watch",
25
- "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
26
- "lint:fix": "eslint \"src/**/*.ts\" \"test/**/*.ts\" --fix",
27
- "test": "vitest run",
28
- "test:watch": "vitest",
29
- "test:coverage": "vitest run --coverage"
30
- },
31
- "publishConfig": {
32
- "access": "public",
33
- "provenance": true,
34
- "registry": "https://registry.npmjs.org"
35
- },
36
- "devDependencies": {
37
- "@eslint/js": "^9.23.0",
38
- "@eslint/eslintrc": "^3.3.1",
39
- "@mparticle/event-models": "^1.1.9",
40
- "@semantic-release/changelog": "^6.0.3",
41
- "@semantic-release/exec": "^6.0.3",
42
- "@semantic-release/git": "^10.0.1",
43
- "@semantic-release/npm": "^13.1.2",
44
- "@typescript-eslint/eslint-plugin": "^8.28.0",
45
- "@typescript-eslint/parser": "^8.28.0",
46
- "@types/node": "^20.11.5",
47
- "@vitest/coverage-v8": "^4.0.0",
48
- "eslint": "^9.23.0",
49
- "eslint-config-prettier": "^9.0.0",
50
- "eslint-plugin-prettier": "^5.0.0",
51
- "jsdom": "latest",
52
- "prettier": "^3.0.0",
53
- "semantic-release": "^24.2.0",
54
- "typescript": "^5.5.4",
55
- "vite": "^6.0.0",
56
- "vite-plugin-dts": "~3.8.1",
57
- "vitest": "^4.0.0"
58
- },
59
- "dependencies": {
60
- "@mparticle/web-sdk": "^2.62.0"
61
- },
62
- "license": "Apache-2.0"
2
+ "name": "@mparticle/web-rokt-kit",
3
+ "version": "3.1.0",
4
+ "description": "mParticle integration kit for Rokt",
5
+ "main": "dist/Rokt-Kit.common.js",
6
+ "module": "dist/Rokt-Kit.esm.js",
7
+ "types": "dist/Rokt-Kit.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/Rokt-Kit.d.ts",
11
+ "import": "./dist/Rokt-Kit.esm.js",
12
+ "require": "./dist/Rokt-Kit.common.js"
13
+ }
14
+ },
15
+ "files": [
16
+ "dist/Rokt-Kit.common.js",
17
+ "dist/Rokt-Kit.esm.js",
18
+ "dist/Rokt-Kit.iife.js",
19
+ "dist/Rokt-Kit.d.ts"
20
+ ],
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "https://github.com/mParticle/mparticle-web-sdk",
24
+ "directory": "kits/rokt"
25
+ },
26
+ "scripts": {
27
+ "build": "vite build",
28
+ "build:watch": "vite build --watch",
29
+ "lint": "eslint \"src/**/*.ts\" \"test/**/*.ts\"",
30
+ "lint:fix": "eslint \"src/**/*.ts\" \"test/**/*.ts\" --fix",
31
+ "test": "vitest run",
32
+ "test:watch": "vitest",
33
+ "test:coverage": "vitest run --coverage"
34
+ },
35
+ "publishConfig": {
36
+ "access": "public",
37
+ "registry": "https://registry.npmjs.org"
38
+ },
39
+ "peerDependencies": {
40
+ "@mparticle/web-sdk": "^3.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@eslint/js": "^9.23.0",
44
+ "@eslint/eslintrc": "^3.3.1",
45
+ "@mparticle/event-models": "^1.1.9",
46
+ "@mparticle/web-sdk": "^3.0.0",
47
+ "@typescript-eslint/eslint-plugin": "^8.28.0",
48
+ "@typescript-eslint/parser": "^8.28.0",
49
+ "@types/node": "^20.11.5",
50
+ "@vitest/coverage-v8": "^4.0.0",
51
+ "eslint": "^9.23.0",
52
+ "eslint-config-prettier": "^9.0.0",
53
+ "eslint-plugin-prettier": "^5.0.0",
54
+ "jsdom": "latest",
55
+ "prettier": "^3.0.0",
56
+ "typescript": "^5.5.4",
57
+ "vite": "^6.0.0",
58
+ "vite-plugin-dts": "~3.8.1",
59
+ "vitest": "^4.0.0"
60
+ },
61
+ "license": "Apache-2.0"
63
62
  }