@mparticle/web-sdk 2.55.0 → 2.57.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 +15 -23
- package/dist/mparticle.esm.js +15 -23
- package/dist/mparticle.js +96 -45
- package/package.json +1 -1
- package/src/identityApiClient.ts +20 -11
- package/src/mp-instance.ts +35 -6
- package/src/roktManager.ts +22 -6
- package/src/store.ts +2 -0
- 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.57.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
|
|
@@ -28,7 +28,7 @@ CaptureIntegrationSpecificIds:"captureIntegrationSpecificIds",// CaptureIntegrat
|
|
|
28
28
|
// - 'none' → capture none
|
|
29
29
|
// - 'roktonly' → capture only Rokt-related IDs
|
|
30
30
|
CaptureIntegrationSpecificIdsV2:"captureIntegrationSpecificIdsV2",AstBackgroundEvents:"astBackgroundEvents"},DefaultInstance:"default_instance",CCPAPurpose:"data_sale_opt_out",IdentityMethods:{Modify:"modify",Logout:"logout",Login:"login",Identify:"identify"},Environment:{Development:"development",Production:"production"},CaptureIntegrationSpecificIdsV2Modes:{All:"all",None:"none",RoktOnly:"roktonly"},Rokt:{LauncherInstanceGuidKey:"__rokt_li_guid__"}};var ONE_DAY_IN_SECONDS=86400;var MILLIS_IN_ONE_SEC=1e3;// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
|
|
31
|
-
var HTTP_OK=200;var HTTP_ACCEPTED=202;var HTTP_BAD_REQUEST=400;
|
|
31
|
+
var HTTP_OK=200;var HTTP_ACCEPTED=202;var HTTP_BAD_REQUEST=400;var HTTP_SERVER_ERROR=500;
|
|
32
32
|
|
|
33
33
|
/******************************************************************************
|
|
34
34
|
Copyright (c) Microsoft Corporation.
|
|
@@ -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",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};
|
|
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",JointSdkRoktKitInit:"mp:jointSdkRoktKitInit"};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";
|
|
@@ -580,7 +580,7 @@ document.addEventListener("visibilitychange",function(){return a.handleVisibilit
|
|
|
580
580
|
|
|
581
581
|
function createSDKConfig(a){// TODO: Refactor to create a default config object
|
|
582
582
|
var b={};for(var c in Constants.DefaultConfig)Constants.DefaultConfig.hasOwnProperty(c)&&(b[c]=Constants.DefaultConfig[c]);if(a)for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);for(var c in Constants.DefaultBaseUrls)b[c]=Constants.DefaultBaseUrls[c];return b}// TODO: Merge this with SDKStoreApi in sdkRuntimeModels
|
|
583
|
-
function Store(a,b,c){var d=this,e=b._Helpers.createMainStorageName,f=b._NativeSdkHelpers.isWebviewEnabled,g={isEnabled:!0,sessionAttributes:{},localSessionAttributes:{},currentSessionMPIDs:[],consentState:null,sessionId:null,isFirstRun:null,clientId:null,deviceId:null,devToken:null,serverSettings:{},dateLastEventSent:null,sessionStartDate:null,currentPosition:null,isTracking:!1,watchPositionId:null,cartProducts:[],eventQueue:[],currencyCode:null,globalTimer:null,context:null,configurationLoaded:!1,identityCallInFlight:!1,identifyRequestCount:0,SDKConfig:{},nonCurrentUserMPIDs:{},identifyCalled:!1,isLoggedIn:!1,cookieSyncDates:{},integrationAttributes:{},requireDelay:!0,isLocalStorageAvailable:null,storageName:null,activeForwarders:[],kits:{},sideloadedKits:[],configuredForwarders:[],pixelConfigurations:[],wrapperSDKInfo:{name:"none",version:null,isInfoSet:!1},// Placeholder for in-memory persistence model
|
|
583
|
+
function Store(a,b,c){var d=this,e=b._Helpers.createMainStorageName,f=b._NativeSdkHelpers.isWebviewEnabled,g={isEnabled:!0,sessionAttributes:{},localSessionAttributes:{},currentSessionMPIDs:[],consentState:null,sessionId:null,isFirstRun:null,clientId:null,deviceId:null,devToken:null,serverSettings:{},dateLastEventSent:null,sessionStartDate:null,currentPosition:null,isTracking:!1,watchPositionId:null,cartProducts:[],eventQueue:[],currencyCode:null,globalTimer:null,context:null,configurationLoaded:!1,identityCallInFlight:!1,identityCallFailed:!1,identifyRequestCount:0,SDKConfig:{},nonCurrentUserMPIDs:{},identifyCalled:!1,isLoggedIn:!1,cookieSyncDates:{},integrationAttributes:{},requireDelay:!0,isLocalStorageAvailable:null,storageName:null,activeForwarders:[],kits:{},sideloadedKits:[],configuredForwarders:[],pixelConfigurations:[],wrapperSDKInfo:{name:"none",version:null,isInfoSet:!1},// Placeholder for in-memory persistence model
|
|
584
584
|
persistenceData:{gs:{}}};for(var h in g)this[h]=g[h];if(this.devToken=c||null,this.integrationDelayTimeoutStart=Date.now(),this.SDKConfig=createSDKConfig(a),a){a.hasOwnProperty("flags")||(this.SDKConfig.flags={}),this.SDKConfig.flags=processFlags(a),a.deviceId&&(this.deviceId=a.deviceId),this.SDKConfig.isDevelopmentMode=!!a.hasOwnProperty("isDevelopmentMode")&&returnConvertedBoolean(a.isDevelopmentMode);var i=processBaseUrls(a,this.SDKConfig.flags,c);for(var j in i)this.SDKConfig[j]=i[j];if(a.hasOwnProperty("logLevel")&&(this.SDKConfig.logLevel=a.logLevel),this.SDKConfig.useNativeSdk=!!a.useNativeSdk,this.SDKConfig.kits=a.kits||{},this.SDKConfig.sideloadedKits=a.sideloadedKits||[],this.SDKConfig.isIOS=a.hasOwnProperty("isIOS")?a.isIOS:!!(window.mParticle&&window.mParticle.isIOS)&&window.mParticle.isIOS,this.SDKConfig.useCookieStorage=!!a.hasOwnProperty("useCookieStorage")&&a.useCookieStorage,this.SDKConfig.maxProducts=a.hasOwnProperty("maxProducts")?a.maxProducts:Constants.DefaultConfig.maxProducts,this.SDKConfig.maxCookieSize=a.hasOwnProperty("maxCookieSize")?a.maxCookieSize:Constants.DefaultConfig.maxCookieSize,a.hasOwnProperty("appName")&&(this.SDKConfig.appName=a.appName),a.hasOwnProperty("package")&&(this.SDKConfig["package"]=a["package"]),this.SDKConfig.integrationDelayTimeout=a.hasOwnProperty("integrationDelayTimeout")?a.integrationDelayTimeout:Constants.DefaultConfig.integrationDelayTimeout,a.hasOwnProperty("identifyRequest")&&(this.SDKConfig.identifyRequest=a.identifyRequest),a.hasOwnProperty("identityCallback")){var k=a.identityCallback;b._Helpers.Validators.isFunction(k)?this.SDKConfig.identityCallback=a.identityCallback:b.Logger.warning("The optional callback must be a function. You tried entering a(n) "+_typeof$1(k)+" . Callback not set. Please set your callback again.");}if(a.hasOwnProperty("appVersion")&&(this.SDKConfig.appVersion=a.appVersion),a.hasOwnProperty("appName")&&(this.SDKConfig.appName=a.appName),a.hasOwnProperty("sessionTimeout")&&(this.SDKConfig.sessionTimeout=a.sessionTimeout),a.hasOwnProperty("dataPlan")){this.SDKConfig.dataPlan={PlanVersion:null,PlanId:null};var l=a.dataPlan;l.planId&&(isDataPlanSlug(l.planId)?this.SDKConfig.dataPlan.PlanId=l.planId:b.Logger.error("Your data plan id must be a string and match the data plan slug format (i.e. under_case_slug)")),l.planVersion&&(isNumber(l.planVersion)?this.SDKConfig.dataPlan.PlanVersion=l.planVersion:b.Logger.error("Your data plan version must be a number"));}else this.SDKConfig.dataPlan={};if(this.SDKConfig.forceHttps=!a.hasOwnProperty("forceHttps")||a.forceHttps,this.SDKConfig.customFlags=a.customFlags||{},this.SDKConfig.minWebviewBridgeVersion=a.hasOwnProperty("minWebviewBridgeVersion")?a.minWebviewBridgeVersion:1,this.SDKConfig.aliasMaxWindow=a.hasOwnProperty("aliasMaxWindow")?a.aliasMaxWindow:Constants.DefaultConfig.aliasMaxWindow,a.hasOwnProperty("dataPlanOptions")){var m=a.dataPlanOptions;m.hasOwnProperty("dataPlanVersion")&&m.hasOwnProperty("blockUserAttributes")&&m.hasOwnProperty("blockEventAttributes")&&m.hasOwnProperty("blockEvents")&&m.hasOwnProperty("blockUserIdentities")||b.Logger.error("Ensure your config.dataPlanOptions object has the following keys: a \"dataPlanVersion\" object, and \"blockUserAttributes\", \"blockEventAttributes\", \"blockEvents\", \"blockUserIdentities\" booleans");}a.hasOwnProperty("onCreateBatch")&&("function"==typeof a.onCreateBatch?this.SDKConfig.onCreateBatch=a.onCreateBatch:(b.Logger.error("config.onCreateBatch must be a function"),this.SDKConfig.onCreateBatch=void 0));}this._getFromPersistence=function(a,b){return a?(d.syncPersistenceData(),d.persistenceData&&d.persistenceData[a]&&d.persistenceData[a][b]?d.persistenceData[a][b]:null):null},this._setPersistence=function(a,c,e){var f;a&&(d.syncPersistenceData(),d.persistenceData&&(d.persistenceData[a]?d.persistenceData[a][c]=e:d.persistenceData[a]=(f={},f[c]=e,f),isObject(d.persistenceData[a][c])&&isEmpty(d.persistenceData[a][c])&&delete d.persistenceData[a][c],b._Persistence.savePersistence(d.persistenceData)));},this.hasInvalidIdentifyRequest=function(){var a=d.SDKConfig.identifyRequest;return isObject(a)&&isObject(a.userIdentities)&&isEmpty(a.userIdentities)||!a},this.getConsentState=function(a){var c=b._Consent.ConsentSerialization.fromMinifiedJsonObject,e=d._getFromPersistence(a,"con");return isEmpty(e)?null:c(e)},this.setConsentState=function(a,c){var e=b._Consent.ConsentSerialization.toMinifiedJsonObject;// If ConsentState is null, we assume the intent is to clear out the consent state
|
|
585
585
|
(c||null===c)&&d._setPersistence(a,"con",e(c));},this.getDeviceId=function(){return d.deviceId},this.setDeviceId=function(a){d.deviceId=a,d.persistenceData.gs.das=a,b._Persistence.update();},this.getFirstSeenTime=function(a){return d._getFromPersistence(a,"fst")},this.setFirstSeenTime=function(a,b){if(a){var c=b||new Date().getTime();d._setPersistence(a,"fst",c);}},this.getLastSeenTime=function(a){if(!a)return null;// https://go.mparticle.com/work/SQDSDKS-6315
|
|
586
586
|
var c=b.Identity.getCurrentUser();return a===(null===c||void 0===c?void 0:c.getMPID())?new Date().getTime():d._getFromPersistence(a,"lst")},this.setLastSeenTime=function(a,b){if(a){var c=b||new Date().getTime();d._setPersistence(a,"lst",c);}},this.getLocalSessionAttributes=function(){return d.localSessionAttributes||{}},this.setLocalSessionAttribute=function(a,c){var e;d.localSessionAttributes[a]=c,d.persistenceData.gs.lsa=__assign(__assign({},d.persistenceData.gs.lsa||{}),(e={},e[a]=c,e)),b._Persistence.savePersistence(d.persistenceData);},this.syncPersistenceData=function(){var a=b._Persistence.getPersistence();d.persistenceData=b._Helpers.extend({},d.persistenceData,a);},this.getUserAttributes=function(a){return d._getFromPersistence(a,"ua")||{}},this.setUserAttributes=function(a,b){return d._setPersistence(a,"ua",b)},this.getUserIdentities=function(a){return d._getFromPersistence(a,"ui")||{}},this.setUserIdentities=function(a,b){d._setPersistence(a,"ui",b);},this.addMpidToSessionHistory=function(a,b){var c=d.currentSessionMPIDs.indexOf(a);return a&&b!==a&&0>c?void d.currentSessionMPIDs.push(a):void(0<=c&&(d.currentSessionMPIDs=moveElementToEnd(d.currentSessionMPIDs,c)))},this.nullifySession=function(){d.sessionId=null,d.dateLastEventSent=null,d.sessionStartDate=null,d.sessionAttributes={},d.localSessionAttributes={},b._Persistence.update();},this.processConfig=function(a){var g=a.workspaceToken,h=a.requiredWebviewBridgeName;// We should reprocess the flags and baseUrls in case they have changed when we request an updated config
|
|
@@ -1400,7 +1400,7 @@ return !("boolean"==typeof b&&b)&&"object"===_typeof$1(b)&&!0!==b[a];// When "Bl
|
|
|
1400
1400
|
var buildUrl=function(a,b,c,d){var e=d?"1":"0",f=["env=".concat(e)],g=c||{},h=g.planId,i=g.planVersion;return h&&f.push("plan_id=".concat(h)),i&&f.push("plan_version=".concat(i)),"".concat(a+b+"/config","?").concat(f.join("&"))};function ConfigAPIClient(a,b,c){var d=this,e="https://"+c._Store.SDKConfig.configUrl,f=b.isDevelopmentMode,g=b.dataPlan,h=buildUrl(e,a,g,f),i=window.fetch?new FetchUploader(h):new XHRUploader(h);this.getSDKConfiguration=function(){return __awaiter(d,void 0,void 0,function(){var a,d,e,f,h,j,k;return __generator(this,function(l){switch(l.label){case 0:d={method:"get",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"text/plain;charset=UTF-8"},body:null},l.label=1;case 1:return l.trys.push([1,6,,7]),[4/*yield*/,i.upload(d)];case 2:return (e=l.sent(),200!==e.status)?[3/*break*/,5]:(null===(h=null===c||void 0===c?void 0:c.Logger)||void 0===h?void 0:h.verbose("Successfully received configuration from server"),e.json?[4/*yield*/,e.json()]:[3/*break*/,4]);case 3:return a=l.sent(),[2/*return*/,a];case 4:return f=e,a=JSON.parse(f.responseText),[2/*return*/,a];case 5:return null===(j=null===c||void 0===c?void 0:c.Logger)||void 0===j?void 0:j.verbose("Issue with receiving configuration from server, received HTTP Code of "+e.statusText),[3/*break*/,7];case 6:return l.sent(),null===(k=null===c||void 0===c?void 0:c.Logger)||void 0===k?void 0:k.error("Error getting forwarder configuration from mParticle servers."),[3/*break*/,7];case 7:// Returns the original config object if we cannot retrieve the remote config
|
|
1401
1401
|
return [2/*return*/,b]}})})};}
|
|
1402
1402
|
|
|
1403
|
-
var HTTPCodes$1=Constants.HTTPCodes,Messages$1=Constants.Messages,IdentityMethods=Constants.IdentityMethods,Modify=IdentityMethods.Modify;function IdentityAPIClient(a){this.sendAliasRequest=function(b,c){return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,n;return __generator(this,function(t){switch(t.label){case 0:d=a.Logger,e=a._Helpers.invokeAliasCallback,f=a._Store.SDKConfig.aliasUrl,g=a._Store.devToken,d.verbose(Messages$1.InformationMessages.SendAliasHttp),h="https://".concat(f).concat(g,"/Alias"),i=window.fetch?new FetchUploader(h):new XHRUploader(h),j={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json"},body:JSON.stringify(b)},t.label=1;case 1:return t.trys.push([1,13,,14]),[4/*yield*/,i.upload(j)];case 2:return k=t.sent(),l=void 0,m=void 0,n=void 0,o=k.status,o===HTTP_ACCEPTED?[3/*break*/,3]:o===HTTP_OK?[3/*break*/,3]:o===HTTP_BAD_REQUEST?[3/*break*/,4]:[3/*break*/,11];case 3:return m="Received Alias Response from server: "+JSON.stringify(k.status),[3/*break*/,12];case 4:if(!k.json)return [3/*break*/,9];t.label=5;case 5:return t.trys.push([5,7,,8]),[4/*yield*/,k.json()];case 6:return l=t.sent(),[3/*break*/,8];case 7:return t.sent(),d.verbose("The request has no response body"),[3/*break*/,8];case 8:return [3/*break*/,10];case 9:q=k,l=q.responseText?JSON.parse(q.responseText):"",t.label=10;case 10:return r=l,(null===r||void 0===r?void 0:r.message)&&(n=r.message),m="Issue with sending Alias Request to mParticle Servers, received HTTP Code of "+k.status,(null===r||void 0===r?void 0:r.code)&&(m+=" - "+r.code),[3/*break*/,12];case 11:throw new Error("Received HTTP Code of "+k.status);case 12:return d.verbose(m),e(c,k.status,n),[3/*break*/,14];case 13:return s=t.sent(),n=s.message||s.toString(),d.error("Error sending alias request to mParticle servers. "+n),e(c,HTTPCodes$1.noHttpCoverage,n),[3/*break*/,14];case 14:return [2/*return*/]}})})},this.sendIdentityRequest=function(b,c,d,e,f,g,h){var i,j,k;return __awaiter(this,void 0,void 0,function(){var
|
|
1403
|
+
var HTTPCodes$1=Constants.HTTPCodes,Messages$1=Constants.Messages,IdentityMethods=Constants.IdentityMethods,Modify=IdentityMethods.Modify;function IdentityAPIClient(a){this.sendAliasRequest=function(b,c){return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,n;return __generator(this,function(t){switch(t.label){case 0:d=a.Logger,e=a._Helpers.invokeAliasCallback,f=a._Store.SDKConfig.aliasUrl,g=a._Store.devToken,d.verbose(Messages$1.InformationMessages.SendAliasHttp),h="https://".concat(f).concat(g,"/Alias"),i=window.fetch?new FetchUploader(h):new XHRUploader(h),j={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json"},body:JSON.stringify(b)},t.label=1;case 1:return t.trys.push([1,13,,14]),[4/*yield*/,i.upload(j)];case 2:return k=t.sent(),l=void 0,m=void 0,n=void 0,o=k.status,o===HTTP_ACCEPTED?[3/*break*/,3]:o===HTTP_OK?[3/*break*/,3]:o===HTTP_BAD_REQUEST?[3/*break*/,4]:[3/*break*/,11];case 3:return m="Received Alias Response from server: "+JSON.stringify(k.status),[3/*break*/,12];case 4:if(!k.json)return [3/*break*/,9];t.label=5;case 5:return t.trys.push([5,7,,8]),[4/*yield*/,k.json()];case 6:return l=t.sent(),[3/*break*/,8];case 7:return t.sent(),d.verbose("The request has no response body"),[3/*break*/,8];case 8:return [3/*break*/,10];case 9:q=k,l=q.responseText?JSON.parse(q.responseText):"",t.label=10;case 10:return r=l,(null===r||void 0===r?void 0:r.message)&&(n=r.message),m="Issue with sending Alias Request to mParticle Servers, received HTTP Code of "+k.status,(null===r||void 0===r?void 0:r.code)&&(m+=" - "+r.code),[3/*break*/,12];case 11:throw new Error("Received HTTP Code of "+k.status);case 12:return d.verbose(m),e(c,k.status,n),[3/*break*/,14];case 13:return s=t.sent(),n=s.message||s.toString(),d.error("Error sending alias request to mParticle servers. "+n),e(c,HTTPCodes$1.noHttpCoverage,n),[3/*break*/,14];case 14:return [2/*return*/]}})})},this.sendIdentityRequest=function(b,c,d,e,f,g,h){var i,j,k,l;return __awaiter(this,void 0,void 0,function(){var m,n,o,p,q,r,s,t,u,v,w,x,y,z,z,m,A,m,z;return __generator(this,function(B){switch(B.label){case 0:if((null===(i=a._RoktManager)||void 0===i?void 0:i.isInitialized)&&(a._Store.identifyRequestCount=(a._Store.identifyRequestCount||0)+1,m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestStart"))),n=a._Helpers.invokeCallback,o=a.Logger,o.verbose(Messages$1.InformationMessages.SendIdentityBegin),!b)return o.error(Messages$1.ErrorMessages.APIRequestEmpty),[2/*return*/];if(o.verbose(Messages$1.InformationMessages.SendIdentityHttp),a._Store.identityCallInFlight)return n(d,HTTPCodes$1.activeIdentityRequest,"There is currently an Identity request processing. Please wait for this to return before requesting again"),[2/*return*/];p=g||null,q=this.getUploadUrl(c,g),r=window.fetch?new FetchUploader(q):new XHRUploader(q),s={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","x-mp-key":a._Store.devToken},body:JSON.stringify(b)},a._Store.identityCallInFlight=!0,B.label=1;case 1:return B.trys.push([1,9,,10]),[4/*yield*/,r.upload(s)];case 2:return t=B.sent(),u=void 0,v=void 0,w=t.status,w===HTTP_ACCEPTED?[3/*break*/,3]:w===HTTP_OK?[3/*break*/,3]:w===HTTP_BAD_REQUEST?[3/*break*/,3]:[3/*break*/,7];case 3:return t.json?[4/*yield*/,t.json()]:[3/*break*/,5];case 4:return x=B.sent(),u=this.getIdentityResponseFromFetch(t,x),[3/*break*/,6];case 5:u=this.getIdentityResponseFromXHR(t),B.label=6;case 6:return u.status===HTTP_BAD_REQUEST?(y=u.responseText,v="Issue with sending Identity Request to mParticle Servers, received HTTP Code of "+u.status,(null===y||void 0===y?void 0:y.Errors)&&(z=y.Errors.map(function(a){return a.message}).join(", "),v+=" - "+z)):(v="Received Identity Response from server: ",v+=JSON.stringify(u.responseText)),[3/*break*/,8];case 7:{if(t.status>=HTTP_SERVER_ERROR)throw new Error("Received HTTP Code of "+t.status);return a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!1,z="Received HTTP Code of "+t.status,o.error("Error sending identity request to servers - "+z),n(d,HTTPCodes$1.noHttpCoverage,z),[2/*return*/]}case 8:return a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!1,o.verbose(v),(null===(j=a._RoktManager)||void 0===j?void 0:j.isInitialized)&&(m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestEnd"))),f(u,p,d,e,c,h,!1),[3/*break*/,10];case 9:return A=B.sent(),a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!0,(null===(k=a._RoktManager)||void 0===k?void 0:k.isInitialized)&&(m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestEnd"))),z=A.message||A.toString(),o.error("Error sending identity request to servers - "+z),null===(l=a.processQueueOnIdentityFailure)||void 0===l?void 0:l.call(a),n(d,HTTPCodes$1.noHttpCoverage,z),[3/*break*/,10];case 10:return [2/*return*/]}})})},this.getUploadUrl=function(b,c){var d=a._Helpers.createServiceUrl(a._Store.SDKConfig.identityUrl),e=b===Modify?d+c+"/"+b:d+b;return e},this.getIdentityResponseFromFetch=function(a,b){return {status:a.status,responseText:b,cacheMaxAge:parseInt(a.headers.get(CACHE_HEADER))||0,expireTimestamp:0}},this.getIdentityResponseFromXHR=function(a){return {status:a.status,responseText:a.responseText?JSON.parse(a.responseText):{},cacheMaxAge:parseNumber(a.getResponseHeader(CACHE_HEADER)||""),expireTimestamp:0}};}
|
|
1404
1404
|
|
|
1405
1405
|
// The formatted ClickID value must be of the form version.subdomainIndex.creationTime.<fbclid>, where:
|
|
1406
1406
|
// - version is always this prefix: fb
|
|
@@ -1450,25 +1450,16 @@ for(var e in this.clickIds)if(this.clickIds.hasOwnProperty(e)){var f=this.clickI
|
|
|
1450
1450
|
// Rokt Manager in a "ready" state and it can begin sending data to the kit.
|
|
1451
1451
|
//
|
|
1452
1452
|
// https://github.com/mparticle-integrations/mparticle-javascript-integration-rokt
|
|
1453
|
-
var RoktManager=/** @class */function(){function a(){this.kit=null,this.filters={},this.currentUser=null,this.messageQueue=new Map,this.sandbox=null,this.placementAttributesMapping=[],this.initialized=!1;}/**
|
|
1454
|
-
*
|
|
1455
|
-
|
|
1456
|
-
* @param {IKitConfigs} roktConfig - Configuration object containing user attribute filters and settings
|
|
1457
|
-
* @param {IMParticleUser} filteredUser - User object with filtered attributes
|
|
1458
|
-
* @param {SDKIdentityApi} identityService - The mParticle Identity instance
|
|
1459
|
-
* @param {SDKLoggerApi} logger - The mParticle Logger instance
|
|
1460
|
-
* @param {IRoktOptions} options - Options for the RoktManager
|
|
1461
|
-
* @param {Function} captureTiming - Function to capture performance timing marks
|
|
1462
|
-
*
|
|
1463
|
-
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
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
|
|
1453
|
+
var RoktManager=/** @class */function(){function a(){this.kit=null,this.filters={},this.currentUser=null,this.messageQueue=new Map,this.sandbox=null,this.placementAttributesMapping=[],this.onReadyCallback=null,this.initialized=!1;}/**
|
|
1454
|
+
* Sets a callback to be invoked when RoktManager becomes ready
|
|
1455
|
+
*/return a.prototype.setOnReadyCallback=function(a){this.onReadyCallback=a;},a.prototype.init=function(a,b,c,d,e,f,g){var h,i,j=a||{},k=j.userAttributeFilters,l=j.settings,m=l||{},n=m.placementAttributesMapping,o=m.hashedEmailUserIdentityType;this.mappedEmailShaIdentityType=null!==(h=null===o||void 0===o?void 0:o.toLowerCase())&&void 0!==h?h:null,this.identityService=c,this.store=d,this.logger=e,this.captureTiming=g,null===(i=this.captureTiming)||void 0===i?void 0:i.call(this,PerformanceMarkType.JointSdkRoktKitInit),this.filters={userAttributeFilters:k,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b};try{this.placementAttributesMapping=parseSettingsString(n);}catch(a){this.logger.error("Error parsing placement attributes mapping from config: "+a);}// This is the global setting for sandbox mode
|
|
1465
1456
|
// It is set here and passed in to the createLauncher method in the Rokt Kit
|
|
1466
1457
|
// This is not to be confused for the `sandbox` flag in the selectPlacements attributes
|
|
1467
1458
|
// as that is independent of this setting, though they share the same name.
|
|
1468
|
-
var
|
|
1459
|
+
var p=(null===f||void 0===f?void 0:f.sandbox)||!1;// Launcher options are set here for the kit to pick up and pass through
|
|
1469
1460
|
// to the Rokt Launcher.
|
|
1470
|
-
this.launcherOptions=__assign({sandbox:
|
|
1471
|
-
if(this.captureTiming
|
|
1461
|
+
this.launcherOptions=__assign({sandbox:p},null===f||void 0===f?void 0:f.launcherOptions),(null===f||void 0===f?void 0:f.domain)&&(this.domain=f.domain),this.initialized=!0;},Object.defineProperty(a.prototype,"isInitialized",{get:function get(){return this.initialized},enumerable:!1,configurable:!0}),a.prototype.attachKit=function(a){var b,c;this.kit=a,this.processMessageQueue();try{null===(b=this.onReadyCallback)||void 0===b?void 0:b.call(this);}catch(a){null===(c=this.logger)||void 0===c?void 0:c.error("RoktManager: Error in onReadyCallback: "+a);}},a.prototype.selectPlacements=function(a){var b,c,d,e,f,g,h;return __awaiter(this,void 0,void 0,function(){var i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A=this;return __generator(this,function(B){switch(B.label){case 0:// Queue if kit isn't ready OR if identity is in flight
|
|
1462
|
+
if(null===(b=this.captureTiming)||void 0===b?void 0:b.call(this,PerformanceMarkType.JointSdkSelectPlacements),!this.isReady()||(null===(c=this.store)||void 0===c?void 0:c.identityCallInFlight))return [2/*return*/,this.deferredCall("selectPlacements",a)];B.label=1;case 1:if(B.trys.push([1,6,,7]),i=a.attributes,j=(null===i||void 0===i?void 0:i.sandbox)||null,k=this.mapPlacementAttributes(i,this.placementAttributesMapping),null===(d=this.logger)||void 0===d?void 0:d.verbose("mParticle.Rokt selectPlacements called with attributes:\n".concat(JSON.stringify(i,null,2))),this.currentUser=this.identityService.getCurrentUser(),l=(null===(f=null===(e=this.currentUser)||void 0===e?void 0:e.getUserIdentities())||void 0===f?void 0:f.userIdentities)||{},m=l.email,n=k.email,o=void 0,p=void 0,q=this.mappedEmailShaIdentityType&&!1!==IdentityType.getIdentityType(this.mappedEmailShaIdentityType),q&&(o=l[this.mappedEmailShaIdentityType],p=k.emailsha256||k[this.mappedEmailShaIdentityType]||void 0),r=this.hasIdentityChanged(m,n),s=this.hasIdentityChanged(o,p),t={},r&&(t.email=n,n&&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.")),s&&(t[this.mappedEmailShaIdentityType]=p,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(t))return [3/*break*/,5];B.label=2;case 2:return B.trys.push([2,4,,5]),[4/*yield*/,new Promise(function(a){A.identityService.identify({userIdentities:__assign(__assign({},l),t)},function(){a();});})];case 3:return B.sent(),[3/*break*/,5];case 4:return u=B.sent(),this.logger.error("Failed to identify user with new email: "+JSON.stringify(u)),[3/*break*/,5];case 5:return this.currentUser=this.identityService.getCurrentUser(),v=(null===(h=null===(g=this.currentUser)||void 0===g?void 0:g.getUserIdentities())||void 0===h?void 0:h.userIdentities)||{},this.setUserAttributes(k),w=__assign(__assign({},k),null===j?{}:{sandbox:j}),v.email&&!w.email&&(w.email=v.email),q&&(x=v[this.mappedEmailShaIdentityType],x&&!w.emailsha256&&!w[this.mappedEmailShaIdentityType]&&(w.emailsha256=x)),this.filters.filteredUser=this.currentUser||this.filters.filteredUser||null,y=__assign(__assign({},a),{attributes:w}),[2/*return*/,this.kit.selectPlacements(y)];case 6:return z=B.sent(),[2/*return*/,Promise.reject(z instanceof Error?z:new Error("Unknown error occurred"))];case 7:return [2/*return*/]}})})},a.prototype.hashAttributes=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d,e,f,g,h,i,j,k,l,m,n=this;return __generator(this,function(o){switch(o.label){case 0:return (o.trys.push([0,2,,3]),!a||"object"!==_typeof$1(a))?[2/*return*/,{}]:(b=Object.keys(a),0===b.length)?[2/*return*/,{}]:(c=b.map(function(b){return __awaiter(n,void 0,void 0,function(){var c,d;return __generator(this,function(e){switch(e.label){case 0:return c=a[b],[4/*yield*/,this.hashSha256(c)];case 1:return d=e.sent(),[2/*return*/,{key:b,attributeValue:c,hashedValue:d}]}})})}),[4/*yield*/,Promise.all(c)]);case 1:for(d=o.sent(),e={},(f=0,g=d);f<g.length;f++)h=g[f],i=h.key,j=h.attributeValue,k=h.hashedValue,e[i]=j,k&&(e["".concat(i,"sha256")]=k);return [2/*return*/,e];case 2:return l=o.sent(),m=l instanceof Error?l.message:l+"",this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(m)),[2/*return*/,{}];case 3:return [2/*return*/]}})})},a.prototype.setExtensionData=function(a){if(!this.isReady())return void this.deferredCall("setExtensionData",a);try{this.kit.setExtensionData(a);}catch(a){var b=a instanceof Error?a.message:a+"";throw new Error("Error setting extension data: "+b)}},a.prototype.use=function(a){if(!this.isReady())return this.deferredCall("use",a);try{return this.kit.use(a)}catch(b){return Promise.reject(b instanceof Error?b:new Error("Error using extension: "+a))}},a.prototype.hashSha256=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d;return __generator(this,function(e){switch(e.label){case 0:if(null===a||void 0===a)return this.logger.warning("hashSha256 received null/undefined as input"),[2/*return*/,a];e.label=1;case 1:return e.trys.push([1,3,,4]),b=(a+"").trim().toLocaleLowerCase(),[4/*yield*/,this.sha256Hex(b)];case 2:return [2/*return*/,e.sent()];case 3:return c=e.sent(),d=c instanceof Error?c.message:c+"",this.logger.error("Failed to hashSha256, returning undefined: ".concat(d)),[2/*return*/,void 0];case 4:return [2/*return*/]}})})},a.prototype.getLocalSessionAttributes=function(){return this.store.getLocalSessionAttributes()},a.prototype.setLocalSessionAttribute=function(a,b){this.store.setLocalSessionAttribute(a,b);},a.prototype.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
|
|
1472
1463
|
return !!(this.kit&&this.kit.launcher)},a.prototype.setUserAttributes=function(a){var b=["sandbox"],c={};for(var d in a)if(a.hasOwnProperty(d)&&-1===b.indexOf(d)){var e=a[d];c[d]=Array.isArray(e)?JSON.stringify(e):e;}try{this.currentUser.setUserAttributes(c);}catch(a){this.logger.error("Error setting user attributes: "+a);}},a.prototype.mapPlacementAttributes=function(a,b){for(var c,d={},e=0,f=b;e<f.length;e++)c=f[e],d[c.map]=c.value;var g={};for(var h in a)if(a.hasOwnProperty(h)){var i=d[h]||h;g[i]=a[h];}return g},a.prototype.onIdentityComplete=function(){this.isReady()&&(this.currentUser=this.identityService.getCurrentUser(),this.processMessageQueue());},a.prototype.processMessageQueue=function(){var a,b=this;if(this.isReady()&&0!==this.messageQueue.size){null===(a=this.logger)||void 0===a?void 0:a.verbose("RoktManager: Processing ".concat(this.messageQueue.size," queued messages"));var c=Array.from(this.messageQueue.values());// Clear the queue immediately to prevent re-processing
|
|
1473
1464
|
this.messageQueue.clear(),c.forEach(function(a){var c,d;if(!(a.methodName in b)||!isFunction(b[a.methodName]))return void(null===(c=b.logger)||void 0===c?void 0:c.error("RoktManager: Method ".concat(a.methodName," not found")));null===(d=b.logger)||void 0===d?void 0:d.verbose("RoktManager: Processing queued message: ".concat(a.methodName," with payload: ").concat(JSON.stringify(a.payload)));// Capture resolve/reject functions before async processing
|
|
1474
1465
|
var e=a.resolve,f=a.reject,g=function(c){var d,e=c instanceof Error?c.message:c+"";null===(d=b.logger)||void 0===d?void 0:d.error("RoktManager: Error processing message '".concat(a.methodName,"': ").concat(e)),f&&f(c);};try{var h=b[a.methodName](a.payload);// Handle both sync and async methods
|
|
@@ -1500,10 +1491,10 @@ var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Const
|
|
|
1500
1491
|
*
|
|
1501
1492
|
* @class mParticle & mParticleInstance
|
|
1502
1493
|
*/function mParticleInstance(a){var b=this;// These classes are for internal use only. Not documented for public consumption
|
|
1503
|
-
this._instanceName=a,this._NativeSdkHelpers=new NativeSdkHelpers(this),this._SessionManager=new SessionManager(this),this._Persistence=new _Persistence(this),this._Helpers=new Helpers(this),this._Events=new Events(this),this._CookieSyncManager=new CookieSyncManager(this),this._ServerModel=new ServerModel(this),this._Ecommerce=new Ecommerce(this),this._ForwardingStatsUploader=new forwardingStatsUploader(this),this._Consent=new Consent(this),this._IdentityAPIClient=new IdentityAPIClient(this),this._preInit={readyQueue:[],integrationDelays:{},forwarderConstructors:[]},this._RoktManager=new RoktManager,this.IdentityType=IdentityType,this.EventType=EventType,this.CommerceEventType=CommerceEventType,this.PromotionType=PromotionActionType,this.ProductActionType=ProductActionType,this._Identity=new Identity(this),this.Identity=this._Identity.IdentityAPI,this.generateHash=this._Helpers.generateHash,this.getDeviceId=this._Persistence.getDeviceId,"undefined"!=typeof window&&window.mParticle&&window.mParticle.config&&window.mParticle.config.hasOwnProperty("rq")&&(this._preInit.readyQueue=window.mParticle.config.rq),this.init=function(a,b){var c=this;// config code - Fetch config when requestConfig = true, otherwise, proceed with SDKInitialization
|
|
1494
|
+
this._instanceName=a,this._NativeSdkHelpers=new NativeSdkHelpers(this),this._SessionManager=new SessionManager(this),this._Persistence=new _Persistence(this),this._Helpers=new Helpers(this),this._Events=new Events(this),this._CookieSyncManager=new CookieSyncManager(this),this._ServerModel=new ServerModel(this),this._Ecommerce=new Ecommerce(this),this._ForwardingStatsUploader=new forwardingStatsUploader(this),this._Consent=new Consent(this),this._IdentityAPIClient=new IdentityAPIClient(this),this._preInit={readyQueue:[],integrationDelays:{},forwarderConstructors:[]},this._RoktManager=new RoktManager,this._RoktManager.setOnReadyCallback(function(){b.processQueueOnIdentityFailure();}),this.processQueueOnIdentityFailure=function(){var a,c,d;(null===(a=b._Store)||void 0===a?void 0:a.isInitialized)||(null===(c=b._Store)||void 0===c?void 0:c.identityCallFailed)&&(null===(d=b._RoktManager)||void 0===d?void 0:d.isReady())&&(b._RoktManager.processMessageQueue(),b._preInit.readyQueue=processReadyQueue(b._preInit.readyQueue));},this.IdentityType=IdentityType,this.EventType=EventType,this.CommerceEventType=CommerceEventType,this.PromotionType=PromotionActionType,this.ProductActionType=ProductActionType,this._Identity=new Identity(this),this.Identity=this._Identity.IdentityAPI,this.generateHash=this._Helpers.generateHash,this.getDeviceId=this._Persistence.getDeviceId,"undefined"!=typeof window&&window.mParticle&&window.mParticle.config&&window.mParticle.config.hasOwnProperty("rq")&&(this._preInit.readyQueue=window.mParticle.config.rq),this.init=function(a,b){var c=this;// config code - Fetch config when requestConfig = true, otherwise, proceed with SDKInitialization
|
|
1504
1495
|
// Since fetching the configuration is asynchronous, we must pass completeSDKInitialization
|
|
1505
1496
|
// to it for it to be run after fetched
|
|
1506
|
-
if(b||console.warn("You did not pass a config object to init(). mParticle will not initialize properly"),runPreConfigFetchInitialization(this,a,b),!b)return void console.error("No config available on the window, please pass a config object to mParticle.init()");if(!b.hasOwnProperty("requestConfig")||b.requestConfig){var d=new ConfigAPIClient(a,b,this);d.getSDKConfiguration().then(function(d){var e=c._Helpers.extend({},b,d);completeSDKInitialization(a,e,c);});}else completeSDKInitialization(a,b,this);},this.setLogLevel=function(a){b.Logger.setLogLevel(a);},this.reset=function(a){try{a._Persistence.resetPersistence(),a._Store&&delete a._Store;}catch(a){console.error("Cannot reset mParticle",a);}},this._resetForTests=function(a,b,c){c._Store&&delete c._Store,c.Logger=new Logger(a),c._Store=new Store(a,c),c._Store.isLocalStorageAvailable=c._Persistence.determineLocalStorageAvailability(window.localStorage),c._Events.stopTracking(),b||c._Persistence.resetPersistence(),c._Persistence.forwardingStatsBatches.uploadsTable={},c._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=[],c._preInit={readyQueue:[],pixelConfigurations:[],integrationDelays:{},forwarderConstructors:[],isDevelopmentMode:!1};},this.ready=function(a){b.isInitialized()
|
|
1497
|
+
if(b||console.warn("You did not pass a config object to init(). mParticle will not initialize properly"),runPreConfigFetchInitialization(this,a,b),!b)return void console.error("No config available on the window, please pass a config object to mParticle.init()");if(!b.hasOwnProperty("requestConfig")||b.requestConfig){var d=new ConfigAPIClient(a,b,this);d.getSDKConfiguration().then(function(d){var e=c._Helpers.extend({},b,d);completeSDKInitialization(a,e,c);});}else completeSDKInitialization(a,b,this);},this.setLogLevel=function(a){b.Logger.setLogLevel(a);},this.reset=function(a){try{a._Persistence.resetPersistence(),a._Store&&delete a._Store;}catch(a){console.error("Cannot reset mParticle",a);}},this._resetForTests=function(a,b,c){c._Store&&delete c._Store,c.Logger=new Logger(a),c._Store=new Store(a,c),c._Store.isLocalStorageAvailable=c._Persistence.determineLocalStorageAvailability(window.localStorage),c._Events.stopTracking(),b||c._Persistence.resetPersistence(),c._Persistence.forwardingStatsBatches.uploadsTable={},c._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=[],c._preInit={readyQueue:[],pixelConfigurations:[],integrationDelays:{},forwarderConstructors:[],isDevelopmentMode:!1};},this.ready=function(a){var c,d,e=isFunction(a)&&((null===(c=b._Store)||void 0===c?void 0:c.isInitialized)||(null===(d=b._Store)||void 0===d?void 0:d.identityCallFailed)&&b._RoktManager.isReady());e?a():b._preInit.readyQueue.push(a);},this.getEnvironment=function(){return b._Store.SDKConfig.isDevelopmentMode?Constants.Environment.Development:Constants.Environment.Production},this.getVersion=function(){return Constants.sdkVersion},this.setAppVersion=function(a){var c=queueIfNotInitialized(function(){b.setAppVersion(a);},b);c||(b._Store.SDKConfig.appVersion=a,b._Persistence.update());},this.setDeviceId=function(a){var c=queueIfNotInitialized(function(){b.setDeviceId(a);},b);c||this._Store.setDeviceId(a);},this.isInitialized=function(){return !!b._Store&&b._Store.isInitialized},this.getAppName=function(){return b._Store.SDKConfig.appName},this.setAppName=function(a){var c=queueIfNotInitialized(function(){b.setAppName(a);},b);c||(b._Store.SDKConfig.appName=a);},this.getAppVersion=function(){return b._Store.SDKConfig.appVersion},this.stopTrackingLocation=function(){b._SessionManager.resetSessionTimer(),b._Events.stopTracking();},this.startTrackingLocation=function(a){isFunction(a)||b.Logger.warning("Warning: Location tracking is triggered, but not including a callback into the `startTrackingLocation` may result in events logged too quickly and not being associated with a location."),b._SessionManager.resetSessionTimer(),b._Events.startTracking(a);},this.setPosition=function(a,c){var d=queueIfNotInitialized(function(){b.setPosition(a,c);},b);d||(b._SessionManager.resetSessionTimer(),"number"==typeof a&&"number"==typeof c?b._Store.currentPosition={lat:a,lng:c}:b.Logger.error("Position latitude and/or longitude must both be of type number"));},this.startNewSession=function(){b._SessionManager.startNewSession();},this.endSession=function(){// Sends true as an over ride vs when endSession is called from the setInterval
|
|
1507
1498
|
b._SessionManager.endSession(!0);},this.logBaseEvent=function(a,c){var d=queueIfNotInitialized(function(){b.logBaseEvent(a,c);},b);if(!d)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a.name)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(a.eventType||(a.eventType=EventType.Unknown),b._Helpers.canLog()?void b._Events.logEvent(a,c):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled))},this.logEvent=function(a,c,d,e,f){var g=queueIfNotInitialized(function(){b.logEvent(a,c,d,e,f);},b);if(!g)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(c||(c=EventType.Unknown),b._Helpers.isEventType(c)?b._Helpers.canLog()?void b._Events.logEvent({messageType:MessageType$1.PageEvent,name:a,data:d,eventType:c,customFlags:e},f):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled):void b.Logger.error("Invalid event type: "+c+", must be one of: \n"+JSON.stringify(EventType)))},this.logError=function(a,c){var d=queueIfNotInitialized(function(){b.logError(a,c);},b);if(!d&&(b._SessionManager.resetSessionTimer(),!!a)){"string"==typeof a&&(a={message:a});var e={m:a.message?a.message:a,s:"Error",t:a.stack||null};if(c){var f=b._Helpers.sanitizeAttributes(c,e.m);for(var g in f)e[g]=f[g];}b._Events.logEvent({messageType:MessageType$1.CrashReport,name:a.name?a.name:"Error",eventType:EventType.Other,data:e});}},this.logLink=function(a,c,d,e){b._Events.addEventHandler("click",a,c,e,d);},this.logForm=function(a,c,d,e){b._Events.addEventHandler("submit",a,c,e,d);},this.logPageView=function(a,c,d,e){var f=queueIfNotInitialized(function(){b.logPageView(a,c,d,e);},b);if(!f){if(b._SessionManager.resetSessionTimer(),b._Helpers.canLog()){if(b._Helpers.Validators.isStringOrNumber(a)||(a="PageView"),!c)c={hostname:window.location.hostname,title:window.document.title};else if(!b._Helpers.isObject(c))return void b.Logger.error("The attributes argument must be an object. A "+_typeof$1(c)+" was entered. Please correct and retry.");if(d&&!b._Helpers.isObject(d))return void b.Logger.error("The customFlags argument must be an object. A "+_typeof$1(d)+" was entered. Please correct and retry.")}b._Events.logEvent({messageType:MessageType$1.PageView,name:a,data:c,eventType:EventType.Unknown,customFlags:d},e);}},this.upload=function(){var a,c;b._Helpers.canLog()&&(b._Store.webviewBridgeEnabled?b._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Upload):null===(c=null===(a=b._APIClient)||void 0===a?void 0:a.uploader)||void 0===c?void 0:c.prepareAndUpload(!1,!1));},this.Consent={/**
|
|
1508
1499
|
* Creates a CCPA Opt Out Consent State.
|
|
1509
1500
|
*
|
|
@@ -1676,7 +1667,8 @@ function createKitBlocker(a,b){var c,d,e,f;/* There are three ways a data plan
|
|
|
1676
1667
|
var e=null!==(d=null===c||void 0===c?void 0:c.launcherOptions)&&void 0!==d?d:{},f=e.noFunctional,g=e.noTargeting;a._CookieConsentManager=new CookieConsentManager({noFunctional:f,noTargeting:g});// Check to see if localStorage is available before main configuration runs
|
|
1677
1668
|
// since we will need this for the current implementation of user persistence
|
|
1678
1669
|
// TODO: Refactor this when we refactor User Identity Persistence
|
|
1679
|
-
try{a._Store.isLocalStorageAvailable=a._Persistence.determineLocalStorageAvailability(window.localStorage);}catch(b){a.Logger.warning("localStorage is not available, using cookies if available"),a._Store.isLocalStorageAvailable=!1;}}function processIdentityCallback(a,b,c,d){!a._Store.identifyCalled&&a._Store.SDKConfig.identityCallback&&b&&c&&a._Store.SDKConfig.identityCallback({httpCode:HTTPCodes.activeSession,getUser:function getUser(){return a._Identity.mParticleUser(c)},getPreviousUser:function getPreviousUser(){var b=a.Identity.getUsers(),d=b.shift(),e=d.getMPID();return d&&e===c&&(d=b.shift()),d||null},body:{mpid:c,is_logged_in:a._Store.isLoggedIn,matched_identities:d,context:null,is_ephemeral:!1}});}function queueIfNotInitialized(a,b){
|
|
1670
|
+
try{a._Store.isLocalStorageAvailable=a._Persistence.determineLocalStorageAvailability(window.localStorage);}catch(b){a.Logger.warning("localStorage is not available, using cookies if available"),a._Store.isLocalStorageAvailable=!1;}}function processIdentityCallback(a,b,c,d){!a._Store.identifyCalled&&a._Store.SDKConfig.identityCallback&&b&&c&&a._Store.SDKConfig.identityCallback({httpCode:HTTPCodes.activeSession,getUser:function getUser(){return a._Identity.mParticleUser(c)},getPreviousUser:function getPreviousUser(){var b=a.Identity.getUsers(),d=b.shift(),e=d.getMPID();return d&&e===c&&(d=b.shift()),d||null},body:{mpid:c,is_logged_in:a._Store.isLoggedIn,matched_identities:d,context:null,is_ephemeral:!1}});}function queueIfNotInitialized(a,b){var c;// Core SDK methods must wait for Store initialization
|
|
1671
|
+
return !(null!==(c=b._Store)&&void 0!==c&&c.isInitialized)&&(b._preInit.readyQueue.push(function(){var c;(null===(c=b._Store)||void 0===c?void 0:c.isInitialized)&&a();}),!0)}
|
|
1680
1672
|
|
|
1681
1673
|
// This file is used ONLY for the mParticle ESLint plugin. It should NOT be used otherwise!
|
|
1682
1674
|
var mockFunction=function(){return null},_BatchValidator=/** @class */function(){function a(){}return a.prototype.getMPInstance=function(){return {// Certain Helper, Store, and Identity properties need to be mocked to be used in the `returnBatch` method
|
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.57.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
|
|
@@ -28,7 +28,7 @@ CaptureIntegrationSpecificIds:"captureIntegrationSpecificIds",// CaptureIntegrat
|
|
|
28
28
|
// - 'none' → capture none
|
|
29
29
|
// - 'roktonly' → capture only Rokt-related IDs
|
|
30
30
|
CaptureIntegrationSpecificIdsV2:"captureIntegrationSpecificIdsV2",AstBackgroundEvents:"astBackgroundEvents"},DefaultInstance:"default_instance",CCPAPurpose:"data_sale_opt_out",IdentityMethods:{Modify:"modify",Logout:"logout",Login:"login",Identify:"identify"},Environment:{Development:"development",Production:"production"},CaptureIntegrationSpecificIdsV2Modes:{All:"all",None:"none",RoktOnly:"roktonly"},Rokt:{LauncherInstanceGuidKey:"__rokt_li_guid__"}};var ONE_DAY_IN_SECONDS=86400;var MILLIS_IN_ONE_SEC=1e3;// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status
|
|
31
|
-
var HTTP_OK=200;var HTTP_ACCEPTED=202;var HTTP_BAD_REQUEST=400;
|
|
31
|
+
var HTTP_OK=200;var HTTP_ACCEPTED=202;var HTTP_BAD_REQUEST=400;var HTTP_SERVER_ERROR=500;
|
|
32
32
|
|
|
33
33
|
/******************************************************************************
|
|
34
34
|
Copyright (c) Microsoft Corporation.
|
|
@@ -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",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};
|
|
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",JointSdkRoktKitInit:"mp:jointSdkRoktKitInit"};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";
|
|
@@ -580,7 +580,7 @@ document.addEventListener("visibilitychange",function(){return a.handleVisibilit
|
|
|
580
580
|
|
|
581
581
|
function createSDKConfig(a){// TODO: Refactor to create a default config object
|
|
582
582
|
var b={};for(var c in Constants.DefaultConfig)Constants.DefaultConfig.hasOwnProperty(c)&&(b[c]=Constants.DefaultConfig[c]);if(a)for(var c in a)a.hasOwnProperty(c)&&(b[c]=a[c]);for(var c in Constants.DefaultBaseUrls)b[c]=Constants.DefaultBaseUrls[c];return b}// TODO: Merge this with SDKStoreApi in sdkRuntimeModels
|
|
583
|
-
function Store(a,b,c){var d=this,e=b._Helpers.createMainStorageName,f=b._NativeSdkHelpers.isWebviewEnabled,g={isEnabled:!0,sessionAttributes:{},localSessionAttributes:{},currentSessionMPIDs:[],consentState:null,sessionId:null,isFirstRun:null,clientId:null,deviceId:null,devToken:null,serverSettings:{},dateLastEventSent:null,sessionStartDate:null,currentPosition:null,isTracking:!1,watchPositionId:null,cartProducts:[],eventQueue:[],currencyCode:null,globalTimer:null,context:null,configurationLoaded:!1,identityCallInFlight:!1,identifyRequestCount:0,SDKConfig:{},nonCurrentUserMPIDs:{},identifyCalled:!1,isLoggedIn:!1,cookieSyncDates:{},integrationAttributes:{},requireDelay:!0,isLocalStorageAvailable:null,storageName:null,activeForwarders:[],kits:{},sideloadedKits:[],configuredForwarders:[],pixelConfigurations:[],wrapperSDKInfo:{name:"none",version:null,isInfoSet:!1},// Placeholder for in-memory persistence model
|
|
583
|
+
function Store(a,b,c){var d=this,e=b._Helpers.createMainStorageName,f=b._NativeSdkHelpers.isWebviewEnabled,g={isEnabled:!0,sessionAttributes:{},localSessionAttributes:{},currentSessionMPIDs:[],consentState:null,sessionId:null,isFirstRun:null,clientId:null,deviceId:null,devToken:null,serverSettings:{},dateLastEventSent:null,sessionStartDate:null,currentPosition:null,isTracking:!1,watchPositionId:null,cartProducts:[],eventQueue:[],currencyCode:null,globalTimer:null,context:null,configurationLoaded:!1,identityCallInFlight:!1,identityCallFailed:!1,identifyRequestCount:0,SDKConfig:{},nonCurrentUserMPIDs:{},identifyCalled:!1,isLoggedIn:!1,cookieSyncDates:{},integrationAttributes:{},requireDelay:!0,isLocalStorageAvailable:null,storageName:null,activeForwarders:[],kits:{},sideloadedKits:[],configuredForwarders:[],pixelConfigurations:[],wrapperSDKInfo:{name:"none",version:null,isInfoSet:!1},// Placeholder for in-memory persistence model
|
|
584
584
|
persistenceData:{gs:{}}};for(var h in g)this[h]=g[h];if(this.devToken=c||null,this.integrationDelayTimeoutStart=Date.now(),this.SDKConfig=createSDKConfig(a),a){a.hasOwnProperty("flags")||(this.SDKConfig.flags={}),this.SDKConfig.flags=processFlags(a),a.deviceId&&(this.deviceId=a.deviceId),this.SDKConfig.isDevelopmentMode=!!a.hasOwnProperty("isDevelopmentMode")&&returnConvertedBoolean(a.isDevelopmentMode);var i=processBaseUrls(a,this.SDKConfig.flags,c);for(var j in i)this.SDKConfig[j]=i[j];if(a.hasOwnProperty("logLevel")&&(this.SDKConfig.logLevel=a.logLevel),this.SDKConfig.useNativeSdk=!!a.useNativeSdk,this.SDKConfig.kits=a.kits||{},this.SDKConfig.sideloadedKits=a.sideloadedKits||[],this.SDKConfig.isIOS=a.hasOwnProperty("isIOS")?a.isIOS:!!(window.mParticle&&window.mParticle.isIOS)&&window.mParticle.isIOS,this.SDKConfig.useCookieStorage=!!a.hasOwnProperty("useCookieStorage")&&a.useCookieStorage,this.SDKConfig.maxProducts=a.hasOwnProperty("maxProducts")?a.maxProducts:Constants.DefaultConfig.maxProducts,this.SDKConfig.maxCookieSize=a.hasOwnProperty("maxCookieSize")?a.maxCookieSize:Constants.DefaultConfig.maxCookieSize,a.hasOwnProperty("appName")&&(this.SDKConfig.appName=a.appName),a.hasOwnProperty("package")&&(this.SDKConfig["package"]=a["package"]),this.SDKConfig.integrationDelayTimeout=a.hasOwnProperty("integrationDelayTimeout")?a.integrationDelayTimeout:Constants.DefaultConfig.integrationDelayTimeout,a.hasOwnProperty("identifyRequest")&&(this.SDKConfig.identifyRequest=a.identifyRequest),a.hasOwnProperty("identityCallback")){var k=a.identityCallback;b._Helpers.Validators.isFunction(k)?this.SDKConfig.identityCallback=a.identityCallback:b.Logger.warning("The optional callback must be a function. You tried entering a(n) "+_typeof$1(k)+" . Callback not set. Please set your callback again.");}if(a.hasOwnProperty("appVersion")&&(this.SDKConfig.appVersion=a.appVersion),a.hasOwnProperty("appName")&&(this.SDKConfig.appName=a.appName),a.hasOwnProperty("sessionTimeout")&&(this.SDKConfig.sessionTimeout=a.sessionTimeout),a.hasOwnProperty("dataPlan")){this.SDKConfig.dataPlan={PlanVersion:null,PlanId:null};var l=a.dataPlan;l.planId&&(isDataPlanSlug(l.planId)?this.SDKConfig.dataPlan.PlanId=l.planId:b.Logger.error("Your data plan id must be a string and match the data plan slug format (i.e. under_case_slug)")),l.planVersion&&(isNumber(l.planVersion)?this.SDKConfig.dataPlan.PlanVersion=l.planVersion:b.Logger.error("Your data plan version must be a number"));}else this.SDKConfig.dataPlan={};if(this.SDKConfig.forceHttps=!a.hasOwnProperty("forceHttps")||a.forceHttps,this.SDKConfig.customFlags=a.customFlags||{},this.SDKConfig.minWebviewBridgeVersion=a.hasOwnProperty("minWebviewBridgeVersion")?a.minWebviewBridgeVersion:1,this.SDKConfig.aliasMaxWindow=a.hasOwnProperty("aliasMaxWindow")?a.aliasMaxWindow:Constants.DefaultConfig.aliasMaxWindow,a.hasOwnProperty("dataPlanOptions")){var m=a.dataPlanOptions;m.hasOwnProperty("dataPlanVersion")&&m.hasOwnProperty("blockUserAttributes")&&m.hasOwnProperty("blockEventAttributes")&&m.hasOwnProperty("blockEvents")&&m.hasOwnProperty("blockUserIdentities")||b.Logger.error("Ensure your config.dataPlanOptions object has the following keys: a \"dataPlanVersion\" object, and \"blockUserAttributes\", \"blockEventAttributes\", \"blockEvents\", \"blockUserIdentities\" booleans");}a.hasOwnProperty("onCreateBatch")&&("function"==typeof a.onCreateBatch?this.SDKConfig.onCreateBatch=a.onCreateBatch:(b.Logger.error("config.onCreateBatch must be a function"),this.SDKConfig.onCreateBatch=void 0));}this._getFromPersistence=function(a,b){return a?(d.syncPersistenceData(),d.persistenceData&&d.persistenceData[a]&&d.persistenceData[a][b]?d.persistenceData[a][b]:null):null},this._setPersistence=function(a,c,e){var f;a&&(d.syncPersistenceData(),d.persistenceData&&(d.persistenceData[a]?d.persistenceData[a][c]=e:d.persistenceData[a]=(f={},f[c]=e,f),isObject(d.persistenceData[a][c])&&isEmpty(d.persistenceData[a][c])&&delete d.persistenceData[a][c],b._Persistence.savePersistence(d.persistenceData)));},this.hasInvalidIdentifyRequest=function(){var a=d.SDKConfig.identifyRequest;return isObject(a)&&isObject(a.userIdentities)&&isEmpty(a.userIdentities)||!a},this.getConsentState=function(a){var c=b._Consent.ConsentSerialization.fromMinifiedJsonObject,e=d._getFromPersistence(a,"con");return isEmpty(e)?null:c(e)},this.setConsentState=function(a,c){var e=b._Consent.ConsentSerialization.toMinifiedJsonObject;// If ConsentState is null, we assume the intent is to clear out the consent state
|
|
585
585
|
(c||null===c)&&d._setPersistence(a,"con",e(c));},this.getDeviceId=function(){return d.deviceId},this.setDeviceId=function(a){d.deviceId=a,d.persistenceData.gs.das=a,b._Persistence.update();},this.getFirstSeenTime=function(a){return d._getFromPersistence(a,"fst")},this.setFirstSeenTime=function(a,b){if(a){var c=b||new Date().getTime();d._setPersistence(a,"fst",c);}},this.getLastSeenTime=function(a){if(!a)return null;// https://go.mparticle.com/work/SQDSDKS-6315
|
|
586
586
|
var c=b.Identity.getCurrentUser();return a===(null===c||void 0===c?void 0:c.getMPID())?new Date().getTime():d._getFromPersistence(a,"lst")},this.setLastSeenTime=function(a,b){if(a){var c=b||new Date().getTime();d._setPersistence(a,"lst",c);}},this.getLocalSessionAttributes=function(){return d.localSessionAttributes||{}},this.setLocalSessionAttribute=function(a,c){var e;d.localSessionAttributes[a]=c,d.persistenceData.gs.lsa=__assign(__assign({},d.persistenceData.gs.lsa||{}),(e={},e[a]=c,e)),b._Persistence.savePersistence(d.persistenceData);},this.syncPersistenceData=function(){var a=b._Persistence.getPersistence();d.persistenceData=b._Helpers.extend({},d.persistenceData,a);},this.getUserAttributes=function(a){return d._getFromPersistence(a,"ua")||{}},this.setUserAttributes=function(a,b){return d._setPersistence(a,"ua",b)},this.getUserIdentities=function(a){return d._getFromPersistence(a,"ui")||{}},this.setUserIdentities=function(a,b){d._setPersistence(a,"ui",b);},this.addMpidToSessionHistory=function(a,b){var c=d.currentSessionMPIDs.indexOf(a);return a&&b!==a&&0>c?void d.currentSessionMPIDs.push(a):void(0<=c&&(d.currentSessionMPIDs=moveElementToEnd(d.currentSessionMPIDs,c)))},this.nullifySession=function(){d.sessionId=null,d.dateLastEventSent=null,d.sessionStartDate=null,d.sessionAttributes={},d.localSessionAttributes={},b._Persistence.update();},this.processConfig=function(a){var g=a.workspaceToken,h=a.requiredWebviewBridgeName;// We should reprocess the flags and baseUrls in case they have changed when we request an updated config
|
|
@@ -1400,7 +1400,7 @@ return !("boolean"==typeof b&&b)&&"object"===_typeof$1(b)&&!0!==b[a];// When "Bl
|
|
|
1400
1400
|
var buildUrl=function(a,b,c,d){var e=d?"1":"0",f=["env=".concat(e)],g=c||{},h=g.planId,i=g.planVersion;return h&&f.push("plan_id=".concat(h)),i&&f.push("plan_version=".concat(i)),"".concat(a+b+"/config","?").concat(f.join("&"))};function ConfigAPIClient(a,b,c){var d=this,e="https://"+c._Store.SDKConfig.configUrl,f=b.isDevelopmentMode,g=b.dataPlan,h=buildUrl(e,a,g,f),i=window.fetch?new FetchUploader(h):new XHRUploader(h);this.getSDKConfiguration=function(){return __awaiter(d,void 0,void 0,function(){var a,d,e,f,h,j,k;return __generator(this,function(l){switch(l.label){case 0:d={method:"get",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"text/plain;charset=UTF-8"},body:null},l.label=1;case 1:return l.trys.push([1,6,,7]),[4/*yield*/,i.upload(d)];case 2:return (e=l.sent(),200!==e.status)?[3/*break*/,5]:(null===(h=null===c||void 0===c?void 0:c.Logger)||void 0===h?void 0:h.verbose("Successfully received configuration from server"),e.json?[4/*yield*/,e.json()]:[3/*break*/,4]);case 3:return a=l.sent(),[2/*return*/,a];case 4:return f=e,a=JSON.parse(f.responseText),[2/*return*/,a];case 5:return null===(j=null===c||void 0===c?void 0:c.Logger)||void 0===j?void 0:j.verbose("Issue with receiving configuration from server, received HTTP Code of "+e.statusText),[3/*break*/,7];case 6:return l.sent(),null===(k=null===c||void 0===c?void 0:c.Logger)||void 0===k?void 0:k.error("Error getting forwarder configuration from mParticle servers."),[3/*break*/,7];case 7:// Returns the original config object if we cannot retrieve the remote config
|
|
1401
1401
|
return [2/*return*/,b]}})})};}
|
|
1402
1402
|
|
|
1403
|
-
var HTTPCodes$1=Constants.HTTPCodes,Messages$1=Constants.Messages,IdentityMethods=Constants.IdentityMethods,Modify=IdentityMethods.Modify;function IdentityAPIClient(a){this.sendAliasRequest=function(b,c){return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,n;return __generator(this,function(t){switch(t.label){case 0:d=a.Logger,e=a._Helpers.invokeAliasCallback,f=a._Store.SDKConfig.aliasUrl,g=a._Store.devToken,d.verbose(Messages$1.InformationMessages.SendAliasHttp),h="https://".concat(f).concat(g,"/Alias"),i=window.fetch?new FetchUploader(h):new XHRUploader(h),j={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json"},body:JSON.stringify(b)},t.label=1;case 1:return t.trys.push([1,13,,14]),[4/*yield*/,i.upload(j)];case 2:return k=t.sent(),l=void 0,m=void 0,n=void 0,o=k.status,o===HTTP_ACCEPTED?[3/*break*/,3]:o===HTTP_OK?[3/*break*/,3]:o===HTTP_BAD_REQUEST?[3/*break*/,4]:[3/*break*/,11];case 3:return m="Received Alias Response from server: "+JSON.stringify(k.status),[3/*break*/,12];case 4:if(!k.json)return [3/*break*/,9];t.label=5;case 5:return t.trys.push([5,7,,8]),[4/*yield*/,k.json()];case 6:return l=t.sent(),[3/*break*/,8];case 7:return t.sent(),d.verbose("The request has no response body"),[3/*break*/,8];case 8:return [3/*break*/,10];case 9:q=k,l=q.responseText?JSON.parse(q.responseText):"",t.label=10;case 10:return r=l,(null===r||void 0===r?void 0:r.message)&&(n=r.message),m="Issue with sending Alias Request to mParticle Servers, received HTTP Code of "+k.status,(null===r||void 0===r?void 0:r.code)&&(m+=" - "+r.code),[3/*break*/,12];case 11:throw new Error("Received HTTP Code of "+k.status);case 12:return d.verbose(m),e(c,k.status,n),[3/*break*/,14];case 13:return s=t.sent(),n=s.message||s.toString(),d.error("Error sending alias request to mParticle servers. "+n),e(c,HTTPCodes$1.noHttpCoverage,n),[3/*break*/,14];case 14:return [2/*return*/]}})})},this.sendIdentityRequest=function(b,c,d,e,f,g,h){var i,j,k;return __awaiter(this,void 0,void 0,function(){var
|
|
1403
|
+
var HTTPCodes$1=Constants.HTTPCodes,Messages$1=Constants.Messages,IdentityMethods=Constants.IdentityMethods,Modify=IdentityMethods.Modify;function IdentityAPIClient(a){this.sendAliasRequest=function(b,c){return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,n;return __generator(this,function(t){switch(t.label){case 0:d=a.Logger,e=a._Helpers.invokeAliasCallback,f=a._Store.SDKConfig.aliasUrl,g=a._Store.devToken,d.verbose(Messages$1.InformationMessages.SendAliasHttp),h="https://".concat(f).concat(g,"/Alias"),i=window.fetch?new FetchUploader(h):new XHRUploader(h),j={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json"},body:JSON.stringify(b)},t.label=1;case 1:return t.trys.push([1,13,,14]),[4/*yield*/,i.upload(j)];case 2:return k=t.sent(),l=void 0,m=void 0,n=void 0,o=k.status,o===HTTP_ACCEPTED?[3/*break*/,3]:o===HTTP_OK?[3/*break*/,3]:o===HTTP_BAD_REQUEST?[3/*break*/,4]:[3/*break*/,11];case 3:return m="Received Alias Response from server: "+JSON.stringify(k.status),[3/*break*/,12];case 4:if(!k.json)return [3/*break*/,9];t.label=5;case 5:return t.trys.push([5,7,,8]),[4/*yield*/,k.json()];case 6:return l=t.sent(),[3/*break*/,8];case 7:return t.sent(),d.verbose("The request has no response body"),[3/*break*/,8];case 8:return [3/*break*/,10];case 9:q=k,l=q.responseText?JSON.parse(q.responseText):"",t.label=10;case 10:return r=l,(null===r||void 0===r?void 0:r.message)&&(n=r.message),m="Issue with sending Alias Request to mParticle Servers, received HTTP Code of "+k.status,(null===r||void 0===r?void 0:r.code)&&(m+=" - "+r.code),[3/*break*/,12];case 11:throw new Error("Received HTTP Code of "+k.status);case 12:return d.verbose(m),e(c,k.status,n),[3/*break*/,14];case 13:return s=t.sent(),n=s.message||s.toString(),d.error("Error sending alias request to mParticle servers. "+n),e(c,HTTPCodes$1.noHttpCoverage,n),[3/*break*/,14];case 14:return [2/*return*/]}})})},this.sendIdentityRequest=function(b,c,d,e,f,g,h){var i,j,k,l;return __awaiter(this,void 0,void 0,function(){var m,n,o,p,q,r,s,t,u,v,w,x,y,z,z,m,A,m,z;return __generator(this,function(B){switch(B.label){case 0:if((null===(i=a._RoktManager)||void 0===i?void 0:i.isInitialized)&&(a._Store.identifyRequestCount=(a._Store.identifyRequestCount||0)+1,m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestStart"))),n=a._Helpers.invokeCallback,o=a.Logger,o.verbose(Messages$1.InformationMessages.SendIdentityBegin),!b)return o.error(Messages$1.ErrorMessages.APIRequestEmpty),[2/*return*/];if(o.verbose(Messages$1.InformationMessages.SendIdentityHttp),a._Store.identityCallInFlight)return n(d,HTTPCodes$1.activeIdentityRequest,"There is currently an Identity request processing. Please wait for this to return before requesting again"),[2/*return*/];p=g||null,q=this.getUploadUrl(c,g),r=window.fetch?new FetchUploader(q):new XHRUploader(q),s={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","x-mp-key":a._Store.devToken},body:JSON.stringify(b)},a._Store.identityCallInFlight=!0,B.label=1;case 1:return B.trys.push([1,9,,10]),[4/*yield*/,r.upload(s)];case 2:return t=B.sent(),u=void 0,v=void 0,w=t.status,w===HTTP_ACCEPTED?[3/*break*/,3]:w===HTTP_OK?[3/*break*/,3]:w===HTTP_BAD_REQUEST?[3/*break*/,3]:[3/*break*/,7];case 3:return t.json?[4/*yield*/,t.json()]:[3/*break*/,5];case 4:return x=B.sent(),u=this.getIdentityResponseFromFetch(t,x),[3/*break*/,6];case 5:u=this.getIdentityResponseFromXHR(t),B.label=6;case 6:return u.status===HTTP_BAD_REQUEST?(y=u.responseText,v="Issue with sending Identity Request to mParticle Servers, received HTTP Code of "+u.status,(null===y||void 0===y?void 0:y.Errors)&&(z=y.Errors.map(function(a){return a.message}).join(", "),v+=" - "+z)):(v="Received Identity Response from server: ",v+=JSON.stringify(u.responseText)),[3/*break*/,8];case 7:{if(t.status>=HTTP_SERVER_ERROR)throw new Error("Received HTTP Code of "+t.status);return a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!1,z="Received HTTP Code of "+t.status,o.error("Error sending identity request to servers - "+z),n(d,HTTPCodes$1.noHttpCoverage,z),[2/*return*/]}case 8:return a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!1,o.verbose(v),(null===(j=a._RoktManager)||void 0===j?void 0:j.isInitialized)&&(m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestEnd"))),f(u,p,d,e,c,h,!1),[3/*break*/,10];case 9:return A=B.sent(),a._Store.identityCallInFlight=!1,a._Store.identityCallFailed=!0,(null===(k=a._RoktManager)||void 0===k?void 0:k.isInitialized)&&(m=a._Store.identifyRequestCount,a.captureTiming("".concat(m,"-identityRequestEnd"))),z=A.message||A.toString(),o.error("Error sending identity request to servers - "+z),null===(l=a.processQueueOnIdentityFailure)||void 0===l?void 0:l.call(a),n(d,HTTPCodes$1.noHttpCoverage,z),[3/*break*/,10];case 10:return [2/*return*/]}})})},this.getUploadUrl=function(b,c){var d=a._Helpers.createServiceUrl(a._Store.SDKConfig.identityUrl),e=b===Modify?d+c+"/"+b:d+b;return e},this.getIdentityResponseFromFetch=function(a,b){return {status:a.status,responseText:b,cacheMaxAge:parseInt(a.headers.get(CACHE_HEADER))||0,expireTimestamp:0}},this.getIdentityResponseFromXHR=function(a){return {status:a.status,responseText:a.responseText?JSON.parse(a.responseText):{},cacheMaxAge:parseNumber(a.getResponseHeader(CACHE_HEADER)||""),expireTimestamp:0}};}
|
|
1404
1404
|
|
|
1405
1405
|
// The formatted ClickID value must be of the form version.subdomainIndex.creationTime.<fbclid>, where:
|
|
1406
1406
|
// - version is always this prefix: fb
|
|
@@ -1450,25 +1450,16 @@ for(var e in this.clickIds)if(this.clickIds.hasOwnProperty(e)){var f=this.clickI
|
|
|
1450
1450
|
// Rokt Manager in a "ready" state and it can begin sending data to the kit.
|
|
1451
1451
|
//
|
|
1452
1452
|
// https://github.com/mparticle-integrations/mparticle-javascript-integration-rokt
|
|
1453
|
-
var RoktManager=/** @class */function(){function a(){this.kit=null,this.filters={},this.currentUser=null,this.messageQueue=new Map,this.sandbox=null,this.placementAttributesMapping=[],this.initialized=!1;}/**
|
|
1454
|
-
*
|
|
1455
|
-
|
|
1456
|
-
* @param {IKitConfigs} roktConfig - Configuration object containing user attribute filters and settings
|
|
1457
|
-
* @param {IMParticleUser} filteredUser - User object with filtered attributes
|
|
1458
|
-
* @param {SDKIdentityApi} identityService - The mParticle Identity instance
|
|
1459
|
-
* @param {SDKLoggerApi} logger - The mParticle Logger instance
|
|
1460
|
-
* @param {IRoktOptions} options - Options for the RoktManager
|
|
1461
|
-
* @param {Function} captureTiming - Function to capture performance timing marks
|
|
1462
|
-
*
|
|
1463
|
-
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
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
|
|
1453
|
+
var RoktManager=/** @class */function(){function a(){this.kit=null,this.filters={},this.currentUser=null,this.messageQueue=new Map,this.sandbox=null,this.placementAttributesMapping=[],this.onReadyCallback=null,this.initialized=!1;}/**
|
|
1454
|
+
* Sets a callback to be invoked when RoktManager becomes ready
|
|
1455
|
+
*/return a.prototype.setOnReadyCallback=function(a){this.onReadyCallback=a;},a.prototype.init=function(a,b,c,d,e,f,g){var h,i,j=a||{},k=j.userAttributeFilters,l=j.settings,m=l||{},n=m.placementAttributesMapping,o=m.hashedEmailUserIdentityType;this.mappedEmailShaIdentityType=null!==(h=null===o||void 0===o?void 0:o.toLowerCase())&&void 0!==h?h:null,this.identityService=c,this.store=d,this.logger=e,this.captureTiming=g,null===(i=this.captureTiming)||void 0===i?void 0:i.call(this,PerformanceMarkType.JointSdkRoktKitInit),this.filters={userAttributeFilters:k,filterUserAttributes:KitFilterHelper.filterUserAttributes,filteredUser:b};try{this.placementAttributesMapping=parseSettingsString(n);}catch(a){this.logger.error("Error parsing placement attributes mapping from config: "+a);}// This is the global setting for sandbox mode
|
|
1465
1456
|
// It is set here and passed in to the createLauncher method in the Rokt Kit
|
|
1466
1457
|
// This is not to be confused for the `sandbox` flag in the selectPlacements attributes
|
|
1467
1458
|
// as that is independent of this setting, though they share the same name.
|
|
1468
|
-
var
|
|
1459
|
+
var p=(null===f||void 0===f?void 0:f.sandbox)||!1;// Launcher options are set here for the kit to pick up and pass through
|
|
1469
1460
|
// to the Rokt Launcher.
|
|
1470
|
-
this.launcherOptions=__assign({sandbox:
|
|
1471
|
-
if(this.captureTiming
|
|
1461
|
+
this.launcherOptions=__assign({sandbox:p},null===f||void 0===f?void 0:f.launcherOptions),(null===f||void 0===f?void 0:f.domain)&&(this.domain=f.domain),this.initialized=!0;},Object.defineProperty(a.prototype,"isInitialized",{get:function get(){return this.initialized},enumerable:!1,configurable:!0}),a.prototype.attachKit=function(a){var b,c;this.kit=a,this.processMessageQueue();try{null===(b=this.onReadyCallback)||void 0===b?void 0:b.call(this);}catch(a){null===(c=this.logger)||void 0===c?void 0:c.error("RoktManager: Error in onReadyCallback: "+a);}},a.prototype.selectPlacements=function(a){var b,c,d,e,f,g,h;return __awaiter(this,void 0,void 0,function(){var i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z,A=this;return __generator(this,function(B){switch(B.label){case 0:// Queue if kit isn't ready OR if identity is in flight
|
|
1462
|
+
if(null===(b=this.captureTiming)||void 0===b?void 0:b.call(this,PerformanceMarkType.JointSdkSelectPlacements),!this.isReady()||(null===(c=this.store)||void 0===c?void 0:c.identityCallInFlight))return [2/*return*/,this.deferredCall("selectPlacements",a)];B.label=1;case 1:if(B.trys.push([1,6,,7]),i=a.attributes,j=(null===i||void 0===i?void 0:i.sandbox)||null,k=this.mapPlacementAttributes(i,this.placementAttributesMapping),null===(d=this.logger)||void 0===d?void 0:d.verbose("mParticle.Rokt selectPlacements called with attributes:\n".concat(JSON.stringify(i,null,2))),this.currentUser=this.identityService.getCurrentUser(),l=(null===(f=null===(e=this.currentUser)||void 0===e?void 0:e.getUserIdentities())||void 0===f?void 0:f.userIdentities)||{},m=l.email,n=k.email,o=void 0,p=void 0,q=this.mappedEmailShaIdentityType&&!1!==IdentityType.getIdentityType(this.mappedEmailShaIdentityType),q&&(o=l[this.mappedEmailShaIdentityType],p=k.emailsha256||k[this.mappedEmailShaIdentityType]||void 0),r=this.hasIdentityChanged(m,n),s=this.hasIdentityChanged(o,p),t={},r&&(t.email=n,n&&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.")),s&&(t[this.mappedEmailShaIdentityType]=p,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(t))return [3/*break*/,5];B.label=2;case 2:return B.trys.push([2,4,,5]),[4/*yield*/,new Promise(function(a){A.identityService.identify({userIdentities:__assign(__assign({},l),t)},function(){a();});})];case 3:return B.sent(),[3/*break*/,5];case 4:return u=B.sent(),this.logger.error("Failed to identify user with new email: "+JSON.stringify(u)),[3/*break*/,5];case 5:return this.currentUser=this.identityService.getCurrentUser(),v=(null===(h=null===(g=this.currentUser)||void 0===g?void 0:g.getUserIdentities())||void 0===h?void 0:h.userIdentities)||{},this.setUserAttributes(k),w=__assign(__assign({},k),null===j?{}:{sandbox:j}),v.email&&!w.email&&(w.email=v.email),q&&(x=v[this.mappedEmailShaIdentityType],x&&!w.emailsha256&&!w[this.mappedEmailShaIdentityType]&&(w.emailsha256=x)),this.filters.filteredUser=this.currentUser||this.filters.filteredUser||null,y=__assign(__assign({},a),{attributes:w}),[2/*return*/,this.kit.selectPlacements(y)];case 6:return z=B.sent(),[2/*return*/,Promise.reject(z instanceof Error?z:new Error("Unknown error occurred"))];case 7:return [2/*return*/]}})})},a.prototype.hashAttributes=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d,e,f,g,h,i,j,k,l,m,n=this;return __generator(this,function(o){switch(o.label){case 0:return (o.trys.push([0,2,,3]),!a||"object"!==_typeof$1(a))?[2/*return*/,{}]:(b=Object.keys(a),0===b.length)?[2/*return*/,{}]:(c=b.map(function(b){return __awaiter(n,void 0,void 0,function(){var c,d;return __generator(this,function(e){switch(e.label){case 0:return c=a[b],[4/*yield*/,this.hashSha256(c)];case 1:return d=e.sent(),[2/*return*/,{key:b,attributeValue:c,hashedValue:d}]}})})}),[4/*yield*/,Promise.all(c)]);case 1:for(d=o.sent(),e={},(f=0,g=d);f<g.length;f++)h=g[f],i=h.key,j=h.attributeValue,k=h.hashedValue,e[i]=j,k&&(e["".concat(i,"sha256")]=k);return [2/*return*/,e];case 2:return l=o.sent(),m=l instanceof Error?l.message:l+"",this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(m)),[2/*return*/,{}];case 3:return [2/*return*/]}})})},a.prototype.setExtensionData=function(a){if(!this.isReady())return void this.deferredCall("setExtensionData",a);try{this.kit.setExtensionData(a);}catch(a){var b=a instanceof Error?a.message:a+"";throw new Error("Error setting extension data: "+b)}},a.prototype.use=function(a){if(!this.isReady())return this.deferredCall("use",a);try{return this.kit.use(a)}catch(b){return Promise.reject(b instanceof Error?b:new Error("Error using extension: "+a))}},a.prototype.hashSha256=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d;return __generator(this,function(e){switch(e.label){case 0:if(null===a||void 0===a)return this.logger.warning("hashSha256 received null/undefined as input"),[2/*return*/,a];e.label=1;case 1:return e.trys.push([1,3,,4]),b=(a+"").trim().toLocaleLowerCase(),[4/*yield*/,this.sha256Hex(b)];case 2:return [2/*return*/,e.sent()];case 3:return c=e.sent(),d=c instanceof Error?c.message:c+"",this.logger.error("Failed to hashSha256, returning undefined: ".concat(d)),[2/*return*/,void 0];case 4:return [2/*return*/]}})})},a.prototype.getLocalSessionAttributes=function(){return this.store.getLocalSessionAttributes()},a.prototype.setLocalSessionAttribute=function(a,b){this.store.setLocalSessionAttribute(a,b);},a.prototype.isReady=function(){// The Rokt Manager is ready when a kit is attached and has a launcher
|
|
1472
1463
|
return !!(this.kit&&this.kit.launcher)},a.prototype.setUserAttributes=function(a){var b=["sandbox"],c={};for(var d in a)if(a.hasOwnProperty(d)&&-1===b.indexOf(d)){var e=a[d];c[d]=Array.isArray(e)?JSON.stringify(e):e;}try{this.currentUser.setUserAttributes(c);}catch(a){this.logger.error("Error setting user attributes: "+a);}},a.prototype.mapPlacementAttributes=function(a,b){for(var c,d={},e=0,f=b;e<f.length;e++)c=f[e],d[c.map]=c.value;var g={};for(var h in a)if(a.hasOwnProperty(h)){var i=d[h]||h;g[i]=a[h];}return g},a.prototype.onIdentityComplete=function(){this.isReady()&&(this.currentUser=this.identityService.getCurrentUser(),this.processMessageQueue());},a.prototype.processMessageQueue=function(){var a,b=this;if(this.isReady()&&0!==this.messageQueue.size){null===(a=this.logger)||void 0===a?void 0:a.verbose("RoktManager: Processing ".concat(this.messageQueue.size," queued messages"));var c=Array.from(this.messageQueue.values());// Clear the queue immediately to prevent re-processing
|
|
1473
1464
|
this.messageQueue.clear(),c.forEach(function(a){var c,d;if(!(a.methodName in b)||!isFunction(b[a.methodName]))return void(null===(c=b.logger)||void 0===c?void 0:c.error("RoktManager: Method ".concat(a.methodName," not found")));null===(d=b.logger)||void 0===d?void 0:d.verbose("RoktManager: Processing queued message: ".concat(a.methodName," with payload: ").concat(JSON.stringify(a.payload)));// Capture resolve/reject functions before async processing
|
|
1474
1465
|
var e=a.resolve,f=a.reject,g=function(c){var d,e=c instanceof Error?c.message:c+"";null===(d=b.logger)||void 0===d?void 0:d.error("RoktManager: Error processing message '".concat(a.methodName,"': ").concat(e)),f&&f(c);};try{var h=b[a.methodName](a.payload);// Handle both sync and async methods
|
|
@@ -1500,10 +1491,10 @@ var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Const
|
|
|
1500
1491
|
*
|
|
1501
1492
|
* @class mParticle & mParticleInstance
|
|
1502
1493
|
*/function mParticleInstance(a){var b=this;// These classes are for internal use only. Not documented for public consumption
|
|
1503
|
-
this._instanceName=a,this._NativeSdkHelpers=new NativeSdkHelpers(this),this._SessionManager=new SessionManager(this),this._Persistence=new _Persistence(this),this._Helpers=new Helpers(this),this._Events=new Events(this),this._CookieSyncManager=new CookieSyncManager(this),this._ServerModel=new ServerModel(this),this._Ecommerce=new Ecommerce(this),this._ForwardingStatsUploader=new forwardingStatsUploader(this),this._Consent=new Consent(this),this._IdentityAPIClient=new IdentityAPIClient(this),this._preInit={readyQueue:[],integrationDelays:{},forwarderConstructors:[]},this._RoktManager=new RoktManager,this.IdentityType=IdentityType,this.EventType=EventType,this.CommerceEventType=CommerceEventType,this.PromotionType=PromotionActionType,this.ProductActionType=ProductActionType,this._Identity=new Identity(this),this.Identity=this._Identity.IdentityAPI,this.generateHash=this._Helpers.generateHash,this.getDeviceId=this._Persistence.getDeviceId,"undefined"!=typeof window&&window.mParticle&&window.mParticle.config&&window.mParticle.config.hasOwnProperty("rq")&&(this._preInit.readyQueue=window.mParticle.config.rq),this.init=function(a,b){var c=this;// config code - Fetch config when requestConfig = true, otherwise, proceed with SDKInitialization
|
|
1494
|
+
this._instanceName=a,this._NativeSdkHelpers=new NativeSdkHelpers(this),this._SessionManager=new SessionManager(this),this._Persistence=new _Persistence(this),this._Helpers=new Helpers(this),this._Events=new Events(this),this._CookieSyncManager=new CookieSyncManager(this),this._ServerModel=new ServerModel(this),this._Ecommerce=new Ecommerce(this),this._ForwardingStatsUploader=new forwardingStatsUploader(this),this._Consent=new Consent(this),this._IdentityAPIClient=new IdentityAPIClient(this),this._preInit={readyQueue:[],integrationDelays:{},forwarderConstructors:[]},this._RoktManager=new RoktManager,this._RoktManager.setOnReadyCallback(function(){b.processQueueOnIdentityFailure();}),this.processQueueOnIdentityFailure=function(){var a,c,d;(null===(a=b._Store)||void 0===a?void 0:a.isInitialized)||(null===(c=b._Store)||void 0===c?void 0:c.identityCallFailed)&&(null===(d=b._RoktManager)||void 0===d?void 0:d.isReady())&&(b._RoktManager.processMessageQueue(),b._preInit.readyQueue=processReadyQueue(b._preInit.readyQueue));},this.IdentityType=IdentityType,this.EventType=EventType,this.CommerceEventType=CommerceEventType,this.PromotionType=PromotionActionType,this.ProductActionType=ProductActionType,this._Identity=new Identity(this),this.Identity=this._Identity.IdentityAPI,this.generateHash=this._Helpers.generateHash,this.getDeviceId=this._Persistence.getDeviceId,"undefined"!=typeof window&&window.mParticle&&window.mParticle.config&&window.mParticle.config.hasOwnProperty("rq")&&(this._preInit.readyQueue=window.mParticle.config.rq),this.init=function(a,b){var c=this;// config code - Fetch config when requestConfig = true, otherwise, proceed with SDKInitialization
|
|
1504
1495
|
// Since fetching the configuration is asynchronous, we must pass completeSDKInitialization
|
|
1505
1496
|
// to it for it to be run after fetched
|
|
1506
|
-
if(b||console.warn("You did not pass a config object to init(). mParticle will not initialize properly"),runPreConfigFetchInitialization(this,a,b),!b)return void console.error("No config available on the window, please pass a config object to mParticle.init()");if(!b.hasOwnProperty("requestConfig")||b.requestConfig){var d=new ConfigAPIClient(a,b,this);d.getSDKConfiguration().then(function(d){var e=c._Helpers.extend({},b,d);completeSDKInitialization(a,e,c);});}else completeSDKInitialization(a,b,this);},this.setLogLevel=function(a){b.Logger.setLogLevel(a);},this.reset=function(a){try{a._Persistence.resetPersistence(),a._Store&&delete a._Store;}catch(a){console.error("Cannot reset mParticle",a);}},this._resetForTests=function(a,b,c){c._Store&&delete c._Store,c.Logger=new Logger(a),c._Store=new Store(a,c),c._Store.isLocalStorageAvailable=c._Persistence.determineLocalStorageAvailability(window.localStorage),c._Events.stopTracking(),b||c._Persistence.resetPersistence(),c._Persistence.forwardingStatsBatches.uploadsTable={},c._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=[],c._preInit={readyQueue:[],pixelConfigurations:[],integrationDelays:{},forwarderConstructors:[],isDevelopmentMode:!1};},this.ready=function(a){b.isInitialized()
|
|
1497
|
+
if(b||console.warn("You did not pass a config object to init(). mParticle will not initialize properly"),runPreConfigFetchInitialization(this,a,b),!b)return void console.error("No config available on the window, please pass a config object to mParticle.init()");if(!b.hasOwnProperty("requestConfig")||b.requestConfig){var d=new ConfigAPIClient(a,b,this);d.getSDKConfiguration().then(function(d){var e=c._Helpers.extend({},b,d);completeSDKInitialization(a,e,c);});}else completeSDKInitialization(a,b,this);},this.setLogLevel=function(a){b.Logger.setLogLevel(a);},this.reset=function(a){try{a._Persistence.resetPersistence(),a._Store&&delete a._Store;}catch(a){console.error("Cannot reset mParticle",a);}},this._resetForTests=function(a,b,c){c._Store&&delete c._Store,c.Logger=new Logger(a),c._Store=new Store(a,c),c._Store.isLocalStorageAvailable=c._Persistence.determineLocalStorageAvailability(window.localStorage),c._Events.stopTracking(),b||c._Persistence.resetPersistence(),c._Persistence.forwardingStatsBatches.uploadsTable={},c._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=[],c._preInit={readyQueue:[],pixelConfigurations:[],integrationDelays:{},forwarderConstructors:[],isDevelopmentMode:!1};},this.ready=function(a){var c,d,e=isFunction(a)&&((null===(c=b._Store)||void 0===c?void 0:c.isInitialized)||(null===(d=b._Store)||void 0===d?void 0:d.identityCallFailed)&&b._RoktManager.isReady());e?a():b._preInit.readyQueue.push(a);},this.getEnvironment=function(){return b._Store.SDKConfig.isDevelopmentMode?Constants.Environment.Development:Constants.Environment.Production},this.getVersion=function(){return Constants.sdkVersion},this.setAppVersion=function(a){var c=queueIfNotInitialized(function(){b.setAppVersion(a);},b);c||(b._Store.SDKConfig.appVersion=a,b._Persistence.update());},this.setDeviceId=function(a){var c=queueIfNotInitialized(function(){b.setDeviceId(a);},b);c||this._Store.setDeviceId(a);},this.isInitialized=function(){return !!b._Store&&b._Store.isInitialized},this.getAppName=function(){return b._Store.SDKConfig.appName},this.setAppName=function(a){var c=queueIfNotInitialized(function(){b.setAppName(a);},b);c||(b._Store.SDKConfig.appName=a);},this.getAppVersion=function(){return b._Store.SDKConfig.appVersion},this.stopTrackingLocation=function(){b._SessionManager.resetSessionTimer(),b._Events.stopTracking();},this.startTrackingLocation=function(a){isFunction(a)||b.Logger.warning("Warning: Location tracking is triggered, but not including a callback into the `startTrackingLocation` may result in events logged too quickly and not being associated with a location."),b._SessionManager.resetSessionTimer(),b._Events.startTracking(a);},this.setPosition=function(a,c){var d=queueIfNotInitialized(function(){b.setPosition(a,c);},b);d||(b._SessionManager.resetSessionTimer(),"number"==typeof a&&"number"==typeof c?b._Store.currentPosition={lat:a,lng:c}:b.Logger.error("Position latitude and/or longitude must both be of type number"));},this.startNewSession=function(){b._SessionManager.startNewSession();},this.endSession=function(){// Sends true as an over ride vs when endSession is called from the setInterval
|
|
1507
1498
|
b._SessionManager.endSession(!0);},this.logBaseEvent=function(a,c){var d=queueIfNotInitialized(function(){b.logBaseEvent(a,c);},b);if(!d)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a.name)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(a.eventType||(a.eventType=EventType.Unknown),b._Helpers.canLog()?void b._Events.logEvent(a,c):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled))},this.logEvent=function(a,c,d,e,f){var g=queueIfNotInitialized(function(){b.logEvent(a,c,d,e,f);},b);if(!g)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(c||(c=EventType.Unknown),b._Helpers.isEventType(c)?b._Helpers.canLog()?void b._Events.logEvent({messageType:MessageType$1.PageEvent,name:a,data:d,eventType:c,customFlags:e},f):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled):void b.Logger.error("Invalid event type: "+c+", must be one of: \n"+JSON.stringify(EventType)))},this.logError=function(a,c){var d=queueIfNotInitialized(function(){b.logError(a,c);},b);if(!d&&(b._SessionManager.resetSessionTimer(),!!a)){"string"==typeof a&&(a={message:a});var e={m:a.message?a.message:a,s:"Error",t:a.stack||null};if(c){var f=b._Helpers.sanitizeAttributes(c,e.m);for(var g in f)e[g]=f[g];}b._Events.logEvent({messageType:MessageType$1.CrashReport,name:a.name?a.name:"Error",eventType:EventType.Other,data:e});}},this.logLink=function(a,c,d,e){b._Events.addEventHandler("click",a,c,e,d);},this.logForm=function(a,c,d,e){b._Events.addEventHandler("submit",a,c,e,d);},this.logPageView=function(a,c,d,e){var f=queueIfNotInitialized(function(){b.logPageView(a,c,d,e);},b);if(!f){if(b._SessionManager.resetSessionTimer(),b._Helpers.canLog()){if(b._Helpers.Validators.isStringOrNumber(a)||(a="PageView"),!c)c={hostname:window.location.hostname,title:window.document.title};else if(!b._Helpers.isObject(c))return void b.Logger.error("The attributes argument must be an object. A "+_typeof$1(c)+" was entered. Please correct and retry.");if(d&&!b._Helpers.isObject(d))return void b.Logger.error("The customFlags argument must be an object. A "+_typeof$1(d)+" was entered. Please correct and retry.")}b._Events.logEvent({messageType:MessageType$1.PageView,name:a,data:c,eventType:EventType.Unknown,customFlags:d},e);}},this.upload=function(){var a,c;b._Helpers.canLog()&&(b._Store.webviewBridgeEnabled?b._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Upload):null===(c=null===(a=b._APIClient)||void 0===a?void 0:a.uploader)||void 0===c?void 0:c.prepareAndUpload(!1,!1));},this.Consent={/**
|
|
1508
1499
|
* Creates a CCPA Opt Out Consent State.
|
|
1509
1500
|
*
|
|
@@ -1676,7 +1667,8 @@ function createKitBlocker(a,b){var c,d,e,f;/* There are three ways a data plan
|
|
|
1676
1667
|
var e=null!==(d=null===c||void 0===c?void 0:c.launcherOptions)&&void 0!==d?d:{},f=e.noFunctional,g=e.noTargeting;a._CookieConsentManager=new CookieConsentManager({noFunctional:f,noTargeting:g});// Check to see if localStorage is available before main configuration runs
|
|
1677
1668
|
// since we will need this for the current implementation of user persistence
|
|
1678
1669
|
// TODO: Refactor this when we refactor User Identity Persistence
|
|
1679
|
-
try{a._Store.isLocalStorageAvailable=a._Persistence.determineLocalStorageAvailability(window.localStorage);}catch(b){a.Logger.warning("localStorage is not available, using cookies if available"),a._Store.isLocalStorageAvailable=!1;}}function processIdentityCallback(a,b,c,d){!a._Store.identifyCalled&&a._Store.SDKConfig.identityCallback&&b&&c&&a._Store.SDKConfig.identityCallback({httpCode:HTTPCodes.activeSession,getUser:function getUser(){return a._Identity.mParticleUser(c)},getPreviousUser:function getPreviousUser(){var b=a.Identity.getUsers(),d=b.shift(),e=d.getMPID();return d&&e===c&&(d=b.shift()),d||null},body:{mpid:c,is_logged_in:a._Store.isLoggedIn,matched_identities:d,context:null,is_ephemeral:!1}});}function queueIfNotInitialized(a,b){
|
|
1670
|
+
try{a._Store.isLocalStorageAvailable=a._Persistence.determineLocalStorageAvailability(window.localStorage);}catch(b){a.Logger.warning("localStorage is not available, using cookies if available"),a._Store.isLocalStorageAvailable=!1;}}function processIdentityCallback(a,b,c,d){!a._Store.identifyCalled&&a._Store.SDKConfig.identityCallback&&b&&c&&a._Store.SDKConfig.identityCallback({httpCode:HTTPCodes.activeSession,getUser:function getUser(){return a._Identity.mParticleUser(c)},getPreviousUser:function getPreviousUser(){var b=a.Identity.getUsers(),d=b.shift(),e=d.getMPID();return d&&e===c&&(d=b.shift()),d||null},body:{mpid:c,is_logged_in:a._Store.isLoggedIn,matched_identities:d,context:null,is_ephemeral:!1}});}function queueIfNotInitialized(a,b){var c;// Core SDK methods must wait for Store initialization
|
|
1671
|
+
return !(null!==(c=b._Store)&&void 0!==c&&c.isInitialized)&&(b._preInit.readyQueue.push(function(){var c;(null===(c=b._Store)||void 0===c?void 0:c.isInitialized)&&a();}),!0)}
|
|
1680
1672
|
|
|
1681
1673
|
// This file is used ONLY for the mParticle ESLint plugin. It should NOT be used otherwise!
|
|
1682
1674
|
var mockFunction=function(){return null},_BatchValidator=/** @class */function(){function a(){}return a.prototype.getMPInstance=function(){return {// Certain Helper, Store, and Identity properties need to be mocked to be used in the `returnBatch` method
|
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.57.0";
|
|
207
207
|
|
|
208
208
|
var Constants = {
|
|
209
209
|
sdkVersion: version,
|
|
@@ -413,6 +413,7 @@ var mParticle = (function () {
|
|
|
413
413
|
var HTTP_OK = 200;
|
|
414
414
|
var HTTP_ACCEPTED = 202;
|
|
415
415
|
var HTTP_BAD_REQUEST = 400;
|
|
416
|
+
var HTTP_SERVER_ERROR = 500;
|
|
416
417
|
|
|
417
418
|
/******************************************************************************
|
|
418
419
|
Copyright (c) Microsoft Corporation.
|
|
@@ -1214,7 +1215,8 @@ var mParticle = (function () {
|
|
|
1214
1215
|
};
|
|
1215
1216
|
var PerformanceMarkType = {
|
|
1216
1217
|
SdkStart: 'mp:sdkStart',
|
|
1217
|
-
JointSdkSelectPlacements: 'mp:jointSdkSelectPlacements'
|
|
1218
|
+
JointSdkSelectPlacements: 'mp:jointSdkSelectPlacements',
|
|
1219
|
+
JointSdkRoktKitInit: 'mp:jointSdkRoktKitInit'
|
|
1218
1220
|
};
|
|
1219
1221
|
var Types = {
|
|
1220
1222
|
MessageType: MessageType$1,
|
|
@@ -4461,6 +4463,7 @@ var mParticle = (function () {
|
|
|
4461
4463
|
context: null,
|
|
4462
4464
|
configurationLoaded: false,
|
|
4463
4465
|
identityCallInFlight: false,
|
|
4466
|
+
identityCallFailed: false,
|
|
4464
4467
|
identifyRequestCount: 0,
|
|
4465
4468
|
SDKConfig: {},
|
|
4466
4469
|
nonCurrentUserMPIDs: {},
|
|
@@ -9258,11 +9261,11 @@ var mParticle = (function () {
|
|
|
9258
9261
|
};
|
|
9259
9262
|
|
|
9260
9263
|
this.sendIdentityRequest = function (identityApiRequest, method, callback, originalIdentityApiData, parseIdentityResponse, mpid, knownIdentities) {
|
|
9261
|
-
var _a, _b, _c;
|
|
9264
|
+
var _a, _b, _c, _d;
|
|
9262
9265
|
return __awaiter(this, void 0, void 0, function () {
|
|
9263
|
-
var requestCount, invokeCallback, Logger, previousMPID, uploadUrl, uploader, fetchPayload, response, identityResponse, message,
|
|
9264
|
-
return __generator(this, function (
|
|
9265
|
-
switch (
|
|
9266
|
+
var requestCount, invokeCallback, Logger, previousMPID, uploadUrl, uploader, fetchPayload, response, identityResponse, message, _e, responseBody, errorResponse, errorMessage, errorMessage, requestCount, err_1, requestCount, errorMessage;
|
|
9267
|
+
return __generator(this, function (_f) {
|
|
9268
|
+
switch (_f.label) {
|
|
9266
9269
|
case 0:
|
|
9267
9270
|
if ((_a = mpInstance._RoktManager) === null || _a === void 0 ? void 0 : _a.isInitialized) {
|
|
9268
9271
|
mpInstance._Store.identifyRequestCount = (mpInstance._Store.identifyRequestCount || 0) + 1;
|
|
@@ -9296,16 +9299,16 @@ var mParticle = (function () {
|
|
|
9296
9299
|
body: JSON.stringify(identityApiRequest)
|
|
9297
9300
|
};
|
|
9298
9301
|
mpInstance._Store.identityCallInFlight = true;
|
|
9299
|
-
|
|
9302
|
+
_f.label = 1;
|
|
9300
9303
|
case 1:
|
|
9301
|
-
|
|
9304
|
+
_f.trys.push([1, 9,, 10]);
|
|
9302
9305
|
return [4 /*yield*/, uploader.upload(fetchPayload)];
|
|
9303
9306
|
case 2:
|
|
9304
|
-
response =
|
|
9307
|
+
response = _f.sent();
|
|
9305
9308
|
identityResponse = void 0;
|
|
9306
9309
|
message = void 0;
|
|
9307
|
-
|
|
9308
|
-
switch (
|
|
9310
|
+
_e = response.status;
|
|
9311
|
+
switch (_e) {
|
|
9309
9312
|
case HTTP_ACCEPTED:
|
|
9310
9313
|
return [3 /*break*/, 3];
|
|
9311
9314
|
case HTTP_OK:
|
|
@@ -9318,12 +9321,12 @@ var mParticle = (function () {
|
|
|
9318
9321
|
if (!response.json) return [3 /*break*/, 5];
|
|
9319
9322
|
return [4 /*yield*/, response.json()];
|
|
9320
9323
|
case 4:
|
|
9321
|
-
responseBody =
|
|
9324
|
+
responseBody = _f.sent();
|
|
9322
9325
|
identityResponse = this.getIdentityResponseFromFetch(response, responseBody);
|
|
9323
9326
|
return [3 /*break*/, 6];
|
|
9324
9327
|
case 5:
|
|
9325
9328
|
identityResponse = this.getIdentityResponseFromXHR(response);
|
|
9326
|
-
|
|
9329
|
+
_f.label = 6;
|
|
9327
9330
|
case 6:
|
|
9328
9331
|
if (identityResponse.status === HTTP_BAD_REQUEST) {
|
|
9329
9332
|
errorResponse = identityResponse.responseText;
|
|
@@ -9341,10 +9344,19 @@ var mParticle = (function () {
|
|
|
9341
9344
|
return [3 /*break*/, 8];
|
|
9342
9345
|
case 7:
|
|
9343
9346
|
{
|
|
9344
|
-
|
|
9347
|
+
if (response.status >= HTTP_SERVER_ERROR) {
|
|
9348
|
+
throw new Error('Received HTTP Code of ' + response.status);
|
|
9349
|
+
}
|
|
9350
|
+
mpInstance._Store.identityCallInFlight = false;
|
|
9351
|
+
mpInstance._Store.identityCallFailed = false;
|
|
9352
|
+
errorMessage = 'Received HTTP Code of ' + response.status;
|
|
9353
|
+
Logger.error('Error sending identity request to servers - ' + errorMessage);
|
|
9354
|
+
invokeCallback(callback, HTTPCodes$1.noHttpCoverage, errorMessage);
|
|
9355
|
+
return [2 /*return*/];
|
|
9345
9356
|
}
|
|
9346
9357
|
case 8:
|
|
9347
9358
|
mpInstance._Store.identityCallInFlight = false;
|
|
9359
|
+
mpInstance._Store.identityCallFailed = false;
|
|
9348
9360
|
Logger.verbose(message);
|
|
9349
9361
|
if ((_b = mpInstance._RoktManager) === null || _b === void 0 ? void 0 : _b.isInitialized) {
|
|
9350
9362
|
requestCount = mpInstance._Store.identifyRequestCount;
|
|
@@ -9353,14 +9365,16 @@ var mParticle = (function () {
|
|
|
9353
9365
|
parseIdentityResponse(identityResponse, previousMPID, callback, originalIdentityApiData, method, knownIdentities, false);
|
|
9354
9366
|
return [3 /*break*/, 10];
|
|
9355
9367
|
case 9:
|
|
9356
|
-
err_1 =
|
|
9368
|
+
err_1 = _f.sent();
|
|
9357
9369
|
mpInstance._Store.identityCallInFlight = false;
|
|
9370
|
+
mpInstance._Store.identityCallFailed = true;
|
|
9358
9371
|
if ((_c = mpInstance._RoktManager) === null || _c === void 0 ? void 0 : _c.isInitialized) {
|
|
9359
9372
|
requestCount = mpInstance._Store.identifyRequestCount;
|
|
9360
9373
|
mpInstance.captureTiming("".concat(requestCount, "-identityRequestEnd"));
|
|
9361
9374
|
}
|
|
9362
9375
|
errorMessage = err_1.message || err_1.toString();
|
|
9363
|
-
Logger.error('Error sending identity request to servers
|
|
9376
|
+
Logger.error('Error sending identity request to servers - ' + errorMessage);
|
|
9377
|
+
(_d = mpInstance.processQueueOnIdentityFailure) === null || _d === void 0 ? void 0 : _d.call(mpInstance);
|
|
9364
9378
|
invokeCallback(callback, HTTPCodes$1.noHttpCoverage, errorMessage);
|
|
9365
9379
|
return [3 /*break*/, 10];
|
|
9366
9380
|
case 10:
|
|
@@ -9708,8 +9722,15 @@ var mParticle = (function () {
|
|
|
9708
9722
|
this.messageQueue = new Map();
|
|
9709
9723
|
this.sandbox = null;
|
|
9710
9724
|
this.placementAttributesMapping = [];
|
|
9725
|
+
this.onReadyCallback = null;
|
|
9711
9726
|
this.initialized = false;
|
|
9712
9727
|
}
|
|
9728
|
+
/**
|
|
9729
|
+
* Sets a callback to be invoked when RoktManager becomes ready
|
|
9730
|
+
*/
|
|
9731
|
+
RoktManager.prototype.setOnReadyCallback = function (callback) {
|
|
9732
|
+
this.onReadyCallback = callback;
|
|
9733
|
+
};
|
|
9713
9734
|
/**
|
|
9714
9735
|
* Initializes the RoktManager with configuration settings and user data.
|
|
9715
9736
|
*
|
|
@@ -9723,18 +9744,19 @@ var mParticle = (function () {
|
|
|
9723
9744
|
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
9724
9745
|
*/
|
|
9725
9746
|
RoktManager.prototype.init = function (roktConfig, filteredUser, identityService, store, logger, options, captureTiming) {
|
|
9726
|
-
var _a;
|
|
9727
|
-
var
|
|
9728
|
-
userAttributeFilters =
|
|
9729
|
-
settings =
|
|
9730
|
-
var
|
|
9731
|
-
placementAttributesMapping =
|
|
9732
|
-
hashedEmailUserIdentityType =
|
|
9747
|
+
var _a, _b;
|
|
9748
|
+
var _c = roktConfig || {},
|
|
9749
|
+
userAttributeFilters = _c.userAttributeFilters,
|
|
9750
|
+
settings = _c.settings;
|
|
9751
|
+
var _d = settings || {},
|
|
9752
|
+
placementAttributesMapping = _d.placementAttributesMapping,
|
|
9753
|
+
hashedEmailUserIdentityType = _d.hashedEmailUserIdentityType;
|
|
9733
9754
|
this.mappedEmailShaIdentityType = (_a = hashedEmailUserIdentityType === null || hashedEmailUserIdentityType === void 0 ? void 0 : hashedEmailUserIdentityType.toLowerCase()) !== null && _a !== void 0 ? _a : null;
|
|
9734
9755
|
this.identityService = identityService;
|
|
9735
9756
|
this.store = store;
|
|
9736
9757
|
this.logger = logger;
|
|
9737
9758
|
this.captureTiming = captureTiming;
|
|
9759
|
+
(_b = this.captureTiming) === null || _b === void 0 ? void 0 : _b.call(this, PerformanceMarkType.JointSdkRoktKitInit);
|
|
9738
9760
|
this.filters = {
|
|
9739
9761
|
userAttributeFilters: userAttributeFilters,
|
|
9740
9762
|
filterUserAttributes: KitFilterHelper.filterUserAttributes,
|
|
@@ -9771,8 +9793,14 @@ var mParticle = (function () {
|
|
|
9771
9793
|
configurable: true
|
|
9772
9794
|
});
|
|
9773
9795
|
RoktManager.prototype.attachKit = function (kit) {
|
|
9796
|
+
var _a, _b;
|
|
9774
9797
|
this.kit = kit;
|
|
9775
9798
|
this.processMessageQueue();
|
|
9799
|
+
try {
|
|
9800
|
+
(_a = this.onReadyCallback) === null || _a === void 0 ? void 0 : _a.call(this);
|
|
9801
|
+
} catch (e) {
|
|
9802
|
+
(_b = this.logger) === null || _b === void 0 ? void 0 : _b.error('RoktManager: Error in onReadyCallback: ' + e);
|
|
9803
|
+
}
|
|
9776
9804
|
};
|
|
9777
9805
|
/**
|
|
9778
9806
|
* Renders ads based on the options provided
|
|
@@ -9790,28 +9818,27 @@ var mParticle = (function () {
|
|
|
9790
9818
|
* });
|
|
9791
9819
|
*/
|
|
9792
9820
|
RoktManager.prototype.selectPlacements = function (options) {
|
|
9793
|
-
var _a, _b, _c, _d, _e;
|
|
9821
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
9794
9822
|
return __awaiter(this, void 0, void 0, function () {
|
|
9795
9823
|
var attributes, sandboxValue, mappedAttributes, currentUserIdentities_1, currentEmail, newEmail, currentHashedEmail, newHashedEmail, isValidHashedEmailIdentityType, emailChanged, hashedEmailChanged, newIdentities_1, error_1, finalUserIdentities, enrichedAttributes, hashedEmail, enrichedOptions, error_2;
|
|
9796
9824
|
var _this = this;
|
|
9797
|
-
return __generator(this, function (
|
|
9798
|
-
switch (
|
|
9825
|
+
return __generator(this, function (_h) {
|
|
9826
|
+
switch (_h.label) {
|
|
9799
9827
|
case 0:
|
|
9800
|
-
|
|
9801
|
-
this.captureTiming(PerformanceMarkType.JointSdkSelectPlacements);
|
|
9802
|
-
}
|
|
9828
|
+
(_a = this.captureTiming) === null || _a === void 0 ? void 0 : _a.call(this, PerformanceMarkType.JointSdkSelectPlacements);
|
|
9803
9829
|
// Queue if kit isn't ready OR if identity is in flight
|
|
9804
|
-
if (!this.isReady() || ((
|
|
9830
|
+
if (!this.isReady() || ((_b = this.store) === null || _b === void 0 ? void 0 : _b.identityCallInFlight)) {
|
|
9805
9831
|
return [2 /*return*/, this.deferredCall('selectPlacements', options)];
|
|
9806
9832
|
}
|
|
9807
|
-
|
|
9833
|
+
_h.label = 1;
|
|
9808
9834
|
case 1:
|
|
9809
|
-
|
|
9835
|
+
_h.trys.push([1, 6,, 7]);
|
|
9810
9836
|
attributes = options.attributes;
|
|
9811
9837
|
sandboxValue = (attributes === null || attributes === void 0 ? void 0 : attributes.sandbox) || null;
|
|
9812
9838
|
mappedAttributes = this.mapPlacementAttributes(attributes, this.placementAttributesMapping);
|
|
9839
|
+
(_c = this.logger) === null || _c === void 0 ? void 0 : _c.verbose("mParticle.Rokt selectPlacements called with attributes:\n".concat(JSON.stringify(attributes, null, 2)));
|
|
9813
9840
|
this.currentUser = this.identityService.getCurrentUser();
|
|
9814
|
-
currentUserIdentities_1 = ((
|
|
9841
|
+
currentUserIdentities_1 = ((_e = (_d = this.currentUser) === null || _d === void 0 ? void 0 : _d.getUserIdentities()) === null || _e === void 0 ? void 0 : _e.userIdentities) || {};
|
|
9815
9842
|
currentEmail = currentUserIdentities_1.email;
|
|
9816
9843
|
newEmail = mappedAttributes.email;
|
|
9817
9844
|
currentHashedEmail = void 0;
|
|
@@ -9835,9 +9862,9 @@ var mParticle = (function () {
|
|
|
9835
9862
|
this.logger.warning("emailsha256 mismatch detected. Current mParticle hashedEmail differs from hashedEmail passed to selectPlacements call. Proceeding to call identify with hashedEmail from selectPlacements call. Please verify your implementation.");
|
|
9836
9863
|
}
|
|
9837
9864
|
if (!!isEmpty(newIdentities_1)) return [3 /*break*/, 5];
|
|
9838
|
-
|
|
9865
|
+
_h.label = 2;
|
|
9839
9866
|
case 2:
|
|
9840
|
-
|
|
9867
|
+
_h.trys.push([2, 4,, 5]);
|
|
9841
9868
|
return [4 /*yield*/, new Promise(function (resolve, reject) {
|
|
9842
9869
|
_this.identityService.identify({
|
|
9843
9870
|
userIdentities: __assign(__assign({}, currentUserIdentities_1), newIdentities_1)
|
|
@@ -9846,16 +9873,16 @@ var mParticle = (function () {
|
|
|
9846
9873
|
});
|
|
9847
9874
|
})];
|
|
9848
9875
|
case 3:
|
|
9849
|
-
|
|
9876
|
+
_h.sent();
|
|
9850
9877
|
return [3 /*break*/, 5];
|
|
9851
9878
|
case 4:
|
|
9852
|
-
error_1 =
|
|
9879
|
+
error_1 = _h.sent();
|
|
9853
9880
|
this.logger.error('Failed to identify user with new email: ' + JSON.stringify(error_1));
|
|
9854
9881
|
return [3 /*break*/, 5];
|
|
9855
9882
|
case 5:
|
|
9856
9883
|
// Refresh current user identities to ensure we have the latest values before building enrichedAttributes
|
|
9857
9884
|
this.currentUser = this.identityService.getCurrentUser();
|
|
9858
|
-
finalUserIdentities = ((
|
|
9885
|
+
finalUserIdentities = ((_g = (_f = this.currentUser) === null || _f === void 0 ? void 0 : _f.getUserIdentities()) === null || _g === void 0 ? void 0 : _g.userIdentities) || {};
|
|
9859
9886
|
this.setUserAttributes(mappedAttributes);
|
|
9860
9887
|
enrichedAttributes = __assign(__assign({}, mappedAttributes), sandboxValue !== null ? {
|
|
9861
9888
|
sandbox: sandboxValue
|
|
@@ -9877,7 +9904,7 @@ var mParticle = (function () {
|
|
|
9877
9904
|
});
|
|
9878
9905
|
return [2 /*return*/, this.kit.selectPlacements(enrichedOptions)];
|
|
9879
9906
|
case 6:
|
|
9880
|
-
error_2 =
|
|
9907
|
+
error_2 = _h.sent();
|
|
9881
9908
|
return [2 /*return*/, Promise.reject(error_2 instanceof Error ? error_2 : new Error('Unknown error occurred'))];
|
|
9882
9909
|
case 7:
|
|
9883
9910
|
return [2 /*return*/];
|
|
@@ -10253,6 +10280,22 @@ var mParticle = (function () {
|
|
|
10253
10280
|
forwarderConstructors: []
|
|
10254
10281
|
};
|
|
10255
10282
|
this._RoktManager = new RoktManager();
|
|
10283
|
+
this._RoktManager.setOnReadyCallback(function () {
|
|
10284
|
+
self.processQueueOnIdentityFailure();
|
|
10285
|
+
});
|
|
10286
|
+
/**
|
|
10287
|
+
* Processes message and ready queue when identity requests fails but Rokt is ready.
|
|
10288
|
+
*/
|
|
10289
|
+
this.processQueueOnIdentityFailure = function () {
|
|
10290
|
+
var _a, _b, _c;
|
|
10291
|
+
if ((_a = self._Store) === null || _a === void 0 ? void 0 : _a.isInitialized) {
|
|
10292
|
+
return;
|
|
10293
|
+
}
|
|
10294
|
+
if (((_b = self._Store) === null || _b === void 0 ? void 0 : _b.identityCallFailed) && ((_c = self._RoktManager) === null || _c === void 0 ? void 0 : _c.isReady())) {
|
|
10295
|
+
self._RoktManager.processMessageQueue();
|
|
10296
|
+
self._preInit.readyQueue = processReadyQueue(self._preInit.readyQueue);
|
|
10297
|
+
}
|
|
10298
|
+
};
|
|
10256
10299
|
// required for forwarders once they reference the mparticle instance
|
|
10257
10300
|
this.IdentityType = IdentityType;
|
|
10258
10301
|
this.EventType = EventType;
|
|
@@ -10342,12 +10385,15 @@ var mParticle = (function () {
|
|
|
10342
10385
|
};
|
|
10343
10386
|
};
|
|
10344
10387
|
/**
|
|
10345
|
-
*
|
|
10388
|
+
* Executes callback when the SDK is ready, or Rokt is ready but identify requests fail due to server errors.
|
|
10389
|
+
* This ensures Rokt methods like selectPlacements continue to work during backend outages.
|
|
10346
10390
|
* @method ready
|
|
10347
|
-
* @param {Function}
|
|
10391
|
+
* @param {Function} f Callback to execute
|
|
10348
10392
|
*/
|
|
10349
10393
|
this.ready = function (f) {
|
|
10350
|
-
|
|
10394
|
+
var _a, _b;
|
|
10395
|
+
var shouldExecute = isFunction(f) && (((_a = self._Store) === null || _a === void 0 ? void 0 : _a.isInitialized) || ((_b = self._Store) === null || _b === void 0 ? void 0 : _b.identityCallFailed) && self._RoktManager.isReady());
|
|
10396
|
+
if (shouldExecute) {
|
|
10351
10397
|
f();
|
|
10352
10398
|
} else {
|
|
10353
10399
|
self._preInit.readyQueue.push(f);
|
|
@@ -11344,9 +11390,14 @@ var mParticle = (function () {
|
|
|
11344
11390
|
}
|
|
11345
11391
|
}
|
|
11346
11392
|
function queueIfNotInitialized(func, self) {
|
|
11347
|
-
|
|
11348
|
-
|
|
11349
|
-
|
|
11393
|
+
var _a;
|
|
11394
|
+
// Core SDK methods must wait for Store initialization
|
|
11395
|
+
if (!((_a = self._Store) === null || _a === void 0 ? void 0 : _a.isInitialized)) {
|
|
11396
|
+
self._preInit.readyQueue.push(function () {
|
|
11397
|
+
var _a;
|
|
11398
|
+
if ((_a = self._Store) === null || _a === void 0 ? void 0 : _a.isInitialized) {
|
|
11399
|
+
func();
|
|
11400
|
+
}
|
|
11350
11401
|
});
|
|
11351
11402
|
return true;
|
|
11352
11403
|
}
|
package/package.json
CHANGED
package/src/identityApiClient.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Constants, { HTTP_ACCEPTED, HTTP_BAD_REQUEST, HTTP_OK } from './constants';
|
|
1
|
+
import Constants, { HTTP_ACCEPTED, HTTP_BAD_REQUEST, HTTP_OK, HTTP_SERVER_ERROR } from './constants';
|
|
2
2
|
import {
|
|
3
3
|
AsyncUploader,
|
|
4
4
|
FetchUploader,
|
|
@@ -284,15 +284,26 @@ export default function IdentityAPIClient(
|
|
|
284
284
|
break;
|
|
285
285
|
|
|
286
286
|
// Our Identity API will return:
|
|
287
|
-
//
|
|
288
|
-
//
|
|
287
|
+
// 401 if the `x-mp-key` is incorrect or missing
|
|
288
|
+
// 403 if the there is a permission or account issue related to the `x-mp-key`
|
|
289
289
|
// 401 and 403 have no response bodies and should be rejected outright
|
|
290
|
+
// 5xx server error throws error but RoktManager continues
|
|
290
291
|
default: {
|
|
291
|
-
|
|
292
|
+
if (response.status >= HTTP_SERVER_ERROR) {
|
|
293
|
+
throw new Error('Received HTTP Code of ' + response.status);
|
|
294
|
+
}
|
|
295
|
+
|
|
296
|
+
mpInstance._Store.identityCallInFlight = false;
|
|
297
|
+
mpInstance._Store.identityCallFailed = false;
|
|
298
|
+
const errorMessage = 'Received HTTP Code of ' + response.status;
|
|
299
|
+
Logger.error('Error sending identity request to servers - ' + errorMessage);
|
|
300
|
+
invokeCallback(callback, HTTPCodes.noHttpCoverage, errorMessage);
|
|
301
|
+
return;
|
|
292
302
|
}
|
|
293
303
|
}
|
|
294
304
|
|
|
295
305
|
mpInstance._Store.identityCallInFlight = false;
|
|
306
|
+
mpInstance._Store.identityCallFailed = false;
|
|
296
307
|
|
|
297
308
|
Logger.verbose(message);
|
|
298
309
|
if (mpInstance._RoktManager?.isInitialized) {
|
|
@@ -310,19 +321,17 @@ export default function IdentityAPIClient(
|
|
|
310
321
|
);
|
|
311
322
|
} catch (err) {
|
|
312
323
|
mpInstance._Store.identityCallInFlight = false;
|
|
324
|
+
mpInstance._Store.identityCallFailed = true;
|
|
313
325
|
if (mpInstance._RoktManager?.isInitialized) {
|
|
314
326
|
const requestCount = mpInstance._Store.identifyRequestCount;
|
|
315
327
|
mpInstance.captureTiming(`${requestCount}-identityRequestEnd`);
|
|
316
328
|
}
|
|
317
329
|
|
|
318
330
|
const errorMessage = (err as Error).message || err.toString();
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
HTTPCodes.noHttpCoverage,
|
|
324
|
-
errorMessage,
|
|
325
|
-
);
|
|
331
|
+
Logger.error('Error sending identity request to servers - ' + errorMessage);
|
|
332
|
+
|
|
333
|
+
mpInstance.processQueueOnIdentityFailure?.();
|
|
334
|
+
invokeCallback(callback, HTTPCodes.noHttpCoverage, errorMessage);
|
|
326
335
|
}
|
|
327
336
|
};
|
|
328
337
|
|
package/src/mp-instance.ts
CHANGED
|
@@ -93,6 +93,7 @@ export interface IMParticleWebSDKInstance extends MParticleWebSDK {
|
|
|
93
93
|
_timeOnSiteTimer: ForegroundTimer;
|
|
94
94
|
setLauncherInstanceGuid: () => void;
|
|
95
95
|
captureTiming(metricName: string);
|
|
96
|
+
processQueueOnIdentityFailure?: () => void;
|
|
96
97
|
}
|
|
97
98
|
|
|
98
99
|
const { Messages, HTTPCodes, FeatureFlags, CaptureIntegrationSpecificIdsV2Modes } = Constants;
|
|
@@ -132,7 +133,26 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
132
133
|
integrationDelays: {},
|
|
133
134
|
forwarderConstructors: [],
|
|
134
135
|
};
|
|
136
|
+
|
|
135
137
|
this._RoktManager = new RoktManager();
|
|
138
|
+
|
|
139
|
+
this._RoktManager.setOnReadyCallback(() => {
|
|
140
|
+
self.processQueueOnIdentityFailure();
|
|
141
|
+
});
|
|
142
|
+
|
|
143
|
+
/**
|
|
144
|
+
* Processes message and ready queue when identity requests fails but Rokt is ready.
|
|
145
|
+
*/
|
|
146
|
+
this.processQueueOnIdentityFailure = function() {
|
|
147
|
+
if (self._Store?.isInitialized) {
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
if (self._Store?.identityCallFailed && self._RoktManager?.isReady()) {
|
|
152
|
+
self._RoktManager.processMessageQueue();
|
|
153
|
+
self._preInit.readyQueue = processReadyQueue(self._preInit.readyQueue);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
136
156
|
|
|
137
157
|
// required for forwarders once they reference the mparticle instance
|
|
138
158
|
this.IdentityType = IdentityType;
|
|
@@ -249,12 +269,18 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
249
269
|
};
|
|
250
270
|
};
|
|
251
271
|
/**
|
|
252
|
-
*
|
|
272
|
+
* Executes callback when the SDK is ready, or Rokt is ready but identify requests fail due to server errors.
|
|
273
|
+
* This ensures Rokt methods like selectPlacements continue to work during backend outages.
|
|
253
274
|
* @method ready
|
|
254
|
-
* @param {Function}
|
|
275
|
+
* @param {Function} f Callback to execute
|
|
255
276
|
*/
|
|
256
277
|
this.ready = function(f) {
|
|
257
|
-
|
|
278
|
+
const shouldExecute = isFunction(f) && (
|
|
279
|
+
self._Store?.isInitialized ||
|
|
280
|
+
(self._Store?.identityCallFailed && self._RoktManager.isReady())
|
|
281
|
+
);
|
|
282
|
+
|
|
283
|
+
if (shouldExecute) {
|
|
258
284
|
f();
|
|
259
285
|
} else {
|
|
260
286
|
self._preInit.readyQueue.push(f);
|
|
@@ -1620,9 +1646,12 @@ function processIdentityCallback(
|
|
|
1620
1646
|
}
|
|
1621
1647
|
|
|
1622
1648
|
function queueIfNotInitialized(func, self) {
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1649
|
+
// Core SDK methods must wait for Store initialization
|
|
1650
|
+
if (!self._Store?.isInitialized) {
|
|
1651
|
+
self._preInit.readyQueue.push(function() {
|
|
1652
|
+
if (self._Store?.isInitialized) {
|
|
1653
|
+
func();
|
|
1654
|
+
}
|
|
1626
1655
|
});
|
|
1627
1656
|
return true;
|
|
1628
1657
|
}
|
package/src/roktManager.ts
CHANGED
|
@@ -102,7 +102,16 @@ export default class RoktManager {
|
|
|
102
102
|
private domain?: string;
|
|
103
103
|
private mappedEmailShaIdentityType?: string | null;
|
|
104
104
|
private captureTiming?: (metricsName: string) => void;
|
|
105
|
+
private onReadyCallback: (() => void) | null = null;
|
|
105
106
|
private initialized: boolean = false;
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Sets a callback to be invoked when RoktManager becomes ready
|
|
110
|
+
*/
|
|
111
|
+
public setOnReadyCallback(callback: () => void): void {
|
|
112
|
+
this.onReadyCallback = callback;
|
|
113
|
+
}
|
|
114
|
+
|
|
106
115
|
/**
|
|
107
116
|
* Initializes the RoktManager with configuration settings and user data.
|
|
108
117
|
*
|
|
@@ -133,6 +142,8 @@ export default class RoktManager {
|
|
|
133
142
|
this.logger = logger;
|
|
134
143
|
this.captureTiming = captureTiming;
|
|
135
144
|
|
|
145
|
+
this.captureTiming?.(PerformanceMarkType.JointSdkRoktKitInit);
|
|
146
|
+
|
|
136
147
|
this.filters = {
|
|
137
148
|
userAttributeFilters,
|
|
138
149
|
filterUserAttributes: KitFilterHelper.filterUserAttributes,
|
|
@@ -171,6 +182,12 @@ export default class RoktManager {
|
|
|
171
182
|
public attachKit(kit: IRoktKit): void {
|
|
172
183
|
this.kit = kit;
|
|
173
184
|
this.processMessageQueue();
|
|
185
|
+
|
|
186
|
+
try {
|
|
187
|
+
this.onReadyCallback?.();
|
|
188
|
+
} catch (e) {
|
|
189
|
+
this.logger?.error('RoktManager: Error in onReadyCallback: ' + e);
|
|
190
|
+
}
|
|
174
191
|
}
|
|
175
192
|
|
|
176
193
|
/**
|
|
@@ -189,9 +206,7 @@ export default class RoktManager {
|
|
|
189
206
|
* });
|
|
190
207
|
*/
|
|
191
208
|
public async selectPlacements(options: IRoktSelectPlacementsOptions): Promise<IRoktSelection> {
|
|
192
|
-
|
|
193
|
-
this.captureTiming(PerformanceMarkType.JointSdkSelectPlacements);
|
|
194
|
-
}
|
|
209
|
+
this.captureTiming?.(PerformanceMarkType.JointSdkSelectPlacements);
|
|
195
210
|
|
|
196
211
|
// Queue if kit isn't ready OR if identity is in flight
|
|
197
212
|
if (!this.isReady() || this.store?.identityCallInFlight) {
|
|
@@ -202,7 +217,8 @@ export default class RoktManager {
|
|
|
202
217
|
const { attributes } = options;
|
|
203
218
|
const sandboxValue = attributes?.sandbox || null;
|
|
204
219
|
const mappedAttributes = this.mapPlacementAttributes(attributes, this.placementAttributesMapping);
|
|
205
|
-
|
|
220
|
+
this.logger?.verbose(`mParticle.Rokt selectPlacements called with attributes:\n${JSON.stringify(attributes, null, 2)}`);
|
|
221
|
+
|
|
206
222
|
this.currentUser = this.identityService.getCurrentUser();
|
|
207
223
|
const currentUserIdentities = this.currentUser?.getUserIdentities()?.userIdentities || {};
|
|
208
224
|
|
|
@@ -405,7 +421,7 @@ export default class RoktManager {
|
|
|
405
421
|
this.store.setLocalSessionAttribute(key, value);
|
|
406
422
|
}
|
|
407
423
|
|
|
408
|
-
|
|
424
|
+
public isReady(): boolean {
|
|
409
425
|
// The Rokt Manager is ready when a kit is attached and has a launcher
|
|
410
426
|
return Boolean(this.kit && this.kit.launcher);
|
|
411
427
|
}
|
|
@@ -452,7 +468,7 @@ export default class RoktManager {
|
|
|
452
468
|
}
|
|
453
469
|
}
|
|
454
470
|
|
|
455
|
-
|
|
471
|
+
public processMessageQueue(): void {
|
|
456
472
|
if (!this.isReady() || this.messageQueue.size === 0) {
|
|
457
473
|
return;
|
|
458
474
|
}
|
package/src/store.ts
CHANGED
|
@@ -182,6 +182,7 @@ export interface IStore {
|
|
|
182
182
|
context: Context | null;
|
|
183
183
|
configurationLoaded: boolean;
|
|
184
184
|
identityCallInFlight: boolean;
|
|
185
|
+
identityCallFailed: boolean;
|
|
185
186
|
identifyRequestCount: number;
|
|
186
187
|
SDKConfig: Partial<SDKConfig>;
|
|
187
188
|
nonCurrentUserMPIDs: Record<MPID, Dictionary>;
|
|
@@ -267,6 +268,7 @@ export default function Store(
|
|
|
267
268
|
context: null,
|
|
268
269
|
configurationLoaded: false,
|
|
269
270
|
identityCallInFlight: false,
|
|
271
|
+
identityCallFailed: false,
|
|
270
272
|
identifyRequestCount: 0,
|
|
271
273
|
SDKConfig: {},
|
|
272
274
|
nonCurrentUserMPIDs: {},
|
package/src/types.ts
CHANGED
|
@@ -394,6 +394,7 @@ export const ApplicationTransitionType = {
|
|
|
394
394
|
export const PerformanceMarkType = {
|
|
395
395
|
SdkStart: 'mp:sdkStart' as const,
|
|
396
396
|
JointSdkSelectPlacements: 'mp:jointSdkSelectPlacements' as const,
|
|
397
|
+
JointSdkRoktKitInit: 'mp:jointSdkRoktKitInit' as const,
|
|
397
398
|
}
|
|
398
399
|
|
|
399
400
|
export default {
|