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