@mparticle/web-sdk 2.52.0 → 2.53.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mparticle.common.js +24 -9
- package/dist/mparticle.esm.js +24 -9
- package/dist/mparticle.js +124 -71
- package/package.json +1 -1
- package/src/batchUploader.ts +3 -3
- package/src/cookieConsentManager.ts +64 -0
- package/src/cookieSyncManager.ts +6 -0
- package/src/identityApiClient.ts +11 -12
- package/src/logger.ts +66 -0
- package/src/mp-instance.ts +8 -1
- package/src/sdkRuntimeModels.ts +9 -1
- package/src/logger.js +0 -61
package/dist/mparticle.common.js
CHANGED
|
@@ -15,7 +15,7 @@ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is nul
|
|
|
15
15
|
filter:function filter(a/*, thisArg*/){if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g);}return d},// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
|
16
16
|
isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1};
|
|
17
17
|
|
|
18
|
-
var version = "2.
|
|
18
|
+
var version = "2.53.0";
|
|
19
19
|
|
|
20
20
|
var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"is a deprecated method and will be removed in future releases.",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",AddToCart:"addToCart",RemoveFromCart:"removeFromCart",ClearCart:"clearCart",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",localStorageProductsV4:"mprtcl-prodv4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4",currentStorageProductsName:"mprtcl-prodv4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,maxProducts:20,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
|
|
21
21
|
},DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},// These are the paths that are used to construct the CNAME urls
|
|
@@ -160,7 +160,7 @@ function _typeof$1(o) {
|
|
|
160
160
|
}, _typeof$1(o);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
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={}));
|
|
163
|
+
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={}));var LogLevelType={None:"none",Verbose:"verbose",Warning:"warning",Error:"error"};
|
|
164
164
|
|
|
165
165
|
function getDefaultExportFromCjs (x) {
|
|
166
166
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -456,7 +456,7 @@ return e>=f},a.prototype.shouldDebounceAndUpdateLastASTTime=function(){var a=Dat
|
|
|
456
456
|
if(s){this.mpInstance._IntegrationCapture.capture();var t=this.mpInstance._IntegrationCapture.getClickIdsAsCustomFlags();o=__assign(__assign({},t),o);var u=this.mpInstance._IntegrationCapture.getClickIdsAsIntegrationAttributes();p=__assign(__assign({},u),p);}return n.CustomFlags=o,n.IntegrationAttributes=p,appendUserInfo(m(),n),n},a.prototype.addEventListeners=function(){var a=this,b=this,c=function(){// Check for debounce before creating and queueing event
|
|
457
457
|
var c=a.mpInstance._Helpers.getFeatureFlag,d=Constants.FeatureFlags.AstBackgroundEvents;if(c(d)){if(b.shouldDebounceAndUpdateLastASTTime())return;// Add application state transition event to queue
|
|
458
458
|
var e=b.createBackgroundASTEvent();b.queueEvent(e);}// Then trigger the upload with beacon
|
|
459
|
-
b.prepareAndUpload(!1,b.isBeaconAvailable());};document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&c();}),window.addEventListener("beforeunload",c),window.addEventListener("pagehide",c);},a.prototype.isBeaconAvailable=function(){return !!navigator.sendBeacon},a.prototype.triggerUploadInterval=function(a,b){var c=this;void 0===a&&(a=!1),void 0===b&&(b=!1),setTimeout(function(){c.prepareAndUpload(a,b);},this.uploadIntervalMillis);},a.prototype.queueEvent=function(a){if(!isEmpty(a)){var b=this.mpInstance.Logger
|
|
459
|
+
b.prepareAndUpload(!1,b.isBeaconAvailable());};document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&c();}),window.addEventListener("beforeunload",c),window.addEventListener("pagehide",c);},a.prototype.isBeaconAvailable=function(){return !!navigator.sendBeacon},a.prototype.triggerUploadInterval=function(a,b){var c=this;void 0===a&&(a=!1),void 0===b&&(b=!1),setTimeout(function(){c.prepareAndUpload(a,b);},this.uploadIntervalMillis);},a.prototype.queueEvent=function(a){if(!isEmpty(a)){var b=this.mpInstance.Logger;this.eventsQueuedForProcessing.push(a),this.offlineStorageEnabled&&this.eventVault&&this.eventVault.store(this.eventsQueuedForProcessing),b.verbose("Queuing event: ".concat(JSON.stringify(a))),b.verbose("Queued event count: ".concat(this.eventsQueuedForProcessing.length)),this.shouldTriggerImmediateUpload(a.EventDataType)&&this.prepareAndUpload(!1,!1);}},a.prototype.shouldTriggerImmediateUpload=function(a){var b=[MessageType$1.Commerce,MessageType$1.UserIdentityChange];return !this.batchingEnabled||b.includes(a)},(a.createNewBatches=function(a,b,c){if(!b||!a||!a.length)return null;//bucket by MPID, and then by session, ordered by timestamp
|
|
460
460
|
for(var d,e=[],f=new Map,g=0,h=a;g<h.length;g++){//on initial startup, there may be events logged without an mpid.
|
|
461
461
|
if(d=h[g],!d.MPID){var i=b.getMPID();d.MPID=i;}var j=f.get(d.MPID);j||(j=[]),j.push(d),f.set(d.MPID,j);}for(var k=0,l=Array.from(f.entries());k<l.length;k++){for(var m=l[k],i=m[0],n=m[1],o=new Map,p=0,q=n;p<q.length;p++){var d=q[p],j=o.get(d.SessionId);j||(j=[]),j.push(d),o.set(d.SessionId,j);}for(var r=0,s=Array.from(o.entries());r<s.length;r++){var t=s[r],u=convertEvents(i,t[1],c),v=c._Store.SDKConfig.onCreateBatch;v&&(u=v(u),u?u.modified=!0:c.Logger.warning("Skiping batch upload because no batch was returned from onCreateBatch callback")),u&&e.push(u);}}return e},a.prototype.prepareAndUpload=function(b,c){return void 0===b&&(b=!1),void 0===c&&(c=!1),__awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k;return __generator(this,function(l){switch(l.label){case 0:return d=this.mpInstance.Identity.getCurrentUser(),e=this.eventsQueuedForProcessing,this.eventsQueuedForProcessing=[],this.offlineStorageEnabled&&this.eventVault&&this.eventVault.store([]),f=[],isEmpty(e)||(f=a.createNewBatches(e,d,this.mpInstance)),this.offlineStorageEnabled&&this.batchVault&&((i=this.batchesQueuedForProcessing).unshift.apply(i,this.batchVault.retrieve()),this.batchVault.purge()),isEmpty(f)||(j=this.batchesQueuedForProcessing).push.apply(j,f),g=this.batchesQueuedForProcessing,this.batchesQueuedForProcessing=[],[4/*yield*/,this.uploadBatches(this.mpInstance.Logger,g,c)];case 1:return h=l.sent(),isEmpty(h)||(k=this.batchesQueuedForProcessing).unshift.apply(k,h),!c&&this.offlineStorageEnabled&&this.batchVault&&(this.batchVault.store(this.batchesQueuedForProcessing),this.batchesQueuedForProcessing=[]),b&&this.triggerUploadInterval(b,!1),[2/*return*/]}})})},a.prototype.uploadBatches=function(b,c,d){return __awaiter(this,void 0,void 0,function(){var e,f,g,h,j,k;return __generator(this,function(i){switch(i.label){case 0:if(e=c.filter(function(a){return !isEmpty(a.events)}),isEmpty(e))return [2/*return*/,null];b.verbose("Uploading batches: ".concat(JSON.stringify(e))),b.verbose("Batch count: ".concat(e.length)),f=0,i.label=1;case 1:return f<e.length?(g={method:"POST",headers:{Accept:a.CONTENT_TYPE,"Content-Type":"text/plain;charset=UTF-8"},body:JSON.stringify(e[f])},!(d&&this.isBeaconAvailable()))?[3/*break*/,2]:(h=new Blob([g.body],{type:"text/plain;charset=UTF-8"}),navigator.sendBeacon(this.uploadUrl,h),[3/*break*/,5]):[3/*break*/,6];case 2:return i.trys.push([2,4,,5]),[4/*yield*/,this.uploader.upload(g)];case 3:if(j=i.sent(),200<=j.status&&300>j.status)b.verbose("Upload success for request ID: ".concat(e[f].source_request_id));else {if(500<=j.status||429===j.status)// Server error, add back current batches and try again later
|
|
462
462
|
return b.error("HTTP error status ".concat(j.status," received")),[2/*return*/,e.slice(f,e.length)];if(401<=j.status)//if we're getting a 401, assume we'll keep getting a 401 and clear the uploads.
|
|
@@ -509,13 +509,14 @@ return !!(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHan
|
|
|
509
509
|
},this.isBridgeV1Available=function(){return !!(a._Store.SDKConfig.useNativeSdk||window.mParticleAndroid||a._Store.SDKConfig.isIOS)},this.sendToNative=function(c,d){return a._Store.bridgeV2Available&&2===a._Store.SDKConfig.minWebviewBridgeVersion?void b.sendViaBridgeV2(c,d,a._Store.SDKConfig.requiredWebviewBridgeName):a._Store.bridgeV2Available&&2>a._Store.SDKConfig.minWebviewBridgeVersion?void b.sendViaBridgeV2(c,d,a._Store.SDKConfig.requiredWebviewBridgeName):a._Store.bridgeV1Available&&2>a._Store.SDKConfig.minWebviewBridgeVersion?void b.sendViaBridgeV1(c,d):void 0},this.sendViaBridgeV1=function(c,d){window.mParticleAndroid&&window.mParticleAndroid.hasOwnProperty(c)?(a.Logger.verbose(Messages$8.InformationMessages.SendAndroid+c),window.mParticleAndroid[c](d)):a._Store.SDKConfig.isIOS&&(a.Logger.verbose(Messages$8.InformationMessages.SendIOS+c),b.sendViaIframeToIOS(c,d));},this.sendViaIframeToIOS=function(a,b){var c=document.createElement("IFRAME");c.setAttribute("src","mp-sdk://"+a+"/"+encodeURIComponent(b)),document.documentElement.appendChild(c),c.parentNode.removeChild(c);},this.sendViaBridgeV2=function(c,d,e){if(e){var f,g,h=window[androidBridgeNameBase+"_"+e+"_v2"],i=iosBridgeNameBase+"_"+e+"_v2";return window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers[i]&&(f=window.webkit.messageHandlers[i]),a.uiwebviewBridgeName===i&&(g=a[i]),h&&h.hasOwnProperty(c)?(a.Logger.verbose(Messages$8.InformationMessages.SendAndroid+c),void h[c](d)):void(f?(a.Logger.verbose(Messages$8.InformationMessages.SendIOS+c),f.postMessage(JSON.stringify({path:c,value:d?JSON.parse(d):null}))):g&&(a.Logger.verbose(Messages$8.InformationMessages.SendIOS+c),b.sendViaIframeToIOS(c,d)))}};}
|
|
510
510
|
|
|
511
511
|
var Messages$7=Constants.Messages,InformationMessages=Messages$7.InformationMessages;var DAYS_IN_MILLISECONDS=86400000;// Partner module IDs for cookie sync configurations
|
|
512
|
-
var PARTNER_MODULE_IDS={AdobeEventForwarder:11,DoubleclickDFP:41,AppNexus:50,Lotame:58,TradeDesk:103,VerizonMedia:155};function CookieSyncManager(a){var b=this;// Public
|
|
512
|
+
var PARTNER_MODULE_IDS={AdobeEventForwarder:11,DoubleclickDFP:41,AppNexus:50,Lotame:58,TradeDesk:103,VerizonMedia:155,Rokt:1277};function CookieSyncManager(a){var b=this;// Public
|
|
513
513
|
// Private
|
|
514
514
|
this.attemptCookieSync=function(c,d){var e=a._Store,f=e.pixelConfigurations,g=e.webviewBridgeEnabled;if(c&&!g){var h=a._Persistence.getPersistence();isEmpty(h)||f.forEach(function(e){var f,g,i=!1,j=e.filteringConsentRuleValues,k=e.pixelUrl,l=e.redirectUrl,m=e.moduleId,// Tells you how often we should do a cookie sync (in days)
|
|
515
515
|
n=e.frequencyCap,o=(j||{}).values;// set requiresConsent to false to start each additional pixel configuration
|
|
516
516
|
// set to true only if filteringConsenRuleValues.values.length exists
|
|
517
517
|
// Filtering rules as defined in UI
|
|
518
|
-
if(!isEmpty(k)&&(isEmpty(o)||(i=!0),!(i&&d)))//
|
|
518
|
+
if(!isEmpty(k)&&(isEmpty(o)||(i=!0),!(i&&d))&&!(m===PARTNER_MODULE_IDS.Rokt&&a._CookieConsentManager.getNoTargeting()))// For Rokt, block cookie sync when noTargeting privacy flag is true
|
|
519
|
+
// If MPID is new to cookies, we should not try to perform the cookie sync
|
|
519
520
|
// because a cookie sync can only occur once a user either consents or doesn't.
|
|
520
521
|
// we should not check if it's enabled if the user has a blank consent
|
|
521
522
|
// The Trade Desk requires a URL parameter for GDPR enabled users.
|
|
@@ -611,7 +612,7 @@ for(var g in c){// Any custom endpoints passed to mpConfig will take priority ov
|
|
|
611
612
|
// mapping to the silo. The most common use case is a customer provided CNAME.
|
|
612
613
|
if("configUrl"==g){d[g]=a[g]||c[g];continue}if(a.hasOwnProperty(g))d[g]=a[g];else {var h=c[g].split(".");d[g]=__spreadArray([h[0],f],h.slice(1),!0).join(".");}}return d}
|
|
613
614
|
|
|
614
|
-
|
|
615
|
+
var Logger=/** @class */function(){function a(a){var b,c;this.logLevel=null!==(b=a.logLevel)&&void 0!==b?b:LogLevelType.Warning,this.logger=null!==(c=a.logger)&&void 0!==c?c:new ConsoleLogger;}return a.prototype.verbose=function(a){this.logLevel===LogLevelType.None||this.logger.verbose&&this.logLevel===LogLevelType.Verbose&&this.logger.verbose(a);},a.prototype.warning=function(a){this.logLevel===LogLevelType.None||this.logger.warning&&(this.logLevel===LogLevelType.Verbose||this.logLevel===LogLevelType.Warning)&&this.logger.warning(a);},a.prototype.error=function(a){this.logLevel===LogLevelType.None||this.logger.error&&this.logger.error(a);},a.prototype.setLogLevel=function(a){this.logLevel=a;},a}();var ConsoleLogger=/** @class */function(){function a(){}return a.prototype.verbose=function(a){console&&console.info&&console.info(a);},a.prototype.error=function(a){console&&console.error&&console.error(a);},a.prototype.warning=function(a){console&&console.warn&&console.warn(a);},a}();
|
|
615
616
|
|
|
616
617
|
var Base64=Polyfill.Base64,Messages$4=Constants.Messages,Base64CookieKeys=Constants.Base64CookieKeys,SDKv2NonMPIDCookieKeys=Constants.SDKv2NonMPIDCookieKeys,StorageNames=Constants.StorageNames;function _Persistence(a){function b(b){var c=a._Store;return b.gs.sid=c.sessionId,b.gs.ie=c.isEnabled,b.gs.sa=c.sessionAttributes,b.gs.lsa=c.localSessionAttributes,b.gs.ss=c.serverSettings,b.gs.dt=c.devToken,b.gs.les=c.dateLastEventSent?c.dateLastEventSent.getTime():null,b.gs.av=c.SDKConfig.appVersion,b.gs.cgid=c.clientId,b.gs.das=c.deviceId,b.gs.c=c.context,b.gs.ssd=c.sessionStartDate?c.sessionStartDate.getTime():0,b.gs.ia=c.integrationAttributes,b}function c(a){localStorage.removeItem(a);}function d(a,b,c){return f.encodePersistence(JSON.stringify(a))+";expires="+b+";path=/"+c}var f=this;// https://go.mparticle.com/work/SQDSDKS-5022
|
|
617
618
|
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
@@ -1399,7 +1400,7 @@ return !("boolean"==typeof b&&b)&&"object"===_typeof$1(b)&&!0!==b[a];// When "Bl
|
|
|
1399
1400
|
var buildUrl=function(a,b,c,d){var e=d?"1":"0",f=["env=".concat(e)],g=c||{},h=g.planId,i=g.planVersion;return h&&f.push("plan_id=".concat(h)),i&&f.push("plan_version=".concat(i)),"".concat(a+b+"/config","?").concat(f.join("&"))};function ConfigAPIClient(a,b,c){var d=this,e="https://"+c._Store.SDKConfig.configUrl,f=b.isDevelopmentMode,g=b.dataPlan,h=buildUrl(e,a,g,f),i=window.fetch?new FetchUploader(h):new XHRUploader(h);this.getSDKConfiguration=function(){return __awaiter(d,void 0,void 0,function(){var a,d,e,f,h,j,k;return __generator(this,function(l){switch(l.label){case 0:d={method:"get",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"text/plain;charset=UTF-8"},body:null},l.label=1;case 1:return l.trys.push([1,6,,7]),[4/*yield*/,i.upload(d)];case 2:return (e=l.sent(),200!==e.status)?[3/*break*/,5]:(null===(h=null===c||void 0===c?void 0:c.Logger)||void 0===h?void 0:h.verbose("Successfully received configuration from server"),e.json?[4/*yield*/,e.json()]:[3/*break*/,4]);case 3:return a=l.sent(),[2/*return*/,a];case 4:return f=e,a=JSON.parse(f.responseText),[2/*return*/,a];case 5:return null===(j=null===c||void 0===c?void 0:c.Logger)||void 0===j?void 0:j.verbose("Issue with receiving configuration from server, received HTTP Code of "+e.statusText),[3/*break*/,7];case 6:return l.sent(),null===(k=null===c||void 0===c?void 0:c.Logger)||void 0===k?void 0:k.error("Error getting forwarder configuration from mParticle servers."),[3/*break*/,7];case 7:// Returns the original config object if we cannot retrieve the remote config
|
|
1400
1401
|
return [2/*return*/,b]}})})};}
|
|
1401
1402
|
|
|
1402
|
-
var HTTPCodes$1=Constants.HTTPCodes,Messages$1=Constants.Messages,IdentityMethods=Constants.IdentityMethods,Modify=IdentityMethods.Modify;function IdentityAPIClient(a){this.sendAliasRequest=function(b,c){return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n,o,
|
|
1403
|
+
var HTTPCodes$1=Constants.HTTPCodes,Messages$1=Constants.Messages,IdentityMethods=Constants.IdentityMethods,Modify=IdentityMethods.Modify;function IdentityAPIClient(a){this.sendAliasRequest=function(b,c){return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,n;return __generator(this,function(t){switch(t.label){case 0:d=a.Logger,e=a._Helpers.invokeAliasCallback,f=a._Store.SDKConfig.aliasUrl,g=a._Store.devToken,d.verbose(Messages$1.InformationMessages.SendAliasHttp),h="https://".concat(f).concat(g,"/Alias"),i=window.fetch?new FetchUploader(h):new XHRUploader(h),j={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json"},body:JSON.stringify(b)},t.label=1;case 1:return t.trys.push([1,13,,14]),[4/*yield*/,i.upload(j)];case 2:return k=t.sent(),l=void 0,m=void 0,n=void 0,o=k.status,o===HTTP_ACCEPTED?[3/*break*/,3]:o===HTTP_OK?[3/*break*/,3]:o===HTTP_BAD_REQUEST?[3/*break*/,4]:[3/*break*/,11];case 3:return m="Received Alias Response from server: "+JSON.stringify(k.status),[3/*break*/,12];case 4:if(!k.json)return [3/*break*/,9];t.label=5;case 5:return t.trys.push([5,7,,8]),[4/*yield*/,k.json()];case 6:return l=t.sent(),[3/*break*/,8];case 7:return t.sent(),d.verbose("The request has no response body"),[3/*break*/,8];case 8:return [3/*break*/,10];case 9:q=k,l=q.responseText?JSON.parse(q.responseText):"",t.label=10;case 10:return r=l,(null===r||void 0===r?void 0:r.message)&&(n=r.message),m="Issue with sending Alias Request to mParticle Servers, received HTTP Code of "+k.status,(null===r||void 0===r?void 0:r.code)&&(m+=" - "+r.code),[3/*break*/,12];case 11:throw new Error("Received HTTP Code of "+k.status);case 12:return d.verbose(m),e(c,k.status,n),[3/*break*/,14];case 13:return s=t.sent(),n=s.message||s.toString(),d.error("Error sending alias request to mParticle servers. "+n),e(c,HTTPCodes$1.noHttpCoverage,n),[3/*break*/,14];case 14:return [2/*return*/]}})})},this.sendIdentityRequest=function(b,c,d,e,f,g,h){return __awaiter(this,void 0,void 0,function(){var i,j,k,l,m,n,o,p,q,r,s,t,u,v,u;return __generator(this,function(w){switch(w.label){case 0:if(i=a._Helpers.invokeCallback,j=a.Logger,j.verbose(Messages$1.InformationMessages.SendIdentityBegin),!b)return j.error(Messages$1.ErrorMessages.APIRequestEmpty),[2/*return*/];if(j.verbose(Messages$1.InformationMessages.SendIdentityHttp),a._Store.identityCallInFlight)return i(d,HTTPCodes$1.activeIdentityRequest,"There is currently an Identity request processing. Please wait for this to return before requesting again"),[2/*return*/];k=g||null,l=this.getUploadUrl(c,g),m=window.fetch?new FetchUploader(l):new XHRUploader(l),n={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","x-mp-key":a._Store.devToken},body:JSON.stringify(b)},a._Store.identityCallInFlight=!0,w.label=1;case 1:return w.trys.push([1,9,,10]),[4/*yield*/,m.upload(n)];case 2:return o=w.sent(),p=void 0,q=void 0,r=o.status,r===HTTP_ACCEPTED?[3/*break*/,3]:r===HTTP_OK?[3/*break*/,3]:r===HTTP_BAD_REQUEST?[3/*break*/,3]:[3/*break*/,7];case 3:return o.json?[4/*yield*/,o.json()]:[3/*break*/,5];case 4:return s=w.sent(),p=this.getIdentityResponseFromFetch(o,s),[3/*break*/,6];case 5:p=this.getIdentityResponseFromXHR(o),w.label=6;case 6:return p.status===HTTP_BAD_REQUEST?(t=p.responseText,q="Issue with sending Identity Request to mParticle Servers, received HTTP Code of "+p.status,(null===t||void 0===t?void 0:t.Errors)&&(u=t.Errors.map(function(a){return a.message}).join(", "),q+=" - "+u)):(q="Received Identity Response from server: ",q+=JSON.stringify(p.responseText)),[3/*break*/,8];case 7:throw new Error("Received HTTP Code of "+o.status);case 8:return a._Store.identityCallInFlight=!1,j.verbose(q),f(p,k,d,e,c,h,!1),[3/*break*/,10];case 9:return v=w.sent(),a._Store.identityCallInFlight=!1,u=v.message||v.toString(),j.error("Error sending identity request to servers - "+u),i(d,HTTPCodes$1.noHttpCoverage,u),[3/*break*/,10];case 10:return [2/*return*/]}})})},this.getUploadUrl=function(b,c){var d=a._Helpers.createServiceUrl(a._Store.SDKConfig.identityUrl),e=b===Modify?d+c+"/"+b:d+b;return e},this.getIdentityResponseFromFetch=function(a,b){return {status:a.status,responseText:b,cacheMaxAge:parseInt(a.headers.get(CACHE_HEADER))||0,expireTimestamp:0}},this.getIdentityResponseFromXHR=function(a){return {status:a.status,responseText:a.responseText?JSON.parse(a.responseText):{},cacheMaxAge:parseNumber(a.getResponseHeader(CACHE_HEADER)||""),expireTimestamp:0}};}
|
|
1403
1404
|
|
|
1404
1405
|
// The formatted ClickID value must be of the form version.subdomainIndex.creationTime.<fbclid>, where:
|
|
1405
1406
|
// - version is always this prefix: fb
|
|
@@ -1470,6 +1471,19 @@ return !!(this.kit&&this.kit.launcher)},a.prototype.setUserAttributes=function(a
|
|
|
1470
1471
|
null===(a=this.logger)||void 0===a?void 0:a.verbose("RoktManager: Processing ".concat(this.messageQueue.size," queued messages")),this.messageQueue.forEach(function(a){var c,d,e;if(!(a.methodName in b)||!isFunction(b[a.methodName]))return void(null===(c=b.logger)||void 0===c?void 0:c.error("RoktManager: Method ".concat(a.methodName," not found")));null===(d=b.logger)||void 0===d?void 0:d.verbose("RoktManager: Processing queued message: ".concat(a.methodName," with payload: ").concat(JSON.stringify(a.payload)));try{var f=b[a.methodName](a.payload);b.completePendingPromise(a.messageId,f);}catch(c){var g=c instanceof Error?c.message:c+"";null===(e=b.logger)||void 0===e?void 0:e.error("RoktManager: Error processing message '".concat(a.methodName,"': ").concat(g)),b.completePendingPromise(a.messageId,Promise.reject(c));}}),this.messageQueue.clear());},a.prototype.queueMessage=function(a){this.messageQueue.set(a.messageId,a);},a.prototype.deferredCall=function(a,b){var c=this;return new Promise(function(d,e){var f="".concat(a,"_").concat(generateUniqueId());c.queueMessage({messageId:f,methodName:a,payload:b,resolve:d,reject:e});})},a.prototype.completePendingPromise=function(a,b){if(a&&this.messageQueue.has(a)){var c=this.messageQueue.get(a);c.resolve&&Promise.resolve(b).then(function(a){return c.resolve(a)})["catch"](function(a){return c.reject(a)}),this.messageQueue["delete"](a);}},a.prototype.sha256Hex=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d;return __generator(this,function(e){switch(e.label){case 0:return b=new TextEncoder,c=b.encode(a),[4/*yield*/,crypto.subtle.digest("SHA-256",c)];case 1:return d=e.sent(),[2/*return*/,this.arrayBufferToHex(d)]}})})},a.prototype.arrayBufferToHex=function(a){for(var b,c=new Uint8Array(a),d="",e=0;e<c.length;e++)b=c[e].toString(16).padStart(2,"0"),d+=b;return d},a.prototype.hasIdentityChanged=function(a,b){return !!b&&(!a||a!==b);// Values are the same
|
|
1471
1472
|
},a}();
|
|
1472
1473
|
|
|
1474
|
+
/**
|
|
1475
|
+
* CookieConsentManager handles storage and access of consent flags (noFunctional, noTargeting)
|
|
1476
|
+
* that are passed via launcherOptions during SDK initialization.
|
|
1477
|
+
*
|
|
1478
|
+
* These flags allow Rokt integration to respect user privacy choices.
|
|
1479
|
+
*
|
|
1480
|
+
* Default behavior: Both flags default to false, meaning all features are allowed
|
|
1481
|
+
* unless explicitly opted out by the user.
|
|
1482
|
+
*/var CookieConsentManager=/** @class */function(){function a(a){this.flags=a,this.flags={noFunctional:!0===a.noFunctional,noTargeting:!0===a.noTargeting};}/**
|
|
1483
|
+
* Returns true if third-party targeting is disabled.
|
|
1484
|
+
* Targeting is allowed when noTargeting is false (default).
|
|
1485
|
+
*/return a.prototype.getNoTargeting=function(){return this.flags.noTargeting},a.prototype.getNoFunctional=function(){return this.flags.noFunctional},a}();
|
|
1486
|
+
|
|
1473
1487
|
var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,CaptureIntegrationSpecificIdsV2Modes=Constants.CaptureIntegrationSpecificIdsV2Modes,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,CaptureIntegrationSpecificIdsV2=FeatureFlags.CaptureIntegrationSpecificIdsV2,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
|
|
1474
1488
|
* <p>All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced <a href="https://docs.mparticle.com/developers/sdk/web/multiple-instances/">multiple instances</a>. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.</p>
|
|
1475
1489
|
* <p>In current versions of mParticle, if your site has one instance, that instance name is 'default_instance'. Any methods called on mParticle on a site with one instance will be mapped to the `default_instance`.</p>
|
|
@@ -1485,7 +1499,7 @@ var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Const
|
|
|
1485
1499
|
this._instanceName=a,this._NativeSdkHelpers=new NativeSdkHelpers(this),this._SessionManager=new SessionManager(this),this._Persistence=new _Persistence(this),this._Helpers=new Helpers(this),this._Events=new Events(this),this._CookieSyncManager=new CookieSyncManager(this),this._ServerModel=new ServerModel(this),this._Ecommerce=new Ecommerce(this),this._ForwardingStatsUploader=new forwardingStatsUploader(this),this._Consent=new Consent(this),this._IdentityAPIClient=new IdentityAPIClient(this),this._preInit={readyQueue:[],integrationDelays:{},forwarderConstructors:[]},this._RoktManager=new RoktManager,this.IdentityType=IdentityType,this.EventType=EventType,this.CommerceEventType=CommerceEventType,this.PromotionType=PromotionActionType,this.ProductActionType=ProductActionType,this._Identity=new Identity(this),this.Identity=this._Identity.IdentityAPI,this.generateHash=this._Helpers.generateHash,this.getDeviceId=this._Persistence.getDeviceId,"undefined"!=typeof window&&window.mParticle&&window.mParticle.config&&window.mParticle.config.hasOwnProperty("rq")&&(this._preInit.readyQueue=window.mParticle.config.rq),this.init=function(a,b){var c=this;// config code - Fetch config when requestConfig = true, otherwise, proceed with SDKInitialization
|
|
1486
1500
|
// Since fetching the configuration is asynchronous, we must pass completeSDKInitialization
|
|
1487
1501
|
// to it for it to be run after fetched
|
|
1488
|
-
if(b||console.warn("You did not pass a config object to init(). mParticle will not initialize properly"),runPreConfigFetchInitialization(this,a,b),!b)return void console.error("No config available on the window, please pass a config object to mParticle.init()");if(!b.hasOwnProperty("requestConfig")||b.requestConfig){var d=new ConfigAPIClient(a,b,this);d.getSDKConfiguration().then(function(d){var e=c._Helpers.extend({},b,d);completeSDKInitialization(a,e,c);});}else completeSDKInitialization(a,b,this);},this.setLogLevel=function(a){b.Logger.setLogLevel(a);},this.reset=function(a){try{a._Persistence.resetPersistence(),a._Store&&delete a._Store;}catch(a){console.error("Cannot reset mParticle",a);}},this._resetForTests=function(a,b,c){c._Store&&delete c._Store,c._Store=new Store(a,c),c._Store.isLocalStorageAvailable=c._Persistence.determineLocalStorageAvailability(window.localStorage),c._Events.stopTracking(),b||c._Persistence.resetPersistence(),c._Persistence.forwardingStatsBatches.uploadsTable={},c._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=[],c._preInit={readyQueue:[],pixelConfigurations:[],integrationDelays:{},forwarderConstructors:[],isDevelopmentMode:!1};},this.ready=function(a){b.isInitialized()&&"function"==typeof a?a():b._preInit.readyQueue.push(a);},this.getEnvironment=function(){return b._Store.SDKConfig.isDevelopmentMode?Constants.Environment.Development:Constants.Environment.Production},this.getVersion=function(){return Constants.sdkVersion},this.setAppVersion=function(a){var c=queueIfNotInitialized(function(){b.setAppVersion(a);},b);c||(b._Store.SDKConfig.appVersion=a,b._Persistence.update());},this.setDeviceId=function(a){var c=queueIfNotInitialized(function(){b.setDeviceId(a);},b);c||this._Store.setDeviceId(a);},this.isInitialized=function(){return !!b._Store&&b._Store.isInitialized},this.getAppName=function(){return b._Store.SDKConfig.appName},this.setAppName=function(a){var c=queueIfNotInitialized(function(){b.setAppName(a);},b);c||(b._Store.SDKConfig.appName=a);},this.getAppVersion=function(){return b._Store.SDKConfig.appVersion},this.stopTrackingLocation=function(){b._SessionManager.resetSessionTimer(),b._Events.stopTracking();},this.startTrackingLocation=function(a){isFunction(a)||b.Logger.warning("Warning: Location tracking is triggered, but not including a callback into the `startTrackingLocation` may result in events logged too quickly and not being associated with a location."),b._SessionManager.resetSessionTimer(),b._Events.startTracking(a);},this.setPosition=function(a,c){var d=queueIfNotInitialized(function(){b.setPosition(a,c);},b);d||(b._SessionManager.resetSessionTimer(),"number"==typeof a&&"number"==typeof c?b._Store.currentPosition={lat:a,lng:c}:b.Logger.error("Position latitude and/or longitude must both be of type number"));},this.startNewSession=function(){b._SessionManager.startNewSession();},this.endSession=function(){// Sends true as an over ride vs when endSession is called from the setInterval
|
|
1502
|
+
if(b||console.warn("You did not pass a config object to init(). mParticle will not initialize properly"),runPreConfigFetchInitialization(this,a,b),!b)return void console.error("No config available on the window, please pass a config object to mParticle.init()");if(!b.hasOwnProperty("requestConfig")||b.requestConfig){var d=new ConfigAPIClient(a,b,this);d.getSDKConfiguration().then(function(d){var e=c._Helpers.extend({},b,d);completeSDKInitialization(a,e,c);});}else completeSDKInitialization(a,b,this);},this.setLogLevel=function(a){b.Logger.setLogLevel(a);},this.reset=function(a){try{a._Persistence.resetPersistence(),a._Store&&delete a._Store;}catch(a){console.error("Cannot reset mParticle",a);}},this._resetForTests=function(a,b,c){c._Store&&delete c._Store,c.Logger=new Logger(a),c._Store=new Store(a,c),c._Store.isLocalStorageAvailable=c._Persistence.determineLocalStorageAvailability(window.localStorage),c._Events.stopTracking(),b||c._Persistence.resetPersistence(),c._Persistence.forwardingStatsBatches.uploadsTable={},c._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=[],c._preInit={readyQueue:[],pixelConfigurations:[],integrationDelays:{},forwarderConstructors:[],isDevelopmentMode:!1};},this.ready=function(a){b.isInitialized()&&"function"==typeof a?a():b._preInit.readyQueue.push(a);},this.getEnvironment=function(){return b._Store.SDKConfig.isDevelopmentMode?Constants.Environment.Development:Constants.Environment.Production},this.getVersion=function(){return Constants.sdkVersion},this.setAppVersion=function(a){var c=queueIfNotInitialized(function(){b.setAppVersion(a);},b);c||(b._Store.SDKConfig.appVersion=a,b._Persistence.update());},this.setDeviceId=function(a){var c=queueIfNotInitialized(function(){b.setDeviceId(a);},b);c||this._Store.setDeviceId(a);},this.isInitialized=function(){return !!b._Store&&b._Store.isInitialized},this.getAppName=function(){return b._Store.SDKConfig.appName},this.setAppName=function(a){var c=queueIfNotInitialized(function(){b.setAppName(a);},b);c||(b._Store.SDKConfig.appName=a);},this.getAppVersion=function(){return b._Store.SDKConfig.appVersion},this.stopTrackingLocation=function(){b._SessionManager.resetSessionTimer(),b._Events.stopTracking();},this.startTrackingLocation=function(a){isFunction(a)||b.Logger.warning("Warning: Location tracking is triggered, but not including a callback into the `startTrackingLocation` may result in events logged too quickly and not being associated with a location."),b._SessionManager.resetSessionTimer(),b._Events.startTracking(a);},this.setPosition=function(a,c){var d=queueIfNotInitialized(function(){b.setPosition(a,c);},b);d||(b._SessionManager.resetSessionTimer(),"number"==typeof a&&"number"==typeof c?b._Store.currentPosition={lat:a,lng:c}:b.Logger.error("Position latitude and/or longitude must both be of type number"));},this.startNewSession=function(){b._SessionManager.startNewSession();},this.endSession=function(){// Sends true as an over ride vs when endSession is called from the setInterval
|
|
1489
1503
|
b._SessionManager.endSession(!0);},this.logBaseEvent=function(a,c){var d=queueIfNotInitialized(function(){b.logBaseEvent(a,c);},b);if(!d)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a.name)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(a.eventType||(a.eventType=EventType.Unknown),b._Helpers.canLog()?void b._Events.logEvent(a,c):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled))},this.logEvent=function(a,c,d,e,f){var g=queueIfNotInitialized(function(){b.logEvent(a,c,d,e,f);},b);if(!g)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(c||(c=EventType.Unknown),b._Helpers.isEventType(c)?b._Helpers.canLog()?void b._Events.logEvent({messageType:MessageType$1.PageEvent,name:a,data:d,eventType:c,customFlags:e},f):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled):void b.Logger.error("Invalid event type: "+c+", must be one of: \n"+JSON.stringify(EventType)))},this.logError=function(a,c){var d=queueIfNotInitialized(function(){b.logError(a,c);},b);if(!d&&(b._SessionManager.resetSessionTimer(),!!a)){"string"==typeof a&&(a={message:a});var e={m:a.message?a.message:a,s:"Error",t:a.stack||null};if(c){var f=b._Helpers.sanitizeAttributes(c,e.m);for(var g in f)e[g]=f[g];}b._Events.logEvent({messageType:MessageType$1.CrashReport,name:a.name?a.name:"Error",eventType:EventType.Other,data:e});}},this.logLink=function(a,c,d,e){b._Events.addEventHandler("click",a,c,e,d);},this.logForm=function(a,c,d,e){b._Events.addEventHandler("submit",a,c,e,d);},this.logPageView=function(a,c,d,e){var f=queueIfNotInitialized(function(){b.logPageView(a,c,d,e);},b);if(!f){if(b._SessionManager.resetSessionTimer(),b._Helpers.canLog()){if(b._Helpers.Validators.isStringOrNumber(a)||(a="PageView"),!c)c={hostname:window.location.hostname,title:window.document.title};else if(!b._Helpers.isObject(c))return void b.Logger.error("The attributes argument must be an object. A "+_typeof$1(c)+" was entered. Please correct and retry.");if(d&&!b._Helpers.isObject(d))return void b.Logger.error("The customFlags argument must be an object. A "+_typeof$1(d)+" was entered. Please correct and retry.")}b._Events.logEvent({messageType:MessageType$1.PageView,name:a,data:c,eventType:EventType.Unknown,customFlags:d},e);}},this.upload=function(){var a,c;b._Helpers.canLog()&&(b._Store.webviewBridgeEnabled?b._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Upload):null===(c=null===(a=b._APIClient)||void 0===a?void 0:a.uploader)||void 0===c?void 0:c.prepareAndUpload(!1,!1));},this.Consent={/**
|
|
1490
1504
|
* Creates a CCPA Opt Out Consent State.
|
|
1491
1505
|
*
|
|
@@ -1654,7 +1668,8 @@ function createKitBlocker(a,b){var c,d,e,f;/* There are three ways a data plan
|
|
|
1654
1668
|
If not passed in manually, we user the server provided via either
|
|
1655
1669
|
2. Snippet via /mparticle.js endpoint (config.dataPlan.document)
|
|
1656
1670
|
3. Self hosting via /config endpoint (config.dataPlanResult)
|
|
1657
|
-
*/return a.dataPlanOptions&&(b.Logger.verbose("Customer provided data plan found"),f=a.dataPlanOptions,d={document:{dtpn:{vers:f.dataPlanVersion,blok:{ev:f.blockEvents,ea:f.blockEventAttributes,ua:f.blockUserAttributes,id:f.blockUserIdentities}}}}),d||(a.dataPlan&&a.dataPlan.document?a.dataPlan.document.error_message?e=a.dataPlan.document.error_message:(b.Logger.verbose("Data plan found from mParticle.js"),d=a.dataPlan):a.dataPlanResult&&(a.dataPlanResult.error_message?e=a.dataPlanResult.error_message:(b.Logger.verbose("Data plan found from /config"),d={document:a.dataPlanResult}))),e&&b.Logger.error(e),d&&(c=new KitBlocker(d,b)),c}function createIdentityCache(a){return new LocalStorageVault("".concat(a._Store.storageName,"-id-cache"),{logger:a.Logger})}function runPreConfigFetchInitialization(a,b,c){a.Logger=new Logger(c),a._Store=new Store(c,a,b),window.mParticle.Store=a._Store,a.Logger.verbose(StartingInitialization);//
|
|
1671
|
+
*/return a.dataPlanOptions&&(b.Logger.verbose("Customer provided data plan found"),f=a.dataPlanOptions,d={document:{dtpn:{vers:f.dataPlanVersion,blok:{ev:f.blockEvents,ea:f.blockEventAttributes,ua:f.blockUserAttributes,id:f.blockUserIdentities}}}}),d||(a.dataPlan&&a.dataPlan.document?a.dataPlan.document.error_message?e=a.dataPlan.document.error_message:(b.Logger.verbose("Data plan found from mParticle.js"),d=a.dataPlan):a.dataPlanResult&&(a.dataPlanResult.error_message?e=a.dataPlanResult.error_message:(b.Logger.verbose("Data plan found from /config"),d={document:a.dataPlanResult}))),e&&b.Logger.error(e),d&&(c=new KitBlocker(d,b)),c}function createIdentityCache(a){return new LocalStorageVault("".concat(a._Store.storageName,"-id-cache"),{logger:a.Logger})}function runPreConfigFetchInitialization(a,b,c){var d;a.Logger=new Logger(c),a._Store=new Store(c,a,b),window.mParticle.Store=a._Store,a.Logger.verbose(StartingInitialization);// Initialize CookieConsentManager with privacy flags from launcherOptions
|
|
1672
|
+
var e=null!==(d=null===c||void 0===c?void 0:c.launcherOptions)&&void 0!==d?d:{},f=e.noFunctional,g=e.noTargeting;a._CookieConsentManager=new CookieConsentManager({noFunctional:f,noTargeting:g});// Check to see if localStorage is available before main configuration runs
|
|
1658
1673
|
// since we will need this for the current implementation of user persistence
|
|
1659
1674
|
// TODO: Refactor this when we refactor User Identity Persistence
|
|
1660
1675
|
try{a._Store.isLocalStorageAvailable=a._Persistence.determineLocalStorageAvailability(window.localStorage);}catch(b){a.Logger.warning("localStorage is not available, using cookies if available"),a._Store.isLocalStorageAvailable=!1;}}function processIdentityCallback(a,b,c,d){!a._Store.identifyCalled&&a._Store.SDKConfig.identityCallback&&b&&c&&a._Store.SDKConfig.identityCallback({httpCode:HTTPCodes.activeSession,getUser:function getUser(){return a._Identity.mParticleUser(c)},getPreviousUser:function getPreviousUser(){var b=a.Identity.getUsers(),d=b.shift(),e=d.getMPID();return d&&e===c&&(d=b.shift()),d||null},body:{mpid:c,is_logged_in:a._Store.isLoggedIn,matched_identities:d,context:null,is_ephemeral:!1}});}function queueIfNotInitialized(a,b){return !b.isInitialized()&&(b.ready(function(){a();}),!0)}
|
package/dist/mparticle.esm.js
CHANGED
|
@@ -15,7 +15,7 @@ map:function map(a,b){var c,d,e;if(null===this)throw new TypeError(" this is nul
|
|
|
15
15
|
filter:function filter(a/*, thisArg*/){if(void 0===this||null===this)throw new TypeError;var b=Object(this),c=b.length>>>0;if("function"!=typeof a)throw new TypeError;for(var d=[],e=2<=arguments.length?arguments[1]:void 0,f=0;f<c;f++)if(f in b){var g=b[f];a.call(e,g,f,b)&&d.push(g);}return d},// https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/isArray
|
|
16
16
|
isArray:function isArray(a){return "[object Array]"===Object.prototype.toString.call(a)},Base64:Base64$1};
|
|
17
17
|
|
|
18
|
-
var version = "2.
|
|
18
|
+
var version = "2.53.0";
|
|
19
19
|
|
|
20
20
|
var Constants={sdkVersion:version,sdkVendor:"mparticle",platform:"web",Messages:{DeprecationMessages:{MethodHasBeenDeprecated:"has been deprecated.",MethodMarkedForDeprecationPostfix:"is a deprecated method and will be removed in future releases.",AlternativeMethodPrefix:"Please use the alternate method:"},ErrorMessages:{NoToken:"A token must be specified.",EventNameInvalidType:"Event name must be a valid string value.",EventDataInvalidType:"Event data must be a valid object hash.",LoggingDisabled:"Event logging is currently disabled.",CookieParseError:"Could not parse cookie",EventEmpty:"Event object is null or undefined, cancelling send",APIRequestEmpty:"APIRequest is null or undefined, cancelling send",NoEventType:"Event type must be specified.",TransactionIdRequired:"Transaction ID is required",TransactionRequired:"A transaction attributes object is required",PromotionIdRequired:"Promotion ID is required",BadAttribute:"Attribute value cannot be object or array",BadKey:"Key value cannot be object or array",BadLogPurchase:"Transaction attributes and a product are both required to log a purchase, https://docs.mparticle.com/?javascript#measuring-transactions",AudienceAPINotEnabled:"Your workspace is not enabled to retrieve user audiences."},InformationMessages:{CookieSearch:"Searching for cookie",CookieFound:"Cookie found, parsing values",CookieNotFound:"Cookies not found",CookieSet:"Setting cookie",CookieSync:"Performing cookie sync",SendBegin:"Starting to send event",SendIdentityBegin:"Starting to send event to identity server",SendWindowsPhone:"Sending event to Windows Phone container",SendIOS:"Calling iOS path: ",SendAndroid:"Calling Android JS interface method: ",SendHttp:"Sending event to mParticle HTTP service",SendAliasHttp:"Sending alias request to mParticle HTTP service",SendIdentityHttp:"Sending event to mParticle HTTP service",StartingNewSession:"Starting new Session",StartingLogEvent:"Starting to log event",StartingLogOptOut:"Starting to log user opt in/out",StartingEndSession:"Starting to end session",StartingInitialization:"Starting to initialize",StartingLogCommerceEvent:"Starting to log commerce event",StartingAliasRequest:"Starting to Alias MPIDs",LoadingConfig:"Loading configuration options",AbandonLogEvent:"Cannot log event, logging disabled or developer token not set",AbandonAliasUsers:"Cannot Alias Users, logging disabled or developer token not set",AbandonStartSession:"Cannot start session, logging disabled or developer token not set",AbandonEndSession:"Cannot end session, logging disabled or developer token not set",NoSessionToEnd:"Cannot end session, no active session found"},ValidationMessages:{ModifyIdentityRequestUserIdentitiesPresent:"identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again",IdentityRequesetInvalidKey:"There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.",OnUserAliasType:"The onUserAlias value must be a function.",UserIdentities:"The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidKey:"There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.",UserIdentitiesInvalidValues:"All user identity values must be strings or null. Request not sent to server. Please fix and try again.",AliasMissingMpid:"Alias Request must contain both a destinationMpid and a sourceMpid",AliasNonUniqueMpid:"Alias Request's destinationMpid and sourceMpid must be unique",AliasMissingTime:"Alias Request must have both a startTime and an endTime",AliasStartBeforeEndTime:"Alias Request's endTime must be later than its startTime"}},NativeSdkPaths:{LogEvent:"logEvent",SetUserTag:"setUserTag",RemoveUserTag:"removeUserTag",SetUserAttribute:"setUserAttribute",RemoveUserAttribute:"removeUserAttribute",SetSessionAttribute:"setSessionAttribute",AddToCart:"addToCart",RemoveFromCart:"removeFromCart",ClearCart:"clearCart",LogOut:"logOut",SetUserAttributeList:"setUserAttributeList",RemoveAllUserAttributes:"removeAllUserAttributes",GetUserAttributesLists:"getUserAttributesLists",GetAllUserAttributes:"getAllUserAttributes",Identify:"identify",Logout:"logout",Login:"login",Modify:"modify",Alias:"aliasUsers",Upload:"upload"},StorageNames:{localStorageName:"mprtcl-api",localStorageNameV3:"mprtcl-v3",cookieName:"mprtcl-api",cookieNameV2:"mprtcl-v2",cookieNameV3:"mprtcl-v3",localStorageNameV4:"mprtcl-v4",localStorageProductsV4:"mprtcl-prodv4",cookieNameV4:"mprtcl-v4",currentStorageName:"mprtcl-v4",currentStorageProductsName:"mprtcl-prodv4"},DefaultConfig:{cookieDomain:null,cookieExpiration:365,logLevel:null,timeout:300,sessionTimeout:30,maxProducts:20,forwarderStatsTimeout:5e3,integrationDelayTimeout:5e3,maxCookieSize:3e3,aliasMaxWindow:90,uploadInterval:0// Maximum milliseconds in between batch uploads, below 500 will mean immediate upload. The server returns this as a string, but we are using it as a number internally
|
|
21
21
|
},DefaultBaseUrls:{v1SecureServiceUrl:"jssdks.mparticle.com/v1/JS/",v2SecureServiceUrl:"jssdks.mparticle.com/v2/JS/",v3SecureServiceUrl:"jssdks.mparticle.com/v3/JS/",configUrl:"jssdkcdns.mparticle.com/JS/v2/",identityUrl:"identity.mparticle.com/v1/",aliasUrl:"jssdks.mparticle.com/v1/identity/",userAudienceUrl:"nativesdks.mparticle.com/v1/"},// These are the paths that are used to construct the CNAME urls
|
|
@@ -160,7 +160,7 @@ function _typeof$1(o) {
|
|
|
160
160
|
}, _typeof$1(o);
|
|
161
161
|
}
|
|
162
162
|
|
|
163
|
-
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={}));
|
|
163
|
+
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={}));var LogLevelType={None:"none",Verbose:"verbose",Warning:"warning",Error:"error"};
|
|
164
164
|
|
|
165
165
|
function getDefaultExportFromCjs (x) {
|
|
166
166
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -456,7 +456,7 @@ return e>=f},a.prototype.shouldDebounceAndUpdateLastASTTime=function(){var a=Dat
|
|
|
456
456
|
if(s){this.mpInstance._IntegrationCapture.capture();var t=this.mpInstance._IntegrationCapture.getClickIdsAsCustomFlags();o=__assign(__assign({},t),o);var u=this.mpInstance._IntegrationCapture.getClickIdsAsIntegrationAttributes();p=__assign(__assign({},u),p);}return n.CustomFlags=o,n.IntegrationAttributes=p,appendUserInfo(m(),n),n},a.prototype.addEventListeners=function(){var a=this,b=this,c=function(){// Check for debounce before creating and queueing event
|
|
457
457
|
var c=a.mpInstance._Helpers.getFeatureFlag,d=Constants.FeatureFlags.AstBackgroundEvents;if(c(d)){if(b.shouldDebounceAndUpdateLastASTTime())return;// Add application state transition event to queue
|
|
458
458
|
var e=b.createBackgroundASTEvent();b.queueEvent(e);}// Then trigger the upload with beacon
|
|
459
|
-
b.prepareAndUpload(!1,b.isBeaconAvailable());};document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&c();}),window.addEventListener("beforeunload",c),window.addEventListener("pagehide",c);},a.prototype.isBeaconAvailable=function(){return !!navigator.sendBeacon},a.prototype.triggerUploadInterval=function(a,b){var c=this;void 0===a&&(a=!1),void 0===b&&(b=!1),setTimeout(function(){c.prepareAndUpload(a,b);},this.uploadIntervalMillis);},a.prototype.queueEvent=function(a){if(!isEmpty(a)){var b=this.mpInstance.Logger
|
|
459
|
+
b.prepareAndUpload(!1,b.isBeaconAvailable());};document.addEventListener("visibilitychange",function(){"hidden"===document.visibilityState&&c();}),window.addEventListener("beforeunload",c),window.addEventListener("pagehide",c);},a.prototype.isBeaconAvailable=function(){return !!navigator.sendBeacon},a.prototype.triggerUploadInterval=function(a,b){var c=this;void 0===a&&(a=!1),void 0===b&&(b=!1),setTimeout(function(){c.prepareAndUpload(a,b);},this.uploadIntervalMillis);},a.prototype.queueEvent=function(a){if(!isEmpty(a)){var b=this.mpInstance.Logger;this.eventsQueuedForProcessing.push(a),this.offlineStorageEnabled&&this.eventVault&&this.eventVault.store(this.eventsQueuedForProcessing),b.verbose("Queuing event: ".concat(JSON.stringify(a))),b.verbose("Queued event count: ".concat(this.eventsQueuedForProcessing.length)),this.shouldTriggerImmediateUpload(a.EventDataType)&&this.prepareAndUpload(!1,!1);}},a.prototype.shouldTriggerImmediateUpload=function(a){var b=[MessageType$1.Commerce,MessageType$1.UserIdentityChange];return !this.batchingEnabled||b.includes(a)},(a.createNewBatches=function(a,b,c){if(!b||!a||!a.length)return null;//bucket by MPID, and then by session, ordered by timestamp
|
|
460
460
|
for(var d,e=[],f=new Map,g=0,h=a;g<h.length;g++){//on initial startup, there may be events logged without an mpid.
|
|
461
461
|
if(d=h[g],!d.MPID){var i=b.getMPID();d.MPID=i;}var j=f.get(d.MPID);j||(j=[]),j.push(d),f.set(d.MPID,j);}for(var k=0,l=Array.from(f.entries());k<l.length;k++){for(var m=l[k],i=m[0],n=m[1],o=new Map,p=0,q=n;p<q.length;p++){var d=q[p],j=o.get(d.SessionId);j||(j=[]),j.push(d),o.set(d.SessionId,j);}for(var r=0,s=Array.from(o.entries());r<s.length;r++){var t=s[r],u=convertEvents(i,t[1],c),v=c._Store.SDKConfig.onCreateBatch;v&&(u=v(u),u?u.modified=!0:c.Logger.warning("Skiping batch upload because no batch was returned from onCreateBatch callback")),u&&e.push(u);}}return e},a.prototype.prepareAndUpload=function(b,c){return void 0===b&&(b=!1),void 0===c&&(c=!1),__awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k;return __generator(this,function(l){switch(l.label){case 0:return d=this.mpInstance.Identity.getCurrentUser(),e=this.eventsQueuedForProcessing,this.eventsQueuedForProcessing=[],this.offlineStorageEnabled&&this.eventVault&&this.eventVault.store([]),f=[],isEmpty(e)||(f=a.createNewBatches(e,d,this.mpInstance)),this.offlineStorageEnabled&&this.batchVault&&((i=this.batchesQueuedForProcessing).unshift.apply(i,this.batchVault.retrieve()),this.batchVault.purge()),isEmpty(f)||(j=this.batchesQueuedForProcessing).push.apply(j,f),g=this.batchesQueuedForProcessing,this.batchesQueuedForProcessing=[],[4/*yield*/,this.uploadBatches(this.mpInstance.Logger,g,c)];case 1:return h=l.sent(),isEmpty(h)||(k=this.batchesQueuedForProcessing).unshift.apply(k,h),!c&&this.offlineStorageEnabled&&this.batchVault&&(this.batchVault.store(this.batchesQueuedForProcessing),this.batchesQueuedForProcessing=[]),b&&this.triggerUploadInterval(b,!1),[2/*return*/]}})})},a.prototype.uploadBatches=function(b,c,d){return __awaiter(this,void 0,void 0,function(){var e,f,g,h,j,k;return __generator(this,function(i){switch(i.label){case 0:if(e=c.filter(function(a){return !isEmpty(a.events)}),isEmpty(e))return [2/*return*/,null];b.verbose("Uploading batches: ".concat(JSON.stringify(e))),b.verbose("Batch count: ".concat(e.length)),f=0,i.label=1;case 1:return f<e.length?(g={method:"POST",headers:{Accept:a.CONTENT_TYPE,"Content-Type":"text/plain;charset=UTF-8"},body:JSON.stringify(e[f])},!(d&&this.isBeaconAvailable()))?[3/*break*/,2]:(h=new Blob([g.body],{type:"text/plain;charset=UTF-8"}),navigator.sendBeacon(this.uploadUrl,h),[3/*break*/,5]):[3/*break*/,6];case 2:return i.trys.push([2,4,,5]),[4/*yield*/,this.uploader.upload(g)];case 3:if(j=i.sent(),200<=j.status&&300>j.status)b.verbose("Upload success for request ID: ".concat(e[f].source_request_id));else {if(500<=j.status||429===j.status)// Server error, add back current batches and try again later
|
|
462
462
|
return b.error("HTTP error status ".concat(j.status," received")),[2/*return*/,e.slice(f,e.length)];if(401<=j.status)//if we're getting a 401, assume we'll keep getting a 401 and clear the uploads.
|
|
@@ -509,13 +509,14 @@ return !!(window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHan
|
|
|
509
509
|
},this.isBridgeV1Available=function(){return !!(a._Store.SDKConfig.useNativeSdk||window.mParticleAndroid||a._Store.SDKConfig.isIOS)},this.sendToNative=function(c,d){return a._Store.bridgeV2Available&&2===a._Store.SDKConfig.minWebviewBridgeVersion?void b.sendViaBridgeV2(c,d,a._Store.SDKConfig.requiredWebviewBridgeName):a._Store.bridgeV2Available&&2>a._Store.SDKConfig.minWebviewBridgeVersion?void b.sendViaBridgeV2(c,d,a._Store.SDKConfig.requiredWebviewBridgeName):a._Store.bridgeV1Available&&2>a._Store.SDKConfig.minWebviewBridgeVersion?void b.sendViaBridgeV1(c,d):void 0},this.sendViaBridgeV1=function(c,d){window.mParticleAndroid&&window.mParticleAndroid.hasOwnProperty(c)?(a.Logger.verbose(Messages$8.InformationMessages.SendAndroid+c),window.mParticleAndroid[c](d)):a._Store.SDKConfig.isIOS&&(a.Logger.verbose(Messages$8.InformationMessages.SendIOS+c),b.sendViaIframeToIOS(c,d));},this.sendViaIframeToIOS=function(a,b){var c=document.createElement("IFRAME");c.setAttribute("src","mp-sdk://"+a+"/"+encodeURIComponent(b)),document.documentElement.appendChild(c),c.parentNode.removeChild(c);},this.sendViaBridgeV2=function(c,d,e){if(e){var f,g,h=window[androidBridgeNameBase+"_"+e+"_v2"],i=iosBridgeNameBase+"_"+e+"_v2";return window.webkit&&window.webkit.messageHandlers&&window.webkit.messageHandlers[i]&&(f=window.webkit.messageHandlers[i]),a.uiwebviewBridgeName===i&&(g=a[i]),h&&h.hasOwnProperty(c)?(a.Logger.verbose(Messages$8.InformationMessages.SendAndroid+c),void h[c](d)):void(f?(a.Logger.verbose(Messages$8.InformationMessages.SendIOS+c),f.postMessage(JSON.stringify({path:c,value:d?JSON.parse(d):null}))):g&&(a.Logger.verbose(Messages$8.InformationMessages.SendIOS+c),b.sendViaIframeToIOS(c,d)))}};}
|
|
510
510
|
|
|
511
511
|
var Messages$7=Constants.Messages,InformationMessages=Messages$7.InformationMessages;var DAYS_IN_MILLISECONDS=86400000;// Partner module IDs for cookie sync configurations
|
|
512
|
-
var PARTNER_MODULE_IDS={AdobeEventForwarder:11,DoubleclickDFP:41,AppNexus:50,Lotame:58,TradeDesk:103,VerizonMedia:155};function CookieSyncManager(a){var b=this;// Public
|
|
512
|
+
var PARTNER_MODULE_IDS={AdobeEventForwarder:11,DoubleclickDFP:41,AppNexus:50,Lotame:58,TradeDesk:103,VerizonMedia:155,Rokt:1277};function CookieSyncManager(a){var b=this;// Public
|
|
513
513
|
// Private
|
|
514
514
|
this.attemptCookieSync=function(c,d){var e=a._Store,f=e.pixelConfigurations,g=e.webviewBridgeEnabled;if(c&&!g){var h=a._Persistence.getPersistence();isEmpty(h)||f.forEach(function(e){var f,g,i=!1,j=e.filteringConsentRuleValues,k=e.pixelUrl,l=e.redirectUrl,m=e.moduleId,// Tells you how often we should do a cookie sync (in days)
|
|
515
515
|
n=e.frequencyCap,o=(j||{}).values;// set requiresConsent to false to start each additional pixel configuration
|
|
516
516
|
// set to true only if filteringConsenRuleValues.values.length exists
|
|
517
517
|
// Filtering rules as defined in UI
|
|
518
|
-
if(!isEmpty(k)&&(isEmpty(o)||(i=!0),!(i&&d)))//
|
|
518
|
+
if(!isEmpty(k)&&(isEmpty(o)||(i=!0),!(i&&d))&&!(m===PARTNER_MODULE_IDS.Rokt&&a._CookieConsentManager.getNoTargeting()))// For Rokt, block cookie sync when noTargeting privacy flag is true
|
|
519
|
+
// If MPID is new to cookies, we should not try to perform the cookie sync
|
|
519
520
|
// because a cookie sync can only occur once a user either consents or doesn't.
|
|
520
521
|
// we should not check if it's enabled if the user has a blank consent
|
|
521
522
|
// The Trade Desk requires a URL parameter for GDPR enabled users.
|
|
@@ -611,7 +612,7 @@ for(var g in c){// Any custom endpoints passed to mpConfig will take priority ov
|
|
|
611
612
|
// mapping to the silo. The most common use case is a customer provided CNAME.
|
|
612
613
|
if("configUrl"==g){d[g]=a[g]||c[g];continue}if(a.hasOwnProperty(g))d[g]=a[g];else {var h=c[g].split(".");d[g]=__spreadArray([h[0],f],h.slice(1),!0).join(".");}}return d}
|
|
613
614
|
|
|
614
|
-
|
|
615
|
+
var Logger=/** @class */function(){function a(a){var b,c;this.logLevel=null!==(b=a.logLevel)&&void 0!==b?b:LogLevelType.Warning,this.logger=null!==(c=a.logger)&&void 0!==c?c:new ConsoleLogger;}return a.prototype.verbose=function(a){this.logLevel===LogLevelType.None||this.logger.verbose&&this.logLevel===LogLevelType.Verbose&&this.logger.verbose(a);},a.prototype.warning=function(a){this.logLevel===LogLevelType.None||this.logger.warning&&(this.logLevel===LogLevelType.Verbose||this.logLevel===LogLevelType.Warning)&&this.logger.warning(a);},a.prototype.error=function(a){this.logLevel===LogLevelType.None||this.logger.error&&this.logger.error(a);},a.prototype.setLogLevel=function(a){this.logLevel=a;},a}();var ConsoleLogger=/** @class */function(){function a(){}return a.prototype.verbose=function(a){console&&console.info&&console.info(a);},a.prototype.error=function(a){console&&console.error&&console.error(a);},a.prototype.warning=function(a){console&&console.warn&&console.warn(a);},a}();
|
|
615
616
|
|
|
616
617
|
var Base64=Polyfill.Base64,Messages$4=Constants.Messages,Base64CookieKeys=Constants.Base64CookieKeys,SDKv2NonMPIDCookieKeys=Constants.SDKv2NonMPIDCookieKeys,StorageNames=Constants.StorageNames;function _Persistence(a){function b(b){var c=a._Store;return b.gs.sid=c.sessionId,b.gs.ie=c.isEnabled,b.gs.sa=c.sessionAttributes,b.gs.lsa=c.localSessionAttributes,b.gs.ss=c.serverSettings,b.gs.dt=c.devToken,b.gs.les=c.dateLastEventSent?c.dateLastEventSent.getTime():null,b.gs.av=c.SDKConfig.appVersion,b.gs.cgid=c.clientId,b.gs.das=c.deviceId,b.gs.c=c.context,b.gs.ssd=c.sessionStartDate?c.sessionStartDate.getTime():0,b.gs.ia=c.integrationAttributes,b}function c(a){localStorage.removeItem(a);}function d(a,b,c){return f.encodePersistence(JSON.stringify(a))+";expires="+b+";path=/"+c}var f=this;// https://go.mparticle.com/work/SQDSDKS-5022
|
|
617
618
|
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
@@ -1399,7 +1400,7 @@ return !("boolean"==typeof b&&b)&&"object"===_typeof$1(b)&&!0!==b[a];// When "Bl
|
|
|
1399
1400
|
var buildUrl=function(a,b,c,d){var e=d?"1":"0",f=["env=".concat(e)],g=c||{},h=g.planId,i=g.planVersion;return h&&f.push("plan_id=".concat(h)),i&&f.push("plan_version=".concat(i)),"".concat(a+b+"/config","?").concat(f.join("&"))};function ConfigAPIClient(a,b,c){var d=this,e="https://"+c._Store.SDKConfig.configUrl,f=b.isDevelopmentMode,g=b.dataPlan,h=buildUrl(e,a,g,f),i=window.fetch?new FetchUploader(h):new XHRUploader(h);this.getSDKConfiguration=function(){return __awaiter(d,void 0,void 0,function(){var a,d,e,f,h,j,k;return __generator(this,function(l){switch(l.label){case 0:d={method:"get",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"text/plain;charset=UTF-8"},body:null},l.label=1;case 1:return l.trys.push([1,6,,7]),[4/*yield*/,i.upload(d)];case 2:return (e=l.sent(),200!==e.status)?[3/*break*/,5]:(null===(h=null===c||void 0===c?void 0:c.Logger)||void 0===h?void 0:h.verbose("Successfully received configuration from server"),e.json?[4/*yield*/,e.json()]:[3/*break*/,4]);case 3:return a=l.sent(),[2/*return*/,a];case 4:return f=e,a=JSON.parse(f.responseText),[2/*return*/,a];case 5:return null===(j=null===c||void 0===c?void 0:c.Logger)||void 0===j?void 0:j.verbose("Issue with receiving configuration from server, received HTTP Code of "+e.statusText),[3/*break*/,7];case 6:return l.sent(),null===(k=null===c||void 0===c?void 0:c.Logger)||void 0===k?void 0:k.error("Error getting forwarder configuration from mParticle servers."),[3/*break*/,7];case 7:// Returns the original config object if we cannot retrieve the remote config
|
|
1400
1401
|
return [2/*return*/,b]}})})};}
|
|
1401
1402
|
|
|
1402
|
-
var HTTPCodes$1=Constants.HTTPCodes,Messages$1=Constants.Messages,IdentityMethods=Constants.IdentityMethods,Modify=IdentityMethods.Modify;function IdentityAPIClient(a){this.sendAliasRequest=function(b,c){return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n,o,
|
|
1403
|
+
var HTTPCodes$1=Constants.HTTPCodes,Messages$1=Constants.Messages,IdentityMethods=Constants.IdentityMethods,Modify=IdentityMethods.Modify;function IdentityAPIClient(a){this.sendAliasRequest=function(b,c){return __awaiter(this,void 0,void 0,function(){var d,e,f,g,h,i,j,k,l,m,n,o,q,r,s,n;return __generator(this,function(t){switch(t.label){case 0:d=a.Logger,e=a._Helpers.invokeAliasCallback,f=a._Store.SDKConfig.aliasUrl,g=a._Store.devToken,d.verbose(Messages$1.InformationMessages.SendAliasHttp),h="https://".concat(f).concat(g,"/Alias"),i=window.fetch?new FetchUploader(h):new XHRUploader(h),j={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json"},body:JSON.stringify(b)},t.label=1;case 1:return t.trys.push([1,13,,14]),[4/*yield*/,i.upload(j)];case 2:return k=t.sent(),l=void 0,m=void 0,n=void 0,o=k.status,o===HTTP_ACCEPTED?[3/*break*/,3]:o===HTTP_OK?[3/*break*/,3]:o===HTTP_BAD_REQUEST?[3/*break*/,4]:[3/*break*/,11];case 3:return m="Received Alias Response from server: "+JSON.stringify(k.status),[3/*break*/,12];case 4:if(!k.json)return [3/*break*/,9];t.label=5;case 5:return t.trys.push([5,7,,8]),[4/*yield*/,k.json()];case 6:return l=t.sent(),[3/*break*/,8];case 7:return t.sent(),d.verbose("The request has no response body"),[3/*break*/,8];case 8:return [3/*break*/,10];case 9:q=k,l=q.responseText?JSON.parse(q.responseText):"",t.label=10;case 10:return r=l,(null===r||void 0===r?void 0:r.message)&&(n=r.message),m="Issue with sending Alias Request to mParticle Servers, received HTTP Code of "+k.status,(null===r||void 0===r?void 0:r.code)&&(m+=" - "+r.code),[3/*break*/,12];case 11:throw new Error("Received HTTP Code of "+k.status);case 12:return d.verbose(m),e(c,k.status,n),[3/*break*/,14];case 13:return s=t.sent(),n=s.message||s.toString(),d.error("Error sending alias request to mParticle servers. "+n),e(c,HTTPCodes$1.noHttpCoverage,n),[3/*break*/,14];case 14:return [2/*return*/]}})})},this.sendIdentityRequest=function(b,c,d,e,f,g,h){return __awaiter(this,void 0,void 0,function(){var i,j,k,l,m,n,o,p,q,r,s,t,u,v,u;return __generator(this,function(w){switch(w.label){case 0:if(i=a._Helpers.invokeCallback,j=a.Logger,j.verbose(Messages$1.InformationMessages.SendIdentityBegin),!b)return j.error(Messages$1.ErrorMessages.APIRequestEmpty),[2/*return*/];if(j.verbose(Messages$1.InformationMessages.SendIdentityHttp),a._Store.identityCallInFlight)return i(d,HTTPCodes$1.activeIdentityRequest,"There is currently an Identity request processing. Please wait for this to return before requesting again"),[2/*return*/];k=g||null,l=this.getUploadUrl(c,g),m=window.fetch?new FetchUploader(l):new XHRUploader(l),n={method:"post",headers:{Accept:"text/plain;charset=UTF-8","Content-Type":"application/json","x-mp-key":a._Store.devToken},body:JSON.stringify(b)},a._Store.identityCallInFlight=!0,w.label=1;case 1:return w.trys.push([1,9,,10]),[4/*yield*/,m.upload(n)];case 2:return o=w.sent(),p=void 0,q=void 0,r=o.status,r===HTTP_ACCEPTED?[3/*break*/,3]:r===HTTP_OK?[3/*break*/,3]:r===HTTP_BAD_REQUEST?[3/*break*/,3]:[3/*break*/,7];case 3:return o.json?[4/*yield*/,o.json()]:[3/*break*/,5];case 4:return s=w.sent(),p=this.getIdentityResponseFromFetch(o,s),[3/*break*/,6];case 5:p=this.getIdentityResponseFromXHR(o),w.label=6;case 6:return p.status===HTTP_BAD_REQUEST?(t=p.responseText,q="Issue with sending Identity Request to mParticle Servers, received HTTP Code of "+p.status,(null===t||void 0===t?void 0:t.Errors)&&(u=t.Errors.map(function(a){return a.message}).join(", "),q+=" - "+u)):(q="Received Identity Response from server: ",q+=JSON.stringify(p.responseText)),[3/*break*/,8];case 7:throw new Error("Received HTTP Code of "+o.status);case 8:return a._Store.identityCallInFlight=!1,j.verbose(q),f(p,k,d,e,c,h,!1),[3/*break*/,10];case 9:return v=w.sent(),a._Store.identityCallInFlight=!1,u=v.message||v.toString(),j.error("Error sending identity request to servers - "+u),i(d,HTTPCodes$1.noHttpCoverage,u),[3/*break*/,10];case 10:return [2/*return*/]}})})},this.getUploadUrl=function(b,c){var d=a._Helpers.createServiceUrl(a._Store.SDKConfig.identityUrl),e=b===Modify?d+c+"/"+b:d+b;return e},this.getIdentityResponseFromFetch=function(a,b){return {status:a.status,responseText:b,cacheMaxAge:parseInt(a.headers.get(CACHE_HEADER))||0,expireTimestamp:0}},this.getIdentityResponseFromXHR=function(a){return {status:a.status,responseText:a.responseText?JSON.parse(a.responseText):{},cacheMaxAge:parseNumber(a.getResponseHeader(CACHE_HEADER)||""),expireTimestamp:0}};}
|
|
1403
1404
|
|
|
1404
1405
|
// The formatted ClickID value must be of the form version.subdomainIndex.creationTime.<fbclid>, where:
|
|
1405
1406
|
// - version is always this prefix: fb
|
|
@@ -1470,6 +1471,19 @@ return !!(this.kit&&this.kit.launcher)},a.prototype.setUserAttributes=function(a
|
|
|
1470
1471
|
null===(a=this.logger)||void 0===a?void 0:a.verbose("RoktManager: Processing ".concat(this.messageQueue.size," queued messages")),this.messageQueue.forEach(function(a){var c,d,e;if(!(a.methodName in b)||!isFunction(b[a.methodName]))return void(null===(c=b.logger)||void 0===c?void 0:c.error("RoktManager: Method ".concat(a.methodName," not found")));null===(d=b.logger)||void 0===d?void 0:d.verbose("RoktManager: Processing queued message: ".concat(a.methodName," with payload: ").concat(JSON.stringify(a.payload)));try{var f=b[a.methodName](a.payload);b.completePendingPromise(a.messageId,f);}catch(c){var g=c instanceof Error?c.message:c+"";null===(e=b.logger)||void 0===e?void 0:e.error("RoktManager: Error processing message '".concat(a.methodName,"': ").concat(g)),b.completePendingPromise(a.messageId,Promise.reject(c));}}),this.messageQueue.clear());},a.prototype.queueMessage=function(a){this.messageQueue.set(a.messageId,a);},a.prototype.deferredCall=function(a,b){var c=this;return new Promise(function(d,e){var f="".concat(a,"_").concat(generateUniqueId());c.queueMessage({messageId:f,methodName:a,payload:b,resolve:d,reject:e});})},a.prototype.completePendingPromise=function(a,b){if(a&&this.messageQueue.has(a)){var c=this.messageQueue.get(a);c.resolve&&Promise.resolve(b).then(function(a){return c.resolve(a)})["catch"](function(a){return c.reject(a)}),this.messageQueue["delete"](a);}},a.prototype.sha256Hex=function(a){return __awaiter(this,void 0,void 0,function(){var b,c,d;return __generator(this,function(e){switch(e.label){case 0:return b=new TextEncoder,c=b.encode(a),[4/*yield*/,crypto.subtle.digest("SHA-256",c)];case 1:return d=e.sent(),[2/*return*/,this.arrayBufferToHex(d)]}})})},a.prototype.arrayBufferToHex=function(a){for(var b,c=new Uint8Array(a),d="",e=0;e<c.length;e++)b=c[e].toString(16).padStart(2,"0"),d+=b;return d},a.prototype.hasIdentityChanged=function(a,b){return !!b&&(!a||a!==b);// Values are the same
|
|
1471
1472
|
},a}();
|
|
1472
1473
|
|
|
1474
|
+
/**
|
|
1475
|
+
* CookieConsentManager handles storage and access of consent flags (noFunctional, noTargeting)
|
|
1476
|
+
* that are passed via launcherOptions during SDK initialization.
|
|
1477
|
+
*
|
|
1478
|
+
* These flags allow Rokt integration to respect user privacy choices.
|
|
1479
|
+
*
|
|
1480
|
+
* Default behavior: Both flags default to false, meaning all features are allowed
|
|
1481
|
+
* unless explicitly opted out by the user.
|
|
1482
|
+
*/var CookieConsentManager=/** @class */function(){function a(a){this.flags=a,this.flags={noFunctional:!0===a.noFunctional,noTargeting:!0===a.noTargeting};}/**
|
|
1483
|
+
* Returns true if third-party targeting is disabled.
|
|
1484
|
+
* Targeting is allowed when noTargeting is false (default).
|
|
1485
|
+
*/return a.prototype.getNoTargeting=function(){return this.flags.noTargeting},a.prototype.getNoFunctional=function(){return this.flags.noFunctional},a}();
|
|
1486
|
+
|
|
1473
1487
|
var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Constants.FeatureFlags,CaptureIntegrationSpecificIdsV2Modes=Constants.CaptureIntegrationSpecificIdsV2Modes,ReportBatching=FeatureFlags.ReportBatching,CaptureIntegrationSpecificIds=FeatureFlags.CaptureIntegrationSpecificIds,CaptureIntegrationSpecificIdsV2=FeatureFlags.CaptureIntegrationSpecificIdsV2,StartingInitialization=Messages.InformationMessages.StartingInitialization;/**
|
|
1474
1488
|
* <p>All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced <a href="https://docs.mparticle.com/developers/sdk/web/multiple-instances/">multiple instances</a>. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.</p>
|
|
1475
1489
|
* <p>In current versions of mParticle, if your site has one instance, that instance name is 'default_instance'. Any methods called on mParticle on a site with one instance will be mapped to the `default_instance`.</p>
|
|
@@ -1485,7 +1499,7 @@ var Messages=Constants.Messages,HTTPCodes=Constants.HTTPCodes,FeatureFlags=Const
|
|
|
1485
1499
|
this._instanceName=a,this._NativeSdkHelpers=new NativeSdkHelpers(this),this._SessionManager=new SessionManager(this),this._Persistence=new _Persistence(this),this._Helpers=new Helpers(this),this._Events=new Events(this),this._CookieSyncManager=new CookieSyncManager(this),this._ServerModel=new ServerModel(this),this._Ecommerce=new Ecommerce(this),this._ForwardingStatsUploader=new forwardingStatsUploader(this),this._Consent=new Consent(this),this._IdentityAPIClient=new IdentityAPIClient(this),this._preInit={readyQueue:[],integrationDelays:{},forwarderConstructors:[]},this._RoktManager=new RoktManager,this.IdentityType=IdentityType,this.EventType=EventType,this.CommerceEventType=CommerceEventType,this.PromotionType=PromotionActionType,this.ProductActionType=ProductActionType,this._Identity=new Identity(this),this.Identity=this._Identity.IdentityAPI,this.generateHash=this._Helpers.generateHash,this.getDeviceId=this._Persistence.getDeviceId,"undefined"!=typeof window&&window.mParticle&&window.mParticle.config&&window.mParticle.config.hasOwnProperty("rq")&&(this._preInit.readyQueue=window.mParticle.config.rq),this.init=function(a,b){var c=this;// config code - Fetch config when requestConfig = true, otherwise, proceed with SDKInitialization
|
|
1486
1500
|
// Since fetching the configuration is asynchronous, we must pass completeSDKInitialization
|
|
1487
1501
|
// to it for it to be run after fetched
|
|
1488
|
-
if(b||console.warn("You did not pass a config object to init(). mParticle will not initialize properly"),runPreConfigFetchInitialization(this,a,b),!b)return void console.error("No config available on the window, please pass a config object to mParticle.init()");if(!b.hasOwnProperty("requestConfig")||b.requestConfig){var d=new ConfigAPIClient(a,b,this);d.getSDKConfiguration().then(function(d){var e=c._Helpers.extend({},b,d);completeSDKInitialization(a,e,c);});}else completeSDKInitialization(a,b,this);},this.setLogLevel=function(a){b.Logger.setLogLevel(a);},this.reset=function(a){try{a._Persistence.resetPersistence(),a._Store&&delete a._Store;}catch(a){console.error("Cannot reset mParticle",a);}},this._resetForTests=function(a,b,c){c._Store&&delete c._Store,c._Store=new Store(a,c),c._Store.isLocalStorageAvailable=c._Persistence.determineLocalStorageAvailability(window.localStorage),c._Events.stopTracking(),b||c._Persistence.resetPersistence(),c._Persistence.forwardingStatsBatches.uploadsTable={},c._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=[],c._preInit={readyQueue:[],pixelConfigurations:[],integrationDelays:{},forwarderConstructors:[],isDevelopmentMode:!1};},this.ready=function(a){b.isInitialized()&&"function"==typeof a?a():b._preInit.readyQueue.push(a);},this.getEnvironment=function(){return b._Store.SDKConfig.isDevelopmentMode?Constants.Environment.Development:Constants.Environment.Production},this.getVersion=function(){return Constants.sdkVersion},this.setAppVersion=function(a){var c=queueIfNotInitialized(function(){b.setAppVersion(a);},b);c||(b._Store.SDKConfig.appVersion=a,b._Persistence.update());},this.setDeviceId=function(a){var c=queueIfNotInitialized(function(){b.setDeviceId(a);},b);c||this._Store.setDeviceId(a);},this.isInitialized=function(){return !!b._Store&&b._Store.isInitialized},this.getAppName=function(){return b._Store.SDKConfig.appName},this.setAppName=function(a){var c=queueIfNotInitialized(function(){b.setAppName(a);},b);c||(b._Store.SDKConfig.appName=a);},this.getAppVersion=function(){return b._Store.SDKConfig.appVersion},this.stopTrackingLocation=function(){b._SessionManager.resetSessionTimer(),b._Events.stopTracking();},this.startTrackingLocation=function(a){isFunction(a)||b.Logger.warning("Warning: Location tracking is triggered, but not including a callback into the `startTrackingLocation` may result in events logged too quickly and not being associated with a location."),b._SessionManager.resetSessionTimer(),b._Events.startTracking(a);},this.setPosition=function(a,c){var d=queueIfNotInitialized(function(){b.setPosition(a,c);},b);d||(b._SessionManager.resetSessionTimer(),"number"==typeof a&&"number"==typeof c?b._Store.currentPosition={lat:a,lng:c}:b.Logger.error("Position latitude and/or longitude must both be of type number"));},this.startNewSession=function(){b._SessionManager.startNewSession();},this.endSession=function(){// Sends true as an over ride vs when endSession is called from the setInterval
|
|
1502
|
+
if(b||console.warn("You did not pass a config object to init(). mParticle will not initialize properly"),runPreConfigFetchInitialization(this,a,b),!b)return void console.error("No config available on the window, please pass a config object to mParticle.init()");if(!b.hasOwnProperty("requestConfig")||b.requestConfig){var d=new ConfigAPIClient(a,b,this);d.getSDKConfiguration().then(function(d){var e=c._Helpers.extend({},b,d);completeSDKInitialization(a,e,c);});}else completeSDKInitialization(a,b,this);},this.setLogLevel=function(a){b.Logger.setLogLevel(a);},this.reset=function(a){try{a._Persistence.resetPersistence(),a._Store&&delete a._Store;}catch(a){console.error("Cannot reset mParticle",a);}},this._resetForTests=function(a,b,c){c._Store&&delete c._Store,c.Logger=new Logger(a),c._Store=new Store(a,c),c._Store.isLocalStorageAvailable=c._Persistence.determineLocalStorageAvailability(window.localStorage),c._Events.stopTracking(),b||c._Persistence.resetPersistence(),c._Persistence.forwardingStatsBatches.uploadsTable={},c._Persistence.forwardingStatsBatches.forwardingStatsEventQueue=[],c._preInit={readyQueue:[],pixelConfigurations:[],integrationDelays:{},forwarderConstructors:[],isDevelopmentMode:!1};},this.ready=function(a){b.isInitialized()&&"function"==typeof a?a():b._preInit.readyQueue.push(a);},this.getEnvironment=function(){return b._Store.SDKConfig.isDevelopmentMode?Constants.Environment.Development:Constants.Environment.Production},this.getVersion=function(){return Constants.sdkVersion},this.setAppVersion=function(a){var c=queueIfNotInitialized(function(){b.setAppVersion(a);},b);c||(b._Store.SDKConfig.appVersion=a,b._Persistence.update());},this.setDeviceId=function(a){var c=queueIfNotInitialized(function(){b.setDeviceId(a);},b);c||this._Store.setDeviceId(a);},this.isInitialized=function(){return !!b._Store&&b._Store.isInitialized},this.getAppName=function(){return b._Store.SDKConfig.appName},this.setAppName=function(a){var c=queueIfNotInitialized(function(){b.setAppName(a);},b);c||(b._Store.SDKConfig.appName=a);},this.getAppVersion=function(){return b._Store.SDKConfig.appVersion},this.stopTrackingLocation=function(){b._SessionManager.resetSessionTimer(),b._Events.stopTracking();},this.startTrackingLocation=function(a){isFunction(a)||b.Logger.warning("Warning: Location tracking is triggered, but not including a callback into the `startTrackingLocation` may result in events logged too quickly and not being associated with a location."),b._SessionManager.resetSessionTimer(),b._Events.startTracking(a);},this.setPosition=function(a,c){var d=queueIfNotInitialized(function(){b.setPosition(a,c);},b);d||(b._SessionManager.resetSessionTimer(),"number"==typeof a&&"number"==typeof c?b._Store.currentPosition={lat:a,lng:c}:b.Logger.error("Position latitude and/or longitude must both be of type number"));},this.startNewSession=function(){b._SessionManager.startNewSession();},this.endSession=function(){// Sends true as an over ride vs when endSession is called from the setInterval
|
|
1489
1503
|
b._SessionManager.endSession(!0);},this.logBaseEvent=function(a,c){var d=queueIfNotInitialized(function(){b.logBaseEvent(a,c);},b);if(!d)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a.name)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(a.eventType||(a.eventType=EventType.Unknown),b._Helpers.canLog()?void b._Events.logEvent(a,c):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled))},this.logEvent=function(a,c,d,e,f){var g=queueIfNotInitialized(function(){b.logEvent(a,c,d,e,f);},b);if(!g)return (b._SessionManager.resetSessionTimer(),"string"!=typeof a)?void b.Logger.error(Messages.ErrorMessages.EventNameInvalidType):(c||(c=EventType.Unknown),b._Helpers.isEventType(c)?b._Helpers.canLog()?void b._Events.logEvent({messageType:MessageType$1.PageEvent,name:a,data:d,eventType:c,customFlags:e},f):void b.Logger.error(Messages.ErrorMessages.LoggingDisabled):void b.Logger.error("Invalid event type: "+c+", must be one of: \n"+JSON.stringify(EventType)))},this.logError=function(a,c){var d=queueIfNotInitialized(function(){b.logError(a,c);},b);if(!d&&(b._SessionManager.resetSessionTimer(),!!a)){"string"==typeof a&&(a={message:a});var e={m:a.message?a.message:a,s:"Error",t:a.stack||null};if(c){var f=b._Helpers.sanitizeAttributes(c,e.m);for(var g in f)e[g]=f[g];}b._Events.logEvent({messageType:MessageType$1.CrashReport,name:a.name?a.name:"Error",eventType:EventType.Other,data:e});}},this.logLink=function(a,c,d,e){b._Events.addEventHandler("click",a,c,e,d);},this.logForm=function(a,c,d,e){b._Events.addEventHandler("submit",a,c,e,d);},this.logPageView=function(a,c,d,e){var f=queueIfNotInitialized(function(){b.logPageView(a,c,d,e);},b);if(!f){if(b._SessionManager.resetSessionTimer(),b._Helpers.canLog()){if(b._Helpers.Validators.isStringOrNumber(a)||(a="PageView"),!c)c={hostname:window.location.hostname,title:window.document.title};else if(!b._Helpers.isObject(c))return void b.Logger.error("The attributes argument must be an object. A "+_typeof$1(c)+" was entered. Please correct and retry.");if(d&&!b._Helpers.isObject(d))return void b.Logger.error("The customFlags argument must be an object. A "+_typeof$1(d)+" was entered. Please correct and retry.")}b._Events.logEvent({messageType:MessageType$1.PageView,name:a,data:c,eventType:EventType.Unknown,customFlags:d},e);}},this.upload=function(){var a,c;b._Helpers.canLog()&&(b._Store.webviewBridgeEnabled?b._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Upload):null===(c=null===(a=b._APIClient)||void 0===a?void 0:a.uploader)||void 0===c?void 0:c.prepareAndUpload(!1,!1));},this.Consent={/**
|
|
1490
1504
|
* Creates a CCPA Opt Out Consent State.
|
|
1491
1505
|
*
|
|
@@ -1654,7 +1668,8 @@ function createKitBlocker(a,b){var c,d,e,f;/* There are three ways a data plan
|
|
|
1654
1668
|
If not passed in manually, we user the server provided via either
|
|
1655
1669
|
2. Snippet via /mparticle.js endpoint (config.dataPlan.document)
|
|
1656
1670
|
3. Self hosting via /config endpoint (config.dataPlanResult)
|
|
1657
|
-
*/return a.dataPlanOptions&&(b.Logger.verbose("Customer provided data plan found"),f=a.dataPlanOptions,d={document:{dtpn:{vers:f.dataPlanVersion,blok:{ev:f.blockEvents,ea:f.blockEventAttributes,ua:f.blockUserAttributes,id:f.blockUserIdentities}}}}),d||(a.dataPlan&&a.dataPlan.document?a.dataPlan.document.error_message?e=a.dataPlan.document.error_message:(b.Logger.verbose("Data plan found from mParticle.js"),d=a.dataPlan):a.dataPlanResult&&(a.dataPlanResult.error_message?e=a.dataPlanResult.error_message:(b.Logger.verbose("Data plan found from /config"),d={document:a.dataPlanResult}))),e&&b.Logger.error(e),d&&(c=new KitBlocker(d,b)),c}function createIdentityCache(a){return new LocalStorageVault("".concat(a._Store.storageName,"-id-cache"),{logger:a.Logger})}function runPreConfigFetchInitialization(a,b,c){a.Logger=new Logger(c),a._Store=new Store(c,a,b),window.mParticle.Store=a._Store,a.Logger.verbose(StartingInitialization);//
|
|
1671
|
+
*/return a.dataPlanOptions&&(b.Logger.verbose("Customer provided data plan found"),f=a.dataPlanOptions,d={document:{dtpn:{vers:f.dataPlanVersion,blok:{ev:f.blockEvents,ea:f.blockEventAttributes,ua:f.blockUserAttributes,id:f.blockUserIdentities}}}}),d||(a.dataPlan&&a.dataPlan.document?a.dataPlan.document.error_message?e=a.dataPlan.document.error_message:(b.Logger.verbose("Data plan found from mParticle.js"),d=a.dataPlan):a.dataPlanResult&&(a.dataPlanResult.error_message?e=a.dataPlanResult.error_message:(b.Logger.verbose("Data plan found from /config"),d={document:a.dataPlanResult}))),e&&b.Logger.error(e),d&&(c=new KitBlocker(d,b)),c}function createIdentityCache(a){return new LocalStorageVault("".concat(a._Store.storageName,"-id-cache"),{logger:a.Logger})}function runPreConfigFetchInitialization(a,b,c){var d;a.Logger=new Logger(c),a._Store=new Store(c,a,b),window.mParticle.Store=a._Store,a.Logger.verbose(StartingInitialization);// Initialize CookieConsentManager with privacy flags from launcherOptions
|
|
1672
|
+
var e=null!==(d=null===c||void 0===c?void 0:c.launcherOptions)&&void 0!==d?d:{},f=e.noFunctional,g=e.noTargeting;a._CookieConsentManager=new CookieConsentManager({noFunctional:f,noTargeting:g});// Check to see if localStorage is available before main configuration runs
|
|
1658
1673
|
// since we will need this for the current implementation of user persistence
|
|
1659
1674
|
// TODO: Refactor this when we refactor User Identity Persistence
|
|
1660
1675
|
try{a._Store.isLocalStorageAvailable=a._Persistence.determineLocalStorageAvailability(window.localStorage);}catch(b){a.Logger.warning("localStorage is not available, using cookies if available"),a._Store.isLocalStorageAvailable=!1;}}function processIdentityCallback(a,b,c,d){!a._Store.identifyCalled&&a._Store.SDKConfig.identityCallback&&b&&c&&a._Store.SDKConfig.identityCallback({httpCode:HTTPCodes.activeSession,getUser:function getUser(){return a._Identity.mParticleUser(c)},getPreviousUser:function getPreviousUser(){var b=a.Identity.getUsers(),d=b.shift(),e=d.getMPID();return d&&e===c&&(d=b.shift()),d||null},body:{mpid:c,is_logged_in:a._Store.isLoggedIn,matched_identities:d,context:null,is_ephemeral:!1}});}function queueIfNotInitialized(a,b){return !b.isInitialized()&&(b.ready(function(){a();}),!0)}
|
package/dist/mparticle.js
CHANGED
|
@@ -203,7 +203,7 @@ var mParticle = (function () {
|
|
|
203
203
|
Base64: Base64$1
|
|
204
204
|
};
|
|
205
205
|
|
|
206
|
-
var version = "2.
|
|
206
|
+
var version = "2.53.0";
|
|
207
207
|
|
|
208
208
|
var Constants = {
|
|
209
209
|
sdkVersion: version,
|
|
@@ -1251,6 +1251,12 @@ var mParticle = (function () {
|
|
|
1251
1251
|
SDKProductActionType[SDKProductActionType["AddToWishlist"] = 9] = "AddToWishlist";
|
|
1252
1252
|
SDKProductActionType[SDKProductActionType["RemoveFromWishlist"] = 10] = "RemoveFromWishlist";
|
|
1253
1253
|
})(SDKProductActionType || (SDKProductActionType = {}));
|
|
1254
|
+
var LogLevelType = {
|
|
1255
|
+
None: 'none',
|
|
1256
|
+
Verbose: 'verbose',
|
|
1257
|
+
Warning: 'warning',
|
|
1258
|
+
Error: 'error'
|
|
1259
|
+
};
|
|
1254
1260
|
|
|
1255
1261
|
function getDefaultExportFromCjs (x) {
|
|
1256
1262
|
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
@@ -2529,13 +2535,13 @@ var mParticle = (function () {
|
|
|
2529
2535
|
if (isEmpty(event)) {
|
|
2530
2536
|
return;
|
|
2531
2537
|
}
|
|
2532
|
-
var
|
|
2538
|
+
var Logger = this.mpInstance.Logger;
|
|
2533
2539
|
this.eventsQueuedForProcessing.push(event);
|
|
2534
2540
|
if (this.offlineStorageEnabled && this.eventVault) {
|
|
2535
2541
|
this.eventVault.store(this.eventsQueuedForProcessing);
|
|
2536
2542
|
}
|
|
2537
|
-
verbose("Queuing event: ".concat(JSON.stringify(event)));
|
|
2538
|
-
verbose("Queued event count: ".concat(this.eventsQueuedForProcessing.length));
|
|
2543
|
+
Logger.verbose("Queuing event: ".concat(JSON.stringify(event)));
|
|
2544
|
+
Logger.verbose("Queued event count: ".concat(this.eventsQueuedForProcessing.length));
|
|
2539
2545
|
if (this.shouldTriggerImmediateUpload(event.EventDataType)) {
|
|
2540
2546
|
this.prepareAndUpload(false, false);
|
|
2541
2547
|
}
|
|
@@ -3486,7 +3492,8 @@ var mParticle = (function () {
|
|
|
3486
3492
|
AppNexus: 50,
|
|
3487
3493
|
Lotame: 58,
|
|
3488
3494
|
TradeDesk: 103,
|
|
3489
|
-
VerizonMedia: 155
|
|
3495
|
+
VerizonMedia: 155,
|
|
3496
|
+
Rokt: 1277
|
|
3490
3497
|
};
|
|
3491
3498
|
function CookieSyncManager(mpInstance) {
|
|
3492
3499
|
var self = this;
|
|
@@ -3527,6 +3534,10 @@ var mParticle = (function () {
|
|
|
3527
3534
|
if (requiresConsent && mpidIsNotInCookies) {
|
|
3528
3535
|
return;
|
|
3529
3536
|
}
|
|
3537
|
+
// For Rokt, block cookie sync when noTargeting privacy flag is true
|
|
3538
|
+
if (moduleId === PARTNER_MODULE_IDS.Rokt && mpInstance._CookieConsentManager.getNoTargeting()) {
|
|
3539
|
+
return;
|
|
3540
|
+
}
|
|
3530
3541
|
var isEnabledForUserConsent = mpInstance._Consent.isEnabledForUserConsent;
|
|
3531
3542
|
if (!isEnabledForUserConsent(filteringConsentRuleValues, mpInstance.Identity.getCurrentUser())) {
|
|
3532
3543
|
return;
|
|
@@ -4864,56 +4875,54 @@ var mParticle = (function () {
|
|
|
4864
4875
|
return directBaseUrls;
|
|
4865
4876
|
}
|
|
4866
4877
|
|
|
4867
|
-
function
|
|
4868
|
-
|
|
4869
|
-
|
|
4870
|
-
|
|
4871
|
-
this.logger = config.logger;
|
|
4872
|
-
} else {
|
|
4873
|
-
this.logger = new ConsoleLogger();
|
|
4878
|
+
var Logger = /** @class */function () {
|
|
4879
|
+
function Logger(config) {
|
|
4880
|
+
var _a, _b;
|
|
4881
|
+
this.logLevel = (_a = config.logLevel) !== null && _a !== void 0 ? _a : LogLevelType.Warning;
|
|
4882
|
+
this.logger = (_b = config.logger) !== null && _b !== void 0 ? _b : new ConsoleLogger();
|
|
4874
4883
|
}
|
|
4875
|
-
|
|
4876
|
-
if (logLevel
|
|
4877
|
-
|
|
4878
|
-
|
|
4879
|
-
}
|
|
4884
|
+
Logger.prototype.verbose = function (msg) {
|
|
4885
|
+
if (this.logLevel === LogLevelType.None) return;
|
|
4886
|
+
if (this.logger.verbose && this.logLevel === LogLevelType.Verbose) {
|
|
4887
|
+
this.logger.verbose(msg);
|
|
4880
4888
|
}
|
|
4881
4889
|
};
|
|
4882
|
-
|
|
4883
|
-
if (logLevel
|
|
4884
|
-
|
|
4885
|
-
|
|
4886
|
-
}
|
|
4890
|
+
Logger.prototype.warning = function (msg) {
|
|
4891
|
+
if (this.logLevel === LogLevelType.None) return;
|
|
4892
|
+
if (this.logger.warning && (this.logLevel === LogLevelType.Verbose || this.logLevel === LogLevelType.Warning)) {
|
|
4893
|
+
this.logger.warning(msg);
|
|
4887
4894
|
}
|
|
4888
4895
|
};
|
|
4889
|
-
|
|
4890
|
-
if (logLevel
|
|
4891
|
-
|
|
4892
|
-
|
|
4893
|
-
}
|
|
4896
|
+
Logger.prototype.error = function (msg) {
|
|
4897
|
+
if (this.logLevel === LogLevelType.None) return;
|
|
4898
|
+
if (this.logger.error) {
|
|
4899
|
+
this.logger.error(msg);
|
|
4894
4900
|
}
|
|
4895
4901
|
};
|
|
4896
|
-
|
|
4897
|
-
logLevel = newLogLevel;
|
|
4902
|
+
Logger.prototype.setLogLevel = function (newLogLevel) {
|
|
4903
|
+
this.logLevel = newLogLevel;
|
|
4898
4904
|
};
|
|
4899
|
-
|
|
4900
|
-
|
|
4901
|
-
|
|
4905
|
+
return Logger;
|
|
4906
|
+
}();
|
|
4907
|
+
var ConsoleLogger = /** @class */function () {
|
|
4908
|
+
function ConsoleLogger() {}
|
|
4909
|
+
ConsoleLogger.prototype.verbose = function (msg) {
|
|
4902
4910
|
if (console && console.info) {
|
|
4903
4911
|
console.info(msg);
|
|
4904
4912
|
}
|
|
4905
4913
|
};
|
|
4906
|
-
|
|
4914
|
+
ConsoleLogger.prototype.error = function (msg) {
|
|
4907
4915
|
if (console && console.error) {
|
|
4908
4916
|
console.error(msg);
|
|
4909
4917
|
}
|
|
4910
4918
|
};
|
|
4911
|
-
|
|
4919
|
+
ConsoleLogger.prototype.warning = function (msg) {
|
|
4912
4920
|
if (console && console.warn) {
|
|
4913
4921
|
console.warn(msg);
|
|
4914
4922
|
}
|
|
4915
4923
|
};
|
|
4916
|
-
|
|
4924
|
+
return ConsoleLogger;
|
|
4925
|
+
}();
|
|
4917
4926
|
|
|
4918
4927
|
var Base64 = Polyfill.Base64,
|
|
4919
4928
|
Messages$4 = Constants.Messages,
|
|
@@ -9156,15 +9165,15 @@ var mParticle = (function () {
|
|
|
9156
9165
|
function IdentityAPIClient(mpInstance) {
|
|
9157
9166
|
this.sendAliasRequest = function (aliasRequest, aliasCallback) {
|
|
9158
9167
|
return __awaiter(this, void 0, void 0, function () {
|
|
9159
|
-
var
|
|
9160
|
-
return __generator(this, function (
|
|
9161
|
-
switch (
|
|
9168
|
+
var Logger, invokeAliasCallback, aliasUrl, apiKey, uploadUrl, uploader, uploadPayload, response, aliasResponseBody, message, errorMessage, _a, xhrResponse, errorResponse, e_2, errorMessage;
|
|
9169
|
+
return __generator(this, function (_b) {
|
|
9170
|
+
switch (_b.label) {
|
|
9162
9171
|
case 0:
|
|
9163
|
-
|
|
9172
|
+
Logger = mpInstance.Logger;
|
|
9164
9173
|
invokeAliasCallback = mpInstance._Helpers.invokeAliasCallback;
|
|
9165
9174
|
aliasUrl = mpInstance._Store.SDKConfig.aliasUrl;
|
|
9166
9175
|
apiKey = mpInstance._Store.devToken;
|
|
9167
|
-
verbose(Messages$1.InformationMessages.SendAliasHttp);
|
|
9176
|
+
Logger.verbose(Messages$1.InformationMessages.SendAliasHttp);
|
|
9168
9177
|
uploadUrl = "https://".concat(aliasUrl).concat(apiKey, "/Alias");
|
|
9169
9178
|
uploader = window.fetch ? new FetchUploader(uploadUrl) : new XHRUploader(uploadUrl);
|
|
9170
9179
|
uploadPayload = {
|
|
@@ -9175,17 +9184,17 @@ var mParticle = (function () {
|
|
|
9175
9184
|
},
|
|
9176
9185
|
body: JSON.stringify(aliasRequest)
|
|
9177
9186
|
};
|
|
9178
|
-
|
|
9187
|
+
_b.label = 1;
|
|
9179
9188
|
case 1:
|
|
9180
|
-
|
|
9189
|
+
_b.trys.push([1, 13,, 14]);
|
|
9181
9190
|
return [4 /*yield*/, uploader.upload(uploadPayload)];
|
|
9182
9191
|
case 2:
|
|
9183
|
-
response =
|
|
9192
|
+
response = _b.sent();
|
|
9184
9193
|
aliasResponseBody = void 0;
|
|
9185
9194
|
message = void 0;
|
|
9186
9195
|
errorMessage = void 0;
|
|
9187
|
-
|
|
9188
|
-
switch (
|
|
9196
|
+
_a = response.status;
|
|
9197
|
+
switch (_a) {
|
|
9189
9198
|
case HTTP_ACCEPTED:
|
|
9190
9199
|
return [3 /*break*/, 3];
|
|
9191
9200
|
case HTTP_OK:
|
|
@@ -9200,23 +9209,23 @@ var mParticle = (function () {
|
|
|
9200
9209
|
return [3 /*break*/, 12];
|
|
9201
9210
|
case 4:
|
|
9202
9211
|
if (!response.json) return [3 /*break*/, 9];
|
|
9203
|
-
|
|
9212
|
+
_b.label = 5;
|
|
9204
9213
|
case 5:
|
|
9205
|
-
|
|
9214
|
+
_b.trys.push([5, 7,, 8]);
|
|
9206
9215
|
return [4 /*yield*/, response.json()];
|
|
9207
9216
|
case 6:
|
|
9208
|
-
aliasResponseBody =
|
|
9217
|
+
aliasResponseBody = _b.sent();
|
|
9209
9218
|
return [3 /*break*/, 8];
|
|
9210
9219
|
case 7:
|
|
9211
|
-
|
|
9212
|
-
verbose('The request has no response body');
|
|
9220
|
+
_b.sent();
|
|
9221
|
+
Logger.verbose('The request has no response body');
|
|
9213
9222
|
return [3 /*break*/, 8];
|
|
9214
9223
|
case 8:
|
|
9215
9224
|
return [3 /*break*/, 10];
|
|
9216
9225
|
case 9:
|
|
9217
9226
|
xhrResponse = response;
|
|
9218
9227
|
aliasResponseBody = xhrResponse.responseText ? JSON.parse(xhrResponse.responseText) : '';
|
|
9219
|
-
|
|
9228
|
+
_b.label = 10;
|
|
9220
9229
|
case 10:
|
|
9221
9230
|
errorResponse = aliasResponseBody;
|
|
9222
9231
|
if (errorResponse === null || errorResponse === void 0 ? void 0 : errorResponse.message) {
|
|
@@ -9232,13 +9241,13 @@ var mParticle = (function () {
|
|
|
9232
9241
|
throw new Error('Received HTTP Code of ' + response.status);
|
|
9233
9242
|
}
|
|
9234
9243
|
case 12:
|
|
9235
|
-
verbose(message);
|
|
9244
|
+
Logger.verbose(message);
|
|
9236
9245
|
invokeAliasCallback(aliasCallback, response.status, errorMessage);
|
|
9237
9246
|
return [3 /*break*/, 14];
|
|
9238
9247
|
case 13:
|
|
9239
|
-
e_2 =
|
|
9248
|
+
e_2 = _b.sent();
|
|
9240
9249
|
errorMessage = e_2.message || e_2.toString();
|
|
9241
|
-
error('Error sending alias request to mParticle servers. ' + errorMessage);
|
|
9250
|
+
Logger.error('Error sending alias request to mParticle servers. ' + errorMessage);
|
|
9242
9251
|
invokeAliasCallback(aliasCallback, HTTPCodes$1.noHttpCoverage, errorMessage);
|
|
9243
9252
|
return [3 /*break*/, 14];
|
|
9244
9253
|
case 14:
|
|
@@ -9250,19 +9259,19 @@ var mParticle = (function () {
|
|
|
9250
9259
|
|
|
9251
9260
|
this.sendIdentityRequest = function (identityApiRequest, method, callback, originalIdentityApiData, parseIdentityResponse, mpid, knownIdentities) {
|
|
9252
9261
|
return __awaiter(this, void 0, void 0, function () {
|
|
9253
|
-
var
|
|
9254
|
-
return __generator(this, function (
|
|
9255
|
-
switch (
|
|
9262
|
+
var invokeCallback, Logger, previousMPID, uploadUrl, uploader, fetchPayload, response, identityResponse, message, _a, responseBody, errorResponse, errorMessage, err_1, errorMessage;
|
|
9263
|
+
return __generator(this, function (_b) {
|
|
9264
|
+
switch (_b.label) {
|
|
9256
9265
|
case 0:
|
|
9257
|
-
_a = mpInstance.Logger, verbose = _a.verbose, error = _a.error;
|
|
9258
9266
|
invokeCallback = mpInstance._Helpers.invokeCallback;
|
|
9259
|
-
|
|
9267
|
+
Logger = mpInstance.Logger;
|
|
9268
|
+
Logger.verbose(Messages$1.InformationMessages.SendIdentityBegin);
|
|
9260
9269
|
if (!identityApiRequest) {
|
|
9261
|
-
error(Messages$1.ErrorMessages.APIRequestEmpty);
|
|
9270
|
+
Logger.error(Messages$1.ErrorMessages.APIRequestEmpty);
|
|
9262
9271
|
return [2 /*return*/];
|
|
9263
9272
|
}
|
|
9264
9273
|
|
|
9265
|
-
verbose(Messages$1.InformationMessages.SendIdentityHttp);
|
|
9274
|
+
Logger.verbose(Messages$1.InformationMessages.SendIdentityHttp);
|
|
9266
9275
|
if (mpInstance._Store.identityCallInFlight) {
|
|
9267
9276
|
invokeCallback(callback, HTTPCodes$1.activeIdentityRequest, 'There is currently an Identity request processing. Please wait for this to return before requesting again');
|
|
9268
9277
|
return [2 /*return*/];
|
|
@@ -9281,16 +9290,16 @@ var mParticle = (function () {
|
|
|
9281
9290
|
body: JSON.stringify(identityApiRequest)
|
|
9282
9291
|
};
|
|
9283
9292
|
mpInstance._Store.identityCallInFlight = true;
|
|
9284
|
-
|
|
9293
|
+
_b.label = 1;
|
|
9285
9294
|
case 1:
|
|
9286
|
-
|
|
9295
|
+
_b.trys.push([1, 9,, 10]);
|
|
9287
9296
|
return [4 /*yield*/, uploader.upload(fetchPayload)];
|
|
9288
9297
|
case 2:
|
|
9289
|
-
response =
|
|
9298
|
+
response = _b.sent();
|
|
9290
9299
|
identityResponse = void 0;
|
|
9291
9300
|
message = void 0;
|
|
9292
|
-
|
|
9293
|
-
switch (
|
|
9301
|
+
_a = response.status;
|
|
9302
|
+
switch (_a) {
|
|
9294
9303
|
case HTTP_ACCEPTED:
|
|
9295
9304
|
return [3 /*break*/, 3];
|
|
9296
9305
|
case HTTP_OK:
|
|
@@ -9303,12 +9312,12 @@ var mParticle = (function () {
|
|
|
9303
9312
|
if (!response.json) return [3 /*break*/, 5];
|
|
9304
9313
|
return [4 /*yield*/, response.json()];
|
|
9305
9314
|
case 4:
|
|
9306
|
-
responseBody =
|
|
9315
|
+
responseBody = _b.sent();
|
|
9307
9316
|
identityResponse = this.getIdentityResponseFromFetch(response, responseBody);
|
|
9308
9317
|
return [3 /*break*/, 6];
|
|
9309
9318
|
case 5:
|
|
9310
9319
|
identityResponse = this.getIdentityResponseFromXHR(response);
|
|
9311
|
-
|
|
9320
|
+
_b.label = 6;
|
|
9312
9321
|
case 6:
|
|
9313
9322
|
if (identityResponse.status === HTTP_BAD_REQUEST) {
|
|
9314
9323
|
errorResponse = identityResponse.responseText;
|
|
@@ -9330,14 +9339,14 @@ var mParticle = (function () {
|
|
|
9330
9339
|
}
|
|
9331
9340
|
case 8:
|
|
9332
9341
|
mpInstance._Store.identityCallInFlight = false;
|
|
9333
|
-
verbose(message);
|
|
9342
|
+
Logger.verbose(message);
|
|
9334
9343
|
parseIdentityResponse(identityResponse, previousMPID, callback, originalIdentityApiData, method, knownIdentities, false);
|
|
9335
9344
|
return [3 /*break*/, 10];
|
|
9336
9345
|
case 9:
|
|
9337
|
-
err_1 =
|
|
9346
|
+
err_1 = _b.sent();
|
|
9338
9347
|
mpInstance._Store.identityCallInFlight = false;
|
|
9339
9348
|
errorMessage = err_1.message || err_1.toString();
|
|
9340
|
-
error('Error sending identity request to servers' + ' - ' + errorMessage);
|
|
9349
|
+
Logger.error('Error sending identity request to servers' + ' - ' + errorMessage);
|
|
9341
9350
|
invokeCallback(callback, HTTPCodes$1.noHttpCoverage, errorMessage);
|
|
9342
9351
|
return [3 /*break*/, 10];
|
|
9343
9352
|
case 10:
|
|
@@ -10114,6 +10123,40 @@ var mParticle = (function () {
|
|
|
10114
10123
|
return RoktManager;
|
|
10115
10124
|
}();
|
|
10116
10125
|
|
|
10126
|
+
/**
|
|
10127
|
+
* CookieConsentManager handles storage and access of consent flags (noFunctional, noTargeting)
|
|
10128
|
+
* that are passed via launcherOptions during SDK initialization.
|
|
10129
|
+
*
|
|
10130
|
+
* These flags allow Rokt integration to respect user privacy choices.
|
|
10131
|
+
*
|
|
10132
|
+
* Default behavior: Both flags default to false, meaning all features are allowed
|
|
10133
|
+
* unless explicitly opted out by the user.
|
|
10134
|
+
*/
|
|
10135
|
+
var CookieConsentManager = /** @class */function () {
|
|
10136
|
+
function CookieConsentManager(flags) {
|
|
10137
|
+
this.flags = flags;
|
|
10138
|
+
this.flags = {
|
|
10139
|
+
noFunctional: flags.noFunctional === true,
|
|
10140
|
+
noTargeting: flags.noTargeting === true
|
|
10141
|
+
};
|
|
10142
|
+
}
|
|
10143
|
+
/**
|
|
10144
|
+
* Returns true if third-party targeting is disabled.
|
|
10145
|
+
* Targeting is allowed when noTargeting is false (default).
|
|
10146
|
+
*/
|
|
10147
|
+
CookieConsentManager.prototype.getNoTargeting = function () {
|
|
10148
|
+
return this.flags.noTargeting;
|
|
10149
|
+
};
|
|
10150
|
+
/**
|
|
10151
|
+
* Returns true if functional tracking is disabled.
|
|
10152
|
+
* Functional tracking is allowed when noFunctional is false (default).
|
|
10153
|
+
*/
|
|
10154
|
+
CookieConsentManager.prototype.getNoFunctional = function () {
|
|
10155
|
+
return this.flags.noFunctional;
|
|
10156
|
+
};
|
|
10157
|
+
return CookieConsentManager;
|
|
10158
|
+
}();
|
|
10159
|
+
|
|
10117
10160
|
var Messages = Constants.Messages,
|
|
10118
10161
|
HTTPCodes = Constants.HTTPCodes,
|
|
10119
10162
|
FeatureFlags = Constants.FeatureFlags,
|
|
@@ -10226,6 +10269,7 @@ var mParticle = (function () {
|
|
|
10226
10269
|
if (instance._Store) {
|
|
10227
10270
|
delete instance._Store;
|
|
10228
10271
|
}
|
|
10272
|
+
instance.Logger = new Logger(config);
|
|
10229
10273
|
instance._Store = new Store(config, instance);
|
|
10230
10274
|
instance._Store.isLocalStorageAvailable = instance._Persistence.determineLocalStorageAvailability(window.localStorage);
|
|
10231
10275
|
instance._Events.stopTracking();
|
|
@@ -11190,10 +11234,19 @@ var mParticle = (function () {
|
|
|
11190
11234
|
});
|
|
11191
11235
|
}
|
|
11192
11236
|
function runPreConfigFetchInitialization(mpInstance, apiKey, config) {
|
|
11237
|
+
var _a;
|
|
11193
11238
|
mpInstance.Logger = new Logger(config);
|
|
11194
11239
|
mpInstance._Store = new Store(config, mpInstance, apiKey);
|
|
11195
11240
|
window.mParticle.Store = mpInstance._Store;
|
|
11196
11241
|
mpInstance.Logger.verbose(StartingInitialization);
|
|
11242
|
+
// Initialize CookieConsentManager with privacy flags from launcherOptions
|
|
11243
|
+
var _b = (_a = config === null || config === void 0 ? void 0 : config.launcherOptions) !== null && _a !== void 0 ? _a : {},
|
|
11244
|
+
noFunctional = _b.noFunctional,
|
|
11245
|
+
noTargeting = _b.noTargeting;
|
|
11246
|
+
mpInstance._CookieConsentManager = new CookieConsentManager({
|
|
11247
|
+
noFunctional: noFunctional,
|
|
11248
|
+
noTargeting: noTargeting
|
|
11249
|
+
});
|
|
11197
11250
|
// Check to see if localStorage is available before main configuration runs
|
|
11198
11251
|
// since we will need this for the current implementation of user persistence
|
|
11199
11252
|
// TODO: Refactor this when we refactor User Identity Persistence
|
package/package.json
CHANGED
package/src/batchUploader.ts
CHANGED
|
@@ -257,15 +257,15 @@ export class BatchUploader {
|
|
|
257
257
|
return;
|
|
258
258
|
}
|
|
259
259
|
|
|
260
|
-
const {
|
|
260
|
+
const { Logger } = this.mpInstance;
|
|
261
261
|
|
|
262
262
|
this.eventsQueuedForProcessing.push(event);
|
|
263
263
|
if (this.offlineStorageEnabled && this.eventVault) {
|
|
264
264
|
this.eventVault.store(this.eventsQueuedForProcessing);
|
|
265
265
|
}
|
|
266
266
|
|
|
267
|
-
verbose(`Queuing event: ${JSON.stringify(event)}`);
|
|
268
|
-
verbose(`Queued event count: ${this.eventsQueuedForProcessing.length}`);
|
|
267
|
+
Logger.verbose(`Queuing event: ${JSON.stringify(event)}`);
|
|
268
|
+
Logger.verbose(`Queued event count: ${this.eventsQueuedForProcessing.length}`);
|
|
269
269
|
|
|
270
270
|
if (this.shouldTriggerImmediateUpload(event.EventDataType)) {
|
|
271
271
|
this.prepareAndUpload(false, false);
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cookie consent flags control SDK behavior based on user consent preferences for Rokt integration.
|
|
3
|
+
* @see https://docs.rokt.com/developers/integration-guides/web/cookie-consent-flags/
|
|
4
|
+
*/
|
|
5
|
+
export interface ICookieConsentFlags {
|
|
6
|
+
/**
|
|
7
|
+
* When true, indicates the user has opted out of functional cookies/tracking.
|
|
8
|
+
* Default: false (functional tracking is allowed)
|
|
9
|
+
*/
|
|
10
|
+
noFunctional: boolean;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* When true, indicates the user has opted out of targeting cookies/tracking.
|
|
14
|
+
* This flag is used to block cookie syncs and other targeting-related features.
|
|
15
|
+
* Default: false (targeting is allowed)
|
|
16
|
+
*/
|
|
17
|
+
noTargeting: boolean;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ICookieConsentManager {
|
|
21
|
+
/**
|
|
22
|
+
* Targeting is allowed when noTargeting is false (default)
|
|
23
|
+
*/
|
|
24
|
+
getNoTargeting: () => boolean;
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Functional tracking is allowed when noFunctional is false (default)
|
|
28
|
+
*/
|
|
29
|
+
getNoFunctional: () => boolean;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* CookieConsentManager handles storage and access of consent flags (noFunctional, noTargeting)
|
|
34
|
+
* that are passed via launcherOptions during SDK initialization.
|
|
35
|
+
*
|
|
36
|
+
* These flags allow Rokt integration to respect user privacy choices.
|
|
37
|
+
*
|
|
38
|
+
* Default behavior: Both flags default to false, meaning all features are allowed
|
|
39
|
+
* unless explicitly opted out by the user.
|
|
40
|
+
*/
|
|
41
|
+
export default class CookieConsentManager implements ICookieConsentManager {
|
|
42
|
+
constructor(private flags: ICookieConsentFlags) {
|
|
43
|
+
this.flags = {
|
|
44
|
+
noFunctional: flags.noFunctional === true,
|
|
45
|
+
noTargeting: flags.noTargeting === true,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Returns true if third-party targeting is disabled.
|
|
51
|
+
* Targeting is allowed when noTargeting is false (default).
|
|
52
|
+
*/
|
|
53
|
+
getNoTargeting(): boolean {
|
|
54
|
+
return this.flags.noTargeting;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Returns true if functional tracking is disabled.
|
|
59
|
+
* Functional tracking is allowed when noFunctional is false (default).
|
|
60
|
+
*/
|
|
61
|
+
getNoFunctional(): boolean {
|
|
62
|
+
return this.flags.noFunctional;
|
|
63
|
+
}
|
|
64
|
+
}
|
package/src/cookieSyncManager.ts
CHANGED
|
@@ -21,6 +21,7 @@ export const PARTNER_MODULE_IDS = {
|
|
|
21
21
|
Lotame: 58,
|
|
22
22
|
TradeDesk: 103,
|
|
23
23
|
VerizonMedia: 155,
|
|
24
|
+
Rokt: 1277,
|
|
24
25
|
} as const;
|
|
25
26
|
|
|
26
27
|
export type CookieSyncDates = Dictionary<number>;
|
|
@@ -108,6 +109,11 @@ export default function CookieSyncManager(
|
|
|
108
109
|
return;
|
|
109
110
|
}
|
|
110
111
|
|
|
112
|
+
// For Rokt, block cookie sync when noTargeting privacy flag is true
|
|
113
|
+
if (moduleId === PARTNER_MODULE_IDS.Rokt && mpInstance._CookieConsentManager.getNoTargeting()) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
111
117
|
const { isEnabledForUserConsent } = mpInstance._Consent;
|
|
112
118
|
|
|
113
119
|
if (!isEnabledForUserConsent(filteringConsentRuleValues, mpInstance.Identity.getCurrentUser())) {
|
package/src/identityApiClient.ts
CHANGED
|
@@ -88,12 +88,12 @@ export default function IdentityAPIClient(
|
|
|
88
88
|
aliasRequest: IAliasRequest,
|
|
89
89
|
aliasCallback: IAliasCallback
|
|
90
90
|
) {
|
|
91
|
-
const {
|
|
91
|
+
const { Logger } = mpInstance;
|
|
92
92
|
const { invokeAliasCallback } = mpInstance._Helpers;
|
|
93
93
|
const { aliasUrl } = mpInstance._Store.SDKConfig;
|
|
94
94
|
const { devToken: apiKey } = mpInstance._Store;
|
|
95
95
|
|
|
96
|
-
verbose(Messages.InformationMessages.SendAliasHttp);
|
|
96
|
+
Logger.verbose(Messages.InformationMessages.SendAliasHttp);
|
|
97
97
|
|
|
98
98
|
// https://go.mparticle.com/work/SQDSDKS-6750
|
|
99
99
|
const uploadUrl = `https://${aliasUrl}${apiKey}/Alias`;
|
|
@@ -136,7 +136,7 @@ export default function IdentityAPIClient(
|
|
|
136
136
|
try {
|
|
137
137
|
aliasResponseBody = await response.json();
|
|
138
138
|
} catch (e) {
|
|
139
|
-
verbose('The request has no response body');
|
|
139
|
+
Logger.verbose('The request has no response body');
|
|
140
140
|
}
|
|
141
141
|
} else {
|
|
142
142
|
// https://go.mparticle.com/work/SQDSDKS-6568
|
|
@@ -171,11 +171,11 @@ export default function IdentityAPIClient(
|
|
|
171
171
|
|
|
172
172
|
}
|
|
173
173
|
|
|
174
|
-
verbose(message);
|
|
174
|
+
Logger.verbose(message);
|
|
175
175
|
invokeAliasCallback(aliasCallback, response.status, errorMessage);
|
|
176
176
|
} catch (e) {
|
|
177
177
|
const errorMessage = (e as Error).message || e.toString();
|
|
178
|
-
error('Error sending alias request to mParticle servers. ' + errorMessage);
|
|
178
|
+
Logger.error('Error sending alias request to mParticle servers. ' + errorMessage);
|
|
179
179
|
invokeAliasCallback(
|
|
180
180
|
aliasCallback,
|
|
181
181
|
HTTPCodes.noHttpCoverage,
|
|
@@ -193,15 +193,14 @@ export default function IdentityAPIClient(
|
|
|
193
193
|
mpid: MPID,
|
|
194
194
|
knownIdentities: UserIdentities
|
|
195
195
|
) {
|
|
196
|
-
const { verbose, error } = mpInstance.Logger;
|
|
197
196
|
const { invokeCallback } = mpInstance._Helpers;
|
|
198
|
-
|
|
199
|
-
verbose(Messages.InformationMessages.SendIdentityBegin);
|
|
197
|
+
const { Logger } = mpInstance;
|
|
198
|
+
Logger.verbose(Messages.InformationMessages.SendIdentityBegin);
|
|
200
199
|
if (!identityApiRequest) {
|
|
201
|
-
error(Messages.ErrorMessages.APIRequestEmpty);
|
|
200
|
+
Logger.error(Messages.ErrorMessages.APIRequestEmpty);
|
|
202
201
|
return;
|
|
203
202
|
}
|
|
204
|
-
verbose(Messages.InformationMessages.SendIdentityHttp);
|
|
203
|
+
Logger.verbose(Messages.InformationMessages.SendIdentityHttp);
|
|
205
204
|
|
|
206
205
|
if (mpInstance._Store.identityCallInFlight) {
|
|
207
206
|
invokeCallback(
|
|
@@ -289,7 +288,7 @@ export default function IdentityAPIClient(
|
|
|
289
288
|
|
|
290
289
|
mpInstance._Store.identityCallInFlight = false;
|
|
291
290
|
|
|
292
|
-
verbose(message);
|
|
291
|
+
Logger.verbose(message);
|
|
293
292
|
parseIdentityResponse(
|
|
294
293
|
identityResponse,
|
|
295
294
|
previousMPID,
|
|
@@ -304,7 +303,7 @@ export default function IdentityAPIClient(
|
|
|
304
303
|
|
|
305
304
|
const errorMessage = (err as Error).message || err.toString();
|
|
306
305
|
|
|
307
|
-
error('Error sending identity request to servers' + ' - ' + errorMessage);
|
|
306
|
+
Logger.error('Error sending identity request to servers' + ' - ' + errorMessage);
|
|
308
307
|
invokeCallback(
|
|
309
308
|
callback,
|
|
310
309
|
HTTPCodes.noHttpCoverage,
|
package/src/logger.ts
ADDED
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { LogLevelType, SDKInitConfig, SDKLoggerApi } from './sdkRuntimeModels';
|
|
2
|
+
|
|
3
|
+
export type ILoggerConfig = Pick<SDKInitConfig, 'logLevel' | 'logger'>;
|
|
4
|
+
export type IConsoleLogger = Partial<Pick<SDKLoggerApi, 'error' | 'warning' | 'verbose'>>;
|
|
5
|
+
|
|
6
|
+
export class Logger {
|
|
7
|
+
private logLevel: LogLevelType;
|
|
8
|
+
private logger: IConsoleLogger;
|
|
9
|
+
|
|
10
|
+
constructor(config: ILoggerConfig) {
|
|
11
|
+
this.logLevel = config.logLevel ?? LogLevelType.Warning;
|
|
12
|
+
this.logger = config.logger ?? new ConsoleLogger();
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
public verbose(msg: string): void {
|
|
16
|
+
if(this.logLevel === LogLevelType.None)
|
|
17
|
+
return;
|
|
18
|
+
|
|
19
|
+
if (this.logger.verbose && this.logLevel === LogLevelType.Verbose) {
|
|
20
|
+
this.logger.verbose(msg);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
public warning(msg: string): void {
|
|
25
|
+
if(this.logLevel === LogLevelType.None)
|
|
26
|
+
return;
|
|
27
|
+
|
|
28
|
+
if (this.logger.warning &&
|
|
29
|
+
(this.logLevel === LogLevelType.Verbose || this.logLevel === LogLevelType.Warning)) {
|
|
30
|
+
this.logger.warning(msg);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
public error(msg: string): void {
|
|
35
|
+
if(this.logLevel === LogLevelType.None)
|
|
36
|
+
return;
|
|
37
|
+
|
|
38
|
+
if (this.logger.error) {
|
|
39
|
+
this.logger.error(msg);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
public setLogLevel(newLogLevel: LogLevelType): void {
|
|
44
|
+
this.logLevel = newLogLevel;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export class ConsoleLogger implements IConsoleLogger {
|
|
49
|
+
public verbose(msg: string): void {
|
|
50
|
+
if (console && console.info) {
|
|
51
|
+
console.info(msg);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
public error(msg: string): void {
|
|
56
|
+
if (console && console.error) {
|
|
57
|
+
console.error(msg);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
public warning(msg: string): void {
|
|
62
|
+
if (console && console.warn) {
|
|
63
|
+
console.warn(msg);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
package/src/mp-instance.ts
CHANGED
|
@@ -25,7 +25,7 @@ import CookieSyncManager, { ICookieSyncManager } from './cookieSyncManager';
|
|
|
25
25
|
import SessionManager, { ISessionManager } from './sessionManager';
|
|
26
26
|
import Ecommerce from './ecommerce';
|
|
27
27
|
import Store, { IStore } from './store';
|
|
28
|
-
import Logger from './logger';
|
|
28
|
+
import { Logger } from './logger';
|
|
29
29
|
import Persistence from './persistence';
|
|
30
30
|
import Events from './events';
|
|
31
31
|
import Forwarders from './forwarders';
|
|
@@ -51,6 +51,7 @@ import { IPersistence } from './persistence.interfaces';
|
|
|
51
51
|
import ForegroundTimer from './foregroundTimeTracker';
|
|
52
52
|
import RoktManager, { IRoktOptions } from './roktManager';
|
|
53
53
|
import filteredMparticleUser from './filteredMparticleUser';
|
|
54
|
+
import CookieConsentManager, { ICookieConsentManager } from './cookieConsentManager';
|
|
54
55
|
|
|
55
56
|
export interface IErrorLogMessage {
|
|
56
57
|
message?: string;
|
|
@@ -82,6 +83,7 @@ export interface IMParticleWebSDKInstance extends MParticleWebSDK {
|
|
|
82
83
|
_IntegrationCapture: IntegrationCapture;
|
|
83
84
|
_NativeSdkHelpers: INativeSdkHelpers;
|
|
84
85
|
_Persistence: IPersistence;
|
|
86
|
+
_CookieConsentManager: ICookieConsentManager;
|
|
85
87
|
_RoktManager: RoktManager;
|
|
86
88
|
_SessionManager: ISessionManager;
|
|
87
89
|
_ServerModel: IServerModel;
|
|
@@ -227,6 +229,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
227
229
|
if (instance._Store) {
|
|
228
230
|
delete instance._Store;
|
|
229
231
|
}
|
|
232
|
+
instance.Logger = new Logger(config);
|
|
230
233
|
instance._Store = new Store(config, instance);
|
|
231
234
|
instance._Store.isLocalStorageAvailable = instance._Persistence.determineLocalStorageAvailability(
|
|
232
235
|
window.localStorage
|
|
@@ -1554,6 +1557,10 @@ function runPreConfigFetchInitialization(mpInstance, apiKey, config) {
|
|
|
1554
1557
|
window.mParticle.Store = mpInstance._Store;
|
|
1555
1558
|
mpInstance.Logger.verbose(StartingInitialization);
|
|
1556
1559
|
|
|
1560
|
+
// Initialize CookieConsentManager with privacy flags from launcherOptions
|
|
1561
|
+
const { noFunctional, noTargeting } = config?.launcherOptions ?? {};
|
|
1562
|
+
mpInstance._CookieConsentManager = new CookieConsentManager({ noFunctional, noTargeting });
|
|
1563
|
+
|
|
1557
1564
|
// Check to see if localStorage is available before main configuration runs
|
|
1558
1565
|
// since we will need this for the current implementation of user persistence
|
|
1559
1566
|
// TODO: Refactor this when we refactor User Identity Persistence
|
package/src/sdkRuntimeModels.ts
CHANGED
|
@@ -40,6 +40,7 @@ import { SDKECommerceAPI } from './ecommerce.interfaces';
|
|
|
40
40
|
import { IErrorLogMessage, IMParticleWebSDKInstance, IntegrationDelays } from './mp-instance';
|
|
41
41
|
import Constants from './constants';
|
|
42
42
|
import RoktManager, { IRoktLauncherOptions } from './roktManager';
|
|
43
|
+
import { IConsoleLogger } from './logger';
|
|
43
44
|
|
|
44
45
|
// TODO: Resolve this with version in @mparticle/web-sdk
|
|
45
46
|
export type SDKEventCustomFlags = Dictionary<any>;
|
|
@@ -259,7 +260,13 @@ export interface IMParticleInstanceManager extends MParticleWebSDK {
|
|
|
259
260
|
export type BooleanStringLowerCase = 'false' | 'true';
|
|
260
261
|
export type BooleanStringTitleCase = 'False' | 'True';
|
|
261
262
|
|
|
262
|
-
export type LogLevelType =
|
|
263
|
+
export type LogLevelType = (typeof LogLevelType)[keyof typeof LogLevelType];
|
|
264
|
+
export const LogLevelType = {
|
|
265
|
+
None: 'none',
|
|
266
|
+
Verbose: 'verbose',
|
|
267
|
+
Warning: 'warning',
|
|
268
|
+
Error: 'error',
|
|
269
|
+
} as const;
|
|
263
270
|
|
|
264
271
|
// TODO: This should eventually be moved into wherever init logic lives
|
|
265
272
|
// TODO: Replace/Merge this with MPConfiguration in @types/mparticle__web-sdk
|
|
@@ -306,6 +313,7 @@ export interface SDKInitConfig
|
|
|
306
313
|
launcherOptions?: IRoktLauncherOptions;
|
|
307
314
|
|
|
308
315
|
rq?: Function[] | any[];
|
|
316
|
+
logger?: IConsoleLogger;
|
|
309
317
|
}
|
|
310
318
|
|
|
311
319
|
export interface DataPlanConfig {
|
package/src/logger.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
function Logger(config) {
|
|
2
|
-
var self = this;
|
|
3
|
-
var logLevel = config.logLevel || 'warning';
|
|
4
|
-
if (config.hasOwnProperty('logger')) {
|
|
5
|
-
this.logger = config.logger;
|
|
6
|
-
} else {
|
|
7
|
-
this.logger = new ConsoleLogger();
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
this.verbose = function(msg) {
|
|
11
|
-
if (logLevel !== 'none') {
|
|
12
|
-
if (self.logger.verbose && logLevel === 'verbose') {
|
|
13
|
-
self.logger.verbose(msg);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
this.warning = function(msg) {
|
|
19
|
-
if (logLevel !== 'none') {
|
|
20
|
-
if (
|
|
21
|
-
self.logger.warning &&
|
|
22
|
-
(logLevel === 'verbose' || logLevel === 'warning')
|
|
23
|
-
) {
|
|
24
|
-
self.logger.warning(msg);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
this.error = function(msg) {
|
|
30
|
-
if (logLevel !== 'none') {
|
|
31
|
-
if (self.logger.error) {
|
|
32
|
-
self.logger.error(msg);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
this.setLogLevel = function(newLogLevel) {
|
|
38
|
-
logLevel = newLogLevel;
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
function ConsoleLogger() {
|
|
43
|
-
this.verbose = function(msg) {
|
|
44
|
-
if (console && console.info) {
|
|
45
|
-
console.info(msg);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
this.error = function(msg) {
|
|
50
|
-
if (console && console.error) {
|
|
51
|
-
console.error(msg);
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
this.warning = function(msg) {
|
|
55
|
-
if (console && console.warn) {
|
|
56
|
-
console.warn(msg);
|
|
57
|
-
}
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
export default Logger;
|