@mparticle/web-rokt-kit 1.25.0 → 1.25.1

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 u="Rokt",w=181,B="selectPlacements",V="apps.roktecommerce.com",W=.1,b={LOGIN:"login",LOGOUT:"logout",MODIFY_USER:"modify_user",IDENTIFY:"identify"},q="ThankYouPageJourney",J="rokt-launcher",X="rokt-thank-you-element",N={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST"},v={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"},Z="apps.rokt-api.com/v1/log",$="apps.rokt-api.com/v1/errors",tt=10;function s(){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 I(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?I(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(q)):e.push(o)}return{roktExtensionsQueryParams:e,legacyRoktExtensions:n,loadThankYouElement:r}}async function et(i,t){const e=[];if(t)for(const n of i)e.push(t.use(n));return Promise.all(e)}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 D(i){const t={};if(!Array.isArray(i))return t;for(let e=0;e<i.length;e++){const n=i[e];if(!n||!y(n.value)||!y(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 Y(i,t,e){return s().generateHash([i,t,e].join(""))}function R(i){return i==null?!0:typeof i=="object"?Object.keys(i).length===0:Array.isArray(i)?i.length===0:!1}function y(i){return typeof i=="string"}function nt(i){let n="mParticle_wsdkv_"+s().getVersion()+"_kitv_"+"1.25.1";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 T(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 j(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 a=window.location.href.split("?")[0].split("#")[0],o="version="+encodeURIComponent(t??"")+"&launcherInstanceGuid="+encodeURIComponent(r)+"&pageUrl="+encodeURIComponent(a);T("https://"+(i||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+o),T("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,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 Q,this._isEnabled=rt()||it()&&o}send(t,e,n,r,a,o){if(!(!this._isEnabled||this._rateLimiter.incrementAndCheck(e)))try{const c={additionalInformation:{message:n,version:this._integrationName},severity:e,code:r||N.UNKNOWN_ERROR,url:ot(),deviceInfo:st(),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(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 H{constructor(t,e,n,r,a){this._transport=new U(t,e,n,r,a),this._errorUrl="https://"+(t?.errorUrl||$)}report(t){if(!t)return;const e=t.severity||v.ERROR;this._transport.send(this._errorUrl,e,t.message,t.code,t.stackTrace)}}class F{constructor(t,e,n,r,a,o){this._transport=new U(t,n,r,a,o),this._loggingUrl="https://"+(t?.loggingUrl||Z),this._errorReportingService=e}log(t){t&&this._transport.send(this._loggingUrl,v.INFO,t.message,t.code,void 0,e=>{this._errorReportingService&&this._errorReportingService.report({message:"LoggingService: Failed to send log: "+e.message,code:N.UNKNOWN_ERROR,severity:v.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,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1}getEventAttributeValue(t,e){const n=t&&t.EventAttributes;return!n||typeof n[e]>"u"?null:n[e]}doesEventAttributeConditionMatch(t,e){if(!t||!y(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||!y(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(R(a))continue;let o=!0;for(let c=0;c<a.length;c++)if(!this.doesEventMatchRule(t,a[c])){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"?{}:R(this.placementEventMappingLookup)&&R(this.placementEventAttributeMappingLookup)?{}:s().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 s().logEvent!="function"||!O(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: "+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=s().getInstance();e&&typeof e.setIntegrationAttribute=="function"&&e.setIntegrationAttribute(w,{roktSessionId:t})}catch{}}attachLauncher(t,e,n=[]){const r=s()&&s().sessionManager&&typeof s().sessionManager.getSession=="function"?s().sessionManager.getSession():void 0,a={accountId:t,...e||{},...r?{mpSessionId:r}:{}};let o;this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(a)):o=window.Rokt.createLauncher(a),o.then(async c=>{await et(n,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}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,j(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,c=o.accountId;this.userAttributes=a||{},this._onboardingExpProvider=o.onboardingExpProvider;const l=I(o.placementEventMapping);this.placementEventMappingLookup=x(l);const p=I(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=D(p),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase());const f=s().Rokt?.domain,{roktExtensionsQueryParams:L,legacyRoktExtensions:m,loadThankYouElement:S}=K(o.roktExtensions),d={...s().Rokt?.launcherOptions||{}};this.integrationName=nt(d.integrationName),d.integrationName=this.integrationName,this.domain=f;const k={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,isLoggingEnabled:o.isLoggingEnabled==="true"||o.isLoggingEnabled===!0},E=new H(k,this.integrationName,window.__rokt_li_guid__,o.accountId),A=new F(k,E,this.integrationName,window.__rokt_li_guid__,o.accountId);return this.errorReportingService=E,this.loggingService=A,s()._registerErrorReportingService&&s()._registerErrorReportingService(E),s()._registerLoggingService&&s()._registerLoggingService(A),n?(this.testHelpers={generateLauncherScript:M,generateThankYouElementScript:C,extractRoktExtensionConfig:K,hashEventMessage:Y,parseSettingsString:I,generateMappedEventLookup:x,generateMappedEventAttributeLookup:D,sendAdBlockMeasurementSignals:j,createAutoRemovedIframe:T,djb2:z,setAllowedOriginHashes:_=>{h._allowedOriginHashes=_},ReportingTransport:U,ErrorReportingService:H,LoggingService:F,RateLimiter:Q,ErrorCodes:N,WSDKErrorSeverity:v},this.attachLauncher(c,d),"Successfully initialized: "+u):(S&&(s().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),P(X,C(f),{onLoad:()=>{this._isThankYouElementLoaded=!0,this._thankYouElementOnLoadCallback&&this._thankYouElementOnLoadCallback()},onError:_=>{console.error("Error loading Rokt Thank You Element script:",_)}})),this.isLauncherReadyToAttach()?this.attachLauncher(c,d,m):(P(J,M(f,L),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,d,m):console.error("Rokt object is not available after script load.")},onError:_=>{console.error("Error loading Rokt launcher script:",_)}}),this.captureTiming(h.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+u)}process(t){if(!this.isKitReady())return"Kit not ready for forwarder: "+u;if(typeof s().Rokt?.setLocalSessionAttribute=="function"&&(R(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(t),!R(this.placementEventMappingLookup))){const e=Y(t.EventDataType,t.EventCategory,t.EventName??"");this.placementEventMappingLookup[String(e)]&&s().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,b.IDENTIFY,"onUserIdentified")}onLoginComplete(t,e){return this.handleIdentityComplete(t,b.LOGIN,"onLoginComplete")}onLogoutComplete(t,e){return this.handleIdentityComplete(t,b.LOGOUT,"onLogoutComplete")}onModifyComplete(t,e){return this.handleIdentityComplete(t,b.MODIFY_USER,"onModifyComplete")}selectPlacements(t){const e=t&&t.attributes||{},n={...this.userAttributes,...e},r=this.filters||{},a=r.userAttributeFilters||[],o=r.filteredUser||null,c=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 p=this._onboardingExpProvider==="Optimizely"?this.fetchOptimizely():{},f=this.returnUserIdentities(o),L=this.returnLocalSessionAttributes(),m={...f,...l,...p,...L,mpid:c},S={...t,attributes:m},d=this.launcher.selectPlacements(S),k=()=>this.logSelectPlacementsEvent(m);return Promise.resolve(d).then(E=>E?.context?.sessionId?.then(A=>this.setRoktSessionId(A))).catch(()=>{}).finally(k),d}hashAttributes(t){return this.isKitReady()?this.launcher.hashAttributes(t):(console.error("Rokt Kit: Not initialized"),null)}use(t){return this.isKitReady()?!t||!y(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")))}onShoppableAdsReady(t){this._isThankYouElementLoaded?t():this._thankYouElementOnLoadCallback=t}};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&&s().addForwarder&&s().addForwarder({name:u,constructor:g,getId:at});exports.register=ct;
2
2
  //# sourceMappingURL=Rokt-Kit.common.js.map
@@ -1,11 +1,11 @@
1
1
  const u = "Rokt";
2
2
  const Q = "selectPlacements", B = "apps.roktecommerce.com";
3
- const k = {
3
+ const I = {
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
+ }, V = "ThankYouPageJourney", W = "rokt-launcher", q = "rokt-thank-you-element", N = {
9
9
  UNKNOWN_ERROR: "UNKNOWN_ERROR",
10
10
  UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION",
11
11
  IDENTITY_REQUEST: "IDENTITY_REQUEST"
@@ -14,17 +14,17 @@ const k = {
14
14
  INFO: "INFO",
15
15
  WARNING: "WARNING"
16
16
  }, J = "apps.rokt-api.com/v1/log", X = "apps.rokt-api.com/v1/errors", Z = 10;
17
- function a() {
17
+ function s() {
18
18
  return window.mParticle;
19
19
  }
20
20
  function U(i, t) {
21
- const n = [Y(i), "/wsdk/integrations/launcher.js"].join("");
21
+ const n = [H(i), "/wsdk/integrations/launcher.js"].join("");
22
22
  return !t || t.length === 0 ? n : n + "?extensions=" + t.join(",");
23
23
  }
24
24
  function M(i) {
25
- return [Y(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
25
+ return [H(i), "/rokt-elements/rokt-element-thank-you.js"].join("");
26
26
  }
27
- function Y(i) {
27
+ function H(i) {
28
28
  return ["https://", typeof i < "u" ? i : "apps.rokt-api.com"].join("");
29
29
  }
30
30
  function C(i, t, e) {
@@ -35,7 +35,7 @@ function C(i, t, e) {
35
35
  function S(i) {
36
36
  return i != null && typeof i == "object" && Array.isArray(i) === !1;
37
37
  }
38
- function A(i) {
38
+ function b(i) {
39
39
  if (!i)
40
40
  return [];
41
41
  try {
@@ -46,10 +46,10 @@ function A(i) {
46
46
  return [];
47
47
  }
48
48
  function P(i) {
49
- const t = i ? A(i) : [], e = [], n = [];
49
+ const t = i ? b(i) : [], e = [], n = [];
50
50
  let r = !1;
51
- for (let s = 0; s < t.length; s++) {
52
- const o = t[s].value;
51
+ for (let a = 0; a < t.length; a++) {
52
+ const o = t[a].value;
53
53
  o === "thank-you-journey" ? (r = !0, n.push(V)) : e.push(o);
54
54
  }
55
55
  return {
@@ -58,9 +58,12 @@ function P(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 $(i, t) {
62
+ const e = [];
63
+ if (t)
64
+ for (const n of i)
65
+ e.push(t.use(n));
66
+ return Promise.all(e);
64
67
  }
65
68
  function K(i) {
66
69
  if (!i)
@@ -78,27 +81,27 @@ function x(i) {
78
81
  return t;
79
82
  for (let e = 0; e < i.length; e++) {
80
83
  const n = i[e];
81
- if (!n || !_(n.value) || !_(n.map))
84
+ if (!n || !y(n.value) || !y(n.map))
82
85
  continue;
83
- const r = n.value, s = n.map;
86
+ const r = n.value, a = n.map;
84
87
  t[r] || (t[r] = []), t[r].push({
85
- eventAttributeKey: s,
88
+ eventAttributeKey: a,
86
89
  conditions: Array.isArray(n.conditions) ? n.conditions : []
87
90
  });
88
91
  }
89
92
  return t;
90
93
  }
91
94
  function D(i, t, e) {
92
- return a().generateHash([i, t, e].join(""));
95
+ return s().generateHash([i, t, e].join(""));
93
96
  }
94
- function E(i) {
97
+ function R(i) {
95
98
  return i == null ? !0 : typeof i == "object" ? Object.keys(i).length === 0 : Array.isArray(i) ? i.length === 0 : !1;
96
99
  }
97
- function _(i) {
100
+ function y(i) {
98
101
  return typeof i == "string";
99
102
  }
100
103
  function tt(i) {
101
- let n = "mParticle_wsdkv_" + a().getVersion() + "_kitv_" + "1.25.0";
104
+ let n = "mParticle_wsdkv_" + s().getVersion() + "_kitv_" + "1.25.1";
102
105
  return i && (n += "_" + i), n;
103
106
  }
104
107
  function F(i) {
@@ -107,7 +110,7 @@ function F(i) {
107
110
  t = (t << 5) + t + i.charCodeAt(e), t = t & t;
108
111
  return t;
109
112
  }
110
- function N(i) {
113
+ function O(i) {
111
114
  const t = document.createElement("iframe");
112
115
  t.style.display = "none", t.setAttribute("sandbox", "allow-scripts allow-same-origin"), t.src = i, t.onload = function() {
113
116
  t.onload = null, t.parentNode && t.parentNode.removeChild(t);
@@ -115,15 +118,15 @@ function N(i) {
115
118
  const e = document.body || document.head;
116
119
  e && e.appendChild(t);
117
120
  }
118
- function j(i, t) {
121
+ function Y(i, t) {
119
122
  const e = F(window.location.origin);
120
123
  if (g._allowedOriginHashes.indexOf(e) === -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(
128
+ const a = window.location.href.split("?")[0].split("#")[0], o = "version=" + encodeURIComponent(t ?? "") + "&launcherInstanceGuid=" + encodeURIComponent(r) + "&pageUrl=" + encodeURIComponent(a);
129
+ O("https://" + (i || "apps.rokt.com") + "/v1/wsdk-init/index.html?" + o), O(
127
130
  "https://" + B + "/v1/wsdk-init/index.html?" + o + "&isControl=true"
128
131
  );
129
132
  }
@@ -149,12 +152,12 @@ class z {
149
152
  }
150
153
  }
151
154
  class T {
152
- constructor(t, e, n, r, s) {
155
+ constructor(t, e, n, r, a) {
153
156
  this._reporter = "mp-wsdk";
154
157
  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;
158
+ this._integrationName = e || "", this._launcherInstanceGuid = n, this._accountId = r || null, this._rateLimiter = a || new z(), this._isEnabled = nt() || et() && o;
156
159
  }
157
- send(t, e, n, r, s, o) {
160
+ send(t, e, n, r, a, o) {
158
161
  if (!(!this._isEnabled || this._rateLimiter.incrementAndCheck(e)))
159
162
  try {
160
163
  const c = {
@@ -163,10 +166,10 @@ class T {
163
166
  version: this._integrationName
164
167
  },
165
168
  severity: e,
166
- code: r || O.UNKNOWN_ERROR,
169
+ code: r || N.UNKNOWN_ERROR,
167
170
  url: it(),
168
171
  deviceInfo: rt(),
169
- stackTrace: s,
172
+ stackTrace: a,
170
173
  reporter: this._reporter,
171
174
  integration: this._integrationName
172
175
  }, l = {
@@ -187,9 +190,9 @@ class T {
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 j {
194
+ constructor(t, e, n, r, a) {
195
+ this._transport = new T(t, e, n, r, a), this._errorUrl = "https://" + (t?.errorUrl || X);
193
196
  }
194
197
  report(t) {
195
198
  if (!t) return;
@@ -197,9 +200,9 @@ class G {
197
200
  this._transport.send(this._errorUrl, e, t.message, t.code, t.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 G {
204
+ constructor(t, e, n, r, a, o) {
205
+ this._transport = new T(t, n, r, a, o), this._loggingUrl = "https://" + (t?.loggingUrl || J), this._errorReportingService = e;
203
206
  }
204
207
  log(t) {
205
208
  t && this._transport.send(
@@ -211,7 +214,7 @@ class H {
211
214
  (e) => {
212
215
  this._errorReportingService && this._errorReportingService.report({
213
216
  message: "LoggingService: Failed to send log: " + e.message,
214
- code: O.UNKNOWN_ERROR,
217
+ code: N.UNKNOWN_ERROR,
215
218
  severity: w.ERROR
216
219
  });
217
220
  }
@@ -220,7 +223,7 @@ class H {
220
223
  }
221
224
  const h = class h {
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 = 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, this._thankYouElementOnLoadCallback = null, this._isThankYouElementLoaded = !1;
224
227
  }
225
228
  // ---- Private helpers ----
226
229
  getEventAttributeValue(t, e) {
@@ -228,13 +231,13 @@ const h = class h {
228
231
  return !n || typeof n[e] > "u" ? null : n[e];
229
232
  }
230
233
  doesEventAttributeConditionMatch(t, e) {
231
- if (!t || !_(t.operator))
234
+ if (!t || !y(t.operator))
232
235
  return !1;
233
236
  const n = t.operator.toLowerCase(), r = t.attributeValue;
234
237
  return n === "exists" ? e !== null : e == null ? !1 : n === "equals" ? String(e) === String(r) : n === "contains" ? String(e).indexOf(String(r)) !== -1 : !1;
235
238
  }
236
239
  doesEventMatchRule(t, e) {
237
- if (!e || !_(e.eventAttributeKey))
240
+ if (!e || !y(e.eventAttributeKey))
238
241
  return !1;
239
242
  const n = e.conditions;
240
243
  if (!Array.isArray(n))
@@ -242,24 +245,24 @@ const h = class h {
242
245
  const r = this.getEventAttributeValue(t, e.eventAttributeKey);
243
246
  if (n.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 a = 0; a < n.length; a++)
249
+ if (!this.doesEventAttributeConditionMatch(n[a], r))
247
250
  return !1;
248
251
  return !0;
249
252
  }
250
253
  applyPlacementEventAttributeMapping(t) {
251
254
  const e = Object.keys(this.placementEventAttributeMappingLookup);
252
255
  for (let n = 0; n < e.length; n++) {
253
- const r = e[n], s = this.placementEventAttributeMappingLookup[r];
254
- if (E(s))
256
+ const r = e[n], a = this.placementEventAttributeMappingLookup[r];
257
+ if (R(a))
255
258
  continue;
256
259
  let o = !0;
257
- for (let c = 0; c < s.length; c++)
258
- if (!this.doesEventMatchRule(t, s[c])) {
260
+ for (let c = 0; c < a.length; c++)
261
+ if (!this.doesEventMatchRule(t, a[c])) {
259
262
  o = !1;
260
263
  break;
261
264
  }
262
- o && a().Rokt.setLocalSessionAttribute?.(r, !0);
265
+ o && s().Rokt.setLocalSessionAttribute?.(r, !0);
263
266
  }
264
267
  }
265
268
  isLauncherReadyToAttach() {
@@ -275,20 +278,20 @@ const h = class h {
275
278
  return this.replaceOtherIdentityWithEmailsha256(e);
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 !s().Rokt || typeof s().Rokt.getLocalSessionAttributes != "function" ? {} : R(this.placementEventMappingLookup) && R(this.placementEventAttributeMappingLookup) ? {} : s().Rokt.getLocalSessionAttributes();
279
282
  }
280
283
  replaceOtherIdentityWithEmailsha256(t) {
281
284
  const e = { ...t || {} }, n = this._mappedEmailSha256Key;
282
285
  return n && t[n] && (e[h.EMAIL_SHA256_KEY] = t[n]), n && delete e[n], e;
283
286
  }
284
287
  logSelectPlacementsEvent(t) {
285
- if (!window.mParticle || typeof a().logEvent != "function" || !S(t))
288
+ if (!window.mParticle || typeof s().logEvent != "function" || !S(t))
286
289
  return;
287
- const e = a().EventType.Other;
288
- a().logEvent(Q, e, t);
290
+ const e = s().EventType.Other;
291
+ s().logEvent(Q, e, t);
289
292
  }
290
293
  buildIdentityEvent(t, e) {
291
- const n = e.getMPID(), r = a() && a().sessionManager && typeof a().sessionManager.getSession == "function" ? a().sessionManager.getSession() : void 0;
294
+ const n = e.getMPID(), r = s() && s().sessionManager && typeof s().sessionManager.getSession == "function" ? s().sessionManager.getSession() : void 0;
292
295
  return {
293
296
  event_type: t,
294
297
  data: {
@@ -330,38 +333,37 @@ const h = class h {
330
333
  setRoktSessionId(t) {
331
334
  if (!(!t || typeof t != "string"))
332
335
  try {
333
- const e = a().getInstance();
336
+ const e = s().getInstance();
334
337
  e && typeof e.setIntegrationAttribute == "function" && e.setIntegrationAttribute(181, {
335
338
  roktSessionId: t
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 = {
343
+ attachLauncher(t, e, n = []) {
344
+ const r = s() && s().sessionManager && typeof s().sessionManager.getSession == "function" ? s().sessionManager.getSession() : void 0, a = {
342
345
  accountId: t,
343
346
  ...e || {},
344
- ...n ? { mpSessionId: n } : {}
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 o;
350
+ this.isPartnerInLocalLauncherTestGroup() ? o = Promise.resolve(window.Rokt.createLocalLauncher(a)) : o = window.Rokt.createLauncher(a), o.then(async (c) => {
351
+ await $(n, c), this.initRoktLauncher(c);
352
+ }).catch((c) => {
353
+ console.error("Error creating Rokt launcher:", c);
354
+ });
353
355
  }
354
356
  initRoktLauncher(t) {
355
357
  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();
358
+ const e = s().Rokt?.filters;
359
+ 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();
358
360
  }
359
361
  fetchOptimizely() {
360
- const t = a()._getActiveForwarders().filter((e) => e.name === "Optimizely");
362
+ const t = s()._getActiveForwarders().filter((e) => e.name === "Optimizely");
361
363
  try {
362
364
  if (t.length > 0 && window.optimizely) {
363
365
  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), {});
366
+ return !e || !e.getActiveExperimentIds ? {} : e.getActiveExperimentIds().reduce((a, o) => (a["rokt.custom.optimizely.experiment." + o + ".variationId"] = e.getVariationMap()[o].id, a), {});
365
367
  }
366
368
  } catch (e) {
367
369
  console.error("Error fetching Optimizely attributes:", e);
@@ -372,84 +374,91 @@ const h = class h {
372
374
  return !!(this.isInitialized && this.launcher);
373
375
  }
374
376
  isPartnerInLocalLauncherTestGroup() {
375
- return !!(a().config && a().config.isLocalLauncherEnabled && this.isAssignedToSampleGroup());
377
+ return !!(s().config && s().config.isLocalLauncherEnabled && this.isAssignedToSampleGroup());
376
378
  }
377
379
  isAssignedToSampleGroup() {
378
380
  return Math.random() > 0.5;
379
381
  }
380
382
  captureTiming(t) {
381
- window && a() && a().captureTiming && t && a().captureTiming(t);
383
+ window && s() && s().captureTiming && t && s().captureTiming(t);
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) {
389
+ init(t, e, n, r, a) {
388
390
  const o = t, c = o.accountId;
389
- this.userAttributes = s || {}, this._onboardingExpProvider = o.onboardingExpProvider;
390
- const l = A(o.placementEventMapping);
391
+ this.userAttributes = a || {}, this._onboardingExpProvider = o.onboardingExpProvider;
392
+ const l = b(o.placementEventMapping);
391
393
  this.placementEventMappingLookup = K(l);
392
- const p = A(
394
+ const p = b(
393
395
  o.placementEventAttributeMapping
394
396
  );
395
397
  this.placementEventAttributeMappingLookup = x(p), o.hashedEmailUserIdentityType && (this._mappedEmailSha256Key = o.hashedEmailUserIdentityType.toLowerCase());
396
- const f = a().Rokt?.domain, { roktExtensionsQueryParams: b, legacyRoktExtensions: R, loadThankYouElement: v } = P(
398
+ const f = s().Rokt?.domain, { roktExtensionsQueryParams: v, legacyRoktExtensions: m, loadThankYouElement: L } = P(
397
399
  o.roktExtensions
398
400
  ), d = {
399
- ...a().Rokt?.launcherOptions || {}
401
+ ...s().Rokt?.launcherOptions || {}
400
402
  };
401
403
  this.integrationName = tt(d.integrationName), d.integrationName = this.integrationName, this.domain = f;
402
- const y = {
404
+ const k = {
403
405
  loggingUrl: o.loggingUrl,
404
406
  errorUrl: o.errorUrl,
405
407
  isLoggingEnabled: o.isLoggingEnabled === "true" || o.isLoggingEnabled === !0
406
- }, m = new G(
407
- y,
408
+ }, E = new j(
409
+ k,
408
410
  this.integrationName,
409
411
  window.__rokt_li_guid__,
410
412
  o.accountId
411
- ), I = new H(
412
- y,
413
- m,
413
+ ), A = new G(
414
+ k,
415
+ E,
414
416
  this.integrationName,
415
417
  window.__rokt_li_guid__,
416
418
  o.accountId
417
419
  );
418
- return this.errorReportingService = m, this.loggingService = I, a()._registerErrorReportingService && a()._registerErrorReportingService(m), a()._registerLoggingService && a()._registerLoggingService(I), n ? (this.testHelpers = {
420
+ return this.errorReportingService = E, this.loggingService = A, s()._registerErrorReportingService && s()._registerErrorReportingService(E), s()._registerLoggingService && s()._registerLoggingService(A), n ? (this.testHelpers = {
419
421
  generateLauncherScript: U,
420
422
  generateThankYouElementScript: M,
421
423
  extractRoktExtensionConfig: P,
422
424
  hashEventMessage: D,
423
- parseSettingsString: A,
425
+ parseSettingsString: b,
424
426
  generateMappedEventLookup: K,
425
427
  generateMappedEventAttributeLookup: x,
426
- sendAdBlockMeasurementSignals: j,
427
- createAutoRemovedIframe: N,
428
+ sendAdBlockMeasurementSignals: Y,
429
+ createAutoRemovedIframe: O,
428
430
  djb2: F,
429
- setAllowedOriginHashes: (L) => {
430
- h._allowedOriginHashes = L;
431
+ setAllowedOriginHashes: (_) => {
432
+ h._allowedOriginHashes = _;
431
433
  },
432
434
  ReportingTransport: T,
433
- ErrorReportingService: G,
434
- LoggingService: H,
435
+ ErrorReportingService: j,
436
+ LoggingService: G,
435
437
  RateLimiter: z,
436
- ErrorCodes: O,
438
+ ErrorCodes: N,
437
439
  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), {
440
+ }, this.attachLauncher(c, d), "Successfully initialized: " + u) : (L && (s().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this), C(q, M(f), {
441
+ onLoad: () => {
442
+ this._isThankYouElementLoaded = !0, this._thankYouElementOnLoadCallback && this._thankYouElementOnLoadCallback();
443
+ },
444
+ onError: (_) => {
445
+ console.error("Error loading Rokt Thank You Element script:", _);
446
+ }
447
+ })), this.isLauncherReadyToAttach() ? this.attachLauncher(c, d, m) : (C(W, U(f, 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, d, m) : 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: (_) => {
452
+ console.error("Error loading Rokt launcher script:", _);
444
453
  }
445
454
  }), this.captureTiming(h.PERFORMANCE_MARKS.RoktScriptAppended)), "Successfully initialized: " + u);
446
455
  }
447
456
  process(t) {
448
457
  if (!this.isKitReady())
449
458
  return "Kit not ready for forwarder: " + u;
450
- if (typeof a().Rokt?.setLocalSessionAttribute == "function" && (E(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(t), !E(this.placementEventMappingLookup))) {
459
+ if (typeof s().Rokt?.setLocalSessionAttribute == "function" && (R(this.placementEventAttributeMappingLookup) || this.applyPlacementEventAttributeMapping(t), !R(this.placementEventMappingLookup))) {
451
460
  const e = D(t.EventDataType, t.EventCategory, t.EventName ?? "");
452
- this.placementEventMappingLookup[String(e)] && a().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(e)], !0);
461
+ this.placementEventMappingLookup[String(e)] && s().Rokt.setLocalSessionAttribute?.(this.placementEventMappingLookup[String(e)], !0);
453
462
  }
454
463
  return "Successfully sent to forwarder: " + u;
455
464
  }
@@ -471,33 +480,33 @@ const h = class h {
471
480
  return this.userAttributes = t.getAllUserAttributes(), this.pendingIdentityEvents.push(this.buildIdentityEvent(e, r)), "Successfully called " + n + " for forwarder: " + u;
472
481
  }
473
482
  onUserIdentified(t) {
474
- return this.filters.filteredUser = t, this.handleIdentityComplete(t, k.IDENTIFY, "onUserIdentified");
483
+ return this.filters.filteredUser = t, this.handleIdentityComplete(t, I.IDENTIFY, "onUserIdentified");
475
484
  }
476
485
  onLoginComplete(t, e) {
477
- return this.handleIdentityComplete(t, k.LOGIN, "onLoginComplete");
486
+ return this.handleIdentityComplete(t, I.LOGIN, "onLoginComplete");
478
487
  }
479
488
  onLogoutComplete(t, e) {
480
- return this.handleIdentityComplete(t, k.LOGOUT, "onLogoutComplete");
489
+ return this.handleIdentityComplete(t, I.LOGOUT, "onLogoutComplete");
481
490
  }
482
491
  onModifyComplete(t, e) {
483
- return this.handleIdentityComplete(t, k.MODIFY_USER, "onModifyComplete");
492
+ return this.handleIdentityComplete(t, I.MODIFY_USER, "onModifyComplete");
484
493
  }
485
494
  /**
486
495
  * Selects placements for Rokt Web SDK with merged attributes, filters, and experimentation options.
487
496
  */
488
497
  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;
498
+ const e = t && t.attributes || {}, n = { ...this.userAttributes, ...e }, r = this.filters || {}, a = r.userAttributeFilters || [], o = r.filteredUser || null, c = o ? o.getMPID() : null;
490
499
  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 = {
500
+ 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;
501
+ const p = this._onboardingExpProvider === "Optimizely" ? this.fetchOptimizely() : {}, f = this.returnUserIdentities(o), v = this.returnLocalSessionAttributes(), m = {
493
502
  ...f,
494
503
  ...l,
495
504
  ...p,
496
- ...b,
505
+ ...v,
497
506
  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;
507
+ }, L = { ...t, attributes: m }, d = this.launcher.selectPlacements(L), k = () => this.logSelectPlacementsEvent(m);
508
+ return Promise.resolve(d).then((E) => E?.context?.sessionId?.then((A) => this.setRoktSessionId(A))).catch(() => {
509
+ }).finally(k), d;
501
510
  }
502
511
  /**
503
512
  * Passes attributes to the Rokt Web SDK for client-side hashing.
@@ -511,7 +520,13 @@ const h = class h {
511
520
  * @deprecated This functionality has been internalized and will be removed in a future release.
512
521
  */
513
522
  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")));
523
+ return this.isKitReady() ? !t || !y(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")));
524
+ }
525
+ /**
526
+ * Registers a callback to be invoked once rokt-thank-you-element.js becomes available.
527
+ */
528
+ onShoppableAdsReady(t) {
529
+ this._isThankYouElementLoaded ? t() : this._thankYouElementOnLoadCallback = t;
515
530
  }
516
531
  };
517
532
  h._allowedOriginHashes = [-553112570, 549508659], h.PERFORMANCE_MARKS = {
@@ -536,7 +551,7 @@ function st(i) {
536
551
  constructor: g
537
552
  }), window.console.log("Successfully registered " + u + " to your mParticle configuration");
538
553
  }
539
- typeof window < "u" && window.mParticle && a().addForwarder && a().addForwarder({
554
+ typeof window < "u" && window.mParticle && s().addForwarder && s().addForwarder({
540
555
  name: u,
541
556
  constructor: g,
542
557
  getId: ot
@@ -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 u="Rokt",B="selectPlacements",V="apps.roktecommerce.com",k={LOGIN:"login",LOGOUT:"logout",MODIFY_USER:"modify_user",IDENTIFY:"identify"},W="ThankYouPageJourney",q="rokt-launcher",J="rokt-thank-you-element",L={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST"},A={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 I(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?I(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}}async function tt(i,t){const e=[];if(t)for(const n of i)e.push(t.use(n));return Promise.all(e)}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 Y(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 j(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.1";return i&&(n+="_"+i),n}function G(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 O(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=G(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);O("https://"+(i||"apps.rokt.com")+"/v1/wsdk-init/index.html?"+o),O("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 T{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 c={additionalInformation:{message:n,version:this._integrationName},severity:e,code:r||L.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(c)}).catch(g=>{console.error("ReportingTransport: Failed to send log",g),o&&o(g)})}catch(c){console.error("ReportingTransport: Failed to send log",c),o&&o(c)}}}class z{constructor(t,e,n,r,a){this._transport=new T(t,e,n,r,a),this._errorUrl="https://"+(t?.errorUrl||Z)}report(t){if(!t)return;const e=t.severity||A.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 T(t,n,r,a,o),this._loggingUrl="https://"+(t?.loggingUrl||X),this._errorReportingService=e}log(t){t&&this._transport.send(this._loggingUrl,A.INFO,t.message,t.code,void 0,e=>{this._errorReportingService&&this._errorReportingService.report({message:"LoggingService: Failed to send log: "+e.message,code:L.UNKNOWN_ERROR,severity:A.ERROR})})}}const d=class d{constructor(){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,this._thankYouElementOnLoadCallback=null,this._isThankYouElementLoaded=!1}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 c=0;c<a.length;c++)if(!this.doesEventMatchRule(t,a[c])){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: "+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=s().getInstance();e&&typeof e.setIntegrationAttribute=="function"&&e.setIntegrationAttribute(181,{roktSessionId:t})}catch{}}attachLauncher(t,e,n=[]){const r=s()&&s().sessionManager&&typeof s().sessionManager.getSession=="function"?s().sessionManager.getSession():void 0,a={accountId:t,...e||{},...r?{mpSessionId:r}:{}};let o;this.isPartnerInLocalLauncherTestGroup()?o=Promise.resolve(window.Rokt.createLocalLauncher(a)):o=window.Rokt.createLauncher(a),o.then(async c=>{await tt(n,c),this.initRoktLauncher(c)}).catch(c=>{console.error("Error creating Rokt launcher:",c)})}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,H(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,c=o.accountId;this.userAttributes=a||{},this._onboardingExpProvider=o.onboardingExpProvider;const l=I(o.placementEventMapping);this.placementEventMappingLookup=x(l);const g=I(o.placementEventAttributeMapping);this.placementEventAttributeMappingLookup=Y(g),o.hashedEmailUserIdentityType&&(this._mappedEmailSha256Key=o.hashedEmailUserIdentityType.toLowerCase());const E=s().Rokt?.domain,{roktExtensionsQueryParams:N,legacyRoktExtensions:_,loadThankYouElement:U}=D(o.roktExtensions),h={...s().Rokt?.launcherOptions||{}};this.integrationName=et(h.integrationName),h.integrationName=this.integrationName,this.domain=E;const b={loggingUrl:o.loggingUrl,errorUrl:o.errorUrl,isLoggingEnabled:o.isLoggingEnabled==="true"||o.isLoggingEnabled===!0},R=new z(b,this.integrationName,window.__rokt_li_guid__,o.accountId),w=new Q(b,R,this.integrationName,window.__rokt_li_guid__,o.accountId);return this.errorReportingService=R,this.loggingService=w,s()._registerErrorReportingService&&s()._registerErrorReportingService(R),s()._registerLoggingService&&s()._registerLoggingService(w),n?(this.testHelpers={generateLauncherScript:M,generateThankYouElementScript:P,extractRoktExtensionConfig:D,hashEventMessage:j,parseSettingsString:I,generateMappedEventLookup:x,generateMappedEventAttributeLookup:Y,sendAdBlockMeasurementSignals:H,createAutoRemovedIframe:O,djb2:G,setAllowedOriginHashes:y=>{d._allowedOriginHashes=y},ReportingTransport:T,ErrorReportingService:z,LoggingService:Q,RateLimiter:F,ErrorCodes:L,WSDKErrorSeverity:A},this.attachLauncher(c,h),"Successfully initialized: "+u):(U&&(s().Rokt.flushOnShoppableAdsReadyMessageQueue?.(this),K(J,P(E),{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,_):(K(q,M(E,N),{onLoad:()=>{this.isLauncherReadyToAttach()?this.attachLauncher(c,h,_):console.error("Rokt object is not available after script load.")},onError:y=>{console.error("Error loading Rokt launcher script:",y)}}),this.captureTiming(d.PERFORMANCE_MARKS.RoktScriptAppended)),"Successfully initialized: "+u)}process(t){if(!this.isKitReady())return"Kit not ready for forwarder: "+u;if(typeof s().Rokt?.setLocalSessionAttribute=="function"&&(f(this.placementEventAttributeMappingLookup)||this.applyPlacementEventAttributeMapping(t),!f(this.placementEventMappingLookup))){const e=j(t.EventDataType,t.EventCategory,t.EventName??"");this.placementEventMappingLookup[String(e)]&&s().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,k.IDENTIFY,"onUserIdentified")}onLoginComplete(t,e){return this.handleIdentityComplete(t,k.LOGIN,"onLoginComplete")}onLogoutComplete(t,e){return this.handleIdentityComplete(t,k.LOGOUT,"onLogoutComplete")}onModifyComplete(t,e){return this.handleIdentityComplete(t,k.MODIFY_USER,"onModifyComplete")}selectPlacements(t){const e=t&&t.attributes||{},n={...this.userAttributes,...e},r=this.filters||{},a=r.userAttributeFilters||[],o=r.filteredUser||null,c=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),N=this.returnLocalSessionAttributes(),_={...E,...l,...g,...N,mpid:c},U={...t,attributes:_},h=this.launcher.selectPlacements(U),b=()=>this.logSelectPlacementsEvent(_);return Promise.resolve(h).then(R=>R?.context?.sessionId?.then(w=>this.setRoktSessionId(w))).catch(()=>{}).finally(b),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")))}onShoppableAdsReady(t){this._isThankYouElementLoaded?t():this._thankYouElementOnLoadCallback=t}};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 "+u);return}if(!S(i)){window.console.log("'config' must be an object. You passed in a "+typeof i);return}S(i.kits)?i.kits[u]={constructor:p}:(i.kits={},i.kits[u]={constructor:p}),window.console.log("Successfully registered "+u+" to your mParticle configuration")}return typeof window<"u"&&window.mParticle&&s().addForwarder&&s().addForwarder({name:u,constructor:p,getId:st}),v.register=at,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.25.1",
4
4
  "description": "mParticle integration kit for Rokt",
5
5
  "main": "dist/Rokt-Kit.common.js",
6
6
  "module": "dist/Rokt-Kit.esm.js",