@mparticle/web-rokt-kit 1.26.2 → 1.27.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 l="Rokt",S=181,Q="selectPlacements",B="apps.roktecommerce.com",V=.1,w={LOGIN:"login",LOGOUT:"logout",MODIFY_USER:"modify_user",IDENTIFY:"identify"},q="ThankYouPageJourney",J="rokt-launcher",X="rokt-thank-you-element",$="userIdentifiedInWorkspace",Z=500,N={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST"},v={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},ee="apps.rokt-api.com/v1/log",te="apps.rokt-api.com/v1/errors",ie=10;function o(){return window.mParticle}function U(n,e){const i=[G(n),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?i:i+"?extensions="+e.join(",")}function C(n){return[G(n),"/rokt-elements/rokt-element-thank-you.js"].join("")}function G(n){return["https://",typeof n<"u"?n:"apps.rokt-api.com"].join("")}function M(n,e,t){if(document.getElementById(n))return;const i=document.head||document.body,r=document.createElement("script");r.id=n,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),i.appendChild(r)}function O(n){return n!=null&&typeof n=="object"&&Array.isArray(n)===!1}function A(n){if(!n)return[];try{return JSON.parse(n.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function K(n){const e=n?A(n):[],t=[],i=[];let r=!1;for(let a=0;a<e.length;a++){const s=e[a].value;s==="thank-you-journey"?(r=!0,i.push(q)):t.push(s)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:i,loadThankYouElement:r}}async function ne(n,e){const t=[];if(e)for(const i of n)t.push(e.use(i));return Promise.all(t)}function D(n){if(!n)return{};const e={};for(let t=0;t<n.length;t++){const i=n[t];e[i.jsmap]=i.value}return e}function x(n){const e={};if(!Array.isArray(n))return e;for(let t=0;t<n.length;t++){const i=n[t];if(!i||!g(i.value)||!g(i.map))continue;const r=i.value,a=i.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:a,conditions:Array.isArray(i.conditions)?i.conditions:[]})}return e}function Y(n,e,t){return o().generateHash([n,e,t].join(""))}function k(n){return n==null?!0:typeof n=="object"?Object.keys(n).length===0:Array.isArray(n)?n.length===0:!1}function g(n){return typeof n=="string"}function re(n){let i="mParticle_wsdkv_"+o().getVersion()+"_kitv_"+"1.26.2";return n&&(i+="_"+n),i}function W(n){let e=5381;for(let t=0;t<n.length;t++)e=(e<<5)+e+n.charCodeAt(t),e=e&e;return e}function T(n){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=n,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function F(n,e){const t=W(window.location.origin);if(f._allowedOriginHashes.indexOf(t)===-1||Math.random()>=V)return;const r=window.__rokt_li_guid__;if(!r)return;const a=window.location.href.split("?")[0].split("#")[0],s="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(a);T("https://"+(n||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+s),T("https://"+B+"/v1/wsdk-init/index.html?"+s+"&isControl=true")}function se(){return typeof window<"u"&&!!window.ROKT_DOMAIN}function oe(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function ae(){return typeof window<"u"?window.location?.href:void 0}function ce(){return typeof window<"u"?window.navigator?.userAgent:void 0}class z{constructor(){this._logCount={}}incrementAndCheck(e){const i=(this._logCount[e]||0)+1;return this._logCount[e]=i,i>ie}}class P{constructor(e,t,i,r,a){this._reporter="mp-wsdk";const s=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=i,this._accountId=r||null,this._rateLimiter=a||new z,this._isEnabled=oe()||se()&&s}send(e,t,i,r,a,s){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:i,version:this._integrationName},severity:t,code:r||N.UNKNOWN_ERROR,url:ae(),deviceInfo:ce(),stackTrace:a,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)}).catch(d=>{console.error("ReportingTransport: Failed to send log",d),s&&s(d)})}catch(c){console.error("ReportingTransport: Failed to send log",c),s&&s(c)}}}class j{constructor(e,t,i,r,a){this._transport=new P(e,t,i,r,a),this._errorUrl="https://"+(e?.errorUrl||te)}report(e){if(!e)return;const t=e.severity||v.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class H{constructor(e,t,i,r,a,s){this._transport=new P(e,i,r,a,s),this._loggingUrl="https://"+(e?.loggingUrl||ee),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,v.INFO,e.message,e.code,void 0,t=>{this._errorReportingService&&this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:N.UNKNOWN_ERROR,severity:v.ERROR})})}}const p=class p{constructor(){this.name=l,this.id=S,this.moduleId=S,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.batchQueue=[],this.batchStreamQueue=[],this.pendingIdentityEvents=[],this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null}getEventAttributeValue(e,t){const i=e&&e.EventAttributes;return!i||typeof i[t]>"u"?null:i[t]}doesEventAttributeConditionMatch(e,t){if(!e||!g(e.operator))return!1;const i=e.operator.toLowerCase(),r=e.attributeValue;return i==="exists"?t!==null:t==null?!1:i==="equals"?String(t)===String(r):i==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!g(t.eventAttributeKey))return!1;const i=t.conditions;if(!Array.isArray(i))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(i.length===0)return r!==null;for(let a=0;a<i.length;a++)if(!this.doesEventAttributeConditionMatch(i[a],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let i=0;i<t.length;i++){const r=t[i],a=this.placementEventAttributeMappingLookup[r];if(k(a))continue;let s=!0;for(let c=0;c<a.length;c++)if(!this.doesEventMatchRule(e,a[c])){s=!1;break}s&&o().Rokt.setLocalSessionAttribute?.(r,!0)}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!o().Rokt||typeof o().Rokt.getLocalSessionAttributes!="function"?{}:k(this.placementEventMappingLookup)&&k(this.placementEventAttributeMappingLookup)?{}:o().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},i=this._mappedEmailSha256Key;return i&&e[i]&&(t[p.EMAIL_SHA256_KEY]=e[i]),i&&delete t[i],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof o().logEvent!="function"||!O(e))return;const t=o().EventType.Other;o().logEvent(Q,t,e)}buildIdentityEvent(e,t){const i=t.getMPID(),r=o()&&o().sessionManager&&typeof o().sessionManager.getSession=="function"?o().sessionManager.getSession():void 0;return{event_type:e,data:{timestamp_unixtime_ms:Date.now(),session_uuid:r??void 0,mpid:i}}}mergePendingIdentityEvents(e){if(this.pendingIdentityEvents.length===0)return e;const t={...e,events:[...e.events??[],...this.pendingIdentityEvents]};return this.pendingIdentityEvents=[],t}drainBatchQueue(){this.batchQueue.forEach(e=>{this.processBatch(e)}),this.batchQueue=[]}processBatch(e){return this.isKitReady()?(this.sendBatchStream(this.mergePendingIdentityEvents(e)),"Successfully sent batch to forwarder: "+l):(this.batchQueue.push(e),"Batch queued for forwarder: "+l)}sendBatchStream(e){if(window.Rokt&&typeof window.Rokt.__batch_stream__=="function"){if(this.batchStreamQueue.length){const t=this.batchStreamQueue;this.batchStreamQueue=[];for(let i=0;i<t.length;i++)window.Rokt.__batch_stream__(t[i])}window.Rokt.__batch_stream__(e)}else this.batchStreamQueue.push(e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=o().getInstance();t&&typeof t.setIntegrationAttribute=="function"&&t.setIntegrationAttribute(S,{roktSessionId:e})}catch{}}attachLauncher(e,t,i=[]){const r=o()&&o().sessionManager&&typeof o().sessionManager.getSession=="function"?o().sessionManager.getSession():void 0,a={accountId:e,...t||{},...r?{mpSessionId:r}:{}};let s;this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(a)):s=window.Rokt.createLauncher(a),s.then(async c=>{await ne(i,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e;const t=o().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,F(this.domain,this.integrationName),o().Rokt.attachKit(this),this.drainBatchQueue()}fetchOptimizely(){const e=o()._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((a,s)=>(a["rokt.custom.optimizely.experiment."+s+".variationId"]=t.getVariationMap()[s].id,a),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isPartnerInLocalLauncherTestGroup(){return!!(o().config&&o().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&o()&&o().captureTiming&&e&&o().captureTiming(e)}init(e,t,i,r,a){const s=e,c=s.accountId;this.userAttributes=a||{},this._onboardingExpProvider=s.onboardingExpProvider;const u=A(s.placementEventMapping);this.placementEventMappingLookup=D(u);const d=A(s.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=x(d),s.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=s.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(s.workspaceIdSyncApiKey)?s.workspaceIdSyncApiKey:void 0;const m=o().Rokt?.domain,{roktExtensionsQueryParams:b,legacyRoktExtensions:E,loadThankYouElement:L}=K(s.roktExtensions),h={...o().Rokt?.launcherOptions||{}};this.integrationName=re(h.integrationName),h.integrationName=this.integrationName,this.domain=m;const I={loggingUrl:s.loggingUrl,errorUrl:s.errorUrl,isLoggingEnabled:o().config?.isLoggingEnabled===!0},_=new j(I,this.integrationName,window.__rokt_li_guid__,s.accountId),R=new H(I,_,this.integrationName,window.__rokt_li_guid__,s.accountId);return this.errorReportingService=_,this.loggingService=R,o()._registerErrorReportingService&&o()._registerErrorReportingService(_),o()._registerLoggingService&&o()._registerLoggingService(R),i?(this.testHelpers={generateLauncherScript:U,generateThankYouElementScript:C,extractRoktExtensionConfig:K,hashEventMessage:Y,parseSettingsString:A,generateMappedEventLookup:D,generateMappedEventAttributeLookup:x,sendAdBlockMeasurementSignals:F,createAutoRemovedIframe:T,djb2:W,setAllowedOriginHashes:y=>{p._allowedOriginHashes=y},ReportingTransport:P,ErrorReportingService:j,LoggingService:H,RateLimiter:z,ErrorCodes:N,WSDKErrorSeverity:v},this.attachLauncher(c,h),"Successfully initialized: "+l):(L&&(o().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),M(X,C(m),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:y=>{console.error("Error loading Rokt Thank You Element script:",y)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,h,E):(M(J,U(m,b),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,h,E):console.error("Rokt object is not available after script load.")},onError:y=>{console.error("Error loading Rokt launcher script:",y)}}),this.captureTiming(p.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+l)}process(e){if(!this.isKitReady())return"Kit not ready for forwarder: "+l;if(typeof o().Rokt?.setLocalSessionAttribute=="function"&&(k(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!k(this.placementEventMappingLookup))){const t=Y(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&o().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+l}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return this.userAttributes[e]=t,"Successfully set user attribute for forwarder: "+l}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+l}handleIdentityComplete(e,t,i){const r=e;return this.userAttributes=e.getAllUserAttributes(),this.pendingIdentityEvents.push(this.buildIdentityEvent(t,r)),"Successfully called "+i+" for forwarder: "+l}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,w.IDENTIFY,"onUserIdentified")}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const i=o().Identity?.search;if(typeof i!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,a={};if(r)for(const u of Object.keys(r)){const d=r[u];g(d)&&d.length>0&&(a[u]=d)}const s=Object.keys(a);if(s.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=s.sort().map(u=>`${u}=${a[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{i(t,a,d=>{d?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(d){console.error("Rokt Kit: Workspace IDSync search failed",d),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,w.LOGIN,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(e,w.LOGOUT,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,w.MODIFY_USER,"onModifyComplete")}selectPlacements(e){if(this._workspaceSearchInFlightPromise){const t=this._workspaceSearchInFlightPromise;return Promise.race([t,new Promise(i=>setTimeout(i,Z))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},i={...this.userAttributes,...t},r=this.filters||{},a=r.userAttributeFilters||[],s=r.filteredUser||null,c=s?s.getMPID():null;let u;r?r.filterUserAttributes?u=r.filterUserAttributes(i,a):u=i:(console.warn("Rokt Kit: No filters available, using user attributes"),u=i),this.userAttributes=u;const d=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},m=this.returnUserIdentities(s),b=this.returnLocalSessionAttributes(),E={...m,...u,...d,...b,...this.userIdentifiedInWorkspace?{[$]:!0}:{},mpid:c},L={...e,attributes:E},h=this.launcher.selectPlacements(L),I=()=>this.logSelectPlacementsEvent(E);return Promise.resolve(h).then(_=>_?.context?.sessionId?.then(R=>this.setRoktSessionId(R))).catch(()=>{}).finally(I),h}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!g(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};p._allowedOriginHashes=[-553112570,549508659],p.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},p.EMAIL_SHA256_KEY="emailsha256";let f=p;function ue(){return S}function le(n){if(!n){window.console.log("You must pass a config object to register the kit "+l);return}if(!O(n)){window.console.log("'config' must be an object. You passed in a "+typeof n);return}O(n.kits)?n.kits[l]={constructor:f}:(n.kits={},n.kits[l]={constructor:f}),window.console.log("Successfully registered "+l+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&o().addForwarder&&o().addForwarder({name:l,constructor:f,getId:ue});exports.register=le;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const V=["billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],q=new Set(V);function z(n){return q.has(n.toLowerCase())}function v(n){const e={},t=n||{},i=Object.keys(t);for(let r=0;r<i.length;r++){const s=i[r];z(s)||(e[s]=t[s])}return e}const d="Rokt",w=181,J="selectPlacements",X="apps.roktecommerce.com",$=.1,A={LOGIN:"login",LOGOUT:"logout",MODIFY_USER:"modify_user",IDENTIFY:"identify"},Z="ThankYouPageJourney",ee="rokt-launcher",te="rokt-thank-you-element",ie="userIdentifiedInWorkspace",ne=500,P={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST"},L={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},re="apps.rokt-api.com/v1/log",se="apps.rokt-api.com/v1/errors",oe=10;function a(){return window.mParticle}function C(n,e){const i=[W(n),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?i:i+"?extensions="+e.join(",")}function M(n){return[W(n),"/rokt-elements/rokt-element-thank-you.js"].join("")}function W(n){return["https://",typeof n<"u"?n:"apps.rokt-api.com"].join("")}function K(n,e,t){if(document.getElementById(n))return;const i=document.head||document.body,r=document.createElement("script");r.id=n,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),i.appendChild(r)}function T(n){return n!=null&&typeof n=="object"&&Array.isArray(n)===!1}function b(n){if(!n)return[];try{return JSON.parse(n.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function D(n){const e=n?b(n):[],t=[],i=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,i.push(Z)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:i,loadThankYouElement:r}}async function ae(n,e){const t=[];if(e)for(const i of n)t.push(e.use(i));return Promise.all(t)}function Y(n){if(!n)return{};const e={};for(let t=0;t<n.length;t++){const i=n[t];e[i.jsmap]=i.value}return e}function x(n){const e={};if(!Array.isArray(n))return e;for(let t=0;t<n.length;t++){const i=n[t];if(!i||!f(i.value)||!f(i.map))continue;const r=i.value,s=i.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(i.conditions)?i.conditions:[]})}return e}function F(n,e,t){return a().generateHash([n,e,t].join(""))}function I(n){return n==null?!0:typeof n=="object"?Object.keys(n).length===0:Array.isArray(n)?n.length===0:!1}function f(n){return typeof n=="string"}function ce(n){let i="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.27.0";return n&&(i+="_"+n),i}function Q(n){let e=5381;for(let t=0;t<n.length;t++)e=(e<<5)+e+n.charCodeAt(t),e=e&e;return e}function N(n){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=n,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function j(n,e){const t=Q(window.location.origin);if(m._allowedOriginHashes.indexOf(t)===-1||Math.random()>=$)return;const r=window.__rokt_li_guid__;if(!r)return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s);N("https://"+(n||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+o),N("https://"+X+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function ue(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function le(){return typeof window<"u"?window.location?.href:void 0}function de(){return typeof window<"u"?window.navigator?.userAgent:void 0}class B{constructor(){this._logCount={}}incrementAndCheck(e){const i=(this._logCount[e]||0)+1;return this._logCount[e]=i,i>oe}}class U{constructor(e,t,i,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=i,this._accountId=r||null,this._rateLimiter=s||new B,this._isEnabled=ue()||o}send(e,t,i,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:i,version:this._integrationName},severity:t,code:r||P.UNKNOWN_ERROR,url:le(),deviceInfo:de(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},l={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(l["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(l["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:l,body:JSON.stringify(c)}).catch(u=>{console.error("ReportingTransport: Failed to send log",u),o&&o(u)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class H{constructor(e,t,i,r,s){this._transport=new U(e,t,i,r,s),this._errorUrl="https://"+(e?.errorUrl||se)}report(e){if(!e)return;const t=e.severity||L.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class G{constructor(e,t,i,r,s,o){this._transport=new U(e,i,r,s,o),this._loggingUrl="https://"+(e?.loggingUrl||re),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,L.INFO,e.message,e.code,void 0,t=>{this._errorReportingService&&this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:P.UNKNOWN_ERROR,severity:L.ERROR})})}}const h=class h{constructor(){this.name=d,this.id=w,this.moduleId=w,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.batchQueue=[],this.batchStreamQueue=[],this.pendingIdentityEvents=[],this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null}getEventAttributeValue(e,t){const i=e&&e.EventAttributes;return!i||typeof i[t]>"u"?null:i[t]}doesEventAttributeConditionMatch(e,t){if(!e||!f(e.operator))return!1;const i=e.operator.toLowerCase(),r=e.attributeValue;return i==="exists"?t!==null:t==null?!1:i==="equals"?String(t)===String(r):i==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!f(t.eventAttributeKey))return!1;const i=t.conditions;if(!Array.isArray(i))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(i.length===0)return r!==null;for(let s=0;s<i.length;s++)if(!this.doesEventAttributeConditionMatch(i[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let i=0;i<t.length;i++){const r=t[i],s=this.placementEventAttributeMappingLookup[r];if(I(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)}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}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"?{}:I(this.placementEventMappingLookup)&&I(this.placementEventAttributeMappingLookup)?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},i=this._mappedEmailSha256Key;return i&&e[i]&&(t[h.EMAIL_SHA256_KEY]=e[i]),i&&delete t[i],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!T(e))return;const t=a().EventType.Other;a().logEvent(J,t,e)}buildIdentityEvent(e,t){const i=t.getMPID(),r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0;return{event_type:e,data:{timestamp_unixtime_ms:Date.now(),session_uuid:r??void 0,mpid:i}}}mergePendingIdentityEvents(e){if(this.pendingIdentityEvents.length===0)return e;const t={...e,events:[...e.events??[],...this.pendingIdentityEvents]};return this.pendingIdentityEvents=[],t}drainBatchQueue(){this.batchQueue.forEach(e=>{this.processBatch(e)}),this.batchQueue=[]}processBatch(e){if(!this.isKitReady())return this.batchQueue.push(e),"Batch queued for forwarder: "+d;const t=this.enrichCommerceEventTypes(this.mergePendingIdentityEvents(e));return this.sendBatchStream(t),"Successfully sent batch to forwarder: "+d}enrichCommerceEventTypes(e){if(!e.events)return e;for(const t of e.events){if(t.event_type!=="commerce_event")continue;const{data:i}=t;if(!i)continue;const r=i.custom_flags?.["Rokt.CommerceEventType"];r&&T(i.product_action)&&(i.product_action.action=r)}return e}sendBatchStream(e){if(window.Rokt&&typeof window.Rokt.__batch_stream__=="function"){if(this.batchStreamQueue.length){const t=this.batchStreamQueue;this.batchStreamQueue=[];for(let i=0;i<t.length;i++)window.Rokt.__batch_stream__(t[i])}window.Rokt.__batch_stream__(e)}else this.batchStreamQueue.push(e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&typeof t.setIntegrationAttribute=="function"&&t.setIntegrationAttribute(w,{roktSessionId:e})}catch{}}attachLauncher(e,t,i=[]){const r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0,s={accountId:e,...t||{},...r?{mpSessionId:r}:{}};let o;this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(s)):o=window.Rokt.createLauncher(s),o.then(async c=>{await ae(i,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e;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,j(this.domain,this.integrationName),a().Rokt.attachKit(this),this.drainBatchQueue()}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)}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,i,r,s){const o=e,c=o.accountId;this.userAttributes=v(s),this._onboardingExpProvider=o.onboardingExpProvider;const l=b(o.placementEventMapping);this.placementEventMappingLookup=Y(l);const u=b(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=x(u),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=f(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const E=a().Rokt?.domain,{roktExtensionsQueryParams:O,legacyRoktExtensions:k,loadThankYouElement:R}=D(o.roktExtensions),p={...a().Rokt?.launcherOptions||{}};this.integrationName=ce(p.integrationName),p.integrationName=this.integrationName,this.domain=E;const _={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,isLoggingEnabled:a().config?.isLoggingEnabled===!0},y=new H(_,this.integrationName,window.__rokt_li_guid__,o.accountId),S=new G(_,y,this.integrationName,window.__rokt_li_guid__,o.accountId);return this.errorReportingService=y,this.loggingService=S,a()._registerErrorReportingService&&a()._registerErrorReportingService(y),a()._registerLoggingService&&a()._registerLoggingService(S),i?(this.testHelpers={generateLauncherScript:C,generateThankYouElementScript:M,extractRoktExtensionConfig:D,hashEventMessage:F,parseSettingsString:b,generateMappedEventLookup:Y,generateMappedEventAttributeLookup:x,sendAdBlockMeasurementSignals:j,createAutoRemovedIframe:N,djb2:Q,setAllowedOriginHashes:g=>{h._allowedOriginHashes=g},ReportingTransport:U,ErrorReportingService:H,LoggingService:G,RateLimiter:B,ErrorCodes:P,WSDKErrorSeverity:L},this.attachLauncher(c,p),"Successfully initialized: "+d):(R&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),K(te,M(E),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:g=>{console.error("Error loading Rokt Thank You Element script:",g)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,p,k):(K(ee,C(E,O),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,p,k):console.error("Rokt object is not available after script load.")},onError:g=>{console.error("Error loading Rokt launcher script:",g)}}),this.captureTiming(h.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(!this.isKitReady())return"Kit not ready for forwarder: "+d;if(typeof a().Rokt?.setLocalSessionAttribute=="function"&&(I(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!I(this.placementEventMappingLookup))){const t=F(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 z(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,i){const r=e;return this.userAttributes=v(e.getAllUserAttributes()),this.pendingIdentityEvents.push(this.buildIdentityEvent(t,r)),"Successfully called "+i+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,A.IDENTIFY,"onUserIdentified")}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const i=a().Identity?.search;if(typeof i!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const l of Object.keys(r)){const u=r[l];f(u)&&u.length>0&&(s[l]=u)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(l=>`${l}=${s[l]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(l=>{try{i(t,s,u=>{u?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),l()})}catch(u){console.error("Rokt Kit: Workspace IDSync search failed",u),this._workspaceLastSearchedIdentitiesKey=void 0,l()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,A.LOGIN,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(e,A.LOGOUT,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,A.MODIFY_USER,"onModifyComplete")}selectPlacements(e){if(this._workspaceSearchInFlightPromise){const t=this._workspaceSearchInFlightPromise;return Promise.race([t,new Promise(i=>setTimeout(i,ne))]).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,l=c?c.getMPID():null;let u;s?s.filterUserAttributes?u=s.filterUserAttributes(r,o):u=r:(console.warn("Rokt Kit: No filters available, using user attributes"),u=r),this.userAttributes=v(u);const E=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},O=this.returnUserIdentities(c),k=this.returnLocalSessionAttributes(),R={...O,...u,...E,...k,...this.userIdentifiedInWorkspace?{[ie]:!0}:{},mpid:l},p={...e,attributes:R},_=this.launcher.selectPlacements(p),y=()=>this.logSelectPlacementsEvent(R);return Promise.resolve(_).then(S=>S?.context?.sessionId?.then(g=>this.setRoktSessionId(g))).catch(()=>{}).finally(y),_}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!f(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")))}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};h._allowedOriginHashes=[-553112570,549508659],h.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},h.EMAIL_SHA256_KEY="emailsha256";let m=h;function he(){return w}function pe(n){if(!n){window.console.log("You must pass a config object to register the kit "+d);return}if(!T(n)){window.console.log("'config' must be an object. You passed in a "+typeof n);return}T(n.kits)?n.kits[d]={constructor:m}:(n.kits={},n.kits[d]={constructor:m}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:m,getId:he});exports.register=pe;
2
2
  //# sourceMappingURL=Rokt-Kit.common.js.map
@@ -10,7 +10,6 @@ declare global {
10
10
  Rokt?: RoktGlobal;
11
11
  __rokt_li_guid__?: string;
12
12
  optimizely?: OptimizelyGlobal;
13
- ROKT_DOMAIN?: string;
14
13
  mParticle: any;
15
14
  }
16
15
  }
