@mparticle/web-sdk 2.79.0 → 2.79.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -6,16 +6,16 @@ encode:function(a){try{if(window.btoa&&window.atob)return window.btoa(unescape(e
6
6
  }return Base64$1._decode(a)},_decode:function(a){var b,c,d,e,f,g,h,j="",k=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k<a.length;)e=Base64$1._keyStr.indexOf(a.charAt(k++)),f=Base64$1._keyStr.indexOf(a.charAt(k++)),g=Base64$1._keyStr.indexOf(a.charAt(k++)),h=Base64$1._keyStr.indexOf(a.charAt(k++)),b=e<<2|f>>4,c=(15&f)<<4|g>>2,d=(3&g)<<6|h,j+=String.fromCharCode(b),64!==g&&(j+=String.fromCharCode(c)),64!==h&&(j+=String.fromCharCode(d));return j=UTF8.decode(j),j}},UTF8={encode:function(a){for(var b,d="",e=0;e<a.length;e++)b=a.charCodeAt(e),128>b?d+=String.fromCharCode(b):127<b&&2048>b?(d+=String.fromCharCode(192|b>>6),d+=String.fromCharCode(128|63&b)):(d+=String.fromCharCode(224|b>>12),d+=String.fromCharCode(128|63&b>>6),d+=String.fromCharCode(128|63&b));return d},decode:function(a){for(var b="",d=0,e=0,f=0,g=0;d<a.length;)e=a.charCodeAt(d),128>e?(b+=String.fromCharCode(e),d++):191<e&&224>e?(f=a.charCodeAt(d+1),b+=String.fromCharCode((31&e)<<6|63&f),d+=2):(f=a.charCodeAt(d+1),g=a.charCodeAt(d+2),b+=String.fromCharCode((15&e)<<12|(63&f)<<6|63&g),d+=3);return b}};var Polyfill = {// forEach polyfill
7
7
  // Production steps of ECMA-262, Edition 5, 15.4.4.18
8
8
  // Reference: http://es5.github.io/#x15.4.4.18
9
- forEach:function forEach(a,b){var c,d;if(null==this)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(1<arguments.length&&(c=b),d=0;d<f;){var g;d in e&&(g=e[d],a.call(c,g,d,e)),d++;}},// map polyfill
9
+ forEach:function forEach(a,b){var c,d;if(null==this)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(1<arguments.length&&(c=b),d=0;d<f;){var g=void 0;d in e&&(g=e[d],a.call(c,g,d,e)),d++;}},// map polyfill
10
10
  // Production steps of ECMA-262, Edition 5, 15.4.4.19
11
11
  // Reference: http://es5.github.io/#x15.4.4.19
12
- map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is null or not defined");var f=Object(this),g=f.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(1<arguments.length&&(c=b),d=Array(g),e=0;e<g;){var h,i;e in f&&(h=f[e],i=a.call(c,h,e,f),d[e]=i),e++;}return d},// filter polyfill
12
+ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is null or not defined");var f=Object(this),g=f.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(1<arguments.length&&(c=b),d=Array(g),e=0;e<g;){var h=void 0,i=void 0;e in f&&(h=f[e],i=a.call(c,h,e,f),d[e]=i),e++;}return d},// filter polyfill
13
13
  // Prodcution steps of ECMA-262, Edition 5
14
14
  // Reference: http://es5.github.io/#x15.4.4.20
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.79.0";
18
+ var version = "2.79.1";
19
19
 
20
20
  var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"is a deprecated method and will be removed in future releases.",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",AddToCart:"addToCart",RemoveFromCart:"removeFromCart",ClearCart:"clearCart",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",localStorageProductsV4:"mprtcl-prodv4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4",currentStorageProductsName:"mprtcl-prodv4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,maxProducts:20,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
21
21
  },DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},// These are the paths that are used to construct the CNAME urls
@@ -617,11 +617,11 @@ if(!g||a._Store.requireDelay||!a._Store.configurationLoaded)return a.Logger.verb
617
617
 
618
618
  var KitFilterHelper=/** @class */function(){function a(){}a.hashEventType=function(a){return generateHash(a)},a.hashEventName=function(a,b){return generateHash(b+a)},a.hashEventAttributeKey=function(a,b,c){return generateHash(a+b+c)},a.hashUserAttribute=function(a){return generateHash(a)},a.hashUserIdentity=function(a){return a},a.hashConsentPurpose=function(a,b){return generateHash(a+b)},a.hashAttributeConditionalForwarding=function(a){return generateHash(a).toString()},a.hashConsentPurposeConditionalForwarding=function(a,b){return this.hashConsentPurpose(a,b).toString()};var b;return b=a,a.filterUserAttributes=function(a,c){return filterDictionaryWithHash(a,c,function(a){return b.hashUserAttribute(a)})},a.filterUserIdentities=function(a,c){return filterDictionaryWithHash(a,c,function(a){return b.hashUserIdentity(IdentityType.getIdentityType(a))})},a.isFilteredUserAttribute=function(a,c){var d=b.hashUserAttribute(a);return c&&inArray(c,d)},a}();
619
619
 
