Skip to content

Commit ade768d

Browse files
Address PR Comments
1 parent bf8e322 commit ade768d

File tree

1 file changed

+33
-30
lines changed

1 file changed

+33
-30
lines changed

src/mp-instance.ts

Lines changed: 33 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ const { StartingInitialization } = Messages.InformationMessages;
116116
*/
117117

118118
export default function mParticleInstance(this: IMParticleWebSDKInstance, instanceName: string) {
119-
var self = this;
119+
const self = this;
120120
// These classes are for internal use only. Not documented for public consumption
121121
this._instanceName = instanceName;
122122
this._NativeSdkHelpers = new NativeSdkHelpers(this);
@@ -286,7 +286,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
286286
* @param {String} version version number
287287
*/
288288
this.setAppVersion = function(version) {
289-
var queued = queueIfNotInitialized(function() {
289+
const queued = queueIfNotInitialized(function() {
290290
self.setAppVersion(version);
291291
}, self);
292292

@@ -301,7 +301,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
301301
* @param {String} name device ID (UUIDv4-formatted string)
302302
*/
303303
this.setDeviceId = function(guid) {
304-
var queued = queueIfNotInitialized(function() {
304+
const queued = queueIfNotInitialized(function() {
305305
self.setDeviceId(guid);
306306
}, self);
307307
if (queued) return;
@@ -330,7 +330,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
330330
* @param {String} name App Name
331331
*/
332332
this.setAppName = function(name) {
333-
var queued = queueIfNotInitialized(function() {
333+
const queued = queueIfNotInitialized(function() {
334334
self.setAppName(name);
335335
}, self);
336336

@@ -376,7 +376,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
376376
* @param {Number} longitude longitude digit
377377
*/
378378
this.setPosition = function(lat, lng) {
379-
var queued = queueIfNotInitialized(function() {
379+
const queued = queueIfNotInitialized(function() {
380380
self.setPosition(lat, lng);
381381
}, self);
382382

@@ -416,7 +416,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
416416
* @param {Object} [eventOptions] For Event-level Configuration Options
417417
*/
418418
this.logBaseEvent = function(event, eventOptions) {
419-
var queued = queueIfNotInitialized(function() {
419+
const queued = queueIfNotInitialized(function() {
420420
self.logBaseEvent(event, eventOptions);
421421
}, self);
422422

@@ -455,7 +455,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
455455
customFlags,
456456
eventOptions
457457
) {
458-
var queued = queueIfNotInitialized(function() {
458+
const queued = queueIfNotInitialized(function() {
459459
self.logEvent(
460460
eventName,
461461
eventType,
@@ -511,7 +511,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
511511
* @param {Object} [attrs] Custom attrs to be passed along with the error event; values must be string, number, or boolean
512512
*/
513513
this.logError = function(error, attrs) {
514-
var queued = queueIfNotInitialized(function() {
514+
const queued = queueIfNotInitialized(function() {
515515
self.logError(error, attrs);
516516
}, self);
517517

@@ -535,8 +535,8 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
535535
};
536536

537537
if (attrs) {
538-
var sanitized = self._Helpers.sanitizeAttributes(attrs, data.m);
539-
for (var prop in sanitized) {
538+
const sanitized = self._Helpers.sanitizeAttributes(attrs, data.m);
539+
for (const prop in sanitized) {
540540
data[prop] = sanitized[prop];
541541
}
542542
}
@@ -591,7 +591,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
591591
* @param {Object} [eventOptions] For Event-level Configuration Options
592592
*/
593593
this.logPageView = function(eventName, attrs, customFlags, eventOptions) {
594-
var queued = queueIfNotInitialized(function() {
594+
const queued = queueIfNotInitialized(function() {
595595
self.logPageView(eventName, attrs, customFlags, eventOptions);
596596
}, self);
597597

@@ -715,8 +715,8 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
715715
self.Logger.warning(
716716
'Deprecated function eCommerce.Cart.add() will be removed in future releases'
717717
);
718-
var mpid,
719-
currentUser = self.Identity.getCurrentUser();
718+
let mpid;
719+
const currentUser = self.Identity.getCurrentUser();
720720
if (currentUser) {
721721
mpid = currentUser.getMPID();
722722
}
@@ -735,8 +735,8 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
735735
self.Logger.warning(
736736
'Deprecated function eCommerce.Cart.remove() will be removed in future releases'
737737
);
738-
var mpid,
739-
currentUser = self.Identity.getCurrentUser();
738+
let mpid;
739+
const currentUser = self.Identity.getCurrentUser();
740740
if (currentUser) {
741741
mpid = currentUser.getMPID();
742742
}
@@ -753,8 +753,8 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
753753
self.Logger.warning(
754754
'Deprecated function eCommerce.Cart.clear() will be removed in future releases'
755755
);
756-
var mpid,
757-
currentUser = self.Identity.getCurrentUser();
756+
let mpid;
757+
const currentUser = self.Identity.getCurrentUser();
758758
if (currentUser) {
759759
mpid = currentUser.getMPID();
760760
}
@@ -768,7 +768,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
768768
* @param {String} code The currency code
769769
*/
770770
setCurrencyCode: function(code) {
771-
var queued = queueIfNotInitialized(function() {
771+
const queued = queueIfNotInitialized(function() {
772772
self.eCommerce.setCurrencyCode(code);
773773
}, self);
774774

@@ -926,7 +926,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
926926
transactionAttributes,
927927
eventOptions
928928
) {
929-
var queued = queueIfNotInitialized(function() {
929+
const queued = queueIfNotInitialized(function() {
930930
self.eCommerce.logProductAction(
931931
productActionType,
932932
product,
@@ -1011,7 +1011,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
10111011
customFlags,
10121012
eventOptions
10131013
) {
1014-
var queued = queueIfNotInitialized(function() {
1014+
const queued = queueIfNotInitialized(function() {
10151015
self.eCommerce.logPromotion(
10161016
type,
10171017
promotion,
@@ -1042,7 +1042,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
10421042
* @param {Object} [eventOptions] For Event-level Configuration Options
10431043
*/
10441044
logImpression: function(impression, attrs, customFlags, eventOptions) {
1045-
var queued = queueIfNotInitialized(function() {
1045+
const queued = queueIfNotInitialized(function() {
10461046
self.eCommerce.logImpression(
10471047
impression,
10481048
attrs,
@@ -1113,7 +1113,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
11131113
* @param {String or Number} value value for session attribute
11141114
*/
11151115
this.setSessionAttribute = function(key, value) {
1116-
var queued = queueIfNotInitialized(function() {
1116+
const queued = queueIfNotInitialized(function() {
11171117
self.setSessionAttribute(key, value);
11181118
}, self);
11191119

@@ -1139,7 +1139,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
11391139
JSON.stringify({ key: key, value: value })
11401140
);
11411141
} else {
1142-
var existingProp = self._Helpers.findKeyInObject(
1142+
const existingProp = self._Helpers.findKeyInObject(
11431143
self._Store.sessionAttributes,
11441144
key
11451145
);
@@ -1164,7 +1164,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
11641164
* @param {Boolean} isOptingOut boolean to opt out or not. When set to true, opt out of logging.
11651165
*/
11661166
this.setOptOut = function(isOptingOut) {
1167-
var queued = queueIfNotInitialized(function() {
1167+
const queued = queueIfNotInitialized(function() {
11681168
self.setOptOut(isOptingOut);
11691169
}, self);
11701170

@@ -1179,7 +1179,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
11791179
if (self._Store.activeForwarders.length) {
11801180
self._Store.activeForwarders.forEach(function(forwarder) {
11811181
if (forwarder.setOptOut) {
1182-
var result = forwarder.setOptOut(isOptingOut);
1182+
const result = forwarder.setOptOut(isOptingOut);
11831183

11841184
if (result) {
11851185
self.Logger.verbose(result);
@@ -1202,7 +1202,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
12021202
* also pass a null or empty map here to remove all of the attributes.
12031203
*/
12041204
this.setIntegrationAttribute = function(integrationId, attrs) {
1205-
var queued = queueIfNotInitialized(function() {
1205+
const queued = queueIfNotInitialized(function() {
12061206
self.setIntegrationAttribute(integrationId, attrs);
12071207
}, self);
12081208

@@ -1218,7 +1218,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
12181218
if (Object.keys(attrs).length === 0) {
12191219
self._Store.integrationAttributes[integrationId] = {};
12201220
} else {
1221-
for (var key in attrs) {
1221+
for (const key in attrs) {
12221222
if (typeof key === 'string') {
12231223
if (typeof attrs[key] === 'string') {
12241224
if (
@@ -1338,7 +1338,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
13381338

13391339
// Internal use only. Used by our wrapper SDKs to identify themselves during initialization.
13401340
this._setWrapperSDKInfo = function(name, version) {
1341-
var queued = queueIfNotInitialized(function() {
1341+
const queued = queueIfNotInitialized(function() {
13421342
self._setWrapperSDKInfo(name, version);
13431343
}, self);
13441344

@@ -1359,7 +1359,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
13591359

13601360
// Some (server) config settings need to be returned before they are set on SDKConfig in a self hosted environment
13611361
function completeSDKInitialization(apiKey, config, mpInstance) {
1362-
var kitBlocker = createKitBlocker(config, mpInstance);
1362+
const kitBlocker = createKitBlocker(config, mpInstance);
13631363

13641364
mpInstance._APIClient = new APIClient(mpInstance, kitBlocker);
13651365
mpInstance._Forwarders = new Forwarders(mpInstance, kitBlocker);
@@ -1439,7 +1439,10 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
14391439
}
14401440

14411441
function createKitBlocker(config, mpInstance) {
1442-
var kitBlocker, dataPlanForKitBlocker, kitBlockError, kitBlockOptions;
1442+
let kitBlocker;
1443+
let dataPlanForKitBlocker;
1444+
let kitBlockError;
1445+
let kitBlockOptions;
14431446

14441447
/* There are three ways a data plan object for blocking can be passed to the SDK:
14451448
1. Manually via config.dataPlanOptions (this takes priority)

0 commit comments

Comments
 (0)