@mparticle/web-sdk 2.55.0 → 2.56.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 +3 -3
- package/dist/mparticle.esm.js +3 -3
- package/dist/mparticle.js +14 -13
- package/package.json +1 -1
- package/src/roktManager.ts +2 -1
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.56.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
|
|
@@ -1467,8 +1467,8 @@ 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),this.initialized=!0;},Object.defineProperty(a.prototype,"isInitialized",{get:function get(){return this.initialized},enumerable:!1,configurable:!0}),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
|
|
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)];
|
|
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),this.initialized=!0;},Object.defineProperty(a.prototype,"isInitialized",{get:function get(){return this.initialized},enumerable:!1,configurable:!0}),a.prototype.attachKit=function(a){this.kit=a,this.processMessageQueue();},a.prototype.selectPlacements=function(a){var b,c,d,e,f,g;return __awaiter(this,void 0,void 0,function(){var h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z=this;return __generator(this,function(A){switch(A.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)];A.label=1;case 1:if(A.trys.push([1,6,,7]),h=a.attributes,i=(null===h||void 0===h?void 0:h.sandbox)||null,j=this.mapPlacementAttributes(h,this.placementAttributesMapping),null===(c=this.logger)||void 0===c?void 0:c.verbose("mParticle.Rokt selectPlacements called with attributes:\n".concat(JSON.stringify(h,null,2))),this.currentUser=this.identityService.getCurrentUser(),k=(null===(e=null===(d=this.currentUser)||void 0===d?void 0:d.getUserIdentities())||void 0===e?void 0:e.userIdentities)||{},l=k.email,m=j.email,n=void 0,o=void 0,p=this.mappedEmailShaIdentityType&&!1!==IdentityType.getIdentityType(this.mappedEmailShaIdentityType),p&&(n=k[this.mappedEmailShaIdentityType],o=j.emailsha256||j[this.mappedEmailShaIdentityType]||void 0),q=this.hasIdentityChanged(l,m),r=this.hasIdentityChanged(n,o),s={},q&&(s.email=m,m&&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.")),r&&(s[this.mappedEmailShaIdentityType]=o,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(s))return [3/*break*/,5];A.label=2;case 2:return A.trys.push([2,4,,5]),[4/*yield*/,new Promise(function(a){z.identityService.identify({userIdentities:__assign(__assign({},k),s)},function(){a();});})];case 3:return A.sent(),[3/*break*/,5];case 4:return t=A.sent(),this.logger.error("Failed to identify user with new email: "+JSON.stringify(t)),[3/*break*/,5];case 5:return this.currentUser=this.identityService.getCurrentUser(),u=(null===(g=null===(f=this.currentUser)||void 0===f?void 0:f.getUserIdentities())||void 0===g?void 0:g.userIdentities)||{},this.setUserAttributes(j),v=__assign(__assign({},j),null===i?{}:{sandbox:i}),u.email&&!v.email&&(v.email=u.email),p&&(w=u[this.mappedEmailShaIdentityType],w&&!v.emailsha256&&!v[this.mappedEmailShaIdentityType]&&(v.emailsha256=w)),this.filters.filteredUser=this.currentUser||this.filters.filteredUser||null,x=__assign(__assign({},a),{attributes:v}),[2/*return*/,this.kit.selectPlacements(x)];case 6:return y=A.sent(),[2/*return*/,Promise.reject(y instanceof Error?y: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
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
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
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
|
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.56.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
|
|
@@ -1467,8 +1467,8 @@ 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),this.initialized=!0;},Object.defineProperty(a.prototype,"isInitialized",{get:function get(){return this.initialized},enumerable:!1,configurable:!0}),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
|
|
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)];
|
|
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),this.initialized=!0;},Object.defineProperty(a.prototype,"isInitialized",{get:function get(){return this.initialized},enumerable:!1,configurable:!0}),a.prototype.attachKit=function(a){this.kit=a,this.processMessageQueue();},a.prototype.selectPlacements=function(a){var b,c,d,e,f,g;return __awaiter(this,void 0,void 0,function(){var h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z=this;return __generator(this,function(A){switch(A.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)];A.label=1;case 1:if(A.trys.push([1,6,,7]),h=a.attributes,i=(null===h||void 0===h?void 0:h.sandbox)||null,j=this.mapPlacementAttributes(h,this.placementAttributesMapping),null===(c=this.logger)||void 0===c?void 0:c.verbose("mParticle.Rokt selectPlacements called with attributes:\n".concat(JSON.stringify(h,null,2))),this.currentUser=this.identityService.getCurrentUser(),k=(null===(e=null===(d=this.currentUser)||void 0===d?void 0:d.getUserIdentities())||void 0===e?void 0:e.userIdentities)||{},l=k.email,m=j.email,n=void 0,o=void 0,p=this.mappedEmailShaIdentityType&&!1!==IdentityType.getIdentityType(this.mappedEmailShaIdentityType),p&&(n=k[this.mappedEmailShaIdentityType],o=j.emailsha256||j[this.mappedEmailShaIdentityType]||void 0),q=this.hasIdentityChanged(l,m),r=this.hasIdentityChanged(n,o),s={},q&&(s.email=m,m&&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.")),r&&(s[this.mappedEmailShaIdentityType]=o,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(s))return [3/*break*/,5];A.label=2;case 2:return A.trys.push([2,4,,5]),[4/*yield*/,new Promise(function(a){z.identityService.identify({userIdentities:__assign(__assign({},k),s)},function(){a();});})];case 3:return A.sent(),[3/*break*/,5];case 4:return t=A.sent(),this.logger.error("Failed to identify user with new email: "+JSON.stringify(t)),[3/*break*/,5];case 5:return this.currentUser=this.identityService.getCurrentUser(),u=(null===(g=null===(f=this.currentUser)||void 0===f?void 0:f.getUserIdentities())||void 0===g?void 0:g.userIdentities)||{},this.setUserAttributes(j),v=__assign(__assign({},j),null===i?{}:{sandbox:i}),u.email&&!v.email&&(v.email=u.email),p&&(w=u[this.mappedEmailShaIdentityType],w&&!v.emailsha256&&!v[this.mappedEmailShaIdentityType]&&(v.emailsha256=w)),this.filters.filteredUser=this.currentUser||this.filters.filteredUser||null,x=__assign(__assign({},a),{attributes:v}),[2/*return*/,this.kit.selectPlacements(x)];case 6:return y=A.sent(),[2/*return*/,Promise.reject(y instanceof Error?y: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
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
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
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
|
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.56.0";
|
|
207
207
|
|
|
208
208
|
var Constants = {
|
|
209
209
|
sdkVersion: version,
|
|
@@ -9790,12 +9790,12 @@ var mParticle = (function () {
|
|
|
9790
9790
|
* });
|
|
9791
9791
|
*/
|
|
9792
9792
|
RoktManager.prototype.selectPlacements = function (options) {
|
|
9793
|
-
var _a, _b, _c, _d, _e;
|
|
9793
|
+
var _a, _b, _c, _d, _e, _f;
|
|
9794
9794
|
return __awaiter(this, void 0, void 0, function () {
|
|
9795
9795
|
var attributes, sandboxValue, mappedAttributes, currentUserIdentities_1, currentEmail, newEmail, currentHashedEmail, newHashedEmail, isValidHashedEmailIdentityType, emailChanged, hashedEmailChanged, newIdentities_1, error_1, finalUserIdentities, enrichedAttributes, hashedEmail, enrichedOptions, error_2;
|
|
9796
9796
|
var _this = this;
|
|
9797
|
-
return __generator(this, function (
|
|
9798
|
-
switch (
|
|
9797
|
+
return __generator(this, function (_g) {
|
|
9798
|
+
switch (_g.label) {
|
|
9799
9799
|
case 0:
|
|
9800
9800
|
if (this.captureTiming) {
|
|
9801
9801
|
this.captureTiming(PerformanceMarkType.JointSdkSelectPlacements);
|
|
@@ -9804,14 +9804,15 @@ var mParticle = (function () {
|
|
|
9804
9804
|
if (!this.isReady() || ((_a = this.store) === null || _a === void 0 ? void 0 : _a.identityCallInFlight)) {
|
|
9805
9805
|
return [2 /*return*/, this.deferredCall('selectPlacements', options)];
|
|
9806
9806
|
}
|
|
9807
|
-
|
|
9807
|
+
_g.label = 1;
|
|
9808
9808
|
case 1:
|
|
9809
|
-
|
|
9809
|
+
_g.trys.push([1, 6,, 7]);
|
|
9810
9810
|
attributes = options.attributes;
|
|
9811
9811
|
sandboxValue = (attributes === null || attributes === void 0 ? void 0 : attributes.sandbox) || null;
|
|
9812
9812
|
mappedAttributes = this.mapPlacementAttributes(attributes, this.placementAttributesMapping);
|
|
9813
|
+
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.verbose("mParticle.Rokt selectPlacements called with attributes:\n".concat(JSON.stringify(attributes, null, 2)));
|
|
9813
9814
|
this.currentUser = this.identityService.getCurrentUser();
|
|
9814
|
-
currentUserIdentities_1 = ((
|
|
9815
|
+
currentUserIdentities_1 = ((_d = (_c = this.currentUser) === null || _c === void 0 ? void 0 : _c.getUserIdentities()) === null || _d === void 0 ? void 0 : _d.userIdentities) || {};
|
|
9815
9816
|
currentEmail = currentUserIdentities_1.email;
|
|
9816
9817
|
newEmail = mappedAttributes.email;
|
|
9817
9818
|
currentHashedEmail = void 0;
|
|
@@ -9835,9 +9836,9 @@ var mParticle = (function () {
|
|
|
9835
9836
|
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.");
|
|
9836
9837
|
}
|
|
9837
9838
|
if (!!isEmpty(newIdentities_1)) return [3 /*break*/, 5];
|
|
9838
|
-
|
|
9839
|
+
_g.label = 2;
|
|
9839
9840
|
case 2:
|
|
9840
|
-
|
|
9841
|
+
_g.trys.push([2, 4,, 5]);
|
|
9841
9842
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
9842
9843
|
_this.identityService.identify({
|
|
9843
9844
|
userIdentities: __assign(__assign({}, currentUserIdentities_1), newIdentities_1)
|
|
@@ -9846,16 +9847,16 @@ var mParticle = (function () {
|
|
|
9846
9847
|
});
|
|
9847
9848
|
})];
|
|
9848
9849
|
case 3:
|
|
9849
|
-
|
|
9850
|
+
_g.sent();
|
|
9850
9851
|
return [3 /*break*/, 5];
|
|
9851
9852
|
case 4:
|
|
9852
|
-
error_1 =
|
|
9853
|
+
error_1 = _g.sent();
|
|
9853
9854
|
this.logger.error('Failed to identify user with new email: ' + JSON.stringify(error_1));
|
|
9854
9855
|
return [3 /*break*/, 5];
|
|
9855
9856
|
case 5:
|
|
9856
9857
|
// Refresh current user identities to ensure we have the latest values before building enrichedAttributes
|
|
9857
9858
|
this.currentUser = this.identityService.getCurrentUser();
|
|
9858
|
-
finalUserIdentities = ((
|
|
9859
|
+
finalUserIdentities = ((_f = (_e = this.currentUser) === null || _e === void 0 ? void 0 : _e.getUserIdentities()) === null || _f === void 0 ? void 0 : _f.userIdentities) || {};
|
|
9859
9860
|
this.setUserAttributes(mappedAttributes);
|
|
9860
9861
|
enrichedAttributes = __assign(__assign({}, mappedAttributes), sandboxValue !== null ? {
|
|
9861
9862
|
sandbox: sandboxValue
|
|
@@ -9877,7 +9878,7 @@ var mParticle = (function () {
|
|
|
9877
9878
|
});
|
|
9878
9879
|
return [2 /*return*/, this.kit.selectPlacements(enrichedOptions)];
|
|
9879
9880
|
case 6:
|
|
9880
|
-
error_2 =
|
|
9881
|
+
error_2 = _g.sent();
|
|
9881
9882
|
return [2 /*return*/, Promise.reject(error_2 instanceof Error ? error_2 : new Error('Unknown error occurred'))];
|
|
9882
9883
|
case 7:
|
|
9883
9884
|
return [2 /*return*/];
|
package/package.json
CHANGED
package/src/roktManager.ts
CHANGED
|
@@ -202,7 +202,8 @@ export default class RoktManager {
|
|
|
202
202
|
const { attributes } = options;
|
|
203
203
|
const sandboxValue = attributes?.sandbox || null;
|
|
204
204
|
const mappedAttributes = this.mapPlacementAttributes(attributes, this.placementAttributesMapping);
|
|
205
|
-
|
|
205
|
+
this.logger?.verbose(`mParticle.Rokt selectPlacements called with attributes:\n${JSON.stringify(attributes, null, 2)}`);
|
|
206
|
+
|
|
206
207
|
this.currentUser = this.identityService.getCurrentUser();
|
|
207
208
|
const currentUserIdentities = this.currentUser?.getUserIdentities()?.userIdentities || {};
|
|
208
209
|
|