@mparticle/web-sdk 2.54.0 → 2.54.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mparticle.common.js +8 -5
- package/dist/mparticle.esm.js +8 -5
- package/dist/mparticle.js +63 -42
- package/package.json +1 -1
- package/src/identity.js +1 -4
- package/src/roktManager.ts +71 -30
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.54.
|
|
18
|
+
var version = "2.54.1";
|
|
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
|
|
@@ -1296,7 +1296,7 @@ return a._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===d.audie
|
|
|
1296
1296
|
* @deprecated
|
|
1297
1297
|
*/getCartProducts:function getCartProducts(){return a.Logger.warning(generateDeprecationMessage("Identity.getCurrentUser().getCart().getCartProducts()",!0,"eCommerce.logProductAction()","https://docs.mparticle.com/developers/sdk/web/commerce-tracking")),[]}}},this.parseIdentityResponse=function(b,d,f,g,h,i,j){var k,l,m,n=a.Identity.getUser(d),o=n?n.getMPID():null,p=n?n.getUserIdentities().userIdentities:{},q={};a._Store.identityCallInFlight=!1;try{var r,s,t;if(a.Logger.verbose("Parsing \""+h+"\" identity response from server"),l=null!==(r=b.responseText)&&void 0!==r?r:null,a._Store.isLoggedIn=(null===(s=l)||void 0===s?void 0:s.is_logged_in)||!1,hasMPIDChanged(n,l)&&(a._Store.mpid=l.mpid,n&&a._Persistence.setLastSeenTime(d),k=!a._Persistence.getFirstSeenTime(l.mpid),a._Persistence.setFirstSeenTime(l.mpid)),b.status===HTTP_OK){c(CacheIdentity)&&cacheOrClearIdCache(h,i,e.idCache,b,j);var u=e.IdentityAPI.getUser(l.mpid),v=u?u.getUserIdentities().userIdentities:{};h===Modify$1?(q=a._Identity.IdentityRequest.combineUserIdentities(p,g.userIdentities),a._Store.setUserIdentities(d,q)):(h===Identify&&n&&l.mpid===o&&a._Persistence.setFirstSeenTime(l.mpid),a._Store.addMpidToSessionHistory(l.mpid,d),a._CookieSyncManager.attemptCookieSync(l.mpid,k),a._Persistence.swapCurrentUser(d,l.mpid,a._Store.currentSessionMPIDs),g&&!isEmpty(g.userIdentities)&&(q=e.IdentityRequest.combineUserIdentities(v,g.userIdentities)),a._Store.setUserIdentities(l.mpid,q),a._Persistence.update(),a._Store.syncPersistenceData(),a._Persistence.findPrevCookiesBasedOnUI(g),a._Store.context=l.context||a._Store.context),m=a.Identity.getCurrentUser(),tryOnUserAlias(n,m,g,a.Logger);var w=a._Persistence.getPersistence();m&&(a._Persistence.storeDataInMemory(w,m.getMPID()),e.reinitForwardersOnUserChange(n,m),e.setForwarderCallbacks(m,h));var x=IdentityType.getNewIdentitiesByName(q),y=h===Modify$1?p:v;// https://go.mparticle.com/work/SQDSDKS-6501
|
|
1298
1298
|
e.sendUserIdentityChangeEvent(x,h,l.mpid,y);}if(f){var z=0===b.status?HTTPCodes$2.noHttpCoverage:b.status;a._Helpers.invokeCallback(f,z,l||null,m);}else l&&!isEmpty(l.errors)&&// https://go.mparticle.com/work/SQDSDKS-6500
|
|
1299
|
-
a.Logger.error("Received HTTP response code of "+b.status+" - "+l.errors[0].message);a.Logger.verbose("Successfully parsed Identity Response"),null===(t=a._APIClient)||void 0===t||t.processQueuedEvents();}catch(c){f&&a._Helpers.invokeCallback(f,b.status,l||null),a.Logger.error("Error parsing JSON response from Identity server: "+c);}a._Store.isInitialized=!0,a._RoktManager.
|
|
1299
|
+
a.Logger.error("Received HTTP response code of "+b.status+" - "+l.errors[0].message);a.Logger.verbose("Successfully parsed Identity Response"),null===(t=a._APIClient)||void 0===t||t.processQueuedEvents();}catch(c){f&&a._Helpers.invokeCallback(f,b.status,l||null),a.Logger.error("Error parsing JSON response from Identity server: "+c);}a._Store.isInitialized=!0,a._RoktManager.onIdentityComplete(),a._preInit.readyQueue=processReadyQueue(a._preInit.readyQueue);},this.sendUserIdentityChangeEvent=function(b,c,d,f){if(d||c===Modify$1)// https://go.mparticle.com/work/SQDSDKS-6501
|
|
1300
1300
|
{// https://go.mparticle.com/work/SQDSDKS-6354
|
|
1301
1301
|
var g=this.IdentityAPI.getUser(d);for(var h in b)// Verifies a change actually happened
|
|
1302
1302
|
if(f[h]!==b[h]){var i,j=!f[h],k=e.createUserIdentityChange(h,b[h],f[h],j,g);// If a new identity type was introduced when the identity changes
|
|
@@ -1467,9 +1467,12 @@ var RoktManager=/** @class */function(){function a(){this.kit=null,this.filters=
|
|
|
1467
1467
|
// as that is independent of this setting, though they share the same name.
|
|
1468
1468
|
var o=(null===f||void 0===f?void 0:f.sandbox)||!1;// Launcher options are set here for the kit to pick up and pass through
|
|
1469
1469
|
// to the Rokt Launcher.
|
|
1470
|
-
this.launcherOptions=__assign({sandbox:o},null===f||void 0===f?void 0:f.launcherOptions),(null===f||void 0===f?void 0:f.domain)&&(this.domain=f.domain);},a.prototype.attachKit=function(a){this.kit=a,this.processMessageQueue();},a.prototype.selectPlacements=function(a){var b,c;return __awaiter(this,void 0,void 0,function(){var
|
|
1471
|
-
|
|
1472
|
-
|
|
1470
|
+
this.launcherOptions=__assign({sandbox:o},null===f||void 0===f?void 0:f.launcherOptions),(null===f||void 0===f?void 0:f.domain)&&(this.domain=f.domain);},a.prototype.attachKit=function(a){this.kit=a,this.processMessageQueue();},a.prototype.selectPlacements=function(a){var b,c,d,e,f;return __awaiter(this,void 0,void 0,function(){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y=this;return __generator(this,function(z){switch(z.label){case 0:// Queue if kit isn't ready OR if identity is in flight
|
|
1471
|
+
if(this.captureTiming&&this.captureTiming(PerformanceMarkType.JointSdkSelectPlacements),!this.isReady()||(null===(b=this.store)||void 0===b?void 0:b.identityCallInFlight))return [2/*return*/,this.deferredCall("selectPlacements",a)];z.label=1;case 1:if(z.trys.push([1,6,,7]),g=a.attributes,h=(null===g||void 0===g?void 0:g.sandbox)||null,i=this.mapPlacementAttributes(g,this.placementAttributesMapping),this.currentUser=this.identityService.getCurrentUser(),j=(null===(d=null===(c=this.currentUser)||void 0===c?void 0:c.getUserIdentities())||void 0===d?void 0:d.userIdentities)||{},k=j.email,l=i.email,m=void 0,n=void 0,o=this.mappedEmailShaIdentityType&&!1!==IdentityType.getIdentityType(this.mappedEmailShaIdentityType),o&&(m=j[this.mappedEmailShaIdentityType],n=i.emailsha256||i[this.mappedEmailShaIdentityType]||void 0),p=this.hasIdentityChanged(k,l),q=this.hasIdentityChanged(m,n),r={},p&&(r.email=l,l&&this.logger.warning("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.")),q&&(r[this.mappedEmailShaIdentityType]=n,this.logger.warning("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.")),!!isEmpty(r))return [3/*break*/,5];z.label=2;case 2:return z.trys.push([2,4,,5]),[4/*yield*/,new Promise(function(a){y.identityService.identify({userIdentities:__assign(__assign({},j),r)},function(){a();});})];case 3:return z.sent(),[3/*break*/,5];case 4:return s=z.sent(),this.logger.error("Failed to identify user with new email: "+JSON.stringify(s)),[3/*break*/,5];case 5:return this.currentUser=this.identityService.getCurrentUser(),t=(null===(f=null===(e=this.currentUser)||void 0===e?void 0:e.getUserIdentities())||void 0===f?void 0:f.userIdentities)||{},this.setUserAttributes(i),u=__assign(__assign({},i),null===h?{}:{sandbox:h}),t.email&&!u.email&&(u.email=t.email),o&&(v=t[this.mappedEmailShaIdentityType],v&&!u.emailsha256&&!u[this.mappedEmailShaIdentityType]&&(u.emailsha256=v)),this.filters.filteredUser=this.currentUser||this.filters.filteredUser||null,w=__assign(__assign({},a),{attributes:u}),[2/*return*/,this.kit.selectPlacements(w)];case 6:return x=z.sent(),[2/*return*/,Promise.reject(x instanceof Error?x:new Error("Unknown error occurred"))];case 7: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.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
|
|
1472
|
+
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
|
|
1473
|
+
this.messageQueue.clear(),c.forEach(function(a){var c,d;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")));null===(d=b.logger)||void 0===d?void 0:d.verbose("RoktManager: Processing queued message: ".concat(a.methodName," with payload: ").concat(JSON.stringify(a.payload)));// Capture resolve/reject functions before async processing
|
|
1474
|
+
var e=a.resolve,f=a.reject,g=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)),f&&f(c);};try{var h=b[a.methodName](a.payload);// Handle both sync and async methods
|
|
1475
|
+
Promise.resolve(h).then(function(a){e&&e(a);})["catch"](g);}catch(a){g(a);}});}},a.prototype.queueMessage=function(a){this.messageQueue.set(a.messageId,a);},a.prototype.deferredCall=function(a,b){var c=this;return new Promise(function(d,e){var f="".concat(a,"_").concat(generateUniqueId());c.queueMessage({messageId:f,methodName:a,payload:b,resolve:d,reject:e});})},a.prototype.sha256Hex=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d;return __generator(this,function(e){switch(e.label){case 0:return b=new TextEncoder,c=b.encode(a),[4/*yield*/,crypto.subtle.digest("SHA-256",c)];case 1:return d=e.sent(),[2/*return*/,this.arrayBufferToHex(d)]}})})},a.prototype.arrayBufferToHex=function(a){for(var b,c=new Uint8Array(a),d="",e=0;e<c.length;e++)b=c[e].toString(16).padStart(2,"0"),d+=b;return d},a.prototype.hasIdentityChanged=function(a,b){return !!b&&(!a||a!==b);// Values are the same
|
|
1473
1476
|
},a}();
|
|
1474
1477
|
|
|
1475
1478
|
/**
|
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.54.
|
|
18
|
+
var version = "2.54.1";
|
|
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
|
|
@@ -1296,7 +1296,7 @@ return a._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===d.audie
|
|
|
1296
1296
|
* @deprecated
|
|
1297
1297
|
*/getCartProducts:function getCartProducts(){return a.Logger.warning(generateDeprecationMessage("Identity.getCurrentUser().getCart().getCartProducts()",!0,"eCommerce.logProductAction()","https://docs.mparticle.com/developers/sdk/web/commerce-tracking")),[]}}},this.parseIdentityResponse=function(b,d,f,g,h,i,j){var k,l,m,n=a.Identity.getUser(d),o=n?n.getMPID():null,p=n?n.getUserIdentities().userIdentities:{},q={};a._Store.identityCallInFlight=!1;try{var r,s,t;if(a.Logger.verbose("Parsing \""+h+"\" identity response from server"),l=null!==(r=b.responseText)&&void 0!==r?r:null,a._Store.isLoggedIn=(null===(s=l)||void 0===s?void 0:s.is_logged_in)||!1,hasMPIDChanged(n,l)&&(a._Store.mpid=l.mpid,n&&a._Persistence.setLastSeenTime(d),k=!a._Persistence.getFirstSeenTime(l.mpid),a._Persistence.setFirstSeenTime(l.mpid)),b.status===HTTP_OK){c(CacheIdentity)&&cacheOrClearIdCache(h,i,e.idCache,b,j);var u=e.IdentityAPI.getUser(l.mpid),v=u?u.getUserIdentities().userIdentities:{};h===Modify$1?(q=a._Identity.IdentityRequest.combineUserIdentities(p,g.userIdentities),a._Store.setUserIdentities(d,q)):(h===Identify&&n&&l.mpid===o&&a._Persistence.setFirstSeenTime(l.mpid),a._Store.addMpidToSessionHistory(l.mpid,d),a._CookieSyncManager.attemptCookieSync(l.mpid,k),a._Persistence.swapCurrentUser(d,l.mpid,a._Store.currentSessionMPIDs),g&&!isEmpty(g.userIdentities)&&(q=e.IdentityRequest.combineUserIdentities(v,g.userIdentities)),a._Store.setUserIdentities(l.mpid,q),a._Persistence.update(),a._Store.syncPersistenceData(),a._Persistence.findPrevCookiesBasedOnUI(g),a._Store.context=l.context||a._Store.context),m=a.Identity.getCurrentUser(),tryOnUserAlias(n,m,g,a.Logger);var w=a._Persistence.getPersistence();m&&(a._Persistence.storeDataInMemory(w,m.getMPID()),e.reinitForwardersOnUserChange(n,m),e.setForwarderCallbacks(m,h));var x=IdentityType.getNewIdentitiesByName(q),y=h===Modify$1?p:v;// https://go.mparticle.com/work/SQDSDKS-6501
|
|
1298
1298
|
e.sendUserIdentityChangeEvent(x,h,l.mpid,y);}if(f){var z=0===b.status?HTTPCodes$2.noHttpCoverage:b.status;a._Helpers.invokeCallback(f,z,l||null,m);}else l&&!isEmpty(l.errors)&&// https://go.mparticle.com/work/SQDSDKS-6500
|
|
1299
|
-
a.Logger.error("Received HTTP response code of "+b.status+" - "+l.errors[0].message);a.Logger.verbose("Successfully parsed Identity Response"),null===(t=a._APIClient)||void 0===t||t.processQueuedEvents();}catch(c){f&&a._Helpers.invokeCallback(f,b.status,l||null),a.Logger.error("Error parsing JSON response from Identity server: "+c);}a._Store.isInitialized=!0,a._RoktManager.
|
|
1299
|
+
a.Logger.error("Received HTTP response code of "+b.status+" - "+l.errors[0].message);a.Logger.verbose("Successfully parsed Identity Response"),null===(t=a._APIClient)||void 0===t||t.processQueuedEvents();}catch(c){f&&a._Helpers.invokeCallback(f,b.status,l||null),a.Logger.error("Error parsing JSON response from Identity server: "+c);}a._Store.isInitialized=!0,a._RoktManager.onIdentityComplete(),a._preInit.readyQueue=processReadyQueue(a._preInit.readyQueue);},this.sendUserIdentityChangeEvent=function(b,c,d,f){if(d||c===Modify$1)// https://go.mparticle.com/work/SQDSDKS-6501
|
|
1300
1300
|
{// https://go.mparticle.com/work/SQDSDKS-6354
|
|
1301
1301
|
var g=this.IdentityAPI.getUser(d);for(var h in b)// Verifies a change actually happened
|
|
1302
1302
|
if(f[h]!==b[h]){var i,j=!f[h],k=e.createUserIdentityChange(h,b[h],f[h],j,g);// If a new identity type was introduced when the identity changes
|
|
@@ -1467,9 +1467,12 @@ var RoktManager=/** @class */function(){function a(){this.kit=null,this.filters=
|
|
|
1467
1467
|
// as that is independent of this setting, though they share the same name.
|
|
1468
1468
|
var o=(null===f||void 0===f?void 0:f.sandbox)||!1;// Launcher options are set here for the kit to pick up and pass through
|
|
1469
1469
|
// to the Rokt Launcher.
|
|
1470
|
-
this.launcherOptions=__assign({sandbox:o},null===f||void 0===f?void 0:f.launcherOptions),(null===f||void 0===f?void 0:f.domain)&&(this.domain=f.domain);},a.prototype.attachKit=function(a){this.kit=a,this.processMessageQueue();},a.prototype.selectPlacements=function(a){var b,c;return __awaiter(this,void 0,void 0,function(){var
|
|
1471
|
-
|
|
1472
|
-
|
|
1470
|
+
this.launcherOptions=__assign({sandbox:o},null===f||void 0===f?void 0:f.launcherOptions),(null===f||void 0===f?void 0:f.domain)&&(this.domain=f.domain);},a.prototype.attachKit=function(a){this.kit=a,this.processMessageQueue();},a.prototype.selectPlacements=function(a){var b,c,d,e,f;return __awaiter(this,void 0,void 0,function(){var g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y=this;return __generator(this,function(z){switch(z.label){case 0:// Queue if kit isn't ready OR if identity is in flight
|
|
1471
|
+
if(this.captureTiming&&this.captureTiming(PerformanceMarkType.JointSdkSelectPlacements),!this.isReady()||(null===(b=this.store)||void 0===b?void 0:b.identityCallInFlight))return [2/*return*/,this.deferredCall("selectPlacements",a)];z.label=1;case 1:if(z.trys.push([1,6,,7]),g=a.attributes,h=(null===g||void 0===g?void 0:g.sandbox)||null,i=this.mapPlacementAttributes(g,this.placementAttributesMapping),this.currentUser=this.identityService.getCurrentUser(),j=(null===(d=null===(c=this.currentUser)||void 0===c?void 0:c.getUserIdentities())||void 0===d?void 0:d.userIdentities)||{},k=j.email,l=i.email,m=void 0,n=void 0,o=this.mappedEmailShaIdentityType&&!1!==IdentityType.getIdentityType(this.mappedEmailShaIdentityType),o&&(m=j[this.mappedEmailShaIdentityType],n=i.emailsha256||i[this.mappedEmailShaIdentityType]||void 0),p=this.hasIdentityChanged(k,l),q=this.hasIdentityChanged(m,n),r={},p&&(r.email=l,l&&this.logger.warning("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.")),q&&(r[this.mappedEmailShaIdentityType]=n,this.logger.warning("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.")),!!isEmpty(r))return [3/*break*/,5];z.label=2;case 2:return z.trys.push([2,4,,5]),[4/*yield*/,new Promise(function(a){y.identityService.identify({userIdentities:__assign(__assign({},j),r)},function(){a();});})];case 3:return z.sent(),[3/*break*/,5];case 4:return s=z.sent(),this.logger.error("Failed to identify user with new email: "+JSON.stringify(s)),[3/*break*/,5];case 5:return this.currentUser=this.identityService.getCurrentUser(),t=(null===(f=null===(e=this.currentUser)||void 0===e?void 0:e.getUserIdentities())||void 0===f?void 0:f.userIdentities)||{},this.setUserAttributes(i),u=__assign(__assign({},i),null===h?{}:{sandbox:h}),t.email&&!u.email&&(u.email=t.email),o&&(v=t[this.mappedEmailShaIdentityType],v&&!u.emailsha256&&!u[this.mappedEmailShaIdentityType]&&(u.emailsha256=v)),this.filters.filteredUser=this.currentUser||this.filters.filteredUser||null,w=__assign(__assign({},a),{attributes:u}),[2/*return*/,this.kit.selectPlacements(w)];case 6:return x=z.sent(),[2/*return*/,Promise.reject(x instanceof Error?x:new Error("Unknown error occurred"))];case 7: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.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
|
|
1472
|
+
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
|
|
1473
|
+
this.messageQueue.clear(),c.forEach(function(a){var c,d;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")));null===(d=b.logger)||void 0===d?void 0:d.verbose("RoktManager: Processing queued message: ".concat(a.methodName," with payload: ").concat(JSON.stringify(a.payload)));// Capture resolve/reject functions before async processing
|
|
1474
|
+
var e=a.resolve,f=a.reject,g=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)),f&&f(c);};try{var h=b[a.methodName](a.payload);// Handle both sync and async methods
|
|
1475
|
+
Promise.resolve(h).then(function(a){e&&e(a);})["catch"](g);}catch(a){g(a);}});}},a.prototype.queueMessage=function(a){this.messageQueue.set(a.messageId,a);},a.prototype.deferredCall=function(a,b){var c=this;return new Promise(function(d,e){var f="".concat(a,"_").concat(generateUniqueId());c.queueMessage({messageId:f,methodName:a,payload:b,resolve:d,reject:e});})},a.prototype.sha256Hex=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d;return __generator(this,function(e){switch(e.label){case 0:return b=new TextEncoder,c=b.encode(a),[4/*yield*/,crypto.subtle.digest("SHA-256",c)];case 1:return d=e.sent(),[2/*return*/,this.arrayBufferToHex(d)]}})})},a.prototype.arrayBufferToHex=function(a){for(var b,c=new Uint8Array(a),d="",e=0;e<c.length;e++)b=c[e].toString(16).padStart(2,"0"),d+=b;return d},a.prototype.hasIdentityChanged=function(a,b){return !!b&&(!a||a!==b);// Values are the same
|
|
1473
1476
|
},a}();
|
|
1474
1477
|
|
|
1475
1478
|
/**
|
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.54.
|
|
206
|
+
var version = "2.54.1";
|
|
207
207
|
|
|
208
208
|
var Constants = {
|
|
209
209
|
sdkVersion: version,
|
|
@@ -8224,9 +8224,7 @@ var mParticle = (function () {
|
|
|
8224
8224
|
mpInstance.Logger.error('Error parsing JSON response from Identity server: ' + e);
|
|
8225
8225
|
}
|
|
8226
8226
|
mpInstance._Store.isInitialized = true;
|
|
8227
|
-
|
|
8228
|
-
mpInstance._RoktManager.currentUser = mpInstance.Identity.getCurrentUser();
|
|
8229
|
-
}
|
|
8227
|
+
mpInstance._RoktManager.onIdentityComplete();
|
|
8230
8228
|
mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue);
|
|
8231
8229
|
};
|
|
8232
8230
|
|
|
@@ -9765,34 +9763,34 @@ var mParticle = (function () {
|
|
|
9765
9763
|
* });
|
|
9766
9764
|
*/
|
|
9767
9765
|
RoktManager.prototype.selectPlacements = function (options) {
|
|
9768
|
-
var _a, _b;
|
|
9766
|
+
var _a, _b, _c, _d, _e;
|
|
9769
9767
|
return __awaiter(this, void 0, void 0, function () {
|
|
9770
|
-
var attributes, sandboxValue, mappedAttributes, currentUserIdentities_1, currentEmail, newEmail, currentHashedEmail, newHashedEmail, emailChanged, hashedEmailChanged, newIdentities_1, error_1, enrichedAttributes, enrichedOptions, error_2;
|
|
9768
|
+
var attributes, sandboxValue, mappedAttributes, currentUserIdentities_1, currentEmail, newEmail, currentHashedEmail, newHashedEmail, isValidHashedEmailIdentityType, emailChanged, hashedEmailChanged, newIdentities_1, error_1, finalUserIdentities, enrichedAttributes, hashedEmail, enrichedOptions, error_2;
|
|
9771
9769
|
var _this = this;
|
|
9772
|
-
return __generator(this, function (
|
|
9773
|
-
switch (
|
|
9770
|
+
return __generator(this, function (_f) {
|
|
9771
|
+
switch (_f.label) {
|
|
9774
9772
|
case 0:
|
|
9775
9773
|
if (this.captureTiming) {
|
|
9776
9774
|
this.captureTiming(PerformanceMarkType.JointSdkSelectPlacements);
|
|
9777
9775
|
}
|
|
9778
|
-
if
|
|
9776
|
+
// Queue if kit isn't ready OR if identity is in flight
|
|
9777
|
+
if (!this.isReady() || ((_a = this.store) === null || _a === void 0 ? void 0 : _a.identityCallInFlight)) {
|
|
9779
9778
|
return [2 /*return*/, this.deferredCall('selectPlacements', options)];
|
|
9780
9779
|
}
|
|
9781
|
-
|
|
9780
|
+
_f.label = 1;
|
|
9782
9781
|
case 1:
|
|
9783
|
-
|
|
9782
|
+
_f.trys.push([1, 6,, 7]);
|
|
9784
9783
|
attributes = options.attributes;
|
|
9785
9784
|
sandboxValue = (attributes === null || attributes === void 0 ? void 0 : attributes.sandbox) || null;
|
|
9786
9785
|
mappedAttributes = this.mapPlacementAttributes(attributes, this.placementAttributesMapping);
|
|
9787
|
-
// Get current user identities
|
|
9788
9786
|
this.currentUser = this.identityService.getCurrentUser();
|
|
9789
|
-
currentUserIdentities_1 = ((
|
|
9787
|
+
currentUserIdentities_1 = ((_c = (_b = this.currentUser) === null || _b === void 0 ? void 0 : _b.getUserIdentities()) === null || _c === void 0 ? void 0 : _c.userIdentities) || {};
|
|
9790
9788
|
currentEmail = currentUserIdentities_1.email;
|
|
9791
9789
|
newEmail = mappedAttributes.email;
|
|
9792
9790
|
currentHashedEmail = void 0;
|
|
9793
9791
|
newHashedEmail = void 0;
|
|
9794
|
-
|
|
9795
|
-
if (
|
|
9792
|
+
isValidHashedEmailIdentityType = this.mappedEmailShaIdentityType && IdentityType.getIdentityType(this.mappedEmailShaIdentityType) !== false;
|
|
9793
|
+
if (isValidHashedEmailIdentityType) {
|
|
9796
9794
|
currentHashedEmail = currentUserIdentities_1[this.mappedEmailShaIdentityType];
|
|
9797
9795
|
newHashedEmail = mappedAttributes['emailsha256'] || mappedAttributes[this.mappedEmailShaIdentityType] || undefined;
|
|
9798
9796
|
}
|
|
@@ -9810,9 +9808,9 @@ var mParticle = (function () {
|
|
|
9810
9808
|
this.logger.warning("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.");
|
|
9811
9809
|
}
|
|
9812
9810
|
if (!!isEmpty(newIdentities_1)) return [3 /*break*/, 5];
|
|
9813
|
-
|
|
9811
|
+
_f.label = 2;
|
|
9814
9812
|
case 2:
|
|
9815
|
-
|
|
9813
|
+
_f.trys.push([2, 4,, 5]);
|
|
9816
9814
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
9817
9815
|
_this.identityService.identify({
|
|
9818
9816
|
userIdentities: __assign(__assign({}, currentUserIdentities_1), newIdentities_1)
|
|
@@ -9821,23 +9819,38 @@ var mParticle = (function () {
|
|
|
9821
9819
|
});
|
|
9822
9820
|
})];
|
|
9823
9821
|
case 3:
|
|
9824
|
-
|
|
9822
|
+
_f.sent();
|
|
9825
9823
|
return [3 /*break*/, 5];
|
|
9826
9824
|
case 4:
|
|
9827
|
-
error_1 =
|
|
9825
|
+
error_1 = _f.sent();
|
|
9828
9826
|
this.logger.error('Failed to identify user with new email: ' + JSON.stringify(error_1));
|
|
9829
9827
|
return [3 /*break*/, 5];
|
|
9830
9828
|
case 5:
|
|
9829
|
+
// Refresh current user identities to ensure we have the latest values before building enrichedAttributes
|
|
9830
|
+
this.currentUser = this.identityService.getCurrentUser();
|
|
9831
|
+
finalUserIdentities = ((_e = (_d = this.currentUser) === null || _d === void 0 ? void 0 : _d.getUserIdentities()) === null || _e === void 0 ? void 0 : _e.userIdentities) || {};
|
|
9831
9832
|
this.setUserAttributes(mappedAttributes);
|
|
9832
9833
|
enrichedAttributes = __assign(__assign({}, mappedAttributes), sandboxValue !== null ? {
|
|
9833
9834
|
sandbox: sandboxValue
|
|
9834
9835
|
} : {});
|
|
9836
|
+
// Propagate email from current user identities if not already in attributes
|
|
9837
|
+
if (finalUserIdentities.email && !enrichedAttributes.email) {
|
|
9838
|
+
enrichedAttributes.email = finalUserIdentities.email;
|
|
9839
|
+
}
|
|
9840
|
+
// Propagate emailsha256 from current user identities if not already in attributes
|
|
9841
|
+
if (isValidHashedEmailIdentityType) {
|
|
9842
|
+
hashedEmail = finalUserIdentities[this.mappedEmailShaIdentityType];
|
|
9843
|
+
if (hashedEmail && !enrichedAttributes.emailsha256 && !enrichedAttributes[this.mappedEmailShaIdentityType]) {
|
|
9844
|
+
enrichedAttributes.emailsha256 = hashedEmail;
|
|
9845
|
+
}
|
|
9846
|
+
}
|
|
9847
|
+
this.filters.filteredUser = this.currentUser || this.filters.filteredUser || null;
|
|
9835
9848
|
enrichedOptions = __assign(__assign({}, options), {
|
|
9836
9849
|
attributes: enrichedAttributes
|
|
9837
9850
|
});
|
|
9838
9851
|
return [2 /*return*/, this.kit.selectPlacements(enrichedOptions)];
|
|
9839
9852
|
case 6:
|
|
9840
|
-
error_2 =
|
|
9853
|
+
error_2 = _f.sent();
|
|
9841
9854
|
return [2 /*return*/, Promise.reject(error_2 instanceof Error ? error_2 : new Error('Unknown error occurred'))];
|
|
9842
9855
|
case 7:
|
|
9843
9856
|
return [2 /*return*/];
|
|
@@ -10010,6 +10023,13 @@ var mParticle = (function () {
|
|
|
10010
10023
|
}
|
|
10011
10024
|
return mappedAttributes;
|
|
10012
10025
|
};
|
|
10026
|
+
RoktManager.prototype.onIdentityComplete = function () {
|
|
10027
|
+
if (this.isReady()) {
|
|
10028
|
+
this.currentUser = this.identityService.getCurrentUser();
|
|
10029
|
+
// Process any queued selectPlacements calls that were waiting for identity
|
|
10030
|
+
this.processMessageQueue();
|
|
10031
|
+
}
|
|
10032
|
+
};
|
|
10013
10033
|
RoktManager.prototype.processMessageQueue = function () {
|
|
10014
10034
|
var _this = this;
|
|
10015
10035
|
var _a;
|
|
@@ -10017,24 +10037,39 @@ var mParticle = (function () {
|
|
|
10017
10037
|
return;
|
|
10018
10038
|
}
|
|
10019
10039
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.verbose("RoktManager: Processing ".concat(this.messageQueue.size, " queued messages"));
|
|
10020
|
-
this.messageQueue.
|
|
10021
|
-
|
|
10040
|
+
var messagesToProcess = Array.from(this.messageQueue.values());
|
|
10041
|
+
// Clear the queue immediately to prevent re-processing
|
|
10042
|
+
this.messageQueue.clear();
|
|
10043
|
+
messagesToProcess.forEach(function (message) {
|
|
10044
|
+
var _a, _b;
|
|
10022
10045
|
if (!(message.methodName in _this) || !isFunction(_this[message.methodName])) {
|
|
10023
10046
|
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Method ".concat(message.methodName, " not found"));
|
|
10024
10047
|
return;
|
|
10025
10048
|
}
|
|
10026
10049
|
(_b = _this.logger) === null || _b === void 0 ? void 0 : _b.verbose("RoktManager: Processing queued message: ".concat(message.methodName, " with payload: ").concat(JSON.stringify(message.payload)));
|
|
10050
|
+
// Capture resolve/reject functions before async processing
|
|
10051
|
+
var resolve = message.resolve;
|
|
10052
|
+
var reject = message.reject;
|
|
10053
|
+
var handleError = function handleError(error) {
|
|
10054
|
+
var _a;
|
|
10055
|
+
var errorMessage = error instanceof Error ? error.message : String(error);
|
|
10056
|
+
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Error processing message '".concat(message.methodName, "': ").concat(errorMessage));
|
|
10057
|
+
if (reject) {
|
|
10058
|
+
reject(error);
|
|
10059
|
+
}
|
|
10060
|
+
};
|
|
10027
10061
|
try {
|
|
10028
10062
|
var result = _this[message.methodName](message.payload);
|
|
10029
|
-
|
|
10063
|
+
// Handle both sync and async methods
|
|
10064
|
+
Promise.resolve(result).then(function (resolvedResult) {
|
|
10065
|
+
if (resolve) {
|
|
10066
|
+
resolve(resolvedResult);
|
|
10067
|
+
}
|
|
10068
|
+
})["catch"](handleError);
|
|
10030
10069
|
} catch (error) {
|
|
10031
|
-
|
|
10032
|
-
(_c = _this.logger) === null || _c === void 0 ? void 0 : _c.error("RoktManager: Error processing message '".concat(message.methodName, "': ").concat(errorMessage));
|
|
10033
|
-
_this.completePendingPromise(message.messageId, Promise.reject(error));
|
|
10070
|
+
handleError(error);
|
|
10034
10071
|
}
|
|
10035
10072
|
});
|
|
10036
|
-
// Clear the queue after processing all messages
|
|
10037
|
-
this.messageQueue.clear();
|
|
10038
10073
|
};
|
|
10039
10074
|
RoktManager.prototype.queueMessage = function (message) {
|
|
10040
10075
|
this.messageQueue.set(message.messageId, message);
|
|
@@ -10052,20 +10087,6 @@ var mParticle = (function () {
|
|
|
10052
10087
|
});
|
|
10053
10088
|
});
|
|
10054
10089
|
};
|
|
10055
|
-
RoktManager.prototype.completePendingPromise = function (messageId, resultOrError) {
|
|
10056
|
-
if (!messageId || !this.messageQueue.has(messageId)) {
|
|
10057
|
-
return;
|
|
10058
|
-
}
|
|
10059
|
-
var message = this.messageQueue.get(messageId);
|
|
10060
|
-
if (message.resolve) {
|
|
10061
|
-
Promise.resolve(resultOrError).then(function (result) {
|
|
10062
|
-
return message.resolve(result);
|
|
10063
|
-
})["catch"](function (error) {
|
|
10064
|
-
return message.reject(error);
|
|
10065
|
-
});
|
|
10066
|
-
}
|
|
10067
|
-
this.messageQueue["delete"](messageId);
|
|
10068
|
-
};
|
|
10069
10090
|
/**
|
|
10070
10091
|
* Hashes a string input using SHA-256 and returns the hex digest
|
|
10071
10092
|
* Uses the Web Crypto API for secure hashing
|
package/package.json
CHANGED
package/src/identity.js
CHANGED
|
@@ -1372,7 +1372,6 @@ export default function Identity(mpInstance) {
|
|
|
1372
1372
|
: {};
|
|
1373
1373
|
let mpidIsNotInCookies;
|
|
1374
1374
|
let identityApiResult;
|
|
1375
|
-
|
|
1376
1375
|
let newUser;
|
|
1377
1376
|
let newIdentitiesByType = {};
|
|
1378
1377
|
|
|
@@ -1577,9 +1576,7 @@ export default function Identity(mpInstance) {
|
|
|
1577
1576
|
}
|
|
1578
1577
|
mpInstance._Store.isInitialized = true;
|
|
1579
1578
|
|
|
1580
|
-
|
|
1581
|
-
mpInstance._RoktManager.currentUser = mpInstance.Identity.getCurrentUser();
|
|
1582
|
-
}
|
|
1579
|
+
mpInstance._RoktManager.onIdentityComplete();
|
|
1583
1580
|
|
|
1584
1581
|
mpInstance._preInit.readyQueue = processReadyQueue(
|
|
1585
1582
|
mpInstance._preInit.readyQueue
|
package/src/roktManager.ts
CHANGED
|
@@ -184,7 +184,8 @@ export default class RoktManager {
|
|
|
184
184
|
this.captureTiming(PerformanceMarkType.JointSdkSelectPlacements);
|
|
185
185
|
}
|
|
186
186
|
|
|
187
|
-
if
|
|
187
|
+
// Queue if kit isn't ready OR if identity is in flight
|
|
188
|
+
if (!this.isReady() || this.store?.identityCallInFlight) {
|
|
188
189
|
return this.deferredCall<IRoktSelection>('selectPlacements', options);
|
|
189
190
|
}
|
|
190
191
|
|
|
@@ -192,8 +193,7 @@ export default class RoktManager {
|
|
|
192
193
|
const { attributes } = options;
|
|
193
194
|
const sandboxValue = attributes?.sandbox || null;
|
|
194
195
|
const mappedAttributes = this.mapPlacementAttributes(attributes, this.placementAttributesMapping);
|
|
195
|
-
|
|
196
|
-
// Get current user identities
|
|
196
|
+
|
|
197
197
|
this.currentUser = this.identityService.getCurrentUser();
|
|
198
198
|
const currentUserIdentities = this.currentUser?.getUserIdentities()?.userIdentities || {};
|
|
199
199
|
|
|
@@ -204,9 +204,16 @@ export default class RoktManager {
|
|
|
204
204
|
let newHashedEmail: string | undefined;
|
|
205
205
|
|
|
206
206
|
// Hashed email identity is valid if it is set to Other-Other10
|
|
207
|
-
|
|
207
|
+
const isValidHashedEmailIdentityType =
|
|
208
|
+
this.mappedEmailShaIdentityType &&
|
|
209
|
+
IdentityType.getIdentityType(this.mappedEmailShaIdentityType) !== false;
|
|
210
|
+
|
|
211
|
+
if (isValidHashedEmailIdentityType) {
|
|
208
212
|
currentHashedEmail = currentUserIdentities[this.mappedEmailShaIdentityType];
|
|
209
|
-
newHashedEmail =
|
|
213
|
+
newHashedEmail =
|
|
214
|
+
(mappedAttributes['emailsha256'] as string) ||
|
|
215
|
+
(mappedAttributes[this.mappedEmailShaIdentityType] as string) ||
|
|
216
|
+
undefined;
|
|
210
217
|
}
|
|
211
218
|
|
|
212
219
|
const emailChanged = this.hasIdentityChanged(currentEmail, newEmail);
|
|
@@ -242,14 +249,37 @@ export default class RoktManager {
|
|
|
242
249
|
this.logger.error('Failed to identify user with new email: ' + JSON.stringify(error));
|
|
243
250
|
}
|
|
244
251
|
}
|
|
252
|
+
|
|
253
|
+
// Refresh current user identities to ensure we have the latest values before building enrichedAttributes
|
|
254
|
+
this.currentUser = this.identityService.getCurrentUser();
|
|
255
|
+
const finalUserIdentities = this.currentUser?.getUserIdentities()?.userIdentities || {};
|
|
245
256
|
|
|
246
257
|
this.setUserAttributes(mappedAttributes);
|
|
247
258
|
|
|
248
|
-
const enrichedAttributes = {
|
|
259
|
+
const enrichedAttributes: RoktAttributes = {
|
|
249
260
|
...mappedAttributes,
|
|
250
261
|
...(sandboxValue !== null ? { sandbox: sandboxValue } : {}),
|
|
251
262
|
};
|
|
252
263
|
|
|
264
|
+
// Propagate email from current user identities if not already in attributes
|
|
265
|
+
if (finalUserIdentities.email && !enrichedAttributes.email) {
|
|
266
|
+
enrichedAttributes.email = finalUserIdentities.email;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
// Propagate emailsha256 from current user identities if not already in attributes
|
|
270
|
+
if (isValidHashedEmailIdentityType) {
|
|
271
|
+
const hashedEmail = finalUserIdentities[this.mappedEmailShaIdentityType];
|
|
272
|
+
if (
|
|
273
|
+
hashedEmail &&
|
|
274
|
+
!enrichedAttributes.emailsha256 &&
|
|
275
|
+
!enrichedAttributes[this.mappedEmailShaIdentityType]
|
|
276
|
+
) {
|
|
277
|
+
enrichedAttributes.emailsha256 = hashedEmail;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
this.filters.filteredUser = this.currentUser || this.filters.filteredUser || null;
|
|
282
|
+
|
|
253
283
|
const enrichedOptions = {
|
|
254
284
|
...options,
|
|
255
285
|
attributes: enrichedAttributes,
|
|
@@ -405,6 +435,14 @@ export default class RoktManager {
|
|
|
405
435
|
return mappedAttributes;
|
|
406
436
|
}
|
|
407
437
|
|
|
438
|
+
public onIdentityComplete(): void {
|
|
439
|
+
if (this.isReady()) {
|
|
440
|
+
this.currentUser = this.identityService.getCurrentUser();
|
|
441
|
+
// Process any queued selectPlacements calls that were waiting for identity
|
|
442
|
+
this.processMessageQueue();
|
|
443
|
+
}
|
|
444
|
+
}
|
|
445
|
+
|
|
408
446
|
private processMessageQueue(): void {
|
|
409
447
|
if (!this.isReady() || this.messageQueue.size === 0) {
|
|
410
448
|
return;
|
|
@@ -412,7 +450,12 @@ export default class RoktManager {
|
|
|
412
450
|
|
|
413
451
|
this.logger?.verbose(`RoktManager: Processing ${this.messageQueue.size} queued messages`);
|
|
414
452
|
|
|
415
|
-
this.messageQueue.
|
|
453
|
+
const messagesToProcess = Array.from(this.messageQueue.values());
|
|
454
|
+
|
|
455
|
+
// Clear the queue immediately to prevent re-processing
|
|
456
|
+
this.messageQueue.clear();
|
|
457
|
+
|
|
458
|
+
messagesToProcess.forEach((message) => {
|
|
416
459
|
if(!(message.methodName in this) || !isFunction(this[message.methodName])) {
|
|
417
460
|
this.logger?.error(`RoktManager: Method ${message.methodName} not found`);
|
|
418
461
|
|
|
@@ -421,18 +464,32 @@ export default class RoktManager {
|
|
|
421
464
|
|
|
422
465
|
this.logger?.verbose(`RoktManager: Processing queued message: ${message.methodName} with payload: ${JSON.stringify(message.payload)}`);
|
|
423
466
|
|
|
467
|
+
// Capture resolve/reject functions before async processing
|
|
468
|
+
const resolve = message.resolve;
|
|
469
|
+
const reject = message.reject;
|
|
470
|
+
|
|
471
|
+
const handleError = (error: unknown) => {
|
|
472
|
+
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
473
|
+
this.logger?.error(`RoktManager: Error processing message '${message.methodName}': ${errorMessage}`);
|
|
474
|
+
if (reject) {
|
|
475
|
+
reject(error);
|
|
476
|
+
}
|
|
477
|
+
};
|
|
478
|
+
|
|
424
479
|
try {
|
|
425
480
|
const result = (this[message.methodName] as Function)(message.payload);
|
|
426
|
-
|
|
481
|
+
// Handle both sync and async methods
|
|
482
|
+
Promise.resolve(result)
|
|
483
|
+
.then((resolvedResult) => {
|
|
484
|
+
if (resolve) {
|
|
485
|
+
resolve(resolvedResult);
|
|
486
|
+
}
|
|
487
|
+
})
|
|
488
|
+
.catch(handleError);
|
|
427
489
|
} catch (error) {
|
|
428
|
-
|
|
429
|
-
this.logger?.error(`RoktManager: Error processing message '${message.methodName}': ${errorMessage}`);
|
|
430
|
-
this.completePendingPromise(message.messageId, Promise.reject(error));
|
|
490
|
+
handleError(error);
|
|
431
491
|
}
|
|
432
492
|
});
|
|
433
|
-
|
|
434
|
-
// Clear the queue after processing all messages
|
|
435
|
-
this.messageQueue.clear();
|
|
436
493
|
}
|
|
437
494
|
|
|
438
495
|
private queueMessage(message: IRoktMessage): void {
|
|
@@ -453,22 +510,6 @@ export default class RoktManager {
|
|
|
453
510
|
});
|
|
454
511
|
}
|
|
455
512
|
|
|
456
|
-
private completePendingPromise(messageId: string | undefined, resultOrError: any): void {
|
|
457
|
-
if (!messageId || !this.messageQueue.has(messageId)) {
|
|
458
|
-
return;
|
|
459
|
-
}
|
|
460
|
-
|
|
461
|
-
const message = this.messageQueue.get(messageId)!;
|
|
462
|
-
|
|
463
|
-
if (message.resolve) {
|
|
464
|
-
Promise.resolve(resultOrError)
|
|
465
|
-
.then((result) => message.resolve!(result))
|
|
466
|
-
.catch((error) => message.reject!(error));
|
|
467
|
-
}
|
|
468
|
-
|
|
469
|
-
this.messageQueue.delete(messageId);
|
|
470
|
-
}
|
|
471
|
-
|
|
472
513
|
/**
|
|
473
514
|
* Hashes a string input using SHA-256 and returns the hex digest
|
|
474
515
|
* Uses the Web Crypto API for secure hashing
|