@mparticle/web-sdk 2.53.0 → 2.54.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 +8 -7
- package/dist/mparticle.esm.js +8 -7
- package/dist/mparticle.js +14 -7
- package/package.json +1 -1
- package/src/mp-instance.ts +2 -1
- package/src/roktManager.ts +30 -20
- package/src/types.ts +1 -0
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.54.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
|
|
@@ -148,7 +148,7 @@ var CommerceEventType={ProductAddToCart:10,ProductRemoveFromCart:11,ProductCheck
|
|
|
148
148
|
getValuesAsStrings:function getValuesAsStrings(){return Object.values(IdentityType).map(function(a){return isNumber(a)?a.toString():void 0}).filter(function(a){return a!==void 0})},getNewIdentitiesByName:function getNewIdentitiesByName(a){var b={},c=IdentityType.getValuesAsStrings();for(var d in a)// IdentityTypes are stored as numbers but are passed in as strings
|
|
149
149
|
if(c.includes(d)){var e=IdentityType.getIdentityName(parseNumber(d));b[e]=a[d];}return b}};var ProductActionType={Unknown:0,AddToCart:1,RemoveFromCart:2,Checkout:3,CheckoutOption:4,Click:5,ViewDetail:6,Purchase:7,Refund:8,AddToWishlist:9,RemoveFromWishlist:10,getName:function getName(a){return a===ProductActionType.AddToCart?"Add to Cart":a===ProductActionType.RemoveFromCart?"Remove from Cart":a===ProductActionType.Checkout?"Checkout":a===ProductActionType.CheckoutOption?"Checkout Option":a===ProductActionType.Click?"Click":a===ProductActionType.ViewDetail?"View Detail":a===ProductActionType.Purchase?"Purchase":a===ProductActionType.Refund?"Refund":a===ProductActionType.AddToWishlist?"Add to Wishlist":a===ProductActionType.RemoveFromWishlist?"Remove from Wishlist":"Unknown"},// these are the action names used by server and mobile SDKs when expanding a CommerceEvent
|
|
150
150
|
getExpansionName:function getExpansionName(a){return a===ProductActionType.AddToCart?"add_to_cart":a===ProductActionType.RemoveFromCart?"remove_from_cart":a===ProductActionType.Checkout?"checkout":a===ProductActionType.CheckoutOption?"checkout_option":a===ProductActionType.Click?"click":a===ProductActionType.ViewDetail?"view_detail":a===ProductActionType.Purchase?"purchase":a===ProductActionType.Refund?"refund":a===ProductActionType.AddToWishlist?"add_to_wishlist":a===ProductActionType.RemoveFromWishlist?"remove_from_wishlist":"unknown"}};var PromotionActionType={Unknown:0,PromotionView:1,PromotionClick:2,getName:function getName(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"},// these are the names that the server and mobile SDKs use while expanding CommerceEvent
|
|
151
|
-
getExpansionName:function getExpansionName(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"}};var ProfileMessageType={Logout:3};var ApplicationTransitionType$1={AppInit:1};var PerformanceMarkType={SdkStart:"mp:sdkStart"};var Types = {MessageType:MessageType$1,EventType:EventType,CommerceEventType:CommerceEventType,IdentityType:IdentityType,ProfileMessageType:ProfileMessageType,ApplicationTransitionType:ApplicationTransitionType$1,ProductActionType:ProductActionType,PromotionActionType:PromotionActionType,Environment:Constants.Environment};
|
|
151
|
+
getExpansionName:function getExpansionName(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"}};var ProfileMessageType={Logout:3};var ApplicationTransitionType$1={AppInit:1};var PerformanceMarkType={SdkStart:"mp:sdkStart",JointSdkSelectPlacements:"mp:jointSdkSelectPlacements"};var Types = {MessageType:MessageType$1,EventType:EventType,CommerceEventType:CommerceEventType,IdentityType:IdentityType,ProfileMessageType:ProfileMessageType,ApplicationTransitionType:ApplicationTransitionType$1,ProductActionType:ProductActionType,PromotionActionType:PromotionActionType,Environment:Constants.Environment};
|
|
152
152
|
|
|
153
153
|
function _typeof$1(o) {
|
|
154
154
|
"@babel/helpers - typeof";
|
|
@@ -1458,16 +1458,17 @@ var RoktManager=/** @class */function(){function a(){this.kit=null,this.filters=
|
|
|
1458
1458
|
* @param {SDKIdentityApi} identityService - The mParticle Identity instance
|
|
1459
1459
|
* @param {SDKLoggerApi} logger - The mParticle Logger instance
|
|
1460
1460
|
* @param {IRoktOptions} options - Options for the RoktManager
|
|
1461
|
+
* @param {Function} captureTiming - Function to capture performance timing marks
|
|
1461
1462
|
*
|
|
1462
1463
|
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
1463
|
-
*/return a.prototype.init=function(a,b,c,d,e,f){var
|
|
1464
|
+
*/return a.prototype.init=function(a,b,c,d,e,f,g){var h,i=a||{},j=i.userAttributeFilters,k=i.settings,l=k||{},m=l.placementAttributesMapping,n=l.hashedEmailUserIdentityType;this.mappedEmailShaIdentityType=null!==(h=null===n||void 0===n?void 0:n.toLowerCase())&&void 0!==h?h:null,this.identityService=c,this.store=d,this.logger=e,this.captureTiming=g,this.filters={userAttributeFilters:j,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b};try{this.placementAttributesMapping=parseSettingsString(m);}catch(a){this.logger.error("Error parsing placement attributes mapping from config: "+a);}// This is the global setting for sandbox mode
|
|
1464
1465
|
// It is set here and passed in to the createLauncher method in the Rokt Kit
|
|
1465
1466
|
// This is not to be confused for the `sandbox` flag in the selectPlacements attributes
|
|
1466
1467
|
// as that is independent of this setting, though they share the same name.
|
|
1467
|
-
var
|
|
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
|
|
1468
1469
|
// to the Rokt Launcher.
|
|
1469
|
-
this.launcherOptions=__assign({sandbox:
|
|
1470
|
-
return !!(this.kit&&this.kit.launcher)},a.prototype.setUserAttributes=function(a){var b=["sandbox"],c={};for(var d in a)a.hasOwnProperty(d)&&-1===b.indexOf(d)
|
|
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 d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s=this;return __generator(this,function(t){switch(t.label){case 0:if(this.captureTiming&&this.captureTiming(PerformanceMarkType.JointSdkSelectPlacements),!this.isReady())return [2/*return*/,this.deferredCall("selectPlacements",a)];t.label=1;case 1:if(t.trys.push([1,6,,7]),d=a.attributes,e=(null===d||void 0===d?void 0:d.sandbox)||null,f=this.mapPlacementAttributes(d,this.placementAttributesMapping),this.currentUser=this.identityService.getCurrentUser(),g=(null===(c=null===(b=this.currentUser)||void 0===b?void 0:b.getUserIdentities())||void 0===c?void 0:c.userIdentities)||{},h=g.email,i=f.email,j=void 0,k=void 0,this.mappedEmailShaIdentityType&&!1!==IdentityType.getIdentityType(this.mappedEmailShaIdentityType)&&(j=g[this.mappedEmailShaIdentityType],k=f.emailsha256||f[this.mappedEmailShaIdentityType]||void 0),l=this.hasIdentityChanged(h,i),m=this.hasIdentityChanged(j,k),n={},l&&(n.email=i,i&&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.")),m&&(n[this.mappedEmailShaIdentityType]=k,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(n))return [3/*break*/,5];t.label=2;case 2:return t.trys.push([2,4,,5]),[4/*yield*/,new Promise(function(a){s.identityService.identify({userIdentities:__assign(__assign({},g),n)},function(){a();});})];case 3:return t.sent(),[3/*break*/,5];case 4:return o=t.sent(),this.logger.error("Failed to identify user with new email: "+JSON.stringify(o)),[3/*break*/,5];case 5:return this.setUserAttributes(f),p=__assign(__assign({},f),null===e?{}:{sandbox:e}),q=__assign(__assign({},a),{attributes:p}),[2/*return*/,this.kit.selectPlacements(q)];case 6:return r=t.sent(),[2/*return*/,Promise.reject(r instanceof Error?r: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
|
|
1471
|
+
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.processMessageQueue=function(){var a,b=this;this.isReady()&&0!==this.messageQueue.size&&(// Clear the queue after processing all messages
|
|
1471
1472
|
null===(a=this.logger)||void 0===a?void 0:a.verbose("RoktManager: Processing ".concat(this.messageQueue.size," queued messages")),this.messageQueue.forEach(function(a){var c,d,e;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)));try{var f=b[a.methodName](a.payload);b.completePendingPromise(a.messageId,f);}catch(c){var g=c instanceof Error?c.message:c+"";null===(e=b.logger)||void 0===e?void 0:e.error("RoktManager: Error processing message '".concat(a.methodName,"': ").concat(g)),b.completePendingPromise(a.messageId,Promise.reject(c));}}),this.messageQueue.clear());},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.completePendingPromise=function(a,b){if(a&&this.messageQueue.has(a)){var c=this.messageQueue.get(a);c.resolve&&Promise.resolve(b).then(function(a){return c.resolve(a)})["catch"](function(a){return c.reject(a)}),this.messageQueue["delete"](a);}},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
|
|
1472
1473
|
},a}();
|
|
1473
1474
|
|
|
@@ -1660,7 +1661,7 @@ if(c._APIClient=new APIClient(c,d),c._Forwarders=new Forwarders(c,d),c._Store.pr
|
|
|
1660
1661
|
var f=c.Identity.getCurrentUser(),g=f?f.getMPID():null,h=f?f.getUserIdentities().userIdentities:{};c._Store.SDKConfig.identifyRequest=c._Store.hasInvalidIdentifyRequest()?{userIdentities:h}:c._Store.SDKConfig.identifyRequest,e(ReportBatching)&&c._ForwardingStatsUploader.startForwardingStatsTimer();// https://go.mparticle.com/work/SQDSDKS-7639
|
|
1661
1662
|
var i=e(CaptureIntegrationSpecificIds),j=e(CaptureIntegrationSpecificIdsV2),k=j&&j!==CaptureIntegrationSpecificIdsV2Modes.None||!0===i;if(k){var l;i||j===CaptureIntegrationSpecificIdsV2Modes.All?l="all":j===CaptureIntegrationSpecificIdsV2Modes.RoktOnly&&(l="roktonly"),c._IntegrationCapture=new IntegrationCapture(l),c._IntegrationCapture.capture();}// Configure Rokt Manager with user and filtered user
|
|
1662
1663
|
var m=parseConfig(b,"Rokt",181);if(m){var n=m.userAttributeFilters,o=filteredMparticleUser(g,{userAttributeFilters:n},c),p={sandbox:null===b||void 0===b?void 0:b.isDevelopmentMode,launcherOptions:null===b||void 0===b?void 0:b.launcherOptions,domain:null===b||void 0===b?void 0:b.domain};// https://go.mparticle.com/work/SQDSDKS-7339
|
|
1663
|
-
c._RoktManager.init(m,o,c.Identity,c._Store,c.Logger,p);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,f,g,h);}// We will continue to clear out the ready queue as part of the initial init flow
|
|
1664
|
+
c._RoktManager.init(m,o,c.Identity,c._Store,c.Logger,p,c.captureTiming);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,f,g,h);}// We will continue to clear out the ready queue as part of the initial init flow
|
|
1664
1665
|
// if an identify request is unnecessary, such as if there is an existing session
|
|
1665
1666
|
(c._Store.mpid&&!c._Store.identifyCalled||c._Store.webviewBridgeEnabled)&&(c._Store.isInitialized=!0,c._preInit.readyQueue=processReadyQueue(c._preInit.readyQueue)),c._Store.isFirstRun&&(c._Store.isFirstRun=!1);}// https://go.mparticle.com/work/SQDSDKS-7061
|
|
1666
1667
|
function createKitBlocker(a,b){var c,d,e,f;/* There are three ways a data plan object for blocking can be passed to the SDK:
|
package/dist/mparticle.esm.js
CHANGED
|
@@ -15,7 +15,7 @@ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is nul
|
|
|
15
15
|
filter:function filter(a/*, thisArg*/){if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g);}return d},// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
|
16
16
|
isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1};
|
|
17
17
|
|
|
18
|
-
var version = "2.
|
|
18
|
+
var version = "2.54.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
|
|
@@ -148,7 +148,7 @@ var CommerceEventType={ProductAddToCart:10,ProductRemoveFromCart:11,ProductCheck
|
|
|
148
148
|
getValuesAsStrings:function getValuesAsStrings(){return Object.values(IdentityType).map(function(a){return isNumber(a)?a.toString():void 0}).filter(function(a){return a!==void 0})},getNewIdentitiesByName:function getNewIdentitiesByName(a){var b={},c=IdentityType.getValuesAsStrings();for(var d in a)// IdentityTypes are stored as numbers but are passed in as strings
|
|
149
149
|
if(c.includes(d)){var e=IdentityType.getIdentityName(parseNumber(d));b[e]=a[d];}return b}};var ProductActionType={Unknown:0,AddToCart:1,RemoveFromCart:2,Checkout:3,CheckoutOption:4,Click:5,ViewDetail:6,Purchase:7,Refund:8,AddToWishlist:9,RemoveFromWishlist:10,getName:function getName(a){return a===ProductActionType.AddToCart?"Add to Cart":a===ProductActionType.RemoveFromCart?"Remove from Cart":a===ProductActionType.Checkout?"Checkout":a===ProductActionType.CheckoutOption?"Checkout Option":a===ProductActionType.Click?"Click":a===ProductActionType.ViewDetail?"View Detail":a===ProductActionType.Purchase?"Purchase":a===ProductActionType.Refund?"Refund":a===ProductActionType.AddToWishlist?"Add to Wishlist":a===ProductActionType.RemoveFromWishlist?"Remove from Wishlist":"Unknown"},// these are the action names used by server and mobile SDKs when expanding a CommerceEvent
|
|
150
150
|
getExpansionName:function getExpansionName(a){return a===ProductActionType.AddToCart?"add_to_cart":a===ProductActionType.RemoveFromCart?"remove_from_cart":a===ProductActionType.Checkout?"checkout":a===ProductActionType.CheckoutOption?"checkout_option":a===ProductActionType.Click?"click":a===ProductActionType.ViewDetail?"view_detail":a===ProductActionType.Purchase?"purchase":a===ProductActionType.Refund?"refund":a===ProductActionType.AddToWishlist?"add_to_wishlist":a===ProductActionType.RemoveFromWishlist?"remove_from_wishlist":"unknown"}};var PromotionActionType={Unknown:0,PromotionView:1,PromotionClick:2,getName:function getName(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"},// these are the names that the server and mobile SDKs use while expanding CommerceEvent
|
|
151
|
-
getExpansionName:function getExpansionName(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"}};var ProfileMessageType={Logout:3};var ApplicationTransitionType$1={AppInit:1};var PerformanceMarkType={SdkStart:"mp:sdkStart"};var Types = {MessageType:MessageType$1,EventType:EventType,CommerceEventType:CommerceEventType,IdentityType:IdentityType,ProfileMessageType:ProfileMessageType,ApplicationTransitionType:ApplicationTransitionType$1,ProductActionType:ProductActionType,PromotionActionType:PromotionActionType,Environment:Constants.Environment};
|
|
151
|
+
getExpansionName:function getExpansionName(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"}};var ProfileMessageType={Logout:3};var ApplicationTransitionType$1={AppInit:1};var PerformanceMarkType={SdkStart:"mp:sdkStart",JointSdkSelectPlacements:"mp:jointSdkSelectPlacements"};var Types = {MessageType:MessageType$1,EventType:EventType,CommerceEventType:CommerceEventType,IdentityType:IdentityType,ProfileMessageType:ProfileMessageType,ApplicationTransitionType:ApplicationTransitionType$1,ProductActionType:ProductActionType,PromotionActionType:PromotionActionType,Environment:Constants.Environment};
|
|
152
152
|
|
|
153
153
|
function _typeof$1(o) {
|
|
154
154
|
"@babel/helpers - typeof";
|
|
@@ -1458,16 +1458,17 @@ var RoktManager=/** @class */function(){function a(){this.kit=null,this.filters=
|
|
|
1458
1458
|
* @param {SDKIdentityApi} identityService - The mParticle Identity instance
|
|
1459
1459
|
* @param {SDKLoggerApi} logger - The mParticle Logger instance
|
|
1460
1460
|
* @param {IRoktOptions} options - Options for the RoktManager
|
|
1461
|
+
* @param {Function} captureTiming - Function to capture performance timing marks
|
|
1461
1462
|
*
|
|
1462
1463
|
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
1463
|
-
*/return a.prototype.init=function(a,b,c,d,e,f){var
|
|
1464
|
+
*/return a.prototype.init=function(a,b,c,d,e,f,g){var h,i=a||{},j=i.userAttributeFilters,k=i.settings,l=k||{},m=l.placementAttributesMapping,n=l.hashedEmailUserIdentityType;this.mappedEmailShaIdentityType=null!==(h=null===n||void 0===n?void 0:n.toLowerCase())&&void 0!==h?h:null,this.identityService=c,this.store=d,this.logger=e,this.captureTiming=g,this.filters={userAttributeFilters:j,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b};try{this.placementAttributesMapping=parseSettingsString(m);}catch(a){this.logger.error("Error parsing placement attributes mapping from config: "+a);}// This is the global setting for sandbox mode
|
|
1464
1465
|
// It is set here and passed in to the createLauncher method in the Rokt Kit
|
|
1465
1466
|
// This is not to be confused for the `sandbox` flag in the selectPlacements attributes
|
|
1466
1467
|
// as that is independent of this setting, though they share the same name.
|
|
1467
|
-
var
|
|
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
|
|
1468
1469
|
// to the Rokt Launcher.
|
|
1469
|
-
this.launcherOptions=__assign({sandbox:
|
|
1470
|
-
return !!(this.kit&&this.kit.launcher)},a.prototype.setUserAttributes=function(a){var b=["sandbox"],c={};for(var d in a)a.hasOwnProperty(d)&&-1===b.indexOf(d)
|
|
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 d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s=this;return __generator(this,function(t){switch(t.label){case 0:if(this.captureTiming&&this.captureTiming(PerformanceMarkType.JointSdkSelectPlacements),!this.isReady())return [2/*return*/,this.deferredCall("selectPlacements",a)];t.label=1;case 1:if(t.trys.push([1,6,,7]),d=a.attributes,e=(null===d||void 0===d?void 0:d.sandbox)||null,f=this.mapPlacementAttributes(d,this.placementAttributesMapping),this.currentUser=this.identityService.getCurrentUser(),g=(null===(c=null===(b=this.currentUser)||void 0===b?void 0:b.getUserIdentities())||void 0===c?void 0:c.userIdentities)||{},h=g.email,i=f.email,j=void 0,k=void 0,this.mappedEmailShaIdentityType&&!1!==IdentityType.getIdentityType(this.mappedEmailShaIdentityType)&&(j=g[this.mappedEmailShaIdentityType],k=f.emailsha256||f[this.mappedEmailShaIdentityType]||void 0),l=this.hasIdentityChanged(h,i),m=this.hasIdentityChanged(j,k),n={},l&&(n.email=i,i&&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.")),m&&(n[this.mappedEmailShaIdentityType]=k,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(n))return [3/*break*/,5];t.label=2;case 2:return t.trys.push([2,4,,5]),[4/*yield*/,new Promise(function(a){s.identityService.identify({userIdentities:__assign(__assign({},g),n)},function(){a();});})];case 3:return t.sent(),[3/*break*/,5];case 4:return o=t.sent(),this.logger.error("Failed to identify user with new email: "+JSON.stringify(o)),[3/*break*/,5];case 5:return this.setUserAttributes(f),p=__assign(__assign({},f),null===e?{}:{sandbox:e}),q=__assign(__assign({},a),{attributes:p}),[2/*return*/,this.kit.selectPlacements(q)];case 6:return r=t.sent(),[2/*return*/,Promise.reject(r instanceof Error?r: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
|
|
1471
|
+
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.processMessageQueue=function(){var a,b=this;this.isReady()&&0!==this.messageQueue.size&&(// Clear the queue after processing all messages
|
|
1471
1472
|
null===(a=this.logger)||void 0===a?void 0:a.verbose("RoktManager: Processing ".concat(this.messageQueue.size," queued messages")),this.messageQueue.forEach(function(a){var c,d,e;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)));try{var f=b[a.methodName](a.payload);b.completePendingPromise(a.messageId,f);}catch(c){var g=c instanceof Error?c.message:c+"";null===(e=b.logger)||void 0===e?void 0:e.error("RoktManager: Error processing message '".concat(a.methodName,"': ").concat(g)),b.completePendingPromise(a.messageId,Promise.reject(c));}}),this.messageQueue.clear());},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.completePendingPromise=function(a,b){if(a&&this.messageQueue.has(a)){var c=this.messageQueue.get(a);c.resolve&&Promise.resolve(b).then(function(a){return c.resolve(a)})["catch"](function(a){return c.reject(a)}),this.messageQueue["delete"](a);}},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
|
|
1472
1473
|
},a}();
|
|
1473
1474
|
|
|
@@ -1660,7 +1661,7 @@ if(c._APIClient=new APIClient(c,d),c._Forwarders=new Forwarders(c,d),c._Store.pr
|
|
|
1660
1661
|
var f=c.Identity.getCurrentUser(),g=f?f.getMPID():null,h=f?f.getUserIdentities().userIdentities:{};c._Store.SDKConfig.identifyRequest=c._Store.hasInvalidIdentifyRequest()?{userIdentities:h}:c._Store.SDKConfig.identifyRequest,e(ReportBatching)&&c._ForwardingStatsUploader.startForwardingStatsTimer();// https://go.mparticle.com/work/SQDSDKS-7639
|
|
1661
1662
|
var i=e(CaptureIntegrationSpecificIds),j=e(CaptureIntegrationSpecificIdsV2),k=j&&j!==CaptureIntegrationSpecificIdsV2Modes.None||!0===i;if(k){var l;i||j===CaptureIntegrationSpecificIdsV2Modes.All?l="all":j===CaptureIntegrationSpecificIdsV2Modes.RoktOnly&&(l="roktonly"),c._IntegrationCapture=new IntegrationCapture(l),c._IntegrationCapture.capture();}// Configure Rokt Manager with user and filtered user
|
|
1662
1663
|
var m=parseConfig(b,"Rokt",181);if(m){var n=m.userAttributeFilters,o=filteredMparticleUser(g,{userAttributeFilters:n},c),p={sandbox:null===b||void 0===b?void 0:b.isDevelopmentMode,launcherOptions:null===b||void 0===b?void 0:b.launcherOptions,domain:null===b||void 0===b?void 0:b.domain};// https://go.mparticle.com/work/SQDSDKS-7339
|
|
1663
|
-
c._RoktManager.init(m,o,c.Identity,c._Store,c.Logger,p);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,f,g,h);}// We will continue to clear out the ready queue as part of the initial init flow
|
|
1664
|
+
c._RoktManager.init(m,o,c.Identity,c._Store,c.Logger,p,c.captureTiming);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,f,g,h);}// We will continue to clear out the ready queue as part of the initial init flow
|
|
1664
1665
|
// if an identify request is unnecessary, such as if there is an existing session
|
|
1665
1666
|
(c._Store.mpid&&!c._Store.identifyCalled||c._Store.webviewBridgeEnabled)&&(c._Store.isInitialized=!0,c._preInit.readyQueue=processReadyQueue(c._preInit.readyQueue)),c._Store.isFirstRun&&(c._Store.isFirstRun=!1);}// https://go.mparticle.com/work/SQDSDKS-7061
|
|
1666
1667
|
function createKitBlocker(a,b){var c,d,e,f;/* There are three ways a data plan object for blocking can be passed to the SDK:
|
package/dist/mparticle.js
CHANGED
|
@@ -203,7 +203,7 @@ var mParticle = (function () {
|
|
|
203
203
|
Base64: Base64$1
|
|
204
204
|
};
|
|
205
205
|
|
|
206
|
-
var version = "2.
|
|
206
|
+
var version = "2.54.0";
|
|
207
207
|
|
|
208
208
|
var Constants = {
|
|
209
209
|
sdkVersion: version,
|
|
@@ -1213,7 +1213,8 @@ var mParticle = (function () {
|
|
|
1213
1213
|
AppInit: 1
|
|
1214
1214
|
};
|
|
1215
1215
|
var PerformanceMarkType = {
|
|
1216
|
-
SdkStart: 'mp:sdkStart'
|
|
1216
|
+
SdkStart: 'mp:sdkStart',
|
|
1217
|
+
JointSdkSelectPlacements: 'mp:jointSdkSelectPlacements'
|
|
1217
1218
|
};
|
|
1218
1219
|
var Types = {
|
|
1219
1220
|
MessageType: MessageType$1,
|
|
@@ -9703,10 +9704,11 @@ var mParticle = (function () {
|
|
|
9703
9704
|
* @param {SDKIdentityApi} identityService - The mParticle Identity instance
|
|
9704
9705
|
* @param {SDKLoggerApi} logger - The mParticle Logger instance
|
|
9705
9706
|
* @param {IRoktOptions} options - Options for the RoktManager
|
|
9707
|
+
* @param {Function} captureTiming - Function to capture performance timing marks
|
|
9706
9708
|
*
|
|
9707
9709
|
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
9708
9710
|
*/
|
|
9709
|
-
RoktManager.prototype.init = function (roktConfig, filteredUser, identityService, store, logger, options) {
|
|
9711
|
+
RoktManager.prototype.init = function (roktConfig, filteredUser, identityService, store, logger, options, captureTiming) {
|
|
9710
9712
|
var _a;
|
|
9711
9713
|
var _b = roktConfig || {},
|
|
9712
9714
|
userAttributeFilters = _b.userAttributeFilters,
|
|
@@ -9718,6 +9720,7 @@ var mParticle = (function () {
|
|
|
9718
9720
|
this.identityService = identityService;
|
|
9719
9721
|
this.store = store;
|
|
9720
9722
|
this.logger = logger;
|
|
9723
|
+
this.captureTiming = captureTiming;
|
|
9721
9724
|
this.filters = {
|
|
9722
9725
|
userAttributeFilters: userAttributeFilters,
|
|
9723
9726
|
filterUserAttributes: KitFilterHelper.filterUserAttributes,
|
|
@@ -9769,6 +9772,9 @@ var mParticle = (function () {
|
|
|
9769
9772
|
return __generator(this, function (_c) {
|
|
9770
9773
|
switch (_c.label) {
|
|
9771
9774
|
case 0:
|
|
9775
|
+
if (this.captureTiming) {
|
|
9776
|
+
this.captureTiming(PerformanceMarkType.JointSdkSelectPlacements);
|
|
9777
|
+
}
|
|
9772
9778
|
if (!this.isReady()) {
|
|
9773
9779
|
return [2 /*return*/, this.deferredCall('selectPlacements', options)];
|
|
9774
9780
|
}
|
|
@@ -9844,8 +9850,8 @@ var mParticle = (function () {
|
|
|
9844
9850
|
* with Rokt-compatible key names (like emailsha256, mobilesha256)
|
|
9845
9851
|
*
|
|
9846
9852
|
*
|
|
9847
|
-
* @param {
|
|
9848
|
-
* @returns {Promise<
|
|
9853
|
+
* @param {RoktAttributes} attributes - Attributes to hash
|
|
9854
|
+
* @returns {Promise<RoktAttributes>} Object with both original and hashed attributes
|
|
9849
9855
|
*
|
|
9850
9856
|
*/
|
|
9851
9857
|
RoktManager.prototype.hashAttributes = function (attributes) {
|
|
@@ -9979,7 +9985,8 @@ var mParticle = (function () {
|
|
|
9979
9985
|
var filteredAttributes = {};
|
|
9980
9986
|
for (var key in attributes) {
|
|
9981
9987
|
if (attributes.hasOwnProperty(key) && reservedAttributes.indexOf(key) === -1) {
|
|
9982
|
-
|
|
9988
|
+
var value = attributes[key];
|
|
9989
|
+
filteredAttributes[key] = Array.isArray(value) ? JSON.stringify(value) : value;
|
|
9983
9990
|
}
|
|
9984
9991
|
}
|
|
9985
9992
|
try {
|
|
@@ -11148,7 +11155,7 @@ var mParticle = (function () {
|
|
|
11148
11155
|
domain: config === null || config === void 0 ? void 0 : config.domain
|
|
11149
11156
|
};
|
|
11150
11157
|
// https://go.mparticle.com/work/SQDSDKS-7339
|
|
11151
|
-
mpInstance._RoktManager.init(roktConfig, roktFilteredUser, mpInstance.Identity, mpInstance._Store, mpInstance.Logger, roktOptions);
|
|
11158
|
+
mpInstance._RoktManager.init(roktConfig, roktFilteredUser, mpInstance.Identity, mpInstance._Store, mpInstance.Logger, roktOptions, mpInstance.captureTiming);
|
|
11152
11159
|
}
|
|
11153
11160
|
mpInstance._Forwarders.processForwarders(config, mpInstance._APIClient.prepareForwardingStats);
|
|
11154
11161
|
mpInstance._Forwarders.processPixelConfigs(config);
|
package/package.json
CHANGED
package/src/mp-instance.ts
CHANGED
package/src/roktManager.ts
CHANGED
|
@@ -14,12 +14,13 @@ import { SDKIdentityApi } from "./identity.interfaces";
|
|
|
14
14
|
import { SDKLoggerApi } from "./sdkRuntimeModels";
|
|
15
15
|
import { IStore, LocalSessionAttributes } from "./store";
|
|
16
16
|
import { UserIdentities } from "@mparticle/web-sdk";
|
|
17
|
-
import { IdentityType } from "./types";
|
|
17
|
+
import { IdentityType, PerformanceMarkType } from "./types";
|
|
18
18
|
|
|
19
19
|
// https://docs.rokt.com/developers/integration-guides/web/library/attributes
|
|
20
|
-
export
|
|
21
|
-
|
|
22
|
-
|
|
20
|
+
export type RoktAttributeValueArray = Array<string | number | boolean>;
|
|
21
|
+
export type RoktAttributeValueType = string | number | boolean | undefined | null;
|
|
22
|
+
export type RoktAttributeValue = RoktAttributeValueType | RoktAttributeValueArray;
|
|
23
|
+
export type RoktAttributes = Record<string, RoktAttributeValue>;
|
|
23
24
|
|
|
24
25
|
export interface IRoktPartnerExtensionData<T> {
|
|
25
26
|
[extensionName: string]: T;
|
|
@@ -27,7 +28,7 @@ export interface IRoktPartnerExtensionData<T> {
|
|
|
27
28
|
|
|
28
29
|
// https://docs.rokt.com/developers/integration-guides/web/library/select-placements-options
|
|
29
30
|
export interface IRoktSelectPlacementsOptions {
|
|
30
|
-
attributes:
|
|
31
|
+
attributes: RoktAttributes;
|
|
31
32
|
identifier?: string;
|
|
32
33
|
}
|
|
33
34
|
|
|
@@ -40,7 +41,7 @@ export interface IRoktSelection {
|
|
|
40
41
|
|
|
41
42
|
export interface IRoktLauncher {
|
|
42
43
|
selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise<IRoktSelection>;
|
|
43
|
-
hashAttributes: (attributes:
|
|
44
|
+
hashAttributes: (attributes: RoktAttributes) => Promise<Record<string, string>>;
|
|
44
45
|
use: <T>(name: string) => Promise<T>;
|
|
45
46
|
}
|
|
46
47
|
|
|
@@ -63,7 +64,7 @@ export interface IRoktKit {
|
|
|
63
64
|
filteredUser: IMParticleUser | null;
|
|
64
65
|
launcher: IRoktLauncher | null;
|
|
65
66
|
userAttributes: Dictionary<string>;
|
|
66
|
-
hashAttributes: (attributes:
|
|
67
|
+
hashAttributes: (attributes: RoktAttributes) => Promise<RoktAttributes>;
|
|
67
68
|
selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise<IRoktSelection>;
|
|
68
69
|
setExtensionData<T>(extensionData: IRoktPartnerExtensionData<T>): void;
|
|
69
70
|
use: <T>(name: string) => Promise<T>;
|
|
@@ -99,7 +100,8 @@ export default class RoktManager {
|
|
|
99
100
|
private launcherOptions?: IRoktLauncherOptions;
|
|
100
101
|
private logger: SDKLoggerApi;
|
|
101
102
|
private domain?: string;
|
|
102
|
-
private mappedEmailShaIdentityType?: string
|
|
103
|
+
private mappedEmailShaIdentityType?: string | null;
|
|
104
|
+
private captureTiming?: (metricsName: string) => void;
|
|
103
105
|
/**
|
|
104
106
|
* Initializes the RoktManager with configuration settings and user data.
|
|
105
107
|
*
|
|
@@ -108,6 +110,7 @@ export default class RoktManager {
|
|
|
108
110
|
* @param {SDKIdentityApi} identityService - The mParticle Identity instance
|
|
109
111
|
* @param {SDKLoggerApi} logger - The mParticle Logger instance
|
|
110
112
|
* @param {IRoktOptions} options - Options for the RoktManager
|
|
113
|
+
* @param {Function} captureTiming - Function to capture performance timing marks
|
|
111
114
|
*
|
|
112
115
|
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
113
116
|
*/
|
|
@@ -117,7 +120,8 @@ export default class RoktManager {
|
|
|
117
120
|
identityService: SDKIdentityApi,
|
|
118
121
|
store: IStore,
|
|
119
122
|
logger?: SDKLoggerApi,
|
|
120
|
-
options?: IRoktOptions
|
|
123
|
+
options?: IRoktOptions,
|
|
124
|
+
captureTiming?: (metricsName: string) => void
|
|
121
125
|
): void {
|
|
122
126
|
const { userAttributeFilters, settings } = roktConfig || {};
|
|
123
127
|
const { placementAttributesMapping, hashedEmailUserIdentityType } = settings || {};
|
|
@@ -126,6 +130,7 @@ export default class RoktManager {
|
|
|
126
130
|
this.identityService = identityService;
|
|
127
131
|
this.store = store;
|
|
128
132
|
this.logger = logger;
|
|
133
|
+
this.captureTiming = captureTiming;
|
|
129
134
|
|
|
130
135
|
this.filters = {
|
|
131
136
|
userAttributeFilters,
|
|
@@ -175,6 +180,10 @@ export default class RoktManager {
|
|
|
175
180
|
* });
|
|
176
181
|
*/
|
|
177
182
|
public async selectPlacements(options: IRoktSelectPlacementsOptions): Promise<IRoktSelection> {
|
|
183
|
+
if (this.captureTiming) {
|
|
184
|
+
this.captureTiming(PerformanceMarkType.JointSdkSelectPlacements);
|
|
185
|
+
}
|
|
186
|
+
|
|
178
187
|
if (!this.isReady()) {
|
|
179
188
|
return this.deferredCall<IRoktSelection>('selectPlacements', options);
|
|
180
189
|
}
|
|
@@ -257,11 +266,11 @@ export default class RoktManager {
|
|
|
257
266
|
* with Rokt-compatible key names (like emailsha256, mobilesha256)
|
|
258
267
|
*
|
|
259
268
|
*
|
|
260
|
-
* @param {
|
|
261
|
-
* @returns {Promise<
|
|
269
|
+
* @param {RoktAttributes} attributes - Attributes to hash
|
|
270
|
+
* @returns {Promise<RoktAttributes>} Object with both original and hashed attributes
|
|
262
271
|
*
|
|
263
272
|
*/
|
|
264
|
-
public async hashAttributes(attributes:
|
|
273
|
+
public async hashAttributes(attributes: RoktAttributes): Promise<RoktAttributes> {
|
|
265
274
|
try {
|
|
266
275
|
if (!attributes || typeof attributes !== 'object') {
|
|
267
276
|
return {};
|
|
@@ -276,7 +285,7 @@ export default class RoktManager {
|
|
|
276
285
|
|
|
277
286
|
// Hash all attributes in parallel
|
|
278
287
|
const hashPromises = keys.map(async (key) => {
|
|
279
|
-
const attributeValue = attributes[key];
|
|
288
|
+
const attributeValue = attributes[key] as RoktAttributeValueType;
|
|
280
289
|
const hashedValue = await this.hashSha256(attributeValue);
|
|
281
290
|
return { key, attributeValue, hashedValue };
|
|
282
291
|
});
|
|
@@ -284,7 +293,7 @@ export default class RoktManager {
|
|
|
284
293
|
const results = await Promise.all(hashPromises);
|
|
285
294
|
|
|
286
295
|
// Build the result object
|
|
287
|
-
const hashedAttributes:
|
|
296
|
+
const hashedAttributes: RoktAttributes = {};
|
|
288
297
|
for (const { key, attributeValue, hashedValue } of results) {
|
|
289
298
|
hashedAttributes[key] = attributeValue;
|
|
290
299
|
if (hashedValue) {
|
|
@@ -333,7 +342,7 @@ export default class RoktManager {
|
|
|
333
342
|
* @returns {Promise<string | undefined | null>} SHA-256 hashed value or undefined/null
|
|
334
343
|
*
|
|
335
344
|
*/
|
|
336
|
-
public async hashSha256(attribute:
|
|
345
|
+
public async hashSha256(attribute: RoktAttributeValueType): Promise<string | undefined | null> {
|
|
337
346
|
if (attribute === null || attribute === undefined) {
|
|
338
347
|
this.logger.warning(`hashSha256 received null/undefined as input`);
|
|
339
348
|
return attribute as null | undefined;
|
|
@@ -362,13 +371,14 @@ export default class RoktManager {
|
|
|
362
371
|
return Boolean(this.kit && this.kit.launcher);
|
|
363
372
|
}
|
|
364
373
|
|
|
365
|
-
private setUserAttributes(attributes:
|
|
374
|
+
private setUserAttributes(attributes: RoktAttributes): void {
|
|
366
375
|
const reservedAttributes = ['sandbox'];
|
|
367
376
|
const filteredAttributes = {};
|
|
368
377
|
|
|
369
378
|
for (const key in attributes) {
|
|
370
379
|
if (attributes.hasOwnProperty(key) && reservedAttributes.indexOf(key) === -1) {
|
|
371
|
-
|
|
380
|
+
const value = attributes[key];
|
|
381
|
+
filteredAttributes[key] = Array.isArray(value) ? JSON.stringify(value) : value;
|
|
372
382
|
}
|
|
373
383
|
}
|
|
374
384
|
|
|
@@ -379,13 +389,13 @@ export default class RoktManager {
|
|
|
379
389
|
}
|
|
380
390
|
}
|
|
381
391
|
|
|
382
|
-
private mapPlacementAttributes(attributes:
|
|
392
|
+
private mapPlacementAttributes(attributes: RoktAttributes, placementAttributesMapping: Dictionary<string>[]): RoktAttributes {
|
|
383
393
|
const mappingLookup: { [key: string]: string } = {};
|
|
384
394
|
for (const mapping of placementAttributesMapping) {
|
|
385
395
|
mappingLookup[mapping.map] = mapping.value;
|
|
386
396
|
}
|
|
387
397
|
|
|
388
|
-
const mappedAttributes:
|
|
398
|
+
const mappedAttributes: RoktAttributes = {};
|
|
389
399
|
for (const key in attributes) {
|
|
390
400
|
if (attributes.hasOwnProperty(key)) {
|
|
391
401
|
const newKey = mappingLookup[key] || key;
|
|
@@ -512,4 +522,4 @@ export default class RoktManager {
|
|
|
512
522
|
|
|
513
523
|
return false; // Values are the same
|
|
514
524
|
}
|
|
515
|
-
}
|
|
525
|
+
}
|
package/src/types.ts
CHANGED