620
- var StorageNames$1=Constants.StorageNames;function Helpers(a){var b=this;// TODO: Refactor SDK to directly use these methods
620
+ var StorageNames$1=Constants.StorageNames;function appendFilteredUserIdentity(a,b,c){c===Types.IdentityType.CustomerId?a.unshift(b):a.push(b);}function buildFilteredUserIdentities(a,b,c){var d=[];if(!a||!Object.keys(a).length)return d;for(var e in a)if(a.hasOwnProperty(e)){var f=Types.IdentityType.getIdentityType(e);c(b,f)||appendFilteredUserIdentity(d,{Type:f,Identity:a[e]},f);}return d}function Helpers(a){var b=this;// TODO: Refactor SDK to directly use these methods
621
621
  // https://go.mparticle.com/work/SQDSDKS-5239
622
622
  // Utility Functions
623
623
  // Imported Validators
624
- this.canLog=function(){return !!(a._Store.isEnabled&&(a._Store.devToken||a._Store.webviewBridgeEnabled))},this.getFeatureFlag=function(b){return a._Store.SDKConfig.flags.hasOwnProperty(b)?a._Store.SDKConfig.flags[b]:null},this.invokeCallback=function(c,d,e,f,g){c||a.Logger.warning("There is no callback provided");try{b.Validators.isFunction(c)&&c({httpCode:d,body:e,getUser:function getUser(){return f?f:a.Identity.getCurrentUser()},getPreviousUser:function getPreviousUser(){if(!g){var b=a.Identity.getUsers(),c=b.shift(),d=f||a.Identity.getCurrentUser();return c&&d&&c.getMPID()===d.getMPID()&&(c=b.shift()),c||null}return a.Identity.getUser(g)}});}catch(b){a.Logger.error("There was an error with your callback: "+b);}},this.invokeAliasCallback=function(c,d,e){c||a.Logger.warning("There is no callback provided");try{if(b.Validators.isFunction(c)){var f={httpCode:d};e&&(f.message=e),c(f);}}catch(b){a.Logger.error("There was an error with your callback: "+b);}},this.extend=extend,this.createServiceUrl=function(b,c){var d,e=window.mParticle&&a._Store.SDKConfig.forceHttps?"https://":window.location.protocol+"//";return d=a._Store.SDKConfig.forceHttps?"https://"+b:e+b,c&&(d+=c),d},this.createXHR=function(b){var c;try{c=new window.XMLHttpRequest;}catch(b){a.Logger.error("Error creating XMLHttpRequest object.");}if(c&&b&&"withCredentials"in c)c.onreadystatechange=b;else if("undefined"!=typeof window.XDomainRequest){a.Logger.verbose("Creating XDomainRequest object");try{c=new window.XDomainRequest,c.onload=b;}catch(b){a.Logger.error("Error creating XDomainRequest object");}}return c},this.filterUserIdentities=function(a,c){var d=[];if(a&&Object.keys(a).length)for(var e in a)if(a.hasOwnProperty(e)){var f=Types.IdentityType.getIdentityType(e);if(!b.inArray(c,f)){var g={Type:f,Identity:a[e]};f===Types.IdentityType.CustomerId?d.unshift(g):d.push(g);}}return d},this.filterUserIdentitiesForForwarders=KitFilterHelper.filterUserIdentities,this.filterUserAttributes=KitFilterHelper.filterUserAttributes,this.isEventType=function(a){for(var b in Types.EventType)if(Types.EventType.hasOwnProperty(b)&&Types.EventType[b]===a)return !0;return !1},this.sanitizeAttributes=function(c,d){if(!c||!b.isObject(c))return null;var e={};for(var f in c)// Make sure that attribute values are not objects or arrays, which are not valid
624
+ this.canLog=function(){return !!(a._Store.isEnabled&&(a._Store.devToken||a._Store.webviewBridgeEnabled))},this.getFeatureFlag=function(b){return a._Store.SDKConfig.flags.hasOwnProperty(b)?a._Store.SDKConfig.flags[b]:null},this.invokeCallback=function(c,d,e,f,g){c||a.Logger.warning("There is no callback provided");try{b.Validators.isFunction(c)&&c({httpCode:d,body:e,getUser:function getUser(){return f?f:a.Identity.getCurrentUser()},getPreviousUser:function getPreviousUser(){if(!g){var b=a.Identity.getUsers(),c=b.shift(),d=f||a.Identity.getCurrentUser();return c&&d&&c.getMPID()===d.getMPID()&&(c=b.shift()),c||null}return a.Identity.getUser(g)}});}catch(b){a.Logger.error("There was an error with your callback: "+b);}},this.invokeAliasCallback=function(c,d,e){c||a.Logger.warning("There is no callback provided");try{if(b.Validators.isFunction(c)){var f={httpCode:d};e&&(f.message=e),c(f);}}catch(b){a.Logger.error("There was an error with your callback: "+b);}},this.extend=extend,this.createServiceUrl=function(b,c){var d,e=window.mParticle&&a._Store.SDKConfig.forceHttps?"https://":window.location.protocol+"//";return d=a._Store.SDKConfig.forceHttps?"https://"+b:e+b,c&&(d+=c),d},this.createXHR=function(b){var c;try{c=new window.XMLHttpRequest;}catch(b){a.Logger.error("Error creating XMLHttpRequest object.");}if(c&&b&&"withCredentials"in c)c.onreadystatechange=b;else if("undefined"!=typeof window.XDomainRequest){a.Logger.verbose("Creating XDomainRequest object");try{c=new window.XDomainRequest,c.onload=b;}catch(b){a.Logger.error("Error creating XDomainRequest object");}}return c},this.filterUserIdentities=function(a,c){return buildFilteredUserIdentities(a,c,b.inArray)},this.filterUserIdentitiesForForwarders=KitFilterHelper.filterUserIdentities,this.filterUserAttributes=KitFilterHelper.filterUserAttributes,this.isEventType=function(a){for(var b in Types.EventType)if(Types.EventType.hasOwnProperty(b)&&Types.EventType[b]===a)return !0;return !1},this.sanitizeAttributes=function(c,d){if(!c||!b.isObject(c))return null;var e={};for(var f in c)// Make sure that attribute values are not objects or arrays, which are not valid
625
625
  c.hasOwnProperty(f)&&b.Validators.isValidAttributeValue(c[f])?e[f]=c[f]:a.Logger.warning("For '"+d+"', the corresponding attribute value of '"+f+"' must be a string, number, boolean, or null.");return e},this.isDelayedByIntegration=function(b,c,d){if(d-c>a._Store.SDKConfig.integrationDelayTimeout)return !1;for(var e in b){if(!0===b[e])return !0;continue}return !1},this.createMainStorageName=function(a){return a?StorageNames$1.currentStorageName+"_"+a:StorageNames$1.currentStorageName},this.converted=converted,this.findKeyInObject=findKeyInObject,this.parseNumber=parseNumber,this.inArray=inArray,this.isObject=isObject,this.decoded=decoded,this.parseStringOrNumber=parseStringOrNumber,this.generateHash=generateHash,this.generateUniqueId=generateUniqueId,this.Validators=Validators;}
626
626
 
627
627
  var Messages$8=Constants.Messages,androidBridgeNameBase="mParticleAndroid",iosBridgeNameBase="mParticle";function NativeSdkHelpers(a){var b=this;this.initializeSessionAttributes=function(a){var c=Constants.NativeSdkPaths.SetSessionAttribute,d=JSON.stringify({key:"$src_env",value:"webview"}),e=JSON.stringify({key:"$src_key",value:a});b.sendToNative(c,d),a&&b.sendToNative(c,e);},this.isBridgeV2Available=function(a){if(!a)return !1;var b=iosBridgeNameBase+"_"+a+"_v2";// iOS v2 bridge
@@ -792,7 +792,7 @@ c(b),b=null,a._Store.isTracking=!1;}));else {var d={coords:{latitude:a._Store.cu
792
792
  // null, resulting in kit forwarding errors on the server.
793
793
  // The check for `ProductAction` is required to denote that these are
794
794
  // ProductAction events, and not impression or promotions
795
- return a.Logger.verbose(Messages$3.InformationMessages.StartingLogCommerceEvent),b.ProductAction&&null===b.EventCategory?void a.Logger.error("Commerce event not sent. The mParticle.ProductActionType you passed was invalid. Re-check your code."):void(c=a._Helpers.sanitizeAttributes(c,b.EventName),a._Helpers.canLog()?(a._Store.webviewBridgeEnabled&&(b.ShoppingCart={}),c&&(b.EventAttributes=c),b.ProductAction&&a._Ecommerce.calculateProductActionTotalAmount(b.ProductAction),a._APIClient.sendEventToServer(b,d),a._Persistence.update()):a.Logger.verbose(Messages$3.InformationMessages.AbandonLogEvent))},this.addEventHandler=function(c,d,f,g,h){var j,k,e=[],l=function handler(c){var d=function timeoutHandler(){j.href?window.location.href=j.href:j.submit&&j.submit();};a.Logger.verbose("DOM event triggered, handling event"),b.logEvent({messageType:Types.MessageType.PageEvent,name:"function"==typeof f?f(j):f,data:"function"==typeof g?g(j):g,eventType:h||Types.EventType.Other}),(j.href&&"_blank"!==j.target||j.submit)&&(c.preventDefault?c.preventDefault():c.returnValue=!1,setTimeout(d,a._Store.SDKConfig.timeout));};if(!d)return void a.Logger.error("Can't bind event, selector is required");// Handle a css selector string or a dom element
795
+ if(a.Logger.verbose(Messages$3.InformationMessages.StartingLogCommerceEvent),b.ProductAction&&null===b.EventCategory)return void a.Logger.error("Commerce event not sent. The mParticle.ProductActionType you passed was invalid. Re-check your code.");var e=a._Helpers.sanitizeAttributes(c,b.EventName);a._Helpers.canLog()?(a._Store.webviewBridgeEnabled&&(b.ShoppingCart={}),e&&(b.EventAttributes=e),b.ProductAction&&a._Ecommerce.calculateProductActionTotalAmount(b.ProductAction),a._APIClient.sendEventToServer(b,d),a._Persistence.update()):a.Logger.verbose(Messages$3.InformationMessages.AbandonLogEvent);},this.addEventHandler=function(c,d,f,g,h){var j,k,e=[],l=function handler(c){var d=function timeoutHandler(){j.href?window.location.href=j.href:j.submit&&j.submit();};a.Logger.verbose("DOM event triggered, handling event"),b.logEvent({messageType:Types.MessageType.PageEvent,name:"function"==typeof f?f(j):f,data:"function"==typeof g?g(j):g,eventType:h||Types.EventType.Other}),(j.href&&"_blank"!==j.target||j.submit)&&(c.preventDefault?c.preventDefault():c.returnValue=!1,setTimeout(d,a._Store.SDKConfig.timeout));};if(!d)return void a.Logger.error("Can't bind event, selector is required");// Handle a css selector string or a dom element
796
796
  if("string"==typeof d?e=document.querySelectorAll(d):d.nodeType&&(e=[d]),e.length)for(a.Logger.verbose("Found "+e.length+" element"+(1<e.length?"s":"")+", attaching event handlers"),k=0;k<e.length;k++)j=e[k],j.addEventListener?j.addEventListener(c,l,!1):j.attachEvent?j.attachEvent("on"+c,l):j["on"+c]=l;else a.Logger.verbose("No elements found");};}
797
797
 
798
798
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
@@ -6,16 +6,16 @@ encode:function(a){try{if(window.btoa&&window.atob)return window.btoa(unescape(e
6
6
  }return Base64$1._decode(a)},_decode:function(a){var b,c,d,e,f,g,h,j="",k=0;for(a=a.replace(/[^A-Za-z0-9\+\/\=]/g,"");k<a.length;)e=Base64$1._keyStr.indexOf(a.charAt(k++)),f=Base64$1._keyStr.indexOf(a.charAt(k++)),g=Base64$1._keyStr.indexOf(a.charAt(k++)),h=Base64$1._keyStr.indexOf(a.charAt(k++)),b=e<<2|f>>4,c=(15&f)<<4|g>>2,d=(3&g)<<6|h,j+=String.fromCharCode(b),64!==g&&(j+=String.fromCharCode(c)),64!==h&&(j+=String.fromCharCode(d));return j=UTF8.decode(j),j}},UTF8={encode:function(a){for(var b,d="",e=0;e<a.length;e++)b=a.charCodeAt(e),128>b?d+=String.fromCharCode(b):127<b&&2048>b?(d+=String.fromCharCode(192|b>>6),d+=String.fromCharCode(128|63&b)):(d+=String.fromCharCode(224|b>>12),d+=String.fromCharCode(128|63&b>>6),d+=String.fromCharCode(128|63&b));return d},decode:function(a){for(var b="",d=0,e=0,f=0,g=0;d<a.length;)e=a.charCodeAt(d),128>e?(b+=String.fromCharCode(e),d++):191<e&&224>e?(f=a.charCodeAt(d+1),b+=String.fromCharCode((31&e)<<6|63&f),d+=2):(f=a.charCodeAt(d+1),g=a.charCodeAt(d+2),b+=String.fromCharCode((15&e)<<12|(63&f)<<6|63&g),d+=3);return b}};var Polyfill = {// forEach polyfill
7
7
  // Production steps of ECMA-262, Edition 5, 15.4.4.18
8
8
  // Reference: http://es5.github.io/#x15.4.4.18
9
- forEach:function forEach(a,b){var c,d;if(null==this)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(1<arguments.length&&(c=b),d=0;d<f;){var g;d in e&&(g=e[d],a.call(c,g,d,e)),d++;}},// map polyfill
9
+ forEach:function forEach(a,b){var c,d;if(null==this)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(1<arguments.length&&(c=b),d=0;d<f;){var g=void 0;d in e&&(g=e[d],a.call(c,g,d,e)),d++;}},// map polyfill
10
10
  // Production steps of ECMA-262, Edition 5, 15.4.4.19
11
11
  // Reference: http://es5.github.io/#x15.4.4.19
12
- map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is null or not defined");var f=Object(this),g=f.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(1<arguments.length&&(c=b),d=Array(g),e=0;e<g;){var h,i;e in f&&(h=f[e],i=a.call(c,h,e,f),d[e]=i),e++;}return d},// filter polyfill
12
+ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is null or not defined");var f=Object(this),g=f.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(1<arguments.length&&(c=b),d=Array(g),e=0;e<g;){var h=void 0,i=void 0;e in f&&(h=f[e],i=a.call(c,h,e,f),d[e]=i),e++;}return d},// filter polyfill
13
13
  // Prodcution steps of ECMA-262, Edition 5
14
14
  // Reference: http://es5.github.io/#x15.4.4.20
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.79.0";
18
+ var version = "2.79.1";
19
19
 
20
20
  var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"is a deprecated method and will be removed in future releases.",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",AddToCart:"addToCart",RemoveFromCart:"removeFromCart",ClearCart:"clearCart",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",localStorageProductsV4:"mprtcl-prodv4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4",currentStorageProductsName:"mprtcl-prodv4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,maxProducts:20,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
21
21
  },DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},// These are the paths that are used to construct the CNAME urls
@@ -617,11 +617,11 @@ if(!g||a._Store.requireDelay||!a._Store.configurationLoaded)return a.Logger.verb
617
617
 
618
618
  var KitFilterHelper=/** @class */function(){function a(){}a.hashEventType=function(a){return generateHash(a)},a.hashEventName=function(a,b){return generateHash(b+a)},a.hashEventAttributeKey=function(a,b,c){return generateHash(a+b+c)},a.hashUserAttribute=function(a){return generateHash(a)},a.hashUserIdentity=function(a){return a},a.hashConsentPurpose=function(a,b){return generateHash(a+b)},a.hashAttributeConditionalForwarding=function(a){return generateHash(a).toString()},a.hashConsentPurposeConditionalForwarding=function(a,b){return this.hashConsentPurpose(a,b).toString()};var b;return b=a,a.filterUserAttributes=function(a,c){return filterDictionaryWithHash(a,c,function(a){return b.hashUserAttribute(a)})},a.filterUserIdentities=function(a,c){return filterDictionaryWithHash(a,c,function(a){return b.hashUserIdentity(IdentityType.getIdentityType(a))})},a.isFilteredUserAttribute=function(a,c){var d=b.hashUserAttribute(a);return c&&inArray(c,d)},a}();
619
619
 
620
- var StorageNames$1=Constants.StorageNames;function Helpers(a){var b=this;// TODO: Refactor SDK to directly use these methods
620
+ var StorageNames$1=Constants.StorageNames;function appendFilteredUserIdentity(a,b,c){c===Types.IdentityType.CustomerId?a.unshift(b):a.push(b);}function buildFilteredUserIdentities(a,b,c){var d=[];if(!a||!Object.keys(a).length)return d;for(var e in a)if(a.hasOwnProperty(e)){var f=Types.IdentityType.getIdentityType(e);c(b,f)||appendFilteredUserIdentity(d,{Type:f,Identity:a[e]},f);}return d}function Helpers(a){var b=this;// TODO: Refactor SDK to directly use these methods
621
621
  // https://go.mparticle.com/work/SQDSDKS-5239
622
622
  // Utility Functions
623
623
  // Imported Validators
624
- this.canLog=function(){return !!(a._Store.isEnabled&&(a._Store.devToken||a._Store.webviewBridgeEnabled))},this.getFeatureFlag=function(b){return a._Store.SDKConfig.flags.hasOwnProperty(b)?a._Store.SDKConfig.flags[b]:null},this.invokeCallback=function(c,d,e,f,g){c||a.Logger.warning("There is no callback provided");try{b.Validators.isFunction(c)&&c({httpCode:d,body:e,getUser:function getUser(){return f?f:a.Identity.getCurrentUser()},getPreviousUser:function getPreviousUser(){if(!g){var b=a.Identity.getUsers(),c=b.shift(),d=f||a.Identity.getCurrentUser();return c&&d&&c.getMPID()===d.getMPID()&&(c=b.shift()),c||null}return a.Identity.getUser(g)}});}catch(b){a.Logger.error("There was an error with your callback: "+b);}},this.invokeAliasCallback=function(c,d,e){c||a.Logger.warning("There is no callback provided");try{if(b.Validators.isFunction(c)){var f={httpCode:d};e&&(f.message=e),c(f);}}catch(b){a.Logger.error("There was an error with your callback: "+b);}},this.extend=extend,this.createServiceUrl=function(b,c){var d,e=window.mParticle&&a._Store.SDKConfig.forceHttps?"https://":window.location.protocol+"//";return d=a._Store.SDKConfig.forceHttps?"https://"+b:e+b,c&&(d+=c),d},this.createXHR=function(b){var c;try{c=new window.XMLHttpRequest;}catch(b){a.Logger.error("Error creating XMLHttpRequest object.");}if(c&&b&&"withCredentials"in c)c.onreadystatechange=b;else if("undefined"!=typeof window.XDomainRequest){a.Logger.verbose("Creating XDomainRequest object");try{c=new window.XDomainRequest,c.onload=b;}catch(b){a.Logger.error("Error creating XDomainRequest object");}}return c},this.filterUserIdentities=function(a,c){var d=[];if(a&&Object.keys(a).length)for(var e in a)if(a.hasOwnProperty(e)){var f=Types.IdentityType.getIdentityType(e);if(!b.inArray(c,f)){var g={Type:f,Identity:a[e]};f===Types.IdentityType.CustomerId?d.unshift(g):d.push(g);}}return d},this.filterUserIdentitiesForForwarders=KitFilterHelper.filterUserIdentities,this.filterUserAttributes=KitFilterHelper.filterUserAttributes,this.isEventType=function(a){for(var b in Types.EventType)if(Types.EventType.hasOwnProperty(b)&&Types.EventType[b]===a)return !0;return !1},this.sanitizeAttributes=function(c,d){if(!c||!b.isObject(c))return null;var e={};for(var f in c)// Make sure that attribute values are not objects or arrays, which are not valid
624
+ this.canLog=function(){return !!(a._Store.isEnabled&&(a._Store.devToken||a._Store.webviewBridgeEnabled))},this.getFeatureFlag=function(b){return a._Store.SDKConfig.flags.hasOwnProperty(b)?a._Store.SDKConfig.flags[b]:null},this.invokeCallback=function(c,d,e,f,g){c||a.Logger.warning("There is no callback provided");try{b.Validators.isFunction(c)&&c({httpCode:d,body:e,getUser:function getUser(){return f?f:a.Identity.getCurrentUser()},getPreviousUser:function getPreviousUser(){if(!g){var b=a.Identity.getUsers(),c=b.shift(),d=f||a.Identity.getCurrentUser();return c&&d&&c.getMPID()===d.getMPID()&&(c=b.shift()),c||null}return a.Identity.getUser(g)}});}catch(b){a.Logger.error("There was an error with your callback: "+b);}},this.invokeAliasCallback=function(c,d,e){c||a.Logger.warning("There is no callback provided");try{if(b.Validators.isFunction(c)){var f={httpCode:d};e&&(f.message=e),c(f);}}catch(b){a.Logger.error("There was an error with your callback: "+b);}},this.extend=extend,this.createServiceUrl=function(b,c){var d,e=window.mParticle&&a._Store.SDKConfig.forceHttps?"https://":window.location.protocol+"//";return d=a._Store.SDKConfig.forceHttps?"https://"+b:e+b,c&&(d+=c),d},this.createXHR=function(b){var c;try{c=new window.XMLHttpRequest;}catch(b){a.Logger.error("Error creating XMLHttpRequest object.");}if(c&&b&&"withCredentials"in c)c.onreadystatechange=b;else if("undefined"!=typeof window.XDomainRequest){a.Logger.verbose("Creating XDomainRequest object");try{c=new window.XDomainRequest,c.onload=b;}catch(b){a.Logger.error("Error creating XDomainRequest object");}}return c},this.filterUserIdentities=function(a,c){return buildFilteredUserIdentities(a,c,b.inArray)},this.filterUserIdentitiesForForwarders=KitFilterHelper.filterUserIdentities,this.filterUserAttributes=KitFilterHelper.filterUserAttributes,this.isEventType=function(a){for(var b in Types.EventType)if(Types.EventType.hasOwnProperty(b)&&Types.EventType[b]===a)return !0;return !1},this.sanitizeAttributes=function(c,d){if(!c||!b.isObject(c))return null;var e={};for(var f in c)// Make sure that attribute values are not objects or arrays, which are not valid
625
625
  c.hasOwnProperty(f)&&b.Validators.isValidAttributeValue(c[f])?e[f]=c[f]:a.Logger.warning("For '"+d+"', the corresponding attribute value of '"+f+"' must be a string, number, boolean, or null.");return e},this.isDelayedByIntegration=function(b,c,d){if(d-c>a._Store.SDKConfig.integrationDelayTimeout)return !1;for(var e in b){if(!0===b[e])return !0;continue}return !1},this.createMainStorageName=function(a){return a?StorageNames$1.currentStorageName+"_"+a:StorageNames$1.currentStorageName},this.converted=converted,this.findKeyInObject=findKeyInObject,this.parseNumber=parseNumber,this.inArray=inArray,this.isObject=isObject,this.decoded=decoded,this.parseStringOrNumber=parseStringOrNumber,this.generateHash=generateHash,this.generateUniqueId=generateUniqueId,this.Validators=Validators;}
626
626
 
627
627
  var Messages$8=Constants.Messages,androidBridgeNameBase="mParticleAndroid",iosBridgeNameBase="mParticle";function NativeSdkHelpers(a){var b=this;this.initializeSessionAttributes=function(a){var c=Constants.NativeSdkPaths.SetSessionAttribute,d=JSON.stringify({key:"$src_env",value:"webview"}),e=JSON.stringify({key:"$src_key",value:a});b.sendToNative(c,d),a&&b.sendToNative(c,e);},this.isBridgeV2Available=function(a){if(!a)return !1;var b=iosBridgeNameBase+"_"+a+"_v2";// iOS v2 bridge
@@ -792,7 +792,7 @@ c(b),b=null,a._Store.isTracking=!1;}));else {var d={coords:{latitude:a._Store.cu
792
792
  // null, resulting in kit forwarding errors on the server.
793
793
  // The check for `ProductAction` is required to denote that these are
794
794
  // ProductAction events, and not impression or promotions
795
- return a.Logger.verbose(Messages$3.InformationMessages.StartingLogCommerceEvent),b.ProductAction&&null===b.EventCategory?void a.Logger.error("Commerce event not sent. The mParticle.ProductActionType you passed was invalid. Re-check your code."):void(c=a._Helpers.sanitizeAttributes(c,b.EventName),a._Helpers.canLog()?(a._Store.webviewBridgeEnabled&&(b.ShoppingCart={}),c&&(b.EventAttributes=c),b.ProductAction&&a._Ecommerce.calculateProductActionTotalAmount(b.ProductAction),a._APIClient.sendEventToServer(b,d),a._Persistence.update()):a.Logger.verbose(Messages$3.InformationMessages.AbandonLogEvent))},this.addEventHandler=function(c,d,f,g,h){var j,k,e=[],l=function handler(c){var d=function timeoutHandler(){j.href?window.location.href=j.href:j.submit&&j.submit();};a.Logger.verbose("DOM event triggered, handling event"),b.logEvent({messageType:Types.MessageType.PageEvent,name:"function"==typeof f?f(j):f,data:"function"==typeof g?g(j):g,eventType:h||Types.EventType.Other}),(j.href&&"_blank"!==j.target||j.submit)&&(c.preventDefault?c.preventDefault():c.returnValue=!1,setTimeout(d,a._Store.SDKConfig.timeout));};if(!d)return void a.Logger.error("Can't bind event, selector is required");// Handle a css selector string or a dom element
795
+ if(a.Logger.verbose(Messages$3.InformationMessages.StartingLogCommerceEvent),b.ProductAction&&null===b.EventCategory)return void a.Logger.error("Commerce event not sent. The mParticle.ProductActionType you passed was invalid. Re-check your code.");var e=a._Helpers.sanitizeAttributes(c,b.EventName);a._Helpers.canLog()?(a._Store.webviewBridgeEnabled&&(b.ShoppingCart={}),e&&(b.EventAttributes=e),b.ProductAction&&a._Ecommerce.calculateProductActionTotalAmount(b.ProductAction),a._APIClient.sendEventToServer(b,d),a._Persistence.update()):a.Logger.verbose(Messages$3.InformationMessages.AbandonLogEvent);},this.addEventHandler=function(c,d,f,g,h){var j,k,e=[],l=function handler(c){var d=function timeoutHandler(){j.href?window.location.href=j.href:j.submit&&j.submit();};a.Logger.verbose("DOM event triggered, handling event"),b.logEvent({messageType:Types.MessageType.PageEvent,name:"function"==typeof f?f(j):f,data:"function"==typeof g?g(j):g,eventType:h||Types.EventType.Other}),(j.href&&"_blank"!==j.target||j.submit)&&(c.preventDefault?c.preventDefault():c.returnValue=!1,setTimeout(d,a._Store.SDKConfig.timeout));};if(!d)return void a.Logger.error("Can't bind event, selector is required");// Handle a css selector string or a dom element
796
796
  if("string"==typeof d?e=document.querySelectorAll(d):d.nodeType&&(e=[d]),e.length)for(a.Logger.verbose("Found "+e.length+" element"+(1<e.length?"s":"")+", attaching event handlers"),k=0;k<e.length;k++)j=e[k],j.addEventListener?j.addEventListener(c,l,!1):j.attachEvent?j.attachEvent("on"+c,l):j["on"+c]=l;else a.Logger.verbose("No elements found");};}
797
797
 
798
798
  function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
package/dist/mparticle.js CHANGED
@@ -134,7 +134,7 @@ var mParticle = (function () {
134
134
  }
135
135
  k = 0;
136
136
  while (k < len) {
137
- var kValue;
137
+ var kValue = void 0;
138
138
  if (k in O) {
139
139
  kValue = O[k];
140
140
  callback.call(T, kValue, k, O);
@@ -161,7 +161,8 @@ var mParticle = (function () {
161
161
  A = new Array(len);
162
162
  k = 0;
163
163
  while (k < len) {
164
- var kValue, mappedValue;
164
+ var kValue = void 0,
165
+ mappedValue = void 0;
165
166
  if (k in O) {
166
167
  kValue = O[k];
167
168
  mappedValue = callback.call(T, kValue, k, O);
@@ -203,7 +204,7 @@ var mParticle = (function () {
203
204
  Base64: Base64$1
204
205
  };
205
206
 
206
- var version = "2.79.0";
207
+ var version = "2.79.1";
207
208
 
208
209
  var Constants = {
209
210
  sdkVersion: version,
@@ -3858,6 +3859,33 @@ var mParticle = (function () {
3858
3859
  }();
3859
3860
 
3860
3861
  var StorageNames$1 = Constants.StorageNames;
3862
+ function appendFilteredUserIdentity(filteredUserIdentities, identity, userIdentityType) {
3863
+ if (userIdentityType === Types.IdentityType.CustomerId) {
3864
+ filteredUserIdentities.unshift(identity);
3865
+ } else {
3866
+ filteredUserIdentities.push(identity);
3867
+ }
3868
+ }
3869
+ function buildFilteredUserIdentities(userIdentitiesObject, filterList, inArray) {
3870
+ var filteredUserIdentities = [];
3871
+ if (!userIdentitiesObject || !Object.keys(userIdentitiesObject).length) {
3872
+ return filteredUserIdentities;
3873
+ }
3874
+ for (var userIdentityName in userIdentitiesObject) {
3875
+ if (!userIdentitiesObject.hasOwnProperty(userIdentityName)) {
3876
+ continue;
3877
+ }
3878
+ var userIdentityType = Types.IdentityType.getIdentityType(userIdentityName);
3879
+ if (inArray(filterList, userIdentityType)) {
3880
+ continue;
3881
+ }
3882
+ appendFilteredUserIdentity(filteredUserIdentities, {
3883
+ Type: userIdentityType,
3884
+ Identity: userIdentitiesObject[userIdentityName]
3885
+ }, userIdentityType);
3886
+ }
3887
+ return filteredUserIdentities;
3888
+ }
3861
3889
  function Helpers(mpInstance) {
3862
3890
  var self = this;
3863
3891
  this.canLog = function () {
@@ -3960,26 +3988,7 @@ var mParticle = (function () {
3960
3988
  return xhr;
3961
3989
  };
3962
3990
  this.filterUserIdentities = function (userIdentitiesObject, filterList) {
3963
- var filteredUserIdentities = [];
3964
- if (userIdentitiesObject && Object.keys(userIdentitiesObject).length) {
3965
- for (var userIdentityName in userIdentitiesObject) {
3966
- if (userIdentitiesObject.hasOwnProperty(userIdentityName)) {
3967
- var userIdentityType = Types.IdentityType.getIdentityType(userIdentityName);
3968
- if (!self.inArray(filterList, userIdentityType)) {
3969
- var identity = {
3970
- Type: userIdentityType,
3971
- Identity: userIdentitiesObject[userIdentityName]
3972
- };
3973
- if (userIdentityType === Types.IdentityType.CustomerId) {
3974
- filteredUserIdentities.unshift(identity);
3975
- } else {
3976
- filteredUserIdentities.push(identity);
3977
- }
3978
- }
3979
- }
3980
- }
3981
- }
3982
- return filteredUserIdentities;
3991
+ return buildFilteredUserIdentities(userIdentitiesObject, filterList, self.inArray);
3983
3992
  };
3984
3993
  this.filterUserIdentitiesForForwarders = KitFilterHelper.filterUserIdentities;
3985
3994
  this.filterUserAttributes = KitFilterHelper.filterUserAttributes;
@@ -4028,7 +4037,6 @@ var mParticle = (function () {
4028
4037
  return StorageNames$1.currentStorageName;
4029
4038
  }
4030
4039
  };
4031
-
4032
4040
  // TODO: Refactor SDK to directly use these methods
4033
4041
  // https://go.mparticle.com/work/SQDSDKS-5239
4034
4042
  // Utility Functions
@@ -4041,7 +4049,6 @@ var mParticle = (function () {
4041
4049
  this.parseStringOrNumber = parseStringOrNumber;
4042
4050
  this.generateHash = generateHash;
4043
4051
  this.generateUniqueId = generateUniqueId;
4044
-
4045
4052
  // Imported Validators
4046
4053
  this.Validators = Validators;
4047
4054
  }
@@ -6502,7 +6509,6 @@ var mParticle = (function () {
6502
6509
  };
6503
6510
  this.logCommerceEvent = function (commerceEvent, attrs, options) {
6504
6511
  mpInstance.Logger.verbose(Messages$3.InformationMessages.StartingLogCommerceEvent);
6505
-
6506
6512
  // If a developer typos the ProductActionType, the event category will be
6507
6513
  // null, resulting in kit forwarding errors on the server.
6508
6514
  // The check for `ProductAction` is required to denote that these are
@@ -6511,23 +6517,21 @@ var mParticle = (function () {
6511
6517
  mpInstance.Logger.error('Commerce event not sent. The mParticle.ProductActionType you passed was invalid. Re-check your code.');
6512
6518
  return;
6513
6519
  }
6514
- attrs = mpInstance._Helpers.sanitizeAttributes(attrs, commerceEvent.EventName);
6520
+ var sanitizedAttrs = mpInstance._Helpers.sanitizeAttributes(attrs, commerceEvent.EventName);
6515
6521
  if (mpInstance._Helpers.canLog()) {
6516
6522
  if (mpInstance._Store.webviewBridgeEnabled) {
6517
6523
  // Don't send shopping cart to parent sdks
6518
6524
  commerceEvent.ShoppingCart = {};
6519
6525
  }
6520
- if (attrs) {
6521
- commerceEvent.EventAttributes = attrs;
6526
+ if (sanitizedAttrs) {
6527
+ commerceEvent.EventAttributes = sanitizedAttrs;
6522
6528
  }
6523
-
6524
6529
  // When no transaction total (Revenue) was provided, derive it from
6525
6530
  // the products, shipping, and tax.
6526
6531
  if (commerceEvent.ProductAction) {
6527
6532
  mpInstance._Ecommerce.calculateProductActionTotalAmount(commerceEvent.ProductAction);
6528
6533
  }
6529
6534
  mpInstance._APIClient.sendEventToServer(commerceEvent, options);
6530
-
6531
6535
  // https://go.mparticle.com/work/SQDSDKS-6038
6532
6536
  mpInstance._Persistence.update();
6533
6537
  } else {
@@ -6551,11 +6555,9 @@ var mParticle = (function () {
6551
6555
  data: typeof data === 'function' ? data(element) : data,
6552
6556
  eventType: eventType || Types.EventType.Other
6553
6557
  });
6554
-
6555
6558
  // TODO: Handle middle-clicks and special keys (ctrl, alt, etc)
6556
6559
  if (element.href && element.target !== '_blank' || element.submit) {
6557
6560
  // Give xmlhttprequest enough time to execute before navigating a link or submitting form
6558
-
6559
6561
  if (e.preventDefault) {
6560
6562
  e.preventDefault();
6561
6563
  } else {
@@ -6570,7 +6572,6 @@ var mParticle = (function () {
6570
6572
  mpInstance.Logger.error("Can't bind event, selector is required");
6571
6573
  return;
6572
6574
  }
6573
-
6574
6575
  // Handle a css selector string or a dom element
6575
6576
  if (typeof selector === 'string') {
6576
6577
  elements = document.querySelectorAll(selector);
@@ -1,8 +1,8 @@
1
1
  import { ProductAction, Product, Promotion, CommerceEvent } from '@mparticle/event-models';
2
2
  import { SDKEventAttrs, SDKEventOptions, TransactionAttributes } from '@mparticle/web-sdk';
3
3
  import { valueof } from './utils';
4
- import { ProductActionType, PromotionActionType, CommerceEventType, EventType } from './types';
5
- import { SDKEvent, SDKEventCustomFlags, SDKImpression, SDKProduct, SDKProductImpression, SDKPromotion } from './sdkRuntimeModels';
4
+ import { ProductActionType, PromotionActionType } from './types';
5
+ import { SDKEvent, SDKEventCustomFlags, SDKImpression, SDKProduct, SDKProductAction, SDKPromotion } from './sdkRuntimeModels';
6
6
  interface IECommerceShared {
7
7
  createProduct(name: string, sku: string | number, price: string | number, quantity?: string | number, variant?: string, category?: string, brand?: string, position?: number, couponCode?: string, attributes?: SDKEventAttrs): SDKProduct | null;
8
8
  createImpression(name: string, product: Product): SDKImpression | null;
@@ -17,7 +17,7 @@ export interface SDKCart {
17
17
  }
18
18
  export interface SDKECommerceAPI extends IECommerceShared {
19
19
  logCheckout(step: number, option?: string, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags): void;
20
- logImpression(impression: SDKProductImpression, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
20
+ logImpression(impression: SDKImpression | SDKImpression[], attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
21
21
  logProductAction(productActionType: valueof<typeof ProductActionType>, product: SDKProduct | SDKProduct[], attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, transactionAttributes?: TransactionAttributes, eventOptions?: SDKEventOptions): void;
22
22
  logPromotion(type: valueof<typeof PromotionActionType>, promotion: SDKPromotion, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
23
23
  setCurrencyCode(code: string): void;
@@ -57,11 +57,12 @@ interface ExtractedTransactionId {
57
57
  'Transaction ID'?: string;
58
58
  }
59
59
  export interface IECommerce extends IECommerceShared {
60
- buildProductList(event: SDKEvent, product: Product | Product[]): Product[];
60
+ buildProductList(event: SDKEvent, product: SDKProduct | SDKProduct[]): SDKProduct[];
61
61
  convertProductActionToEventType(productActionType: valueof<typeof ProductActionType>): // https://go.mparticle.com/work/SQDSDKS-4801
62
- typeof CommerceEventType | typeof EventType | null;
63
- convertPromotionActionToEventType(promotionActionType: valueof<typeof PromotionActionType>): typeof CommerceEventType | null;
64
- convertTransactionAttributesToProductAction(transactionAttributes: TransactionAttributes, productAction: ProductAction): void;
62
+ number | null;
63
+ convertPromotionActionToEventType(promotionActionType: valueof<typeof PromotionActionType>): number | null;
64
+ calculateProductActionTotalAmount(productAction: SDKProductAction): SDKProductAction;
65
+ convertTransactionAttributesToProductAction(transactionAttributes: TransactionAttributes, productAction: SDKProductAction): void;
65
66
  createCommerceEventObject(customFlags: SDKEventCustomFlags, options?: SDKEventOptions): SDKEvent | null;
66
67
  expandProductAction(commerceEvent: CommerceEvent): SDKEvent[];
67
68
  expandProductImpression(commerceEvent: CommerceEvent): SDKEvent[];
@@ -1,18 +1,3 @@
1
- export default function Events(mpInstance: any): void;
2
- export default class Events {
3
- constructor(mpInstance: any);
4
- logEvent: (event: any, options: any) => void;
5
- startTracking: (callback: any) => void;
6
- stopTracking: () => void;
7
- logOptOut: () => void;
8
- logAST: () => void;
9
- logPageView: () => void;
10
- logCheckoutEvent: (step: any, option: any, attrs: any, customFlags: any) => void;
11
- logProductActionEvent: (productActionType: any, product: any, customAttrs: any, customFlags: any, transactionAttributes: any, options: any) => void;
12
- logPurchaseEvent: (transactionAttributes: any, product: any, attrs: any, customFlags: any) => void;
13
- logRefundEvent: (transactionAttributes: any, product: any, attrs: any, customFlags: any) => void;
14
- logPromotionEvent: (promotionType: any, promotion: any, attrs: any, customFlags: any, eventOptions: any) => void;
15
- logImpressionEvent: (impression: any, attrs: any, customFlags: any, options: any) => void;
16
- logCommerceEvent: (commerceEvent: any, attrs: any, options: any) => void;
17
- addEventHandler: (domEvent: any, selector: any, eventName: any, data: any, eventType: any) => void;
18
- }
1
+ import { IEvents } from './events.interfaces';
2
+ import { IMParticleWebSDKInstance } from './mp-instance';
3
+ export default function Events(this: IEvents, mpInstance: IMParticleWebSDKInstance): void;
@@ -1,5 +1,5 @@
1
1
  import { Callback, SDKEventAttrs, SDKEventOptions, TransactionAttributes } from '@mparticle/web-sdk';
2
- import { BaseEvent, SDKEvent, SDKEventCustomFlags, SDKProduct, SDKProductImpression, SDKPromotion } from './sdkRuntimeModels';
2
+ import { BaseEvent, SDKEvent, SDKEventCustomFlags, SDKImpression, SDKProduct, SDKPromotion } from './sdkRuntimeModels';
3
3
  import { valueof } from './utils';
4
4
  import { EventType, ProductActionType, PromotionActionType } from './types';
5
5
  type EventHandlerFunction<T> = (element: HTMLLinkElement | HTMLFormElement) => T;
@@ -9,7 +9,7 @@ export interface IEvents {
9
9
  logCheckoutEvent(step: number, option?: string, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags): void;
10
10
  logCommerceEvent(commerceEvent: SDKEvent, attrs?: SDKEventAttrs, options?: SDKEventOptions): void;
11
11
  logEvent(event: BaseEvent, eventOptions?: SDKEventOptions): void;
12
- logImpressionEvent(impression: SDKProductImpression, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): any;
12
+ logImpressionEvent(impression: SDKImpression | SDKImpression[], attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
13
13
  logOptOut(): void;
14
14
  logPageView(): void;
15
15
  logProductActionEvent(productActionType: valueof<typeof ProductActionType>, product: SDKProduct | SDKProduct[], attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, transactionAttributes?: TransactionAttributes, eventOptions?: SDKEventOptions): void;
@@ -1,54 +1,3 @@
1
- export default function Helpers(mpInstance: any): void;
2
- export default class Helpers {
3
- constructor(mpInstance: any);
4
- canLog: () => boolean;
5
- getFeatureFlag: (feature: any) => any;
6
- invokeCallback: (callback: any, code: any, body: any, mParticleUser: any, previousMpid: any) => void;
7
- invokeAliasCallback: (callback: any, code: any, message: any) => void;
8
- extend: typeof utils.extend;
9
- createServiceUrl: (secureServiceUrl: any, devToken: any) => string;
10
- createXHR: (cb: any) => any;
11
- filterUserIdentities: (userIdentitiesObject: any, filterList: any) => {
12
- Type: any;
13
- Identity: any;
14
- }[];
15
- filterUserIdentitiesForForwarders: (userIdentities: utils.Dictionary<string>, filterList: number[]) => utils.Dictionary<string>;
16
- filterUserAttributes: (userAttributes: utils.Dictionary<string>, filterList: number[]) => utils.Dictionary<string>;
17
- isEventType: (type: any) => boolean;
18
- sanitizeAttributes: (attrs: any, name: any) => {};
19
- isDelayedByIntegration: (delayedIntegrations: any, timeoutStart: any, now: any) => boolean;
20
- createMainStorageName: (workspaceToken: any) => string;
21
- converted: (s: string) => string;
22
- findKeyInObject: (obj: any, key: string) => string;
23
- parseNumber: (value: string | number) => number;
24
- inArray: (items: any[], name: any) => boolean;
25
- isObject: (value: any) => boolean;
26
- decoded: (s: string) => string;
27
- parseStringOrNumber: (value: string | number) => string | number;
28
- generateHash: typeof utils.generateHash;
29
- generateUniqueId: (a?: string) => string;
30
- Validators: {
31
- isNumber: (value: any) => boolean;
32
- isFunction: (fn: any) => boolean;
33
- isStringOrNumber: (value: any) => boolean;
34
- isValidAttributeValue: (value: any) => boolean;
35
- isValidKeyValue: (key: any) => boolean;
36
- removeFalsyIdentityValues: (identityApiData: import("@mparticle/web-sdk").IdentityApiData, logger: any) => import("@mparticle/web-sdk").IdentityApiData;
37
- validateIdentities: (identityApiData: import("@mparticle/web-sdk").IdentityApiData, method?: import("./identity.interfaces").IdentityAPIMethod) => {
38
- valid: boolean;
39
- error?: utils.valueof<{
40
- readonly ModifyIdentityRequestUserIdentitiesPresent: "identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again";
41
- readonly 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.";
42
- readonly OnUserAliasType: "The onUserAlias value must be a function.";
43
- readonly 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.";
44
- readonly UserIdentitiesInvalidKey: "There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.";
45
- readonly UserIdentitiesInvalidValues: "All user identity values must be strings or null. Request not sent to server. Please fix and try again.";
46
- readonly AliasMissingMpid: "Alias Request must contain both a destinationMpid and a sourceMpid";
47
- readonly AliasNonUniqueMpid: "Alias Request's destinationMpid and sourceMpid must be unique";
48
- readonly AliasMissingTime: "Alias Request must have both a startTime and an endTime";
49
- readonly AliasStartBeforeEndTime: "Alias Request's endTime must be later than its startTime";
50
- }>;
51
- };
52
- };
53
- }
54
- import * as utils from './utils';
1
+ import { IMParticleWebSDKInstance } from './mp-instance';
2
+ import { SDKHelpersApi } from './sdkRuntimeModels';
3
+ export default function Helpers(this: SDKHelpersApi, mpInstance: IMParticleWebSDKInstance): void;
@@ -1,15 +1,14 @@
1
- declare namespace _default {
2
- export function forEach(callback: any, thisArg: any, ...args: any[]): void;
3
- export function map(callback: any, thisArg: any, ...args: any[]): any[];
4
- export function filter(fun: any, ...args: any[]): any[];
5
- export function isArray(arg: any): boolean;
6
- export { Base64 };
7
- }
1
+ declare const _default: {
2
+ forEach: (callback: any, thisArg: any) => void;
3
+ map: (callback: any, thisArg: any) => any;
4
+ filter: (fun: any) => any[];
5
+ isArray: (arg: unknown) => boolean;
6
+ Base64: {
7
+ _keyStr: string;
8
+ encode: (input: string) => string;
9
+ _encode: (input: string) => string;
10
+ decode: (input: string) => string;
11
+ _decode: (input: string) => string;
12
+ };
13
+ };
8
14
  export default _default;
9
- declare namespace Base64 {
10
- let _keyStr: string;
11
- function encode(input: any): string;
12
- function _encode(input: any): string;
13
- function decode(input: any): string;
14
- function _decode(input: any): string;
15
- }
@@ -186,7 +186,7 @@ export interface MParticleWebSDK {
186
186
  setOptOut(isOptingOut: boolean): void;
187
187
  startTrackingLocation(callback?: Callback): void;
188
188
  stopTrackingLocation(): void;
189
- generateHash(value: string): string;
189
+ generateHash(value: string): number;
190
190
  setIntegrationAttribute(integrationModuleId: number, attrs: IntegrationAttribute): void;
191
191
  getIntegrationAttributes(integrationModuleId: number): IntegrationAttribute;
192
192
  captureTiming(metricName: string): void;
@@ -262,9 +262,16 @@ export interface SDKHelpersApi {
262
262
  findKeyInObject?(obj: any, key: string): string;
263
263
  parseNumber?(value: string | number): number;
264
264
  generateUniqueId(): any;
265
- generateHash?(value: string): string;
265
+ generateHash?(value: string): number;
266
266
  getFeatureFlag?(feature: string): boolean | string;
267
- invokeAliasCallback(aliasCallback: IAliasCallback, number: number, errorMessage: string): void;
267
+ decoded?(s: string): string;
268
+ parseStringOrNumber?(value: string | number): string | number | null;
269
+ inArray?(items: any[], value: any): boolean;
270
+ converted?(s: string): string;
271
+ filterUserIdentitiesForForwarders?(userIdentities: Dictionary, filterList: number[]): Dictionary;
272
+ filterUserAttributes?(userAttributes: Dictionary, filterList: number[]): Dictionary;
273
+ filterUserIdentities?(userIdentitiesObject: Dictionary<string>, filterList: number[]): ISDKUserIdentity[];
274
+ invokeAliasCallback(aliasCallback: IAliasCallback, number: number, errorMessage?: string): void;
268
275
  isDelayedByIntegration?(delayedIntegrations: Dictionary<boolean>, timeoutStart: number, now: number): boolean;
269
276
  isEventType?(type: valueof<typeof EventType>): boolean;
270
277
  isObject?(item: any): any;
@@ -47,6 +47,7 @@ export interface SDKConfig {
47
47
  maxProducts: number;
48
48
  requestConfig?: boolean;
49
49
  sessionTimeout?: number;
50
+ timeout?: number;
50
51
  useNativeSdk?: boolean;
51
52
  useCookieStorage?: boolean;
52
53
  v1SecureServiceUrl?: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-sdk",
3
- "version": "2.79.0",
3
+ "version": "2.79.1",
4
4
  "description": "mParticle core SDK for web applications",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -13,15 +13,13 @@ import { valueof } from './utils';
13
13
  import {
14
14
  ProductActionType,
15
15
  PromotionActionType,
16
- CommerceEventType,
17
- EventType,
18
16
  } from './types';
19
17
  import {
20
18
  SDKEvent,
21
19
  SDKEventCustomFlags,
22
20
  SDKImpression,
23
21
  SDKProduct,
24
- SDKProductImpression,
22
+ SDKProductAction,
25
23
  SDKPromotion,
26
24
  } from './sdkRuntimeModels';
27
25
 
@@ -71,7 +69,7 @@ export interface SDKECommerceAPI extends IECommerceShared {
71
69
  customFlags?: SDKEventCustomFlags
72
70
  ): void;
73
71
  logImpression(
74
- impression: SDKProductImpression,
72
+ impression: SDKImpression | SDKImpression[],
75
73
  attrs?: SDKEventAttrs,
76
74
  customFlags?: SDKEventCustomFlags,
77
75
  eventOptions?: SDKEventOptions
@@ -155,17 +153,23 @@ interface ExtractedTransactionId {
155
153
 
156
154
  // Used for the private `_Ecommerce` namespace
157
155
  export interface IECommerce extends IECommerceShared {
158
- buildProductList(event: SDKEvent, product: Product | Product[]): Product[];
156
+ buildProductList(
157
+ event: SDKEvent,
158
+ product: SDKProduct | SDKProduct[]
159
+ ): SDKProduct[];
159
160
  convertProductActionToEventType(
160
161
  productActionType: valueof<typeof ProductActionType>
161
162
  ): // https://go.mparticle.com/work/SQDSDKS-4801
162
- typeof CommerceEventType | typeof EventType | null;
163
+ number | null;
163
164
  convertPromotionActionToEventType(
164
165
  promotionActionType: valueof<typeof PromotionActionType>
165
- ): typeof CommerceEventType | null;
166
+ ): number | null;
167
+ calculateProductActionTotalAmount(
168
+ productAction: SDKProductAction
169
+ ): SDKProductAction;
166
170
  convertTransactionAttributesToProductAction(
167
171
  transactionAttributes: TransactionAttributes,
168
- productAction: ProductAction
172
+ productAction: SDKProductAction
169
173
  ): void;
170
174
  createCommerceEventObject(
171
175
  customFlags: SDKEventCustomFlags,
@@ -8,8 +8,8 @@ import {
8
8
  BaseEvent,
9
9
  SDKEvent,
10
10
  SDKEventCustomFlags,
11
+ SDKImpression,
11
12
  SDKProduct,
12
- SDKProductImpression,
13
13
  SDKPromotion,
14
14
  } from './sdkRuntimeModels';
15
15
  import { valueof } from './utils';
@@ -45,11 +45,11 @@ export interface IEvents {
45
45
  ): void;
46
46
  logEvent(event: BaseEvent, eventOptions?: SDKEventOptions): void;
47
47
  logImpressionEvent(
48
- impression: SDKProductImpression,
48
+ impression: SDKImpression | SDKImpression[],
49
49
  attrs?: SDKEventAttrs,
50
50
  customFlags?: SDKEventCustomFlags,
51
51
  eventOptions?: SDKEventOptions
52
- );
52
+ ): void;
53
53
  logOptOut(): void;
54
54
  logPageView(): void;
55
55
  logProductActionEvent(