@mparticle/web-sdk 2.33.0 → 2.34.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 +25 -12
- package/dist/mparticle.esm.js +25 -12
- package/dist/mparticle.js +148 -10
- package/package.json +1 -1
- package/src/foregroundTimeTracker.ts +1 -1
- package/src/integrationCapture.ts +82 -2
- package/src/mp-instance.ts +7 -4
- package/src/mparticle-instance-manager.ts +9 -7
- package/src/roktManager.ts +76 -0
- package/src/sdkRuntimeModels.ts +12 -7
- package/src/serverModel.ts +6 -2
- package/src/utils.ts +9 -4
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.34.0";
|
|
19
19
|
|
|
20
20
|
var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodIsDeprecatedPostfix:"is a deprecated method and will be removed in future releases",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",AddToCart:"addToCart",RemoveFromCart:"removeFromCart",ClearCart:"clearCart",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",localStorageProductsV4:"mprtcl-prodv4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4",currentStorageProductsName:"mprtcl-prodv4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,maxProducts:20,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
|
|
21
21
|
},DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},Base64CookieKeys:{csm:1,sa:1,ss:1,ua:1,ui:1,csd:1,ia:1,con:1},// https://go.mparticle.com/work/SQDSDKS-6039
|
|
@@ -127,7 +127,7 @@ var Messages$9=Constants.Messages,createCookieString=function(a){return replaceC
|
|
|
127
127
|
"".concat(1e7,"-").concat(1e3,"-").concat(4e3,"-").concat(8e3,"-").concat(1e11).replace(/[018]/g,// zeroes, ones, and eights with
|
|
128
128
|
generateUniqueId// random hex digits
|
|
129
129
|
)},getRampNumber=function(a){if(!a)return 100;var b=generateHash(a);return Math.abs(b%100)+1},isObject=function(a){var b=Object.prototype.toString.call(a);return "[object Object]"===b||"[object Error]"===b},parseNumber=function(a){if(isNaN(a)||!isFinite(a))return 0;var b=parseFloat(a);return isNaN(b)?0:b},parseStringOrNumber=function(a){return isStringOrNumber(a)?a:null},replaceCommasWithPipes=function(a){return a.replace(/,/g,"|")},replacePipesWithCommas=function(a){return a.replace(/\|/g,",")},replaceApostrophesWithQuotes=function(a){return a.replace(/\'/g,"\"")},replaceQuotesWithApostrophes=function(a){return a.replace(/\"/g,"'")},replaceMPID=function(a,b){return a.replace("%%mpid%%",b)},replaceAmpWithAmpersand=function(a){return a.replace(/&/g,"&")},createCookieSyncUrl=function(a,b,c){var d=replaceAmpWithAmpersand(b),e=c?replaceAmpWithAmpersand(c):null,f=replaceMPID(d,a),g=e?replaceMPID(e,a):"";return f+encodeURIComponent(g)},returnConvertedBoolean=function(a){return "false"!==a&&"0"!==a&&!!a},decoded=function(a){return decodeURIComponent(a.replace(/\+/g," "))},converted=function(a){return 0===a.indexOf("\"")&&(a=a.slice(1,-1).replace(/\\"/g,"\"").replace(/\\\\/g,"\\")),a},isString=function(a){return "string"==typeof a},isNumber=function(a){return "number"==typeof a},isBoolean=function(a){return "boolean"==typeof a},isFunction=function(a){return "function"==typeof a},isValidCustomFlagProperty=function(a){return isNumber(a)||isString(a)||isBoolean(a)},toDataPlanSlug=function(a){// Make sure we are only acting on strings or numbers
|
|
130
|
-
return isStringOrNumber(a)?a.toString().toLowerCase().replace(/[^0-9a-zA-Z]+/g,"_"):""},isDataPlanSlug=function(a){return a===toDataPlanSlug(a)},isStringOrNumber=function(a){return isString(a)||isNumber(a)},isEmpty=function(a){return null==a||!(Object.keys(a)||a).length},moveElementToEnd=function(a,b){return a.slice(0,b).concat(a.slice(b+1),a[b])},queryStringParser=function(a,b){void 0===b&&(b=[]);var c,d={};if(!a)return d;if("undefined"!=typeof URL&&"undefined"!=typeof URLSearchParams){var e=new URL(a);c=new URLSearchParams(e.search);}else c=queryStringParserFallback(a);return isEmpty(b)?c.forEach(function(a,b){d[b]=a;}):b.forEach(function(a){var b=c.get(a);b&&(d[a]=b);}),d},queryStringParserFallback=function(a){var b={},c=a.split("?")[1]||"",d=c.split("&");return d.forEach(function(a){var c=a.split("="),d=c[0],e=c
|
|
130
|
+
return isStringOrNumber(a)?a.toString().toLowerCase().replace(/[^0-9a-zA-Z]+/g,"_"):""},isDataPlanSlug=function(a){return a===toDataPlanSlug(a)},isStringOrNumber=function(a){return isString(a)||isNumber(a)},isEmpty=function(a){return null==a||!(Object.keys(a)||a).length},moveElementToEnd=function(a,b){return a.slice(0,b).concat(a.slice(b+1),a[b])},queryStringParser=function(a,b){void 0===b&&(b=[]);var c,d={};if(!a)return d;if("undefined"!=typeof URL&&"undefined"!=typeof URLSearchParams){var e=new URL(a);c=new URLSearchParams(e.search);}else c=queryStringParserFallback(a);return isEmpty(b)?c.forEach(function(a,b){d[b]=a;}):b.forEach(function(a){var b=c.get(a);b&&(d[a]=b);}),d},queryStringParserFallback=function(a){var b={},c=a.split("?")[1]||"",d=c.split("&");return d.forEach(function(a){var c=a.split("="),d=c[0],e=c.slice(1),f=e.join("=");if(d&&void 0!==f)try{b[d]=decodeURIComponent(f||"");}catch(a){console.error("Failed to decode value for key ".concat(d,": ").concat(a));}}),{get:function get(a){return b[a]},forEach:function forEach(a){for(var c in b)b.hasOwnProperty(c)&&a(b[c],c);}}},getCookies=function(a){// Helper function to parse cookies from document.cookie
|
|
131
131
|
var b=function parseCookies(){return "undefined"==typeof window?[]:window.document.cookie.split(";").map(function(a){return a.trim()})}();// Helper function to filter cookies by keys
|
|
132
132
|
// Parse cookies from document.cookie
|
|
133
133
|
// Filter cookies by keys if provided
|
|
@@ -515,7 +515,7 @@ this.convertTransactionAttributesToProductAction=function(a,b){a.hasOwnProperty(
|
|
|
515
515
|
return (a.Logger.verbose(Messages$5.InformationMessages.StartingLogCommerceEvent),a._Helpers.canLog())?(d=a._ServerModel.createEventObject({messageType:Types.MessageType.Commerce,sourceMessageId:null===c||void 0===c?void 0:c.sourceMessageId}),d.EventName="eCommerce - ",d.CurrencyCode=a._Store.currencyCode,d.ShoppingCart=[],d.CustomFlags=e(d.CustomFlags,b),d):(a.Logger.verbose(Messages$5.InformationMessages.AbandonLogEvent),null)},this.sanitizeAmount=function(b,c){if(!a._Helpers.Validators.isStringOrNumber(b)){var d=[c,"must be of type number. A",_typeof$1(b),"was passed. Converting to 0"].join(" ");return a.Logger.warning(d),0}// if amount is a string, it will be parsed into a number if possible, or set to 0
|
|
516
516
|
return a._Helpers.parseNumber(b)};}
|
|
517
517
|
|
|
518
|
-
var ForegroundTimeTracker=/** @class */function(){function a(a){this.isTrackerActive=!1,this.localStorageName="",this.startTime=0,this.totalTime=0,this.localStorageName="
|
|
518
|
+
var ForegroundTimeTracker=/** @class */function(){function a(a){this.isTrackerActive=!1,this.localStorageName="",this.startTime=0,this.totalTime=0,this.localStorageName="mprtcl-tos-".concat(a),this.timerVault=new LocalStorageVault(this.localStorageName),this.loadTimeFromStorage(),this.addHandlers(),!1===document.hidden&&this.startTracking();}return a.prototype.addHandlers=function(){var a=this;// when user switches tabs or minimizes the window
|
|
519
519
|
document.addEventListener("visibilitychange",function(){return a.handleVisibilityChange()}),window.addEventListener("blur",function(){return a.handleWindowBlur()}),window.addEventListener("focus",function(){return a.handleWindowFocus()}),window.addEventListener("storage",function(b){return a.syncAcrossTabs(b)}),window.addEventListener("beforeunload",function(){return a.updateTimeInPersistence()});},a.prototype.handleVisibilityChange=function(){document.hidden?this.stopTracking():this.startTracking();},a.prototype.handleWindowBlur=function(){this.isTrackerActive&&this.stopTracking();},a.prototype.handleWindowFocus=function(){this.isTrackerActive||this.startTracking();},a.prototype.syncAcrossTabs=function(a){if(a.key===this.localStorageName&&null!==a.newValue){var b=parseFloat(a.newValue)||0;this.totalTime=b;}},a.prototype.updateTimeInPersistence=function(){this.isTrackerActive&&this.timerVault.store(Math.round(this.totalTime));},a.prototype.loadTimeFromStorage=function(){var a=this.timerVault.retrieve();isNumber(a)&&null!==a&&(this.totalTime=a);},a.prototype.startTracking=function(){document.hidden||(this.startTime=Math.floor(performance.now()),this.isTrackerActive=!0);},a.prototype.stopTracking=function(){this.isTrackerActive&&(this.setTotalTime(),this.updateTimeInPersistence(),this.isTrackerActive=!1);},a.prototype.setTotalTime=function(){if(this.isTrackerActive){var a=Math.floor(performance.now());this.totalTime+=a-this.startTime,this.startTime=a;}},a.prototype.getTimeInForeground=function(){return this.setTotalTime(),this.updateTimeInPersistence(),this.totalTime},a.prototype.resetTimer=function(){this.totalTime=0,this.updateTimeInPersistence();},a}();
|
|
520
520
|
|
|
521
521
|
function createSDKConfig(a){// TODO: Refactor to create a default config object
|
|
@@ -1046,12 +1046,12 @@ this.appendUserInfo=function(b,c){if(c){if(!b)return c.MPID=null,c.ConsentState=
|
|
|
1046
1046
|
// tracked. If this is an `optOut` Event, we set `optOut` to the inverse of the SDK's
|
|
1047
1047
|
// `isEnabled` boolean which is controlled via `MPInstanceManager.setOptOut`.
|
|
1048
1048
|
// TODO: Why is Webview Bridge Enabled or Opt Out necessary here?
|
|
1049
|
-
if(a._Store.sessionId||c.messageType===Types.MessageType.OptOut||a._Store.webviewBridgeEnabled){var i=__assign({},c.customFlags);// https://go.mparticle.com/work/SQDSDKS-5053
|
|
1050
|
-
if(a._Helpers.getFeatureFlag&&a._Helpers.getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIds)){a._IntegrationCapture.capture();var
|
|
1049
|
+
if(a._Store.sessionId||c.messageType===Types.MessageType.OptOut||a._Store.webviewBridgeEnabled){var i=__assign({},c.customFlags),j=a._Store.integrationAttributes;// https://go.mparticle.com/work/SQDSDKS-5053
|
|
1050
|
+
if(a._Helpers.getFeatureFlag&&a._Helpers.getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIds)){a._IntegrationCapture.capture();var k=a._IntegrationCapture.getClickIdsAsCustomFlags();i=__assign(__assign({},k),i);var l=a._IntegrationCapture.getClickIdsAsIntegrationAttributes();j=__assign(__assign({},l),j);}g=c.hasOwnProperty("toEventAPIObject")?c.toEventAPIObject():{// This is an artifact from v2 events where SessionStart/End and AST event
|
|
1051
1051
|
// names are numbers (1, 2, or 10), but going forward with v3, these lifecycle
|
|
1052
1052
|
// events do not have names, but are denoted by their `event_type`
|
|
1053
1053
|
EventName:c.name||c.messageType,EventCategory:c.eventType,EventAttributes:a._Helpers.sanitizeAttributes(c.data,c.name),ActiveTimeOnSite:null===(e=a._timeOnSiteTimer)||void 0===e?void 0:e.getTimeInForeground(),SourceMessageId:c.sourceMessageId||a._Helpers.generateUniqueId(),EventDataType:c.messageType,CustomFlags:i,UserAttributeChanges:c.userAttributeChanges,UserIdentityChanges:c.userIdentityChanges},c.messageType!==Types.MessageType.SessionEnd&&(a._Store.dateLastEventSent=new Date),f={// FIXME: Deprecate when we get rid of V2
|
|
1054
|
-
Store:a._Store.serverSettings,SDKVersion:Constants.sdkVersion,SessionId:a._Store.sessionId,SessionStartDate:a._Store.sessionStartDate?a._Store.sessionStartDate.getTime():0,Debug:a._Store.SDKConfig.isDevelopmentMode,Location:a._Store.currentPosition,OptOut:h,ExpandedEventCount:0,AppVersion:a.getAppVersion(),AppName:a.getAppName(),Package:a._Store.SDKConfig["package"],ClientGeneratedId:a._Store.clientId,DeviceId:a._Store.deviceId,IntegrationAttributes:
|
|
1054
|
+
Store:a._Store.serverSettings,SDKVersion:Constants.sdkVersion,SessionId:a._Store.sessionId,SessionStartDate:a._Store.sessionStartDate?a._Store.sessionStartDate.getTime():0,Debug:a._Store.SDKConfig.isDevelopmentMode,Location:a._Store.currentPosition,OptOut:h,ExpandedEventCount:0,AppVersion:a.getAppVersion(),AppName:a.getAppName(),Package:a._Store.SDKConfig["package"],ClientGeneratedId:a._Store.clientId,DeviceId:a._Store.deviceId,IntegrationAttributes:j,CurrencyCode:a._Store.currencyCode,DataPlan:a._Store.SDKConfig.dataPlan?a._Store.SDKConfig.dataPlan:{}},g.EventDataType===MessageType.AppStateTransition&&(g.IsFirstRun=a._Store.isFirstRun,g.LaunchReferral=window.location.href||null),g.CurrencyCode=a._Store.currencyCode;var m=d||a.Identity.getCurrentUser();return b.appendUserInfo(m,g),c.messageType===Types.MessageType.SessionEnd&&(g.SessionLength=a._Store.dateLastEventSent.getTime()-a._Store.sessionStartDate.getTime(),g.currentSessionMPIDs=a._Store.currentSessionMPIDs,g.EventAttributes=a._Store.sessionAttributes,a._Store.currentSessionMPIDs=[],a._Store.sessionStartDate=null),f.Timestamp=a._Store.dateLastEventSent.getTime(),a._Helpers.extend({},g,f)}return null},this.convertEventToV2DTO=function(c){var d={n:c.EventName,et:c.EventCategory,ua:c.UserAttributes,ui:c.UserIdentities,ia:c.IntegrationAttributes,str:c.Store,attrs:c.EventAttributes,sdk:c.SDKVersion,sid:c.SessionId,sl:c.SessionLength,ssd:c.SessionStartDate,dt:c.EventDataType,dbg:c.Debug,ct:c.Timestamp,lc:c.Location,o:c.OptOut,eec:c.ExpandedEventCount,av:c.AppVersion,cgid:c.ClientGeneratedId,das:c.DeviceId,mpid:c.MPID,smpids:c.currentSessionMPIDs};c.DataPlan&&c.DataPlan.PlanId&&(d.dp_id=c.DataPlan.PlanId,c.DataPlan.PlanVersion&&(d.dp_v=c.DataPlan.PlanVersion));var e=b.convertToConsentStateV2DTO(c.ConsentState);return e&&(d.con=e),c.EventDataType===MessageType.AppStateTransition&&(d.fr=c.IsFirstRun,d.iu=!1,d.at=ApplicationTransitionType.AppInit,d.lr=c.LaunchReferral,d.attrs=null),c.CustomFlags&&convertCustomFlags(c,d),c.EventDataType===MessageType.Commerce?(d.cu=c.CurrencyCode,c.ShoppingCart&&(d.sc={pl:convertProductListToV2DTO(c.ShoppingCart.ProductList)}),c.ProductAction?d.pd={an:c.ProductAction.ProductActionType,cs:a._Helpers.parseNumber(c.ProductAction.CheckoutStep),co:c.ProductAction.CheckoutOptions,pl:convertProductListToV2DTO(c.ProductAction.ProductList),ti:c.ProductAction.TransactionId,ta:c.ProductAction.Affiliation,tcc:c.ProductAction.CouponCode,tr:a._Helpers.parseNumber(c.ProductAction.TotalAmount),ts:a._Helpers.parseNumber(c.ProductAction.ShippingAmount),tt:a._Helpers.parseNumber(c.ProductAction.TaxAmount)}:c.PromotionAction?d.pm={an:c.PromotionAction.PromotionActionType,pl:c.PromotionAction.PromotionList.map(function(a){return {id:a.Id,nm:a.Name,cr:a.Creative,ps:a.Position?a.Position:0}})}:c.ProductImpressions&&(d.pi=c.ProductImpressions.map(function(a){return {pil:a.ProductImpressionList,pl:convertProductListToV2DTO(a.ProductList)}}))):c.EventDataType===MessageType.Profile&&(d.pet=c.ProfileMessageType),d};}
|
|
1055
1055
|
|
|
1056
1056
|
function forwardingStatsUploader(a){function b(){var b=a._Forwarders.getForwarderStatsQueue(),c=a._Persistence.forwardingStatsBatches.uploadsTable,d=Date.now();for(var e in b.length&&(c[d]={uploading:!1,data:b},a._Forwarders.setForwarderStatsQueue([])),c)(function(b){if(c.hasOwnProperty(b)&&!1===c[b].uploading){var d=function(){4===e.readyState&&(200===e.status||202===e.status?(a.Logger.verbose("Successfully sent "+e.statusText+" from server"),delete c[b]):"4"===e.status.toString()[0]?429!==e.status&&delete c[b]:c[b].uploading=!1);},e=a._Helpers.createXHR(d),f=c[b].data;c[b].uploading=!0,a._APIClient.sendBatchForwardingStatsToServer(f,e);}})(e);}this.startForwardingStatsTimer=function(){mParticle._forwardingStatsTimer=setInterval(function(){b();},a._Store.SDKConfig.forwarderStatsTimeout);};}
|
|
1057
1057
|
|
|
@@ -1378,12 +1378,25 @@ var facebookClickIdProcessor=function(a,b,c){if(!a||!b)return "";var d=null===b|
|
|
|
1378
1378
|
var h=c||Date.now();return "fb.".concat(g,".").concat(h,".").concat(a)};// Integration outputs are used to determine how click ids are used within the SDK
|
|
1379
1379
|
// CUSTOM_FLAGS are sent out when an Event is created via ServerModel.createEventObject
|
|
1380
1380
|
// PARTNER_IDENTITIES are sent out in a Batch when a group of events are converted to a Batch
|
|
1381
|
-
|
|
1381
|
+
// INTEGRATION_ATTRIBUTES are stored initially on the SDKEvent level but then is added to the Batch when the batch is created
|
|
1382
|
+
var IntegrationOutputs={CUSTOM_FLAGS:"custom_flags",PARTNER_IDENTITIES:"partner_identities",INTEGRATION_ATTRIBUTES:"integration_attributes"},integrationMapping={// Facebook / Meta
|
|
1382
1383
|
fbclid:{mappedKey:"Facebook.ClickId",processor:facebookClickIdProcessor,output:IntegrationOutputs.CUSTOM_FLAGS},_fbp:{mappedKey:"Facebook.BrowserId",output:IntegrationOutputs.CUSTOM_FLAGS},_fbc:{mappedKey:"Facebook.ClickId",output:IntegrationOutputs.CUSTOM_FLAGS},// Google
|
|
1383
|
-
gclid:{mappedKey:"GoogleEnhancedConversions.Gclid",output:IntegrationOutputs.CUSTOM_FLAGS},gbraid:{mappedKey:"GoogleEnhancedConversions.Gbraid",output:IntegrationOutputs.CUSTOM_FLAGS},wbraid:{mappedKey:"GoogleEnhancedConversions.Wbraid",output:IntegrationOutputs.CUSTOM_FLAGS},//
|
|
1384
|
-
|
|
1384
|
+
gclid:{mappedKey:"GoogleEnhancedConversions.Gclid",output:IntegrationOutputs.CUSTOM_FLAGS},gbraid:{mappedKey:"GoogleEnhancedConversions.Gbraid",output:IntegrationOutputs.CUSTOM_FLAGS},wbraid:{mappedKey:"GoogleEnhancedConversions.Wbraid",output:IntegrationOutputs.CUSTOM_FLAGS},// Rokt
|
|
1385
|
+
// https://docs.rokt.com/developers/integration-guides/web/advanced/rokt-id-tag/
|
|
1386
|
+
rtid:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},RoktTransactionId:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},// TIKTOK
|
|
1387
|
+
ttclid:{mappedKey:"TikTok.Callback",output:IntegrationOutputs.CUSTOM_FLAGS},_ttp:{mappedKey:"tiktok_cookie_id",output:IntegrationOutputs.PARTNER_IDENTITIES}},IntegrationCapture=/** @class */function(){function a(){this.initialTimestamp=Date.now(),this.filteredPartnerIdentityMappings=this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES),this.filteredCustomFlagMappings=this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS),this.filteredIntegrationAttributeMappings=this.filterMappings(IntegrationOutputs.INTEGRATION_ATTRIBUTES);}/**
|
|
1385
1388
|
* Captures Integration Ids from cookies and query params and stores them in clickIds object
|
|
1386
|
-
*/return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{};a.fbclid&&b._fbc&&delete b._fbc,this.clickIds=__assign(__assign(__assign({},this.clickIds),a),b);},a.prototype.captureCookies=function(){var a=getCookies(Object.keys(integrationMapping));return this.applyProcessors(a)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.getQueryParams=function(){return queryStringParser(getHref(),Object.keys(integrationMapping))},a.prototype.getClickIdsAsCustomFlags=function(){return this.getClickIds(this.clickIds,this.filteredCustomFlagMappings)},a.prototype.getClickIdsAsPartnerIdentities=function(){return this.getClickIds(this.clickIds,this.filteredPartnerIdentityMappings)},a.prototype.
|
|
1389
|
+
*/return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{},c=this.captureLocalStorage()||{};a.fbclid&&b._fbc&&delete b._fbc,a.rtid&&c.RoktTransactionId&&b.RoktTransactionId?(delete c.RoktTransactionId,delete b.RoktTransactionId):a.rtid&&c.RoktTransactionId?delete c.RoktTransactionId:a.rtid&&b.RoktTransactionId?delete b.RoktTransactionId:c.RoktTransactionId&&b.RoktTransactionId&&delete b.RoktTransactionId,this.clickIds=__assign(__assign(__assign(__assign({},this.clickIds),a),c),b);},a.prototype.captureCookies=function(){var a=getCookies(Object.keys(integrationMapping));return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureLocalStorage=function(){var a={};for(var b in integrationMapping){var c=localStorage.getItem(b);c&&(a[b]=c);}return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.getQueryParams=function(){return queryStringParser(getHref(),Object.keys(integrationMapping))},a.prototype.getClickIdsAsCustomFlags=function(){return this.getClickIds(this.clickIds,this.filteredCustomFlagMappings)},a.prototype.getClickIdsAsPartnerIdentities=function(){return this.getClickIds(this.clickIds,this.filteredPartnerIdentityMappings)},a.prototype.getClickIdsAsIntegrationAttributes=function(){var a,b,c,d={};// Integration IDs are stored in the following format:
|
|
1390
|
+
// {
|
|
1391
|
+
// "integration_attributes": {
|
|
1392
|
+
// "<moduleId>": {
|
|
1393
|
+
// "mappedKey": "clickIdValue"
|
|
1394
|
+
// }
|
|
1395
|
+
// }
|
|
1396
|
+
// }
|
|
1397
|
+
for(var e in this.clickIds)if(this.clickIds.hasOwnProperty(e)){var f=this.clickIds[e],g=null===(b=this.filteredIntegrationAttributeMappings[e])||void 0===b?void 0:b.mappedKey;if(!isEmpty(g)){var h=null===(c=this.filteredIntegrationAttributeMappings[e])||void 0===c?void 0:c.moduleId;h&&!d[h]&&(d[h]=(a={},a[g]=f,a));}}return d},a.prototype.getClickIds=function(a,b){var c,d={};if(!a)return d;for(var e in a)if(a.hasOwnProperty(e)){var f=a[e],g=null===(c=b[e])||void 0===c?void 0:c.mappedKey;isEmpty(g)||(d[g]=f);}return d},a.prototype.applyProcessors=function(a,b,c){var d,e={};for(var f in a)if(a.hasOwnProperty(f)){var g=a[f],h=null===(d=integrationMapping[f])||void 0===d?void 0:d.processor;e[f]=h?h(g,b,c):g;}return e},a.prototype.filterMappings=function(a){var b={};for(var c in integrationMapping)integrationMapping[c].output===a&&(b[c]=integrationMapping[c]);return b},a}();
|
|
1398
|
+
|
|
1399
|
+
var RoktManager=/** @class */function(){function a(){this.launcher=null,this.messageQueue=[],this.launcher=null;}return a.prototype.attachLauncher=function(a){this.setLauncher(a),this.processMessageQueue();},a.prototype.selectPlacements=function(a){if(!this.launcher)return this.queueMessage({methodName:"selectPlacements",payload:a}),Promise.resolve({});try{return this.launcher.selectPlacements(a)}catch(a){return Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))}},a.prototype.processMessageQueue=function(){var a=this;0<this.messageQueue.length&&(this.messageQueue.forEach(function(b){return __awaiter(a,void 0,void 0,function(){return __generator(this,function(a){switch(a.label){case 0:return this.launcher&&b.methodName in this.launcher?[4/*yield*/,this.launcher[b.methodName](b.payload)]:[3/*break*/,2];case 1:a.sent(),a.label=2;case 2:return [2/*return*/]}})})}),this.messageQueue=[]);},a.prototype.queueMessage=function(a){this.messageQueue.push(a);},a.prototype.setLauncher=function(a){this.launcher=a;},a}();
|
|
1387
1400
|
|
|
1388
1401
|
var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
|
|
1389
1402
|
* <p>All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced <a href="https://docs.mparticle.com/developers/sdk/web/multiple-instances/">multiple instances</a>. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.</p>
|
|
@@ -1559,7 +1572,7 @@ var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Const
|
|
|
1559
1572
|
If there is no delay, then the events sent before an integration attribute is included would not
|
|
1560
1573
|
be forwarded successfully server side.
|
|
1561
1574
|
*/ // Internal use only. Used by our wrapper SDKs to identify themselves during initialization.
|
|
1562
|
-
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._IntegrationCapture=new IntegrationCapture,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
|
|
1575
|
+
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._IntegrationCapture=new IntegrationCapture,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
|
|
1563
1576
|
// Since fetching the configuration is asynchronous, we must pass completeSDKInitialization
|
|
1564
1577
|
// to it for it to be run after fetched
|
|
1565
1578
|
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._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()&&"function"==typeof a?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
|
|
@@ -1750,6 +1763,6 @@ Array.prototype.forEach||(Array.prototype.forEach=Polyfill.forEach),Array.protot
|
|
|
1750
1763
|
* @param {String} apiKey your mParticle assigned API key
|
|
1751
1764
|
* @param {Object} [config] an options object for additional configuration
|
|
1752
1765
|
* @param {String} [instanceName] If you are self hosting the JS SDK and working with multiple instances, you would pass an instanceName to `init`. This instance will be selected when invoking other methods. See the above link to the doc site for more info and examples.
|
|
1753
|
-
*/this.Store={},this._instances={},this.IdentityType=
|
|
1766
|
+
*/this.Store={},this._instances={},this.IdentityType=IdentityType,this.EventType=EventType,this.CommerceEventType=CommerceEventType,this.PromotionType=PromotionActionType,this.ProductActionType=ProductActionType,this.MPSideloadedKit=MPSideloadedKit,"undefined"!=typeof window&&(this.isIOS=!!(window.mParticle&&window.mParticle.isIOS)&&window.mParticle.isIOS,this.config=window.mParticle&&window.mParticle.config?window.mParticle.config:{}),this.init=function(b,c,d){!c&&window.mParticle&&window.mParticle.config&&(console.warn("You did not pass a config object to mParticle.init(). Attempting to use the window.mParticle.config if it exists. Please note that in a future release, this may not work and mParticle will not initialize properly"),c=window.mParticle?window.mParticle.config:{}),d=(d&&0!==d.length?d:Constants.DefaultInstance).toLowerCase();var e=a._instances[d];e===void 0&&(e=new mParticleInstance(d),a._instances[d]=e),e.init(b,c,d);},this.getInstance=function(b){var c;return b?(c=a._instances[b.toLowerCase()],c?c:(console.log("You tried to initialize an instance named "+b+". This instance does not exist. Check your instance name or initialize a new instance with this name before calling it."),null)):(b=Constants.DefaultInstance,c=a._instances[b],c||(c=new mParticleInstance(b),a._instances[Constants.DefaultInstance]=c),c)},this.Rokt=a.getInstance()._RoktManager,this.getDeviceId=function(){return a.getInstance().getDeviceId()},this.setDeviceId=function(b){return a.getInstance().setDeviceId(b)},this.isInitialized=function(){return a.getInstance().isInitialized()},this.startNewSession=function(){a.getInstance().startNewSession();},this.endSession=function(){a.getInstance().endSession();},this.setLogLevel=function(b){a.getInstance().setLogLevel(b);},this.ready=function(b){a.getInstance().ready(b);},this.setAppVersion=function(b){a.getInstance().setAppVersion(b);},this.getAppName=function(){return a.getInstance().getAppName()},this.setAppName=function(b){a.getInstance().setAppName(b);},this.getAppVersion=function(){return a.getInstance().getAppVersion()},this.getEnvironment=function(){return a.getInstance().getEnvironment()},this.stopTrackingLocation=function(){a.getInstance().stopTrackingLocation();},this.startTrackingLocation=function(b){a.getInstance().startTrackingLocation(b);},this.setPosition=function(b,c){a.getInstance().setPosition(b,c);},this.startNewSession=function(){a.getInstance().startNewSession();},this.endSession=function(){a.getInstance().endSession();},this.logBaseEvent=function(b,c){a.getInstance().logBaseEvent(b,c);},this.logEvent=function(b,c,d,e,f){a.getInstance().logEvent(b,c,d,e,f);},this.logError=function(b,c){a.getInstance().logError(b,c);},this.logLink=function(b,c,d,e){a.getInstance().logLink(b,c,d,e);},this.logForm=function(b,c,d,e){a.getInstance().logForm(b,c,d,e);},this.logPageView=function(b,c,d,e){a.getInstance().logPageView(b,c,d,e);},this.upload=function(){a.getInstance().upload();},this.eCommerce={Cart:{add:function add(b,c){a.getInstance().eCommerce.Cart.add(b,c);},remove:function remove(b,c){a.getInstance().eCommerce.Cart.remove(b,c);},clear:function clear(){a.getInstance().eCommerce.Cart.clear();}},setCurrencyCode:function setCurrencyCode(b){a.getInstance().eCommerce.setCurrencyCode(b);},createProduct:function createProduct(b,c,d,e,f,g,h,i,j,k){return a.getInstance().eCommerce.createProduct(b,c,d,e,f,g,h,i,j,k)},createPromotion:function createPromotion(b,c,d,e){return a.getInstance().eCommerce.createPromotion(b,c,d,e)},createImpression:function createImpression(b,c){return a.getInstance().eCommerce.createImpression(b,c)},createTransactionAttributes:function createTransactionAttributes(b,c,d,e,f,g){return a.getInstance().eCommerce.createTransactionAttributes(b,c,d,e,f,g)},logCheckout:function logCheckout(b,c,d,e){a.getInstance().eCommerce.logCheckout(b,c,d,e);},logProductAction:function logProductAction(b,c,d,e,f,g){a.getInstance().eCommerce.logProductAction(b,c,d,e,f,g);},logPurchase:function logPurchase(b,c,d,e,f){a.getInstance().eCommerce.logPurchase(b,c,d,e,f);},logPromotion:function logPromotion(b,c,d,e,f){a.getInstance().eCommerce.logPromotion(b,c,d,e,f);},logImpression:function logImpression(b,c,d,e){a.getInstance().eCommerce.logImpression(b,c,d,e);},logRefund:function logRefund(b,c,d,e,f){a.getInstance().eCommerce.logRefund(b,c,d,e,f);},expandCommerceEvent:function expandCommerceEvent(b){return a.getInstance().eCommerce.expandCommerceEvent(b)}},this.setSessionAttribute=function(b,c){a.getInstance().setSessionAttribute(b,c);},this.setOptOut=function(b){a.getInstance().setOptOut(b);},this.setIntegrationAttribute=function(b,c){a.getInstance().setIntegrationAttribute(b,c);},this.getIntegrationAttributes=function(b){return a.getInstance().getIntegrationAttributes(b)},this.Identity={HTTPCodes:Constants.HTTPCodes,aliasUsers:function aliasUsers(b,c){a.getInstance().Identity.aliasUsers(b,c);},createAliasRequest:function createAliasRequest(b,c){return a.getInstance().Identity.createAliasRequest(b,c)},getCurrentUser:function getCurrentUser(){return a.getInstance().Identity.getCurrentUser()},getUser:function getUser(b){return a.getInstance().Identity.getUser(b)},getUsers:function getUsers(){return a.getInstance().Identity.getUsers()},identify:function identify(b,c){a.getInstance().Identity.identify(b,c);},login:function login(b,c){a.getInstance().Identity.login(b,c);},logout:function logout(b,c){a.getInstance().Identity.logout(b,c);},modify:function modify(b,c){a.getInstance().Identity.modify(b,c);}},this.sessionManager={getSession:function getSession(){return a.getInstance()._SessionManager.getSession()}},this.Consent={createConsentState:function createConsentState(){return a.getInstance().Consent.createConsentState()},createGDPRConsent:function createGDPRConsent(b,c,d,e,f){return a.getInstance().Consent.createGDPRConsent(b,c,d,e,f)},createCCPAConsent:function createCCPAConsent(b,c,d,e,f){return a.getInstance().Consent.createGDPRConsent(b,c,d,e,f)}},this.reset=function(){a.getInstance().reset(a.getInstance());},this._resetForTests=function(b,c){"boolean"==typeof c?a.getInstance()._resetForTests(b,c,a.getInstance()):a.getInstance()._resetForTests(b,!1,a.getInstance());},this.configurePixel=function(b){a.getInstance().configurePixel(b);},this._setIntegrationDelay=function(b,c){a.getInstance()._setIntegrationDelay(b,c);},this._getIntegrationDelays=function(){return a.getInstance()._getIntegrationDelays()},this.getVersion=function(){return a.getInstance().getVersion()},this.generateHash=function(b){return a.getInstance().generateHash(b)},this.addForwarder=function(b){a.getInstance().addForwarder(b);},this._getActiveForwarders=function(){return a.getInstance()._getActiveForwarders()},this._setWrapperSDKInfo=function(b,c){a.getInstance()._setWrapperSDKInfo(b,c);};}var mParticleManager=new mParticleInstanceManager;"undefined"!=typeof window&&(window.mParticle=mParticleManager,window.mParticle._BatchValidator=new _BatchValidator);
|
|
1754
1767
|
|
|
1755
1768
|
module.exports = mParticleManager;
|
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.34.0";
|
|
19
19
|
|
|
20
20
|
var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodIsDeprecatedPostfix:"is a deprecated method and will be removed in future releases",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",AddToCart:"addToCart",RemoveFromCart:"removeFromCart",ClearCart:"clearCart",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",localStorageProductsV4:"mprtcl-prodv4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4",currentStorageProductsName:"mprtcl-prodv4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,maxProducts:20,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
|
|
21
21
|
},DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},Base64CookieKeys:{csm:1,sa:1,ss:1,ua:1,ui:1,csd:1,ia:1,con:1},// https://go.mparticle.com/work/SQDSDKS-6039
|
|
@@ -127,7 +127,7 @@ var Messages$9=Constants.Messages,createCookieString=function(a){return replaceC
|
|
|
127
127
|
"".concat(1e7,"-").concat(1e3,"-").concat(4e3,"-").concat(8e3,"-").concat(1e11).replace(/[018]/g,// zeroes, ones, and eights with
|
|
128
128
|
generateUniqueId// random hex digits
|
|
129
129
|
)},getRampNumber=function(a){if(!a)return 100;var b=generateHash(a);return Math.abs(b%100)+1},isObject=function(a){var b=Object.prototype.toString.call(a);return "[object Object]"===b||"[object Error]"===b},parseNumber=function(a){if(isNaN(a)||!isFinite(a))return 0;var b=parseFloat(a);return isNaN(b)?0:b},parseStringOrNumber=function(a){return isStringOrNumber(a)?a:null},replaceCommasWithPipes=function(a){return a.replace(/,/g,"|")},replacePipesWithCommas=function(a){return a.replace(/\|/g,",")},replaceApostrophesWithQuotes=function(a){return a.replace(/\'/g,"\"")},replaceQuotesWithApostrophes=function(a){return a.replace(/\"/g,"'")},replaceMPID=function(a,b){return a.replace("%%mpid%%",b)},replaceAmpWithAmpersand=function(a){return a.replace(/&/g,"&")},createCookieSyncUrl=function(a,b,c){var d=replaceAmpWithAmpersand(b),e=c?replaceAmpWithAmpersand(c):null,f=replaceMPID(d,a),g=e?replaceMPID(e,a):"";return f+encodeURIComponent(g)},returnConvertedBoolean=function(a){return "false"!==a&&"0"!==a&&!!a},decoded=function(a){return decodeURIComponent(a.replace(/\+/g," "))},converted=function(a){return 0===a.indexOf("\"")&&(a=a.slice(1,-1).replace(/\\"/g,"\"").replace(/\\\\/g,"\\")),a},isString=function(a){return "string"==typeof a},isNumber=function(a){return "number"==typeof a},isBoolean=function(a){return "boolean"==typeof a},isFunction=function(a){return "function"==typeof a},isValidCustomFlagProperty=function(a){return isNumber(a)||isString(a)||isBoolean(a)},toDataPlanSlug=function(a){// Make sure we are only acting on strings or numbers
|
|
130
|
-
return isStringOrNumber(a)?a.toString().toLowerCase().replace(/[^0-9a-zA-Z]+/g,"_"):""},isDataPlanSlug=function(a){return a===toDataPlanSlug(a)},isStringOrNumber=function(a){return isString(a)||isNumber(a)},isEmpty=function(a){return null==a||!(Object.keys(a)||a).length},moveElementToEnd=function(a,b){return a.slice(0,b).concat(a.slice(b+1),a[b])},queryStringParser=function(a,b){void 0===b&&(b=[]);var c,d={};if(!a)return d;if("undefined"!=typeof URL&&"undefined"!=typeof URLSearchParams){var e=new URL(a);c=new URLSearchParams(e.search);}else c=queryStringParserFallback(a);return isEmpty(b)?c.forEach(function(a,b){d[b]=a;}):b.forEach(function(a){var b=c.get(a);b&&(d[a]=b);}),d},queryStringParserFallback=function(a){var b={},c=a.split("?")[1]||"",d=c.split("&");return d.forEach(function(a){var c=a.split("="),d=c[0],e=c
|
|
130
|
+
return isStringOrNumber(a)?a.toString().toLowerCase().replace(/[^0-9a-zA-Z]+/g,"_"):""},isDataPlanSlug=function(a){return a===toDataPlanSlug(a)},isStringOrNumber=function(a){return isString(a)||isNumber(a)},isEmpty=function(a){return null==a||!(Object.keys(a)||a).length},moveElementToEnd=function(a,b){return a.slice(0,b).concat(a.slice(b+1),a[b])},queryStringParser=function(a,b){void 0===b&&(b=[]);var c,d={};if(!a)return d;if("undefined"!=typeof URL&&"undefined"!=typeof URLSearchParams){var e=new URL(a);c=new URLSearchParams(e.search);}else c=queryStringParserFallback(a);return isEmpty(b)?c.forEach(function(a,b){d[b]=a;}):b.forEach(function(a){var b=c.get(a);b&&(d[a]=b);}),d},queryStringParserFallback=function(a){var b={},c=a.split("?")[1]||"",d=c.split("&");return d.forEach(function(a){var c=a.split("="),d=c[0],e=c.slice(1),f=e.join("=");if(d&&void 0!==f)try{b[d]=decodeURIComponent(f||"");}catch(a){console.error("Failed to decode value for key ".concat(d,": ").concat(a));}}),{get:function get(a){return b[a]},forEach:function forEach(a){for(var c in b)b.hasOwnProperty(c)&&a(b[c],c);}}},getCookies=function(a){// Helper function to parse cookies from document.cookie
|
|
131
131
|
var b=function parseCookies(){return "undefined"==typeof window?[]:window.document.cookie.split(";").map(function(a){return a.trim()})}();// Helper function to filter cookies by keys
|
|
132
132
|
// Parse cookies from document.cookie
|
|
133
133
|
// Filter cookies by keys if provided
|
|
@@ -515,7 +515,7 @@ this.convertTransactionAttributesToProductAction=function(a,b){a.hasOwnProperty(
|
|
|
515
515
|
return (a.Logger.verbose(Messages$5.InformationMessages.StartingLogCommerceEvent),a._Helpers.canLog())?(d=a._ServerModel.createEventObject({messageType:Types.MessageType.Commerce,sourceMessageId:null===c||void 0===c?void 0:c.sourceMessageId}),d.EventName="eCommerce - ",d.CurrencyCode=a._Store.currencyCode,d.ShoppingCart=[],d.CustomFlags=e(d.CustomFlags,b),d):(a.Logger.verbose(Messages$5.InformationMessages.AbandonLogEvent),null)},this.sanitizeAmount=function(b,c){if(!a._Helpers.Validators.isStringOrNumber(b)){var d=[c,"must be of type number. A",_typeof$1(b),"was passed. Converting to 0"].join(" ");return a.Logger.warning(d),0}// if amount is a string, it will be parsed into a number if possible, or set to 0
|
|
516
516
|
return a._Helpers.parseNumber(b)};}
|
|
517
517
|
|
|
518
|
-
var ForegroundTimeTracker=/** @class */function(){function a(a){this.isTrackerActive=!1,this.localStorageName="",this.startTime=0,this.totalTime=0,this.localStorageName="
|
|
518
|
+
var ForegroundTimeTracker=/** @class */function(){function a(a){this.isTrackerActive=!1,this.localStorageName="",this.startTime=0,this.totalTime=0,this.localStorageName="mprtcl-tos-".concat(a),this.timerVault=new LocalStorageVault(this.localStorageName),this.loadTimeFromStorage(),this.addHandlers(),!1===document.hidden&&this.startTracking();}return a.prototype.addHandlers=function(){var a=this;// when user switches tabs or minimizes the window
|
|
519
519
|
document.addEventListener("visibilitychange",function(){return a.handleVisibilityChange()}),window.addEventListener("blur",function(){return a.handleWindowBlur()}),window.addEventListener("focus",function(){return a.handleWindowFocus()}),window.addEventListener("storage",function(b){return a.syncAcrossTabs(b)}),window.addEventListener("beforeunload",function(){return a.updateTimeInPersistence()});},a.prototype.handleVisibilityChange=function(){document.hidden?this.stopTracking():this.startTracking();},a.prototype.handleWindowBlur=function(){this.isTrackerActive&&this.stopTracking();},a.prototype.handleWindowFocus=function(){this.isTrackerActive||this.startTracking();},a.prototype.syncAcrossTabs=function(a){if(a.key===this.localStorageName&&null!==a.newValue){var b=parseFloat(a.newValue)||0;this.totalTime=b;}},a.prototype.updateTimeInPersistence=function(){this.isTrackerActive&&this.timerVault.store(Math.round(this.totalTime));},a.prototype.loadTimeFromStorage=function(){var a=this.timerVault.retrieve();isNumber(a)&&null!==a&&(this.totalTime=a);},a.prototype.startTracking=function(){document.hidden||(this.startTime=Math.floor(performance.now()),this.isTrackerActive=!0);},a.prototype.stopTracking=function(){this.isTrackerActive&&(this.setTotalTime(),this.updateTimeInPersistence(),this.isTrackerActive=!1);},a.prototype.setTotalTime=function(){if(this.isTrackerActive){var a=Math.floor(performance.now());this.totalTime+=a-this.startTime,this.startTime=a;}},a.prototype.getTimeInForeground=function(){return this.setTotalTime(),this.updateTimeInPersistence(),this.totalTime},a.prototype.resetTimer=function(){this.totalTime=0,this.updateTimeInPersistence();},a}();
|
|
520
520
|
|
|
521
521
|
function createSDKConfig(a){// TODO: Refactor to create a default config object
|
|
@@ -1046,12 +1046,12 @@ this.appendUserInfo=function(b,c){if(c){if(!b)return c.MPID=null,c.ConsentState=
|
|
|
1046
1046
|
// tracked. If this is an `optOut` Event, we set `optOut` to the inverse of the SDK's
|
|
1047
1047
|
// `isEnabled` boolean which is controlled via `MPInstanceManager.setOptOut`.
|
|
1048
1048
|
// TODO: Why is Webview Bridge Enabled or Opt Out necessary here?
|
|
1049
|
-
if(a._Store.sessionId||c.messageType===Types.MessageType.OptOut||a._Store.webviewBridgeEnabled){var i=__assign({},c.customFlags);// https://go.mparticle.com/work/SQDSDKS-5053
|
|
1050
|
-
if(a._Helpers.getFeatureFlag&&a._Helpers.getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIds)){a._IntegrationCapture.capture();var
|
|
1049
|
+
if(a._Store.sessionId||c.messageType===Types.MessageType.OptOut||a._Store.webviewBridgeEnabled){var i=__assign({},c.customFlags),j=a._Store.integrationAttributes;// https://go.mparticle.com/work/SQDSDKS-5053
|
|
1050
|
+
if(a._Helpers.getFeatureFlag&&a._Helpers.getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIds)){a._IntegrationCapture.capture();var k=a._IntegrationCapture.getClickIdsAsCustomFlags();i=__assign(__assign({},k),i);var l=a._IntegrationCapture.getClickIdsAsIntegrationAttributes();j=__assign(__assign({},l),j);}g=c.hasOwnProperty("toEventAPIObject")?c.toEventAPIObject():{// This is an artifact from v2 events where SessionStart/End and AST event
|
|
1051
1051
|
// names are numbers (1, 2, or 10), but going forward with v3, these lifecycle
|
|
1052
1052
|
// events do not have names, but are denoted by their `event_type`
|
|
1053
1053
|
EventName:c.name||c.messageType,EventCategory:c.eventType,EventAttributes:a._Helpers.sanitizeAttributes(c.data,c.name),ActiveTimeOnSite:null===(e=a._timeOnSiteTimer)||void 0===e?void 0:e.getTimeInForeground(),SourceMessageId:c.sourceMessageId||a._Helpers.generateUniqueId(),EventDataType:c.messageType,CustomFlags:i,UserAttributeChanges:c.userAttributeChanges,UserIdentityChanges:c.userIdentityChanges},c.messageType!==Types.MessageType.SessionEnd&&(a._Store.dateLastEventSent=new Date),f={// FIXME: Deprecate when we get rid of V2
|
|
1054
|
-
Store:a._Store.serverSettings,SDKVersion:Constants.sdkVersion,SessionId:a._Store.sessionId,SessionStartDate:a._Store.sessionStartDate?a._Store.sessionStartDate.getTime():0,Debug:a._Store.SDKConfig.isDevelopmentMode,Location:a._Store.currentPosition,OptOut:h,ExpandedEventCount:0,AppVersion:a.getAppVersion(),AppName:a.getAppName(),Package:a._Store.SDKConfig["package"],ClientGeneratedId:a._Store.clientId,DeviceId:a._Store.deviceId,IntegrationAttributes:
|
|
1054
|
+
Store:a._Store.serverSettings,SDKVersion:Constants.sdkVersion,SessionId:a._Store.sessionId,SessionStartDate:a._Store.sessionStartDate?a._Store.sessionStartDate.getTime():0,Debug:a._Store.SDKConfig.isDevelopmentMode,Location:a._Store.currentPosition,OptOut:h,ExpandedEventCount:0,AppVersion:a.getAppVersion(),AppName:a.getAppName(),Package:a._Store.SDKConfig["package"],ClientGeneratedId:a._Store.clientId,DeviceId:a._Store.deviceId,IntegrationAttributes:j,CurrencyCode:a._Store.currencyCode,DataPlan:a._Store.SDKConfig.dataPlan?a._Store.SDKConfig.dataPlan:{}},g.EventDataType===MessageType.AppStateTransition&&(g.IsFirstRun=a._Store.isFirstRun,g.LaunchReferral=window.location.href||null),g.CurrencyCode=a._Store.currencyCode;var m=d||a.Identity.getCurrentUser();return b.appendUserInfo(m,g),c.messageType===Types.MessageType.SessionEnd&&(g.SessionLength=a._Store.dateLastEventSent.getTime()-a._Store.sessionStartDate.getTime(),g.currentSessionMPIDs=a._Store.currentSessionMPIDs,g.EventAttributes=a._Store.sessionAttributes,a._Store.currentSessionMPIDs=[],a._Store.sessionStartDate=null),f.Timestamp=a._Store.dateLastEventSent.getTime(),a._Helpers.extend({},g,f)}return null},this.convertEventToV2DTO=function(c){var d={n:c.EventName,et:c.EventCategory,ua:c.UserAttributes,ui:c.UserIdentities,ia:c.IntegrationAttributes,str:c.Store,attrs:c.EventAttributes,sdk:c.SDKVersion,sid:c.SessionId,sl:c.SessionLength,ssd:c.SessionStartDate,dt:c.EventDataType,dbg:c.Debug,ct:c.Timestamp,lc:c.Location,o:c.OptOut,eec:c.ExpandedEventCount,av:c.AppVersion,cgid:c.ClientGeneratedId,das:c.DeviceId,mpid:c.MPID,smpids:c.currentSessionMPIDs};c.DataPlan&&c.DataPlan.PlanId&&(d.dp_id=c.DataPlan.PlanId,c.DataPlan.PlanVersion&&(d.dp_v=c.DataPlan.PlanVersion));var e=b.convertToConsentStateV2DTO(c.ConsentState);return e&&(d.con=e),c.EventDataType===MessageType.AppStateTransition&&(d.fr=c.IsFirstRun,d.iu=!1,d.at=ApplicationTransitionType.AppInit,d.lr=c.LaunchReferral,d.attrs=null),c.CustomFlags&&convertCustomFlags(c,d),c.EventDataType===MessageType.Commerce?(d.cu=c.CurrencyCode,c.ShoppingCart&&(d.sc={pl:convertProductListToV2DTO(c.ShoppingCart.ProductList)}),c.ProductAction?d.pd={an:c.ProductAction.ProductActionType,cs:a._Helpers.parseNumber(c.ProductAction.CheckoutStep),co:c.ProductAction.CheckoutOptions,pl:convertProductListToV2DTO(c.ProductAction.ProductList),ti:c.ProductAction.TransactionId,ta:c.ProductAction.Affiliation,tcc:c.ProductAction.CouponCode,tr:a._Helpers.parseNumber(c.ProductAction.TotalAmount),ts:a._Helpers.parseNumber(c.ProductAction.ShippingAmount),tt:a._Helpers.parseNumber(c.ProductAction.TaxAmount)}:c.PromotionAction?d.pm={an:c.PromotionAction.PromotionActionType,pl:c.PromotionAction.PromotionList.map(function(a){return {id:a.Id,nm:a.Name,cr:a.Creative,ps:a.Position?a.Position:0}})}:c.ProductImpressions&&(d.pi=c.ProductImpressions.map(function(a){return {pil:a.ProductImpressionList,pl:convertProductListToV2DTO(a.ProductList)}}))):c.EventDataType===MessageType.Profile&&(d.pet=c.ProfileMessageType),d};}
|
|
1055
1055
|
|
|
1056
1056
|
function forwardingStatsUploader(a){function b(){var b=a._Forwarders.getForwarderStatsQueue(),c=a._Persistence.forwardingStatsBatches.uploadsTable,d=Date.now();for(var e in b.length&&(c[d]={uploading:!1,data:b},a._Forwarders.setForwarderStatsQueue([])),c)(function(b){if(c.hasOwnProperty(b)&&!1===c[b].uploading){var d=function(){4===e.readyState&&(200===e.status||202===e.status?(a.Logger.verbose("Successfully sent "+e.statusText+" from server"),delete c[b]):"4"===e.status.toString()[0]?429!==e.status&&delete c[b]:c[b].uploading=!1);},e=a._Helpers.createXHR(d),f=c[b].data;c[b].uploading=!0,a._APIClient.sendBatchForwardingStatsToServer(f,e);}})(e);}this.startForwardingStatsTimer=function(){mParticle._forwardingStatsTimer=setInterval(function(){b();},a._Store.SDKConfig.forwarderStatsTimeout);};}
|
|
1057
1057
|
|
|
@@ -1378,12 +1378,25 @@ var facebookClickIdProcessor=function(a,b,c){if(!a||!b)return "";var d=null===b|
|
|
|
1378
1378
|
var h=c||Date.now();return "fb.".concat(g,".").concat(h,".").concat(a)};// Integration outputs are used to determine how click ids are used within the SDK
|
|
1379
1379
|
// CUSTOM_FLAGS are sent out when an Event is created via ServerModel.createEventObject
|
|
1380
1380
|
// PARTNER_IDENTITIES are sent out in a Batch when a group of events are converted to a Batch
|
|
1381
|
-
|
|
1381
|
+
// INTEGRATION_ATTRIBUTES are stored initially on the SDKEvent level but then is added to the Batch when the batch is created
|
|
1382
|
+
var IntegrationOutputs={CUSTOM_FLAGS:"custom_flags",PARTNER_IDENTITIES:"partner_identities",INTEGRATION_ATTRIBUTES:"integration_attributes"},integrationMapping={// Facebook / Meta
|
|
1382
1383
|
fbclid:{mappedKey:"Facebook.ClickId",processor:facebookClickIdProcessor,output:IntegrationOutputs.CUSTOM_FLAGS},_fbp:{mappedKey:"Facebook.BrowserId",output:IntegrationOutputs.CUSTOM_FLAGS},_fbc:{mappedKey:"Facebook.ClickId",output:IntegrationOutputs.CUSTOM_FLAGS},// Google
|
|
1383
|
-
gclid:{mappedKey:"GoogleEnhancedConversions.Gclid",output:IntegrationOutputs.CUSTOM_FLAGS},gbraid:{mappedKey:"GoogleEnhancedConversions.Gbraid",output:IntegrationOutputs.CUSTOM_FLAGS},wbraid:{mappedKey:"GoogleEnhancedConversions.Wbraid",output:IntegrationOutputs.CUSTOM_FLAGS},//
|
|
1384
|
-
|
|
1384
|
+
gclid:{mappedKey:"GoogleEnhancedConversions.Gclid",output:IntegrationOutputs.CUSTOM_FLAGS},gbraid:{mappedKey:"GoogleEnhancedConversions.Gbraid",output:IntegrationOutputs.CUSTOM_FLAGS},wbraid:{mappedKey:"GoogleEnhancedConversions.Wbraid",output:IntegrationOutputs.CUSTOM_FLAGS},// Rokt
|
|
1385
|
+
// https://docs.rokt.com/developers/integration-guides/web/advanced/rokt-id-tag/
|
|
1386
|
+
rtid:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},RoktTransactionId:{mappedKey:"passbackconversiontrackingid",output:IntegrationOutputs.INTEGRATION_ATTRIBUTES,moduleId:1277},// TIKTOK
|
|
1387
|
+
ttclid:{mappedKey:"TikTok.Callback",output:IntegrationOutputs.CUSTOM_FLAGS},_ttp:{mappedKey:"tiktok_cookie_id",output:IntegrationOutputs.PARTNER_IDENTITIES}},IntegrationCapture=/** @class */function(){function a(){this.initialTimestamp=Date.now(),this.filteredPartnerIdentityMappings=this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES),this.filteredCustomFlagMappings=this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS),this.filteredIntegrationAttributeMappings=this.filterMappings(IntegrationOutputs.INTEGRATION_ATTRIBUTES);}/**
|
|
1385
1388
|
* Captures Integration Ids from cookies and query params and stores them in clickIds object
|
|
1386
|
-
*/return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{};a.fbclid&&b._fbc&&delete b._fbc,this.clickIds=__assign(__assign(__assign({},this.clickIds),a),b);},a.prototype.captureCookies=function(){var a=getCookies(Object.keys(integrationMapping));return this.applyProcessors(a)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.getQueryParams=function(){return queryStringParser(getHref(),Object.keys(integrationMapping))},a.prototype.getClickIdsAsCustomFlags=function(){return this.getClickIds(this.clickIds,this.filteredCustomFlagMappings)},a.prototype.getClickIdsAsPartnerIdentities=function(){return this.getClickIds(this.clickIds,this.filteredPartnerIdentityMappings)},a.prototype.
|
|
1389
|
+
*/return a.prototype.capture=function(){var a=this.captureQueryParams()||{},b=this.captureCookies()||{},c=this.captureLocalStorage()||{};a.fbclid&&b._fbc&&delete b._fbc,a.rtid&&c.RoktTransactionId&&b.RoktTransactionId?(delete c.RoktTransactionId,delete b.RoktTransactionId):a.rtid&&c.RoktTransactionId?delete c.RoktTransactionId:a.rtid&&b.RoktTransactionId?delete b.RoktTransactionId:c.RoktTransactionId&&b.RoktTransactionId&&delete b.RoktTransactionId,this.clickIds=__assign(__assign(__assign(__assign({},this.clickIds),a),c),b);},a.prototype.captureCookies=function(){var a=getCookies(Object.keys(integrationMapping));return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureQueryParams=function(){var a=this.getQueryParams();return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.captureLocalStorage=function(){var a={};for(var b in integrationMapping){var c=localStorage.getItem(b);c&&(a[b]=c);}return this.applyProcessors(a,getHref(),this.initialTimestamp)},a.prototype.getQueryParams=function(){return queryStringParser(getHref(),Object.keys(integrationMapping))},a.prototype.getClickIdsAsCustomFlags=function(){return this.getClickIds(this.clickIds,this.filteredCustomFlagMappings)},a.prototype.getClickIdsAsPartnerIdentities=function(){return this.getClickIds(this.clickIds,this.filteredPartnerIdentityMappings)},a.prototype.getClickIdsAsIntegrationAttributes=function(){var a,b,c,d={};// Integration IDs are stored in the following format:
|
|
1390
|
+
// {
|
|
1391
|
+
// "integration_attributes": {
|
|
1392
|
+
// "<moduleId>": {
|
|
1393
|
+
// "mappedKey": "clickIdValue"
|
|
1394
|
+
// }
|
|
1395
|
+
// }
|
|
1396
|
+
// }
|
|
1397
|
+
for(var e in this.clickIds)if(this.clickIds.hasOwnProperty(e)){var f=this.clickIds[e],g=null===(b=this.filteredIntegrationAttributeMappings[e])||void 0===b?void 0:b.mappedKey;if(!isEmpty(g)){var h=null===(c=this.filteredIntegrationAttributeMappings[e])||void 0===c?void 0:c.moduleId;h&&!d[h]&&(d[h]=(a={},a[g]=f,a));}}return d},a.prototype.getClickIds=function(a,b){var c,d={};if(!a)return d;for(var e in a)if(a.hasOwnProperty(e)){var f=a[e],g=null===(c=b[e])||void 0===c?void 0:c.mappedKey;isEmpty(g)||(d[g]=f);}return d},a.prototype.applyProcessors=function(a,b,c){var d,e={};for(var f in a)if(a.hasOwnProperty(f)){var g=a[f],h=null===(d=integrationMapping[f])||void 0===d?void 0:d.processor;e[f]=h?h(g,b,c):g;}return e},a.prototype.filterMappings=function(a){var b={};for(var c in integrationMapping)integrationMapping[c].output===a&&(b[c]=integrationMapping[c]);return b},a}();
|
|
1398
|
+
|
|
1399
|
+
var RoktManager=/** @class */function(){function a(){this.launcher=null,this.messageQueue=[],this.launcher=null;}return a.prototype.attachLauncher=function(a){this.setLauncher(a),this.processMessageQueue();},a.prototype.selectPlacements=function(a){if(!this.launcher)return this.queueMessage({methodName:"selectPlacements",payload:a}),Promise.resolve({});try{return this.launcher.selectPlacements(a)}catch(a){return Promise.reject(a instanceof Error?a:new Error("Unknown error occurred"))}},a.prototype.processMessageQueue=function(){var a=this;0<this.messageQueue.length&&(this.messageQueue.forEach(function(b){return __awaiter(a,void 0,void 0,function(){return __generator(this,function(a){switch(a.label){case 0:return this.launcher&&b.methodName in this.launcher?[4/*yield*/,this.launcher[b.methodName](b.payload)]:[3/*break*/,2];case 1:a.sent(),a.label=2;case 2:return [2/*return*/]}})})}),this.messageQueue=[]);},a.prototype.queueMessage=function(a){this.messageQueue.push(a);},a.prototype.setLauncher=function(a){this.launcher=a;},a}();
|
|
1387
1400
|
|
|
1388
1401
|
var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
|
|
1389
1402
|
* <p>All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced <a href="https://docs.mparticle.com/developers/sdk/web/multiple-instances/">multiple instances</a>. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.</p>
|
|
@@ -1559,7 +1572,7 @@ var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Const
|
|
|
1559
1572
|
If there is no delay, then the events sent before an integration attribute is included would not
|
|
1560
1573
|
be forwarded successfully server side.
|
|
1561
1574
|
*/ // Internal use only. Used by our wrapper SDKs to identify themselves during initialization.
|
|
1562
|
-
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._IntegrationCapture=new IntegrationCapture,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
|
|
1575
|
+
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._IntegrationCapture=new IntegrationCapture,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
|
|
1563
1576
|
// Since fetching the configuration is asynchronous, we must pass completeSDKInitialization
|
|
1564
1577
|
// to it for it to be run after fetched
|
|
1565
1578
|
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._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()&&"function"==typeof a?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
|
|
@@ -1750,6 +1763,6 @@ Array.prototype.forEach||(Array.prototype.forEach=Polyfill.forEach),Array.protot
|
|
|
1750
1763
|
* @param {String} apiKey your mParticle assigned API key
|
|
1751
1764
|
* @param {Object} [config] an options object for additional configuration
|
|
1752
1765
|
* @param {String} [instanceName] If you are self hosting the JS SDK and working with multiple instances, you would pass an instanceName to `init`. This instance will be selected when invoking other methods. See the above link to the doc site for more info and examples.
|
|
1753
|
-
*/this.Store={},this._instances={},this.IdentityType=
|
|
1766
|
+
*/this.Store={},this._instances={},this.IdentityType=IdentityType,this.EventType=EventType,this.CommerceEventType=CommerceEventType,this.PromotionType=PromotionActionType,this.ProductActionType=ProductActionType,this.MPSideloadedKit=MPSideloadedKit,"undefined"!=typeof window&&(this.isIOS=!!(window.mParticle&&window.mParticle.isIOS)&&window.mParticle.isIOS,this.config=window.mParticle&&window.mParticle.config?window.mParticle.config:{}),this.init=function(b,c,d){!c&&window.mParticle&&window.mParticle.config&&(console.warn("You did not pass a config object to mParticle.init(). Attempting to use the window.mParticle.config if it exists. Please note that in a future release, this may not work and mParticle will not initialize properly"),c=window.mParticle?window.mParticle.config:{}),d=(d&&0!==d.length?d:Constants.DefaultInstance).toLowerCase();var e=a._instances[d];e===void 0&&(e=new mParticleInstance(d),a._instances[d]=e),e.init(b,c,d);},this.getInstance=function(b){var c;return b?(c=a._instances[b.toLowerCase()],c?c:(console.log("You tried to initialize an instance named "+b+". This instance does not exist. Check your instance name or initialize a new instance with this name before calling it."),null)):(b=Constants.DefaultInstance,c=a._instances[b],c||(c=new mParticleInstance(b),a._instances[Constants.DefaultInstance]=c),c)},this.Rokt=a.getInstance()._RoktManager,this.getDeviceId=function(){return a.getInstance().getDeviceId()},this.setDeviceId=function(b){return a.getInstance().setDeviceId(b)},this.isInitialized=function(){return a.getInstance().isInitialized()},this.startNewSession=function(){a.getInstance().startNewSession();},this.endSession=function(){a.getInstance().endSession();},this.setLogLevel=function(b){a.getInstance().setLogLevel(b);},this.ready=function(b){a.getInstance().ready(b);},this.setAppVersion=function(b){a.getInstance().setAppVersion(b);},this.getAppName=function(){return a.getInstance().getAppName()},this.setAppName=function(b){a.getInstance().setAppName(b);},this.getAppVersion=function(){return a.getInstance().getAppVersion()},this.getEnvironment=function(){return a.getInstance().getEnvironment()},this.stopTrackingLocation=function(){a.getInstance().stopTrackingLocation();},this.startTrackingLocation=function(b){a.getInstance().startTrackingLocation(b);},this.setPosition=function(b,c){a.getInstance().setPosition(b,c);},this.startNewSession=function(){a.getInstance().startNewSession();},this.endSession=function(){a.getInstance().endSession();},this.logBaseEvent=function(b,c){a.getInstance().logBaseEvent(b,c);},this.logEvent=function(b,c,d,e,f){a.getInstance().logEvent(b,c,d,e,f);},this.logError=function(b,c){a.getInstance().logError(b,c);},this.logLink=function(b,c,d,e){a.getInstance().logLink(b,c,d,e);},this.logForm=function(b,c,d,e){a.getInstance().logForm(b,c,d,e);},this.logPageView=function(b,c,d,e){a.getInstance().logPageView(b,c,d,e);},this.upload=function(){a.getInstance().upload();},this.eCommerce={Cart:{add:function add(b,c){a.getInstance().eCommerce.Cart.add(b,c);},remove:function remove(b,c){a.getInstance().eCommerce.Cart.remove(b,c);},clear:function clear(){a.getInstance().eCommerce.Cart.clear();}},setCurrencyCode:function setCurrencyCode(b){a.getInstance().eCommerce.setCurrencyCode(b);},createProduct:function createProduct(b,c,d,e,f,g,h,i,j,k){return a.getInstance().eCommerce.createProduct(b,c,d,e,f,g,h,i,j,k)},createPromotion:function createPromotion(b,c,d,e){return a.getInstance().eCommerce.createPromotion(b,c,d,e)},createImpression:function createImpression(b,c){return a.getInstance().eCommerce.createImpression(b,c)},createTransactionAttributes:function createTransactionAttributes(b,c,d,e,f,g){return a.getInstance().eCommerce.createTransactionAttributes(b,c,d,e,f,g)},logCheckout:function logCheckout(b,c,d,e){a.getInstance().eCommerce.logCheckout(b,c,d,e);},logProductAction:function logProductAction(b,c,d,e,f,g){a.getInstance().eCommerce.logProductAction(b,c,d,e,f,g);},logPurchase:function logPurchase(b,c,d,e,f){a.getInstance().eCommerce.logPurchase(b,c,d,e,f);},logPromotion:function logPromotion(b,c,d,e,f){a.getInstance().eCommerce.logPromotion(b,c,d,e,f);},logImpression:function logImpression(b,c,d,e){a.getInstance().eCommerce.logImpression(b,c,d,e);},logRefund:function logRefund(b,c,d,e,f){a.getInstance().eCommerce.logRefund(b,c,d,e,f);},expandCommerceEvent:function expandCommerceEvent(b){return a.getInstance().eCommerce.expandCommerceEvent(b)}},this.setSessionAttribute=function(b,c){a.getInstance().setSessionAttribute(b,c);},this.setOptOut=function(b){a.getInstance().setOptOut(b);},this.setIntegrationAttribute=function(b,c){a.getInstance().setIntegrationAttribute(b,c);},this.getIntegrationAttributes=function(b){return a.getInstance().getIntegrationAttributes(b)},this.Identity={HTTPCodes:Constants.HTTPCodes,aliasUsers:function aliasUsers(b,c){a.getInstance().Identity.aliasUsers(b,c);},createAliasRequest:function createAliasRequest(b,c){return a.getInstance().Identity.createAliasRequest(b,c)},getCurrentUser:function getCurrentUser(){return a.getInstance().Identity.getCurrentUser()},getUser:function getUser(b){return a.getInstance().Identity.getUser(b)},getUsers:function getUsers(){return a.getInstance().Identity.getUsers()},identify:function identify(b,c){a.getInstance().Identity.identify(b,c);},login:function login(b,c){a.getInstance().Identity.login(b,c);},logout:function logout(b,c){a.getInstance().Identity.logout(b,c);},modify:function modify(b,c){a.getInstance().Identity.modify(b,c);}},this.sessionManager={getSession:function getSession(){return a.getInstance()._SessionManager.getSession()}},this.Consent={createConsentState:function createConsentState(){return a.getInstance().Consent.createConsentState()},createGDPRConsent:function createGDPRConsent(b,c,d,e,f){return a.getInstance().Consent.createGDPRConsent(b,c,d,e,f)},createCCPAConsent:function createCCPAConsent(b,c,d,e,f){return a.getInstance().Consent.createGDPRConsent(b,c,d,e,f)}},this.reset=function(){a.getInstance().reset(a.getInstance());},this._resetForTests=function(b,c){"boolean"==typeof c?a.getInstance()._resetForTests(b,c,a.getInstance()):a.getInstance()._resetForTests(b,!1,a.getInstance());},this.configurePixel=function(b){a.getInstance().configurePixel(b);},this._setIntegrationDelay=function(b,c){a.getInstance()._setIntegrationDelay(b,c);},this._getIntegrationDelays=function(){return a.getInstance()._getIntegrationDelays()},this.getVersion=function(){return a.getInstance().getVersion()},this.generateHash=function(b){return a.getInstance().generateHash(b)},this.addForwarder=function(b){a.getInstance().addForwarder(b);},this._getActiveForwarders=function(){return a.getInstance()._getActiveForwarders()},this._setWrapperSDKInfo=function(b,c){a.getInstance()._setWrapperSDKInfo(b,c);};}var mParticleManager=new mParticleInstanceManager;"undefined"!=typeof window&&(window.mParticle=mParticleManager,window.mParticle._BatchValidator=new _BatchValidator);
|
|
1754
1767
|
|
|
1755
1768
|
export { mParticleManager as default };
|
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.34.0";
|
|
207
207
|
|
|
208
208
|
var Constants = {
|
|
209
209
|
sdkVersion: version,
|
|
@@ -713,9 +713,14 @@ var mParticle = (function () {
|
|
|
713
713
|
pairs.forEach(function (pair) {
|
|
714
714
|
var _a = pair.split('='),
|
|
715
715
|
key = _a[0],
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
716
|
+
valueParts = _a.slice(1);
|
|
717
|
+
var value = valueParts.join('=');
|
|
718
|
+
if (key && value !== undefined) {
|
|
719
|
+
try {
|
|
720
|
+
params[key] = decodeURIComponent(value || '');
|
|
721
|
+
} catch (e) {
|
|
722
|
+
console.error("Failed to decode value for key ".concat(key, ": ").concat(e));
|
|
723
|
+
}
|
|
719
724
|
}
|
|
720
725
|
});
|
|
721
726
|
return {
|
|
@@ -3883,7 +3888,7 @@ var mParticle = (function () {
|
|
|
3883
3888
|
this.localStorageName = '';
|
|
3884
3889
|
this.startTime = 0;
|
|
3885
3890
|
this.totalTime = 0;
|
|
3886
|
-
this.localStorageName = "
|
|
3891
|
+
this.localStorageName = "mprtcl-tos-".concat(timerKey);
|
|
3887
3892
|
this.timerVault = new LocalStorageVault(this.localStorageName);
|
|
3888
3893
|
this.loadTimeFromStorage();
|
|
3889
3894
|
this.addHandlers();
|
|
@@ -6649,6 +6654,7 @@ var mParticle = (function () {
|
|
|
6649
6654
|
// TODO: Why is Webview Bridge Enabled or Opt Out necessary here?
|
|
6650
6655
|
if (mpInstance._Store.sessionId || event.messageType === Types.MessageType.OptOut || mpInstance._Store.webviewBridgeEnabled) {
|
|
6651
6656
|
var customFlags = __assign({}, event.customFlags);
|
|
6657
|
+
var integrationAttributes = mpInstance._Store.integrationAttributes;
|
|
6652
6658
|
// https://go.mparticle.com/work/SQDSDKS-5053
|
|
6653
6659
|
if (mpInstance._Helpers.getFeatureFlag && mpInstance._Helpers.getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIds)) {
|
|
6654
6660
|
// Attempt to recapture click IDs in case a third party integration
|
|
@@ -6656,6 +6662,8 @@ var mParticle = (function () {
|
|
|
6656
6662
|
mpInstance._IntegrationCapture.capture();
|
|
6657
6663
|
var transformedClickIDs = mpInstance._IntegrationCapture.getClickIdsAsCustomFlags();
|
|
6658
6664
|
customFlags = __assign(__assign({}, transformedClickIDs), customFlags);
|
|
6665
|
+
var transformedIntegrationAttributes = mpInstance._IntegrationCapture.getClickIdsAsIntegrationAttributes();
|
|
6666
|
+
integrationAttributes = __assign(__assign({}, transformedIntegrationAttributes), integrationAttributes);
|
|
6659
6667
|
}
|
|
6660
6668
|
if (event.hasOwnProperty('toEventAPIObject')) {
|
|
6661
6669
|
eventObject = event.toEventAPIObject();
|
|
@@ -6694,7 +6702,7 @@ var mParticle = (function () {
|
|
|
6694
6702
|
Package: mpInstance._Store.SDKConfig["package"],
|
|
6695
6703
|
ClientGeneratedId: mpInstance._Store.clientId,
|
|
6696
6704
|
DeviceId: mpInstance._Store.deviceId,
|
|
6697
|
-
IntegrationAttributes:
|
|
6705
|
+
IntegrationAttributes: integrationAttributes,
|
|
6698
6706
|
CurrencyCode: mpInstance._Store.currencyCode,
|
|
6699
6707
|
DataPlan: mpInstance._Store.SDKConfig.dataPlan ? mpInstance._Store.SDKConfig.dataPlan : {}
|
|
6700
6708
|
};
|
|
@@ -9312,9 +9320,11 @@ var mParticle = (function () {
|
|
|
9312
9320
|
// Integration outputs are used to determine how click ids are used within the SDK
|
|
9313
9321
|
// CUSTOM_FLAGS are sent out when an Event is created via ServerModel.createEventObject
|
|
9314
9322
|
// PARTNER_IDENTITIES are sent out in a Batch when a group of events are converted to a Batch
|
|
9323
|
+
// INTEGRATION_ATTRIBUTES are stored initially on the SDKEvent level but then is added to the Batch when the batch is created
|
|
9315
9324
|
var IntegrationOutputs = {
|
|
9316
9325
|
CUSTOM_FLAGS: 'custom_flags',
|
|
9317
|
-
PARTNER_IDENTITIES: 'partner_identities'
|
|
9326
|
+
PARTNER_IDENTITIES: 'partner_identities',
|
|
9327
|
+
INTEGRATION_ATTRIBUTES: 'integration_attributes'
|
|
9318
9328
|
};
|
|
9319
9329
|
var integrationMapping = {
|
|
9320
9330
|
// Facebook / Meta
|
|
@@ -9344,6 +9354,18 @@ var mParticle = (function () {
|
|
|
9344
9354
|
mappedKey: 'GoogleEnhancedConversions.Wbraid',
|
|
9345
9355
|
output: IntegrationOutputs.CUSTOM_FLAGS
|
|
9346
9356
|
},
|
|
9357
|
+
// Rokt
|
|
9358
|
+
// https://docs.rokt.com/developers/integration-guides/web/advanced/rokt-id-tag/
|
|
9359
|
+
rtid: {
|
|
9360
|
+
mappedKey: 'passbackconversiontrackingid',
|
|
9361
|
+
output: IntegrationOutputs.INTEGRATION_ATTRIBUTES,
|
|
9362
|
+
moduleId: 1277
|
|
9363
|
+
},
|
|
9364
|
+
RoktTransactionId: {
|
|
9365
|
+
mappedKey: 'passbackconversiontrackingid',
|
|
9366
|
+
output: IntegrationOutputs.INTEGRATION_ATTRIBUTES,
|
|
9367
|
+
moduleId: 1277
|
|
9368
|
+
},
|
|
9347
9369
|
// TIKTOK
|
|
9348
9370
|
ttclid: {
|
|
9349
9371
|
mappedKey: 'TikTok.Callback',
|
|
@@ -9360,6 +9382,7 @@ var mParticle = (function () {
|
|
|
9360
9382
|
// Cache filtered mappings for faster access
|
|
9361
9383
|
this.filteredPartnerIdentityMappings = this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES);
|
|
9362
9384
|
this.filteredCustomFlagMappings = this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS);
|
|
9385
|
+
this.filteredIntegrationAttributeMappings = this.filterMappings(IntegrationOutputs.INTEGRATION_ATTRIBUTES);
|
|
9363
9386
|
}
|
|
9364
9387
|
/**
|
|
9365
9388
|
* Captures Integration Ids from cookies and query params and stores them in clickIds object
|
|
@@ -9367,19 +9390,33 @@ var mParticle = (function () {
|
|
|
9367
9390
|
IntegrationCapture.prototype.capture = function () {
|
|
9368
9391
|
var queryParams = this.captureQueryParams() || {};
|
|
9369
9392
|
var cookies = this.captureCookies() || {};
|
|
9393
|
+
var localStorage = this.captureLocalStorage() || {};
|
|
9370
9394
|
// Exclude _fbc if fbclid is present
|
|
9371
9395
|
// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc#retrieve-from-fbclid-url-query-parameter
|
|
9372
9396
|
if (queryParams['fbclid'] && cookies['_fbc']) {
|
|
9373
9397
|
delete cookies['_fbc'];
|
|
9374
9398
|
}
|
|
9375
|
-
|
|
9399
|
+
// If both rtid and RoktTransactionId are present, prioritize rtid
|
|
9400
|
+
// If RoktTransactionId is present in both cookies and localStorage,
|
|
9401
|
+
// prioritize localStorage
|
|
9402
|
+
if (queryParams['rtid'] && localStorage['RoktTransactionId'] && cookies['RoktTransactionId']) {
|
|
9403
|
+
delete localStorage['RoktTransactionId'];
|
|
9404
|
+
delete cookies['RoktTransactionId'];
|
|
9405
|
+
} else if (queryParams['rtid'] && localStorage['RoktTransactionId']) {
|
|
9406
|
+
delete localStorage['RoktTransactionId'];
|
|
9407
|
+
} else if (queryParams['rtid'] && cookies['RoktTransactionId']) {
|
|
9408
|
+
delete cookies['RoktTransactionId'];
|
|
9409
|
+
} else if (localStorage['RoktTransactionId'] && cookies['RoktTransactionId']) {
|
|
9410
|
+
delete cookies['RoktTransactionId'];
|
|
9411
|
+
}
|
|
9412
|
+
this.clickIds = __assign(__assign(__assign(__assign({}, this.clickIds), queryParams), localStorage), cookies);
|
|
9376
9413
|
};
|
|
9377
9414
|
/**
|
|
9378
9415
|
* Captures cookies based on the integration ID mapping.
|
|
9379
9416
|
*/
|
|
9380
9417
|
IntegrationCapture.prototype.captureCookies = function () {
|
|
9381
9418
|
var cookies = getCookies(Object.keys(integrationMapping));
|
|
9382
|
-
return this.applyProcessors(cookies);
|
|
9419
|
+
return this.applyProcessors(cookies, getHref(), this.initialTimestamp);
|
|
9383
9420
|
};
|
|
9384
9421
|
/**
|
|
9385
9422
|
* Captures query parameters based on the integration ID mapping.
|
|
@@ -9388,6 +9425,19 @@ var mParticle = (function () {
|
|
|
9388
9425
|
var queryParams = this.getQueryParams();
|
|
9389
9426
|
return this.applyProcessors(queryParams, getHref(), this.initialTimestamp);
|
|
9390
9427
|
};
|
|
9428
|
+
/**
|
|
9429
|
+
* Captures local storage based on the integration ID mapping.
|
|
9430
|
+
*/
|
|
9431
|
+
IntegrationCapture.prototype.captureLocalStorage = function () {
|
|
9432
|
+
var localStorageItems = {};
|
|
9433
|
+
for (var key in integrationMapping) {
|
|
9434
|
+
var localStorageItem = localStorage.getItem(key);
|
|
9435
|
+
if (localStorageItem) {
|
|
9436
|
+
localStorageItems[key] = localStorageItem;
|
|
9437
|
+
}
|
|
9438
|
+
}
|
|
9439
|
+
return this.applyProcessors(localStorageItems, getHref(), this.initialTimestamp);
|
|
9440
|
+
};
|
|
9391
9441
|
/**
|
|
9392
9442
|
* Gets the query parameters based on the integration ID mapping.
|
|
9393
9443
|
* @returns {Dictionary<string>} The query parameters.
|
|
@@ -9409,6 +9459,36 @@ var mParticle = (function () {
|
|
|
9409
9459
|
IntegrationCapture.prototype.getClickIdsAsPartnerIdentities = function () {
|
|
9410
9460
|
return this.getClickIds(this.clickIds, this.filteredPartnerIdentityMappings);
|
|
9411
9461
|
};
|
|
9462
|
+
/**
|
|
9463
|
+
* Returns only the `integration_attributes` mapped integration output.
|
|
9464
|
+
* @returns {IntegrationAttributes} The integration attributes.
|
|
9465
|
+
*/
|
|
9466
|
+
IntegrationCapture.prototype.getClickIdsAsIntegrationAttributes = function () {
|
|
9467
|
+
var _a;
|
|
9468
|
+
var _b, _c;
|
|
9469
|
+
// Integration IDs are stored in the following format:
|
|
9470
|
+
// {
|
|
9471
|
+
// "integration_attributes": {
|
|
9472
|
+
// "<moduleId>": {
|
|
9473
|
+
// "mappedKey": "clickIdValue"
|
|
9474
|
+
// }
|
|
9475
|
+
// }
|
|
9476
|
+
// }
|
|
9477
|
+
var mappedClickIds = {};
|
|
9478
|
+
for (var key in this.clickIds) {
|
|
9479
|
+
if (this.clickIds.hasOwnProperty(key)) {
|
|
9480
|
+
var value = this.clickIds[key];
|
|
9481
|
+
var mappingKey = (_b = this.filteredIntegrationAttributeMappings[key]) === null || _b === void 0 ? void 0 : _b.mappedKey;
|
|
9482
|
+
if (!isEmpty(mappingKey)) {
|
|
9483
|
+
var moduleId = (_c = this.filteredIntegrationAttributeMappings[key]) === null || _c === void 0 ? void 0 : _c.moduleId;
|
|
9484
|
+
if (moduleId && !mappedClickIds[moduleId]) {
|
|
9485
|
+
mappedClickIds[moduleId] = (_a = {}, _a[mappingKey] = value, _a);
|
|
9486
|
+
}
|
|
9487
|
+
}
|
|
9488
|
+
}
|
|
9489
|
+
}
|
|
9490
|
+
return mappedClickIds;
|
|
9491
|
+
};
|
|
9412
9492
|
IntegrationCapture.prototype.getClickIds = function (clickIds, mappingList) {
|
|
9413
9493
|
var _a;
|
|
9414
9494
|
var mappedClickIds = {};
|
|
@@ -9450,6 +9530,62 @@ var mParticle = (function () {
|
|
|
9450
9530
|
return IntegrationCapture;
|
|
9451
9531
|
}();
|
|
9452
9532
|
|
|
9533
|
+
var RoktManager = /** @class */function () {
|
|
9534
|
+
function RoktManager() {
|
|
9535
|
+
this.launcher = null;
|
|
9536
|
+
this.messageQueue = [];
|
|
9537
|
+
this.launcher = null;
|
|
9538
|
+
}
|
|
9539
|
+
RoktManager.prototype.attachLauncher = function (launcher) {
|
|
9540
|
+
this.setLauncher(launcher);
|
|
9541
|
+
this.processMessageQueue();
|
|
9542
|
+
};
|
|
9543
|
+
RoktManager.prototype.selectPlacements = function (options) {
|
|
9544
|
+
if (!this.launcher) {
|
|
9545
|
+
this.queueMessage({
|
|
9546
|
+
methodName: 'selectPlacements',
|
|
9547
|
+
payload: options
|
|
9548
|
+
});
|
|
9549
|
+
return Promise.resolve({});
|
|
9550
|
+
}
|
|
9551
|
+
try {
|
|
9552
|
+
return this.launcher.selectPlacements(options);
|
|
9553
|
+
} catch (error) {
|
|
9554
|
+
return Promise.reject(error instanceof Error ? error : new Error('Unknown error occurred'));
|
|
9555
|
+
}
|
|
9556
|
+
};
|
|
9557
|
+
RoktManager.prototype.processMessageQueue = function () {
|
|
9558
|
+
var _this = this;
|
|
9559
|
+
if (this.messageQueue.length > 0) {
|
|
9560
|
+
this.messageQueue.forEach(function (message) {
|
|
9561
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
9562
|
+
return __generator(this, function (_a) {
|
|
9563
|
+
switch (_a.label) {
|
|
9564
|
+
case 0:
|
|
9565
|
+
if (!(this.launcher && message.methodName in this.launcher)) return [3 /*break*/, 2];
|
|
9566
|
+
return [4 /*yield*/, this.launcher[message.methodName](message.payload)];
|
|
9567
|
+
case 1:
|
|
9568
|
+
_a.sent();
|
|
9569
|
+
_a.label = 2;
|
|
9570
|
+
case 2:
|
|
9571
|
+
return [2 /*return*/];
|
|
9572
|
+
}
|
|
9573
|
+
});
|
|
9574
|
+
});
|
|
9575
|
+
});
|
|
9576
|
+
|
|
9577
|
+
this.messageQueue = [];
|
|
9578
|
+
}
|
|
9579
|
+
};
|
|
9580
|
+
RoktManager.prototype.queueMessage = function (message) {
|
|
9581
|
+
this.messageQueue.push(message);
|
|
9582
|
+
};
|
|
9583
|
+
RoktManager.prototype.setLauncher = function (launcher) {
|
|
9584
|
+
this.launcher = launcher;
|
|
9585
|
+
};
|
|
9586
|
+
return RoktManager;
|
|
9587
|
+
}();
|
|
9588
|
+
|
|
9453
9589
|
var Messages = Constants.Messages,
|
|
9454
9590
|
HTTPCodes = Constants.HTTPCodes,
|
|
9455
9591
|
FeatureFlags = Constants.FeatureFlags;
|
|
@@ -9489,6 +9625,7 @@ var mParticle = (function () {
|
|
|
9489
9625
|
forwarderConstructors: []
|
|
9490
9626
|
};
|
|
9491
9627
|
this._IntegrationCapture = new IntegrationCapture();
|
|
9628
|
+
this._RoktManager = new RoktManager();
|
|
9492
9629
|
// required for forwarders once they reference the mparticle instance
|
|
9493
9630
|
this.IdentityType = IdentityType;
|
|
9494
9631
|
this.EventType = EventType;
|
|
@@ -10762,7 +10899,7 @@ var mParticle = (function () {
|
|
|
10762
10899
|
// Only leaving this here in case any clients are trying to access mParticle.Store, to prevent from throwing
|
|
10763
10900
|
this.Store = {};
|
|
10764
10901
|
this._instances = {};
|
|
10765
|
-
this.IdentityType =
|
|
10902
|
+
this.IdentityType = IdentityType;
|
|
10766
10903
|
this.EventType = EventType;
|
|
10767
10904
|
this.CommerceEventType = CommerceEventType;
|
|
10768
10905
|
this.PromotionType = PromotionActionType;
|
|
@@ -10813,6 +10950,7 @@ var mParticle = (function () {
|
|
|
10813
10950
|
return client;
|
|
10814
10951
|
}
|
|
10815
10952
|
};
|
|
10953
|
+
this.Rokt = self.getInstance()._RoktManager;
|
|
10816
10954
|
this.getDeviceId = function () {
|
|
10817
10955
|
return self.getInstance().getDeviceId();
|
|
10818
10956
|
};
|
package/package.json
CHANGED
|
@@ -9,7 +9,7 @@ export default class ForegroundTimeTracker {
|
|
|
9
9
|
public totalTime: number = 0;
|
|
10
10
|
|
|
11
11
|
constructor(timerKey: string) {
|
|
12
|
-
this.localStorageName = `
|
|
12
|
+
this.localStorageName = `mprtcl-tos-${timerKey}`;
|
|
13
13
|
this.timerVault = new LocalStorageVault<number>(this.localStorageName);
|
|
14
14
|
this.loadTimeFromStorage();
|
|
15
15
|
this.addHandlers();
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SDKEventCustomFlags } from './sdkRuntimeModels';
|
|
2
|
+
import { IntegrationAttributes } from './store';
|
|
2
3
|
import {
|
|
3
4
|
Dictionary,
|
|
4
5
|
queryStringParser,
|
|
@@ -53,16 +54,19 @@ export const facebookClickIdProcessor: IntegrationCaptureProcessorFunction = (
|
|
|
53
54
|
// Integration outputs are used to determine how click ids are used within the SDK
|
|
54
55
|
// CUSTOM_FLAGS are sent out when an Event is created via ServerModel.createEventObject
|
|
55
56
|
// PARTNER_IDENTITIES are sent out in a Batch when a group of events are converted to a Batch
|
|
57
|
+
// INTEGRATION_ATTRIBUTES are stored initially on the SDKEvent level but then is added to the Batch when the batch is created
|
|
56
58
|
|
|
57
59
|
const IntegrationOutputs = {
|
|
58
60
|
CUSTOM_FLAGS: 'custom_flags',
|
|
59
61
|
PARTNER_IDENTITIES: 'partner_identities',
|
|
62
|
+
INTEGRATION_ATTRIBUTES: 'integration_attributes',
|
|
60
63
|
} as const;
|
|
61
64
|
|
|
62
65
|
interface IntegrationMappingItem {
|
|
63
66
|
mappedKey: string;
|
|
64
67
|
output: valueof<typeof IntegrationOutputs>;
|
|
65
68
|
processor?: IntegrationCaptureProcessorFunction;
|
|
69
|
+
moduleId?: number;
|
|
66
70
|
}
|
|
67
71
|
|
|
68
72
|
interface IntegrationIdMapping {
|
|
@@ -99,6 +103,19 @@ const integrationMapping: IntegrationIdMapping = {
|
|
|
99
103
|
output: IntegrationOutputs.CUSTOM_FLAGS,
|
|
100
104
|
},
|
|
101
105
|
|
|
106
|
+
// Rokt
|
|
107
|
+
// https://docs.rokt.com/developers/integration-guides/web/advanced/rokt-id-tag/
|
|
108
|
+
rtid: {
|
|
109
|
+
mappedKey: 'passbackconversiontrackingid',
|
|
110
|
+
output: IntegrationOutputs.INTEGRATION_ATTRIBUTES,
|
|
111
|
+
moduleId: 1277,
|
|
112
|
+
},
|
|
113
|
+
RoktTransactionId: {
|
|
114
|
+
mappedKey: 'passbackconversiontrackingid',
|
|
115
|
+
output: IntegrationOutputs.INTEGRATION_ATTRIBUTES,
|
|
116
|
+
moduleId: 1277,
|
|
117
|
+
},
|
|
118
|
+
|
|
102
119
|
// TIKTOK
|
|
103
120
|
ttclid: {
|
|
104
121
|
mappedKey: 'TikTok.Callback',
|
|
@@ -115,6 +132,7 @@ export default class IntegrationCapture {
|
|
|
115
132
|
public readonly initialTimestamp: number;
|
|
116
133
|
public readonly filteredPartnerIdentityMappings: IntegrationIdMapping;
|
|
117
134
|
public readonly filteredCustomFlagMappings: IntegrationIdMapping;
|
|
135
|
+
public readonly filteredIntegrationAttributeMappings: IntegrationIdMapping;
|
|
118
136
|
|
|
119
137
|
constructor() {
|
|
120
138
|
this.initialTimestamp = Date.now();
|
|
@@ -122,6 +140,7 @@ export default class IntegrationCapture {
|
|
|
122
140
|
// Cache filtered mappings for faster access
|
|
123
141
|
this.filteredPartnerIdentityMappings = this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES);
|
|
124
142
|
this.filteredCustomFlagMappings = this.filterMappings(IntegrationOutputs.CUSTOM_FLAGS);
|
|
143
|
+
this.filteredIntegrationAttributeMappings = this.filterMappings(IntegrationOutputs.INTEGRATION_ATTRIBUTES);
|
|
125
144
|
}
|
|
126
145
|
|
|
127
146
|
/**
|
|
@@ -130,6 +149,7 @@ export default class IntegrationCapture {
|
|
|
130
149
|
public capture(): void {
|
|
131
150
|
const queryParams = this.captureQueryParams() || {};
|
|
132
151
|
const cookies = this.captureCookies() || {};
|
|
152
|
+
const localStorage = this.captureLocalStorage() || {};
|
|
133
153
|
|
|
134
154
|
// Exclude _fbc if fbclid is present
|
|
135
155
|
// https://developers.facebook.com/docs/marketing-api/conversions-api/parameters/fbp-and-fbc#retrieve-from-fbclid-url-query-parameter
|
|
@@ -137,7 +157,21 @@ export default class IntegrationCapture {
|
|
|
137
157
|
delete cookies['_fbc'];
|
|
138
158
|
}
|
|
139
159
|
|
|
140
|
-
|
|
160
|
+
// If both rtid and RoktTransactionId are present, prioritize rtid
|
|
161
|
+
// If RoktTransactionId is present in both cookies and localStorage,
|
|
162
|
+
// prioritize localStorage
|
|
163
|
+
if (queryParams['rtid'] && localStorage['RoktTransactionId'] && cookies['RoktTransactionId']) {
|
|
164
|
+
delete localStorage['RoktTransactionId'];
|
|
165
|
+
delete cookies['RoktTransactionId'];
|
|
166
|
+
} else if (queryParams['rtid'] && localStorage['RoktTransactionId']) {
|
|
167
|
+
delete localStorage['RoktTransactionId'];
|
|
168
|
+
} else if (queryParams['rtid'] && cookies['RoktTransactionId']) {
|
|
169
|
+
delete cookies['RoktTransactionId'];
|
|
170
|
+
} else if (localStorage['RoktTransactionId'] && cookies['RoktTransactionId']) {
|
|
171
|
+
delete cookies['RoktTransactionId'];
|
|
172
|
+
}
|
|
173
|
+
|
|
174
|
+
this.clickIds = { ...this.clickIds, ...queryParams, ...localStorage, ...cookies };
|
|
141
175
|
}
|
|
142
176
|
|
|
143
177
|
/**
|
|
@@ -145,7 +179,7 @@ export default class IntegrationCapture {
|
|
|
145
179
|
*/
|
|
146
180
|
public captureCookies(): Dictionary<string> {
|
|
147
181
|
const cookies = getCookies(Object.keys(integrationMapping));
|
|
148
|
-
return this.applyProcessors(cookies);
|
|
182
|
+
return this.applyProcessors(cookies, getHref(), this.initialTimestamp);
|
|
149
183
|
}
|
|
150
184
|
|
|
151
185
|
/**
|
|
@@ -156,6 +190,21 @@ export default class IntegrationCapture {
|
|
|
156
190
|
return this.applyProcessors(queryParams, getHref(), this.initialTimestamp);
|
|
157
191
|
}
|
|
158
192
|
|
|
193
|
+
/**
|
|
194
|
+
* Captures local storage based on the integration ID mapping.
|
|
195
|
+
*/
|
|
196
|
+
public captureLocalStorage(): Dictionary<string> {
|
|
197
|
+
let localStorageItems: Dictionary<string> = {};
|
|
198
|
+
for (const key in integrationMapping) {
|
|
199
|
+
const localStorageItem = localStorage.getItem(key);
|
|
200
|
+
if (localStorageItem) {
|
|
201
|
+
localStorageItems[key] = localStorageItem;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return this.applyProcessors(localStorageItems, getHref(), this.initialTimestamp);
|
|
206
|
+
}
|
|
207
|
+
|
|
159
208
|
/**
|
|
160
209
|
* Gets the query parameters based on the integration ID mapping.
|
|
161
210
|
* @returns {Dictionary<string>} The query parameters.
|
|
@@ -180,6 +229,37 @@ export default class IntegrationCapture {
|
|
|
180
229
|
return this.getClickIds(this.clickIds, this.filteredPartnerIdentityMappings);
|
|
181
230
|
}
|
|
182
231
|
|
|
232
|
+
/**
|
|
233
|
+
* Returns only the `integration_attributes` mapped integration output.
|
|
234
|
+
* @returns {IntegrationAttributes} The integration attributes.
|
|
235
|
+
*/
|
|
236
|
+
public getClickIdsAsIntegrationAttributes(): IntegrationAttributes {
|
|
237
|
+
// Integration IDs are stored in the following format:
|
|
238
|
+
// {
|
|
239
|
+
// "integration_attributes": {
|
|
240
|
+
// "<moduleId>": {
|
|
241
|
+
// "mappedKey": "clickIdValue"
|
|
242
|
+
// }
|
|
243
|
+
// }
|
|
244
|
+
// }
|
|
245
|
+
const mappedClickIds: IntegrationAttributes = {};
|
|
246
|
+
|
|
247
|
+
for (const key in this.clickIds) {
|
|
248
|
+
if (this.clickIds.hasOwnProperty(key)) {
|
|
249
|
+
const value = this.clickIds[key];
|
|
250
|
+
const mappingKey = this.filteredIntegrationAttributeMappings[key]?.mappedKey;
|
|
251
|
+
if (!isEmpty(mappingKey)) {
|
|
252
|
+
const moduleId = this.filteredIntegrationAttributeMappings[key]?.moduleId;
|
|
253
|
+
if (moduleId && !mappedClickIds[moduleId]) {
|
|
254
|
+
mappedClickIds[moduleId] = { [mappingKey]: value };
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
return mappedClickIds;
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
|
|
183
263
|
private getClickIds(
|
|
184
264
|
clickIds: Dictionary<string>,
|
|
185
265
|
mappingList: IntegrationIdMapping
|
package/src/mp-instance.ts
CHANGED
|
@@ -49,6 +49,7 @@ import { IECommerce } from './ecommerce.interfaces';
|
|
|
49
49
|
import { INativeSdkHelpers } from './nativeSdkHelpers.interfaces';
|
|
50
50
|
import { IPersistence } from './persistence.interfaces';
|
|
51
51
|
import ForegroundTimer from './foregroundTimeTracker';
|
|
52
|
+
import RoktManager from './roktManager';
|
|
52
53
|
|
|
53
54
|
export interface IErrorLogMessage {
|
|
54
55
|
message?: string;
|
|
@@ -80,6 +81,7 @@ export interface IMParticleWebSDKInstance extends MParticleWebSDK {
|
|
|
80
81
|
_IntegrationCapture: IntegrationCapture;
|
|
81
82
|
_NativeSdkHelpers: INativeSdkHelpers;
|
|
82
83
|
_Persistence: IPersistence;
|
|
84
|
+
_RoktManager: RoktManager;
|
|
83
85
|
_SessionManager: ISessionManager;
|
|
84
86
|
_ServerModel: IServerModel;
|
|
85
87
|
_Store: IStore;
|
|
@@ -126,13 +128,14 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
126
128
|
forwarderConstructors: [],
|
|
127
129
|
};
|
|
128
130
|
this._IntegrationCapture = new IntegrationCapture();
|
|
131
|
+
this._RoktManager = new RoktManager();
|
|
129
132
|
|
|
130
133
|
// required for forwarders once they reference the mparticle instance
|
|
131
134
|
this.IdentityType = IdentityType;
|
|
132
|
-
this.EventType = EventType
|
|
133
|
-
this.CommerceEventType = CommerceEventType
|
|
134
|
-
this.PromotionType = PromotionActionType
|
|
135
|
-
this.ProductActionType = ProductActionType
|
|
135
|
+
this.EventType = EventType;
|
|
136
|
+
this.CommerceEventType = CommerceEventType;
|
|
137
|
+
this.PromotionType = PromotionActionType;
|
|
138
|
+
this.ProductActionType = ProductActionType;
|
|
136
139
|
|
|
137
140
|
|
|
138
141
|
this._Identity = new Identity(this);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Polyfill from './polyfill';
|
|
2
|
-
import
|
|
2
|
+
import { CommerceEventType, EventType, IdentityType, ProductActionType, PromotionActionType } from './types';
|
|
3
3
|
import Constants from './constants';
|
|
4
4
|
import mParticleInstance, { IMParticleWebSDKInstance } from './mp-instance.js';
|
|
5
5
|
import _BatchValidator from './mockBatchCreator';
|
|
@@ -7,7 +7,6 @@ import MPSideloadedKit from './sideloadedKit';
|
|
|
7
7
|
import { IMParticleInstanceManager } from './sdkRuntimeModels';
|
|
8
8
|
import { IStore } from './store';
|
|
9
9
|
import { Dictionary } from '@mparticle/web-sdk';
|
|
10
|
-
import { valueof } from './utils';
|
|
11
10
|
|
|
12
11
|
if (!Array.prototype.forEach) {
|
|
13
12
|
Array.prototype.forEach = Polyfill.forEach;
|
|
@@ -32,11 +31,11 @@ function mParticleInstanceManager(this: IMParticleInstanceManager) {
|
|
|
32
31
|
// Only leaving this here in case any clients are trying to access mParticle.Store, to prevent from throwing
|
|
33
32
|
this.Store = {} as IStore;
|
|
34
33
|
this._instances = {} as Dictionary<IMParticleWebSDKInstance>;
|
|
35
|
-
this.IdentityType =
|
|
36
|
-
this.EventType = EventType
|
|
37
|
-
this.CommerceEventType = CommerceEventType
|
|
38
|
-
this.PromotionType = PromotionActionType
|
|
39
|
-
this.ProductActionType = ProductActionType
|
|
34
|
+
this.IdentityType = IdentityType;
|
|
35
|
+
this.EventType = EventType;
|
|
36
|
+
this.CommerceEventType = CommerceEventType;
|
|
37
|
+
this.PromotionType = PromotionActionType;
|
|
38
|
+
this.ProductActionType = ProductActionType;
|
|
40
39
|
|
|
41
40
|
this.MPSideloadedKit = MPSideloadedKit;
|
|
42
41
|
|
|
@@ -104,6 +103,9 @@ function mParticleInstanceManager(this: IMParticleInstanceManager) {
|
|
|
104
103
|
return client;
|
|
105
104
|
}
|
|
106
105
|
};
|
|
106
|
+
|
|
107
|
+
this.Rokt = self.getInstance()._RoktManager;
|
|
108
|
+
|
|
107
109
|
this.getDeviceId = function() {
|
|
108
110
|
return self.getInstance().getDeviceId();
|
|
109
111
|
};
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
// https://docs.rokt.com/developers/integration-guides/web/library/attributes
|
|
2
|
+
export interface IRoktPartnerAttributes {
|
|
3
|
+
[key: string]: string | number | boolean | undefined | null;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
// https://docs.rokt.com/developers/integration-guides/web/library/select-placements-options
|
|
7
|
+
export interface IRoktSelectPlacementsOptions {
|
|
8
|
+
attributes: IRoktPartnerAttributes;
|
|
9
|
+
identifier?: string;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface IRoktPlacement {}
|
|
13
|
+
|
|
14
|
+
export interface IRoktSelection {
|
|
15
|
+
close: () => void;
|
|
16
|
+
getPlacements: () => Promise<IRoktPlacement[]>;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export interface IRoktLauncher {
|
|
20
|
+
selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise<IRoktSelection>;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export interface IRoktMessage {
|
|
24
|
+
methodName: string;
|
|
25
|
+
payload: any;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default class RoktManager {
|
|
29
|
+
public launcher: IRoktLauncher | null = null;
|
|
30
|
+
private messageQueue: IRoktMessage[] = [];
|
|
31
|
+
|
|
32
|
+
constructor() {
|
|
33
|
+
this.launcher = null;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public attachLauncher(launcher: IRoktLauncher): void {
|
|
37
|
+
this.setLauncher(launcher);
|
|
38
|
+
this.processMessageQueue();
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
public selectPlacements(options: IRoktSelectPlacementsOptions): Promise<IRoktSelection> {
|
|
42
|
+
if (!this.launcher) {
|
|
43
|
+
this.queueMessage({
|
|
44
|
+
methodName: 'selectPlacements',
|
|
45
|
+
payload: options,
|
|
46
|
+
});
|
|
47
|
+
return Promise.resolve({} as IRoktSelection);
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
return this.launcher.selectPlacements(options);
|
|
52
|
+
} catch (error) {
|
|
53
|
+
return Promise.reject(error instanceof Error ? error : new Error('Unknown error occurred'));
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private processMessageQueue(): void {
|
|
58
|
+
if (this.messageQueue.length > 0) {
|
|
59
|
+
this.messageQueue.forEach(async (message) => {
|
|
60
|
+
if (this.launcher && message.methodName in this.launcher) {
|
|
61
|
+
await (this.launcher[message.methodName] as Function)(message.payload);
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
this.messageQueue = [];
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
private queueMessage(message: IRoktMessage): void {
|
|
70
|
+
this.messageQueue.push(message);
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
private setLauncher(launcher: IRoktLauncher): void {
|
|
74
|
+
this.launcher = launcher;
|
|
75
|
+
}
|
|
76
|
+
}
|
package/src/sdkRuntimeModels.ts
CHANGED
|
@@ -39,6 +39,7 @@ import _BatchValidator from './mockBatchCreator';
|
|
|
39
39
|
import { SDKECommerceAPI } from './ecommerce.interfaces';
|
|
40
40
|
import { IErrorLogMessage, IMParticleWebSDKInstance, IntegrationDelays } from './mp-instance';
|
|
41
41
|
import Constants from './constants';
|
|
42
|
+
import RoktManager from './roktManager';
|
|
42
43
|
|
|
43
44
|
// TODO: Resolve this with version in @mparticle/web-sdk
|
|
44
45
|
export type SDKEventCustomFlags = Dictionary<any>;
|
|
@@ -164,10 +165,11 @@ export interface SDKProduct {
|
|
|
164
165
|
// https://go.mparticle.com/work/SQDSDKS-6949
|
|
165
166
|
export interface MParticleWebSDK {
|
|
166
167
|
addForwarder(mockForwarder: MPForwarder): void;
|
|
167
|
-
IdentityType:
|
|
168
|
-
CommerceEventType:
|
|
169
|
-
EventType:
|
|
170
|
-
PromotionType:
|
|
168
|
+
IdentityType: typeof IdentityType;
|
|
169
|
+
CommerceEventType: typeof CommerceEventType;
|
|
170
|
+
EventType: typeof EventType;
|
|
171
|
+
PromotionType: typeof PromotionActionType;
|
|
172
|
+
ProductActionType: typeof ProductActionType;
|
|
171
173
|
Identity: SDKIdentityApi;
|
|
172
174
|
Logger: SDKLoggerApi;
|
|
173
175
|
Consent: SDKConsentApi;
|
|
@@ -205,13 +207,15 @@ export interface MParticleWebSDK {
|
|
|
205
207
|
logError(error: IErrorLogMessage, attrs?: SDKEventAttrs): void;
|
|
206
208
|
logLink(selector: string, eventName: string, eventType: valueof<typeof EventType>, eventInfo: SDKEventAttrs): void;
|
|
207
209
|
logForm(selector: string, eventName: string, eventType: valueof<typeof EventType>, eventInfo: SDKEventAttrs): void;
|
|
208
|
-
logPageView(eventName
|
|
210
|
+
logPageView(eventName?: string, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
|
|
209
211
|
setOptOut(isOptingOut: boolean): void;
|
|
210
212
|
eCommerce: SDKECommerceAPI;
|
|
211
213
|
isInitialized(): boolean;
|
|
212
|
-
ProductActionType: valueof<typeof ProductActionType>;
|
|
213
214
|
ready(f: Function): void;
|
|
214
|
-
|
|
215
|
+
|
|
216
|
+
// https://go.mparticle.com/work/SQDSDKS-7072
|
|
217
|
+
reset(instance?: IMParticleWebSDKInstance): void;
|
|
218
|
+
|
|
215
219
|
setAppName(name: string): void;
|
|
216
220
|
setAppVersion(version: string): void;
|
|
217
221
|
setOptOut(isOptingOut: boolean): void;
|
|
@@ -239,6 +243,7 @@ export interface IMParticleInstanceManager extends MParticleWebSDK {
|
|
|
239
243
|
config: SDKInitConfig;
|
|
240
244
|
isIOS?: boolean;
|
|
241
245
|
MPSideloadedKit: typeof MPSideloadedKit;
|
|
246
|
+
Rokt: RoktManager;
|
|
242
247
|
// https://go.mparticle.com/work/SQDSDKS-7060
|
|
243
248
|
sessionManager: Pick<ISessionManager, 'getSession'>;
|
|
244
249
|
Store: IStore;
|
package/src/serverModel.ts
CHANGED
|
@@ -17,7 +17,7 @@ import {
|
|
|
17
17
|
Dictionary,
|
|
18
18
|
isValidCustomFlagProperty,
|
|
19
19
|
} from './utils';
|
|
20
|
-
import { ServerSettings } from './store';
|
|
20
|
+
import { IntegrationAttributes, ServerSettings } from './store';
|
|
21
21
|
import { MPID } from '@mparticle/web-sdk';
|
|
22
22
|
import {
|
|
23
23
|
IConsentStateV2DTO,
|
|
@@ -319,6 +319,7 @@ export default function ServerModel(
|
|
|
319
319
|
mpInstance._Store.webviewBridgeEnabled
|
|
320
320
|
) {
|
|
321
321
|
let customFlags: SDKEventCustomFlags = {...event.customFlags};
|
|
322
|
+
let integrationAttributes: IntegrationAttributes = mpInstance._Store.integrationAttributes;
|
|
322
323
|
|
|
323
324
|
// https://go.mparticle.com/work/SQDSDKS-5053
|
|
324
325
|
if (mpInstance._Helpers.getFeatureFlag && mpInstance._Helpers.getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIds)) {
|
|
@@ -328,6 +329,9 @@ export default function ServerModel(
|
|
|
328
329
|
mpInstance._IntegrationCapture.capture();
|
|
329
330
|
const transformedClickIDs = mpInstance._IntegrationCapture.getClickIdsAsCustomFlags();
|
|
330
331
|
customFlags = {...transformedClickIDs, ...customFlags};
|
|
332
|
+
|
|
333
|
+
const transformedIntegrationAttributes = mpInstance._IntegrationCapture.getClickIdsAsIntegrationAttributes();
|
|
334
|
+
integrationAttributes = {...transformedIntegrationAttributes, ...integrationAttributes};
|
|
331
335
|
}
|
|
332
336
|
|
|
333
337
|
if (event.hasOwnProperty('toEventAPIObject')) {
|
|
@@ -378,7 +382,7 @@ export default function ServerModel(
|
|
|
378
382
|
Package: mpInstance._Store.SDKConfig.package,
|
|
379
383
|
ClientGeneratedId: mpInstance._Store.clientId,
|
|
380
384
|
DeviceId: mpInstance._Store.deviceId,
|
|
381
|
-
IntegrationAttributes:
|
|
385
|
+
IntegrationAttributes: integrationAttributes,
|
|
382
386
|
CurrencyCode: mpInstance._Store.currencyCode,
|
|
383
387
|
DataPlan: mpInstance._Store.SDKConfig.dataPlan
|
|
384
388
|
? mpInstance._Store.SDKConfig.dataPlan
|
package/src/utils.ts
CHANGED
|
@@ -292,14 +292,19 @@ interface URLSearchParamsFallback {
|
|
|
292
292
|
}
|
|
293
293
|
|
|
294
294
|
const queryStringParserFallback = (url: string): URLSearchParamsFallback => {
|
|
295
|
-
|
|
295
|
+
const params: Dictionary<string> = {};
|
|
296
296
|
const queryString = url.split('?')[1] || '';
|
|
297
297
|
const pairs = queryString.split('&');
|
|
298
298
|
|
|
299
299
|
pairs.forEach(pair => {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
300
|
+
const [key, ...valueParts] = pair.split('=');
|
|
301
|
+
const value = valueParts.join('=');
|
|
302
|
+
if (key && value !== undefined) {
|
|
303
|
+
try {
|
|
304
|
+
params[key] = decodeURIComponent(value || '');
|
|
305
|
+
} catch (e) {
|
|
306
|
+
console.error(`Failed to decode value for key ${key}: ${e}`);
|
|
307
|
+
}
|
|
303
308
|
}
|
|
304
309
|
});
|
|
305
310
|
|