@mparticle/web-sdk 2.72.0 → 2.73.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.
- package/dist/mparticle.common.js +18 -10
- package/dist/mparticle.esm.js +18 -10
- package/dist/mparticle.js +31 -15
- package/dist/types/src/reporting/types.d.ts +0 -1
- package/dist/types/src/roktManager.d.ts +3 -1
- package/package.json +1 -1
- package/src/mp-instance.ts +2 -1
- package/src/pre-init-utils.ts +13 -1
- package/src/reporting/types.ts +0 -1
- package/src/roktManager.ts +17 -6
package/dist/mparticle.common.js
CHANGED
|
@@ -15,7 +15,7 @@ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is nul
|
|
|
15
15
|
filter:function filter(a/*, thisArg*/){if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g);}return d},// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
|
16
16
|
isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1};
|
|
17
17
|
|
|
18
|
-
var version = "2.
|
|
18
|
+
var version = "2.73.0";
|
|
19
19
|
|
|
20
20
|
var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"is a deprecated method and will be removed in future releases.",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",AddToCart:"addToCart",RemoveFromCart:"removeFromCart",ClearCart:"clearCart",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",localStorageProductsV4:"mprtcl-prodv4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4",currentStorageProductsName:"mprtcl-prodv4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,maxProducts:20,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
|
|
21
21
|
},DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},// These are the paths that are used to construct the CNAME urls
|
|
@@ -518,7 +518,7 @@ this.mpInstance.Logger.warning("Offline batch storage is over quota. Retaining b
|
|
|
518
518
|
return this.mpInstance.Logger.error("HTTP error status ".concat(j.status," received")),[2/*return*/,d.slice(f,d.length)];if(401<=j.status)//if we're getting a 401, assume we'll keep getting a 401 and clear the uploads.
|
|
519
519
|
return this.mpInstance.Logger.error("HTTP error status ".concat(j.status," while uploading - please verify your API key.")),[2/*return*/,null];throw console.error("HTTP error status ".concat(j.status," while uploading events."),j),new Error("Uncaught HTTP Error ".concat(j.status,". Batch upload will be re-attempted."))}return [3/*break*/,5];case 4:return k=i.sent(),this.mpInstance.Logger.error("Error sending event to mParticle servers. ".concat(k)),[2/*return*/,d.slice(f,d.length)];case 5:return f++,[3/*break*/,1];case 6:return [2/*return*/,null]}})})},a.CONTENT_TYPE="text/plain;charset=UTF-8",a.MINIMUM_INTERVAL_MILLIS=500,a)}();
|
|
520
520
|
|
|
521
|
-
var ErrorCodes={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",IDENTITY_MISMATCH:"IDENTITY_MISMATCH",
|
|
521
|
+
var ErrorCodes={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",IDENTITY_MISMATCH:"IDENTITY_MISMATCH",MP_DEPRECATED_METHOD_USAGE:"MP_DEPRECATED_METHOD_USAGE"};var WSDKErrorSeverity={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"};
|
|
522
522
|
|
|
523
523
|
var Modify$4=Constants.IdentityMethods.Modify,Validators={// From ./utils
|
|
524
524
|
// Utility Functions for backwards compatability
|
|
@@ -1260,7 +1260,15 @@ function _defineProperty(obj, key, value) {
|
|
|
1260
1260
|
var AudienceManager=/** @class */function(){function a(a,b,c){this.url="",this.logger=c,this.url="https://".concat(a).concat(b,"/audience"),this.userAudienceAPI=window.fetch?new FetchUploader(this.url):new XHRUploader(this.url);}return a.prototype.sendGetUserAudienceRequest=function(a,b){return __awaiter(this,void 0,void 0,function(){var c,d,e,f,g,h;return __generator(this,function(i){switch(i.label){case 0:this.logger.verbose("Fetching user audiences from server"),c={method:"GET",headers:{Accept:"*/*"}},d="".concat(this.url,"?mpid=").concat(a),i.label=1;case 1:return i.trys.push([1,6,,7]),[4/*yield*/,this.userAudienceAPI.upload(c,d)];case 2:return (e=i.sent(),!(200<=e.status&&300>e.status))?[3/*break*/,4]:(this.logger.verbose("User Audiences successfully received"),[4/*yield*/,e.json()]);case 3:f=i.sent(),g={currentAudienceMemberships:null===f||void 0===f?void 0:f.audience_memberships};try{b(g);}catch(a){throw new Error("Error invoking callback on user audience response.")}return [3/*break*/,5];case 4:if(401===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your API key.`");else if(403===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your workspace is enabled for audiences.`");else// In case there is an HTTP error we did not anticipate.
|
|
1261
1261
|
throw new Error("Uncaught HTTP Error ".concat(e.status,"."));case 5:return [3/*break*/,7];case 6:return h=i.sent(),this.logger.error("Error retrieving audiences. ".concat(h)),[3/*break*/,7];case 7:return [2/*return*/]}})})},a}();
|
|
1262
1262
|
|
|
1263
|
-
var processReadyQueue=function(a){return isEmpty(a)||a.forEach(function(a){isFunction(a)?a():Array.isArray(a)&&processPreloadedItem(a);}),[]};var processPreloadedItem=function(a){
|
|
1263
|
+
var processReadyQueue=function(a){return isEmpty(a)||a.forEach(function(a){isFunction(a)?a():Array.isArray(a)&&processPreloadedItem(a);}),[]};var processPreloadedItem=function(a){// Operate on a copy of the queued item. The ready queue can be drained more
|
|
1264
|
+
// than once (e.g. a synchronous cache-hit identify re-enters processReadyQueue
|
|
1265
|
+
// before the outer drain resets the queue). Splicing the shared item array in
|
|
1266
|
+
// place would corrupt it on the second pass — ["Identity.login", opts] becomes
|
|
1267
|
+
// [opts] — so `method` turns into a non-string/undefined and `method.split('.')`
|
|
1268
|
+
// throws. Copying keeps the original item intact for any repeat pass.
|
|
1269
|
+
var b=a.slice(),c=b.splice(0,1)[0];// Skip malformed queue entries (empty array or non-string method) instead of
|
|
1270
|
+
// throwing an uncaught TypeError from method.split() below.
|
|
1271
|
+
if("string"==typeof c&&0!==c.length)// if the first argument is a method on the base mParticle object, run it
|
|
1264
1272
|
if("undefined"!=typeof window&&window.mParticle&&window.mParticle[b[0]])window.mParticle[c].apply(window.mParticle,b);else {var d=c.split(".");try{// Track both the function and its context
|
|
1265
1273
|
for(var e,f=window.mParticle,g=window.mParticle,h=0,i=d;h<i.length;h++)// Keep track of the parent object
|
|
1266
1274
|
e=i[h],g=f,f=f[e];// Apply the function with its proper context
|
|
@@ -1602,17 +1610,17 @@ var d=a.rtid||a.rclid,e=c.RoktTransactionId,f=b.RoktTransactionId;d?(e&&delete c
|
|
|
1602
1610
|
// }
|
|
1603
1611
|
for(var e in this.clickIds)if(this.clickIds.hasOwnProperty(e)){var f=this.clickIds[e],g=null===(b=this.filteredIntegrationAttributeMappings[e])||void 0===b?void 0:b.mappedKey;if(!isEmpty(g)){var h=null===(c=this.filteredIntegrationAttributeMappings[e])||void 0===c?void 0:c.moduleId;h&&!d[h]&&(d[h]=(a={},a[g]=f,a));}}return d},a.prototype.getClickIds=function(a,b){var c,d={};if(!a)return d;for(var e in a)if(a.hasOwnProperty(e)){var f=a[e],g=null===(c=b[e])||void 0===c?void 0:c.mappedKey;isEmpty(g)||(d[g]=f);}return d},a.prototype.applyProcessors=function(a,b,c){var d,e={},f=this.getActiveIntegrationMapping();for(var g in a)if(a.hasOwnProperty(g)){var h=a[g],i=null===(d=f[g])||void 0===d?void 0:d.processor;e[g]=i?i(h,b,c):h;}return e},a.prototype.filterMappings=function(a){var b={},c=this.getActiveIntegrationMapping();for(var d in c)c[d].output===a&&(b[d]=c[d]);return b},a.prototype.getAllowedKeysForMode=function(){return Object.keys(this.getActiveIntegrationMapping())},a.prototype.getActiveIntegrationMapping=function(){return this.captureMode===Constants.CaptureIntegrationSpecificIdsV2Modes.RoktOnly?integrationMappingRokt:this.captureMode===Constants.CaptureIntegrationSpecificIdsV2Modes.All?__assign(__assign({},integrationMappingExternal),integrationMappingRokt):{}},a}();
|
|
1604
1612
|
|
|
1605
|
-
var ON_SHOPPABLE_ADS_READY_METHOD="onShoppableAdsReady",RoktManager=/** @class */function(){function a(){this.kit=null,this.filters={},this.currentUser=null,this.messageQueue=new Map,this.sandbox=null,this.placementAttributesMapping=[],this.onReadyCallback=null,this.initialized=!1,this.isShoppableAdsLoaded=!1;}/**
|
|
1613
|
+
var PASSBACK_CONVERSION_TRACKING_ID="passbackconversiontrackingid",ON_SHOPPABLE_ADS_READY_METHOD="onShoppableAdsReady",RoktManager=/** @class */function(){function a(){this.kit=null,this.filters={},this.currentUser=null,this.messageQueue=new Map,this.sandbox=null,this.placementAttributesMapping=[],this.onReadyCallback=null,this.initialized=!1,this.isShoppableAdsLoaded=!1;}/**
|
|
1606
1614
|
* Sets a callback to be invoked when RoktManager becomes ready
|
|
1607
|
-
*/return a.prototype.setOnReadyCallback=function(a){this.onReadyCallback=a;},a.prototype.init=function(a,b,c,d,e,f,g,h,i){var
|
|
1615
|
+
*/return a.prototype.setOnReadyCallback=function(a){this.onReadyCallback=a;},a.prototype.init=function(a,b,c,d,e,f,g,h,i,j){var k,l,m=a||{},n=m.userAttributeFilters,o=m.settings,p=o||{},q=p.placementAttributesMapping,r=p.hashedEmailUserIdentityType;this.mappedEmailShaIdentityType=null!==(k=null===r||void 0===r?void 0:r.toLowerCase())&&void 0!==k?k:null,this.identityService=c,this.store=d,this.logger=e,this.errorReporter=h,this.loggingService=i,this.captureTiming=g,this.integrationCapture=j,null===(l=this.captureTiming)||void 0===l?void 0:l.call(this,PerformanceMarkType.JointSdkRoktKitInit),this.filters={userAttributeFilters:n,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b};try{this.placementAttributesMapping=parseSettingsString(q);}catch(a){this.logger.error("Error parsing placement attributes mapping from config: "+a);}// This is the global setting for sandbox mode
|
|
1608
1616
|
// It is set here and passed in to the createLauncher method in the Rokt Kit
|
|
1609
1617
|
// This is not to be confused for the `sandbox` flag in the selectPlacements attributes
|
|
1610
1618
|
// as that is independent of this setting, though they share the same name.
|
|
1611
|
-
var
|
|
1619
|
+
var s=(null===f||void 0===f?void 0:f.sandbox)||!1,t=normalizeRoktLauncherOptions(null===f||void 0===f?void 0:f.launcherOptions);// Launcher options are set here for the kit to pick up and pass through
|
|
1612
1620
|
// to the Rokt Launcher.
|
|
1613
|
-
this.launcherOptions=__assign({sandbox:
|
|
1614
|
-
if(null===(b=this.captureTiming)||void 0===b?void 0:b.call(this,PerformanceMarkType.JointSdkSelectPlacements),!this.isReady()||(null===(c=this.store)||void 0===c?void 0:c.identityCallInFlight))return [2/*return*/,this.deferredCall("selectPlacements",a)];try{if(
|
|
1615
|
-
try{this.identityService.identify({userIdentities:__assign(__assign({},
|
|
1621
|
+
this.launcherOptions=__assign({sandbox:s},t),(null===f||void 0===f?void 0:f.domain)&&(this.domain=f.domain),this.initialized=!0;},Object.defineProperty(a.prototype,"isInitialized",{get:function get(){return this.initialized},enumerable:!1,configurable:!0}),a.prototype.attachKit=function(a){var b,c,d,f;this.kit=a,(null===(b=a.settings)||void 0===b?void 0:b.accountId)&&this.store.setRoktAccountId(a.settings.accountId),a.integrationName&&(null===(c=this.store)||void 0===c?void 0:c.setIntegrationName(a.integrationName)),this.processMessageQueue();try{null===(d=this.onReadyCallback)||void 0===d?void 0:d.call(this);}catch(a){null===(f=this.logger)||void 0===f?void 0:f.error("RoktManager: Error in onReadyCallback: "+a);}},a.prototype.selectPlacements=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;return __awaiter(this,void 0,void 0,function(){var n,o,p,q,r,s,t,u,v,w,x,y,z,A,A,B,C,D,E,F,G,H,I=this;return __generator(this,function(){// Queue if kit isn't ready OR if identity is in flight
|
|
1622
|
+
if(null===(b=this.captureTiming)||void 0===b?void 0:b.call(this,PerformanceMarkType.JointSdkSelectPlacements),!this.isReady()||(null===(c=this.store)||void 0===c?void 0:c.identityCallInFlight))return [2/*return*/,this.deferredCall("selectPlacements",a)];try{if(n=a.attributes,o=(null===n||void 0===n?void 0:n.sandbox)||null,p=this.mapPlacementAttributes(n,this.placementAttributesMapping),(null===(d=this.logger)||void 0===d?void 0:d.isVerbose())&&(q=obfuscateDevData(n,null===(f=null===(e=this.store)||void 0===e?void 0:e.SDKConfig)||void 0===f?void 0:f.isDevelopmentMode),this.logger.verbose("mParticle.Rokt selectPlacements called with attributes:\n".concat(JSON.stringify(q,null,2)))),this.currentUser=this.identityService.getCurrentUser(),r=(null===(h=null===(g=this.currentUser)||void 0===g?void 0:g.getUserIdentities())||void 0===h?void 0:h.userIdentities)||{},s=r.email,t=p.email,u=void 0,v=void 0,w=this.mappedEmailShaIdentityType&&!1!==IdentityType.getIdentityType(this.mappedEmailShaIdentityType),w&&(u=r[this.mappedEmailShaIdentityType],v=p.emailsha256||p[this.mappedEmailShaIdentityType]||void 0),x=this.hasIdentityChanged(s,t),y=this.hasIdentityChanged(u,v),z={},x&&(z.email=t,t&&(A="Email mismatch detected. Current email differs from email passed to selectPlacements call. Proceeding to call identify with email from selectPlacements call. Please verify your implementation.",this.logger.warning(A),null===(i=this.errorReporter)||void 0===i?void 0:i.report({message:A,code:ErrorCodes.IDENTITY_MISMATCH,severity:WSDKErrorSeverity.WARNING}))),y&&(z[this.mappedEmailShaIdentityType]=v,A="emailsha256 mismatch detected. Current mParticle hashedEmail differs from hashedEmail passed to selectPlacements call. Proceeding to call identify with hashedEmail from selectPlacements call. Please verify your implementation.",this.logger.warning(A),null===(j=this.errorReporter)||void 0===j?void 0:j.report({message:A,code:ErrorCodes.IDENTITY_MISMATCH,severity:WSDKErrorSeverity.WARNING})),!isEmpty(z))// Fire-and-forget identify — best-effort, does not block selectPlacements
|
|
1623
|
+
try{this.identityService.identify({userIdentities:__assign(__assign({},r),z)},function(a){var b=+(null===a||void 0===a?void 0:a.httpCode);b&&(400<=b||0>b)&&I.logger.error("Background identify failed with HTTP "+b),I.processMessageQueue();});}catch(a){B=a instanceof Error?a.message:JSON.stringify(a),this.logger.error("Background identify threw an error: "+B);}return C=__assign(__assign({},r),z),this.setUserAttributes(p),D=__assign(__assign({},p),null===o?{}:{sandbox:o}),C.email&&!D.email&&(D.email=C.email),w&&(E=C[this.mappedEmailShaIdentityType],E&&!D.emailsha256&&!D[this.mappedEmailShaIdentityType]&&(D.emailsha256=E)),D[PASSBACK_CONVERSION_TRACKING_ID]||(null===(k=this.integrationCapture)||void 0===k?void 0:k.capture(),F=null===(l=this.integrationCapture)||void 0===l?void 0:l.getClickIdsAsIntegrationAttributes(),G=null===(m=null===F||void 0===F?void 0:F[PARTNER_MODULE_IDS.Rokt])||void 0===m?void 0:m[PASSBACK_CONVERSION_TRACKING_ID],G&&(D[PASSBACK_CONVERSION_TRACKING_ID]=G)),this.filters.filteredUser=this.currentUser||this.filters.filteredUser||null,H=__assign(__assign({},a),{attributes:D}),[2/*return*/,this.kit.selectPlacements(H)]}catch(a){return [2/*return*/,Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))]}return [2/*return*/]})})},a.prototype.hashAttributes=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d,e,f,g,h,i,j,k,l,m,n=this;return __generator(this,function(o){switch(o.label){case 0:return (o.trys.push([0,2,,3]),!a||"object"!==_typeof$1(a))?[2/*return*/,{}]:(b=Object.keys(a),0===b.length)?[2/*return*/,{}]:(c=b.map(function(b){return __awaiter(n,void 0,void 0,function(){var c,d;return __generator(this,function(e){switch(e.label){case 0:return c=a[b],[4/*yield*/,this.hashSha256(c)];case 1:return d=e.sent(),[2/*return*/,{key:b,attributeValue:c,hashedValue:d}]}})})}),[4/*yield*/,Promise.all(c)]);case 1:for(d=o.sent(),e={},(f=0,g=d);f<g.length;f++)h=g[f],i=h.key,j=h.attributeValue,k=h.hashedValue,e[i]=j,k&&(e["".concat(i,"sha256")]=k);return [2/*return*/,e];case 2:return l=o.sent(),m=l instanceof Error?l.message:l+"",this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(m)),[2/*return*/,{}];case 3:return [2/*return*/]}})})},a.prototype.setExtensionData=function(a){if(!this.isReady())return void this.deferredCall("setExtensionData",a);try{this.kit.setExtensionData(a);}catch(a){var b=a instanceof Error?a.message:a+"";throw new Error("Error setting extension data: "+b)}},a.prototype.use=function(a){if(!this.isReady())return this.deferredCall("use",a);try{return this.kit.use(a)}catch(b){return Promise.reject(b instanceof Error?b:new Error("Error using extension: "+a))}},a.prototype.onShoppableAdsReady=function(a){if(!this.kit||!this.isShoppableAdsLoaded)return void this.deferredCall("onShoppableAdsReady",a);try{this.kit.onShoppableAdsReady(a);}catch(a){var b=a instanceof Error?a.message:a+"";this.logger.error("Failed to register onShoppableAdsReady callback: ".concat(b));}},a.prototype.flushOnShoppableAdsReadyMessageQueue=function(a){var b=this;this.kit=a,this.messageQueue.forEach(function(c,d){var f;if(c.methodName===ON_SHOPPABLE_ADS_READY_METHOD){try{a.onShoppableAdsReady(c.payload);}catch(a){null===(f=b.logger)||void 0===f?void 0:f.error("RoktManager: Error flushing onShoppableAdsReady: "+a);}b.messageQueue["delete"](d);}}),this.isShoppableAdsLoaded=!0;},a.prototype.hashSha256=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d;return __generator(this,function(e){switch(e.label){case 0:if(null===a||void 0===a)return this.logger.warning("hashSha256 received null/undefined as input"),[2/*return*/,a];e.label=1;case 1:return e.trys.push([1,3,,4]),b=(a+"").trim().toLocaleLowerCase(),[4/*yield*/,this.sha256Hex(b)];case 2:return [2/*return*/,e.sent()];case 3:return c=e.sent(),d=c instanceof Error?c.message:c+"",this.logger.error("Failed to hashSha256, returning undefined: ".concat(d)),[2/*return*/,void 0];case 4:return [2/*return*/]}})})},a.prototype.getLocalSessionAttributes=function(){return this.store.getLocalSessionAttributes()},a.prototype.setLocalSessionAttribute=function(a,b){this.store.setLocalSessionAttribute(a,b);},a.prototype.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
|
|
1616
1624
|
return !!(this.kit&&this.kit.launcher)},a.prototype.setUserAttributes=function(a){var b=["sandbox"],c={};for(var d in a)if(a.hasOwnProperty(d)&&-1===b.indexOf(d)){var e=a[d];c[d]=Array.isArray(e)?JSON.stringify(e):e;}try{this.currentUser.setUserAttributes(c);}catch(a){this.logger.error("Error setting user attributes: "+a);}},a.prototype.mapPlacementAttributes=function(a,b){for(var c,d={},e=0,f=b;e<f.length;e++)c=f[e],d[c.map]=c.value;var g={};for(var h in a)if(a.hasOwnProperty(h)){var i=d[h]||h;g[i]=a[h];}return g},a.prototype.onIdentityComplete=function(){this.isReady()&&(this.currentUser=this.identityService.getCurrentUser(),this.processMessageQueue());},a.prototype.processMessageQueue=function(){var a,b=this;if(this.isReady()&&0!==this.messageQueue.size){null===(a=this.logger)||void 0===a?void 0:a.verbose("RoktManager: Processing ".concat(this.messageQueue.size," queued messages"));var c=Array.from(this.messageQueue.values());// Clear the queue immediately to prevent re-processing
|
|
1617
1625
|
this.messageQueue.clear(),c.forEach(function(a){var c,d,e,f;if(!(a.methodName in b)||!isFunction(b[a.methodName]))return void(null===(c=b.logger)||void 0===c?void 0:c.error("RoktManager: Method ".concat(a.methodName," not found")));if(null===(d=b.logger)||void 0===d?void 0:d.isVerbose()){var g=obfuscateDevData(a.payload,null===(f=null===(e=b.store)||void 0===e?void 0:e.SDKConfig)||void 0===f?void 0:f.isDevelopmentMode);b.logger.verbose("RoktManager: Processing queued message: ".concat(a.methodName," with payload: ").concat(JSON.stringify(g)));}// Capture resolve/reject functions before async processing
|
|
1618
1626
|
var h=a.resolve,i=a.reject,j=function(c){var d,e=c instanceof Error?c.message:c+"";null===(d=b.logger)||void 0===d?void 0:d.error("RoktManager: Error processing message '".concat(a.methodName,"': ").concat(e)),i&&i(c);};try{var k=b[a.methodName](a.payload);// Handle both sync and async methods
|
|
@@ -1813,7 +1821,7 @@ if((null===(d=c._APIClient)||void 0===d?void 0:d.uploader)&&c._APIClient.uploade
|
|
|
1813
1821
|
var j=c.Identity.getCurrentUser(),k=j?j.getMPID():null,l=j?j.getUserIdentities().userIdentities:{};c._Store.SDKConfig.identifyRequest=c._Store.hasInvalidIdentifyRequest()?{userIdentities:l}:c._Store.SDKConfig.identifyRequest,i(ReportBatching)&&c._ForwardingStatsUploader.startForwardingStatsTimer();// https://go.mparticle.com/work/SQDSDKS-7639
|
|
1814
1822
|
var m=i(CaptureIntegrationSpecificIds),n=i(CaptureIntegrationSpecificIdsV2),o=n&&n!==CaptureIntegrationSpecificIdsV2Modes.None||!0===m;if(o){var p;m||n===CaptureIntegrationSpecificIdsV2Modes.All?p="all":n===CaptureIntegrationSpecificIdsV2Modes.RoktOnly&&(p="roktonly"),c._IntegrationCapture=new IntegrationCapture(p),c._IntegrationCapture.capture();}// Configure Rokt Manager with user and filtered user
|
|
1815
1823
|
var q=parseConfig(b,"Rokt",181);if(q){var r=null===(e=q.settings)||void 0===e?void 0:e.accountId;c._Store.setRoktAccountId(r);var s=q.userAttributeFilters,t=filteredMparticleUser(k,{userAttributeFilters:s},c),u={sandbox:null===b||void 0===b?void 0:b.isDevelopmentMode,launcherOptions:null===b||void 0===b?void 0:b.launcherOptions,domain:null===b||void 0===b?void 0:b.domain};// https://go.mparticle.com/work/SQDSDKS-7339
|
|
1816
|
-
c._RoktManager.init(q,t,c.Identity,c._Store,c.Logger,u,c.captureTiming,c._ErrorReportingDispatcher,c._LoggingDispatcher);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,j,k,l);}// We will continue to clear out the ready queue as part of the initial init flow
|
|
1824
|
+
c._RoktManager.init(q,t,c.Identity,c._Store,c.Logger,u,c.captureTiming,c._ErrorReportingDispatcher,c._LoggingDispatcher,c._IntegrationCapture);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,j,k,l);}// We will continue to clear out the ready queue as part of the initial init flow
|
|
1817
1825
|
// if an identify request is unnecessary, such as if there is an existing session
|
|
1818
1826
|
(c._Store.mpid&&!c._Store.identifyCalled||c._Store.webviewBridgeEnabled)&&(c._Store.isInitialized=!0,null===(f=c._CookieConsentManager)||void 0===f?void 0:f.syncNoTargetingAttribute(c.Identity.getCurrentUser()),c._preInit.readyQueue=processReadyQueue(c._preInit.readyQueue)),null===(g=c.processQueueOnNoFunctional)||void 0===g?void 0:g.call(c),c._Store.isFirstRun&&(c._Store.isFirstRun=!1);}// https://go.mparticle.com/work/SQDSDKS-7061
|
|
1819
1827
|
function createKitBlocker(a,b){var c,d,e,f;/* There are three ways a data plan object for blocking can be passed to the SDK:
|
package/dist/mparticle.esm.js
CHANGED
|
@@ -15,7 +15,7 @@ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is nul
|
|
|
15
15
|
filter:function filter(a/*, thisArg*/){if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g);}return d},// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
|
16
16
|
isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1};
|
|
17
17
|
|
|
18
|
-
var version = "2.
|
|
18
|
+
var version = "2.73.0";
|
|
19
19
|
|
|
20
20
|
var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"is a deprecated method and will be removed in future releases.",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",AddToCart:"addToCart",RemoveFromCart:"removeFromCart",ClearCart:"clearCart",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",localStorageProductsV4:"mprtcl-prodv4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4",currentStorageProductsName:"mprtcl-prodv4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,maxProducts:20,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
|
|
21
21
|
},DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},// These are the paths that are used to construct the CNAME urls
|
|
@@ -518,7 +518,7 @@ this.mpInstance.Logger.warning("Offline batch storage is over quota. Retaining b
|
|
|
518
518
|
return this.mpInstance.Logger.error("HTTP error status ".concat(j.status," received")),[2/*return*/,d.slice(f,d.length)];if(401<=j.status)//if we're getting a 401, assume we'll keep getting a 401 and clear the uploads.
|
|
519
519
|
return this.mpInstance.Logger.error("HTTP error status ".concat(j.status," while uploading - please verify your API key.")),[2/*return*/,null];throw console.error("HTTP error status ".concat(j.status," while uploading events."),j),new Error("Uncaught HTTP Error ".concat(j.status,". Batch upload will be re-attempted."))}return [3/*break*/,5];case 4:return k=i.sent(),this.mpInstance.Logger.error("Error sending event to mParticle servers. ".concat(k)),[2/*return*/,d.slice(f,d.length)];case 5:return f++,[3/*break*/,1];case 6:return [2/*return*/,null]}})})},a.CONTENT_TYPE="text/plain;charset=UTF-8",a.MINIMUM_INTERVAL_MILLIS=500,a)}();
|
|
520
520
|
|
|
521
|
-
var ErrorCodes={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",IDENTITY_MISMATCH:"IDENTITY_MISMATCH",
|
|
521
|
+
var ErrorCodes={UNKNOWN_ERROR:"UNKNOWN_ERROR",UNHANDLED_EXCEPTION:"UNHANDLED_EXCEPTION",IDENTITY_REQUEST:"IDENTITY_REQUEST",IDENTITY_MISMATCH:"IDENTITY_MISMATCH",MP_DEPRECATED_METHOD_USAGE:"MP_DEPRECATED_METHOD_USAGE"};var WSDKErrorSeverity={ERROR:"ERROR",INFO:"INFO",WARNING:"WARNING"};
|
|
522
522
|
|
|
523
523
|
var Modify$4=Constants.IdentityMethods.Modify,Validators={// From ./utils
|
|
524
524
|
// Utility Functions for backwards compatability
|
|
@@ -1260,7 +1260,15 @@ function _defineProperty(obj, key, value) {
|
|
|
1260
1260
|
var AudienceManager=/** @class */function(){function a(a,b,c){this.url="",this.logger=c,this.url="https://".concat(a).concat(b,"/audience"),this.userAudienceAPI=window.fetch?new FetchUploader(this.url):new XHRUploader(this.url);}return a.prototype.sendGetUserAudienceRequest=function(a,b){return __awaiter(this,void 0,void 0,function(){var c,d,e,f,g,h;return __generator(this,function(i){switch(i.label){case 0:this.logger.verbose("Fetching user audiences from server"),c={method:"GET",headers:{Accept:"*/*"}},d="".concat(this.url,"?mpid=").concat(a),i.label=1;case 1:return i.trys.push([1,6,,7]),[4/*yield*/,this.userAudienceAPI.upload(c,d)];case 2:return (e=i.sent(),!(200<=e.status&&300>e.status))?[3/*break*/,4]:(this.logger.verbose("User Audiences successfully received"),[4/*yield*/,e.json()]);case 3:f=i.sent(),g={currentAudienceMemberships:null===f||void 0===f?void 0:f.audience_memberships};try{b(g);}catch(a){throw new Error("Error invoking callback on user audience response.")}return [3/*break*/,5];case 4:if(401===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your API key.`");else if(403===e.status)throw new Error("`HTTP error status ${userAudiencePromise.status} while retrieving User Audiences - please verify your workspace is enabled for audiences.`");else// In case there is an HTTP error we did not anticipate.
|
|
1261
1261
|
throw new Error("Uncaught HTTP Error ".concat(e.status,"."));case 5:return [3/*break*/,7];case 6:return h=i.sent(),this.logger.error("Error retrieving audiences. ".concat(h)),[3/*break*/,7];case 7:return [2/*return*/]}})})},a}();
|
|
1262
1262
|
|
|
1263
|
-
var processReadyQueue=function(a){return isEmpty(a)||a.forEach(function(a){isFunction(a)?a():Array.isArray(a)&&processPreloadedItem(a);}),[]};var processPreloadedItem=function(a){
|
|
1263
|
+
var processReadyQueue=function(a){return isEmpty(a)||a.forEach(function(a){isFunction(a)?a():Array.isArray(a)&&processPreloadedItem(a);}),[]};var processPreloadedItem=function(a){// Operate on a copy of the queued item. The ready queue can be drained more
|
|
1264
|
+
// than once (e.g. a synchronous cache-hit identify re-enters processReadyQueue
|
|
1265
|
+
// before the outer drain resets the queue). Splicing the shared item array in
|
|
1266
|
+
// place would corrupt it on the second pass — ["Identity.login", opts] becomes
|
|
1267
|
+
// [opts] — so `method` turns into a non-string/undefined and `method.split('.')`
|
|
1268
|
+
// throws. Copying keeps the original item intact for any repeat pass.
|
|
1269
|
+
var b=a.slice(),c=b.splice(0,1)[0];// Skip malformed queue entries (empty array or non-string method) instead of
|
|
1270
|
+
// throwing an uncaught TypeError from method.split() below.
|
|
1271
|
+
if("string"==typeof c&&0!==c.length)// if the first argument is a method on the base mParticle object, run it
|
|
1264
1272
|
if("undefined"!=typeof window&&window.mParticle&&window.mParticle[b[0]])window.mParticle[c].apply(window.mParticle,b);else {var d=c.split(".");try{// Track both the function and its context
|
|
1265
1273
|
for(var e,f=window.mParticle,g=window.mParticle,h=0,i=d;h<i.length;h++)// Keep track of the parent object
|
|
1266
1274
|
e=i[h],g=f,f=f[e];// Apply the function with its proper context
|
|
@@ -1602,17 +1610,17 @@ var d=a.rtid||a.rclid,e=c.RoktTransactionId,f=b.RoktTransactionId;d?(e&&delete c
|
|
|
1602
1610
|
// }
|
|
1603
1611
|
for(var e in this.clickIds)if(this.clickIds.hasOwnProperty(e)){var f=this.clickIds[e],g=null===(b=this.filteredIntegrationAttributeMappings[e])||void 0===b?void 0:b.mappedKey;if(!isEmpty(g)){var h=null===(c=this.filteredIntegrationAttributeMappings[e])||void 0===c?void 0:c.moduleId;h&&!d[h]&&(d[h]=(a={},a[g]=f,a));}}return d},a.prototype.getClickIds=function(a,b){var c,d={};if(!a)return d;for(var e in a)if(a.hasOwnProperty(e)){var f=a[e],g=null===(c=b[e])||void 0===c?void 0:c.mappedKey;isEmpty(g)||(d[g]=f);}return d},a.prototype.applyProcessors=function(a,b,c){var d,e={},f=this.getActiveIntegrationMapping();for(var g in a)if(a.hasOwnProperty(g)){var h=a[g],i=null===(d=f[g])||void 0===d?void 0:d.processor;e[g]=i?i(h,b,c):h;}return e},a.prototype.filterMappings=function(a){var b={},c=this.getActiveIntegrationMapping();for(var d in c)c[d].output===a&&(b[d]=c[d]);return b},a.prototype.getAllowedKeysForMode=function(){return Object.keys(this.getActiveIntegrationMapping())},a.prototype.getActiveIntegrationMapping=function(){return this.captureMode===Constants.CaptureIntegrationSpecificIdsV2Modes.RoktOnly?integrationMappingRokt:this.captureMode===Constants.CaptureIntegrationSpecificIdsV2Modes.All?__assign(__assign({},integrationMappingExternal),integrationMappingRokt):{}},a}();
|
|
1604
1612
|
|
|
1605
|
-
var ON_SHOPPABLE_ADS_READY_METHOD="onShoppableAdsReady",RoktManager=/** @class */function(){function a(){this.kit=null,this.filters={},this.currentUser=null,this.messageQueue=new Map,this.sandbox=null,this.placementAttributesMapping=[],this.onReadyCallback=null,this.initialized=!1,this.isShoppableAdsLoaded=!1;}/**
|
|
1613
|
+
var PASSBACK_CONVERSION_TRACKING_ID="passbackconversiontrackingid",ON_SHOPPABLE_ADS_READY_METHOD="onShoppableAdsReady",RoktManager=/** @class */function(){function a(){this.kit=null,this.filters={},this.currentUser=null,this.messageQueue=new Map,this.sandbox=null,this.placementAttributesMapping=[],this.onReadyCallback=null,this.initialized=!1,this.isShoppableAdsLoaded=!1;}/**
|
|
1606
1614
|
* Sets a callback to be invoked when RoktManager becomes ready
|
|
1607
|
-
*/return a.prototype.setOnReadyCallback=function(a){this.onReadyCallback=a;},a.prototype.init=function(a,b,c,d,e,f,g,h,i){var
|
|
1615
|
+
*/return a.prototype.setOnReadyCallback=function(a){this.onReadyCallback=a;},a.prototype.init=function(a,b,c,d,e,f,g,h,i,j){var k,l,m=a||{},n=m.userAttributeFilters,o=m.settings,p=o||{},q=p.placementAttributesMapping,r=p.hashedEmailUserIdentityType;this.mappedEmailShaIdentityType=null!==(k=null===r||void 0===r?void 0:r.toLowerCase())&&void 0!==k?k:null,this.identityService=c,this.store=d,this.logger=e,this.errorReporter=h,this.loggingService=i,this.captureTiming=g,this.integrationCapture=j,null===(l=this.captureTiming)||void 0===l?void 0:l.call(this,PerformanceMarkType.JointSdkRoktKitInit),this.filters={userAttributeFilters:n,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b};try{this.placementAttributesMapping=parseSettingsString(q);}catch(a){this.logger.error("Error parsing placement attributes mapping from config: "+a);}// This is the global setting for sandbox mode
|
|
1608
1616
|
// It is set here and passed in to the createLauncher method in the Rokt Kit
|
|
1609
1617
|
// This is not to be confused for the `sandbox` flag in the selectPlacements attributes
|
|
1610
1618
|
// as that is independent of this setting, though they share the same name.
|
|
1611
|
-
var
|
|
1619
|
+
var s=(null===f||void 0===f?void 0:f.sandbox)||!1,t=normalizeRoktLauncherOptions(null===f||void 0===f?void 0:f.launcherOptions);// Launcher options are set here for the kit to pick up and pass through
|
|
1612
1620
|
// to the Rokt Launcher.
|
|
1613
|
-
this.launcherOptions=__assign({sandbox:
|
|
1614
|
-
if(null===(b=this.captureTiming)||void 0===b?void 0:b.call(this,PerformanceMarkType.JointSdkSelectPlacements),!this.isReady()||(null===(c=this.store)||void 0===c?void 0:c.identityCallInFlight))return [2/*return*/,this.deferredCall("selectPlacements",a)];try{if(
|
|
1615
|
-
try{this.identityService.identify({userIdentities:__assign(__assign({},
|
|
1621
|
+
this.launcherOptions=__assign({sandbox:s},t),(null===f||void 0===f?void 0:f.domain)&&(this.domain=f.domain),this.initialized=!0;},Object.defineProperty(a.prototype,"isInitialized",{get:function get(){return this.initialized},enumerable:!1,configurable:!0}),a.prototype.attachKit=function(a){var b,c,d,f;this.kit=a,(null===(b=a.settings)||void 0===b?void 0:b.accountId)&&this.store.setRoktAccountId(a.settings.accountId),a.integrationName&&(null===(c=this.store)||void 0===c?void 0:c.setIntegrationName(a.integrationName)),this.processMessageQueue();try{null===(d=this.onReadyCallback)||void 0===d?void 0:d.call(this);}catch(a){null===(f=this.logger)||void 0===f?void 0:f.error("RoktManager: Error in onReadyCallback: "+a);}},a.prototype.selectPlacements=function(a){var b,c,d,e,f,g,h,i,j,k,l,m;return __awaiter(this,void 0,void 0,function(){var n,o,p,q,r,s,t,u,v,w,x,y,z,A,A,B,C,D,E,F,G,H,I=this;return __generator(this,function(){// Queue if kit isn't ready OR if identity is in flight
|
|
1622
|
+
if(null===(b=this.captureTiming)||void 0===b?void 0:b.call(this,PerformanceMarkType.JointSdkSelectPlacements),!this.isReady()||(null===(c=this.store)||void 0===c?void 0:c.identityCallInFlight))return [2/*return*/,this.deferredCall("selectPlacements",a)];try{if(n=a.attributes,o=(null===n||void 0===n?void 0:n.sandbox)||null,p=this.mapPlacementAttributes(n,this.placementAttributesMapping),(null===(d=this.logger)||void 0===d?void 0:d.isVerbose())&&(q=obfuscateDevData(n,null===(f=null===(e=this.store)||void 0===e?void 0:e.SDKConfig)||void 0===f?void 0:f.isDevelopmentMode),this.logger.verbose("mParticle.Rokt selectPlacements called with attributes:\n".concat(JSON.stringify(q,null,2)))),this.currentUser=this.identityService.getCurrentUser(),r=(null===(h=null===(g=this.currentUser)||void 0===g?void 0:g.getUserIdentities())||void 0===h?void 0:h.userIdentities)||{},s=r.email,t=p.email,u=void 0,v=void 0,w=this.mappedEmailShaIdentityType&&!1!==IdentityType.getIdentityType(this.mappedEmailShaIdentityType),w&&(u=r[this.mappedEmailShaIdentityType],v=p.emailsha256||p[this.mappedEmailShaIdentityType]||void 0),x=this.hasIdentityChanged(s,t),y=this.hasIdentityChanged(u,v),z={},x&&(z.email=t,t&&(A="Email mismatch detected. Current email differs from email passed to selectPlacements call. Proceeding to call identify with email from selectPlacements call. Please verify your implementation.",this.logger.warning(A),null===(i=this.errorReporter)||void 0===i?void 0:i.report({message:A,code:ErrorCodes.IDENTITY_MISMATCH,severity:WSDKErrorSeverity.WARNING}))),y&&(z[this.mappedEmailShaIdentityType]=v,A="emailsha256 mismatch detected. Current mParticle hashedEmail differs from hashedEmail passed to selectPlacements call. Proceeding to call identify with hashedEmail from selectPlacements call. Please verify your implementation.",this.logger.warning(A),null===(j=this.errorReporter)||void 0===j?void 0:j.report({message:A,code:ErrorCodes.IDENTITY_MISMATCH,severity:WSDKErrorSeverity.WARNING})),!isEmpty(z))// Fire-and-forget identify — best-effort, does not block selectPlacements
|
|
1623
|
+
try{this.identityService.identify({userIdentities:__assign(__assign({},r),z)},function(a){var b=+(null===a||void 0===a?void 0:a.httpCode);b&&(400<=b||0>b)&&I.logger.error("Background identify failed with HTTP "+b),I.processMessageQueue();});}catch(a){B=a instanceof Error?a.message:JSON.stringify(a),this.logger.error("Background identify threw an error: "+B);}return C=__assign(__assign({},r),z),this.setUserAttributes(p),D=__assign(__assign({},p),null===o?{}:{sandbox:o}),C.email&&!D.email&&(D.email=C.email),w&&(E=C[this.mappedEmailShaIdentityType],E&&!D.emailsha256&&!D[this.mappedEmailShaIdentityType]&&(D.emailsha256=E)),D[PASSBACK_CONVERSION_TRACKING_ID]||(null===(k=this.integrationCapture)||void 0===k?void 0:k.capture(),F=null===(l=this.integrationCapture)||void 0===l?void 0:l.getClickIdsAsIntegrationAttributes(),G=null===(m=null===F||void 0===F?void 0:F[PARTNER_MODULE_IDS.Rokt])||void 0===m?void 0:m[PASSBACK_CONVERSION_TRACKING_ID],G&&(D[PASSBACK_CONVERSION_TRACKING_ID]=G)),this.filters.filteredUser=this.currentUser||this.filters.filteredUser||null,H=__assign(__assign({},a),{attributes:D}),[2/*return*/,this.kit.selectPlacements(H)]}catch(a){return [2/*return*/,Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))]}return [2/*return*/]})})},a.prototype.hashAttributes=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d,e,f,g,h,i,j,k,l,m,n=this;return __generator(this,function(o){switch(o.label){case 0:return (o.trys.push([0,2,,3]),!a||"object"!==_typeof$1(a))?[2/*return*/,{}]:(b=Object.keys(a),0===b.length)?[2/*return*/,{}]:(c=b.map(function(b){return __awaiter(n,void 0,void 0,function(){var c,d;return __generator(this,function(e){switch(e.label){case 0:return c=a[b],[4/*yield*/,this.hashSha256(c)];case 1:return d=e.sent(),[2/*return*/,{key:b,attributeValue:c,hashedValue:d}]}})})}),[4/*yield*/,Promise.all(c)]);case 1:for(d=o.sent(),e={},(f=0,g=d);f<g.length;f++)h=g[f],i=h.key,j=h.attributeValue,k=h.hashedValue,e[i]=j,k&&(e["".concat(i,"sha256")]=k);return [2/*return*/,e];case 2:return l=o.sent(),m=l instanceof Error?l.message:l+"",this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(m)),[2/*return*/,{}];case 3:return [2/*return*/]}})})},a.prototype.setExtensionData=function(a){if(!this.isReady())return void this.deferredCall("setExtensionData",a);try{this.kit.setExtensionData(a);}catch(a){var b=a instanceof Error?a.message:a+"";throw new Error("Error setting extension data: "+b)}},a.prototype.use=function(a){if(!this.isReady())return this.deferredCall("use",a);try{return this.kit.use(a)}catch(b){return Promise.reject(b instanceof Error?b:new Error("Error using extension: "+a))}},a.prototype.onShoppableAdsReady=function(a){if(!this.kit||!this.isShoppableAdsLoaded)return void this.deferredCall("onShoppableAdsReady",a);try{this.kit.onShoppableAdsReady(a);}catch(a){var b=a instanceof Error?a.message:a+"";this.logger.error("Failed to register onShoppableAdsReady callback: ".concat(b));}},a.prototype.flushOnShoppableAdsReadyMessageQueue=function(a){var b=this;this.kit=a,this.messageQueue.forEach(function(c,d){var f;if(c.methodName===ON_SHOPPABLE_ADS_READY_METHOD){try{a.onShoppableAdsReady(c.payload);}catch(a){null===(f=b.logger)||void 0===f?void 0:f.error("RoktManager: Error flushing onShoppableAdsReady: "+a);}b.messageQueue["delete"](d);}}),this.isShoppableAdsLoaded=!0;},a.prototype.hashSha256=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d;return __generator(this,function(e){switch(e.label){case 0:if(null===a||void 0===a)return this.logger.warning("hashSha256 received null/undefined as input"),[2/*return*/,a];e.label=1;case 1:return e.trys.push([1,3,,4]),b=(a+"").trim().toLocaleLowerCase(),[4/*yield*/,this.sha256Hex(b)];case 2:return [2/*return*/,e.sent()];case 3:return c=e.sent(),d=c instanceof Error?c.message:c+"",this.logger.error("Failed to hashSha256, returning undefined: ".concat(d)),[2/*return*/,void 0];case 4:return [2/*return*/]}})})},a.prototype.getLocalSessionAttributes=function(){return this.store.getLocalSessionAttributes()},a.prototype.setLocalSessionAttribute=function(a,b){this.store.setLocalSessionAttribute(a,b);},a.prototype.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
|
|
1616
1624
|
return !!(this.kit&&this.kit.launcher)},a.prototype.setUserAttributes=function(a){var b=["sandbox"],c={};for(var d in a)if(a.hasOwnProperty(d)&&-1===b.indexOf(d)){var e=a[d];c[d]=Array.isArray(e)?JSON.stringify(e):e;}try{this.currentUser.setUserAttributes(c);}catch(a){this.logger.error("Error setting user attributes: "+a);}},a.prototype.mapPlacementAttributes=function(a,b){for(var c,d={},e=0,f=b;e<f.length;e++)c=f[e],d[c.map]=c.value;var g={};for(var h in a)if(a.hasOwnProperty(h)){var i=d[h]||h;g[i]=a[h];}return g},a.prototype.onIdentityComplete=function(){this.isReady()&&(this.currentUser=this.identityService.getCurrentUser(),this.processMessageQueue());},a.prototype.processMessageQueue=function(){var a,b=this;if(this.isReady()&&0!==this.messageQueue.size){null===(a=this.logger)||void 0===a?void 0:a.verbose("RoktManager: Processing ".concat(this.messageQueue.size," queued messages"));var c=Array.from(this.messageQueue.values());// Clear the queue immediately to prevent re-processing
|
|
1617
1625
|
this.messageQueue.clear(),c.forEach(function(a){var c,d,e,f;if(!(a.methodName in b)||!isFunction(b[a.methodName]))return void(null===(c=b.logger)||void 0===c?void 0:c.error("RoktManager: Method ".concat(a.methodName," not found")));if(null===(d=b.logger)||void 0===d?void 0:d.isVerbose()){var g=obfuscateDevData(a.payload,null===(f=null===(e=b.store)||void 0===e?void 0:e.SDKConfig)||void 0===f?void 0:f.isDevelopmentMode);b.logger.verbose("RoktManager: Processing queued message: ".concat(a.methodName," with payload: ").concat(JSON.stringify(g)));}// Capture resolve/reject functions before async processing
|
|
1618
1626
|
var h=a.resolve,i=a.reject,j=function(c){var d,e=c instanceof Error?c.message:c+"";null===(d=b.logger)||void 0===d?void 0:d.error("RoktManager: Error processing message '".concat(a.methodName,"': ").concat(e)),i&&i(c);};try{var k=b[a.methodName](a.payload);// Handle both sync and async methods
|
|
@@ -1813,7 +1821,7 @@ if((null===(d=c._APIClient)||void 0===d?void 0:d.uploader)&&c._APIClient.uploade
|
|
|
1813
1821
|
var j=c.Identity.getCurrentUser(),k=j?j.getMPID():null,l=j?j.getUserIdentities().userIdentities:{};c._Store.SDKConfig.identifyRequest=c._Store.hasInvalidIdentifyRequest()?{userIdentities:l}:c._Store.SDKConfig.identifyRequest,i(ReportBatching)&&c._ForwardingStatsUploader.startForwardingStatsTimer();// https://go.mparticle.com/work/SQDSDKS-7639
|
|
1814
1822
|
var m=i(CaptureIntegrationSpecificIds),n=i(CaptureIntegrationSpecificIdsV2),o=n&&n!==CaptureIntegrationSpecificIdsV2Modes.None||!0===m;if(o){var p;m||n===CaptureIntegrationSpecificIdsV2Modes.All?p="all":n===CaptureIntegrationSpecificIdsV2Modes.RoktOnly&&(p="roktonly"),c._IntegrationCapture=new IntegrationCapture(p),c._IntegrationCapture.capture();}// Configure Rokt Manager with user and filtered user
|
|
1815
1823
|
var q=parseConfig(b,"Rokt",181);if(q){var r=null===(e=q.settings)||void 0===e?void 0:e.accountId;c._Store.setRoktAccountId(r);var s=q.userAttributeFilters,t=filteredMparticleUser(k,{userAttributeFilters:s},c),u={sandbox:null===b||void 0===b?void 0:b.isDevelopmentMode,launcherOptions:null===b||void 0===b?void 0:b.launcherOptions,domain:null===b||void 0===b?void 0:b.domain};// https://go.mparticle.com/work/SQDSDKS-7339
|
|
1816
|
-
c._RoktManager.init(q,t,c.Identity,c._Store,c.Logger,u,c.captureTiming,c._ErrorReportingDispatcher,c._LoggingDispatcher);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,j,k,l);}// We will continue to clear out the ready queue as part of the initial init flow
|
|
1824
|
+
c._RoktManager.init(q,t,c.Identity,c._Store,c.Logger,u,c.captureTiming,c._ErrorReportingDispatcher,c._LoggingDispatcher,c._IntegrationCapture);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,j,k,l);}// We will continue to clear out the ready queue as part of the initial init flow
|
|
1817
1825
|
// if an identify request is unnecessary, such as if there is an existing session
|
|
1818
1826
|
(c._Store.mpid&&!c._Store.identifyCalled||c._Store.webviewBridgeEnabled)&&(c._Store.isInitialized=!0,null===(f=c._CookieConsentManager)||void 0===f?void 0:f.syncNoTargetingAttribute(c.Identity.getCurrentUser()),c._preInit.readyQueue=processReadyQueue(c._preInit.readyQueue)),null===(g=c.processQueueOnNoFunctional)||void 0===g?void 0:g.call(c),c._Store.isFirstRun&&(c._Store.isFirstRun=!1);}// https://go.mparticle.com/work/SQDSDKS-7061
|
|
1819
1827
|
function createKitBlocker(a,b){var c,d,e,f;/* There are three ways a data plan object for blocking can be passed to the SDK:
|
package/dist/mparticle.js
CHANGED
|
@@ -203,7 +203,7 @@ var mParticle = (function () {
|
|
|
203
203
|
Base64: Base64$1
|
|
204
204
|
};
|
|
205
205
|
|
|
206
|
-
var version = "2.
|
|
206
|
+
var version = "2.73.0";
|
|
207
207
|
|
|
208
208
|
var Constants = {
|
|
209
209
|
sdkVersion: version,
|
|
@@ -3086,7 +3086,6 @@ var mParticle = (function () {
|
|
|
3086
3086
|
UNHANDLED_EXCEPTION: 'UNHANDLED_EXCEPTION',
|
|
3087
3087
|
IDENTITY_REQUEST: 'IDENTITY_REQUEST',
|
|
3088
3088
|
IDENTITY_MISMATCH: 'IDENTITY_MISMATCH',
|
|
3089
|
-
ROKT_KIT_ATTACHED: 'ROKT_KIT_ATTACHED',
|
|
3090
3089
|
MP_DEPRECATED_METHOD_USAGE: 'MP_DEPRECATED_METHOD_USAGE'
|
|
3091
3090
|
};
|
|
3092
3091
|
var WSDKErrorSeverity = {
|
|
@@ -7925,8 +7924,19 @@ var mParticle = (function () {
|
|
|
7925
7924
|
return [];
|
|
7926
7925
|
};
|
|
7927
7926
|
var processPreloadedItem = function processPreloadedItem(readyQueueItem) {
|
|
7928
|
-
|
|
7927
|
+
// Operate on a copy of the queued item. The ready queue can be drained more
|
|
7928
|
+
// than once (e.g. a synchronous cache-hit identify re-enters processReadyQueue
|
|
7929
|
+
// before the outer drain resets the queue). Splicing the shared item array in
|
|
7930
|
+
// place would corrupt it on the second pass — ["Identity.login", opts] becomes
|
|
7931
|
+
// [opts] — so `method` turns into a non-string/undefined and `method.split('.')`
|
|
7932
|
+
// throws. Copying keeps the original item intact for any repeat pass.
|
|
7933
|
+
var args = readyQueueItem.slice();
|
|
7929
7934
|
var method = args.splice(0, 1)[0];
|
|
7935
|
+
// Skip malformed queue entries (empty array or non-string method) instead of
|
|
7936
|
+
// throwing an uncaught TypeError from method.split() below.
|
|
7937
|
+
if (typeof method !== 'string' || method.length === 0) {
|
|
7938
|
+
return;
|
|
7939
|
+
}
|
|
7930
7940
|
// if the first argument is a method on the base mParticle object, run it
|
|
7931
7941
|
if (typeof window !== 'undefined' && window.mParticle && window.mParticle[args[0]]) {
|
|
7932
7942
|
window.mParticle[method].apply(window.mParticle, args);
|
|
@@ -10436,6 +10446,7 @@ var mParticle = (function () {
|
|
|
10436
10446
|
return IntegrationCapture;
|
|
10437
10447
|
}();
|
|
10438
10448
|
|
|
10449
|
+
var PASSBACK_CONVERSION_TRACKING_ID = 'passbackconversiontrackingid';
|
|
10439
10450
|
var ON_SHOPPABLE_ADS_READY_METHOD = 'onShoppableAdsReady';
|
|
10440
10451
|
// The purpose of this class is to create a link between the Core mParticle SDK and the
|
|
10441
10452
|
// Rokt Web SDK via a Web Kit.
|
|
@@ -10478,7 +10489,7 @@ var mParticle = (function () {
|
|
|
10478
10489
|
*
|
|
10479
10490
|
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
10480
10491
|
*/
|
|
10481
|
-
RoktManager.prototype.init = function (roktConfig, filteredUser, identityService, store, logger, options, captureTiming, errorReporter, loggingService) {
|
|
10492
|
+
RoktManager.prototype.init = function (roktConfig, filteredUser, identityService, store, logger, options, captureTiming, errorReporter, loggingService, integrationCapture) {
|
|
10482
10493
|
var _a, _b;
|
|
10483
10494
|
var _c = roktConfig || {},
|
|
10484
10495
|
userAttributeFilters = _c.userAttributeFilters,
|
|
@@ -10493,6 +10504,7 @@ var mParticle = (function () {
|
|
|
10493
10504
|
this.errorReporter = errorReporter;
|
|
10494
10505
|
this.loggingService = loggingService;
|
|
10495
10506
|
this.captureTiming = captureTiming;
|
|
10507
|
+
this.integrationCapture = integrationCapture;
|
|
10496
10508
|
(_b = this.captureTiming) === null || _b === void 0 ? void 0 : _b.call(this, PerformanceMarkType.JointSdkRoktKitInit);
|
|
10497
10509
|
this.filters = {
|
|
10498
10510
|
userAttributeFilters: userAttributeFilters,
|
|
@@ -10531,7 +10543,7 @@ var mParticle = (function () {
|
|
|
10531
10543
|
configurable: true
|
|
10532
10544
|
});
|
|
10533
10545
|
RoktManager.prototype.attachKit = function (kit) {
|
|
10534
|
-
var _a, _b, _c, _d
|
|
10546
|
+
var _a, _b, _c, _d;
|
|
10535
10547
|
this.kit = kit;
|
|
10536
10548
|
if ((_a = kit.settings) === null || _a === void 0 ? void 0 : _a.accountId) {
|
|
10537
10549
|
this.store.setRoktAccountId(kit.settings.accountId);
|
|
@@ -10539,15 +10551,11 @@ var mParticle = (function () {
|
|
|
10539
10551
|
if (kit.integrationName) {
|
|
10540
10552
|
(_b = this.store) === null || _b === void 0 ? void 0 : _b.setIntegrationName(kit.integrationName);
|
|
10541
10553
|
}
|
|
10542
|
-
(_c = this.loggingService) === null || _c === void 0 ? void 0 : _c.log({
|
|
10543
|
-
message: 'RoktManager: Kit attached, Rokt is ready',
|
|
10544
|
-
code: ErrorCodes.ROKT_KIT_ATTACHED
|
|
10545
|
-
});
|
|
10546
10554
|
this.processMessageQueue();
|
|
10547
10555
|
try {
|
|
10548
|
-
(
|
|
10556
|
+
(_c = this.onReadyCallback) === null || _c === void 0 ? void 0 : _c.call(this);
|
|
10549
10557
|
} catch (e) {
|
|
10550
|
-
(
|
|
10558
|
+
(_d = this.logger) === null || _d === void 0 ? void 0 : _d.error('RoktManager: Error in onReadyCallback: ' + e);
|
|
10551
10559
|
}
|
|
10552
10560
|
};
|
|
10553
10561
|
/**
|
|
@@ -10566,11 +10574,11 @@ var mParticle = (function () {
|
|
|
10566
10574
|
* });
|
|
10567
10575
|
*/
|
|
10568
10576
|
RoktManager.prototype.selectPlacements = function (options) {
|
|
10569
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j;
|
|
10577
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m;
|
|
10570
10578
|
return __awaiter(this, void 0, void 0, function () {
|
|
10571
|
-
var attributes, sandboxValue, mappedAttributes, attributesToLog, currentUserIdentities, currentEmail, newEmail, currentHashedEmail, newHashedEmail, isValidHashedEmailIdentityType, emailChanged, hashedEmailChanged, newIdentities, msg, msg, errorMessage, finalUserIdentities, enrichedAttributes, hashedEmail, enrichedOptions;
|
|
10579
|
+
var attributes, sandboxValue, mappedAttributes, attributesToLog, currentUserIdentities, currentEmail, newEmail, currentHashedEmail, newHashedEmail, isValidHashedEmailIdentityType, emailChanged, hashedEmailChanged, newIdentities, msg, msg, errorMessage, finalUserIdentities, enrichedAttributes, hashedEmail, capturedAttrs, passbackId, enrichedOptions;
|
|
10572
10580
|
var _this = this;
|
|
10573
|
-
return __generator(this, function (
|
|
10581
|
+
return __generator(this, function (_o) {
|
|
10574
10582
|
(_a = this.captureTiming) === null || _a === void 0 ? void 0 : _a.call(this, PerformanceMarkType.JointSdkSelectPlacements);
|
|
10575
10583
|
// Queue if kit isn't ready OR if identity is in flight
|
|
10576
10584
|
if (!this.isReady() || ((_b = this.store) === null || _b === void 0 ? void 0 : _b.identityCallInFlight)) {
|
|
@@ -10656,6 +10664,14 @@ var mParticle = (function () {
|
|
|
10656
10664
|
enrichedAttributes.emailsha256 = hashedEmail;
|
|
10657
10665
|
}
|
|
10658
10666
|
}
|
|
10667
|
+
if (!enrichedAttributes[PASSBACK_CONVERSION_TRACKING_ID]) {
|
|
10668
|
+
(_k = this.integrationCapture) === null || _k === void 0 ? void 0 : _k.capture();
|
|
10669
|
+
capturedAttrs = (_l = this.integrationCapture) === null || _l === void 0 ? void 0 : _l.getClickIdsAsIntegrationAttributes();
|
|
10670
|
+
passbackId = (_m = capturedAttrs === null || capturedAttrs === void 0 ? void 0 : capturedAttrs[PARTNER_MODULE_IDS.Rokt]) === null || _m === void 0 ? void 0 : _m[PASSBACK_CONVERSION_TRACKING_ID];
|
|
10671
|
+
if (passbackId) {
|
|
10672
|
+
enrichedAttributes[PASSBACK_CONVERSION_TRACKING_ID] = passbackId;
|
|
10673
|
+
}
|
|
10674
|
+
}
|
|
10659
10675
|
this.filters.filteredUser = this.currentUser || this.filters.filteredUser || null;
|
|
10660
10676
|
enrichedOptions = __assign(__assign({}, options), {
|
|
10661
10677
|
attributes: enrichedAttributes
|
|
@@ -12145,7 +12161,7 @@ var mParticle = (function () {
|
|
|
12145
12161
|
domain: config === null || config === void 0 ? void 0 : config.domain
|
|
12146
12162
|
};
|
|
12147
12163
|
// https://go.mparticle.com/work/SQDSDKS-7339
|
|
12148
|
-
mpInstance._RoktManager.init(roktConfig, roktFilteredUser, mpInstance.Identity, mpInstance._Store, mpInstance.Logger, roktOptions, mpInstance.captureTiming, mpInstance._ErrorReportingDispatcher, mpInstance._LoggingDispatcher);
|
|
12164
|
+
mpInstance._RoktManager.init(roktConfig, roktFilteredUser, mpInstance.Identity, mpInstance._Store, mpInstance.Logger, roktOptions, mpInstance.captureTiming, mpInstance._ErrorReportingDispatcher, mpInstance._LoggingDispatcher, mpInstance._IntegrationCapture);
|
|
12149
12165
|
}
|
|
12150
12166
|
mpInstance._Forwarders.processForwarders(config, mpInstance._APIClient.prepareForwardingStats);
|
|
12151
12167
|
mpInstance._Forwarders.processPixelConfigs(config);
|
|
@@ -4,7 +4,6 @@ export declare const ErrorCodes: {
|
|
|
4
4
|
readonly UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION";
|
|
5
5
|
readonly IDENTITY_REQUEST: "IDENTITY_REQUEST";
|
|
6
6
|
readonly IDENTITY_MISMATCH: "IDENTITY_MISMATCH";
|
|
7
|
-
readonly ROKT_KIT_ATTACHED: "ROKT_KIT_ATTACHED";
|
|
8
7
|
readonly MP_DEPRECATED_METHOD_USAGE: "MP_DEPRECATED_METHOD_USAGE";
|
|
9
8
|
};
|
|
10
9
|
export type ErrorCodes = valueof<typeof ErrorCodes>;
|
|
@@ -7,6 +7,7 @@ import { SDKLoggerApi } from "./sdkRuntimeModels";
|
|
|
7
7
|
import { IStore, LocalSessionAttributes } from "./store";
|
|
8
8
|
import { IErrorReportingService, ILoggingService } from "./reporting/types";
|
|
9
9
|
import { IRoktLauncherOptions } from "./roktLauncherOptions";
|
|
10
|
+
import IntegrationCapture from "./integrationCapture";
|
|
10
11
|
export type RoktAttributeValueArray = Array<string | number | boolean>;
|
|
11
12
|
export type RoktAttributeValueType = string | number | boolean | undefined | null;
|
|
12
13
|
export type RoktAttributeValue = RoktAttributeValueType | RoktAttributeValueArray;
|
|
@@ -82,6 +83,7 @@ export default class RoktManager {
|
|
|
82
83
|
private domain?;
|
|
83
84
|
private mappedEmailShaIdentityType?;
|
|
84
85
|
private captureTiming?;
|
|
86
|
+
private integrationCapture?;
|
|
85
87
|
private onReadyCallback;
|
|
86
88
|
private initialized;
|
|
87
89
|
private isShoppableAdsLoaded;
|
|
@@ -103,7 +105,7 @@ export default class RoktManager {
|
|
|
103
105
|
*
|
|
104
106
|
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
105
107
|
*/
|
|
106
|
-
init(roktConfig: IKitConfigs, filteredUser: IMParticleUser, identityService: SDKIdentityApi, store: IStore, logger?: SDKLoggerApi, options?: IRoktOptions, captureTiming?: (metricsName: string) => void, errorReporter?: IErrorReportingService, loggingService?: ILoggingService): void;
|
|
108
|
+
init(roktConfig: IKitConfigs, filteredUser: IMParticleUser, identityService: SDKIdentityApi, store: IStore, logger?: SDKLoggerApi, options?: IRoktOptions, captureTiming?: (metricsName: string) => void, errorReporter?: IErrorReportingService, loggingService?: ILoggingService, integrationCapture?: IntegrationCapture): void;
|
|
107
109
|
get isInitialized(): boolean;
|
|
108
110
|
attachKit(kit: IRoktKit): void;
|
|
109
111
|
/**
|
package/package.json
CHANGED
package/src/mp-instance.ts
CHANGED
|
@@ -1560,7 +1560,8 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
|
1560
1560
|
roktOptions,
|
|
1561
1561
|
mpInstance.captureTiming,
|
|
1562
1562
|
mpInstance._ErrorReportingDispatcher,
|
|
1563
|
-
mpInstance._LoggingDispatcher
|
|
1563
|
+
mpInstance._LoggingDispatcher,
|
|
1564
|
+
mpInstance._IntegrationCapture,
|
|
1564
1565
|
);
|
|
1565
1566
|
}
|
|
1566
1567
|
|
package/src/pre-init-utils.ts
CHANGED
|
@@ -25,9 +25,21 @@ export const processReadyQueue = (readyQueue): Function[] => {
|
|
|
25
25
|
};
|
|
26
26
|
|
|
27
27
|
const processPreloadedItem = (readyQueueItem): void => {
|
|
28
|
-
|
|
28
|
+
// Operate on a copy of the queued item. The ready queue can be drained more
|
|
29
|
+
// than once (e.g. a synchronous cache-hit identify re-enters processReadyQueue
|
|
30
|
+
// before the outer drain resets the queue). Splicing the shared item array in
|
|
31
|
+
// place would corrupt it on the second pass — ["Identity.login", opts] becomes
|
|
32
|
+
// [opts] — so `method` turns into a non-string/undefined and `method.split('.')`
|
|
33
|
+
// throws. Copying keeps the original item intact for any repeat pass.
|
|
34
|
+
const args = readyQueueItem.slice();
|
|
29
35
|
const method = args.splice(0, 1)[0];
|
|
30
36
|
|
|
37
|
+
// Skip malformed queue entries (empty array or non-string method) instead of
|
|
38
|
+
// throwing an uncaught TypeError from method.split() below.
|
|
39
|
+
if (typeof method !== 'string' || method.length === 0) {
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
|
|
31
43
|
// if the first argument is a method on the base mParticle object, run it
|
|
32
44
|
if (typeof window !== 'undefined' && window.mParticle && window.mParticle[args[0]]) {
|
|
33
45
|
window.mParticle[method].apply(window.mParticle, args);
|
package/src/reporting/types.ts
CHANGED
|
@@ -5,7 +5,6 @@ export const ErrorCodes = {
|
|
|
5
5
|
UNHANDLED_EXCEPTION: 'UNHANDLED_EXCEPTION',
|
|
6
6
|
IDENTITY_REQUEST: 'IDENTITY_REQUEST',
|
|
7
7
|
IDENTITY_MISMATCH: 'IDENTITY_MISMATCH',
|
|
8
|
-
ROKT_KIT_ATTACHED: 'ROKT_KIT_ATTACHED',
|
|
9
8
|
MP_DEPRECATED_METHOD_USAGE: 'MP_DEPRECATED_METHOD_USAGE',
|
|
10
9
|
} as const;
|
|
11
10
|
|
package/src/roktManager.ts
CHANGED
|
@@ -18,6 +18,10 @@ import { UserIdentities } from "@mparticle/web-sdk";
|
|
|
18
18
|
import { IdentityType, PerformanceMarkType } from "./types";
|
|
19
19
|
import { ErrorCodes, IErrorReportingService, ILoggingService, WSDKErrorSeverity } from "./reporting/types";
|
|
20
20
|
import { IRoktLauncherOptions, normalizeRoktLauncherOptions } from "./roktLauncherOptions";
|
|
21
|
+
import { PARTNER_MODULE_IDS } from "./cookieSyncManager";
|
|
22
|
+
import IntegrationCapture from "./integrationCapture";
|
|
23
|
+
|
|
24
|
+
const PASSBACK_CONVERSION_TRACKING_ID = 'passbackconversiontrackingid';
|
|
21
25
|
|
|
22
26
|
// https://docs.rokt.com/developers/integration-guides/web/library/attributes
|
|
23
27
|
export type RoktAttributeValueArray = Array<string | number | boolean>;
|
|
@@ -118,6 +122,7 @@ export default class RoktManager {
|
|
|
118
122
|
private domain?: string;
|
|
119
123
|
private mappedEmailShaIdentityType?: string | null;
|
|
120
124
|
private captureTiming?: (metricsName: string) => void;
|
|
125
|
+
private integrationCapture?: IntegrationCapture;
|
|
121
126
|
private onReadyCallback: (() => void) | null = null;
|
|
122
127
|
private initialized: boolean = false;
|
|
123
128
|
private isShoppableAdsLoaded: boolean = false;
|
|
@@ -152,7 +157,8 @@ export default class RoktManager {
|
|
|
152
157
|
options?: IRoktOptions,
|
|
153
158
|
captureTiming?: (metricsName: string) => void,
|
|
154
159
|
errorReporter?: IErrorReportingService,
|
|
155
|
-
loggingService?: ILoggingService
|
|
160
|
+
loggingService?: ILoggingService,
|
|
161
|
+
integrationCapture?: IntegrationCapture,
|
|
156
162
|
): void {
|
|
157
163
|
const { userAttributeFilters, settings } = roktConfig || {};
|
|
158
164
|
const { placementAttributesMapping, hashedEmailUserIdentityType } = settings || {};
|
|
@@ -164,6 +170,7 @@ export default class RoktManager {
|
|
|
164
170
|
this.errorReporter = errorReporter;
|
|
165
171
|
this.loggingService = loggingService;
|
|
166
172
|
this.captureTiming = captureTiming;
|
|
173
|
+
this.integrationCapture = integrationCapture;
|
|
167
174
|
|
|
168
175
|
this.captureTiming?.(PerformanceMarkType.JointSdkRoktKitInit);
|
|
169
176
|
|
|
@@ -216,11 +223,6 @@ export default class RoktManager {
|
|
|
216
223
|
this.store?.setIntegrationName(kit.integrationName);
|
|
217
224
|
}
|
|
218
225
|
|
|
219
|
-
this.loggingService?.log({
|
|
220
|
-
message: 'RoktManager: Kit attached, Rokt is ready',
|
|
221
|
-
code: ErrorCodes.ROKT_KIT_ATTACHED,
|
|
222
|
-
});
|
|
223
|
-
|
|
224
226
|
this.processMessageQueue();
|
|
225
227
|
|
|
226
228
|
try {
|
|
@@ -371,6 +373,15 @@ export default class RoktManager {
|
|
|
371
373
|
}
|
|
372
374
|
}
|
|
373
375
|
|
|
376
|
+
if (!enrichedAttributes[PASSBACK_CONVERSION_TRACKING_ID]) {
|
|
377
|
+
this.integrationCapture?.capture();
|
|
378
|
+
const capturedAttrs = this.integrationCapture?.getClickIdsAsIntegrationAttributes();
|
|
379
|
+
const passbackId = capturedAttrs?.[PARTNER_MODULE_IDS.Rokt]?.[PASSBACK_CONVERSION_TRACKING_ID];
|
|
380
|
+
if (passbackId) {
|
|
381
|
+
enrichedAttributes[PASSBACK_CONVERSION_TRACKING_ID] = passbackId;
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
|
|
374
385
|
this.filters.filteredUser = this.currentUser || this.filters.filteredUser || null;
|
|
375
386
|
|
|
376
387
|
const enrichedOptions = {
|