@mparticle/web-sdk 2.23.6 → 2.23.8

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.js CHANGED
@@ -262,7 +262,7 @@ var mParticle = (function () {
262
262
 
263
263
  // Dictionary that contains MessageTypes that will
264
264
  // trigger an immediate upload.
265
- var TriggerUploadType = (_TriggerUploadType = {}, _defineProperty(_TriggerUploadType, MessageType$2.Commerce, 1), _defineProperty(_TriggerUploadType, MessageType$2.UserAttributeChange, 1), _defineProperty(_TriggerUploadType, MessageType$2.UserIdentityChange, 1), _TriggerUploadType);
265
+ var TriggerUploadType = (_TriggerUploadType = {}, _defineProperty(_TriggerUploadType, MessageType$2.Commerce, 1), _defineProperty(_TriggerUploadType, MessageType$2.UserIdentityChange, 1), _TriggerUploadType);
266
266
  var EventType = {
267
267
  Unknown: 0,
268
268
  Navigation: 1,
@@ -608,7 +608,7 @@ var mParticle = (function () {
608
608
  Environment: Environment
609
609
  };
610
610
 
611
- var version = "2.23.6";
611
+ var version = "2.23.8";
612
612
 
613
613
  var Constants = {
614
614
  sdkVersion: version,
@@ -742,6 +742,7 @@ var mParticle = (function () {
742
742
  ia: 1,
743
743
  con: 1
744
744
  },
745
+ // https://go.mparticle.com/work/SQDSDKS-6039
745
746
  SDKv2NonMPIDCookieKeys: {
746
747
  gs: 1,
747
748
  cu: 1,
@@ -764,7 +765,13 @@ var mParticle = (function () {
764
765
  OfflineStorage: 'offlineStorage'
765
766
  },
766
767
  DefaultInstance: 'default_instance',
767
- CCPAPurpose: 'data_sale_opt_out'
768
+ CCPAPurpose: 'data_sale_opt_out',
769
+ IdentityMethods: {
770
+ Modify: 'modify',
771
+ Logout: 'logout',
772
+ Login: 'login',
773
+ Identify: 'identify'
774
+ }
768
775
  };
769
776
 
770
777
  /******************************************************************************
@@ -1282,9 +1289,15 @@ var mParticle = (function () {
1282
1289
  var isNumber = function isNumber(value) {
1283
1290
  return typeof value === 'number';
1284
1291
  };
1292
+ var isBoolean = function isBoolean(value) {
1293
+ return typeof value === 'boolean';
1294
+ };
1285
1295
  var isFunction = function isFunction(fn) {
1286
1296
  return typeof fn === 'function';
1287
1297
  };
1298
+ var isValidCustomFlagProperty = function isValidCustomFlagProperty(value) {
1299
+ return isNumber(value) || isString(value) || isBoolean(value);
1300
+ };
1288
1301
  var toDataPlanSlug = function toDataPlanSlug(value) {
1289
1302
  // Make sure we are only acting on strings or numbers
1290
1303
  return isStringOrNumber(value) ? value.toString().toLowerCase().replace(/[^0-9a-zA-Z]+/g, '_') : '';
@@ -2364,6 +2377,7 @@ var mParticle = (function () {
2364
2377
  this.uploader = new BatchUploader(mpInstance, millis);
2365
2378
  }
2366
2379
  this.uploader.queueEvent(event);
2380
+ // https://go.mparticle.com/work/SQDSDKS-6038
2367
2381
  mpInstance._Persistence.update();
2368
2382
  };
2369
2383
  this.processQueuedEvents = function () {
@@ -2414,6 +2428,7 @@ var mParticle = (function () {
2414
2428
  if (isEmpty(event)) {
2415
2429
  return;
2416
2430
  }
2431
+ // https://go.mparticle.com/work/SQDSDKS-6038
2417
2432
  if (options.shouldUploadEvent) {
2418
2433
  this.queueEventForBatchUpload(event);
2419
2434
  }
@@ -2494,6 +2509,7 @@ var mParticle = (function () {
2494
2509
  };
2495
2510
  }
2496
2511
 
2512
+ var Modify$3 = Constants.IdentityMethods.Modify;
2497
2513
  var Validators = {
2498
2514
  // From ./utils
2499
2515
  // Utility Functions for backwards compatability
@@ -2516,7 +2532,7 @@ var mParticle = (function () {
2516
2532
  copyUserAttributes: 1
2517
2533
  };
2518
2534
  if (identityApiData) {
2519
- if (method === 'modify') {
2535
+ if (method === Modify$3) {
2520
2536
  if (isObject(identityApiData.userIdentities) && !Object.keys(identityApiData.userIdentities).length || !isObject(identityApiData.userIdentities)) {
2521
2537
  return {
2522
2538
  valid: false,
@@ -2690,6 +2706,7 @@ var mParticle = (function () {
2690
2706
  }
2691
2707
  };
2692
2708
 
2709
+ // https://go.mparticle.com/work/SQDSDKS-6047
2693
2710
  // Standalone version of jQuery.extend, from https://github.com/dansdom/extend
2694
2711
  this.extend = function () {
2695
2712
  var options,
@@ -3191,6 +3208,7 @@ var mParticle = (function () {
3191
3208
  self.endSession();
3192
3209
  self.startNewSession();
3193
3210
  } else {
3211
+ // https://go.mparticle.com/work/SQDSDKS-6045
3194
3212
  var persistence = mpInstance._Persistence.getPersistence();
3195
3213
  if (persistence && !persistence.cu) {
3196
3214
  mpInstance.Identity.identify(mpInstance._Store.SDKConfig.identifyRequest, mpInstance._Store.SDKConfig.identityCallback);
@@ -4008,6 +4026,8 @@ var mParticle = (function () {
4008
4026
  StorageNames = Constants.StorageNames;
4009
4027
  function _Persistence(mpInstance) {
4010
4028
  var self = this;
4029
+
4030
+ // https://go.mparticle.com/work/SQDSDKS-5022
4011
4031
  this.useLocalStorage = function () {
4012
4032
  return !mpInstance._Store.SDKConfig.useCookieStorage && mpInstance._Store.isLocalStorageAvailable;
4013
4033
  };
@@ -4018,6 +4038,7 @@ var mParticle = (function () {
4018
4038
  cookies = self.getCookie(),
4019
4039
  allData;
4020
4040
 
4041
+ // https://go.mparticle.com/work/SQDSDKS-6045
4021
4042
  // Determine if there is any data in cookies or localStorage to figure out if it is the first time the browser is loading mParticle
4022
4043
  if (!localStorageData && !cookies) {
4023
4044
  mpInstance._Store.isFirstRun = true;
@@ -4025,9 +4046,13 @@ var mParticle = (function () {
4025
4046
  } else {
4026
4047
  mpInstance._Store.isFirstRun = false;
4027
4048
  }
4049
+
4050
+ // https://go.mparticle.com/work/SQDSDKS-6045
4028
4051
  if (!mpInstance._Store.isLocalStorageAvailable) {
4029
4052
  mpInstance._Store.SDKConfig.useCookieStorage = true;
4030
4053
  }
4054
+
4055
+ // https://go.mparticle.com/work/SQDSDKS-6046
4031
4056
  if (mpInstance._Store.isLocalStorageAvailable) {
4032
4057
  storage = window.localStorage;
4033
4058
  if (mpInstance._Store.SDKConfig.useCookieStorage) {
@@ -4035,6 +4060,7 @@ var mParticle = (function () {
4035
4060
  // no mParticle cookie exists yet and there is localStorage. Get the localStorage, set them to cookies, then delete the localStorage item.
4036
4061
  if (localStorageData) {
4037
4062
  if (cookies) {
4063
+ // https://go.mparticle.com/work/SQDSDKS-6047
4038
4064
  allData = mpInstance._Helpers.extend(false, localStorageData, cookies);
4039
4065
  } else {
4040
4066
  allData = localStorageData;
@@ -4049,6 +4075,7 @@ var mParticle = (function () {
4049
4075
  // no mParticle localStorage exists yet and there are cookies. Get the cookies, set them to localStorage, then delete the cookies.
4050
4076
  if (cookies) {
4051
4077
  if (localStorageData) {
4078
+ // https://go.mparticle.com/work/SQDSDKS-6047
4052
4079
  allData = mpInstance._Helpers.extend(false, localStorageData, cookies);
4053
4080
  } else {
4054
4081
  allData = cookies;
@@ -4062,6 +4089,8 @@ var mParticle = (function () {
4062
4089
  } else {
4063
4090
  self.storeDataInMemory(cookies);
4064
4091
  }
4092
+
4093
+ // https://go.mparticle.com/work/SQDSDKS-6048
4065
4094
  try {
4066
4095
  if (mpInstance._Store.isLocalStorageAvailable) {
4067
4096
  var encodedProducts = localStorage.getItem(mpInstance._Store.prodStorageName);
@@ -4079,6 +4108,9 @@ var mParticle = (function () {
4079
4108
  mpInstance._Store.cartProducts = [];
4080
4109
  mpInstance.Logger.error('Error loading products in initialization: ' + e);
4081
4110
  }
4111
+
4112
+ // https://go.mparticle.com/work/SQDSDKS-6046
4113
+ // Stores all non-current user MPID information into the store
4082
4114
  for (var key in allData) {
4083
4115
  if (allData.hasOwnProperty(key)) {
4084
4116
  if (!SDKv2NonMPIDCookieKeys[key]) {
@@ -4088,6 +4120,8 @@ var mParticle = (function () {
4088
4120
  }
4089
4121
  self.update();
4090
4122
  } catch (e) {
4123
+ // If cookies or local storage is corrupt, we want to remove it
4124
+ // so that in the future, initializeStorage will work
4091
4125
  if (self.useLocalStorage() && mpInstance._Store.isLocalStorageAvailable) {
4092
4126
  localStorage.removeItem(mpInstance._Store.storageName);
4093
4127
  } else {
@@ -4113,6 +4147,8 @@ var mParticle = (function () {
4113
4147
  }
4114
4148
  }
4115
4149
  };
4150
+
4151
+ // https://go.mparticle.com/work/SQDSDKS-6045
4116
4152
  this.storeDataInMemory = function (obj, currentMPID) {
4117
4153
  try {
4118
4154
  if (!obj) {
@@ -4164,6 +4200,8 @@ var mParticle = (function () {
4164
4200
  mpInstance.Logger.error(Messages$4.ErrorMessages.CookieParseError);
4165
4201
  }
4166
4202
  };
4203
+
4204
+ // https://go.mparticle.com/work/SQDSDKS-5022
4167
4205
  this.determineLocalStorageAvailability = function (storage) {
4168
4206
  var result;
4169
4207
  if (window.mParticle && window.mParticle._forceNoLocalStorage) {
@@ -4223,6 +4261,8 @@ var mParticle = (function () {
4223
4261
  }
4224
4262
  return parsedDecodedProducts;
4225
4263
  };
4264
+
4265
+ // https://go.mparticle.com/work/SQDSDKS-6021
4226
4266
  this.setLocalStorage = function () {
4227
4267
  if (!mpInstance._Store.isLocalStorageAvailable) {
4228
4268
  return;
@@ -4355,7 +4395,8 @@ var mParticle = (function () {
4355
4395
  }
4356
4396
  };
4357
4397
 
4358
- // only used in persistence
4398
+ // https://go.mparticle.com/work/SQDSDKS-5022
4399
+ // https://go.mparticle.com/work/SQDSDKS-6021
4359
4400
  this.setCookie = function () {
4360
4401
  var mpid,
4361
4402
  currentUser = mpInstance.Identity.getCurrentUser();
@@ -4706,6 +4747,8 @@ var mParticle = (function () {
4706
4747
  }
4707
4748
  }
4708
4749
  };
4750
+
4751
+ // https://go.mparticle.com/work/SQDSDKS-6021
4709
4752
  this.savePersistence = function (persistence) {
4710
4753
  var encodedPersistence = self.encodePersistence(JSON.stringify(persistence)),
4711
4754
  date = new Date(),
@@ -4835,6 +4878,7 @@ var mParticle = (function () {
4835
4878
  }
4836
4879
  };
4837
4880
 
4881
+ // https://go.mparticle.com/work/SQDSDKS-6045
4838
4882
  // Forwarder Batching Code
4839
4883
  this.forwardingStatsBatches = {
4840
4884
  uploadsTable: {},
@@ -5044,6 +5088,8 @@ var mParticle = (function () {
5044
5088
  commerceEvent.EventAttributes = attrs;
5045
5089
  }
5046
5090
  mpInstance._APIClient.sendEventToServer(commerceEvent, options);
5091
+
5092
+ // https://go.mparticle.com/work/SQDSDKS-6038
5047
5093
  mpInstance._Persistence.update();
5048
5094
  } else {
5049
5095
  mpInstance.Logger.verbose(Messages$3.InformationMessages.AbandonLogEvent);
@@ -5168,6 +5214,11 @@ var mParticle = (function () {
5168
5214
  };
5169
5215
  }
5170
5216
 
5217
+ var _Constants$IdentityMe$1 = Constants.IdentityMethods,
5218
+ Modify$2 = _Constants$IdentityMe$1.Modify,
5219
+ Identify$1 = _Constants$IdentityMe$1.Identify,
5220
+ Login = _Constants$IdentityMe$1.Login,
5221
+ Logout = _Constants$IdentityMe$1.Logout;
5171
5222
  function Forwarders(mpInstance, kitBlocker) {
5172
5223
  var self = this;
5173
5224
  var UserAttributeActionTypes = {
@@ -5398,6 +5449,8 @@ var mParticle = (function () {
5398
5449
  }
5399
5450
  });
5400
5451
  };
5452
+
5453
+ // TODO: https://go.mparticle.com/work/SQDSDKS-6036
5401
5454
  this.setForwarderUserIdentities = function (userIdentities) {
5402
5455
  mpInstance._Store.activeForwarders.forEach(function (forwarder) {
5403
5456
  var filteredUserIdentities = mpInstance._Helpers.filterUserIdentities(userIdentities, forwarder.userIdentityFilters);
@@ -5426,30 +5479,31 @@ var mParticle = (function () {
5426
5479
  var result;
5427
5480
  mpInstance._Store.activeForwarders.forEach(function (forwarder) {
5428
5481
  var filteredUser = filteredMparticleUser(user.getMPID(), forwarder, mpInstance, kitBlocker);
5429
- if (identityMethod === 'identify') {
5482
+ var filteredUserIdentities = filteredUser.getUserIdentities();
5483
+ if (identityMethod === Identify$1) {
5430
5484
  if (forwarder.onIdentifyComplete) {
5431
- result = forwarder.onIdentifyComplete(filteredUser);
5485
+ result = forwarder.onIdentifyComplete(filteredUser, filteredUserIdentities);
5432
5486
  if (result) {
5433
5487
  mpInstance.Logger.verbose(result);
5434
5488
  }
5435
5489
  }
5436
- } else if (identityMethod === 'login') {
5490
+ } else if (identityMethod === Login) {
5437
5491
  if (forwarder.onLoginComplete) {
5438
- result = forwarder.onLoginComplete(filteredUser);
5492
+ result = forwarder.onLoginComplete(filteredUser, filteredUserIdentities);
5439
5493
  if (result) {
5440
5494
  mpInstance.Logger.verbose(result);
5441
5495
  }
5442
5496
  }
5443
- } else if (identityMethod === 'logout') {
5497
+ } else if (identityMethod === Logout) {
5444
5498
  if (forwarder.onLogoutComplete) {
5445
- result = forwarder.onLogoutComplete(filteredUser);
5499
+ result = forwarder.onLogoutComplete(filteredUser, filteredUserIdentities);
5446
5500
  if (result) {
5447
5501
  mpInstance.Logger.verbose(result);
5448
5502
  }
5449
5503
  }
5450
- } else if (identityMethod === 'modify') {
5504
+ } else if (identityMethod === Modify$2) {
5451
5505
  if (forwarder.onModifyComplete) {
5452
- result = forwarder.onModifyComplete(filteredUser);
5506
+ result = forwarder.onModifyComplete(filteredUser, filteredUserIdentities);
5453
5507
  if (result) {
5454
5508
  mpInstance.Logger.verbose(result);
5455
5509
  }
@@ -5543,41 +5597,43 @@ var mParticle = (function () {
5543
5597
  }
5544
5598
  };
5545
5599
 
5546
- // Sideloaded kits are not configured in the UI and do not have kit configurations
5547
- // They are automatically added to active forwarders.
5600
+ // Unlike UI enabled kits, sideloaded kits are always added to active forwarders.
5548
5601
 
5549
- // TODO: Sideloading kits currently requires the use of a register method
5602
+ // TODO: Sideloading kits currently require the use of a register method
5550
5603
  // which requires an object on which to be registered.
5551
- // In the future, when all kits are moved to the config rather than
5604
+ // In the future, when all kits are moved to the mpConfig rather than
5552
5605
  // there being a separate process for MP configured kits and
5553
5606
  // sideloaded kits, this will need to be refactored.
5554
- this.processSideloadedKits = function (config) {
5607
+ this.processSideloadedKits = function (mpConfig) {
5555
5608
  try {
5556
- if (Array.isArray(config.sideloadedKits)) {
5557
- var sideloadedKits = {
5609
+ if (Array.isArray(mpConfig.sideloadedKits)) {
5610
+ var registeredSideloadedKits = {
5558
5611
  kits: {}
5559
5612
  };
5560
- // First register each kit's constructor onto sideloadedKits,
5561
- // which is typed { kits: Dictionary<constructor> }.
5562
- // The constructors are keyed by the name of the kit.
5563
- config.sideloadedKits.forEach(function (sideloadedKit) {
5613
+ var unregisteredSideloadedKits = mpConfig.sideloadedKits;
5614
+ unregisteredSideloadedKits.forEach(function (unregisteredKit) {
5564
5615
  try {
5565
- sideloadedKit.kitInstance.register(sideloadedKits);
5616
+ // Register each sideloaded kit, which adds a key of the sideloaded kit name
5617
+ // and a value of the sideloaded kit constructor.
5618
+ unregisteredKit.kitInstance.register(registeredSideloadedKits);
5619
+ var kitName = unregisteredKit.kitInstance.name;
5620
+ // Then add the kit filters to each registered kit.
5621
+ registeredSideloadedKits.kits[kitName].filters = unregisteredKit.filterDictionary;
5566
5622
  } catch (e) {
5567
- console.error('Error registering sideloaded kit ' + sideloadedKit.kitInstance.name);
5623
+ console.error('Error registering sideloaded kit ' + unregisteredKit.kitInstance.name);
5568
5624
  }
5569
5625
  });
5570
5626
 
5571
- // Then configure each kit
5572
- for (var registeredKitKey in sideloadedKits.kits) {
5573
- var kitConstructor = sideloadedKits.kits[registeredKitKey];
5574
- self.configureSideloadedKit(kitConstructor);
5627
+ // Then configure each registered kit
5628
+ for (var registeredKitKey in registeredSideloadedKits.kits) {
5629
+ var registeredKit = registeredSideloadedKits.kits[registeredKitKey];
5630
+ self.configureSideloadedKit(registeredKit);
5575
5631
  }
5576
5632
 
5577
5633
  // If Sideloaded Kits are successfully registered,
5578
5634
  // record this in the Store.
5579
- if (!isEmpty(sideloadedKits.kits)) {
5580
- var kitKeys = Object.keys(sideloadedKits.kits);
5635
+ if (!isEmpty(registeredSideloadedKits.kits)) {
5636
+ var kitKeys = Object.keys(registeredSideloadedKits.kits);
5581
5637
  mpInstance._Store.sideloadedKitsCount = kitKeys.length;
5582
5638
  }
5583
5639
  }
@@ -5588,7 +5644,7 @@ var mParticle = (function () {
5588
5644
 
5589
5645
  // kits can be included via mParticle UI, or via sideloaded kit config API
5590
5646
  this.configureSideloadedKit = function (kitConstructor) {
5591
- mpInstance._Store.configuredForwarders.push(this.returnConfiguredKit(kitConstructor));
5647
+ mpInstance._Store.configuredForwarders.push(this.returnConfiguredKit(kitConstructor, kitConstructor.filters));
5592
5648
  };
5593
5649
  this.returnConfiguredKit = function (forwarder) {
5594
5650
  var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
@@ -5647,14 +5703,11 @@ var mParticle = (function () {
5647
5703
  if (event.CustomFlags.hasOwnProperty(prop)) {
5648
5704
  if (Array.isArray(event.CustomFlags[prop])) {
5649
5705
  event.CustomFlags[prop].forEach(function (customFlagProperty) {
5650
- // TODO: Can we use our utility functions here?
5651
- if (typeof customFlagProperty === 'number' || typeof customFlagProperty === 'string' || typeof customFlagProperty === 'boolean') {
5706
+ if (isValidCustomFlagProperty(customFlagProperty)) {
5652
5707
  valueArray.push(customFlagProperty.toString());
5653
5708
  }
5654
5709
  });
5655
- } else if (
5656
- // TODO: Can we use our utility functions here?
5657
- typeof event.CustomFlags[prop] === 'number' || typeof event.CustomFlags[prop] === 'string' || typeof event.CustomFlags[prop] === 'boolean') {
5710
+ } else if (isValidCustomFlagProperty(event.CustomFlags[prop])) {
5658
5711
  valueArray.push(event.CustomFlags[prop].toString());
5659
5712
  }
5660
5713
  if (valueArray.length) {
@@ -5990,6 +6043,9 @@ var mParticle = (function () {
5990
6043
 
5991
6044
  var Messages$2 = Constants.Messages,
5992
6045
  HTTPCodes$2 = Constants.HTTPCodes;
6046
+ var _Constants$IdentityMe = Constants.IdentityMethods,
6047
+ Identify = _Constants$IdentityMe.Identify,
6048
+ Modify$1 = _Constants$IdentityMe.Modify;
5993
6049
  function Identity(mpInstance) {
5994
6050
  var self = this;
5995
6051
  this.checkIdentitySwap = function (previousMPID, currentMPID, currentSessionMPIDs) {
@@ -6895,7 +6951,7 @@ var mParticle = (function () {
6895
6951
  mpInstance._Persistence.setFirstSeenTime(identityApiResult.mpid);
6896
6952
  }
6897
6953
  if (xhr.status === 200) {
6898
- if (method === 'modify') {
6954
+ if (method === Modify$1) {
6899
6955
  newIdentitiesByType = mpInstance._Identity.IdentityRequest.combineUserIdentities(previousUIByName, identityApiData.userIdentities);
6900
6956
  mpInstance._Persistence.saveUserIdentitiesToPersistence(previousMPID, newIdentitiesByType);
6901
6957
  } else {
@@ -6907,7 +6963,7 @@ var mParticle = (function () {
6907
6963
  //this covers an edge case where, users stored before "firstSeenTime" was introduced
6908
6964
  //will not have a value for "fst" until the current MPID changes, and in some cases,
6909
6965
  //the current MPID will never change
6910
- if (method === 'identify' && prevUser && identityApiResult.mpid === prevUser.getMPID()) {
6966
+ if (method === Identify && prevUser && identityApiResult.mpid === prevUser.getMPID()) {
6911
6967
  mpInstance._Persistence.setFirstSeenTime(identityApiResult.mpid);
6912
6968
  }
6913
6969
  indexOfMPID = mpInstance._Store.currentSessionMPIDs.indexOf(identityApiResult.mpid);
@@ -6923,6 +6979,8 @@ var mParticle = (function () {
6923
6979
  if (identityApiData && identityApiData.userIdentities && Object.keys(identityApiData.userIdentities).length) {
6924
6980
  newIdentitiesByType = self.IdentityRequest.combineUserIdentities(incomingMpidUIByName, identityApiData.userIdentities);
6925
6981
  }
6982
+
6983
+ // https://go.mparticle.com/work/SQDSDKS-6041
6926
6984
  mpInstance._Persistence.saveUserIdentitiesToPersistence(identityApiResult.mpid, newIdentitiesByType);
6927
6985
  mpInstance._Persistence.update();
6928
6986
  mpInstance._Persistence.findPrevCookiesBasedOnUI(identityApiData);
@@ -6943,15 +7001,17 @@ var mParticle = (function () {
6943
7001
  if (!prevUser || newUser.getMPID() !== prevUser.getMPID() || prevUser.isLoggedIn() !== newUser.isLoggedIn()) {
6944
7002
  mpInstance._Forwarders.initForwarders(newUser.getUserIdentities().userIdentities, mpInstance._APIClient.prepareForwardingStats);
6945
7003
  }
7004
+
7005
+ // TODO: https://go.mparticle.com/work/SQDSDKS-6036
6946
7006
  mpInstance._Forwarders.setForwarderUserIdentities(newUser.getUserIdentities().userIdentities);
6947
7007
  mpInstance._Forwarders.setForwarderOnIdentityComplete(newUser, method);
6948
- mpInstance._Forwarders.setForwarderOnUserIdentified(newUser, method);
7008
+ mpInstance._Forwarders.setForwarderOnUserIdentified(newUser);
6949
7009
  }
6950
7010
  var newIdentitiesByName = {};
6951
7011
  for (var key in newIdentitiesByType) {
6952
7012
  newIdentitiesByName[Types.IdentityType.getIdentityName(mpInstance._Helpers.parseNumber(key))] = newIdentitiesByType[key];
6953
7013
  }
6954
- self.sendUserIdentityChangeEvent(newIdentitiesByName, method, identityApiResult.mpid, method === 'modify' ? previousUIByNameCopy : incomingMpidUIByNameCopy);
7014
+ self.sendUserIdentityChangeEvent(newIdentitiesByName, method, identityApiResult.mpid, method === Modify$1 ? previousUIByNameCopy : incomingMpidUIByNameCopy);
6955
7015
  }
6956
7016
  if (callback) {
6957
7017
  if (xhr.status === 0) {
@@ -7838,6 +7898,7 @@ var mParticle = (function () {
7838
7898
 
7839
7899
  var HTTPCodes$1 = Constants.HTTPCodes,
7840
7900
  Messages$1 = Constants.Messages;
7901
+ var Modify = Constants.IdentityMethods.Modify;
7841
7902
  function IdentityAPIClient(mpInstance) {
7842
7903
  this.sendAliasRequest = function (aliasRequest, callback) {
7843
7904
  var xhr,
@@ -7892,7 +7953,7 @@ var mParticle = (function () {
7892
7953
  mpInstance._Helpers.invokeCallback(callback, HTTPCodes$1.activeIdentityRequest, 'There is currently an Identity request processing. Please wait for this to return before requesting again');
7893
7954
  } else {
7894
7955
  previousMPID = mpid || null;
7895
- if (method === 'modify') {
7956
+ if (method === Modify) {
7896
7957
  xhr.open('post', mpInstance._Helpers.createServiceUrl(mpInstance._Store.SDKConfig.identityUrl) + mpid + '/' + method);
7897
7958
  } else {
7898
7959
  xhr.open('post', mpInstance._Helpers.createServiceUrl(mpInstance._Store.SDKConfig.identityUrl) + method);
@@ -8871,6 +8932,8 @@ var mParticle = (function () {
8871
8932
  }
8872
8933
  mpInstance._Store.webviewBridgeEnabled = mpInstance._NativeSdkHelpers.isWebviewEnabled(mpInstance._Store.SDKConfig.requiredWebviewBridgeName, mpInstance._Store.SDKConfig.minWebviewBridgeVersion);
8873
8934
  mpInstance._Store.configurationLoaded = true;
8935
+
8936
+ // https://go.mparticle.com/work/SQDSDKS-6044
8874
8937
  if (!mpInstance._Store.webviewBridgeEnabled) {
8875
8938
  // Load any settings/identities/attributes from cookie or localStorage
8876
8939
  mpInstance._Persistence.initializeStorage();
@@ -8915,6 +8978,7 @@ var mParticle = (function () {
8915
8978
  mpInstance._Events.logAST();
8916
8979
 
8917
8980
  // Call mParticle._Store.SDKConfig.identityCallback when identify was not called due to a reload or a sessionId already existing
8981
+ // Any identity callback should always be ran regardless if an identity call is made
8918
8982
  if (!mpInstance._Store.identifyCalled && mpInstance._Store.SDKConfig.identityCallback && currentUser && currentUser.getMPID()) {
8919
8983
  mpInstance._Store.SDKConfig.identityCallback({
8920
8984
  httpCode: HTTPCodes.activeSession,
@@ -8951,6 +9015,8 @@ var mParticle = (function () {
8951
9015
  });
8952
9016
  mpInstance._preInit.readyQueue = [];
8953
9017
  }
9018
+
9019
+ // https://go.mparticle.com/work/SQDSDKS-6040
8954
9020
  if (mpInstance._Store.isFirstRun) {
8955
9021
  mpInstance._Store.isFirstRun = false;
8956
9022
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-sdk",
3
- "version": "2.23.6",
3
+ "version": "2.23.8",
4
4
  "description": "mParticle core SDK for web applications",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -34,6 +34,7 @@
34
34
  "build:webpack:cjs": "webpack --config test/integrations/cjs/webpack/webpack.config.js",
35
35
  "build:rollup:module": "rollup --config test/integrations/module/rollup/rollup.config.js",
36
36
  "build:webpack:module": "webpack --config test/integrations/module/webpack/webpack.config.js",
37
+ "build:rollup:requirejs": "rollup --config test/integrations/requirejs/rollup.requirejs.config.js",
37
38
  "build:ts": "tsc -p .",
38
39
  "test": "npm run build && npm run build:test-bundle && cross-env DEBUG=false karma start test/karma.config.js",
39
40
  "test:debug": "cross-env DEBUG=true karma start test/karma.config.js",
@@ -46,7 +47,7 @@
46
47
  "test:integrations:module": "npm run test:integrations:module:webpack && npm run test:integrations:module:rollup",
47
48
  "test:integrations:module:webpack": "npm run build:webpack:module && npm run test:karma:webpack:module",
48
49
  "test:integrations:module:rollup": "npm run build:rollup:module && npm run test:karma:rollup:module",
49
- "test:requirejs": "npm run build && npm run test:requirejs:before && npm run test:requirejs:after",
50
+ "test:requirejs": "npm run build:iife && npm run build:rollup:requirejs && npm run test:requirejs:before && npm run test:requirejs:after",
50
51
  "test:requirejs:before": "cross-env FILE_ORDER=before_mp karma start test/integrations/requirejs/karma.requirejs.config.js",
51
52
  "test:requirejs:after": "cross-env FILE_ORDER=after_mp karma start test/integrations/requirejs/karma.requirejs.config.js",
52
53
  "test:karma:webpack:cjs": "cross-env BUNDLER=webpack karma start test/integrations/cjs/karma.webpack.config.js",
@@ -105,7 +106,7 @@
105
106
  "eslint": "^8.36.0",
106
107
  "eslint-config-prettier": "9.0.0",
107
108
  "eslint-plugin-prettier": "3.4.1",
108
- "fetch-mock": "^7.5.1",
109
+ "fetch-mock": "^9.1.1",
109
110
  "gts": "^5.0.1",
110
111
  "jest": "^29.5.0",
111
112
  "jest-environment-jsdom": "^29.5.0",
@@ -125,7 +126,7 @@
125
126
  "rollup": "^2.75.7",
126
127
  "shelljs": "^0.8.4",
127
128
  "should": "^7.1.0",
128
- "sinon": "^11.0.0",
129
+ "sinon": "^16.1.3",
129
130
  "ts-jest": "^29.1.0",
130
131
  "tslib": "^2.1.0",
131
132
  "typescript": "^5.0.2",
package/src/apiClient.ts CHANGED
@@ -1,15 +1,11 @@
1
1
  import Constants from './constants';
2
2
  import Types from './types';
3
3
  import { BatchUploader } from './batchUploader';
4
- import {
5
- MParticleUser,
6
- MParticleWebSDK,
7
- MPForwarder,
8
- SDKEvent,
9
- } from './sdkRuntimeModels';
4
+ import { MParticleUser, MParticleWebSDK, SDKEvent } from './sdkRuntimeModels';
10
5
  import KitBlocker from './kitBlocking';
11
- import { Dictionary, getRampNumber, isEmpty } from './utils';
6
+ import { Dictionary, isEmpty } from './utils';
12
7
  import { IUploadObject } from './serverModel';
8
+ import { MPForwarder } from './forwarders.interfaces';
13
9
 
14
10
  export type ForwardingStatsData = Dictionary<any>;
15
11
 
@@ -49,6 +45,7 @@ export default function APIClient(
49
45
  }
50
46
  this.uploader.queueEvent(event);
51
47
 
48
+ // https://go.mparticle.com/work/SQDSDKS-6038
52
49
  mpInstance._Persistence.update();
53
50
  };
54
51
 
@@ -120,6 +117,7 @@ export default function APIClient(
120
117
  return;
121
118
  }
122
119
 
120
+ // https://go.mparticle.com/work/SQDSDKS-6038
123
121
  if (options.shouldUploadEvent) {
124
122
  this.queueEventForBatchUpload(event);
125
123
  }
package/src/constants.ts CHANGED
@@ -146,6 +146,8 @@ const Constants = {
146
146
  ia: 1,
147
147
  con: 1,
148
148
  },
149
+
150
+ // https://go.mparticle.com/work/SQDSDKS-6039
149
151
  SDKv2NonMPIDCookieKeys: {
150
152
  gs: 1,
151
153
  cu: 1,
@@ -169,6 +171,12 @@ const Constants = {
169
171
  },
170
172
  DefaultInstance: 'default_instance',
171
173
  CCPAPurpose: 'data_sale_opt_out',
174
+ IdentityMethods: {
175
+ Modify: 'modify',
176
+ Logout: 'logout',
177
+ Login: 'login',
178
+ Identify: 'identify',
179
+ },
172
180
  } as const;
173
181
 
174
182
  export default Constants;
package/src/events.js CHANGED
@@ -349,6 +349,8 @@ export default function Events(mpInstance) {
349
349
  }
350
350
 
351
351
  mpInstance._APIClient.sendEventToServer(commerceEvent, options);
352
+
353
+ // https://go.mparticle.com/work/SQDSDKS-6038
352
354
  mpInstance._Persistence.update();
353
355
  } else {
354
356
  mpInstance.Logger.verbose(
@@ -1,9 +1,18 @@
1
- import { MParticleUser, SDKEvent, SDKEventCustomFlags, SDKUserIdentity } from './sdkRuntimeModels';
1
+ import {
2
+ MParticleUser,
3
+ SDKEvent,
4
+ SDKEventCustomFlags,
5
+ SDKUserIdentity,
6
+ } from './sdkRuntimeModels';
2
7
  import { Dictionary } from './utils';
3
8
  import { IKitConfigs } from './configAPIClient';
4
9
  import { UserAttributes } from './persistence.interfaces';
5
10
  import { IdentityApiData } from '@mparticle/web-sdk';
6
11
 
12
+ // TODO: https://go.mparticle.com/work/SQDSDKS-6035
13
+ export type Kit = Dictionary;
14
+ export type MPForwarder = Dictionary;
15
+
7
16
  // The state of the kit when accessed via window.KitName via CDN
8
17
  // or imported as an NPM package
9
18
  export interface UnregisteredKit {
@@ -32,11 +41,24 @@ export interface ConfiguredKit
32
41
  appVersion: string,
33
42
  appName: string,
34
43
  customFlags: SDKEventCustomFlags,
35
- clientId: string): string;
36
- onIdentifyComplete(user: MParticleUser, filteredIdentityRequest: IdentityApiData): string | KitMappedMethodFailure;
37
- onLoginComplete(user: MParticleUser, filteredIdentityRequest: IdentityApiData): string | KitMappedMethodFailure;
38
- onLogoutComplete(user: MParticleUser, filteredIdentityRequest: IdentityApiData): string | KitMappedMethodFailure;
39
- onModifyComplete(user: MParticleUser, filteredIdentityRequest: IdentityApiData): string | KitMappedMethodFailure;
44
+ clientId: string
45
+ ): string;
46
+ onIdentifyComplete(
47
+ user: MParticleUser,
48
+ filteredIdentityRequest: IdentityApiData
49
+ ): string | KitMappedMethodFailure;
50
+ onLoginComplete(
51
+ user: MParticleUser,
52
+ filteredIdentityRequest: IdentityApiData
53
+ ): string | KitMappedMethodFailure;
54
+ onLogoutComplete(
55
+ user: MParticleUser,
56
+ filteredIdentityRequest: IdentityApiData
57
+ ): string | KitMappedMethodFailure;
58
+ onModifyComplete(
59
+ user: MParticleUser,
60
+ filteredIdentityRequest: IdentityApiData
61
+ ): string | KitMappedMethodFailure;
40
62
  onUserIdentified(user: MParticleUser): string | KitMappedMethodFailure;
41
63
  process(event: SDKEvent): string;
42
64
  setOptOut(isOptingOut: boolean): string | KitMappedMethodFailure;