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