UNPKG

@mparticle/web-sdk

Version:
397 lines (374 loc) 291 kB
if (typeof globalThis !== 'undefined') {globalThis.regeneratorRuntime = undefined} // Base64 encoder/decoder - http://www.webtoolkit.info/javascript_base64.html var Base64$1={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",// Input must be a string encode:function(a){try{if(window.btoa&&window.atob)return window.btoa(unescape(encodeURIComponent(a)))}catch(a){console.error("Error encoding cookie values into Base64:"+a);}return this._encode(a)},_encode:function(a){var b,c,d,e,f,g,h,j="",k=0;for(a=UTF8.encode(a);k<a.length;)b=a.charCodeAt(k++),c=a.charCodeAt(k++),d=a.charCodeAt(k++),e=b>>2,f=(3&b)<<4|c>>4,g=(15&c)<<2|d>>6,h=63&d,isNaN(c)?g=h=64:isNaN(d)&&(h=64),j=j+Base64$1._keyStr.charAt(e)+Base64$1._keyStr.charAt(f)+Base64$1._keyStr.charAt(g)+Base64$1._keyStr.charAt(h);return j},decode:function(a){try{if(window.btoa&&window.atob)return decodeURIComponent(escape(window.atob(a)))}catch(a){//log(e); }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 // Production steps of ECMA-262, Edition 5, 15.4.4.18 // Reference: http://es5.github.io/#x15.4.4.18 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 // Production steps of ECMA-262, Edition 5, 15.4.4.19 // Reference: http://es5.github.io/#x15.4.4.19 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 // Prodcution steps of ECMA-262, Edition 5 // Reference: http://es5.github.io/#x15.4.4.20 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 isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1}; var version = "2.40.0"; 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 },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 SDKv2NonMPIDCookieKeys:{gs:1,cu:1,l:1,globalSettings:1,currentUserMPID:1},HTTPCodes:{noHttpCoverage:-1,activeIdentityRequest:-2,activeSession:-3,validationIssue:-4,nativeIdentityRequest:-5,loggingDisabledOrMissingAPIKey:-6,tooManyRequests:429},FeatureFlags:{ReportBatching:"reportBatching",EventBatchingIntervalMillis:"eventBatchingIntervalMillis",OfflineStorage:"offlineStorage",DirectUrlRouting:"directURLRouting",CacheIdentity:"cacheIdentity",AudienceAPI:"audienceAPI",CaptureIntegrationSpecificIds:"captureIntegrationSpecificIds",AstBackgroundEvents:"astBackgroundEvents"},DefaultInstance:"default_instance",CCPAPurpose:"data_sale_opt_out",IdentityMethods:{Modify:"modify",Logout:"logout",Login:"login",Identify:"identify"},Environment:{Development:"development",Production:"production"}};var ONE_DAY_IN_SECONDS=86400;var MILLIS_IN_ONE_SEC=1e3;// https://developer.mozilla.org/en-US/docs/Web/HTTP/Status var HTTP_OK=200;var HTTP_ACCEPTED=202;var HTTP_BAD_REQUEST=400; /****************************************************************************** Copyright (c) Microsoft Corporation. Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted. THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. ***************************************************************************** */ /* global Reflect, Promise, SuppressedError, Symbol */ var extendStatics = function(d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; }; return extendStatics(d, b); }; function __extends(d, b) { if (typeof b !== "function" && b !== null) throw new TypeError("Class extends value " + String(b) + " is not a constructor or null"); extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); } var __assign = function() { __assign = Object.assign || function __assign(t) { for (var s, i = 1, n = arguments.length; i < n; i++) { s = arguments[i]; for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p]; } return t; }; return __assign.apply(this, arguments); }; function __awaiter(thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); } function __generator(thisArg, body) { var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; function verb(n) { return function (v) { return step([n, v]); }; } function step(op) { if (f) throw new TypeError("Generator is already executing."); while (g && (g = 0, op[0] && (_ = 0)), _) try { if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; if (y = 0, t) op = [op[0] & 2, t.value]; switch (op[0]) { case 0: case 1: t = op; break; case 4: _.label++; return { value: op[1], done: false }; case 5: _.label++; y = op[1]; op = [0]; continue; case 7: op = _.ops.pop(); _.trys.pop(); continue; default: if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } if (t[2]) _.ops.pop(); _.trys.pop(); continue; } op = body.call(thisArg, _); } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; } } function __spreadArray(to, from, pack) { if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) { if (ar || !(i in from)) { if (!ar) ar = Array.prototype.slice.call(from, 0, i); ar[i] = from[i]; } } return to.concat(ar || Array.prototype.slice.call(from)); } typeof SuppressedError === "function" ? SuppressedError : function (error, suppressed, message) { var e = new Error(message); return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e; }; var Messages$9=Constants.Messages,createCookieString=function(a){return replaceCommasWithPipes(replaceQuotesWithApostrophes(a))},revertCookieString=function(a){return replacePipesWithCommas(replaceApostrophesWithQuotes(a))},inArray=function(a,b){if(!a)return !1;var c=0;if(Array.prototype.indexOf)return 0<=a.indexOf(b,0);for(var d=a.length;c<d;c++)if(c in a&&a[c]===b)return !0;return !1},findKeyInObject=function(a,b){if(b&&a)for(var c in a)if(a.hasOwnProperty(c)&&c.toLowerCase()===b.toLowerCase())return c;return null},generateDeprecationMessage=function(a,b){var c=[a,Messages$9.DeprecationMessages.MethodIsDeprecatedPostfix];return b&&(c.push(b),c.push(Messages$9.DeprecationMessages.MethodIsDeprecatedPostfix)),c.join(" ")};function generateHash(a){var b,c=0;if(void 0===a||null===a)return 0;if(a=a.toString().toLowerCase(),Array.prototype.reduce)return a.split("").reduce(function(c,d){return c=(c<<5)-c+d.charCodeAt(0),c&c},0);if(0===a.length)return c;for(var d=0;d<a.length;d++)b=a.charCodeAt(d),c=(c<<5)-c+b,c&=c;return c}var generateRandomValue=function(){var b,c;return window.crypto&&window.crypto.getRandomValues&&(b=window.crypto.getRandomValues(new Uint8Array(1))),b?(c^b[0]%16>>c/4).toString(16):(c^16*Math.random()>>c/4).toString(16)},generateUniqueId=function(b){return void 0===b&&(b=""),b// if the placeholder was passed, return ?generateRandomValue()// if the placeholder was passed, return :// [1e7] -> // 10000000 + // -1e3 -> // -1000 + // -4e3 -> // -4000 + // -8e3 -> // -80000000 + // -1e11 -> //-100000000000, "".concat(1e7,"-").concat(1e3,"-").concat(4e3,"-").concat(8e3,"-").concat(1e11).replace(/[018]/g,// zeroes, ones, and eights with generateUniqueId// random hex digits )},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},parseSettingsString=function(a){try{return a?JSON.parse(a.replace(/&quot;/g,"\"")):[]}catch(a){throw new Error("Settings string contains invalid JSON")}},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(/&amp;/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 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={},e={};if(!a)return d;if("undefined"!=typeof URL&&"undefined"!=typeof URLSearchParams){var f=new URL(a);c=new URLSearchParams(f.search);}else c=queryStringParserFallback(a);return (c.forEach(function(a,b){e[b.toLowerCase()]=a;}),isEmpty(b))?e:(b.forEach(function(a){var b=e[a.toLowerCase()];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 var b=function parseCookies(){try{return "undefined"==typeof window?[]:window.document.cookie.split(";").map(function(a){return a.trim()})}catch(a){return console.error("Unable to parse cookies",a),[]}}();// Helper function to filter cookies by keys // Parse cookies from document.cookie // Filter cookies by keys if provided return function filterCookies(a,b){for(var c={},d=0,e=a;d<e.length;d++){var f=e[d],g=f.split("="),h=g[0],i=g[1];(!b||b.includes(h))&&(c[h]=i);}return c}(b,a)},getHref=function(){return "undefined"!=typeof window&&window.location?window.location.href:""},filterDictionaryWithHash=function(a,b,c){var d={};if(!isEmpty(a))for(var e in a)if(a.hasOwnProperty(e)){var f=c(e);inArray(b,f)||(d[e]=a[e]);}return d},parseConfig=function(a,b,c){var d;return (null===(d=a.kitConfigs)||void 0===d?void 0:d.find(function(a){return a.name===b&&a.moduleId===c}))||null};/** * Returns a value between 1-100 inclusive. */ // FIXME: REFACTOR for V3 var MessageType$1={SessionStart:1,SessionEnd:2,PageView:3,PageEvent:4,CrashReport:5,OptOut:6,AppStateTransition:10,Profile:14,Commerce:16,Media:20,UserAttributeChange:17,UserIdentityChange:18};var EventType={Unknown:0,Navigation:1,Location:2,Search:3,Transaction:4,UserContent:5,UserPreference:6,Social:7,Other:8,Media:9,getName:function getName(a){return a===EventType.Unknown?"Unknown":a===EventType.Navigation?"Navigation":a===EventType.Location?"Location":a===EventType.Search?"Search":a===EventType.Transaction?"Transaction":a===EventType.UserContent?"User Content":a===EventType.UserPreference?"User Preference":a===EventType.Social?"Social":a===CommerceEventType.ProductAddToCart?"Product Added to Cart":a===CommerceEventType.ProductAddToWishlist?"Product Added to Wishlist":a===CommerceEventType.ProductCheckout?"Product Checkout":a===CommerceEventType.ProductCheckoutOption?"Product Checkout Options":a===CommerceEventType.ProductClick?"Product Click":a===CommerceEventType.ProductImpression?"Product Impression":a===CommerceEventType.ProductPurchase?"Product Purchased":a===CommerceEventType.ProductRefund?"Product Refunded":a===CommerceEventType.ProductRemoveFromCart?"Product Removed From Cart":a===CommerceEventType.ProductRemoveFromWishlist?"Product Removed from Wishlist":a===CommerceEventType.ProductViewDetail?"Product View Details":a===CommerceEventType.PromotionClick?"Promotion Click":a===CommerceEventType.PromotionView?"Promotion View":"Other"}};// Continuation of EventType enum above, but in seperate object since we don't expose these to end user var CommerceEventType={ProductAddToCart:10,ProductRemoveFromCart:11,ProductCheckout:12,ProductCheckoutOption:13,ProductClick:14,ProductViewDetail:15,ProductPurchase:16,ProductRefund:17,PromotionView:18,PromotionClick:19,ProductAddToWishlist:20,ProductRemoveFromWishlist:21,ProductImpression:22};var IdentityType={Other:0,CustomerId:1,Facebook:2,Twitter:3,Google:4,Microsoft:5,Yahoo:6,Email:7,FacebookCustomAudienceId:9,Other2:10,Other3:11,Other4:12,Other5:13,Other6:14,Other7:15,Other8:16,Other9:17,Other10:18,MobileNumber:19,PhoneNumber2:20,PhoneNumber3:21,isValid:function isValid(a){if("number"==typeof a)for(var b in IdentityType)if(IdentityType.hasOwnProperty(b)&&IdentityType[b]===a)return !0;return !1},getName:function getName(a){return a===window.mParticle.IdentityType.CustomerId?"Customer ID":a===window.mParticle.IdentityType.Facebook?"Facebook ID":a===window.mParticle.IdentityType.Twitter?"Twitter ID":a===window.mParticle.IdentityType.Google?"Google ID":a===window.mParticle.IdentityType.Microsoft?"Microsoft ID":a===window.mParticle.IdentityType.Yahoo?"Yahoo ID":a===window.mParticle.IdentityType.Email?"Email":a===window.mParticle.IdentityType.FacebookCustomAudienceId?"Facebook App User ID":"Other ID"},getIdentityType:function getIdentityType(a){return "other"===a?IdentityType.Other:"customerid"===a?IdentityType.CustomerId:"facebook"===a?IdentityType.Facebook:"twitter"===a?IdentityType.Twitter:"google"===a?IdentityType.Google:"microsoft"===a?IdentityType.Microsoft:"yahoo"===a?IdentityType.Yahoo:"email"===a?IdentityType.Email:"facebookcustomaudienceid"===a?IdentityType.FacebookCustomAudienceId:"other2"===a?IdentityType.Other2:"other3"===a?IdentityType.Other3:"other4"===a?IdentityType.Other4:"other5"===a?IdentityType.Other5:"other6"===a?IdentityType.Other6:"other7"===a?IdentityType.Other7:"other8"===a?IdentityType.Other8:"other9"===a?IdentityType.Other9:"other10"===a?IdentityType.Other10:"mobile_number"===a?IdentityType.MobileNumber:"phone_number_2"===a?IdentityType.PhoneNumber2:!("phone_number_3"!=a)&&IdentityType.PhoneNumber3},getIdentityName:function getIdentityName(a){return a===IdentityType.Other?"other":a===IdentityType.CustomerId?"customerid":a===IdentityType.Facebook?"facebook":a===IdentityType.Twitter?"twitter":a===IdentityType.Google?"google":a===IdentityType.Microsoft?"microsoft":a===IdentityType.Yahoo?"yahoo":a===IdentityType.Email?"email":a===IdentityType.FacebookCustomAudienceId?"facebookcustomaudienceid":a===IdentityType.Other2?"other2":a===IdentityType.Other3?"other3":a===IdentityType.Other4?"other4":a===IdentityType.Other5?"other5":a===IdentityType.Other6?"other6":a===IdentityType.Other7?"other7":a===IdentityType.Other8?"other8":a===IdentityType.Other9?"other9":a===IdentityType.Other10?"other10":a===IdentityType.MobileNumber?"mobile_number":a===IdentityType.PhoneNumber2?"phone_number_2":a===IdentityType.PhoneNumber3?"phone_number_3":null},// Strips out functions from Identity Types for easier lookups getValuesAsStrings:function getValuesAsStrings(){return Object.values(IdentityType).map(function(a){return isNumber(a)?a.toString():void 0}).filter(function(a){return a!==void 0})},getNewIdentitiesByName:function getNewIdentitiesByName(a){var b={},c=IdentityType.getValuesAsStrings();for(var d in a)// IdentityTypes are stored as numbers but are passed in as strings if(c.includes(d)){var e=IdentityType.getIdentityName(parseNumber(d));b[e]=a[d];}return b}};var ProductActionType={Unknown:0,AddToCart:1,RemoveFromCart:2,Checkout:3,CheckoutOption:4,Click:5,ViewDetail:6,Purchase:7,Refund:8,AddToWishlist:9,RemoveFromWishlist:10,getName:function getName(a){return a===ProductActionType.AddToCart?"Add to Cart":a===ProductActionType.RemoveFromCart?"Remove from Cart":a===ProductActionType.Checkout?"Checkout":a===ProductActionType.CheckoutOption?"Checkout Option":a===ProductActionType.Click?"Click":a===ProductActionType.ViewDetail?"View Detail":a===ProductActionType.Purchase?"Purchase":a===ProductActionType.Refund?"Refund":a===ProductActionType.AddToWishlist?"Add to Wishlist":a===ProductActionType.RemoveFromWishlist?"Remove from Wishlist":"Unknown"},// these are the action names used by server and mobile SDKs when expanding a CommerceEvent getExpansionName:function getExpansionName(a){return a===ProductActionType.AddToCart?"add_to_cart":a===ProductActionType.RemoveFromCart?"remove_from_cart":a===ProductActionType.Checkout?"checkout":a===ProductActionType.CheckoutOption?"checkout_option":a===ProductActionType.Click?"click":a===ProductActionType.ViewDetail?"view_detail":a===ProductActionType.Purchase?"purchase":a===ProductActionType.Refund?"refund":a===ProductActionType.AddToWishlist?"add_to_wishlist":a===ProductActionType.RemoveFromWishlist?"remove_from_wishlist":"unknown"}};var PromotionActionType={Unknown:0,PromotionView:1,PromotionClick:2,getName:function getName(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"},// these are the names that the server and mobile SDKs use while expanding CommerceEvent getExpansionName:function getExpansionName(a){return a===PromotionActionType.PromotionView?"view":a===PromotionActionType.PromotionClick?"click":"unknown"}};var ProfileMessageType={Logout:3};var ApplicationTransitionType$1={AppInit:1};var Types = {MessageType:MessageType$1,EventType:EventType,CommerceEventType:CommerceEventType,IdentityType:IdentityType,ProfileMessageType:ProfileMessageType,ApplicationTransitionType:ApplicationTransitionType$1,ProductActionType:ProductActionType,PromotionActionType:PromotionActionType,Environment:Constants.Environment}; function _typeof$1(o) { "@babel/helpers - typeof"; return _typeof$1 = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof$1(o); } var SDKProductActionType;(function(a){a[a.Unknown=0]="Unknown",a[a.AddToCart=1]="AddToCart",a[a.RemoveFromCart=2]="RemoveFromCart",a[a.Checkout=3]="Checkout",a[a.CheckoutOption=4]="CheckoutOption",a[a.Click=5]="Click",a[a.ViewDetail=6]="ViewDetail",a[a.Purchase=7]="Purchase",a[a.Refund=8]="Refund",a[a.AddToWishlist=9]="AddToWishlist",a[a.RemoveFromWishlist=10]="RemoveFromWishlist";})(SDKProductActionType||(SDKProductActionType={})); function getDefaultExportFromCjs (x) { return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x; } var dist = {}; (function (exports) { Object.defineProperty(exports, "__esModule", { value: true }); (function (ApplicationInformationOsEnum) { ApplicationInformationOsEnum["unknown"] = "Unknown"; ApplicationInformationOsEnum["iOS"] = "IOS"; ApplicationInformationOsEnum["android"] = "Android"; ApplicationInformationOsEnum["windowsPhone"] = "WindowsPhone"; ApplicationInformationOsEnum["mobileWeb"] = "MobileWeb"; ApplicationInformationOsEnum["unityIOS"] = "UnityIOS"; ApplicationInformationOsEnum["unityAndroid"] = "UnityAndroid"; ApplicationInformationOsEnum["desktop"] = "Desktop"; ApplicationInformationOsEnum["tvOS"] = "TVOS"; ApplicationInformationOsEnum["roku"] = "Roku"; ApplicationInformationOsEnum["outOfBand"] = "OutOfBand"; ApplicationInformationOsEnum["alexa"] = "Alexa"; ApplicationInformationOsEnum["smartTV"] = "SmartTV"; ApplicationInformationOsEnum["fireTV"] = "FireTV"; ApplicationInformationOsEnum["xbox"] = "Xbox"; })(exports.ApplicationInformationOsEnum || (exports.ApplicationInformationOsEnum = {})); (function (ApplicationStateTransitionEventEventTypeEnum) { ApplicationStateTransitionEventEventTypeEnum["applicationStateTransition"] = "application_state_transition"; })(exports.ApplicationStateTransitionEventEventTypeEnum || (exports.ApplicationStateTransitionEventEventTypeEnum = {})); (function (ApplicationStateTransitionEventDataApplicationTransitionTypeEnum) { ApplicationStateTransitionEventDataApplicationTransitionTypeEnum["applicationInitialized"] = "application_initialized"; ApplicationStateTransitionEventDataApplicationTransitionTypeEnum["applicationExit"] = "application_exit"; ApplicationStateTransitionEventDataApplicationTransitionTypeEnum["applicationBackground"] = "application_background"; ApplicationStateTransitionEventDataApplicationTransitionTypeEnum["applicationForeground"] = "application_foreground"; })(exports.ApplicationStateTransitionEventDataApplicationTransitionTypeEnum || (exports.ApplicationStateTransitionEventDataApplicationTransitionTypeEnum = {})); (function (BatchEnvironmentEnum) { BatchEnvironmentEnum["unknown"] = "unknown"; BatchEnvironmentEnum["development"] = "development"; BatchEnvironmentEnum["production"] = "production"; })(exports.BatchEnvironmentEnum || (exports.BatchEnvironmentEnum = {})); (function (BreadcrumbEventEventTypeEnum) { BreadcrumbEventEventTypeEnum["breadcrumb"] = "breadcrumb"; })(exports.BreadcrumbEventEventTypeEnum || (exports.BreadcrumbEventEventTypeEnum = {})); (function (CommerceEventEventTypeEnum) { CommerceEventEventTypeEnum["commerceEvent"] = "commerce_event"; })(exports.CommerceEventEventTypeEnum || (exports.CommerceEventEventTypeEnum = {})); (function (CommerceEventDataCustomEventTypeEnum) { CommerceEventDataCustomEventTypeEnum["addToCart"] = "add_to_cart"; CommerceEventDataCustomEventTypeEnum["removeFromCart"] = "remove_from_cart"; CommerceEventDataCustomEventTypeEnum["checkout"] = "checkout"; CommerceEventDataCustomEventTypeEnum["checkoutOption"] = "checkout_option"; CommerceEventDataCustomEventTypeEnum["click"] = "click"; CommerceEventDataCustomEventTypeEnum["viewDetail"] = "view_detail"; CommerceEventDataCustomEventTypeEnum["purchase"] = "purchase"; CommerceEventDataCustomEventTypeEnum["refund"] = "refund"; CommerceEventDataCustomEventTypeEnum["promotionView"] = "promotion_view"; CommerceEventDataCustomEventTypeEnum["promotionClick"] = "promotion_click"; CommerceEventDataCustomEventTypeEnum["addToWishlist"] = "add_to_wishlist"; CommerceEventDataCustomEventTypeEnum["removeFromWishlist"] = "remove_from_wishlist"; CommerceEventDataCustomEventTypeEnum["impression"] = "impression"; })(exports.CommerceEventDataCustomEventTypeEnum || (exports.CommerceEventDataCustomEventTypeEnum = {})); (function (CrashReportEventEventTypeEnum) { CrashReportEventEventTypeEnum["crashReport"] = "crash_report"; })(exports.CrashReportEventEventTypeEnum || (exports.CrashReportEventEventTypeEnum = {})); (function (CustomEventEventTypeEnum) { CustomEventEventTypeEnum["customEvent"] = "custom_event"; })(exports.CustomEventEventTypeEnum || (exports.CustomEventEventTypeEnum = {})); (function (CustomEventDataCustomEventTypeEnum) { CustomEventDataCustomEventTypeEnum["navigation"] = "navigation"; CustomEventDataCustomEventTypeEnum["location"] = "location"; CustomEventDataCustomEventTypeEnum["search"] = "search"; CustomEventDataCustomEventTypeEnum["transaction"] = "transaction"; CustomEventDataCustomEventTypeEnum["userContent"] = "user_content"; CustomEventDataCustomEventTypeEnum["userPreference"] = "user_preference"; CustomEventDataCustomEventTypeEnum["social"] = "social"; CustomEventDataCustomEventTypeEnum["media"] = "media"; CustomEventDataCustomEventTypeEnum["other"] = "other"; CustomEventDataCustomEventTypeEnum["unknown"] = "unknown"; })(exports.CustomEventDataCustomEventTypeEnum || (exports.CustomEventDataCustomEventTypeEnum = {})); (function (DeviceCurrentStateDeviceOrientationEnum) { DeviceCurrentStateDeviceOrientationEnum["portrait"] = "portrait"; DeviceCurrentStateDeviceOrientationEnum["portraitUpsideDown"] = "portrait_upside_down"; DeviceCurrentStateDeviceOrientationEnum["landscape"] = "landscape"; DeviceCurrentStateDeviceOrientationEnum["landscapeLeft"] = "LandscapeLeft"; DeviceCurrentStateDeviceOrientationEnum["landscapeRight"] = "LandscapeRight"; DeviceCurrentStateDeviceOrientationEnum["faceUp"] = "FaceUp"; DeviceCurrentStateDeviceOrientationEnum["faceDown"] = "FaceDown"; DeviceCurrentStateDeviceOrientationEnum["square"] = "Square"; })(exports.DeviceCurrentStateDeviceOrientationEnum || (exports.DeviceCurrentStateDeviceOrientationEnum = {})); (function (DeviceCurrentStateStatusBarOrientationEnum) { DeviceCurrentStateStatusBarOrientationEnum["portrait"] = "portrait"; DeviceCurrentStateStatusBarOrientationEnum["portraitUpsideDown"] = "portrait_upside_down"; DeviceCurrentStateStatusBarOrientationEnum["landscape"] = "landscape"; DeviceCurrentStateStatusBarOrientationEnum["landscapeLeft"] = "LandscapeLeft"; DeviceCurrentStateStatusBarOrientationEnum["landscapeRight"] = "LandscapeRight"; DeviceCurrentStateStatusBarOrientationEnum["faceUp"] = "FaceUp"; DeviceCurrentStateStatusBarOrientationEnum["faceDown"] = "FaceDown"; DeviceCurrentStateStatusBarOrientationEnum["square"] = "Square"; })(exports.DeviceCurrentStateStatusBarOrientationEnum || (exports.DeviceCurrentStateStatusBarOrientationEnum = {})); (function (DeviceInformationPlatformEnum) { DeviceInformationPlatformEnum["iOS"] = "iOS"; DeviceInformationPlatformEnum["android"] = "Android"; DeviceInformationPlatformEnum["web"] = "web"; DeviceInformationPlatformEnum["desktop"] = "desktop"; DeviceInformationPlatformEnum["tvOS"] = "tvOS"; DeviceInformationPlatformEnum["roku"] = "roku"; DeviceInformationPlatformEnum["outOfBand"] = "out_of_band"; DeviceInformationPlatformEnum["smartTV"] = "smart_tv"; DeviceInformationPlatformEnum["xbox"] = "xbox"; })(exports.DeviceInformationPlatformEnum || (exports.DeviceInformationPlatformEnum = {})); (function (EventTypeEnum) { EventTypeEnum["unknown"] = "unknown"; EventTypeEnum["sessionStart"] = "session_start"; EventTypeEnum["sessionEnd"] = "session_end"; EventTypeEnum["screenView"] = "screen_view"; EventTypeEnum["customEvent"] = "custom_event"; EventTypeEnum["crashReport"] = "crash_report"; EventTypeEnum["optOut"] = "opt_out"; EventTypeEnum["firstRun"] = "first_run"; EventTypeEnum["preAttribution"] = "pre_attribution"; EventTypeEnum["pushRegistration"] = "push_registration"; EventTypeEnum["applicationStateTransition"] = "application_state_transition"; EventTypeEnum["pushMessage"] = "push_message"; EventTypeEnum["networkPerformance"] = "network_performance"; EventTypeEnum["breadcrumb"] = "breadcrumb"; EventTypeEnum["profile"] = "profile"; EventTypeEnum["pushReaction"] = "push_reaction"; EventTypeEnum["commerceEvent"] = "commerce_event"; EventTypeEnum["userAttributeChange"] = "user_attribute_change"; EventTypeEnum["userIdentityChange"] = "user_identity_change"; EventTypeEnum["uninstall"] = "uninstall"; EventTypeEnum["validationResult"] = "validation_result"; })(exports.EventTypeEnum || (exports.EventTypeEnum = {})); (function (IdentityTypeEnum) { IdentityTypeEnum["other"] = "other"; IdentityTypeEnum["customerId"] = "customer_id"; IdentityTypeEnum["facebook"] = "facebook"; IdentityTypeEnum["twitter"] = "twitter"; IdentityTypeEnum["google"] = "google"; IdentityTypeEnum["microsoft"] = "microsoft"; IdentityTypeEnum["yahoo"] = "yahoo"; IdentityTypeEnum["email"] = "email"; IdentityTypeEnum["alias"] = "alias"; IdentityTypeEnum["facebookCustomAudienceId"] = "facebook_custom_audience_id"; IdentityTypeEnum["otherId2"] = "other_id_2"; IdentityTypeEnum["otherId3"] = "other_id_3"; IdentityTypeEnum["otherId4"] = "other_id_4"; IdentityTypeEnum["otherId5"] = "other_id_5"; IdentityTypeEnum["otherId6"] = "other_id_6"; IdentityTypeEnum["otherId7"] = "other_id_7"; IdentityTypeEnum["otherId8"] = "other_id_8"; IdentityTypeEnum["otherId9"] = "other_id_9"; IdentityTypeEnum["otherId10"] = "other_id_10"; IdentityTypeEnum["mobileNumber"] = "mobile_number"; IdentityTypeEnum["phoneNumber2"] = "phone_number_2"; IdentityTypeEnum["phoneNumber3"] = "phone_number_3"; })(exports.IdentityTypeEnum || (exports.IdentityTypeEnum = {})); (function (NetworkPerformanceEventEventTypeEnum) { NetworkPerformanceEventEventTypeEnum["networkPerformance"] = "network_performance"; })(exports.NetworkPerformanceEventEventTypeEnum || (exports.NetworkPerformanceEventEventTypeEnum = {})); (function (OptOutEventEnum) { OptOutEventEnum["optOut"] = "opt_out"; })(exports.OptOutEventEnum || (exports.OptOutEventEnum = {})); (function (ProductActionActionEnum) { ProductActionActionEnum["unknown"] = "unknown"; ProductActionActionEnum["addToCart"] = "add_to_cart"; ProductActionActionEnum["removeFromCart"] = "remove_from_cart"; ProductActionActionEnum["checkout"] = "checkout"; ProductActionActionEnum["checkoutOption"] = "checkout_option"; ProductActionActionEnum["click"] = "click"; ProductActionActionEnum["viewDetail"] = "view_detail"; ProductActionActionEnum["purchase"] = "purchase"; ProductActionActionEnum["refund"] = "refund"; ProductActionActionEnum["addToWishlist"] = "add_to_wishlist"; ProductActionActionEnum["removeFromWishlist"] = "remove_from_wish_list"; })(exports.ProductActionActionEnum || (exports.ProductActionActionEnum = {})); (function (ProfileEventEventTypeEnum) { ProfileEventEventTypeEnum["profile"] = "profile"; })(exports.ProfileEventEventTypeEnum || (exports.ProfileEventEventTypeEnum = {})); (function (ProfileEventDataProfileEventTypeEnum) { ProfileEventDataProfileEventTypeEnum["signup"] = "signup"; ProfileEventDataProfileEventTypeEnum["login"] = "login"; ProfileEventDataProfileEventTypeEnum["logout"] = "logout"; ProfileEventDataProfileEventTypeEnum["update"] = "update"; ProfileEventDataProfileEventTypeEnum["delete"] = "delete"; })(exports.ProfileEventDataProfileEventTypeEnum || (exports.ProfileEventDataProfileEventTypeEnum = {})); (function (PromotionActionActionEnum) { PromotionActionActionEnum["view"] = "view"; PromotionActionActionEnum["click"] = "click"; })(exports.PromotionActionActionEnum || (exports.PromotionActionActionEnum = {})); (function (PushMessageEventEventTypeEnum) { PushMessageEventEventTypeEnum["pushMessage"] = "push_message"; })(exports.PushMessageEventEventTypeEnum || (exports.PushMessageEventEventTypeEnum = {})); (function (PushMessageEventDataPushMessageTypeEnum) { PushMessageEventDataPushMessageTypeEnum["sent"] = "sent"; PushMessageEventDataPushMessageTypeEnum["received"] = "received"; PushMessageEventDataPushMessageTypeEnum["action"] = "action"; })(exports.PushMessageEventDataPushMessageTypeEnum || (exports.PushMessageEventDataPushMessageTypeEnum = {})); (function (PushMessageEventDataApplicationStateEnum) { PushMessageEventDataApplicationStateEnum["notRunning"] = "not_running"; PushMessageEventDataApplicationStateEnum["background"] = "background"; PushMessageEventDataApplicationStateEnum["foreground"] = "foreground"; })(exports.PushMessageEventDataApplicationStateEnum || (exports.PushMessageEventDataApplicationStateEnum = {})); (function (PushMessageEventDataPushMessageBehaviorEnum) { PushMessageEventDataPushMessageBehaviorEnum["received"] = "Received"; PushMessageEventDataPushMessageBehaviorEnum["directOpen"] = "DirectOpen"; PushMessageEventDataPushMessageBehaviorEnum["read"] = "Read"; PushMessageEventDataPushMessageBehaviorEnum["influencedOpen"] = "InfluencedOpen"; PushMessageEventDataPushMessageBehaviorEnum["displayed"] = "Displayed"; })(exports.PushMessageEventDataPushMessageBehaviorEnum || (exports.PushMessageEventDataPushMessageBehaviorEnum = {})); (function (PushRegistrationEventEventTypeEnum) { PushRegistrationEventEventTypeEnum["pushRegistration"] = "push_registration"; })(exports.PushRegistrationEventEventTypeEnum || (exports.PushRegistrationEventEventTypeEnum = {})); (function (SessionEndEventEventTypeEnum) { SessionEndEventEventTypeEnum["sessionEnd"] = "session_end"; })(exports.SessionEndEventEventTypeEnum || (exports.SessionEndEventEventTypeEnum = {})); (function (SessionStartEventEventTypeEnum) { SessionStartEventEventTypeEnum["sessionStart"] = "session_start"; })(exports.SessionStartEventEventTypeEnum || (exports.SessionStartEventEventTypeEnum = {})); (function (SourceInformationChannelEnum) { SourceInformationChannelEnum["native"] = "native"; SourceInformationChannelEnum["javascript"] = "javascript"; SourceInformationChannelEnum["pixel"] = "pixel"; SourceInformationChannelEnum["desktop"] = "desktop"; SourceInformationChannelEnum["partner"] = "partner"; SourceInformationChannelEnum["serverToServer"] = "server_to_server"; })(exports.SourceInformationChannelEnum || (exports.SourceInformationChannelEnum = {})); (function (UserAttributeChangeEventEventTypeEnum) { UserAttributeChangeEventEventTypeEnum["userAttributeChange"] = "user_attribute_change"; })(exports.UserAttributeChangeEventEventTypeEnum || (exports.UserAttributeChangeEventEventTypeEnum = {})); (function (UserIdentityChangeEventEventTypeEnum) { UserIdentityChangeEventEventTypeEnum["userIdentityChange"] = "user_identity_change"; })(exports.UserIdentityChangeEventEventTypeEnum || (exports.UserIdentityChangeEventEventTypeEnum = {})); } (dist)); var SDKIdentityTypeEnum;(function(a){a.other="other",a.customerId="customerid",a.facebook="facebook",a.twitter="twitter",a.google="google",a.microsoft="microsoft",a.yahoo="yahoo",a.email="email",a.alias="alias",a.facebookCustomAudienceId="facebookcustomaudienceid",a.otherId2="other2",a.otherId3="other3",a.otherId4="other4",a.otherId5="other5",a.otherId6="other6",a.otherId7="other7",a.otherId8="other8",a.otherId9="other9",a.otherId10="other10",a.mobileNumber="mobile_number",a.phoneNumber2="phone_number_2",a.phoneNumber3="phone_number_3";})(SDKIdentityTypeEnum||(SDKIdentityTypeEnum={})); var FeatureFlags$2=Constants.FeatureFlags,CaptureIntegrationSpecificIds$1=FeatureFlags$2.CaptureIntegrationSpecificIds;function convertEvents(a,b,c){if(!a)return null;if(!b||1>b.length)return null;for(var d,e=c._IntegrationCapture,f=c._Helpers,g=f.getFeatureFlag,h=c.Identity.getCurrentUser(),i=[],j=null,k=0,l=b;k<l.length;k++)if(d=l[k],d){j=d;var m=convertEvent(d);m&&i.push(m);}if(!j)return null;var n=null;// Add the consent state from either the Last Event or the user isEmpty(j.ConsentState)?!isEmpty(h)&&(n=h.getConsentState()):n=j.ConsentState;var o={source_request_id:c._Helpers.generateUniqueId(),mpid:a,timestamp_unixtime_ms:new Date().getTime(),environment:j.Debug?dist.BatchEnvironmentEnum.development:dist.BatchEnvironmentEnum.production,events:i,mp_deviceid:j.DeviceId,sdk_version:j.SDKVersion,// TODO: Refactor this to read from _Store or a global config application_info:{application_version:j.AppVersion,application_name:j.AppName,package:j.Package,sideloaded_kits_count:c._Store.sideloadedKitsCount},device_info:{platform:dist.DeviceInformationPlatformEnum.web,screen_width:"undefined"!=typeof window&&"undefined"!=typeof window.screen?window.screen.width:0,screen_height:"undefined"!=typeof window&&"undefined"!=typeof window.screen?window.screen.height:0},user_attributes:j.UserAttributes,user_identities:convertUserIdentities(j.UserIdentities),consent_state:convertConsentState(n),integration_attributes:j.IntegrationAttributes};j.DataPlan&&j.DataPlan.PlanId&&(o.context={data_plan:{plan_id:j.DataPlan.PlanId,plan_version:j.DataPlan.PlanVersion||void 0}});var p=g&&!!g(CaptureIntegrationSpecificIds$1);if(p){var q=null===e||void 0===e?void 0:e.getClickIdsAsPartnerIdentities();isEmpty(q)||(o.partner_identities=q);}return o}function convertConsentState(a){if(isEmpty(a))return null;var b={gdpr:convertGdprConsentState(a.getGDPRConsentState()),ccpa:convertCcpaConsentState(a.getCCPAConsentState())};return b}function convertGdprConsentState(a){if(!a)return null;var b={};for(var c in a)a.hasOwnProperty(c)&&(b[c]={consented:a[c].Consented,hardware_id:a[c].HardwareId,document:a[c].ConsentDocument,timestamp_unixtime_ms:a[c].Timestamp,location:a[c].Location});return b}function convertCcpaConsentState(a){if(!a)return null;var b={data_sale_opt_out:{consented:a.Consented,hardware_id:a.HardwareId,document:a.ConsentDocument,timestamp_unixtime_ms:a.Timestamp,location:a.Location}};return b}function convertUserIdentities(a){if(!a||!a.length)return null;for(var b,c={},d=0,e=a;d<e.length;d++)switch(b=e[d],b.Type){case Types.IdentityType.CustomerId:c.customer_id=b.Identity;break;case Types.IdentityType.Email:c.email=b.Identity;break;case Types.IdentityType.Facebook:c.facebook=b.Identity;break;case Types.IdentityType.FacebookCustomAudienceId:c.facebook_custom_audience_id=b.Identity;break;case Types.IdentityType.Google:c.google=b.Identity;break;case Types.IdentityType.Microsoft:c.microsoft=b.Identity;break;case Types.IdentityType.Other:c.other=b.Identity;break;case Types.IdentityType.Other2:c.other_id_2=b.Identity;break;case Types.IdentityType.Other3:c.other_id_3=b.Identity;break;case Types.IdentityType.Other4:c.other_id_4=b.Identity;break;case Types.IdentityType.Other5:c.other_id_5=b.Identity;break;case Types.IdentityType.Other6:c.other_id_6=b.Identity;break;case Types.IdentityType.Other7:c.other_id_7=b.Identity;break;case Types.IdentityType.Other8:c.other_id_8=b.Identity;break;case Types.IdentityType.Other9:c.other_id_9=b.Identity;break;case Types.IdentityType.Other10:c.other_id_10=b.Identity;break;case Types.IdentityType.MobileNumber:c.mobile_number=b.Identity;break;case Types.IdentityType.PhoneNumber2:c.phone_number_2=b.Identity;break;case Types.IdentityType.PhoneNumber3:c.phone_number_3=b.Identity;break;}return c}function convertEvent(a){if(!a)return null;switch(a.EventDataType){case Types.MessageType.AppStateTransition:return convertAST(a);case Types.MessageType.Commerce:return convertCommerceEvent(a);case Types.MessageType.CrashReport:return convertCrashReportEvent(a);case Types.MessageType.OptOut:return convertOptOutEvent(a);case Types.MessageType.PageEvent:// Note: Media Events are also sent as PageEvents/CustomEvents return convertCustomEvent(a);case Types.MessageType.PageView:return convertPageViewEvent(a);case Types.MessageType.Profile://deprecated and not supported by the web SDK return null;case Types.MessageType.SessionEnd:return convertSessionEndEvent(a);case Types.MessageType.SessionStart:return convertSessionStartEvent(a);case Types.MessageType.UserAttributeChange:return convertUserAttributeChangeEvent(a);case Types.MessageType.UserIdentityChange:return convertUserIdentityChangeEvent(a);}return null}function convertProductActionType(a){if(!a)return dist.ProductActionActionEnum.unknown;return a===SDKProductActionType.AddToCart?dist.ProductActionActionEnum.addToCart:a===SDKProductActionType.AddToWishlist?dist.ProductActionActionEnum.addToWishlist:a===SDKProductActionType.Checkout?dist.ProductActionActionEnum.checkout:a===SDKProductActionType.CheckoutOption?dist.ProductActionActionEnum.checkoutOption:a===SDKProductActionType.Click?dist.ProductActionActionEnum.click:a===SDKProductActionType.Purchase?dist.ProductActionActionEnum.purchase:a===SDKProductActionType.Refund?dist.ProductActionActionEnum.refund:a===SDKProductActionType.RemoveFromCart?dist.ProductActionActionEnum.removeFromCart:a===SDKProductActionType.RemoveFromWishlist?dist.ProductActionActionEnum.removeFromWishlist:a===SDKProductActionType.ViewDetail?dist.ProductActionActionEnum.viewDetail:dist.ProductActionActionEnum.unknown}function convertProductAction(a){