@@ -1,41 +1,75 @@
1
- const l = "Rokt";
2
- const z = "selectPlacements", Q = "apps.roktecommerce.com";
3
- const w = {
1
+ const V = [
2
+ "billingaddress1",
3
+ "billingaddress2",
4
+ "billingcity",
5
+ "billingstate",
6
+ "billingzipcode",
7
+ "cartitems",
8
+ "ccbin",
9
+ "confirmationref",
10
+ "conversiontype",
11
+ "country",
12
+ "couponcode",
13
+ "currency",
14
+ "language",
15
+ "paymentserviceprovider",
16
+ "paymentserviceproviderattribute",
17
+ "paymenttype",
18
+ "shippingaddress1",
19
+ "shippingcity",
20
+ "shippingcountry",
21
+ "shippingmethod",
22
+ "shippingstate",
23
+ "shippingzipcode",
24
+ "totalprice"
25
+ ], q = new Set(V);
26
+ function z(n) {
27
+ return q.has(n.toLowerCase());
28
+ }
29
+ function A(n) {
30
+ const e = {}, t = n || {}, i = Object.keys(t);
31
+ for (let r = 0; r < i.length; r++) {
32
+ const s = i[r];
33
+ z(s) || (e[s] = t[s]);
34
+ }
35
+ return e;
36
+ }
37
+ const d = "Rokt", w = 181, J = "selectPlacements", X = "apps.roktecommerce.com", $ = 0.1, v = {
4
38
  LOGIN: "login",
5
39
  LOGOUT: "logout",
6
40
  MODIFY_USER: "modify_user",
7
41
  IDENTIFY: "identify"
8
- }, B = "ThankYouPageJourney", V = "rokt-launcher", q = "rokt-thank-you-element", J = "userIdentifiedInWorkspace", X = 500, T = {
42
+ }, Z = "ThankYouPageJourney", ee = "rokt-launcher", te = "rokt-thank-you-element", ie = "userIdentifiedInWorkspace", ne = 500, P = {
9
43
  UNKNOWN_ERROR: "UNKNOWN_ERROR",
10
44
  UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
11
45
  IDENTITY_REQUEST: "IDENTITY_REQUEST"
12
- }, A = {
46
+ }, L = {
13
47
  ERROR: "ERROR",
14
48
  INFO: "INFO",
15
49
  WARNING: "WARNING"
16
- }, $ = "apps.rokt-api.com/v1/log", Z = "apps.rokt-api.com/v1/errors", ee = 10;
17
- function o() {
50
+ }, re = "apps.rokt-api.com/v1/log", se = "apps.rokt-api.com/v1/errors", oe = 10;
51
+ function a() {
18
52
  return window.mParticle;
19
53
  }
20
- function P(n, e) {
21
- const i = [G(n), "/wsdk/integrations/launcher.js"].join("");
54
+ function C(n, e) {
55
+ const i = [W(n), "/wsdk/integrations/launcher.js"].join("");
22
56
  return !e || e.length === 0 ? i : i + "?extensions=" + e.join(",");
23
57
  }
24
- function U(n) {
25
- return [G(n), "/rokt-elements/rokt-element-thank-you.js"].join("");
58
+ function M(n) {
59
+ return [W(n), "/rokt-elements/rokt-element-thank-you.js"].join("");
26
60
  }
27
- function G(n) {
61
+ function W(n) {
28
62
  return ["https://", typeof n < "u" ? n : "apps.rokt-api.com"].join("");
29
63
  }
30
- function C(n, e, t) {
64
+ function K(n, e, t) {
31
65
  if (document.getElementById(n)) return;
32
66
  const i = document.head || document.body, r = document.createElement("script");
33
67
  r.id = n, 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), i.appendChild(r);
34
68
  }
35
- function L(n) {
69
+ function T(n) {
36
70
  return n != null && typeof n == "object" && Array.isArray(n) === !1;
37
71
  }
38
- function S(n) {
72
+ function b(n) {
39
73
  if (!n)
40
74
  return [];
41
75
  try {
@@ -45,12 +79,12 @@ function S(n) {
45
79
  }
46
80
  return [];
47
81
  }
48
- function M(n) {
49
- const e = n ? S(n) : [], t = [], i = [];
82
+ function D(n) {
83
+ const e = n ? b(n) : [], t = [], i = [];
50
84
  let r = !1;
51
- for (let a = 0; a < e.length; a++) {
52
- const s = e[a].value;
53
- s === "thank-you-journey" ? (r = !0, i.push(B)) : t.push(s);
85
+ for (let s = 0; s < e.length; s++) {
86
+ const o = e[s].value;
87
+ o === "thank-you-journey" ? (r = !0, i.push(Z)) : t.push(o);
54
88
  }
55
89
  return {
56
90
  roktExtensionsQueryParams: t,
@@ -58,14 +92,14 @@ function M(n) {
58
92
  loadThankYouElement: r
59
93
  };
60
94
  }
61
- async function te(n, e) {
95
+ async function ae(n, e) {
62
96
  const t = [];
63
97
  if (e)
64
98
  for (const i of n)
65
99
  t.push(e.use(i));
66
100
  return Promise.all(t);
67
101
  }
68
- function K(n) {
102
+ function x(n) {
69
103
  if (!n)
70
104
  return {};
71
105
  const e = {};
@@ -75,42 +109,42 @@ function K(n) {
75
109
  }
76
110
  return e;
77
111
  }
78
- function D(n) {
112
+ function Y(n) {
79
113
  const e = {};
80
114
  if (!Array.isArray(n))
81
115
  return e;
82
116
  for (let t = 0; t < n.length; t++) {
83
117
  const i = n[t];
84
- if (!i || !g(i.value) || !g(i.map))
118
+ if (!i || !f(i.value) || !f(i.map))
85
119
  continue;
86
- const r = i.value, a = i.map;
120
+ const r = i.value, s = i.map;
87
121
  e[r] || (e[r] = []), e[r].push({
88
- eventAttributeKey: a,
122
+ eventAttributeKey: s,
89
123
  conditions: Array.isArray(i.conditions) ? i.conditions : []
90
124
  });
91
125
  }
92
126
  return e;
93
127
  }
94
- function x(n, e, t) {
95
- return o().generateHash([n, e, t].join(""));
128
+ function F(n, e, t) {
129
+ return a().generateHash([n, e, t].join(""));
96
130
  }
97
- function y(n) {
131
+ function I(n) {
98
132
  return n == null ? !0 : typeof n == "object" ? Object.keys(n).length === 0 : Array.isArray(n) ? n.length === 0 : !1;
99
133
  }
100
- function g(n) {
134
+ function f(n) {
101
135
  return typeof n == "string";
102
136
  }
103
- function ie(n) {
104
- let i = "mParticle_wsdkv_" + o().getVersion() + "_kitv_" + "1.26.2";
137
+ function ce(n) {
138
+ let i = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "1.27.0";
105
139
  return n && (i += "_" + n), i;
106
140
  }
107
- function H(n) {
141
+ function Q(n) {
108
142
  let e = 5381;
109
143
  for (let t = 0; t < n.length; t++)
110
144
  e = (e << 5) + e + n.charCodeAt(t), e = e & e;
111
145
  return e;
112
146
  }
113
- function O(n) {
147
+ function N(n) {
114
148
  const e = document.createElement("iframe");
115
149
  e.style.display = "none", e.setAttribute("sandbox", "allow-scripts allow-same-origin"), e.src = n, e.onload = function() {
116
150
  e.onload = null, e.parentNode && e.parentNode.removeChild(e);
@@ -118,46 +152,43 @@ function O(n) {
118
152
  const t = document.body || document.head;
119
153
  t && t.appendChild(e);
120
154
  }
121
- function Y(n, e) {
122
- const t = H(window.location.origin);
123
- if (f._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= 0.1)
155
+ function j(n, e) {
156
+ const t = Q(window.location.origin);
157
+ if (m._allowedOriginHashes.indexOf(t) === -1 || Math.random() >= $)
124
158
  return;
125
159
  const r = window.__rokt_li_guid__;
126
160
  if (!r)
127
161
  return;
128
- const a = window.location.href.split("?")[0].split("#")[0], s = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(a);
129
- O("https://" + (n || "apps.rokt.com") + "/v1/wsdk-init/index.html?" + s), O(
130
- "https://" + Q + "/v1/wsdk-init/index.html?" + s + "&isControl=true"
162
+ const s = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(e ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(s);
163
+ N("https://" + (n || "apps.rokt.com") + "/v1/wsdk-init/index.html?" + o), N(
164
+ "https://" + X + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
131
165
  );
132
166
  }
133
- function ne() {
134
- return typeof window < "u" && !!window.ROKT_DOMAIN;
135
- }
136
- function re() {
167
+ function ue() {
137
168
  return typeof window < "u" && !!window.location?.search?.toLowerCase().includes("mp_enable_logging=true");
138
169
  }
139
- function se() {
170
+ function le() {
140
171
  return typeof window < "u" ? window.location?.href : void 0;
141
172
  }
142
- function oe() {
173
+ function de() {
143
174
  return typeof window < "u" ? window.navigator?.userAgent : void 0;
144
175
  }
145
- class W {
176
+ class B {
146
177
  constructor() {
147
178
  this._logCount = {};
148
179
  }
149
180
  incrementAndCheck(e) {
150
181
  const i = (this._logCount[e] || 0) + 1;
151
- return this._logCount[e] = i, i > ee;
182
+ return this._logCount[e] = i, i > oe;
152
183
  }
153
184
  }
154
- class N {
155
- constructor(e, t, i, r, a) {
185
+ class U {
186
+ constructor(e, t, i, r, s) {
156
187
  this._reporter = "mp-wsdk";
157
- const s = e.isLoggingEnabled;
158
- this._integrationName = t || "", this._launcherInstanceGuid = i, this._accountId = r || null, this._rateLimiter = a || new W(), this._isEnabled = re() || ne() && s;
188
+ const o = e.isLoggingEnabled;
189
+ this._integrationName = t || "", this._launcherInstanceGuid = i, this._accountId = r || null, this._rateLimiter = s || new B(), this._isEnabled = ue() || o;
159
190
  }
160
- send(e, t, i, r, a, s) {
191
+ send(e, t, i, r, s, o) {
161
192
  if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(t)))
162
193
  try {
163
194
  const c = {
@@ -166,64 +197,64 @@ class N {
166
197
  version: this._integrationName
167
198
  },
168
199
  severity: t,
169
- code: r || T.UNKNOWN_ERROR,
170
- url: se(),
171
- deviceInfo: oe(),
172
- stackTrace: a,
200
+ code: r || P.UNKNOWN_ERROR,
201
+ url: le(),
202
+ deviceInfo: de(),
203
+ stackTrace: s,
173
204
  reporter: this._reporter,
174
205
  integration: this._integrationName
175
- }, u = {
206
+ }, l = {
176
207
  Accept: "text/plain;charset=UTF-8",
177
208
  "Content-Type": "application/json",
178
209
  "rokt-launcher-version": this._integrationName,
179
210
  "rokt-wsdk-version": "joint"
180
211
  };
181
- this._launcherInstanceGuid && (u["rokt-launcher-instance-guid"] = this._launcherInstanceGuid), this._accountId && (u["rokt-account-id"] = this._accountId), fetch(e, {
212
+ this._launcherInstanceGuid && (l["rokt-launcher-instance-guid"] = this._launcherInstanceGuid), this._accountId && (l["rokt-account-id"] = this._accountId), fetch(e, {
182
213
  method: "POST",
183
- headers: u,
214
+ headers: l,
184
215
  body: JSON.stringify(c)
185
- }).catch((d) => {
186
- console.error("ReportingTransport: Failed to send log", d), s && s(d);
216
+ }).catch((u) => {
217
+ console.error("ReportingTransport: Failed to send log", u), o && o(u);
187
218
  });
188
219
  } catch (c) {
189
- console.error("ReportingTransport: Failed to send log", c), s && s(c);
220
+ console.error("ReportingTransport: Failed to send log", c), o && o(c);
190
221
  }
191
222
  }
192
223
  }
193
- class F {
194
- constructor(e, t, i, r, a) {
195
- this._transport = new N(e, t, i, r, a), this._errorUrl = "https://" + (e?.errorUrl || Z);
224
+ class H {
225
+ constructor(e, t, i, r, s) {
226
+ this._transport = new U(e, t, i, r, s), this._errorUrl = "https://" + (e?.errorUrl || se);
196
227
  }
197
228
  report(e) {
198
229
  if (!e) return;
199
- const t = e.severity || A.ERROR;
230
+ const t = e.severity || L.ERROR;
200
231
  this._transport.send(this._errorUrl, t, e.message, e.code, e.stackTrace);
201
232
  }
202
233
  }
203
- class j {
204
- constructor(e, t, i, r, a, s) {
205
- this._transport = new N(e, i, r, a, s), this._loggingUrl = "https://" + (e?.loggingUrl || $), this._errorReportingService = t;
234
+ class G {
235
+ constructor(e, t, i, r, s, o) {
236
+ this._transport = new U(e, i, r, s, o), this._loggingUrl = "https://" + (e?.loggingUrl || re), this._errorReportingService = t;
206
237
  }
207
238
  log(e) {
208
239
  e && this._transport.send(
209
240
  this._loggingUrl,
210
- A.INFO,
241
+ L.INFO,
211
242
  e.message,
212
243
  e.code,
213
244
  void 0,
214
245
  (t) => {
215
246
  this._errorReportingService && this._errorReportingService.report({
216
247
  message: "LoggingService: Failed to send log: " + t.message,
217
- code: T.UNKNOWN_ERROR,
218
- severity: A.ERROR
248
+ code: P.UNKNOWN_ERROR,
249
+ severity: L.ERROR
219
250
  });
220
251
  }
221
252
  );
222
253
  }
223
254
  }
224
- const p = class p {
255
+ const h = class h {
225
256
  constructor() {
226
- this.name = l, this.id = 181, this.moduleId = 181, this.isInitialized = !1, this.launcher = null, this.filters = {}, this.userAttributes = {}, this.userIdentifiedInWorkspace = !1, this.testHelpers = null, this.placementEventMappingLookup = {}, this.placementEventAttributeMappingLookup = {}, this.batchQueue = [], this.batchStreamQueue = [], this.pendingIdentityEvents = [], this.integrationName = null, this.errorReportingService = null, this.loggingService = null, this._thankYouElementOnLoadCallback = null, this._isThankYouElementLoaded = !1, this._workspaceSearchInFlightPromise = null;
257
+ this.name = d, this.id = w, this.moduleId = w, this.isInitialized = !1, this.launcher = null, this.filters = {}, this.userAttributes = {}, this.userIdentifiedInWorkspace = !1, this.testHelpers = null, this.placementEventMappingLookup = {}, this.placementEventAttributeMappingLookup = {}, this.batchQueue = [], this.batchStreamQueue = [], this.pendingIdentityEvents = [], this.integrationName = null, this.errorReportingService = null, this.loggingService = null, this._thankYouElementOnLoadCallback = null, this._isThankYouElementLoaded = !1, this._workspaceSearchInFlightPromise = null;
227
258
  }
228
259
  // ---- Private helpers ----
229
260
  getEventAttributeValue(e, t) {
@@ -231,13 +262,13 @@ const p = class p {
231
262
  return !i || typeof i[t] > "u" ? null : i[t];
232
263
  }
233
264
  doesEventAttributeConditionMatch(e, t) {
234
- if (!e || !g(e.operator))
265
+ if (!e || !f(e.operator))
235
266
  return !1;
236
267
  const i = e.operator.toLowerCase(), r = e.attributeValue;
237
268
  return i === "exists" ? t !== null : t == null ? !1 : i === "equals" ? String(t) === String(r) : i === "contains" ? String(t).indexOf(String(r)) !== -1 : !1;
238
269
  }
239
270
  doesEventMatchRule(e, t) {
240
- if (!t || !g(t.eventAttributeKey))
271
+ if (!t || !f(t.eventAttributeKey))
241
272
  return !1;
242
273
  const i = t.conditions;
243
274
  if (!Array.isArray(i))
@@ -245,24 +276,24 @@ const p = class p {
245
276
  const r = this.getEventAttributeValue(e, t.eventAttributeKey);
246
277
  if (i.length === 0)
247
278
  return r !== null;
248
- for (let a = 0; a < i.length; a++)
249
- if (!this.doesEventAttributeConditionMatch(i[a], r))
279
+ for (let s = 0; s < i.length; s++)
280
+ if (!this.doesEventAttributeConditionMatch(i[s], r))
250
281
  return !1;
251
282
  return !0;
252
283
  }
253
284
  applyPlacementEventAttributeMapping(e) {
254
285
  const t = Object.keys(this.placementEventAttributeMappingLookup);
255
286
  for (let i = 0; i < t.length; i++) {
256
- const r = t[i], a = this.placementEventAttributeMappingLookup[r];
257
- if (y(a))
287
+ const r = t[i], s = this.placementEventAttributeMappingLookup[r];
288
+ if (I(s))
258
289
  continue;
259
- let s = !0;
260
- for (let c = 0; c < a.length; c++)
261
- if (!this.doesEventMatchRule(e, a[c])) {
262
- s = !1;
290
+ let o = !0;
291
+ for (let c = 0; c < s.length; c++)
292
+ if (!this.doesEventMatchRule(e, s[c])) {
293
+ o = !1;
263
294
  break;
264
295
  }
265
- s && o().Rokt.setLocalSessionAttribute?.(r, !0);
296
+ o && a().Rokt.setLocalSessionAttribute?.(r, !0);
266
297
  }
267
298
  }
268
299
  isLauncherReadyToAttach() {
@@ -278,20 +309,20 @@ const p = class p {
278
309
  return this.replaceOtherIdentityWithEmailsha256(t);
279
310
  }
280
311
  returnLocalSessionAttributes() {
281
- return !o().Rokt || typeof o().Rokt.getLocalSessionAttributes != "function" ? {} : y(this.placementEventMappingLookup) && y(this.placementEventAttributeMappingLookup) ? {} : o().Rokt.getLocalSessionAttributes();
312
+ return !a().Rokt || typeof a().Rokt.getLocalSessionAttributes != "function" ? {} : I(this.placementEventMappingLookup) && I(this.placementEventAttributeMappingLookup) ? {} : a().Rokt.getLocalSessionAttributes();
282
313
  }
283
314
  replaceOtherIdentityWithEmailsha256(e) {
284
315
  const t = { ...e || {} }, i = this._mappedEmailSha256Key;
285
- return i && e[i] && (t[p.EMAIL_SHA256_KEY] = e[i]), i && delete t[i], t;
316
+ return i && e[i] && (t[h.EMAIL_SHA256_KEY] = e[i]), i && delete t[i], t;
286
317
  }
287
318
  logSelectPlacementsEvent(e) {
288
- if (!window.mParticle || typeof o().logEvent != "function" || !L(e))
319
+ if (!window.mParticle || typeof a().logEvent != "function" || !T(e))
289
320
  return;
290
- const t = o().EventType.Other;
291
- o().logEvent(z, t, e);
321
+ const t = a().EventType.Other;
322
+ a().logEvent(J, t, e);
292
323
  }
293
324
  buildIdentityEvent(e, t) {
294
- const i = t.getMPID(), r = o() && o().sessionManager && typeof o().sessionManager.getSession == "function" ? o().sessionManager.getSession() : void 0;
325
+ const i = t.getMPID(), r = a() && a().sessionManager && typeof a().sessionManager.getSession == "function" ? a().sessionManager.getSession() : void 0;
295
326
  return {
296
327
  event_type: e,
297
328
  data: {
@@ -316,7 +347,22 @@ const p = class p {
316
347
  }), this.batchQueue = [];
317
348
  }
318
349
  processBatch(e) {
319
- return this.isKitReady() ? (this.sendBatchStream(this.mergePendingIdentityEvents(e)), "Successfully sent batch to forwarder: " + l) : (this.batchQueue.push(e), "Batch queued for forwarder: " + l);
350
+ if (!this.isKitReady())
351
+ return this.batchQueue.push(e), "Batch queued for forwarder: " + d;
352
+ const t = this.enrichCommerceEventTypes(this.mergePendingIdentityEvents(e));
353
+ return this.sendBatchStream(t), "Successfully sent batch to forwarder: " + d;
354
+ }
355
+ enrichCommerceEventTypes(e) {
356
+ if (!e.events)
357
+ return e;
358
+ for (const t of e.events) {
359
+ if (t.event_type !== "commerce_event") continue;
360
+ const { data: i } = t;
361
+ if (!i) continue;
362
+ const r = i.custom_flags?.["Rokt.CommerceEventType"];
363
+ r && T(i.product_action) && (i.product_action.action = r);
364
+ }
365
+ return e;
320
366
  }
321
367
  sendBatchStream(e) {
322
368
  if (window.Rokt && typeof window.Rokt.__batch_stream__ == "function") {
@@ -333,37 +379,37 @@ const p = class p {
333
379
  setRoktSessionId(e) {
334
380
  if (!(!e || typeof e != "string"))
335
381
  try {
336
- const t = o().getInstance();
337
- t && typeof t.setIntegrationAttribute == "function" && t.setIntegrationAttribute(181, {
382
+ const t = a().getInstance();
383
+ t && typeof t.setIntegrationAttribute == "function" && t.setIntegrationAttribute(w, {
338
384
  roktSessionId: e
339
385
  });
340
386
  } catch {
341
387
  }
342
388
  }
343
389
  attachLauncher(e, t, i = []) {
344
- const r = o() && o().sessionManager && typeof o().sessionManager.getSession == "function" ? o().sessionManager.getSession() : void 0, a = {
390
+ const r = a() && a().sessionManager && typeof a().sessionManager.getSession == "function" ? a().sessionManager.getSession() : void 0, s = {
345
391
  accountId: e,
346
392
  ...t || {},
347
393
  ...r ? { mpSessionId: r } : {}
348
394
  };
349
- let s;
350
- this.isPartnerInLocalLauncherTestGroup() ? s = Promise.resolve(window.Rokt.createLocalLauncher(a)) : s = window.Rokt.createLauncher(a), s.then(async (c) => {
351
- await te(i, c), this.initRoktLauncher(c);
395
+ let o;
396
+ this.isPartnerInLocalLauncherTestGroup() ? o = Promise.resolve(window.Rokt.createLocalLauncher(s)) : o = window.Rokt.createLauncher(s), o.then(async (c) => {
397
+ await ae(i, c), this.initRoktLauncher(c);
352
398
  }).catch((c) => {
353
399
  console.error("Error creating Rokt launcher:", c);
354
400
  });
355
401
  }
356
402
  initRoktLauncher(e) {
357
403
  window.Rokt && (window.Rokt.currentLauncher = e), this.launcher = e;
358
- const t = o().Rokt?.filters;
359
- 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, Y(this.domain, this.integrationName), o().Rokt.attachKit(this), this.drainBatchQueue();
404
+ const t = a().Rokt?.filters;
405
+ 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, j(this.domain, this.integrationName), a().Rokt.attachKit(this), this.drainBatchQueue();
360
406
  }
361
407
  fetchOptimizely() {
362
- const e = o()._getActiveForwarders().filter((t) => t.name === "Optimizely");
408
+ const e = a()._getActiveForwarders().filter((t) => t.name === "Optimizely");
363
409
  try {
364
410
  if (e.length > 0 && window.optimizely) {
365
411
  const t = window.optimizely.get("state");
366
- return !t || !t.getActiveExperimentIds ? {} : t.getActiveExperimentIds().reduce((a, s) => (a["rokt.custom.optimizely.experiment." + s + ".variationId"] = t.getVariationMap()[s].id, a), {});
412
+ return !t || !t.getActiveExperimentIds ? {} : t.getActiveExperimentIds().reduce((s, o) => (s["rokt.custom.optimizely.experiment." + o + ".variationId"] = t.getVariationMap()[o].id, s), {});
367
413
  }
368
414
  } catch (t) {
369
415
  console.error("Error fetching Optimizely attributes:", t);
@@ -374,93 +420,93 @@ const p = class p {
374
420
  return !!(this.isInitialized && this.launcher);
375
421
  }
376
422
  isPartnerInLocalLauncherTestGroup() {
377
- return !!(o().config && o().config.isLocalLauncherEnabled && this.isAssignedToSampleGroup());
423
+ return !!(a().config && a().config.isLocalLauncherEnabled && this.isAssignedToSampleGroup());
378
424
  }
379
425
  isAssignedToSampleGroup() {
380
426
  return Math.random() > 0.5;
381
427
  }
382
428
  captureTiming(e) {
383
- window && o() && o().captureTiming && e && o().captureTiming(e);
429
+ window && a() && a().captureTiming && e && a().captureTiming(e);
384
430
  }
385
431
  // ---- Public methods (mParticle Kit Callbacks) ----
386
432
  /**
387
433
  * Initializes the Rokt forwarder with settings from the mParticle server.
388
434
  */
389
- init(e, t, i, r, a) {
390
- const s = e, c = s.accountId;
391
- this.userAttributes = a || {}, this._onboardingExpProvider = s.onboardingExpProvider;
392
- const u = S(s.placementEventMapping);
393
- this.placementEventMappingLookup = K(u);
394
- const d = S(
395
- s.placementEventAttributeMapping
435
+ init(e, t, i, r, s) {
436
+ const o = e, c = o.accountId;
437
+ this.userAttributes = A(s), this._onboardingExpProvider = o.onboardingExpProvider;
438
+ const l = b(o.placementEventMapping);
439
+ this.placementEventMappingLookup = x(l);
440
+ const u = b(
441
+ o.placementEventAttributeMapping
396
442
  );
397
- this.placementEventAttributeMappingLookup = D(d), s.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = s.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = g(s.workspaceIdSyncApiKey) ? s.workspaceIdSyncApiKey : void 0;
398
- const m = o().Rokt?.domain, { roktExtensionsQueryParams: v, legacyRoktExtensions: _, loadThankYouElement: b } = M(
399
- s.roktExtensions
400
- ), h = {
401
- ...o().Rokt?.launcherOptions || {}
443
+ this.placementEventAttributeMappingLookup = Y(u), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase()), this._workspaceIdSyncApiKey = f(o.workspaceIdSyncApiKey) ? o.workspaceIdSyncApiKey : void 0;
444
+ const E = a().Rokt?.domain, { roktExtensionsQueryParams: O, legacyRoktExtensions: k, loadThankYouElement: R } = D(
445
+ o.roktExtensions
446
+ ), p = {
447
+ ...a().Rokt?.launcherOptions || {}
402
448
  };
403
- this.integrationName = ie(h.integrationName), h.integrationName = this.integrationName, this.domain = m;
404
- const k = {
405
- loggingUrl: s.loggingUrl,
406
- errorUrl: s.errorUrl,
407
- isLoggingEnabled: o().config?.isLoggingEnabled === !0
408
- }, E = new F(
409
- k,
449
+ this.integrationName = ce(p.integrationName), p.integrationName = this.integrationName, this.domain = E;
450
+ const _ = {
451
+ loggingUrl: o.loggingUrl,
452
+ errorUrl: o.errorUrl,
453
+ isLoggingEnabled: a().config?.isLoggingEnabled === !0
454
+ }, y = new H(
455
+ _,
410
456
  this.integrationName,
411
457
  window.__rokt_li_guid__,
412
- s.accountId
413
- ), R = new j(
414
- k,
415
- E,
458
+ o.accountId
459
+ ), S = new G(
460
+ _,
461
+ y,
416
462
  this.integrationName,
417
463
  window.__rokt_li_guid__,
418
- s.accountId
464
+ o.accountId
419
465
  );
420
- return this.errorReportingService = E, this.loggingService = R, o()._registerErrorReportingService && o()._registerErrorReportingService(E), o()._registerLoggingService && o()._registerLoggingService(R), i ? (this.testHelpers = {
421
- generateLauncherScript: P,
422
- generateThankYouElementScript: U,
423
- extractRoktExtensionConfig: M,
424
- hashEventMessage: x,
425
- parseSettingsString: S,
426
- generateMappedEventLookup: K,
427
- generateMappedEventAttributeLookup: D,
428
- sendAdBlockMeasurementSignals: Y,
429
- createAutoRemovedIframe: O,
430
- djb2: H,
431
- setAllowedOriginHashes: (I) => {
432
- p._allowedOriginHashes = I;
466
+ return this.errorReportingService = y, this.loggingService = S, a()._registerErrorReportingService && a()._registerErrorReportingService(y), a()._registerLoggingService && a()._registerLoggingService(S), i ? (this.testHelpers = {
467
+ generateLauncherScript: C,
468
+ generateThankYouElementScript: M,
469
+ extractRoktExtensionConfig: D,
470
+ hashEventMessage: F,
471
+ parseSettingsString: b,
472
+ generateMappedEventLookup: x,
473
+ generateMappedEventAttributeLookup: Y,
474
+ sendAdBlockMeasurementSignals: j,
475
+ createAutoRemovedIframe: N,
476
+ djb2: Q,
477
+ setAllowedOriginHashes: (g) => {
478
+ h._allowedOriginHashes = g;
433
479
  },
434
- ReportingTransport: N,
435
- ErrorReportingService: F,
436
- LoggingService: j,
437
- RateLimiter: W,
438
- ErrorCodes: T,
439
- WSDKErrorSeverity: A
440
- }, this.attachLauncher(c, h), "Successfully initialized: " + l) : (b && (o().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), C(q, U(m), {
480
+ ReportingTransport: U,
481
+ ErrorReportingService: H,
482
+ LoggingService: G,
483
+ RateLimiter: B,
484
+ ErrorCodes: P,
485
+ WSDKErrorSeverity: L
486
+ }, this.attachLauncher(c, p), "Successfully initialized: " + d) : (R && (a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), K(te, M(E), {
441
487
  onLoad: () => {
442
488
  this._isThankYouElementLoaded = !0, this._thankYouElementOnLoadCallback && this._thankYouElementOnLoadCallback();
443
489
  },
444
- onError: (I) => {
445
- console.error("Error loading Rokt Thank You Element script:", I);
490
+ onError: (g) => {
491
+ console.error("Error loading Rokt Thank You Element script:", g);
446
492
  }
447
- })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, h, _) : (C(V, P(m, v), {
493
+ })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, k) : (K(ee, C(E, O), {
448
494
  onLoad: () => {
449
- this.isLauncherReadyToAttach() ? this.attachLauncher(c, h, _) : console.error("Rokt object is not available after script load.");
495
+ this.isLauncherReadyToAttach() ? this.attachLauncher(c, p, k) : console.error("Rokt object is not available after script load.");
450
496
  },
451
- onError: (I) => {
452
- console.error("Error loading Rokt launcher script:", I);
497
+ onError: (g) => {
498
+ console.error("Error loading Rokt launcher script:", g);
453
499
  }
454
- }), this.captureTiming(p.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + l);
500
+ }), this.captureTiming(h.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + d);
455
501
  }
456
502
  process(e) {
457
503
  if (!this.isKitReady())
458
- return "Kit not ready for forwarder: " + l;
459
- if (typeof o().Rokt?.setLocalSessionAttribute == "function" && (y(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !y(this.placementEventMappingLookup))) {
460
- const t = x(e.EventDataType, e.EventCategory, e.EventName ?? "");
461
- this.placementEventMappingLookup[String(t)] && o().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)], !0);
504
+ return "Kit not ready for forwarder: " + d;
505
+ if (typeof a().Rokt?.setLocalSessionAttribute == "function" && (I(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(e), !I(this.placementEventMappingLookup))) {
506
+ const t = F(e.EventDataType, e.EventCategory, e.EventName ?? "");
507
+ this.placementEventMappingLookup[String(t)] && a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)], !0);
462
508
  }
463
- return "Successfully sent to forwarder: " + l;
509
+ return "Successfully sent to forwarder: " + d;
464
510
  }
465
511
  setExtensionData(e) {
466
512
  if (!this.isKitReady()) {
@@ -470,54 +516,54 @@ const p = class p {
470
516
  window.Rokt.setExtensionData(e);
471
517
  }
472
518
  setUserAttribute(e, t) {
473
- return this.userAttributes[e] = t, "Successfully set user attribute for forwarder: " + l;
519
+ return z(e) || (this.userAttributes[e] = t), "Successfully set user attribute for forwarder: " + d;
474
520
  }
475
521
  removeUserAttribute(e) {
476
- return delete this.userAttributes[e], "Successfully removed user attribute for forwarder: " + l;
522
+ return delete this.userAttributes[e], "Successfully removed user attribute for forwarder: " + d;
477
523
  }
478
524
  handleIdentityComplete(e, t, i) {
479
525
  const r = e;
480
- return this.userAttributes = e.getAllUserAttributes(), this.pendingIdentityEvents.push(this.buildIdentityEvent(t, r)), "Successfully called " + i + " for forwarder: " + l;
526
+ return this.userAttributes = A(e.getAllUserAttributes()), this.pendingIdentityEvents.push(this.buildIdentityEvent(t, r)), "Successfully called " + i + " for forwarder: " + d;
481
527
  }
482
528
  onUserIdentified(e) {
483
529
  const t = e;
484
- return this.filters.filteredUser = t, this._workspaceSearchInFlightPromise = this.search(t), this.handleIdentityComplete(e, w.IDENTIFY, "onUserIdentified");
530
+ return this.filters.filteredUser = t, this._workspaceSearchInFlightPromise = this.search(t), this.handleIdentityComplete(e, v.IDENTIFY, "onUserIdentified");
485
531
  }
486
532
  search(e) {
487
533
  const t = this._workspaceIdSyncApiKey;
488
534
  if (!t)
489
535
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
490
- const i = o().Identity?.search;
536
+ const i = a().Identity?.search;
491
537
  if (typeof i != "function")
492
538
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
493
- const r = e.getUserIdentities ? e.getUserIdentities().userIdentities : null, a = {};
539
+ const r = e.getUserIdentities ? e.getUserIdentities().userIdentities : null, s = {};
494
540
  if (r)
495
- for (const u of Object.keys(r)) {
496
- const d = r[u];
497
- g(d) && d.length > 0 && (a[u] = d);
541
+ for (const l of Object.keys(r)) {
542
+ const u = r[l];
543
+ f(u) && u.length > 0 && (s[l] = u);
498
544
  }
499
- const s = Object.keys(a);
500
- if (s.length === 0)
545
+ const o = Object.keys(s);
546
+ if (o.length === 0)
501
547
  return this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = void 0, Promise.resolve();
502
- const c = s.sort().map((u) => `${u}=${a[u]}`).join("&");
503
- return c === this._workspaceLastSearchedIdentitiesKey ? this._workspaceSearchInFlightPromise || Promise.resolve() : (this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = c, new Promise((u) => {
548
+ const c = o.sort().map((l) => `${l}=${s[l]}`).join("&");
549
+ return c === this._workspaceLastSearchedIdentitiesKey ? this._workspaceSearchInFlightPromise || Promise.resolve() : (this.userIdentifiedInWorkspace = !1, this._workspaceLastSearchedIdentitiesKey = c, new Promise((l) => {
504
550
  try {
505
- i(t, a, (d) => {
506
- d?.httpCode === 200 && (this.userIdentifiedInWorkspace = !0), u();
551
+ i(t, s, (u) => {
552
+ u?.httpCode === 200 && (this.userIdentifiedInWorkspace = !0), l();
507
553
  });
508
- } catch (d) {
509
- console.error("Rokt Kit: Workspace IDSync search failed", d), this._workspaceLastSearchedIdentitiesKey = void 0, u();
554
+ } catch (u) {
555
+ console.error("Rokt Kit: Workspace IDSync search failed", u), this._workspaceLastSearchedIdentitiesKey = void 0, l();
510
556
  }
511
557
  }));
512
558
  }
513
559
  onLoginComplete(e, t) {
514
- return this.handleIdentityComplete(e, w.LOGIN, "onLoginComplete");
560
+ return this.handleIdentityComplete(e, v.LOGIN, "onLoginComplete");
515
561
  }
516
562
  onLogoutComplete(e, t) {
517
- return this.userIdentifiedInWorkspace = !1, this._workspaceSearchInFlightPromise = null, this._workspaceLastSearchedIdentitiesKey = void 0, this.handleIdentityComplete(e, w.LOGOUT, "onLogoutComplete");
563
+ return this.userIdentifiedInWorkspace = !1, this._workspaceSearchInFlightPromise = null, this._workspaceLastSearchedIdentitiesKey = void 0, this.handleIdentityComplete(e, v.LOGOUT, "onLogoutComplete");
518
564
  }
519
565
  onModifyComplete(e, t) {
520
- return this.handleIdentityComplete(e, w.MODIFY_USER, "onModifyComplete");
566
+ return this.handleIdentityComplete(e, v.MODIFY_USER, "onModifyComplete");
521
567
  }
522
568
  /**
523
569
  * Selects placements for Rokt Web SDK with merged attributes, filters, and experimentation options.
@@ -547,25 +593,25 @@ const p = class p {
547
593
  const t = this._workspaceSearchInFlightPromise;
548
594
  return Promise.race([
549
595
  t,
550
- new Promise((i) => setTimeout(i, X))
596
+ new Promise((i) => setTimeout(i, ne))
551
597
  ]).then(() => this._dispatchPlacements(e));
552
598
  }
553
599
  return this._dispatchPlacements(e);
554
600
  }
555
601
  _dispatchPlacements(e) {
556
- const t = e && e.attributes || {}, i = { ...this.userAttributes, ...t }, r = this.filters || {}, a = r.userAttributeFilters || [], s = r.filteredUser || null, c = s ? s.getMPID() : null;
602
+ const t = e && e.attributes || {}, r = { ...A(this.userAttributes), ...t }, s = this.filters || {}, o = s.userAttributeFilters || [], c = s.filteredUser || null, l = c ? c.getMPID() : null;
557
603
  let u;
558
- r ? r.filterUserAttributes ? u = r.filterUserAttributes(i, a) : u = i : (console.warn("Rokt Kit: No filters available, using user attributes"), u = i), this.userAttributes = u;
559
- const d = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, m = this.returnUserIdentities(s), v = this.returnLocalSessionAttributes(), _ = {
560
- ...m,
604
+ s ? s.filterUserAttributes ? u = s.filterUserAttributes(r, o) : u = r : (console.warn("Rokt Kit: No filters available, using user attributes"), u = r), this.userAttributes = A(u);
605
+ const E = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, O = this.returnUserIdentities(c), k = this.returnLocalSessionAttributes(), R = {
606
+ ...O,
561
607
  ...u,
562
- ...d,
563
- ...v,
564
- ...this.userIdentifiedInWorkspace ? { [J]: !0 } : {},
565
- mpid: c
566
- }, b = { ...e, attributes: _ }, h = this.launcher.selectPlacements(b), k = () => this.logSelectPlacementsEvent(_);
567
- return Promise.resolve(h).then((E) => E?.context?.sessionId?.then((R) => this.setRoktSessionId(R))).catch(() => {
568
- }).finally(k), h;
608
+ ...E,
609
+ ...k,
610
+ ...this.userIdentifiedInWorkspace ? { [ie]: !0 } : {},
611
+ mpid: l
612
+ }, p = { ...e, attributes: R }, _ = this.launcher.selectPlacements(p), y = () => this.logSelectPlacementsEvent(R);
613
+ return Promise.resolve(_).then((S) => S?.context?.sessionId?.then((g) => this.setRoktSessionId(g))).catch(() => {
614
+ }).finally(y), _;
569
615
  }
570
616
  /**
571
617
  * Passes attributes to the Rokt Web SDK for client-side hashing.
@@ -579,7 +625,7 @@ const p = class p {
579
625
  * @deprecated This functionality has been internalized and will be removed in a future release.
580
626
  */
581
627
  use(e) {
582
- return this.isKitReady() ? !e || !g(e) ? Promise.reject(new Error("Rokt Kit: Invalid extension name")) : this.launcher.use(e) : (console.error("Rokt Kit: Not initialized"), Promise.reject(new Error("Rokt Kit: Not initialized")));
628
+ return this.isKitReady() ? !e || !f(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")));
583
629
  }
584
630
  /**
585
631
  * Registers a callback to be invoked once rokt-thank-you-element.js becomes available.
@@ -588,34 +634,34 @@ const p = class p {
588
634
  this._isThankYouElementLoaded ? e() : this._thankYouElementOnLoadCallback = e;
589
635
  }
590
636
  };
591
- p._allowedOriginHashes = [-553112570, 549508659], p.PERFORMANCE_MARKS = {
637
+ h._allowedOriginHashes = [-553112570, 549508659], h.PERFORMANCE_MARKS = {
592
638
  RoktScriptAppended: "mp:RoktScriptAppended"
593
- }, p.EMAIL_SHA256_KEY = "emailsha256";
594
- let f = p;
595
- function ae() {
596
- return 181;
639
+ }, h.EMAIL_SHA256_KEY = "emailsha256";
640
+ let m = h;
641
+ function he() {
642
+ return w;
597
643
  }
598
- function ce(n) {
644
+ function pe(n) {
599
645
  if (!n) {
600
- window.console.log("You must pass a config object to register the kit " + l);
646
+ window.console.log("You must pass a config object to register the kit " + d);
601
647
  return;
602
648
  }
603
- if (!L(n)) {
649
+ if (!T(n)) {
604
650
  window.console.log("'config' must be an object. You passed in a " + typeof n);
605
651
  return;
606
652
  }
607
- L(n.kits) ? n.kits[l] = {
608
- constructor: f
609
- } : (n.kits = {}, n.kits[l] = {
610
- constructor: f
611
- }), window.console.log("Successfully registered " + l + " to your mParticle configuration");
653
+ T(n.kits) ? n.kits[d] = {
654
+ constructor: m
655
+ } : (n.kits = {}, n.kits[d] = {
656
+ constructor: m
657
+ }), window.console.log("Successfully registered " + d + " to your mParticle configuration");
612
658
  }
613
- typeof window < "u" && window.mParticle && o().addForwarder && o().addForwarder({
614
- name: l,
615
- constructor: f,
616
- getId: ae
659
+ typeof window < "u" && window.mParticle && a().addForwarder && a().addForwarder({
660
+ name: d,
661
+ constructor: m,
662
+ getId: he
617
663
  });
618
664
  export {
619
- ce as register
665
+ pe as register
620
666
  };
621
667
  //# sourceMappingURL=Rokt-Kit.esm.js.map
@@ -1,2 +1,2 @@
1
- var RoktKit=(function(v){"use strict";const l="Rokt",Q="selectPlacements",B="apps.roktecommerce.com",k={LOGIN:"login",LOGOUT:"logout",MODIFY_USER:"modify_user",IDENTIFY:"identify"},V="ThankYouPageJourney",q="rokt-launcher",J="rokt-thank-you-element",X="userIdentifiedInWorkspace",$=500,b={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST"},R={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},Z="apps.rokt-api.com/v1/log",ee="apps.rokt-api.com/v1/errors",te=10;function o(){return window.mParticle}function U(n,e){const i=[M(n),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?i:i+"?extensions="+e.join(",")}function C(n){return[M(n),"/rokt-elements/rokt-element-thank-you.js"].join("")}function M(n){return["https://",typeof n<"u"?n:"apps.rokt-api.com"].join("")}function K(n,e,t){if(document.getElementById(n))return;const i=document.head||document.body,r=document.createElement("script");r.id=n,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),i.appendChild(r)}function L(n){return n!=null&&typeof n=="object"&&Array.isArray(n)===!1}function w(n){if(!n)return[];try{return JSON.parse(n.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function D(n){const e=n?w(n):[],t=[],i=[];let r=!1;for(let a=0;a<e.length;a++){const s=e[a].value;s==="thank-you-journey"?(r=!0,i.push(V)):t.push(s)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:i,loadThankYouElement:r}}async function ie(n,e){const t=[];if(e)for(const i of n)t.push(e.use(i));return Promise.all(t)}function Y(n){if(!n)return{};const e={};for(let t=0;t<n.length;t++){const i=n[t];e[i.jsmap]=i.value}return e}function x(n){const e={};if(!Array.isArray(n))return e;for(let t=0;t<n.length;t++){const i=n[t];if(!i||!g(i.value)||!g(i.map))continue;const r=i.value,a=i.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:a,conditions:Array.isArray(i.conditions)?i.conditions:[]})}return e}function F(n,e,t){return o().generateHash([n,e,t].join(""))}function m(n){return n==null?!0:typeof n=="object"?Object.keys(n).length===0:Array.isArray(n)?n.length===0:!1}function g(n){return typeof n=="string"}function ne(n){let i="mParticle_wsdkv_"+o().getVersion()+"_kitv_"+"1.26.2";return n&&(i+="_"+n),i}function j(n){let e=5381;for(let t=0;t<n.length;t++)e=(e<<5)+e+n.charCodeAt(t),e=e&e;return e}function O(n){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=n,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function G(n,e){const t=j(window.location.origin);if(f._allowedOriginHashes.indexOf(t)===-1||Math.random()>=.1)return;const r=window.__rokt_li_guid__;if(!r)return;const a=window.location.href.split("?")[0].split("#")[0],s="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(a);O("https://"+(n||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+s),O("https://"+B+"/v1/wsdk-init/index.html?"+s+"&isControl=true")}function re(){return typeof window<"u"&&!!window.ROKT_DOMAIN}function se(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function oe(){return typeof window<"u"?window.location?.href:void 0}function ae(){return typeof window<"u"?window.navigator?.userAgent:void 0}class H{constructor(){this._logCount={}}incrementAndCheck(e){const i=(this._logCount[e]||0)+1;return this._logCount[e]=i,i>te}}class T{constructor(e,t,i,r,a){this._reporter="mp-wsdk";const s=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=i,this._accountId=r||null,this._rateLimiter=a||new H,this._isEnabled=se()||re()&&s}send(e,t,i,r,a,s){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:i,version:this._integrationName},severity:t,code:r||b.UNKNOWN_ERROR,url:oe(),deviceInfo:ae(),stackTrace:a,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)}).catch(d=>{console.error("ReportingTransport: Failed to send log",d),s&&s(d)})}catch(c){console.error("ReportingTransport: Failed to send log",c),s&&s(c)}}}class W{constructor(e,t,i,r,a){this._transport=new T(e,t,i,r,a),this._errorUrl="https://"+(e?.errorUrl||ee)}report(e){if(!e)return;const t=e.severity||R.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class z{constructor(e,t,i,r,a,s){this._transport=new T(e,i,r,a,s),this._loggingUrl="https://"+(e?.loggingUrl||Z),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,R.INFO,e.message,e.code,void 0,t=>{this._errorReportingService&&this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:b.UNKNOWN_ERROR,severity:R.ERROR})})}}const h=class h{constructor(){this.name=l,this.id=181,this.moduleId=181,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.batchQueue=[],this.batchStreamQueue=[],this.pendingIdentityEvents=[],this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null}getEventAttributeValue(e,t){const i=e&&e.EventAttributes;return!i||typeof i[t]>"u"?null:i[t]}doesEventAttributeConditionMatch(e,t){if(!e||!g(e.operator))return!1;const i=e.operator.toLowerCase(),r=e.attributeValue;return i==="exists"?t!==null:t==null?!1:i==="equals"?String(t)===String(r):i==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!g(t.eventAttributeKey))return!1;const i=t.conditions;if(!Array.isArray(i))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(i.length===0)return r!==null;for(let a=0;a<i.length;a++)if(!this.doesEventAttributeConditionMatch(i[a],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let i=0;i<t.length;i++){const r=t[i],a=this.placementEventAttributeMappingLookup[r];if(m(a))continue;let s=!0;for(let c=0;c<a.length;c++)if(!this.doesEventMatchRule(e,a[c])){s=!1;break}s&&o().Rokt.setLocalSessionAttribute?.(r,!0)}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}returnUserIdentities(e){if(!e||!e.getUserIdentities)return{};const t=e.getUserIdentities().userIdentities;return this.replaceOtherIdentityWithEmailsha256(t)}returnLocalSessionAttributes(){return!o().Rokt||typeof o().Rokt.getLocalSessionAttributes!="function"?{}:m(this.placementEventMappingLookup)&&m(this.placementEventAttributeMappingLookup)?{}:o().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},i=this._mappedEmailSha256Key;return i&&e[i]&&(t[h.EMAIL_SHA256_KEY]=e[i]),i&&delete t[i],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof o().logEvent!="function"||!L(e))return;const t=o().EventType.Other;o().logEvent(Q,t,e)}buildIdentityEvent(e,t){const i=t.getMPID(),r=o()&&o().sessionManager&&typeof o().sessionManager.getSession=="function"?o().sessionManager.getSession():void 0;return{event_type:e,data:{timestamp_unixtime_ms:Date.now(),session_uuid:r??void 0,mpid:i}}}mergePendingIdentityEvents(e){if(this.pendingIdentityEvents.length===0)return e;const t={...e,events:[...e.events??[],...this.pendingIdentityEvents]};return this.pendingIdentityEvents=[],t}drainBatchQueue(){this.batchQueue.forEach(e=>{this.processBatch(e)}),this.batchQueue=[]}processBatch(e){return this.isKitReady()?(this.sendBatchStream(this.mergePendingIdentityEvents(e)),"Successfully sent batch to forwarder: "+l):(this.batchQueue.push(e),"Batch queued for forwarder: "+l)}sendBatchStream(e){if(window.Rokt&&typeof window.Rokt.__batch_stream__=="function"){if(this.batchStreamQueue.length){const t=this.batchStreamQueue;this.batchStreamQueue=[];for(let i=0;i<t.length;i++)window.Rokt.__batch_stream__(t[i])}window.Rokt.__batch_stream__(e)}else this.batchStreamQueue.push(e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=o().getInstance();t&&typeof t.setIntegrationAttribute=="function"&&t.setIntegrationAttribute(181,{roktSessionId:e})}catch{}}attachLauncher(e,t,i=[]){const r=o()&&o().sessionManager&&typeof o().sessionManager.getSession=="function"?o().sessionManager.getSession():void 0,a={accountId:e,...t||{},...r?{mpSessionId:r}:{}};let s;this.isPartnerInLocalLauncherTestGroup()?s=Promise.resolve(window.Rokt.createLocalLauncher(a)):s=window.Rokt.createLauncher(a),s.then(async c=>{await ie(i,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e;const t=o().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,G(this.domain,this.integrationName),o().Rokt.attachKit(this),this.drainBatchQueue()}fetchOptimizely(){const e=o()._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((a,s)=>(a["rokt.custom.optimizely.experiment."+s+".variationId"]=t.getVariationMap()[s].id,a),{})}}catch(t){console.error("Error fetching Optimizely attributes:",t)}return{}}isKitReady(){return!!(this.isInitialized&&this.launcher)}isPartnerInLocalLauncherTestGroup(){return!!(o().config&&o().config.isLocalLauncherEnabled&&this.isAssignedToSampleGroup())}isAssignedToSampleGroup(){return Math.random()>.5}captureTiming(e){window&&o()&&o().captureTiming&&e&&o().captureTiming(e)}init(e,t,i,r,a){const s=e,c=s.accountId;this.userAttributes=a||{},this._onboardingExpProvider=s.onboardingExpProvider;const u=w(s.placementEventMapping);this.placementEventMappingLookup=Y(u);const d=w(s.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=x(d),s.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=s.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=g(s.workspaceIdSyncApiKey)?s.workspaceIdSyncApiKey:void 0;const _=o().Rokt?.domain,{roktExtensionsQueryParams:N,legacyRoktExtensions:E,loadThankYouElement:P}=D(s.roktExtensions),p={...o().Rokt?.launcherOptions||{}};this.integrationName=ne(p.integrationName),p.integrationName=this.integrationName,this.domain=_;const S={loggingUrl:s.loggingUrl,errorUrl:s.errorUrl,isLoggingEnabled:o().config?.isLoggingEnabled===!0},y=new W(S,this.integrationName,window.__rokt_li_guid__,s.accountId),A=new z(S,y,this.integrationName,window.__rokt_li_guid__,s.accountId);return this.errorReportingService=y,this.loggingService=A,o()._registerErrorReportingService&&o()._registerErrorReportingService(y),o()._registerLoggingService&&o()._registerLoggingService(A),i?(this.testHelpers={generateLauncherScript:U,generateThankYouElementScript:C,extractRoktExtensionConfig:D,hashEventMessage:F,parseSettingsString:w,generateMappedEventLookup:Y,generateMappedEventAttributeLookup:x,sendAdBlockMeasurementSignals:G,createAutoRemovedIframe:O,djb2:j,setAllowedOriginHashes:I=>{h._allowedOriginHashes=I},ReportingTransport:T,ErrorReportingService:W,LoggingService:z,RateLimiter:H,ErrorCodes:b,WSDKErrorSeverity:R},this.attachLauncher(c,p),"Successfully initialized: "+l):(P&&(o().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),K(J,C(_),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:I=>{console.error("Error loading Rokt Thank You Element script:",I)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,p,E):(K(q,U(_,N),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,p,E):console.error("Rokt object is not available after script load.")},onError:I=>{console.error("Error loading Rokt launcher script:",I)}}),this.captureTiming(h.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+l)}process(e){if(!this.isKitReady())return"Kit not ready for forwarder: "+l;if(typeof o().Rokt?.setLocalSessionAttribute=="function"&&(m(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!m(this.placementEventMappingLookup))){const t=F(e.EventDataType,e.EventCategory,e.EventName??"");this.placementEventMappingLookup[String(t)]&&o().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(t)],!0)}return"Successfully sent to forwarder: "+l}setExtensionData(e){if(!this.isKitReady()){console.error("Rokt Kit: Not initialized");return}window.Rokt.setExtensionData(e)}setUserAttribute(e,t){return this.userAttributes[e]=t,"Successfully set user attribute for forwarder: "+l}removeUserAttribute(e){return delete this.userAttributes[e],"Successfully removed user attribute for forwarder: "+l}handleIdentityComplete(e,t,i){const r=e;return this.userAttributes=e.getAllUserAttributes(),this.pendingIdentityEvents.push(this.buildIdentityEvent(t,r)),"Successfully called "+i+" for forwarder: "+l}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,k.IDENTIFY,"onUserIdentified")}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const i=o().Identity?.search;if(typeof i!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,a={};if(r)for(const u of Object.keys(r)){const d=r[u];g(d)&&d.length>0&&(a[u]=d)}const s=Object.keys(a);if(s.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=s.sort().map(u=>`${u}=${a[u]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(u=>{try{i(t,a,d=>{d?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),u()})}catch(d){console.error("Rokt Kit: Workspace IDSync search failed",d),this._workspaceLastSearchedIdentitiesKey=void 0,u()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,k.LOGIN,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(e,k.LOGOUT,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,k.MODIFY_USER,"onModifyComplete")}selectPlacements(e){if(this._workspaceSearchInFlightPromise){const t=this._workspaceSearchInFlightPromise;return Promise.race([t,new Promise(i=>setTimeout(i,$))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},i={...this.userAttributes,...t},r=this.filters||{},a=r.userAttributeFilters||[],s=r.filteredUser||null,c=s?s.getMPID():null;let u;r?r.filterUserAttributes?u=r.filterUserAttributes(i,a):u=i:(console.warn("Rokt Kit: No filters available, using user attributes"),u=i),this.userAttributes=u;const d=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},_=this.returnUserIdentities(s),N=this.returnLocalSessionAttributes(),E={..._,...u,...d,...N,...this.userIdentifiedInWorkspace?{[X]:!0}:{},mpid:c},P={...e,attributes:E},p=this.launcher.selectPlacements(P),S=()=>this.logSelectPlacementsEvent(E);return Promise.resolve(p).then(y=>y?.context?.sessionId?.then(A=>this.setRoktSessionId(A))).catch(()=>{}).finally(S),p}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!g(e)?Promise.reject(new Error("Rokt Kit: Invalid extension name")):this.launcher.use(e):(console.error("Rokt Kit: Not initialized"),Promise.reject(new Error("Rokt Kit: Not initialized")))}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};h._allowedOriginHashes=[-553112570,549508659],h.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},h.EMAIL_SHA256_KEY="emailsha256";let f=h;function ce(){return 181}function ue(n){if(!n){window.console.log("You must pass a config object to register the kit "+l);return}if(!L(n)){window.console.log("'config' must be an object. You passed in a "+typeof n);return}L(n.kits)?n.kits[l]={constructor:f}:(n.kits={},n.kits[l]={constructor:f}),window.console.log("Successfully registered "+l+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&o().addForwarder&&o().addForwarder({name:l,constructor:f,getId:ce}),v.register=ue,Object.defineProperty(v,Symbol.toStringTag,{value:"Module"}),v})({});
1
+ var RoktKit=(function(O){"use strict";const q=["billingaddress1","billingaddress2","billingcity","billingstate","billingzipcode","cartitems","ccbin","confirmationref","conversiontype","country","couponcode","currency","language","paymentserviceprovider","paymentserviceproviderattribute","paymenttype","shippingaddress1","shippingcity","shippingcountry","shippingmethod","shippingstate","shippingzipcode","totalprice"],J=new Set(q);function M(n){return J.has(n.toLowerCase())}function k(n){const e={},t=n||{},i=Object.keys(t);for(let r=0;r<i.length;r++){const s=i[r];M(s)||(e[s]=t[s])}return e}const d="Rokt",R=181,X="selectPlacements",$="apps.roktecommerce.com",Z=.1,S={LOGIN:"login",LOGOUT:"logout",MODIFY_USER:"modify_user",IDENTIFY:"identify"},ee="ThankYouPageJourney",te="rokt-launcher",ie="rokt-thank-you-element",ne="userIdentifiedInWorkspace",re=500,N={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST"},v={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},se="apps.rokt-api.com/v1/log",oe="apps.rokt-api.com/v1/errors",ae=10;function a(){return window.mParticle}function K(n,e){const i=[Y(n),"/wsdk/integrations/launcher.js"].join("");return!e||e.length===0?i:i+"?extensions="+e.join(",")}function D(n){return[Y(n),"/rokt-elements/rokt-element-thank-you.js"].join("")}function Y(n){return["https://",typeof n<"u"?n:"apps.rokt-api.com"].join("")}function x(n,e,t){if(document.getElementById(n))return;const i=document.head||document.body,r=document.createElement("script");r.id=n,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),i.appendChild(r)}function A(n){return n!=null&&typeof n=="object"&&Array.isArray(n)===!1}function w(n){if(!n)return[];try{return JSON.parse(n.replace(/&quot;/g,'"'))}catch{console.error("Settings string contains invalid JSON")}return[]}function F(n){const e=n?w(n):[],t=[],i=[];let r=!1;for(let s=0;s<e.length;s++){const o=e[s].value;o==="thank-you-journey"?(r=!0,i.push(ee)):t.push(o)}return{roktExtensionsQueryParams:t,legacyRoktExtensions:i,loadThankYouElement:r}}async function ce(n,e){const t=[];if(e)for(const i of n)t.push(e.use(i));return Promise.all(t)}function j(n){if(!n)return{};const e={};for(let t=0;t<n.length;t++){const i=n[t];e[i.jsmap]=i.value}return e}function H(n){const e={};if(!Array.isArray(n))return e;for(let t=0;t<n.length;t++){const i=n[t];if(!i||!p(i.value)||!p(i.map))continue;const r=i.value,s=i.map;e[r]||(e[r]=[]),e[r].push({eventAttributeKey:s,conditions:Array.isArray(i.conditions)?i.conditions:[]})}return e}function G(n,e,t){return a().generateHash([n,e,t].join(""))}function E(n){return n==null?!0:typeof n=="object"?Object.keys(n).length===0:Array.isArray(n)?n.length===0:!1}function p(n){return typeof n=="string"}function ue(n){let i="mParticle_wsdkv_"+a().getVersion()+"_kitv_"+"1.27.0";return n&&(i+="_"+n),i}function z(n){let e=5381;for(let t=0;t<n.length;t++)e=(e<<5)+e+n.charCodeAt(t),e=e&e;return e}function P(n){const e=document.createElement("iframe");e.style.display="none",e.setAttribute("sandbox","allow-scripts allow-same-origin"),e.src=n,e.onload=function(){e.onload=null,e.parentNode&&e.parentNode.removeChild(e)};const t=document.body||document.head;t&&t.appendChild(e)}function W(n,e){const t=z(window.location.origin);if(m._allowedOriginHashes.indexOf(t)===-1||Math.random()>=Z)return;const r=window.__rokt_li_guid__;if(!r)return;const s=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(e??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(s);P("https://"+(n||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+o),P("https://"+$+"/v1/wsdk-init/index.html?"+o+"&isControl=true")}function le(){return typeof window<"u"&&!!window.location?.search?.toLowerCase().includes("mp_enable_logging=true")}function de(){return typeof window<"u"?window.location?.href:void 0}function he(){return typeof window<"u"?window.navigator?.userAgent:void 0}class Q{constructor(){this._logCount={}}incrementAndCheck(e){const i=(this._logCount[e]||0)+1;return this._logCount[e]=i,i>ae}}class U{constructor(e,t,i,r,s){this._reporter="mp-wsdk";const o=e.isLoggingEnabled;this._integrationName=t||"",this._launcherInstanceGuid=i,this._accountId=r||null,this._rateLimiter=s||new Q,this._isEnabled=le()||o}send(e,t,i,r,s,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(t)))try{const c={additionalInformation:{message:i,version:this._integrationName},severity:t,code:r||N.UNKNOWN_ERROR,url:de(),deviceInfo:he(),stackTrace:s,reporter:this._reporter,integration:this._integrationName},l={Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","rokt-launcher-version":this._integrationName,"rokt-wsdk-version":"joint"};this._launcherInstanceGuid&&(l["rokt-launcher-instance-guid"]=this._launcherInstanceGuid),this._accountId&&(l["rokt-account-id"]=this._accountId),fetch(e,{method:"POST",headers:l,body:JSON.stringify(c)}).catch(u=>{console.error("ReportingTransport: Failed to send log",u),o&&o(u)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class B{constructor(e,t,i,r,s){this._transport=new U(e,t,i,r,s),this._errorUrl="https://"+(e?.errorUrl||oe)}report(e){if(!e)return;const t=e.severity||v.ERROR;this._transport.send(this._errorUrl,t,e.message,e.code,e.stackTrace)}}class V{constructor(e,t,i,r,s,o){this._transport=new U(e,i,r,s,o),this._loggingUrl="https://"+(e?.loggingUrl||se),this._errorReportingService=t}log(e){e&&this._transport.send(this._loggingUrl,v.INFO,e.message,e.code,void 0,t=>{this._errorReportingService&&this._errorReportingService.report({message:"LoggingService: Failed to send log: "+t.message,code:N.UNKNOWN_ERROR,severity:v.ERROR})})}}const h=class h{constructor(){this.name=d,this.id=R,this.moduleId=R,this.isInitialized=!1,this.launcher=null,this.filters={},this.userAttributes={},this.userIdentifiedInWorkspace=!1,this.testHelpers=null,this.placementEventMappingLookup={},this.placementEventAttributeMappingLookup={},this.batchQueue=[],this.batchStreamQueue=[],this.pendingIdentityEvents=[],this.integrationName=null,this.errorReportingService=null,this.loggingService=null,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1,this._workspaceSearchInFlightPromise=null}getEventAttributeValue(e,t){const i=e&&e.EventAttributes;return!i||typeof i[t]>"u"?null:i[t]}doesEventAttributeConditionMatch(e,t){if(!e||!p(e.operator))return!1;const i=e.operator.toLowerCase(),r=e.attributeValue;return i==="exists"?t!==null:t==null?!1:i==="equals"?String(t)===String(r):i==="contains"?String(t).indexOf(String(r))!==-1:!1}doesEventMatchRule(e,t){if(!t||!p(t.eventAttributeKey))return!1;const i=t.conditions;if(!Array.isArray(i))return!1;const r=this.getEventAttributeValue(e,t.eventAttributeKey);if(i.length===0)return r!==null;for(let s=0;s<i.length;s++)if(!this.doesEventAttributeConditionMatch(i[s],r))return!1;return!0}applyPlacementEventAttributeMapping(e){const t=Object.keys(this.placementEventAttributeMappingLookup);for(let i=0;i<t.length;i++){const r=t[i],s=this.placementEventAttributeMappingLookup[r];if(E(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)}}isLauncherReadyToAttach(){return!!window.Rokt&&typeof window.Rokt.createLauncher=="function"}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"?{}:E(this.placementEventMappingLookup)&&E(this.placementEventAttributeMappingLookup)?{}:a().Rokt.getLocalSessionAttributes()}replaceOtherIdentityWithEmailsha256(e){const t={...e||{}},i=this._mappedEmailSha256Key;return i&&e[i]&&(t[h.EMAIL_SHA256_KEY]=e[i]),i&&delete t[i],t}logSelectPlacementsEvent(e){if(!window.mParticle||typeof a().logEvent!="function"||!A(e))return;const t=a().EventType.Other;a().logEvent(X,t,e)}buildIdentityEvent(e,t){const i=t.getMPID(),r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0;return{event_type:e,data:{timestamp_unixtime_ms:Date.now(),session_uuid:r??void 0,mpid:i}}}mergePendingIdentityEvents(e){if(this.pendingIdentityEvents.length===0)return e;const t={...e,events:[...e.events??[],...this.pendingIdentityEvents]};return this.pendingIdentityEvents=[],t}drainBatchQueue(){this.batchQueue.forEach(e=>{this.processBatch(e)}),this.batchQueue=[]}processBatch(e){if(!this.isKitReady())return this.batchQueue.push(e),"Batch queued for forwarder: "+d;const t=this.enrichCommerceEventTypes(this.mergePendingIdentityEvents(e));return this.sendBatchStream(t),"Successfully sent batch to forwarder: "+d}enrichCommerceEventTypes(e){if(!e.events)return e;for(const t of e.events){if(t.event_type!=="commerce_event")continue;const{data:i}=t;if(!i)continue;const r=i.custom_flags?.["Rokt.CommerceEventType"];r&&A(i.product_action)&&(i.product_action.action=r)}return e}sendBatchStream(e){if(window.Rokt&&typeof window.Rokt.__batch_stream__=="function"){if(this.batchStreamQueue.length){const t=this.batchStreamQueue;this.batchStreamQueue=[];for(let i=0;i<t.length;i++)window.Rokt.__batch_stream__(t[i])}window.Rokt.__batch_stream__(e)}else this.batchStreamQueue.push(e)}setRoktSessionId(e){if(!(!e||typeof e!="string"))try{const t=a().getInstance();t&&typeof t.setIntegrationAttribute=="function"&&t.setIntegrationAttribute(R,{roktSessionId:e})}catch{}}attachLauncher(e,t,i=[]){const r=a()&&a().sessionManager&&typeof a().sessionManager.getSession=="function"?a().sessionManager.getSession():void 0,s={accountId:e,...t||{},...r?{mpSessionId:r}:{}};let o;this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(s)):o=window.Rokt.createLauncher(s),o.then(async c=>{await ce(i,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}initRoktLauncher(e){window.Rokt&&(window.Rokt.currentLauncher=e),this.launcher=e;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,W(this.domain,this.integrationName),a().Rokt.attachKit(this),this.drainBatchQueue()}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)}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,i,r,s){const o=e,c=o.accountId;this.userAttributes=k(s),this._onboardingExpProvider=o.onboardingExpProvider;const l=w(o.placementEventMapping);this.placementEventMappingLookup=j(l);const u=w(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=H(u),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase()),this._workspaceIdSyncApiKey=p(o.workspaceIdSyncApiKey)?o.workspaceIdSyncApiKey:void 0;const _=a().Rokt?.domain,{roktExtensionsQueryParams:C,legacyRoktExtensions:b,loadThankYouElement:L}=F(o.roktExtensions),g={...a().Rokt?.launcherOptions||{}};this.integrationName=ue(g.integrationName),g.integrationName=this.integrationName,this.domain=_;const y={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,isLoggingEnabled:a().config?.isLoggingEnabled===!0},I=new B(y,this.integrationName,window.__rokt_li_guid__,o.accountId),T=new V(y,I,this.integrationName,window.__rokt_li_guid__,o.accountId);return this.errorReportingService=I,this.loggingService=T,a()._registerErrorReportingService&&a()._registerErrorReportingService(I),a()._registerLoggingService&&a()._registerLoggingService(T),i?(this.testHelpers={generateLauncherScript:K,generateThankYouElementScript:D,extractRoktExtensionConfig:F,hashEventMessage:G,parseSettingsString:w,generateMappedEventLookup:j,generateMappedEventAttributeLookup:H,sendAdBlockMeasurementSignals:W,createAutoRemovedIframe:P,djb2:z,setAllowedOriginHashes:f=>{h._allowedOriginHashes=f},ReportingTransport:U,ErrorReportingService:B,LoggingService:V,RateLimiter:Q,ErrorCodes:N,WSDKErrorSeverity:v},this.attachLauncher(c,g),"Successfully initialized: "+d):(L&&(a().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),x(ie,D(_),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:f=>{console.error("Error loading Rokt Thank You Element script:",f)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,g,b):(x(te,K(_,C),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,g,b):console.error("Rokt object is not available after script load.")},onError:f=>{console.error("Error loading Rokt launcher script:",f)}}),this.captureTiming(h.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+d)}process(e){if(!this.isKitReady())return"Kit not ready for forwarder: "+d;if(typeof a().Rokt?.setLocalSessionAttribute=="function"&&(E(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(e),!E(this.placementEventMappingLookup))){const t=G(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 M(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,i){const r=e;return this.userAttributes=k(e.getAllUserAttributes()),this.pendingIdentityEvents.push(this.buildIdentityEvent(t,r)),"Successfully called "+i+" for forwarder: "+d}onUserIdentified(e){const t=e;return this.filters.filteredUser=t,this._workspaceSearchInFlightPromise=this.search(t),this.handleIdentityComplete(e,S.IDENTIFY,"onUserIdentified")}search(e){const t=this._workspaceIdSyncApiKey;if(!t)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const i=a().Identity?.search;if(typeof i!="function")return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const r=e.getUserIdentities?e.getUserIdentities().userIdentities:null,s={};if(r)for(const l of Object.keys(r)){const u=r[l];p(u)&&u.length>0&&(s[l]=u)}const o=Object.keys(s);if(o.length===0)return this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=void 0,Promise.resolve();const c=o.sort().map(l=>`${l}=${s[l]}`).join("&");return c===this._workspaceLastSearchedIdentitiesKey?this._workspaceSearchInFlightPromise||Promise.resolve():(this.userIdentifiedInWorkspace=!1,this._workspaceLastSearchedIdentitiesKey=c,new Promise(l=>{try{i(t,s,u=>{u?.httpCode===200&&(this.userIdentifiedInWorkspace=!0),l()})}catch(u){console.error("Rokt Kit: Workspace IDSync search failed",u),this._workspaceLastSearchedIdentitiesKey=void 0,l()}}))}onLoginComplete(e,t){return this.handleIdentityComplete(e,S.LOGIN,"onLoginComplete")}onLogoutComplete(e,t){return this.userIdentifiedInWorkspace=!1,this._workspaceSearchInFlightPromise=null,this._workspaceLastSearchedIdentitiesKey=void 0,this.handleIdentityComplete(e,S.LOGOUT,"onLogoutComplete")}onModifyComplete(e,t){return this.handleIdentityComplete(e,S.MODIFY_USER,"onModifyComplete")}selectPlacements(e){if(this._workspaceSearchInFlightPromise){const t=this._workspaceSearchInFlightPromise;return Promise.race([t,new Promise(i=>setTimeout(i,re))]).then(()=>this._dispatchPlacements(e))}return this._dispatchPlacements(e)}_dispatchPlacements(e){const t=e&&e.attributes||{},r={...k(this.userAttributes),...t},s=this.filters||{},o=s.userAttributeFilters||[],c=s.filteredUser||null,l=c?c.getMPID():null;let u;s?s.filterUserAttributes?u=s.filterUserAttributes(r,o):u=r:(console.warn("Rokt Kit: No filters available, using user attributes"),u=r),this.userAttributes=k(u);const _=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},C=this.returnUserIdentities(c),b=this.returnLocalSessionAttributes(),L={...C,...u,..._,...b,...this.userIdentifiedInWorkspace?{[ne]:!0}:{},mpid:l},g={...e,attributes:L},y=this.launcher.selectPlacements(g),I=()=>this.logSelectPlacementsEvent(L);return Promise.resolve(y).then(T=>T?.context?.sessionId?.then(f=>this.setRoktSessionId(f))).catch(()=>{}).finally(I),y}hashAttributes(e){return this.isKitReady()?this.launcher.hashAttributes(e):(console.error("Rokt Kit: Not initialized"),null)}use(e){return this.isKitReady()?!e||!p(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")))}onShoppableAdsReady(e){this._isThankYouElementLoaded?e():this._thankYouElementOnLoadCallback=e}};h._allowedOriginHashes=[-553112570,549508659],h.PERFORMANCE_MARKS={RoktScriptAppended:"mp:RoktScriptAppended"},h.EMAIL_SHA256_KEY="emailsha256";let m=h;function pe(){return R}function ge(n){if(!n){window.console.log("You must pass a config object to register the kit "+d);return}if(!A(n)){window.console.log("'config' must be an object. You passed in a "+typeof n);return}A(n.kits)?n.kits[d]={constructor:m}:(n.kits={},n.kits[d]={constructor:m}),window.console.log("Successfully registered "+d+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&a().addForwarder&&a().addForwarder({name:d,constructor:m,getId:pe}),O.register=ge,Object.defineProperty(O,Symbol.toStringTag,{value:"Module"}),O})({});
2
2
  //# sourceMappingURL=Rokt-Kit.iife.js.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-rokt-kit",
3
- "version": "1.26.2",
3
+ "version": "1.27.0",
4
4
  "description": "mParticle integration kit for Rokt",
5
5
  "main": "dist/Rokt-Kit.common.js",
6
6
  "module": "dist/Rokt-Kit.esm.js",