@mparticle/web-sdk 2.40.0 → 2.41.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mparticle.common.js +13 -7
- package/dist/mparticle.esm.js +13 -7
- package/dist/mparticle.js +35 -22
- package/package.json +1 -1
- package/src/identity.js +4 -0
- package/src/mp-instance.ts +15 -15
- package/src/roktManager.ts +18 -6
- package/src/sdkRuntimeModels.ts +3 -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.41.1";
|
|
19
19
|
|
|
20
20
|
var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodIsDeprecatedPostfix:"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/"},Base64CookieKeys:{csm:1,sa:1,ss:1,ua:1,ui:1,csd:1,ia:1,con:1},// https://go.mparticle.com/work/SQDSDKS-6039
|
|
@@ -1265,7 +1265,7 @@ return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audie
|
|
|
1265
1265
|
* @deprecated
|
|
1266
1266
|
*/getCartProducts:function getCartProducts(){return t.Logger.warning("Deprecated function Identity.getCurrentUser().getCart().getCartProducts() will be removed in future releases"),t._Persistence.getCartProducts(e)}}},this.parseIdentityResponse=function(r,i,a,d,o,g,l){var u,p,y,c=t.Identity.getUser(i),I=c?c.getMPID():null,_=c?c.getUserIdentities().userIdentities:{},v={};t._Store.identityCallInFlight=!1;try{var m,S,b;if(t.Logger.verbose("Parsing \""+o+"\" identity response from server"),p=null!==(m=r.responseText)&&void 0!==m?m:null,t._Store.isLoggedIn=(null===(S=p)||void 0===S?void 0:S.is_logged_in)||!1,hasMPIDChanged(c,p)&&(t._Store.mpid=p.mpid,c&&t._Persistence.setLastSeenTime(i),u=!t._Persistence.getFirstSeenTime(p.mpid),t._Persistence.setFirstSeenTime(p.mpid)),r.status===HTTP_OK){s(CacheIdentity)&&cacheOrClearIdCache(o,g,n.idCache,r,l);var A=n.IdentityAPI.getUser(p.mpid),P=A?A.getUserIdentities().userIdentities:{};o===Modify$1?(v=t._Identity.IdentityRequest.combineUserIdentities(_,d.userIdentities),t._Store.setUserIdentities(i,v)):(o===Identify&&c&&p.mpid===I&&t._Persistence.setFirstSeenTime(p.mpid),t._Store.addMpidToSessionHistory(p.mpid,i),t._CookieSyncManager.attemptCookieSync(p.mpid,u),t._Persistence.swapCurrentUser(i,p.mpid,t._Store.currentSessionMPIDs),d&&!isEmpty(d.userIdentities)&&(v=n.IdentityRequest.combineUserIdentities(P,d.userIdentities)),t._Store.setUserIdentities(p.mpid,v),t._Persistence.update(),t._Store.syncPersistenceData(),t._Persistence.findPrevCookiesBasedOnUI(d),t._Store.context=p.context||t._Store.context),y=t.Identity.getCurrentUser(),tryOnUserAlias(c,y,d,t.Logger);var U=t._Persistence.getPersistence();y&&(t._Persistence.storeDataInMemory(U,y.getMPID()),n.reinitForwardersOnUserChange(c,y),n.setForwarderCallbacks(y,o));var C=IdentityType.getNewIdentitiesByName(v),k=o===Modify$1?_:P;// https://go.mparticle.com/work/SQDSDKS-6501
|
|
1267
1267
|
n.sendUserIdentityChangeEvent(C,o,p.mpid,k);}if(a){var f=0===r.status?HTTPCodes$2.noHttpCoverage:r.status;t._Helpers.invokeCallback(a,f,p||null,y);}else p&&!isEmpty(p.errors)&&// https://go.mparticle.com/work/SQDSDKS-6500
|
|
1268
|
-
t.Logger.error("Received HTTP response code of "+r.status+" - "+p.errors[0].message);t.Logger.verbose("Successfully parsed Identity Response"),null===(b=t._APIClient)||void 0===b||b.processQueuedEvents();}catch(s){a&&t._Helpers.invokeCallback(a,r.status,p||null),t.Logger.error("Error parsing JSON response from Identity server: "+s);}t._Store.isInitialized=!0,t._preInit.readyQueue=processReadyQueue(t._preInit.readyQueue);},this.sendUserIdentityChangeEvent=function(e,r,s,i){if(s||r===Modify$1)// https://go.mparticle.com/work/SQDSDKS-6501
|
|
1268
|
+
t.Logger.error("Received HTTP response code of "+r.status+" - "+p.errors[0].message);t.Logger.verbose("Successfully parsed Identity Response"),null===(b=t._APIClient)||void 0===b||b.processQueuedEvents();}catch(s){a&&t._Helpers.invokeCallback(a,r.status,p||null),t.Logger.error("Error parsing JSON response from Identity server: "+s);}t._Store.isInitialized=!0,t._RoktManager.isReady()&&(t._RoktManager.currentUser=t.Identity.getCurrentUser()),t._preInit.readyQueue=processReadyQueue(t._preInit.readyQueue);},this.sendUserIdentityChangeEvent=function(e,r,s,i){if(s||r===Modify$1)// https://go.mparticle.com/work/SQDSDKS-6501
|
|
1269
1269
|
{// https://go.mparticle.com/work/SQDSDKS-6354
|
|
1270
1270
|
var a=this.IdentityAPI.getUser(s);for(var d in e)// Verifies a change actually happened
|
|
1271
1271
|
if(i[d]!==e[d]){var o,g=!i[d],l=n.createUserIdentityChange(d,e[d],i[d],g,a);// If a new identity type was introduced when the identity changes
|
|
@@ -1424,10 +1424,16 @@ var RoktManager=/** @class */function(){function a(){this.kit=null,this.filters=
|
|
|
1424
1424
|
* @param {IMParticleUser} filteredUser - User object with filtered attributes
|
|
1425
1425
|
* @param {SDKIdentityApi} identityService - The mParticle Identity instance
|
|
1426
1426
|
* @param {SDKLoggerApi} logger - The mParticle Logger instance
|
|
1427
|
-
* @param {
|
|
1427
|
+
* @param {IRoktOptions} options - Options for the RoktManager
|
|
1428
1428
|
*
|
|
1429
1429
|
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
1430
|
-
*/return a.prototype.init=function(a,b,c,d,e){var f=a||{},g=f.userAttributeFilters,h=f.settings,i=(h||{}).placementAttributesMapping;try{this.placementAttributesMapping=parseSettingsString(i);}catch(a){console.error("Error parsing placement attributes mapping from config",a);}this.identityService=c,this.logger=d,this.filters={userAttributeFilters:g,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b}
|
|
1430
|
+
*/return a.prototype.init=function(a,b,c,d,e){var f=a||{},g=f.userAttributeFilters,h=f.settings,i=(h||{}).placementAttributesMapping;try{this.placementAttributesMapping=parseSettingsString(i);}catch(a){console.error("Error parsing placement attributes mapping from config",a);}this.identityService=c,this.logger=d,this.filters={userAttributeFilters:g,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b};// This is the global setting for sandbox mode
|
|
1431
|
+
// It is set here and passed in to the createLauncher method in the Rokt Kit
|
|
1432
|
+
// This is not to be confused for the `sandbox` flag in the selectPlacements attributes
|
|
1433
|
+
// as that is independent of this setting, though they share the same name.
|
|
1434
|
+
var j=(null===e||void 0===e?void 0:e.sandbox)||!1;// Launcher options are set here for the kit to pick up and pass through
|
|
1435
|
+
// to the Rokt Launcher.
|
|
1436
|
+
this.launcherOptions=__assign({sandbox:j},null===e||void 0===e?void 0:e.launcherOptions);},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=this;return __generator(this,function(o){switch(o.label){case 0:if(!this.isReady())return this.queueMessage({methodName:"selectPlacements",payload:a}),[2/*return*/,Promise.resolve({})];o.label=1;case 1:if(o.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,!i||h&&h===i)return [3/*break*/,5];h&&h!==i&&this.logger.warning("Email mismatch detected. Current email, ".concat(h," differs from email passed to selectPlacements call, ").concat(i,". Proceeding to call identify with ").concat(i,". Please verify your implementation.")),o.label=2;case 2:return o.trys.push([2,4,,5]),[4/*yield*/,new Promise(function(a){n.identityService.identify({userIdentities:__assign(__assign({},g),{email:i})},function(){a();});})];case 3:return o.sent(),[3/*break*/,5];case 4:return j=o.sent(),this.logger.error("Failed to identify user with new email: "+JSON.stringify(j)),[3/*break*/,5];case 5:return this.setUserAttributes(f),k=__assign(__assign({},f),null===e?{}:{sandbox:e}),l=__assign(__assign({},a),{attributes:k}),[2/*return*/,this.kit.selectPlacements(l)];case 6:return m=o.sent(),[2/*return*/,Promise.reject(m instanceof Error?m:new Error("Unknown error occurred"))];case 7:return [2/*return*/]}})})},a.prototype.hashAttributes=function(a){if(!this.isReady())return this.queueMessage({methodName:"hashAttributes",payload:a}),Promise.resolve({});try{return this.kit.hashAttributes(a)}catch(a){return Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))}},a.prototype.setExtensionData=function(a){if(!this.isReady())return void this.queueMessage({methodName:"setExtensionData",payload: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.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
|
|
1431
1437
|
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)&&(c[d]=a[d]);try{this.currentUser.setUserAttributes(c);}catch(a){console.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=this;0<this.messageQueue.length&&this.isReady()&&(this.messageQueue.forEach(function(b){return __awaiter(a,void 0,void 0,function(){return __generator(this,function(a){switch(a.label){case 0:return this.kit&&b.methodName in this.kit?[4/*yield*/,this.kit[b.methodName](b.payload)]:[3/*break*/,2];case 1:a.sent(),a.label=2;case 2:return [2/*return*/]}})})}),this.messageQueue=[]);},a.prototype.queueMessage=function(a){this.messageQueue.push(a);},a}();
|
|
1432
1438
|
|
|
1433
1439
|
var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
|
|
@@ -1765,9 +1771,9 @@ function completeSDKInitialization(a,b,c){var d=createKitBlocker(b,c);// Web Vie
|
|
|
1765
1771
|
// responsible for sending events directly to mParticle's servers. The Web SDK will not initialize
|
|
1766
1772
|
// persistence or Identity directly.
|
|
1767
1773
|
if(c._APIClient=new APIClient(c,d),c._Forwarders=new Forwarders(c,d),c._Store.processConfig(b),c._Identity.idCache=createIdentityCache(c),removeExpiredIdentityCacheDates(c._Identity.idCache),c._Store.webviewBridgeEnabled)c._NativeSdkHelpers.initializeSessionAttributes(a);else {c._Persistence.initializeStorage(),c._Store.syncPersistenceData();// Set up user identitiy variables for later use
|
|
1768
|
-
var e=c.Identity.getCurrentUser(),f=e?e.getMPID():null,g=e?e.getUserIdentities().userIdentities:{};c._Store.SDKConfig.identifyRequest=c._Store.hasInvalidIdentifyRequest()?{userIdentities:g}:c._Store.SDKConfig.identifyRequest,c._Helpers.getFeatureFlag(ReportBatching)&&c._ForwardingStatsUploader.startForwardingStatsTimer(),c._Helpers.getFeatureFlag(CaptureIntegrationSpecificIds)&&c._IntegrationCapture.capture()
|
|
1769
|
-
var h=parseConfig(b,"Rokt",181);if(h){var i=h.userAttributeFilters,j=filteredMparticleUser(f,{userAttributeFilters:i},c),k={sandbox:b.isDevelopmentMode};// https://go.mparticle.com/work/SQDSDKS-7339
|
|
1770
|
-
c._RoktManager.init(h,j,c.Identity,c.Logger,k);}processIdentityCallback(c,e,f,g);}// We will continue to clear out the ready queue as part of the initial init flow
|
|
1774
|
+
var e=c.Identity.getCurrentUser(),f=e?e.getMPID():null,g=e?e.getUserIdentities().userIdentities:{};c._Store.SDKConfig.identifyRequest=c._Store.hasInvalidIdentifyRequest()?{userIdentities:g}:c._Store.SDKConfig.identifyRequest,c._Helpers.getFeatureFlag(ReportBatching)&&c._ForwardingStatsUploader.startForwardingStatsTimer(),c._Helpers.getFeatureFlag(CaptureIntegrationSpecificIds)&&c._IntegrationCapture.capture();// Configure Rokt Manager with user and filtered user
|
|
1775
|
+
var h=parseConfig(b,"Rokt",181);if(h){var i=h.userAttributeFilters,j=filteredMparticleUser(f,{userAttributeFilters:i},c),k={sandbox:null===b||void 0===b?void 0:b.isDevelopmentMode,launcherOptions:null===b||void 0===b?void 0:b.launcherOptions};// https://go.mparticle.com/work/SQDSDKS-7339
|
|
1776
|
+
c._RoktManager.init(h,j,c.Identity,c.Logger,k);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,e,f,g);}// We will continue to clear out the ready queue as part of the initial init flow
|
|
1771
1777
|
// if an identify request is unnecessary, such as if there is an existing session
|
|
1772
1778
|
(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
|
|
1773
1779
|
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.41.1";
|
|
19
19
|
|
|
20
20
|
var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodIsDeprecatedPostfix:"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/"},Base64CookieKeys:{csm:1,sa:1,ss:1,ua:1,ui:1,csd:1,ia:1,con:1},// https://go.mparticle.com/work/SQDSDKS-6039
|
|
@@ -1265,7 +1265,7 @@ return t._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)?void(null===s.audie
|
|
|
1265
1265
|
* @deprecated
|
|
1266
1266
|
*/getCartProducts:function getCartProducts(){return t.Logger.warning("Deprecated function Identity.getCurrentUser().getCart().getCartProducts() will be removed in future releases"),t._Persistence.getCartProducts(e)}}},this.parseIdentityResponse=function(r,i,a,d,o,g,l){var u,p,y,c=t.Identity.getUser(i),I=c?c.getMPID():null,_=c?c.getUserIdentities().userIdentities:{},v={};t._Store.identityCallInFlight=!1;try{var m,S,b;if(t.Logger.verbose("Parsing \""+o+"\" identity response from server"),p=null!==(m=r.responseText)&&void 0!==m?m:null,t._Store.isLoggedIn=(null===(S=p)||void 0===S?void 0:S.is_logged_in)||!1,hasMPIDChanged(c,p)&&(t._Store.mpid=p.mpid,c&&t._Persistence.setLastSeenTime(i),u=!t._Persistence.getFirstSeenTime(p.mpid),t._Persistence.setFirstSeenTime(p.mpid)),r.status===HTTP_OK){s(CacheIdentity)&&cacheOrClearIdCache(o,g,n.idCache,r,l);var A=n.IdentityAPI.getUser(p.mpid),P=A?A.getUserIdentities().userIdentities:{};o===Modify$1?(v=t._Identity.IdentityRequest.combineUserIdentities(_,d.userIdentities),t._Store.setUserIdentities(i,v)):(o===Identify&&c&&p.mpid===I&&t._Persistence.setFirstSeenTime(p.mpid),t._Store.addMpidToSessionHistory(p.mpid,i),t._CookieSyncManager.attemptCookieSync(p.mpid,u),t._Persistence.swapCurrentUser(i,p.mpid,t._Store.currentSessionMPIDs),d&&!isEmpty(d.userIdentities)&&(v=n.IdentityRequest.combineUserIdentities(P,d.userIdentities)),t._Store.setUserIdentities(p.mpid,v),t._Persistence.update(),t._Store.syncPersistenceData(),t._Persistence.findPrevCookiesBasedOnUI(d),t._Store.context=p.context||t._Store.context),y=t.Identity.getCurrentUser(),tryOnUserAlias(c,y,d,t.Logger);var U=t._Persistence.getPersistence();y&&(t._Persistence.storeDataInMemory(U,y.getMPID()),n.reinitForwardersOnUserChange(c,y),n.setForwarderCallbacks(y,o));var C=IdentityType.getNewIdentitiesByName(v),k=o===Modify$1?_:P;// https://go.mparticle.com/work/SQDSDKS-6501
|
|
1267
1267
|
n.sendUserIdentityChangeEvent(C,o,p.mpid,k);}if(a){var f=0===r.status?HTTPCodes$2.noHttpCoverage:r.status;t._Helpers.invokeCallback(a,f,p||null,y);}else p&&!isEmpty(p.errors)&&// https://go.mparticle.com/work/SQDSDKS-6500
|
|
1268
|
-
t.Logger.error("Received HTTP response code of "+r.status+" - "+p.errors[0].message);t.Logger.verbose("Successfully parsed Identity Response"),null===(b=t._APIClient)||void 0===b||b.processQueuedEvents();}catch(s){a&&t._Helpers.invokeCallback(a,r.status,p||null),t.Logger.error("Error parsing JSON response from Identity server: "+s);}t._Store.isInitialized=!0,t._preInit.readyQueue=processReadyQueue(t._preInit.readyQueue);},this.sendUserIdentityChangeEvent=function(e,r,s,i){if(s||r===Modify$1)// https://go.mparticle.com/work/SQDSDKS-6501
|
|
1268
|
+
t.Logger.error("Received HTTP response code of "+r.status+" - "+p.errors[0].message);t.Logger.verbose("Successfully parsed Identity Response"),null===(b=t._APIClient)||void 0===b||b.processQueuedEvents();}catch(s){a&&t._Helpers.invokeCallback(a,r.status,p||null),t.Logger.error("Error parsing JSON response from Identity server: "+s);}t._Store.isInitialized=!0,t._RoktManager.isReady()&&(t._RoktManager.currentUser=t.Identity.getCurrentUser()),t._preInit.readyQueue=processReadyQueue(t._preInit.readyQueue);},this.sendUserIdentityChangeEvent=function(e,r,s,i){if(s||r===Modify$1)// https://go.mparticle.com/work/SQDSDKS-6501
|
|
1269
1269
|
{// https://go.mparticle.com/work/SQDSDKS-6354
|
|
1270
1270
|
var a=this.IdentityAPI.getUser(s);for(var d in e)// Verifies a change actually happened
|
|
1271
1271
|
if(i[d]!==e[d]){var o,g=!i[d],l=n.createUserIdentityChange(d,e[d],i[d],g,a);// If a new identity type was introduced when the identity changes
|
|
@@ -1424,10 +1424,16 @@ var RoktManager=/** @class */function(){function a(){this.kit=null,this.filters=
|
|
|
1424
1424
|
* @param {IMParticleUser} filteredUser - User object with filtered attributes
|
|
1425
1425
|
* @param {SDKIdentityApi} identityService - The mParticle Identity instance
|
|
1426
1426
|
* @param {SDKLoggerApi} logger - The mParticle Logger instance
|
|
1427
|
-
* @param {
|
|
1427
|
+
* @param {IRoktOptions} options - Options for the RoktManager
|
|
1428
1428
|
*
|
|
1429
1429
|
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
1430
|
-
*/return a.prototype.init=function(a,b,c,d,e){var f=a||{},g=f.userAttributeFilters,h=f.settings,i=(h||{}).placementAttributesMapping;try{this.placementAttributesMapping=parseSettingsString(i);}catch(a){console.error("Error parsing placement attributes mapping from config",a);}this.identityService=c,this.logger=d,this.filters={userAttributeFilters:g,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b}
|
|
1430
|
+
*/return a.prototype.init=function(a,b,c,d,e){var f=a||{},g=f.userAttributeFilters,h=f.settings,i=(h||{}).placementAttributesMapping;try{this.placementAttributesMapping=parseSettingsString(i);}catch(a){console.error("Error parsing placement attributes mapping from config",a);}this.identityService=c,this.logger=d,this.filters={userAttributeFilters:g,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b};// This is the global setting for sandbox mode
|
|
1431
|
+
// It is set here and passed in to the createLauncher method in the Rokt Kit
|
|
1432
|
+
// This is not to be confused for the `sandbox` flag in the selectPlacements attributes
|
|
1433
|
+
// as that is independent of this setting, though they share the same name.
|
|
1434
|
+
var j=(null===e||void 0===e?void 0:e.sandbox)||!1;// Launcher options are set here for the kit to pick up and pass through
|
|
1435
|
+
// to the Rokt Launcher.
|
|
1436
|
+
this.launcherOptions=__assign({sandbox:j},null===e||void 0===e?void 0:e.launcherOptions);},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=this;return __generator(this,function(o){switch(o.label){case 0:if(!this.isReady())return this.queueMessage({methodName:"selectPlacements",payload:a}),[2/*return*/,Promise.resolve({})];o.label=1;case 1:if(o.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,!i||h&&h===i)return [3/*break*/,5];h&&h!==i&&this.logger.warning("Email mismatch detected. Current email, ".concat(h," differs from email passed to selectPlacements call, ").concat(i,". Proceeding to call identify with ").concat(i,". Please verify your implementation.")),o.label=2;case 2:return o.trys.push([2,4,,5]),[4/*yield*/,new Promise(function(a){n.identityService.identify({userIdentities:__assign(__assign({},g),{email:i})},function(){a();});})];case 3:return o.sent(),[3/*break*/,5];case 4:return j=o.sent(),this.logger.error("Failed to identify user with new email: "+JSON.stringify(j)),[3/*break*/,5];case 5:return this.setUserAttributes(f),k=__assign(__assign({},f),null===e?{}:{sandbox:e}),l=__assign(__assign({},a),{attributes:k}),[2/*return*/,this.kit.selectPlacements(l)];case 6:return m=o.sent(),[2/*return*/,Promise.reject(m instanceof Error?m:new Error("Unknown error occurred"))];case 7:return [2/*return*/]}})})},a.prototype.hashAttributes=function(a){if(!this.isReady())return this.queueMessage({methodName:"hashAttributes",payload:a}),Promise.resolve({});try{return this.kit.hashAttributes(a)}catch(a){return Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))}},a.prototype.setExtensionData=function(a){if(!this.isReady())return void this.queueMessage({methodName:"setExtensionData",payload: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.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
|
|
1431
1437
|
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)&&(c[d]=a[d]);try{this.currentUser.setUserAttributes(c);}catch(a){console.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=this;0<this.messageQueue.length&&this.isReady()&&(this.messageQueue.forEach(function(b){return __awaiter(a,void 0,void 0,function(){return __generator(this,function(a){switch(a.label){case 0:return this.kit&&b.methodName in this.kit?[4/*yield*/,this.kit[b.methodName](b.payload)]:[3/*break*/,2];case 1:a.sent(),a.label=2;case 2:return [2/*return*/]}})})}),this.messageQueue=[]);},a.prototype.queueMessage=function(a){this.messageQueue.push(a);},a}();
|
|
1432
1438
|
|
|
1433
1439
|
var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
|
|
@@ -1765,9 +1771,9 @@ function completeSDKInitialization(a,b,c){var d=createKitBlocker(b,c);// Web Vie
|
|
|
1765
1771
|
// responsible for sending events directly to mParticle's servers. The Web SDK will not initialize
|
|
1766
1772
|
// persistence or Identity directly.
|
|
1767
1773
|
if(c._APIClient=new APIClient(c,d),c._Forwarders=new Forwarders(c,d),c._Store.processConfig(b),c._Identity.idCache=createIdentityCache(c),removeExpiredIdentityCacheDates(c._Identity.idCache),c._Store.webviewBridgeEnabled)c._NativeSdkHelpers.initializeSessionAttributes(a);else {c._Persistence.initializeStorage(),c._Store.syncPersistenceData();// Set up user identitiy variables for later use
|
|
1768
|
-
var e=c.Identity.getCurrentUser(),f=e?e.getMPID():null,g=e?e.getUserIdentities().userIdentities:{};c._Store.SDKConfig.identifyRequest=c._Store.hasInvalidIdentifyRequest()?{userIdentities:g}:c._Store.SDKConfig.identifyRequest,c._Helpers.getFeatureFlag(ReportBatching)&&c._ForwardingStatsUploader.startForwardingStatsTimer(),c._Helpers.getFeatureFlag(CaptureIntegrationSpecificIds)&&c._IntegrationCapture.capture()
|
|
1769
|
-
var h=parseConfig(b,"Rokt",181);if(h){var i=h.userAttributeFilters,j=filteredMparticleUser(f,{userAttributeFilters:i},c),k={sandbox:b.isDevelopmentMode};// https://go.mparticle.com/work/SQDSDKS-7339
|
|
1770
|
-
c._RoktManager.init(h,j,c.Identity,c.Logger,k);}processIdentityCallback(c,e,f,g);}// We will continue to clear out the ready queue as part of the initial init flow
|
|
1774
|
+
var e=c.Identity.getCurrentUser(),f=e?e.getMPID():null,g=e?e.getUserIdentities().userIdentities:{};c._Store.SDKConfig.identifyRequest=c._Store.hasInvalidIdentifyRequest()?{userIdentities:g}:c._Store.SDKConfig.identifyRequest,c._Helpers.getFeatureFlag(ReportBatching)&&c._ForwardingStatsUploader.startForwardingStatsTimer(),c._Helpers.getFeatureFlag(CaptureIntegrationSpecificIds)&&c._IntegrationCapture.capture();// Configure Rokt Manager with user and filtered user
|
|
1775
|
+
var h=parseConfig(b,"Rokt",181);if(h){var i=h.userAttributeFilters,j=filteredMparticleUser(f,{userAttributeFilters:i},c),k={sandbox:null===b||void 0===b?void 0:b.isDevelopmentMode,launcherOptions:null===b||void 0===b?void 0:b.launcherOptions};// https://go.mparticle.com/work/SQDSDKS-7339
|
|
1776
|
+
c._RoktManager.init(h,j,c.Identity,c.Logger,k);}c._Forwarders.processForwarders(b,c._APIClient.prepareForwardingStats),c._Forwarders.processPixelConfigs(b),c._SessionManager.initialize(),c._Events.logAST(),processIdentityCallback(c,e,f,g);}// We will continue to clear out the ready queue as part of the initial init flow
|
|
1771
1777
|
// if an identify request is unnecessary, such as if there is an existing session
|
|
1772
1778
|
(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
|
|
1773
1779
|
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.41.1";
|
|
207
207
|
|
|
208
208
|
var Constants = {
|
|
209
209
|
sdkVersion: version,
|
|
@@ -8236,6 +8236,9 @@ var mParticle = (function () {
|
|
|
8236
8236
|
mpInstance.Logger.error('Error parsing JSON response from Identity server: ' + e);
|
|
8237
8237
|
}
|
|
8238
8238
|
mpInstance._Store.isInitialized = true;
|
|
8239
|
+
if (mpInstance._RoktManager.isReady()) {
|
|
8240
|
+
mpInstance._RoktManager.currentUser = mpInstance.Identity.getCurrentUser();
|
|
8241
|
+
}
|
|
8239
8242
|
mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue);
|
|
8240
8243
|
};
|
|
8241
8244
|
|
|
@@ -9675,7 +9678,7 @@ var mParticle = (function () {
|
|
|
9675
9678
|
* @param {IMParticleUser} filteredUser - User object with filtered attributes
|
|
9676
9679
|
* @param {SDKIdentityApi} identityService - The mParticle Identity instance
|
|
9677
9680
|
* @param {SDKLoggerApi} logger - The mParticle Logger instance
|
|
9678
|
-
* @param {
|
|
9681
|
+
* @param {IRoktOptions} options - Options for the RoktManager
|
|
9679
9682
|
*
|
|
9680
9683
|
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
9681
9684
|
*/
|
|
@@ -9696,7 +9699,16 @@ var mParticle = (function () {
|
|
|
9696
9699
|
filterUserAttributes: KitFilterHelper.filterUserAttributes,
|
|
9697
9700
|
filteredUser: filteredUser
|
|
9698
9701
|
};
|
|
9699
|
-
|
|
9702
|
+
// This is the global setting for sandbox mode
|
|
9703
|
+
// It is set here and passed in to the createLauncher method in the Rokt Kit
|
|
9704
|
+
// This is not to be confused for the `sandbox` flag in the selectPlacements attributes
|
|
9705
|
+
// as that is independent of this setting, though they share the same name.
|
|
9706
|
+
var sandbox = (options === null || options === void 0 ? void 0 : options.sandbox) || false;
|
|
9707
|
+
// Launcher options are set here for the kit to pick up and pass through
|
|
9708
|
+
// to the Rokt Launcher.
|
|
9709
|
+
this.launcherOptions = __assign({
|
|
9710
|
+
sandbox: sandbox
|
|
9711
|
+
}, options === null || options === void 0 ? void 0 : options.launcherOptions);
|
|
9700
9712
|
};
|
|
9701
9713
|
RoktManager.prototype.attachKit = function (kit) {
|
|
9702
9714
|
this.kit = kit;
|
|
@@ -9718,12 +9730,12 @@ var mParticle = (function () {
|
|
|
9718
9730
|
* });
|
|
9719
9731
|
*/
|
|
9720
9732
|
RoktManager.prototype.selectPlacements = function (options) {
|
|
9721
|
-
var _a, _b
|
|
9733
|
+
var _a, _b;
|
|
9722
9734
|
return __awaiter(this, void 0, void 0, function () {
|
|
9723
9735
|
var attributes, sandboxValue, mappedAttributes, currentUserIdentities_1, currentEmail, newEmail_1, error_1, enrichedAttributes, enrichedOptions, error_2;
|
|
9724
9736
|
var _this = this;
|
|
9725
|
-
return __generator(this, function (
|
|
9726
|
-
switch (
|
|
9737
|
+
return __generator(this, function (_c) {
|
|
9738
|
+
switch (_c.label) {
|
|
9727
9739
|
case 0:
|
|
9728
9740
|
if (!this.isReady()) {
|
|
9729
9741
|
this.queueMessage({
|
|
@@ -9732,24 +9744,24 @@ var mParticle = (function () {
|
|
|
9732
9744
|
});
|
|
9733
9745
|
return [2 /*return*/, Promise.resolve({})];
|
|
9734
9746
|
}
|
|
9735
|
-
|
|
9747
|
+
_c.label = 1;
|
|
9736
9748
|
case 1:
|
|
9737
|
-
|
|
9749
|
+
_c.trys.push([1, 6,, 7]);
|
|
9738
9750
|
attributes = options.attributes;
|
|
9739
|
-
sandboxValue = (
|
|
9751
|
+
sandboxValue = (attributes === null || attributes === void 0 ? void 0 : attributes.sandbox) || null;
|
|
9740
9752
|
mappedAttributes = this.mapPlacementAttributes(attributes, this.placementAttributesMapping);
|
|
9741
9753
|
// Get current user identities
|
|
9742
9754
|
this.currentUser = this.identityService.getCurrentUser();
|
|
9743
|
-
currentUserIdentities_1 = ((
|
|
9755
|
+
currentUserIdentities_1 = ((_b = (_a = this.currentUser) === null || _a === void 0 ? void 0 : _a.getUserIdentities()) === null || _b === void 0 ? void 0 : _b.userIdentities) || {};
|
|
9744
9756
|
currentEmail = currentUserIdentities_1.email;
|
|
9745
9757
|
newEmail_1 = mappedAttributes.email;
|
|
9746
9758
|
if (!(newEmail_1 && (!currentEmail || currentEmail !== newEmail_1))) return [3 /*break*/, 5];
|
|
9747
9759
|
if (currentEmail && currentEmail !== newEmail_1) {
|
|
9748
9760
|
this.logger.warning("Email mismatch detected. Current email, ".concat(currentEmail, " differs from email passed to selectPlacements call, ").concat(newEmail_1, ". Proceeding to call identify with ").concat(newEmail_1, ". Please verify your implementation."));
|
|
9749
9761
|
}
|
|
9750
|
-
|
|
9762
|
+
_c.label = 2;
|
|
9751
9763
|
case 2:
|
|
9752
|
-
|
|
9764
|
+
_c.trys.push([2, 4,, 5]);
|
|
9753
9765
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
9754
9766
|
_this.identityService.identify({
|
|
9755
9767
|
userIdentities: __assign(__assign({}, currentUserIdentities_1), {
|
|
@@ -9760,10 +9772,10 @@ var mParticle = (function () {
|
|
|
9760
9772
|
});
|
|
9761
9773
|
})];
|
|
9762
9774
|
case 3:
|
|
9763
|
-
|
|
9775
|
+
_c.sent();
|
|
9764
9776
|
return [3 /*break*/, 5];
|
|
9765
9777
|
case 4:
|
|
9766
|
-
error_1 =
|
|
9778
|
+
error_1 = _c.sent();
|
|
9767
9779
|
this.logger.error('Failed to identify user with new email: ' + JSON.stringify(error_1));
|
|
9768
9780
|
return [3 /*break*/, 5];
|
|
9769
9781
|
case 5:
|
|
@@ -9776,7 +9788,7 @@ var mParticle = (function () {
|
|
|
9776
9788
|
});
|
|
9777
9789
|
return [2 /*return*/, this.kit.selectPlacements(enrichedOptions)];
|
|
9778
9790
|
case 6:
|
|
9779
|
-
error_2 =
|
|
9791
|
+
error_2 = _c.sent();
|
|
9780
9792
|
return [2 /*return*/, Promise.reject(error_2 instanceof Error ? error_2 : new Error('Unknown error occurred'))];
|
|
9781
9793
|
case 7:
|
|
9782
9794
|
return [2 /*return*/];
|
|
@@ -10846,12 +10858,6 @@ var mParticle = (function () {
|
|
|
10846
10858
|
if (mpInstance._Helpers.getFeatureFlag(CaptureIntegrationSpecificIds)) {
|
|
10847
10859
|
mpInstance._IntegrationCapture.capture();
|
|
10848
10860
|
}
|
|
10849
|
-
mpInstance._Forwarders.processForwarders(config, mpInstance._APIClient.prepareForwardingStats);
|
|
10850
|
-
mpInstance._Forwarders.processPixelConfigs(config);
|
|
10851
|
-
// Checks if session is created, resumed, or needs to be ended
|
|
10852
|
-
// Logs a session start or session end event accordingly
|
|
10853
|
-
mpInstance._SessionManager.initialize();
|
|
10854
|
-
mpInstance._Events.logAST();
|
|
10855
10861
|
// Configure Rokt Manager with user and filtered user
|
|
10856
10862
|
var roktConfig = parseConfig(config, 'Rokt', 181);
|
|
10857
10863
|
if (roktConfig) {
|
|
@@ -10860,11 +10866,18 @@ var mParticle = (function () {
|
|
|
10860
10866
|
userAttributeFilters: userAttributeFilters
|
|
10861
10867
|
}, mpInstance);
|
|
10862
10868
|
var roktOptions = {
|
|
10863
|
-
sandbox: config.isDevelopmentMode
|
|
10869
|
+
sandbox: config === null || config === void 0 ? void 0 : config.isDevelopmentMode,
|
|
10870
|
+
launcherOptions: config === null || config === void 0 ? void 0 : config.launcherOptions
|
|
10864
10871
|
};
|
|
10865
10872
|
// https://go.mparticle.com/work/SQDSDKS-7339
|
|
10866
10873
|
mpInstance._RoktManager.init(roktConfig, roktFilteredUser, mpInstance.Identity, mpInstance.Logger, roktOptions);
|
|
10867
10874
|
}
|
|
10875
|
+
mpInstance._Forwarders.processForwarders(config, mpInstance._APIClient.prepareForwardingStats);
|
|
10876
|
+
mpInstance._Forwarders.processPixelConfigs(config);
|
|
10877
|
+
// Checks if session is created, resumed, or needs to be ended
|
|
10878
|
+
// Logs a session start or session end event accordingly
|
|
10879
|
+
mpInstance._SessionManager.initialize();
|
|
10880
|
+
mpInstance._Events.logAST();
|
|
10868
10881
|
processIdentityCallback(mpInstance, currentUser, currentUserMPID, currentUserIdentities);
|
|
10869
10882
|
}
|
|
10870
10883
|
// We will continue to clear out the ready queue as part of the initial init flow
|
package/package.json
CHANGED
package/src/identity.js
CHANGED
|
@@ -1677,6 +1677,10 @@ export default function Identity(mpInstance) {
|
|
|
1677
1677
|
}
|
|
1678
1678
|
mpInstance._Store.isInitialized = true;
|
|
1679
1679
|
|
|
1680
|
+
if (mpInstance._RoktManager.isReady()) {
|
|
1681
|
+
mpInstance._RoktManager.currentUser = mpInstance.Identity.getCurrentUser();
|
|
1682
|
+
}
|
|
1683
|
+
|
|
1680
1684
|
mpInstance._preInit.readyQueue = processReadyQueue(
|
|
1681
1685
|
mpInstance._preInit.readyQueue
|
|
1682
1686
|
);
|
package/src/mp-instance.ts
CHANGED
|
@@ -49,7 +49,7 @@ import { IECommerce } from './ecommerce.interfaces';
|
|
|
49
49
|
import { INativeSdkHelpers } from './nativeSdkHelpers.interfaces';
|
|
50
50
|
import { IPersistence } from './persistence.interfaces';
|
|
51
51
|
import ForegroundTimer from './foregroundTimeTracker';
|
|
52
|
-
import RoktManager, {
|
|
52
|
+
import RoktManager, { IRoktOptions } from './roktManager';
|
|
53
53
|
import filteredMparticleUser from './filteredMparticleUser';
|
|
54
54
|
|
|
55
55
|
export interface IErrorLogMessage {
|
|
@@ -1394,17 +1394,6 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
|
1394
1394
|
mpInstance._IntegrationCapture.capture();
|
|
1395
1395
|
}
|
|
1396
1396
|
|
|
1397
|
-
mpInstance._Forwarders.processForwarders(
|
|
1398
|
-
config,
|
|
1399
|
-
mpInstance._APIClient.prepareForwardingStats
|
|
1400
|
-
);
|
|
1401
|
-
mpInstance._Forwarders.processPixelConfigs(config);
|
|
1402
|
-
|
|
1403
|
-
// Checks if session is created, resumed, or needs to be ended
|
|
1404
|
-
// Logs a session start or session end event accordingly
|
|
1405
|
-
mpInstance._SessionManager.initialize();
|
|
1406
|
-
mpInstance._Events.logAST();
|
|
1407
|
-
|
|
1408
1397
|
// Configure Rokt Manager with user and filtered user
|
|
1409
1398
|
const roktConfig: IKitConfigs = parseConfig(config, 'Rokt', 181);
|
|
1410
1399
|
if (roktConfig) {
|
|
@@ -1414,10 +1403,10 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
|
1414
1403
|
{ userAttributeFilters },
|
|
1415
1404
|
mpInstance
|
|
1416
1405
|
);
|
|
1417
|
-
const roktOptions:
|
|
1418
|
-
sandbox: config
|
|
1406
|
+
const roktOptions: IRoktOptions = {
|
|
1407
|
+
sandbox: config?.isDevelopmentMode,
|
|
1408
|
+
launcherOptions: config?.launcherOptions,
|
|
1419
1409
|
};
|
|
1420
|
-
|
|
1421
1410
|
// https://go.mparticle.com/work/SQDSDKS-7339
|
|
1422
1411
|
mpInstance._RoktManager.init(
|
|
1423
1412
|
roktConfig,
|
|
@@ -1428,6 +1417,17 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
|
1428
1417
|
);
|
|
1429
1418
|
}
|
|
1430
1419
|
|
|
1420
|
+
mpInstance._Forwarders.processForwarders(
|
|
1421
|
+
config,
|
|
1422
|
+
mpInstance._APIClient.prepareForwardingStats
|
|
1423
|
+
);
|
|
1424
|
+
mpInstance._Forwarders.processPixelConfigs(config);
|
|
1425
|
+
|
|
1426
|
+
// Checks if session is created, resumed, or needs to be ended
|
|
1427
|
+
// Logs a session start or session end event accordingly
|
|
1428
|
+
mpInstance._SessionManager.initialize();
|
|
1429
|
+
mpInstance._Events.logAST();
|
|
1430
|
+
|
|
1431
1431
|
processIdentityCallback(
|
|
1432
1432
|
mpInstance,
|
|
1433
1433
|
currentUser,
|
package/src/roktManager.ts
CHANGED
|
@@ -52,12 +52,16 @@ export interface IRoktKit {
|
|
|
52
52
|
hashAttributes: (attributes: IRoktPartnerAttributes) => Promise<Record<string, string>>;
|
|
53
53
|
selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise<IRoktSelection>;
|
|
54
54
|
setExtensionData<T>(extensionData: IRoktPartnerExtensionData<T>): void;
|
|
55
|
+
launcherOptions?: Dictionary<any>;
|
|
55
56
|
}
|
|
56
57
|
|
|
57
|
-
export interface
|
|
58
|
+
export interface IRoktOptions {
|
|
58
59
|
sandbox?: boolean;
|
|
60
|
+
launcherOptions?: IRoktLauncherOptions;
|
|
59
61
|
}
|
|
60
62
|
|
|
63
|
+
export type IRoktLauncherOptions = Dictionary<any>;
|
|
64
|
+
|
|
61
65
|
// The purpose of this class is to create a link between the Core mParticle SDK and the
|
|
62
66
|
// Rokt Web SDK via a Web Kit.
|
|
63
67
|
// The Rokt Manager should load before the Web Kit and stubs out many of the
|
|
@@ -75,8 +79,8 @@ export default class RoktManager {
|
|
|
75
79
|
private sandbox: boolean | null = null;
|
|
76
80
|
private placementAttributesMapping: Dictionary<string>[] = [];
|
|
77
81
|
private identityService: SDKIdentityApi;
|
|
82
|
+
private launcherOptions?: IRoktLauncherOptions;
|
|
78
83
|
private logger: SDKLoggerApi;
|
|
79
|
-
|
|
80
84
|
/**
|
|
81
85
|
* Initializes the RoktManager with configuration settings and user data.
|
|
82
86
|
*
|
|
@@ -84,7 +88,7 @@ export default class RoktManager {
|
|
|
84
88
|
* @param {IMParticleUser} filteredUser - User object with filtered attributes
|
|
85
89
|
* @param {SDKIdentityApi} identityService - The mParticle Identity instance
|
|
86
90
|
* @param {SDKLoggerApi} logger - The mParticle Logger instance
|
|
87
|
-
* @param {
|
|
91
|
+
* @param {IRoktOptions} options - Options for the RoktManager
|
|
88
92
|
*
|
|
89
93
|
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
90
94
|
*/
|
|
@@ -93,7 +97,7 @@ export default class RoktManager {
|
|
|
93
97
|
filteredUser: IMParticleUser,
|
|
94
98
|
identityService: SDKIdentityApi,
|
|
95
99
|
logger?: SDKLoggerApi,
|
|
96
|
-
options?:
|
|
100
|
+
options?: IRoktOptions
|
|
97
101
|
): void {
|
|
98
102
|
const { userAttributeFilters, settings } = roktConfig || {};
|
|
99
103
|
const { placementAttributesMapping } = settings || {};
|
|
@@ -113,7 +117,15 @@ export default class RoktManager {
|
|
|
113
117
|
filteredUser: filteredUser,
|
|
114
118
|
};
|
|
115
119
|
|
|
116
|
-
|
|
120
|
+
// This is the global setting for sandbox mode
|
|
121
|
+
// It is set here and passed in to the createLauncher method in the Rokt Kit
|
|
122
|
+
// This is not to be confused for the `sandbox` flag in the selectPlacements attributes
|
|
123
|
+
// as that is independent of this setting, though they share the same name.
|
|
124
|
+
const sandbox = options?.sandbox || false;
|
|
125
|
+
|
|
126
|
+
// Launcher options are set here for the kit to pick up and pass through
|
|
127
|
+
// to the Rokt Launcher.
|
|
128
|
+
this.launcherOptions = { sandbox, ...options?.launcherOptions };
|
|
117
129
|
}
|
|
118
130
|
|
|
119
131
|
public attachKit(kit: IRoktKit): void {
|
|
@@ -147,7 +159,7 @@ export default class RoktManager {
|
|
|
147
159
|
|
|
148
160
|
try {
|
|
149
161
|
const { attributes } = options;
|
|
150
|
-
const sandboxValue = attributes?.sandbox
|
|
162
|
+
const sandboxValue = attributes?.sandbox || null;
|
|
151
163
|
const mappedAttributes = this.mapPlacementAttributes(attributes, this.placementAttributesMapping);
|
|
152
164
|
|
|
153
165
|
// Get current user identities
|
package/src/sdkRuntimeModels.ts
CHANGED
|
@@ -39,7 +39,7 @@ import _BatchValidator from './mockBatchCreator';
|
|
|
39
39
|
import { SDKECommerceAPI } from './ecommerce.interfaces';
|
|
40
40
|
import { IErrorLogMessage, IMParticleWebSDKInstance, IntegrationDelays } from './mp-instance';
|
|
41
41
|
import Constants from './constants';
|
|
42
|
-
import RoktManager from './roktManager';
|
|
42
|
+
import RoktManager, { IRoktLauncherOptions } from './roktManager';
|
|
43
43
|
|
|
44
44
|
// TODO: Resolve this with version in @mparticle/web-sdk
|
|
45
45
|
export type SDKEventCustomFlags = Dictionary<any>;
|
|
@@ -301,6 +301,8 @@ export interface SDKInitConfig
|
|
|
301
301
|
// https://go.mparticle.com/work/SQDSDKS-6460
|
|
302
302
|
identityCallback?: IdentityCallback;
|
|
303
303
|
|
|
304
|
+
launcherOptions?: IRoktLauncherOptions;
|
|
305
|
+
|
|
304
306
|
rq?: Function[] | any[];
|
|
305
307
|
}
|
|
306
308
|
|