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