@mparticle/web-sdk
Advanced tools
Comparing version 2.14.1 to 2.14.2
{ | ||
"name": "@mparticle/web-sdk", | ||
"version": "2.14.1", | ||
"version": "2.14.2", | ||
"description": "mParticle core SDK for web applications", | ||
@@ -5,0 +5,0 @@ "license": "Apache-2.0", |
@@ -147,11 +147,12 @@ import Constants from './constants'; | ||
mpInstance.Logger.verbose(Messages.InformationMessages.CookieSync); | ||
img.onload = function() { | ||
cookieSyncDates[moduleId.toString()] = new Date().getTime(); | ||
mpInstance._Persistence.saveUserCookieSyncDatesToPersistence( | ||
mpid, | ||
cookieSyncDates | ||
); | ||
}; | ||
img.src = url; | ||
cookieSyncDates[moduleId.toString()] = new Date().getTime(); | ||
mpInstance._Persistence.saveUserCookieSyncDatesToPersistence( | ||
mpid, | ||
cookieSyncDates | ||
); | ||
} | ||
}; | ||
} |
@@ -146,5 +146,9 @@ // | ||
this.reset = function(instance) { | ||
instance._Persistence.resetPersistence(); | ||
if (instance._Store) { | ||
delete instance._Store; | ||
try { | ||
instance._Persistence.resetPersistence(); | ||
if (instance._Store) { | ||
delete instance._Store; | ||
} | ||
} catch (error) { | ||
console.error('Cannot reset mParticle', error); | ||
} | ||
@@ -181,3 +185,3 @@ }; | ||
this.ready = function(f) { | ||
if (self._Store.isInitialized && typeof f === 'function') { | ||
if (self.isInitialized() && typeof f === 'function') { | ||
f(); | ||
@@ -202,2 +206,8 @@ } else { | ||
this.setAppVersion = function(version) { | ||
var queued = queueIfNotInitialized(function() { | ||
self.setAppVersion(version); | ||
}, self); | ||
if (queued) return; | ||
self._Store.SDKConfig.appVersion = version; | ||
@@ -220,2 +230,8 @@ self._Persistence.update(); | ||
this.setAppName = function(name) { | ||
var queued = queueIfNotInitialized(function() { | ||
self.setAppName(name); | ||
}, self); | ||
if (queued) return; | ||
self._Store.SDKConfig.appName = name; | ||
@@ -261,2 +277,8 @@ }; | ||
this.setPosition = function(lat, lng) { | ||
var queued = queueIfNotInitialized(function() { | ||
self.setPosition(lat, lng); | ||
}, self); | ||
if (queued) return; | ||
self._SessionManager.resetSessionTimer(); | ||
@@ -296,8 +318,8 @@ if (typeof lat === 'number' && typeof lng === 'number') { | ||
this.logBaseEvent = function(event, eventOptions) { | ||
if (!self._Store.isInitialized) { | ||
self.ready(function() { | ||
self.logBaseEvent(event, eventOptions); | ||
}); | ||
return; | ||
} | ||
var queued = queueIfNotInitialized(function() { | ||
self.logBaseEvent(event, eventOptions); | ||
}, self); | ||
if (queued) return; | ||
self._SessionManager.resetSessionTimer(); | ||
@@ -336,14 +358,14 @@ if (typeof event.name !== 'string') { | ||
) { | ||
if (!self._Store.isInitialized) { | ||
self.ready(function() { | ||
self.logEvent( | ||
eventName, | ||
eventType, | ||
eventInfo, | ||
customFlags, | ||
eventOptions | ||
); | ||
}); | ||
return; | ||
} | ||
var queued = queueIfNotInitialized(function() { | ||
self.logEvent( | ||
eventName, | ||
eventType, | ||
eventInfo, | ||
customFlags, | ||
eventOptions | ||
); | ||
}, self); | ||
if (queued) return; | ||
self._SessionManager.resetSessionTimer(); | ||
@@ -393,8 +415,8 @@ if (typeof eventName !== 'string') { | ||
this.logError = function(error, attrs) { | ||
if (!self._Store.isInitialized) { | ||
self.ready(function() { | ||
self.logError(error, attrs); | ||
}); | ||
return; | ||
} | ||
var queued = queueIfNotInitialized(function() { | ||
self.logError(error, attrs); | ||
}, self); | ||
if (queued) return; | ||
self._SessionManager.resetSessionTimer(); | ||
@@ -474,8 +496,8 @@ if (!error) { | ||
this.logPageView = function(eventName, attrs, customFlags, eventOptions) { | ||
if (!self._Store.isInitialized) { | ||
self.ready(function() { | ||
self.logPageView(eventName, attrs, customFlags, eventOptions); | ||
}); | ||
return; | ||
} | ||
var queued = queueIfNotInitialized(function() { | ||
self.logPageView(eventName, attrs, customFlags, eventOptions); | ||
}, self); | ||
if (queued) return; | ||
self._SessionManager.resetSessionTimer(); | ||
@@ -652,9 +674,8 @@ | ||
setCurrencyCode: function(code) { | ||
if (!self._Store.isInitialized) { | ||
self.ready(function() { | ||
self.eCommerce.setCurrencyCode(code); | ||
}); | ||
return; | ||
} | ||
var queued = queueIfNotInitialized(function() { | ||
self.eCommerce.setCurrencyCode(code); | ||
}, self); | ||
if (queued) return; | ||
if (typeof code !== 'string') { | ||
@@ -776,2 +797,3 @@ self.Logger.error('Code must be a string'); | ||
); | ||
if (!self._Store.isInitialized) { | ||
@@ -786,4 +808,6 @@ self.ready(function() { | ||
}); | ||
return; | ||
} | ||
self._SessionManager.resetSessionTimer(); | ||
@@ -811,15 +835,15 @@ self._Events.logCheckoutEvent(step, option, attrs, customFlags); | ||
) { | ||
if (!self._Store.isInitialized) { | ||
self.ready(function() { | ||
self.eCommerce.logProductAction( | ||
productActionType, | ||
product, | ||
attrs, | ||
customFlags, | ||
transactionAttributes, | ||
eventOptions | ||
); | ||
}); | ||
return; | ||
} | ||
var queued = queueIfNotInitialized(function() { | ||
self.eCommerce.logProductAction( | ||
productActionType, | ||
product, | ||
attrs, | ||
customFlags, | ||
transactionAttributes, | ||
eventOptions | ||
); | ||
}, self); | ||
if (queued) return; | ||
self._SessionManager.resetSessionTimer(); | ||
@@ -897,14 +921,14 @@ self._Events.logProductActionEvent( | ||
) { | ||
if (!self._Store.isInitialized) { | ||
self.ready(function() { | ||
self.eCommerce.logPromotion( | ||
type, | ||
promotion, | ||
attrs, | ||
customFlags, | ||
eventOptions | ||
); | ||
}); | ||
return; | ||
} | ||
var queued = queueIfNotInitialized(function() { | ||
self.eCommerce.logPromotion( | ||
type, | ||
promotion, | ||
attrs, | ||
customFlags, | ||
eventOptions | ||
); | ||
}, self); | ||
if (queued) return; | ||
self._SessionManager.resetSessionTimer(); | ||
@@ -929,13 +953,13 @@ self._Events.logPromotionEvent( | ||
logImpression: function(impression, attrs, customFlags, eventOptions) { | ||
if (!self._Store.isInitialized) { | ||
self.ready(function() { | ||
self.eCommerce.logImpression( | ||
impression, | ||
attrs, | ||
customFlags, | ||
eventOptions | ||
); | ||
}); | ||
return; | ||
} | ||
var queued = queueIfNotInitialized(function() { | ||
self.eCommerce.logImpression( | ||
impression, | ||
attrs, | ||
customFlags, | ||
eventOptions | ||
); | ||
}, self); | ||
if (queued) return; | ||
self._SessionManager.resetSessionTimer(); | ||
@@ -1001,8 +1025,8 @@ self._Events.logImpressionEvent( | ||
this.setSessionAttribute = function(key, value) { | ||
if (!self._Store.isInitialized) { | ||
self.ready(function() { | ||
self.setSessionAttribute(key, value); | ||
}); | ||
return; | ||
} | ||
var queued = queueIfNotInitialized(function() { | ||
self.setSessionAttribute(key, value); | ||
}, self); | ||
if (queued) return; | ||
// Logs to cookie | ||
@@ -1053,8 +1077,8 @@ // And logs to in-memory object | ||
this.setOptOut = function(isOptingOut) { | ||
if (!self._Store.isInitialized) { | ||
self.ready(function() { | ||
self.setOptOut(isOptingOut); | ||
}); | ||
return; | ||
} | ||
var queued = queueIfNotInitialized(function() { | ||
self.setOptOut(isOptingOut); | ||
}, self); | ||
if (queued) return; | ||
self._SessionManager.resetSessionTimer(); | ||
@@ -1092,9 +1116,8 @@ self._Store.isEnabled = !isOptingOut; | ||
this.setIntegrationAttribute = function(integrationId, attrs) { | ||
if (!self._Store.isInitialized) { | ||
self.ready(function() { | ||
self.setIntegrationAttribute(integrationId, attrs); | ||
}); | ||
return; | ||
} | ||
var queued = queueIfNotInitialized(function() { | ||
self.setIntegrationAttribute(integrationId, attrs); | ||
}, self); | ||
if (queued) return; | ||
if (typeof integrationId !== 'number') { | ||
@@ -1184,2 +1207,5 @@ self.Logger.error('integrationId must be a number'); | ||
}; | ||
this.isInitialized = function() { | ||
return self._Store ? self._Store.isInitialized : false; | ||
}; | ||
} | ||
@@ -1486,1 +1512,11 @@ | ||
} | ||
function queueIfNotInitialized(func, self) { | ||
if (!self.isInitialized()) { | ||
self.ready(function() { | ||
func(); | ||
}); | ||
return true; | ||
} | ||
return false; | ||
} |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
27862
1531780
36