@mparticle/web-sdk 2.79.3 → 2.80.1
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 +220 -574
- package/dist/mparticle.esm.js +220 -574
- package/dist/mparticle.js +1489 -1793
- package/dist/types/src/configAPIClient.d.ts +1 -0
- package/dist/types/src/ecommerce.d.ts +3 -53
- package/dist/types/src/ecommerce.interfaces.d.ts +11 -12
- package/dist/types/src/events.interfaces.d.ts +1 -1
- package/dist/types/src/forwarders.d.ts +4 -26
- package/dist/types/src/forwarders.interfaces.d.ts +41 -10
- package/dist/types/src/identity-utils.d.ts +3 -3
- package/dist/types/src/identity.d.ts +3 -0
- package/dist/types/src/identity.interfaces.d.ts +45 -11
- package/dist/types/src/identityApiClient.d.ts +5 -4
- package/dist/types/src/mp-instance.d.ts +2 -2
- package/dist/types/src/pageViewTracker.d.ts +12 -5
- package/dist/types/src/persistence.d.ts +3 -44
- package/dist/types/src/persistence.interfaces.d.ts +12 -13
- package/dist/types/src/sdkRuntimeModels.d.ts +3 -2
- package/dist/types/src/store.d.ts +5 -3
- package/package.json +1 -1
- package/src/configAPIClient.ts +1 -0
- package/src/ecommerce.interfaces.ts +12 -21
- package/src/{ecommerce.js → ecommerce.ts} +144 -73
- package/src/events.interfaces.ts +1 -1
- package/src/events.ts +10 -2
- package/src/forwarders.interfaces.ts +73 -10
- package/src/{forwarders.js → forwarders.ts} +214 -176
- package/src/helpers.ts +7 -3
- package/src/identity-utils.ts +2 -2
- package/src/identity.interfaces.ts +58 -14
- package/src/{identity.js → identity.ts} +237 -192
- package/src/identityApiClient.ts +9 -9
- package/src/mp-instance.ts +2 -2
- package/src/pageViewTracker.ts +176 -42
- package/src/persistence.interfaces.ts +12 -13
- package/src/persistence.ts +1210 -0
- package/src/sdkRuntimeModels.ts +3 -1
- package/src/store.ts +5 -3
- package/src/persistence.js +0 -985
package/dist/mparticle.js
CHANGED
|
@@ -204,7 +204,7 @@ var mParticle = (function () {
|
|
|
204
204
|
Base64: Base64$1
|
|
205
205
|
};
|
|
206
206
|
|
|
207
|
-
var version = "2.
|
|
207
|
+
var version = "2.80.1";
|
|
208
208
|
|
|
209
209
|
var Constants = {
|
|
210
210
|
sdkVersion: version,
|
|
@@ -422,14 +422,14 @@ var mParticle = (function () {
|
|
|
422
422
|
var HTTP_NOT_FOUND = 404;
|
|
423
423
|
var HTTP_SERVER_ERROR = 500;
|
|
424
424
|
|
|
425
|
-
function _typeof
|
|
425
|
+
function _typeof(o) {
|
|
426
426
|
"@babel/helpers - typeof";
|
|
427
427
|
|
|
428
|
-
return _typeof
|
|
428
|
+
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
429
429
|
return typeof o;
|
|
430
430
|
} : function (o) {
|
|
431
431
|
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
432
|
-
}, _typeof
|
|
432
|
+
}, _typeof(o);
|
|
433
433
|
}
|
|
434
434
|
|
|
435
435
|
/******************************************************************************
|
|
@@ -923,7 +923,7 @@ var mParticle = (function () {
|
|
|
923
923
|
return obfuscated;
|
|
924
924
|
}
|
|
925
925
|
// For primitives and other types, return the type as a string
|
|
926
|
-
return _typeof
|
|
926
|
+
return _typeof(value);
|
|
927
927
|
};
|
|
928
928
|
/**
|
|
929
929
|
* For verbose logging: returns raw data when isDevelopmentMode is true, else obfuscated data.
|
|
@@ -996,7 +996,7 @@ var mParticle = (function () {
|
|
|
996
996
|
target = args[1] || {};
|
|
997
997
|
i = 2;
|
|
998
998
|
}
|
|
999
|
-
if (_typeof
|
|
999
|
+
if (_typeof(target) !== 'object' && !objectHelper.isFunction(target)) {
|
|
1000
1000
|
target = {};
|
|
1001
1001
|
}
|
|
1002
1002
|
if (length === i) {
|
|
@@ -1044,7 +1044,7 @@ var mParticle = (function () {
|
|
|
1044
1044
|
return e;
|
|
1045
1045
|
}
|
|
1046
1046
|
// fetch-mock and some network libs reject with { message } rather than Error
|
|
1047
|
-
if (e && _typeof
|
|
1047
|
+
if (e && _typeof(e) === 'object' && typeof e.message === 'string') {
|
|
1048
1048
|
return e.message;
|
|
1049
1049
|
}
|
|
1050
1050
|
return fallback;
|
|
@@ -1519,10 +1519,6 @@ var mParticle = (function () {
|
|
|
1519
1519
|
Error: 'error'
|
|
1520
1520
|
};
|
|
1521
1521
|
|
|
1522
|
-
function getDefaultExportFromCjs (x) {
|
|
1523
|
-
return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, 'default') ? x['default'] : x;
|
|
1524
|
-
}
|
|
1525
|
-
|
|
1526
1522
|
var dist = {};
|
|
1527
1523
|
|
|
1528
1524
|
(function (exports) {
|
|
@@ -3385,11 +3381,11 @@ var mParticle = (function () {
|
|
|
3385
3381
|
});
|
|
3386
3382
|
};
|
|
3387
3383
|
|
|
3388
|
-
var _a = Constants.IdentityMethods,
|
|
3389
|
-
Identify$2 = _a.Identify,
|
|
3390
|
-
Modify$3 = _a.Modify,
|
|
3391
|
-
Login$2 = _a.Login,
|
|
3392
|
-
Logout$2 = _a.Logout;
|
|
3384
|
+
var _a$1 = Constants.IdentityMethods,
|
|
3385
|
+
Identify$2 = _a$1.Identify,
|
|
3386
|
+
Modify$3 = _a$1.Modify,
|
|
3387
|
+
Login$2 = _a$1.Login,
|
|
3388
|
+
Logout$2 = _a$1.Logout;
|
|
3393
3389
|
var HTTPCodes$3 = Constants.HTTPCodes,
|
|
3394
3390
|
Messages$9 = Constants.Messages;
|
|
3395
3391
|
var CACHE_HEADER = 'x-mp-max-age';
|
|
@@ -4474,7 +4470,6 @@ var mParticle = (function () {
|
|
|
4474
4470
|
var Messages$5 = Constants.Messages;
|
|
4475
4471
|
function Ecommerce(mpInstance) {
|
|
4476
4472
|
var self = this;
|
|
4477
|
-
|
|
4478
4473
|
// https://go.mparticle.com/work/SQDSDKS-4801
|
|
4479
4474
|
this.convertTransactionAttributesToProductAction = function (transactionAttributes, productAction) {
|
|
4480
4475
|
if (transactionAttributes.hasOwnProperty('Id')) {
|
|
@@ -4502,7 +4497,6 @@ var mParticle = (function () {
|
|
|
4502
4497
|
productAction.CheckoutOptions = transactionAttributes.Option;
|
|
4503
4498
|
}
|
|
4504
4499
|
};
|
|
4505
|
-
|
|
4506
4500
|
// When the caller does not supply a transaction-level total via
|
|
4507
4501
|
// transactionAttributes.Revenue, derive it from the product list
|
|
4508
4502
|
// (quantity * price) plus shipping and tax. A total that the caller provided
|
|
@@ -4594,13 +4588,11 @@ var mParticle = (function () {
|
|
|
4594
4588
|
return Types.CommerceEventType.ProductRemoveFromCart;
|
|
4595
4589
|
case Types.ProductActionType.RemoveFromWishlist:
|
|
4596
4590
|
return Types.CommerceEventType.ProductRemoveFromWishlist;
|
|
4597
|
-
|
|
4598
4591
|
// https://go.mparticle.com/work/SQDSDKS-4801
|
|
4599
4592
|
case Types.ProductActionType.Unknown:
|
|
4600
4593
|
return Types.EventType.Unknown;
|
|
4601
4594
|
case Types.ProductActionType.ViewDetail:
|
|
4602
4595
|
return Types.CommerceEventType.ProductViewDetail;
|
|
4603
|
-
|
|
4604
4596
|
// Rokt Brain commerce-adjacent types map to Unknown on server
|
|
4605
4597
|
case Types.ProductActionType.ViewCart:
|
|
4606
4598
|
case Types.ProductActionType.AddShippingInfo:
|
|
@@ -4630,7 +4622,6 @@ var mParticle = (function () {
|
|
|
4630
4622
|
this.generateExpandedEcommerceName = function (eventName, plusOne) {
|
|
4631
4623
|
return 'eCommerce - ' + eventName + ' - ' + (plusOne ? 'Total' : 'Item');
|
|
4632
4624
|
};
|
|
4633
|
-
|
|
4634
4625
|
// https://go.mparticle.com/work/SQDSDKS-4801
|
|
4635
4626
|
this.extractProductAttributes = function (attributes, product) {
|
|
4636
4627
|
if (product.CouponCode) {
|
|
@@ -4662,14 +4653,12 @@ var mParticle = (function () {
|
|
|
4662
4653
|
}
|
|
4663
4654
|
attributes['Total Product Amount'] = product.TotalAmount || 0;
|
|
4664
4655
|
};
|
|
4665
|
-
|
|
4666
4656
|
// https://go.mparticle.com/work/SQDSDKS-4801
|
|
4667
4657
|
this.extractTransactionId = function (attributes, productAction) {
|
|
4668
4658
|
if (productAction.TransactionId) {
|
|
4669
4659
|
attributes['Transaction Id'] = productAction.TransactionId;
|
|
4670
4660
|
}
|
|
4671
4661
|
};
|
|
4672
|
-
|
|
4673
4662
|
// https://go.mparticle.com/work/SQDSDKS-4801
|
|
4674
4663
|
this.extractActionAttributes = function (attributes, productAction) {
|
|
4675
4664
|
self.extractTransactionId(attributes, productAction);
|
|
@@ -4695,7 +4684,6 @@ var mParticle = (function () {
|
|
|
4695
4684
|
attributes['Checkout Step'] = productAction.CheckoutStep;
|
|
4696
4685
|
}
|
|
4697
4686
|
};
|
|
4698
|
-
|
|
4699
4687
|
// https://go.mparticle.com/work/SQDSDKS-4801
|
|
4700
4688
|
this.extractPromotionAttributes = function (attributes, promotion) {
|
|
4701
4689
|
if (promotion.Id) {
|
|
@@ -4919,15 +4907,13 @@ var mParticle = (function () {
|
|
|
4919
4907
|
}
|
|
4920
4908
|
return null;
|
|
4921
4909
|
};
|
|
4922
|
-
|
|
4923
4910
|
// sanitizes any non number, non string value to 0
|
|
4924
4911
|
this.sanitizeAmount = function (amount, category) {
|
|
4925
4912
|
if (!mpInstance._Helpers.Validators.isStringOrNumber(amount)) {
|
|
4926
|
-
var message = [category, 'must be of type number. A', _typeof
|
|
4913
|
+
var message = [category, 'must be of type number. A', _typeof(amount), 'was passed. Converting to 0'].join(' ');
|
|
4927
4914
|
mpInstance.Logger.warning(message);
|
|
4928
4915
|
return 0;
|
|
4929
4916
|
}
|
|
4930
|
-
|
|
4931
4917
|
// if amount is a string, it will be parsed into a number if possible, or set to 0
|
|
4932
4918
|
return mpInstance._Helpers.parseNumber(amount);
|
|
4933
4919
|
};
|
|
@@ -5199,7 +5185,7 @@ var mParticle = (function () {
|
|
|
5199
5185
|
if (mpInstance._Helpers.Validators.isFunction(callback)) {
|
|
5200
5186
|
this.SDKConfig.identityCallback = config.identityCallback;
|
|
5201
5187
|
} else {
|
|
5202
|
-
mpInstance.Logger.warning('The optional callback must be a function. You tried entering a(n) ' + _typeof
|
|
5188
|
+
mpInstance.Logger.warning('The optional callback must be a function. You tried entering a(n) ' + _typeof(callback) + ' . Callback not set. Please set your callback again.');
|
|
5203
5189
|
}
|
|
5204
5190
|
}
|
|
5205
5191
|
if (config.hasOwnProperty('appVersion')) {
|
|
@@ -5605,90 +5591,101 @@ var mParticle = (function () {
|
|
|
5605
5591
|
Base64CookieKeys = Constants.Base64CookieKeys,
|
|
5606
5592
|
SDKv2NonMPIDCookieKeys = Constants.SDKv2NonMPIDCookieKeys,
|
|
5607
5593
|
StorageNames = Constants.StorageNames;
|
|
5594
|
+
function getMParticleManager() {
|
|
5595
|
+
return window.mParticle;
|
|
5596
|
+
}
|
|
5608
5597
|
function _Persistence(mpInstance) {
|
|
5609
5598
|
var self = this;
|
|
5610
|
-
|
|
5611
5599
|
// https://go.mparticle.com/work/SQDSDKS-5022
|
|
5612
5600
|
this.useLocalStorage = function () {
|
|
5613
5601
|
return !mpInstance._Store.SDKConfig.useCookieStorage && mpInstance._Store.isLocalStorageAvailable;
|
|
5614
5602
|
};
|
|
5603
|
+
function setFirstRunFromExistingData(localStorageData, cookies) {
|
|
5604
|
+
if (!localStorageData && !cookies) {
|
|
5605
|
+
mpInstance._Store.isFirstRun = true;
|
|
5606
|
+
mpInstance._Store.mpid = 0;
|
|
5607
|
+
return;
|
|
5608
|
+
}
|
|
5609
|
+
mpInstance._Store.isFirstRun = false;
|
|
5610
|
+
}
|
|
5611
|
+
function mergeStorageSources(localStorageData, cookies) {
|
|
5612
|
+
if (localStorageData && cookies) {
|
|
5613
|
+
// https://go.mparticle.com/work/SQDSDKS-6047
|
|
5614
|
+
return extend(false, localStorageData, cookies);
|
|
5615
|
+
}
|
|
5616
|
+
return localStorageData || cookies;
|
|
5617
|
+
}
|
|
5618
|
+
// For migrating from localStorage to cookies -- If an instance switches from
|
|
5619
|
+
// localStorage to cookies, then no mParticle cookie exists yet and there is
|
|
5620
|
+
// localStorage. Get the localStorage, set them to cookies, then delete the
|
|
5621
|
+
// localStorage item.
|
|
5622
|
+
function migrateLocalStorageToCookies(storage, localStorageData, cookies) {
|
|
5623
|
+
var allData;
|
|
5624
|
+
if (localStorageData) {
|
|
5625
|
+
allData = mergeStorageSources(localStorageData, cookies);
|
|
5626
|
+
storage.removeItem(mpInstance._Store.storageName);
|
|
5627
|
+
} else if (cookies) {
|
|
5628
|
+
allData = cookies;
|
|
5629
|
+
}
|
|
5630
|
+
self.storeDataInMemory(allData);
|
|
5631
|
+
return allData;
|
|
5632
|
+
}
|
|
5633
|
+
// For migrating from cookie to localStorage -- If an instance is newly
|
|
5634
|
+
// switching from cookies to localStorage, then no mParticle localStorage
|
|
5635
|
+
// exists yet and there are cookies. Get the cookies, set them to
|
|
5636
|
+
// localStorage, then delete the cookies.
|
|
5637
|
+
function migrateCookiesToLocalStorage(localStorageData, cookies) {
|
|
5638
|
+
if (!cookies) {
|
|
5639
|
+
self.storeDataInMemory(localStorageData);
|
|
5640
|
+
return;
|
|
5641
|
+
}
|
|
5642
|
+
var allData = mergeStorageSources(localStorageData, cookies);
|
|
5643
|
+
self.storeDataInMemory(allData);
|
|
5644
|
+
self.expireCookies(mpInstance._Store.storageName);
|
|
5645
|
+
return allData;
|
|
5646
|
+
}
|
|
5647
|
+
function loadPersistenceIntoMemory(localStorageData, cookies) {
|
|
5648
|
+
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
5649
|
+
self.storeDataInMemory(cookies);
|
|
5650
|
+
return;
|
|
5651
|
+
}
|
|
5652
|
+
if (mpInstance._Store.SDKConfig.useCookieStorage) {
|
|
5653
|
+
return migrateLocalStorageToCookies(window.localStorage, localStorageData, cookies);
|
|
5654
|
+
}
|
|
5655
|
+
return migrateCookiesToLocalStorage(localStorageData, cookies);
|
|
5656
|
+
}
|
|
5657
|
+
function copyNonCurrentUserMpids(allData) {
|
|
5658
|
+
for (var key in allData) {
|
|
5659
|
+
if (allData.hasOwnProperty(key) && !SDKv2NonMPIDCookieKeys[key]) {
|
|
5660
|
+
mpInstance._Store.nonCurrentUserMPIDs[key] = allData[key];
|
|
5661
|
+
}
|
|
5662
|
+
}
|
|
5663
|
+
}
|
|
5664
|
+
function clearCorruptStorage() {
|
|
5665
|
+
if (self.useLocalStorage() && mpInstance._Store.isLocalStorageAvailable) {
|
|
5666
|
+
localStorage.removeItem(mpInstance._Store.storageName);
|
|
5667
|
+
return;
|
|
5668
|
+
}
|
|
5669
|
+
self.expireCookies(mpInstance._Store.storageName);
|
|
5670
|
+
}
|
|
5615
5671
|
this.initializeStorage = function () {
|
|
5616
5672
|
try {
|
|
5617
|
-
var
|
|
5618
|
-
|
|
5619
|
-
cookies = self.getCookie(),
|
|
5620
|
-
allData;
|
|
5621
|
-
|
|
5673
|
+
var localStorageData = self.getLocalStorage();
|
|
5674
|
+
var cookies = self.getCookie();
|
|
5622
5675
|
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
5623
|
-
|
|
5624
|
-
if (!localStorageData && !cookies) {
|
|
5625
|
-
mpInstance._Store.isFirstRun = true;
|
|
5626
|
-
mpInstance._Store.mpid = 0;
|
|
5627
|
-
} else {
|
|
5628
|
-
mpInstance._Store.isFirstRun = false;
|
|
5629
|
-
}
|
|
5630
|
-
|
|
5676
|
+
setFirstRunFromExistingData(localStorageData, cookies);
|
|
5631
5677
|
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
5632
5678
|
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
5633
5679
|
mpInstance._Store.SDKConfig.useCookieStorage = true;
|
|
5634
5680
|
}
|
|
5635
|
-
|
|
5636
|
-
// https://go.mparticle.com/work/SQDSDKS-6046
|
|
5637
|
-
if (mpInstance._Store.isLocalStorageAvailable) {
|
|
5638
|
-
storage = window.localStorage;
|
|
5639
|
-
if (mpInstance._Store.SDKConfig.useCookieStorage) {
|
|
5640
|
-
// For migrating from localStorage to cookies -- If an instance switches from localStorage to cookies, then
|
|
5641
|
-
// no mParticle cookie exists yet and there is localStorage. Get the localStorage, set them to cookies, then delete the localStorage item.
|
|
5642
|
-
if (localStorageData) {
|
|
5643
|
-
if (cookies) {
|
|
5644
|
-
// https://go.mparticle.com/work/SQDSDKS-6047
|
|
5645
|
-
allData = extend(false, localStorageData, cookies);
|
|
5646
|
-
} else {
|
|
5647
|
-
allData = localStorageData;
|
|
5648
|
-
}
|
|
5649
|
-
storage.removeItem(mpInstance._Store.storageName);
|
|
5650
|
-
} else if (cookies) {
|
|
5651
|
-
allData = cookies;
|
|
5652
|
-
}
|
|
5653
|
-
self.storeDataInMemory(allData);
|
|
5654
|
-
} else {
|
|
5655
|
-
// For migrating from cookie to localStorage -- If an instance is newly switching from cookies to localStorage, then
|
|
5656
|
-
// no mParticle localStorage exists yet and there are cookies. Get the cookies, set them to localStorage, then delete the cookies.
|
|
5657
|
-
if (cookies) {
|
|
5658
|
-
if (localStorageData) {
|
|
5659
|
-
// https://go.mparticle.com/work/SQDSDKS-6047
|
|
5660
|
-
allData = extend(false, localStorageData, cookies);
|
|
5661
|
-
} else {
|
|
5662
|
-
allData = cookies;
|
|
5663
|
-
}
|
|
5664
|
-
self.storeDataInMemory(allData);
|
|
5665
|
-
self.expireCookies(mpInstance._Store.storageName);
|
|
5666
|
-
} else {
|
|
5667
|
-
self.storeDataInMemory(localStorageData);
|
|
5668
|
-
}
|
|
5669
|
-
}
|
|
5670
|
-
} else {
|
|
5671
|
-
self.storeDataInMemory(cookies);
|
|
5672
|
-
}
|
|
5673
|
-
|
|
5674
5681
|
// https://go.mparticle.com/work/SQDSDKS-6046
|
|
5675
|
-
|
|
5676
|
-
|
|
5677
|
-
if (allData.hasOwnProperty(key)) {
|
|
5678
|
-
if (!SDKv2NonMPIDCookieKeys[key]) {
|
|
5679
|
-
mpInstance._Store.nonCurrentUserMPIDs[key] = allData[key];
|
|
5680
|
-
}
|
|
5681
|
-
}
|
|
5682
|
-
}
|
|
5682
|
+
var allData = loadPersistenceIntoMemory(localStorageData, cookies);
|
|
5683
|
+
copyNonCurrentUserMpids(allData);
|
|
5683
5684
|
self.update();
|
|
5684
5685
|
} catch (e) {
|
|
5685
5686
|
// If cookies or local storage is corrupt, we want to remove it
|
|
5686
5687
|
// so that in the future, initializeStorage will work
|
|
5687
|
-
|
|
5688
|
-
localStorage.removeItem(mpInstance._Store.storageName);
|
|
5689
|
-
} else {
|
|
5690
|
-
self.expireCookies(mpInstance._Store.storageName);
|
|
5691
|
-
}
|
|
5688
|
+
clearCorruptStorage();
|
|
5692
5689
|
mpInstance.Logger.error('Error initializing storage: ' + e);
|
|
5693
5690
|
}
|
|
5694
5691
|
};
|
|
@@ -5700,86 +5697,83 @@ var mParticle = (function () {
|
|
|
5700
5697
|
self.setLocalStorage();
|
|
5701
5698
|
}
|
|
5702
5699
|
};
|
|
5703
|
-
|
|
5700
|
+
function applyEmptyPersistenceDefaults() {
|
|
5701
|
+
mpInstance.Logger.verbose(Messages$4.InformationMessages.CookieNotFound);
|
|
5702
|
+
mpInstance._Store.clientId = mpInstance._Store.clientId || mpInstance._Helpers.generateUniqueId();
|
|
5703
|
+
mpInstance._Store.deviceId = mpInstance._Store.deviceId || mpInstance._Helpers.generateUniqueId();
|
|
5704
|
+
}
|
|
5705
|
+
function hydrateStoreFromPersistence(obj, currentMPID) {
|
|
5706
|
+
// Set MPID first, then change object to match MPID data
|
|
5707
|
+
if (currentMPID) {
|
|
5708
|
+
mpInstance._Store.mpid = currentMPID;
|
|
5709
|
+
} else {
|
|
5710
|
+
mpInstance._Store.mpid = obj.cu || 0;
|
|
5711
|
+
}
|
|
5712
|
+
obj.gs = obj.gs || {};
|
|
5713
|
+
mpInstance._Store.sessionId = obj.gs.sid || mpInstance._Store.sessionId;
|
|
5714
|
+
mpInstance._Store.isEnabled = typeof obj.gs.ie !== 'undefined' ? obj.gs.ie : mpInstance._Store.isEnabled;
|
|
5715
|
+
mpInstance._Store.sessionAttributes = obj.gs.sa || mpInstance._Store.sessionAttributes;
|
|
5716
|
+
mpInstance._Store.localSessionAttributes = obj.gs.lsa || mpInstance._Store.localSessionAttributes;
|
|
5717
|
+
mpInstance._Store.serverSettings = obj.gs.ss || mpInstance._Store.serverSettings;
|
|
5718
|
+
mpInstance._Store.devToken = mpInstance._Store.devToken || obj.gs.dt;
|
|
5719
|
+
mpInstance._Store.SDKConfig.appVersion = mpInstance._Store.SDKConfig.appVersion || obj.gs.av;
|
|
5720
|
+
mpInstance._Store.clientId = obj.gs.cgid || mpInstance._Store.clientId || mpInstance._Helpers.generateUniqueId();
|
|
5721
|
+
// For most persistence values, we prioritize localstorage/cookie values over
|
|
5722
|
+
// Store. However, we allow device ID to be overriden via a config value and
|
|
5723
|
+
// thus the priority of the deviceId value is
|
|
5724
|
+
// 1. value passed via config.deviceId
|
|
5725
|
+
// 2. previous value in persistence
|
|
5726
|
+
// 3. generate new guid
|
|
5727
|
+
mpInstance._Store.deviceId = mpInstance._Store.deviceId || obj.gs.das || mpInstance._Helpers.generateUniqueId();
|
|
5728
|
+
mpInstance._Store.integrationAttributes = obj.gs.ia || {};
|
|
5729
|
+
mpInstance._Store.context = obj.gs.c || mpInstance._Store.context;
|
|
5730
|
+
mpInstance._Store.currentSessionMPIDs = obj.gs.csm || mpInstance._Store.currentSessionMPIDs;
|
|
5731
|
+
mpInstance._Store.isLoggedIn = obj.l === true;
|
|
5732
|
+
if (obj.gs.les) {
|
|
5733
|
+
mpInstance._Store.dateLastEventSent = new Date(obj.gs.les);
|
|
5734
|
+
}
|
|
5735
|
+
mpInstance._Store.sessionStartDate = obj.gs.ssd ? new Date(obj.gs.ssd) : new Date();
|
|
5736
|
+
if (currentMPID) {
|
|
5737
|
+
obj = obj[currentMPID];
|
|
5738
|
+
} else {
|
|
5739
|
+
obj = obj[obj.cu];
|
|
5740
|
+
}
|
|
5741
|
+
}
|
|
5704
5742
|
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
5705
5743
|
this.storeDataInMemory = function (obj, currentMPID) {
|
|
5706
5744
|
try {
|
|
5707
5745
|
if (!obj) {
|
|
5708
|
-
|
|
5709
|
-
|
|
5710
|
-
mpInstance._Store.deviceId = mpInstance._Store.deviceId || mpInstance._Helpers.generateUniqueId();
|
|
5711
|
-
} else {
|
|
5712
|
-
// Set MPID first, then change object to match MPID data
|
|
5713
|
-
if (currentMPID) {
|
|
5714
|
-
mpInstance._Store.mpid = currentMPID;
|
|
5715
|
-
} else {
|
|
5716
|
-
mpInstance._Store.mpid = obj.cu || 0;
|
|
5717
|
-
}
|
|
5718
|
-
obj.gs = obj.gs || {};
|
|
5719
|
-
mpInstance._Store.sessionId = obj.gs.sid || mpInstance._Store.sessionId;
|
|
5720
|
-
mpInstance._Store.isEnabled = typeof obj.gs.ie !== 'undefined' ? obj.gs.ie : mpInstance._Store.isEnabled;
|
|
5721
|
-
mpInstance._Store.sessionAttributes = obj.gs.sa || mpInstance._Store.sessionAttributes;
|
|
5722
|
-
mpInstance._Store.localSessionAttributes = obj.gs.lsa || mpInstance._Store.localSessionAttributes;
|
|
5723
|
-
mpInstance._Store.serverSettings = obj.gs.ss || mpInstance._Store.serverSettings;
|
|
5724
|
-
mpInstance._Store.devToken = mpInstance._Store.devToken || obj.gs.dt;
|
|
5725
|
-
mpInstance._Store.SDKConfig.appVersion = mpInstance._Store.SDKConfig.appVersion || obj.gs.av;
|
|
5726
|
-
mpInstance._Store.clientId = obj.gs.cgid || mpInstance._Store.clientId || mpInstance._Helpers.generateUniqueId();
|
|
5727
|
-
|
|
5728
|
-
// For most persistence values, we prioritize localstorage/cookie values over
|
|
5729
|
-
// Store. However, we allow device ID to be overriden via a config value and
|
|
5730
|
-
// thus the priority of the deviceId value is
|
|
5731
|
-
// 1. value passed via config.deviceId
|
|
5732
|
-
// 2. previous value in persistence
|
|
5733
|
-
// 3. generate new guid
|
|
5734
|
-
mpInstance._Store.deviceId = mpInstance._Store.deviceId || obj.gs.das || mpInstance._Helpers.generateUniqueId();
|
|
5735
|
-
mpInstance._Store.integrationAttributes = obj.gs.ia || {};
|
|
5736
|
-
mpInstance._Store.context = obj.gs.c || mpInstance._Store.context;
|
|
5737
|
-
mpInstance._Store.currentSessionMPIDs = obj.gs.csm || mpInstance._Store.currentSessionMPIDs;
|
|
5738
|
-
mpInstance._Store.isLoggedIn = obj.l === true;
|
|
5739
|
-
if (obj.gs.les) {
|
|
5740
|
-
mpInstance._Store.dateLastEventSent = new Date(obj.gs.les);
|
|
5741
|
-
}
|
|
5742
|
-
if (obj.gs.ssd) {
|
|
5743
|
-
mpInstance._Store.sessionStartDate = new Date(obj.gs.ssd);
|
|
5744
|
-
} else {
|
|
5745
|
-
mpInstance._Store.sessionStartDate = new Date();
|
|
5746
|
-
}
|
|
5747
|
-
if (currentMPID) {
|
|
5748
|
-
obj = obj[currentMPID];
|
|
5749
|
-
} else {
|
|
5750
|
-
obj = obj[obj.cu];
|
|
5751
|
-
}
|
|
5746
|
+
applyEmptyPersistenceDefaults();
|
|
5747
|
+
return;
|
|
5752
5748
|
}
|
|
5749
|
+
hydrateStoreFromPersistence(obj, currentMPID);
|
|
5753
5750
|
} catch (e) {
|
|
5754
5751
|
mpInstance.Logger.error(Messages$4.ErrorMessages.CookieParseError);
|
|
5755
5752
|
}
|
|
5756
5753
|
};
|
|
5757
|
-
|
|
5758
5754
|
// https://go.mparticle.com/work/SQDSDKS-5022
|
|
5759
5755
|
this.determineLocalStorageAvailability = function (storage) {
|
|
5760
|
-
var
|
|
5761
|
-
if (
|
|
5762
|
-
|
|
5756
|
+
var mParticleManager = getMParticleManager();
|
|
5757
|
+
if (mParticleManager === null || mParticleManager === void 0 ? void 0 : mParticleManager._forceNoLocalStorage) {
|
|
5758
|
+
return false;
|
|
5763
5759
|
}
|
|
5764
5760
|
try {
|
|
5765
5761
|
storage.setItem('mparticle', 'test');
|
|
5766
|
-
result = storage.getItem('mparticle') === 'test';
|
|
5762
|
+
var result = storage.getItem('mparticle') === 'test';
|
|
5767
5763
|
storage.removeItem('mparticle');
|
|
5768
|
-
return result && storage;
|
|
5764
|
+
return Boolean(result && storage);
|
|
5769
5765
|
} catch (e) {
|
|
5770
5766
|
return false;
|
|
5771
5767
|
}
|
|
5772
5768
|
};
|
|
5773
|
-
|
|
5774
5769
|
// https://go.mparticle.com/work/SQDSDKS-6021
|
|
5775
5770
|
this.setLocalStorage = function () {
|
|
5776
|
-
var
|
|
5771
|
+
var _a;
|
|
5777
5772
|
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
5778
5773
|
return;
|
|
5779
5774
|
}
|
|
5780
|
-
|
|
5781
5775
|
// Block mprtcl-v4 localStorage when noFunctional is true
|
|
5782
|
-
if ((
|
|
5776
|
+
if ((_a = mpInstance._CookieConsentManager) === null || _a === void 0 ? void 0 : _a.getNoFunctional()) {
|
|
5783
5777
|
return;
|
|
5784
5778
|
}
|
|
5785
5779
|
var key = mpInstance._Store.storageName,
|
|
@@ -5829,16 +5823,16 @@ var mParticle = (function () {
|
|
|
5829
5823
|
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
5830
5824
|
return null;
|
|
5831
5825
|
}
|
|
5832
|
-
var key = mpInstance._Store.storageName
|
|
5833
|
-
|
|
5834
|
-
|
|
5835
|
-
|
|
5836
|
-
|
|
5837
|
-
|
|
5838
|
-
|
|
5839
|
-
|
|
5840
|
-
|
|
5841
|
-
|
|
5826
|
+
var key = mpInstance._Store.storageName;
|
|
5827
|
+
var decodedPersistence = self.decodePersistence(window.localStorage.getItem(key));
|
|
5828
|
+
if (!decodedPersistence) {
|
|
5829
|
+
return null;
|
|
5830
|
+
}
|
|
5831
|
+
var parsedPersistence = JSON.parse(decodedPersistence);
|
|
5832
|
+
var obj = {};
|
|
5833
|
+
for (var key_1 in parsedPersistence) {
|
|
5834
|
+
if (parsedPersistence.hasOwnProperty(key_1)) {
|
|
5835
|
+
obj[key_1] = parsedPersistence[key_1];
|
|
5842
5836
|
}
|
|
5843
5837
|
}
|
|
5844
5838
|
if (Object.keys(obj).length) {
|
|
@@ -5846,9 +5840,6 @@ var mParticle = (function () {
|
|
|
5846
5840
|
}
|
|
5847
5841
|
return null;
|
|
5848
5842
|
};
|
|
5849
|
-
function removeLocalStorage(localStorageName) {
|
|
5850
|
-
localStorage.removeItem(localStorageName);
|
|
5851
|
-
}
|
|
5852
5843
|
this.expireCookies = function (cookieName) {
|
|
5853
5844
|
var date = new Date(),
|
|
5854
5845
|
expires,
|
|
@@ -5903,13 +5894,12 @@ var mParticle = (function () {
|
|
|
5903
5894
|
return null;
|
|
5904
5895
|
}
|
|
5905
5896
|
};
|
|
5906
|
-
|
|
5907
5897
|
// https://go.mparticle.com/work/SQDSDKS-5022
|
|
5908
5898
|
// https://go.mparticle.com/work/SQDSDKS-6021
|
|
5909
5899
|
this.setCookie = function () {
|
|
5910
|
-
var
|
|
5900
|
+
var _a;
|
|
5911
5901
|
// Block mprtcl-v4 cookies when noFunctional is true
|
|
5912
|
-
if ((
|
|
5902
|
+
if ((_a = mpInstance._CookieConsentManager) === null || _a === void 0 ? void 0 : _a.getNoFunctional()) {
|
|
5913
5903
|
return;
|
|
5914
5904
|
}
|
|
5915
5905
|
var mpid,
|
|
@@ -5920,7 +5910,7 @@ var mParticle = (function () {
|
|
|
5920
5910
|
var date = new Date(),
|
|
5921
5911
|
key = mpInstance._Store.storageName,
|
|
5922
5912
|
cookies = self.getCookie() || {},
|
|
5923
|
-
expires = new Date(date.getTime() + mpInstance._Store.SDKConfig.cookieExpiration * 24 * 60 * 60 * 1000).
|
|
5913
|
+
expires = new Date(date.getTime() + mpInstance._Store.SDKConfig.cookieExpiration * 24 * 60 * 60 * 1000).toUTCString(),
|
|
5924
5914
|
cookieDomain,
|
|
5925
5915
|
domain,
|
|
5926
5916
|
encodedCookiesWithExpirationAndPath;
|
|
@@ -5947,7 +5937,6 @@ var mParticle = (function () {
|
|
|
5947
5937
|
mpInstance.Logger.verbose(Messages$4.InformationMessages.CookieSet);
|
|
5948
5938
|
window.document.cookie = encodeURIComponent(key) + '=' + encodedCookiesWithExpirationAndPath;
|
|
5949
5939
|
};
|
|
5950
|
-
|
|
5951
5940
|
/* This function determines if a cookie is greater than the configured maxCookieSize.
|
|
5952
5941
|
- If it is, we remove an MPID and its associated UI/UA/CSD from the cookie.
|
|
5953
5942
|
- Once removed, check size, and repeat.
|
|
@@ -5959,171 +5948,258 @@ var mParticle = (function () {
|
|
|
5959
5948
|
b. Then remove MPIDs based on order in currentSessionMPIDs array, which
|
|
5960
5949
|
stores MPIDs based on earliest login.
|
|
5961
5950
|
*/
|
|
5962
|
-
|
|
5963
|
-
|
|
5964
|
-
|
|
5965
|
-
|
|
5966
|
-
|
|
5967
|
-
|
|
5968
|
-
|
|
5969
|
-
|
|
5970
|
-
if (encodedCookiesWithExpirationAndPath.length > maxCookieSize) {
|
|
5971
|
-
if (!SDKv2NonMPIDCookieKeys[key] && key !== persistence.cu) {
|
|
5972
|
-
delete persistence[key];
|
|
5973
|
-
}
|
|
5974
|
-
}
|
|
5975
|
-
}
|
|
5951
|
+
function isEncodedCookieTooLarge(encoded, maxCookieSize) {
|
|
5952
|
+
return encoded.length > maxCookieSize;
|
|
5953
|
+
}
|
|
5954
|
+
function removeUnsessionedMpidsWhenOversized(persistence, expires, domain, maxCookieSize) {
|
|
5955
|
+
var encodedCookiesWithExpirationAndPath;
|
|
5956
|
+
for (var key in persistence) {
|
|
5957
|
+
if (!persistence.hasOwnProperty(key)) {
|
|
5958
|
+
continue;
|
|
5976
5959
|
}
|
|
5977
|
-
|
|
5978
|
-
|
|
5979
|
-
|
|
5980
|
-
for (var potentialMPID in persistence) {
|
|
5981
|
-
if (persistence.hasOwnProperty(potentialMPID)) {
|
|
5982
|
-
if (!SDKv2NonMPIDCookieKeys[potentialMPID] && potentialMPID !== persistence.cu) {
|
|
5983
|
-
MPIDsOnCookie[potentialMPID] = 1;
|
|
5984
|
-
}
|
|
5985
|
-
}
|
|
5960
|
+
encodedCookiesWithExpirationAndPath = createFullEncodedCookie(persistence, expires, domain);
|
|
5961
|
+
if (!isEncodedCookieTooLarge(encodedCookiesWithExpirationAndPath, maxCookieSize)) {
|
|
5962
|
+
continue;
|
|
5986
5963
|
}
|
|
5987
|
-
|
|
5988
|
-
|
|
5989
|
-
for (var mpid in MPIDsOnCookie) {
|
|
5990
|
-
encodedCookiesWithExpirationAndPath = createFullEncodedCookie(persistence, expires, domain);
|
|
5991
|
-
if (encodedCookiesWithExpirationAndPath.length > maxCookieSize) {
|
|
5992
|
-
if (MPIDsOnCookie.hasOwnProperty(mpid)) {
|
|
5993
|
-
if (currentSessionMPIDs.indexOf(mpid) === -1) {
|
|
5994
|
-
delete persistence[mpid];
|
|
5995
|
-
}
|
|
5996
|
-
}
|
|
5997
|
-
}
|
|
5998
|
-
}
|
|
5964
|
+
if (SDKv2NonMPIDCookieKeys[key] || key === persistence.cu) {
|
|
5965
|
+
continue;
|
|
5999
5966
|
}
|
|
6000
|
-
|
|
6001
|
-
|
|
6002
|
-
|
|
6003
|
-
|
|
6004
|
-
|
|
6005
|
-
|
|
6006
|
-
|
|
6007
|
-
|
|
6008
|
-
|
|
6009
|
-
|
|
6010
|
-
|
|
6011
|
-
|
|
6012
|
-
|
|
6013
|
-
|
|
5967
|
+
delete persistence[key];
|
|
5968
|
+
}
|
|
5969
|
+
return encodedCookiesWithExpirationAndPath;
|
|
5970
|
+
}
|
|
5971
|
+
function collectRemovableMpids(persistence) {
|
|
5972
|
+
var MPIDsOnCookie = {};
|
|
5973
|
+
for (var potentialMPID in persistence) {
|
|
5974
|
+
if (!persistence.hasOwnProperty(potentialMPID)) {
|
|
5975
|
+
continue;
|
|
5976
|
+
}
|
|
5977
|
+
if (SDKv2NonMPIDCookieKeys[potentialMPID] || potentialMPID === persistence.cu) {
|
|
5978
|
+
continue;
|
|
5979
|
+
}
|
|
5980
|
+
MPIDsOnCookie[potentialMPID] = 1;
|
|
5981
|
+
}
|
|
5982
|
+
return MPIDsOnCookie;
|
|
5983
|
+
}
|
|
5984
|
+
function removeMpidsNotInCurrentSession(persistence, MPIDsOnCookie, currentSessionMPIDs, expires, domain, maxCookieSize) {
|
|
5985
|
+
var encodedCookiesWithExpirationAndPath;
|
|
5986
|
+
for (var mpid in MPIDsOnCookie) {
|
|
5987
|
+
encodedCookiesWithExpirationAndPath = createFullEncodedCookie(persistence, expires, domain);
|
|
5988
|
+
if (!isEncodedCookieTooLarge(encodedCookiesWithExpirationAndPath, maxCookieSize)) {
|
|
5989
|
+
continue;
|
|
5990
|
+
}
|
|
5991
|
+
if (!MPIDsOnCookie.hasOwnProperty(mpid)) {
|
|
5992
|
+
continue;
|
|
5993
|
+
}
|
|
5994
|
+
if (currentSessionMPIDs.indexOf(mpid) === -1) {
|
|
5995
|
+
delete persistence[mpid];
|
|
5996
|
+
}
|
|
5997
|
+
}
|
|
5998
|
+
return encodedCookiesWithExpirationAndPath;
|
|
5999
|
+
}
|
|
6000
|
+
function logAndRemoveOversizedMpid(persistence, MPIDtoRemove, maxCookieSize) {
|
|
6001
|
+
if (persistence[MPIDtoRemove]) {
|
|
6002
|
+
mpInstance.Logger.verbose('Size of new encoded cookie is larger than maxCookieSize setting of ' + maxCookieSize + '. Removing from cookie the earliest logged in MPID containing: ' + JSON.stringify(persistence[MPIDtoRemove], null, 2));
|
|
6003
|
+
delete persistence[MPIDtoRemove];
|
|
6004
|
+
return;
|
|
6005
|
+
}
|
|
6006
|
+
mpInstance.Logger.error('Unable to save MPID data to cookies because the resulting encoded cookie is larger than the maxCookieSize setting of ' + maxCookieSize + '. We recommend using a maxCookieSize of 1500.');
|
|
6007
|
+
}
|
|
6008
|
+
function removeCurrentSessionMpidsByAge(persistence, currentSessionMPIDs, expires, domain, maxCookieSize) {
|
|
6009
|
+
var encodedCookiesWithExpirationAndPath;
|
|
6010
|
+
for (var i = 0; i < currentSessionMPIDs.length; i++) {
|
|
6011
|
+
encodedCookiesWithExpirationAndPath = createFullEncodedCookie(persistence, expires, domain);
|
|
6012
|
+
if (!isEncodedCookieTooLarge(encodedCookiesWithExpirationAndPath, maxCookieSize)) {
|
|
6013
|
+
break;
|
|
6014
6014
|
}
|
|
6015
|
+
logAndRemoveOversizedMpid(persistence, currentSessionMPIDs[i], maxCookieSize);
|
|
6015
6016
|
}
|
|
6016
6017
|
return encodedCookiesWithExpirationAndPath;
|
|
6018
|
+
}
|
|
6019
|
+
this.reduceAndEncodePersistence = function (persistence, expires, domain, maxCookieSize) {
|
|
6020
|
+
var currentSessionMPIDs = persistence.gs.csm ? persistence.gs.csm : [];
|
|
6021
|
+
if (!currentSessionMPIDs.length) {
|
|
6022
|
+
return removeUnsessionedMpidsWhenOversized(persistence, expires, domain, maxCookieSize);
|
|
6023
|
+
}
|
|
6024
|
+
var MPIDsOnCookie = collectRemovableMpids(persistence);
|
|
6025
|
+
if (Object.keys(MPIDsOnCookie).length) {
|
|
6026
|
+
removeMpidsNotInCurrentSession(persistence, MPIDsOnCookie, currentSessionMPIDs, expires, domain, maxCookieSize);
|
|
6027
|
+
}
|
|
6028
|
+
return removeCurrentSessionMpidsByAge(persistence, currentSessionMPIDs, expires, domain, maxCookieSize);
|
|
6017
6029
|
};
|
|
6018
6030
|
function createFullEncodedCookie(persistence, expires, domain) {
|
|
6019
6031
|
return self.encodePersistence(JSON.stringify(persistence)) + ';expires=' + expires + ';path=/' + domain;
|
|
6020
6032
|
}
|
|
6021
|
-
|
|
6022
|
-
var
|
|
6033
|
+
function cookieUiMatchesRequestedIdentity(cookieUIs, requestedIdentityType, requestedValue) {
|
|
6034
|
+
for (var cookieUIType in cookieUIs) {
|
|
6035
|
+
if (requestedIdentityType === cookieUIType && requestedValue === cookieUIs[cookieUIType]) {
|
|
6036
|
+
return true;
|
|
6037
|
+
}
|
|
6038
|
+
}
|
|
6039
|
+
return false;
|
|
6040
|
+
}
|
|
6041
|
+
function findMpidForRequestedIdentity(persistence, requestedIdentityType, requestedValue) {
|
|
6023
6042
|
var matchedUser;
|
|
6024
|
-
|
|
6025
|
-
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6029
|
-
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6038
|
-
|
|
6039
|
-
|
|
6040
|
-
|
|
6043
|
+
for (var key in persistence) {
|
|
6044
|
+
// any value in persistence that has an MPID key will be an MPID to search through
|
|
6045
|
+
// other keys on the cookie are currentSessionMPIDs and currentMPID which should not be searched
|
|
6046
|
+
if (!persistence[key].mpid) {
|
|
6047
|
+
continue;
|
|
6048
|
+
}
|
|
6049
|
+
if (cookieUiMatchesRequestedIdentity(persistence[key].ui, requestedIdentityType, requestedValue)) {
|
|
6050
|
+
matchedUser = key;
|
|
6051
|
+
}
|
|
6052
|
+
}
|
|
6053
|
+
return matchedUser;
|
|
6054
|
+
}
|
|
6055
|
+
function findMpidMatchingIdentities(persistence, identityApiData) {
|
|
6056
|
+
var matchedUser;
|
|
6057
|
+
for (var requestedIdentityType in identityApiData.userIdentities) {
|
|
6058
|
+
if (!persistence || !Object.keys(persistence).length) {
|
|
6059
|
+
continue;
|
|
6060
|
+
}
|
|
6061
|
+
var match = findMpidForRequestedIdentity(persistence, requestedIdentityType, identityApiData.userIdentities[requestedIdentityType]);
|
|
6062
|
+
if (match) {
|
|
6063
|
+
matchedUser = match;
|
|
6041
6064
|
}
|
|
6042
6065
|
}
|
|
6066
|
+
return matchedUser;
|
|
6067
|
+
}
|
|
6068
|
+
this.findPrevCookiesBasedOnUI = function (identityApiData) {
|
|
6069
|
+
var persistence = mpInstance._Persistence.getPersistence();
|
|
6070
|
+
if (!identityApiData) {
|
|
6071
|
+
return;
|
|
6072
|
+
}
|
|
6073
|
+
var matchedUser = findMpidMatchingIdentities(persistence, identityApiData);
|
|
6043
6074
|
if (matchedUser) {
|
|
6044
6075
|
self.storeDataInMemory(persistence, matchedUser);
|
|
6045
6076
|
}
|
|
6046
6077
|
};
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6059
|
-
|
|
6060
|
-
|
|
6061
|
-
|
|
6062
|
-
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6078
|
+
function isNonEmptyArrayOrObject(value) {
|
|
6079
|
+
if (Array.isArray(value)) {
|
|
6080
|
+
return value.length > 0;
|
|
6081
|
+
}
|
|
6082
|
+
if (!mpInstance._Helpers.isObject(value)) {
|
|
6083
|
+
return false;
|
|
6084
|
+
}
|
|
6085
|
+
return Object.keys(value).length > 0;
|
|
6086
|
+
}
|
|
6087
|
+
function encodeGsBase64Field(gs, key) {
|
|
6088
|
+
if (!gs[key] || !isNonEmptyArrayOrObject(gs[key])) {
|
|
6089
|
+
delete gs[key];
|
|
6090
|
+
return;
|
|
6091
|
+
}
|
|
6092
|
+
gs[key] = Base64.encode(JSON.stringify(gs[key]));
|
|
6093
|
+
}
|
|
6094
|
+
function encodeGlobalSettings(gs) {
|
|
6095
|
+
for (var key in gs) {
|
|
6096
|
+
if (!gs.hasOwnProperty(key)) {
|
|
6097
|
+
continue;
|
|
6098
|
+
}
|
|
6099
|
+
if (Base64CookieKeys[key]) {
|
|
6100
|
+
encodeGsBase64Field(gs, key);
|
|
6101
|
+
continue;
|
|
6102
|
+
}
|
|
6103
|
+
if (key === 'ie') {
|
|
6104
|
+
gs[key] = gs[key] ? 1 : 0;
|
|
6105
|
+
continue;
|
|
6106
|
+
}
|
|
6107
|
+
if (!gs[key]) {
|
|
6108
|
+
delete gs[key];
|
|
6109
|
+
}
|
|
6110
|
+
}
|
|
6111
|
+
}
|
|
6112
|
+
function encodeMpidBase64Field(container, key) {
|
|
6113
|
+
var value = container[key];
|
|
6114
|
+
if (mpInstance._Helpers.isObject(value) && Object.keys(value).length) {
|
|
6115
|
+
container[key] = Base64.encode(JSON.stringify(value));
|
|
6116
|
+
return;
|
|
6117
|
+
}
|
|
6118
|
+
delete container[key];
|
|
6119
|
+
}
|
|
6120
|
+
function encodeMpidRecord(record) {
|
|
6121
|
+
for (var key in record) {
|
|
6122
|
+
if (!record.hasOwnProperty(key)) {
|
|
6123
|
+
continue;
|
|
6124
|
+
}
|
|
6125
|
+
if (Base64CookieKeys[key]) {
|
|
6126
|
+
encodeMpidBase64Field(record, key);
|
|
6067
6127
|
}
|
|
6068
6128
|
}
|
|
6129
|
+
}
|
|
6130
|
+
function encodeMpidRecords(persistence) {
|
|
6069
6131
|
for (var mpid in persistence) {
|
|
6070
|
-
if (persistence.hasOwnProperty(mpid)) {
|
|
6071
|
-
|
|
6072
|
-
|
|
6073
|
-
|
|
6074
|
-
|
|
6075
|
-
if (mpInstance._Helpers.isObject(persistence[mpid][key]) && Object.keys(persistence[mpid][key]).length) {
|
|
6076
|
-
persistence[mpid][key] = Base64.encode(JSON.stringify(persistence[mpid][key]));
|
|
6077
|
-
} else {
|
|
6078
|
-
delete persistence[mpid][key];
|
|
6079
|
-
}
|
|
6080
|
-
}
|
|
6081
|
-
}
|
|
6082
|
-
}
|
|
6083
|
-
}
|
|
6132
|
+
if (!persistence.hasOwnProperty(mpid)) {
|
|
6133
|
+
continue;
|
|
6134
|
+
}
|
|
6135
|
+
if (SDKv2NonMPIDCookieKeys[mpid]) {
|
|
6136
|
+
continue;
|
|
6084
6137
|
}
|
|
6138
|
+
encodeMpidRecord(persistence[mpid]);
|
|
6085
6139
|
}
|
|
6140
|
+
}
|
|
6141
|
+
this.encodePersistence = function (persistenceString) {
|
|
6142
|
+
var persistence = JSON.parse(persistenceString);
|
|
6143
|
+
encodeGlobalSettings(persistence.gs);
|
|
6144
|
+
encodeMpidRecords(persistence);
|
|
6086
6145
|
return createCookieString(JSON.stringify(persistence));
|
|
6087
6146
|
};
|
|
6088
|
-
|
|
6147
|
+
function decodeGlobalSettings(gs) {
|
|
6148
|
+
for (var key in gs) {
|
|
6149
|
+
if (!gs.hasOwnProperty(key)) {
|
|
6150
|
+
continue;
|
|
6151
|
+
}
|
|
6152
|
+
if (Base64CookieKeys[key]) {
|
|
6153
|
+
gs[key] = JSON.parse(Base64.decode(gs[key]));
|
|
6154
|
+
continue;
|
|
6155
|
+
}
|
|
6156
|
+
if (key === 'ie') {
|
|
6157
|
+
gs[key] = Boolean(gs[key]);
|
|
6158
|
+
}
|
|
6159
|
+
}
|
|
6160
|
+
}
|
|
6161
|
+
function decodeMpidRecord(record) {
|
|
6162
|
+
for (var key in record) {
|
|
6163
|
+
if (!record.hasOwnProperty(key)) {
|
|
6164
|
+
continue;
|
|
6165
|
+
}
|
|
6166
|
+
if (!Base64CookieKeys[key]) {
|
|
6167
|
+
continue;
|
|
6168
|
+
}
|
|
6169
|
+
if (record[key].length) {
|
|
6170
|
+
record[key] = JSON.parse(Base64.decode(record[key]));
|
|
6171
|
+
}
|
|
6172
|
+
}
|
|
6173
|
+
}
|
|
6174
|
+
function decodeMpidRecords(persistence) {
|
|
6175
|
+
for (var mpid in persistence) {
|
|
6176
|
+
if (!persistence.hasOwnProperty(mpid)) {
|
|
6177
|
+
continue;
|
|
6178
|
+
}
|
|
6179
|
+
if (!SDKv2NonMPIDCookieKeys[mpid]) {
|
|
6180
|
+
decodeMpidRecord(persistence[mpid]);
|
|
6181
|
+
continue;
|
|
6182
|
+
}
|
|
6183
|
+
if (mpid === 'l') {
|
|
6184
|
+
persistence[mpid] = Boolean(persistence[mpid]);
|
|
6185
|
+
}
|
|
6186
|
+
}
|
|
6187
|
+
}
|
|
6089
6188
|
// TODO: This should actually be decodePersistenceString or
|
|
6090
6189
|
// we should refactor this to take a string and return an object
|
|
6091
|
-
this.decodePersistence = function (
|
|
6190
|
+
this.decodePersistence = function (persistenceString) {
|
|
6092
6191
|
try {
|
|
6093
|
-
if (
|
|
6094
|
-
|
|
6095
|
-
if (mpInstance._Helpers.isObject(persistence) && Object.keys(persistence).length) {
|
|
6096
|
-
for (var key in persistence.gs) {
|
|
6097
|
-
if (persistence.gs.hasOwnProperty(key)) {
|
|
6098
|
-
if (Base64CookieKeys[key]) {
|
|
6099
|
-
persistence.gs[key] = JSON.parse(Base64.decode(persistence.gs[key]));
|
|
6100
|
-
} else if (key === 'ie') {
|
|
6101
|
-
persistence.gs[key] = Boolean(persistence.gs[key]);
|
|
6102
|
-
}
|
|
6103
|
-
}
|
|
6104
|
-
}
|
|
6105
|
-
for (var mpid in persistence) {
|
|
6106
|
-
if (persistence.hasOwnProperty(mpid)) {
|
|
6107
|
-
if (!SDKv2NonMPIDCookieKeys[mpid]) {
|
|
6108
|
-
for (key in persistence[mpid]) {
|
|
6109
|
-
if (persistence[mpid].hasOwnProperty(key)) {
|
|
6110
|
-
if (Base64CookieKeys[key]) {
|
|
6111
|
-
if (persistence[mpid][key].length) {
|
|
6112
|
-
persistence[mpid][key] = JSON.parse(Base64.decode(persistence[mpid][key]));
|
|
6113
|
-
}
|
|
6114
|
-
}
|
|
6115
|
-
}
|
|
6116
|
-
}
|
|
6117
|
-
} else if (mpid === 'l') {
|
|
6118
|
-
persistence[mpid] = Boolean(persistence[mpid]);
|
|
6119
|
-
}
|
|
6120
|
-
}
|
|
6121
|
-
}
|
|
6122
|
-
}
|
|
6123
|
-
return JSON.stringify(persistence);
|
|
6192
|
+
if (!persistenceString) {
|
|
6193
|
+
return;
|
|
6124
6194
|
}
|
|
6195
|
+
var persistence = JSON.parse(revertCookieString(persistenceString));
|
|
6196
|
+
if (mpInstance._Helpers.isObject(persistence) && Object.keys(persistence).length) {
|
|
6197
|
+
decodeGlobalSettings(persistence.gs);
|
|
6198
|
+
decodeMpidRecords(persistence);
|
|
6199
|
+
}
|
|
6200
|
+
return JSON.stringify(persistence);
|
|
6125
6201
|
} catch (e) {
|
|
6126
|
-
mpInstance.Logger.error('Problem with decoding cookie'
|
|
6202
|
+
mpInstance.Logger.error('Problem with decoding cookie');
|
|
6127
6203
|
}
|
|
6128
6204
|
};
|
|
6129
6205
|
this.getCookieDomain = function () {
|
|
@@ -6138,7 +6214,6 @@ var mParticle = (function () {
|
|
|
6138
6214
|
}
|
|
6139
6215
|
}
|
|
6140
6216
|
};
|
|
6141
|
-
|
|
6142
6217
|
// This function loops through the parts of a full hostname, attempting to set a cookie on that domain. It will set a cookie at the highest level possible.
|
|
6143
6218
|
// For example subdomain.domain.co.uk would try the following combinations:
|
|
6144
6219
|
// "co.uk" -> fail
|
|
@@ -6184,18 +6259,17 @@ var mParticle = (function () {
|
|
|
6184
6259
|
}
|
|
6185
6260
|
}
|
|
6186
6261
|
};
|
|
6187
|
-
|
|
6188
6262
|
// https://go.mparticle.com/work/SQDSDKS-6021
|
|
6189
6263
|
this.savePersistence = function (persistence) {
|
|
6190
|
-
var
|
|
6264
|
+
var _a;
|
|
6191
6265
|
// Block mprtcl-v4 persistence when noFunctional is true
|
|
6192
|
-
if ((
|
|
6266
|
+
if ((_a = mpInstance._CookieConsentManager) === null || _a === void 0 ? void 0 : _a.getNoFunctional()) {
|
|
6193
6267
|
return;
|
|
6194
6268
|
}
|
|
6195
6269
|
var encodedPersistence = self.encodePersistence(JSON.stringify(persistence)),
|
|
6196
6270
|
date = new Date(),
|
|
6197
6271
|
key = mpInstance._Store.storageName,
|
|
6198
|
-
expires = new Date(date.getTime() + mpInstance._Store.SDKConfig.cookieExpiration * 24 * 60 * 60 * 1000).
|
|
6272
|
+
expires = new Date(date.getTime() + mpInstance._Store.SDKConfig.cookieExpiration * 24 * 60 * 60 * 1000).toUTCString(),
|
|
6199
6273
|
cookieDomain = self.getCookieDomain(),
|
|
6200
6274
|
domain;
|
|
6201
6275
|
if (cookieDomain === '') {
|
|
@@ -6231,7 +6305,6 @@ var mParticle = (function () {
|
|
|
6231
6305
|
return null;
|
|
6232
6306
|
}
|
|
6233
6307
|
};
|
|
6234
|
-
|
|
6235
6308
|
/**
|
|
6236
6309
|
* set the "first seen" time for a user. the time will only be set once for a given
|
|
6237
6310
|
* mpid after which subsequent calls will be ignored
|
|
@@ -6255,7 +6328,6 @@ var mParticle = (function () {
|
|
|
6255
6328
|
}
|
|
6256
6329
|
}
|
|
6257
6330
|
};
|
|
6258
|
-
|
|
6259
6331
|
/**
|
|
6260
6332
|
* returns the "last seen" time for a user. If the mpid represents the current user, the
|
|
6261
6333
|
* return value will always be the current time, otherwise it will be to stored "last seen"
|
|
@@ -6304,13 +6376,13 @@ var mParticle = (function () {
|
|
|
6304
6376
|
self.expireCookies(StorageNames.cookieNameV3);
|
|
6305
6377
|
self.expireCookies(StorageNames.cookieNameV4);
|
|
6306
6378
|
self.expireCookies(mpInstance._Store.storageName);
|
|
6307
|
-
|
|
6379
|
+
var mParticleManager = getMParticleManager();
|
|
6380
|
+
if (mParticleManager === null || mParticleManager === void 0 ? void 0 : mParticleManager._isTestEnv) {
|
|
6308
6381
|
var testWorkspaceToken = 'abcdef';
|
|
6309
|
-
|
|
6382
|
+
localStorage.removeItem(mpInstance._Helpers.createMainStorageName(testWorkspaceToken));
|
|
6310
6383
|
self.expireCookies(mpInstance._Helpers.createMainStorageName(testWorkspaceToken));
|
|
6311
6384
|
}
|
|
6312
6385
|
};
|
|
6313
|
-
|
|
6314
6386
|
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
6315
6387
|
// Forwarder Batching Code
|
|
6316
6388
|
this.forwardingStatsBatches = {
|
|
@@ -6319,117 +6391,540 @@ var mParticle = (function () {
|
|
|
6319
6391
|
};
|
|
6320
6392
|
}
|
|
6321
6393
|
|
|
6322
|
-
var
|
|
6323
|
-
|
|
6324
|
-
|
|
6325
|
-
|
|
6326
|
-
|
|
6327
|
-
|
|
6328
|
-
|
|
6329
|
-
|
|
6330
|
-
|
|
6331
|
-
|
|
6332
|
-
|
|
6333
|
-
|
|
6334
|
-
|
|
6335
|
-
|
|
6336
|
-
|
|
6337
|
-
|
|
6338
|
-
|
|
6339
|
-
|
|
6340
|
-
|
|
6341
|
-
|
|
6342
|
-
|
|
6343
|
-
|
|
6344
|
-
|
|
6345
|
-
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6349
|
-
|
|
6350
|
-
|
|
6351
|
-
|
|
6352
|
-
|
|
6353
|
-
|
|
6354
|
-
|
|
6355
|
-
|
|
6356
|
-
|
|
6357
|
-
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
|
|
6361
|
-
|
|
6362
|
-
|
|
6363
|
-
|
|
6364
|
-
|
|
6365
|
-
|
|
6366
|
-
|
|
6367
|
-
|
|
6368
|
-
|
|
6369
|
-
|
|
6370
|
-
|
|
6371
|
-
|
|
6372
|
-
|
|
6373
|
-
|
|
6374
|
-
|
|
6375
|
-
|
|
6376
|
-
|
|
6377
|
-
|
|
6394
|
+
var HISTORY_METHODS = ['pushState', 'replaceState'];
|
|
6395
|
+
var WRAPPED_MARKER = '__mpApvWrapped__';
|
|
6396
|
+
// All APV state hangs off one window key, and it is the public debugging
|
|
6397
|
+
// contract: `window.__mpApv__` is what you inspect in a console to see whether
|
|
6398
|
+
// tracking is live.
|
|
6399
|
+
//
|
|
6400
|
+
// It lives on `window` rather than in module scope because Next.js re-executes
|
|
6401
|
+
// the SDK bundle on every SPA navigation: module-level state is reset each time,
|
|
6402
|
+
// but `window` persists for the lifetime of the tab.
|
|
6403
|
+
//
|
|
6404
|
+
// One object rather than a key per flag, so resetting is a single reassignment.
|
|
6405
|
+
// Nothing has to be deleted, and there is no ordering in which half the state
|
|
6406
|
+
// survives the reset.
|
|
6407
|
+
var WIN_APV_KEY = '__mpApv__';
|
|
6408
|
+
// The query params an auto page view may carry. An allowlist, not a denylist:
|
|
6409
|
+
// partner URLs routinely hold order ids, email addresses and session tokens, and
|
|
6410
|
+
// none of those should reach the event stream because someone forgot to exclude
|
|
6411
|
+
// them. Anything absent from this list is dropped.
|
|
6412
|
+
//
|
|
6413
|
+
// SECURITY: `code`, `state` and `nonce` are the OAuth 2.0 / OIDC authorization
|
|
6414
|
+
// code and the CSRF/replay tokens. They are credentials until redeemed, and
|
|
6415
|
+
// attaching them here persists them in the event store and forwards them to
|
|
6416
|
+
// every configured kit. They are on the list by explicit product decision —
|
|
6417
|
+
// deleting that line is the whole of the fix if that decision is revisited.
|
|
6418
|
+
var ALLOWED_QUERY_PARAMS = [
|
|
6419
|
+
// Campaign attribution
|
|
6420
|
+
'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'utm_id',
|
|
6421
|
+
// Ad-network click ids
|
|
6422
|
+
'gclid', 'gbraid', 'wbraid', 'fbclid', 'msclkid', 'ttclid', 'twclid', 'li_fat_id', 'dclid',
|
|
6423
|
+
// OAuth / OIDC — see the SECURITY note above
|
|
6424
|
+
'client_id', 'redirect_uri', 'response_type', 'scope', 'state', 'code', 'nonce',
|
|
6425
|
+
// Pagination and search
|
|
6426
|
+
'page', 'limit', 'offset', 'cursor', 'per_page', 'q', 'search',
|
|
6427
|
+
// Referral
|
|
6428
|
+
'ref', 'referrer'];
|
|
6429
|
+
// ---------------------------------------------------------------------------
|
|
6430
|
+
// Pure helpers. No `this`, no globals, no side effects — callable and assertable
|
|
6431
|
+
// on their own, which is where the interesting rules live.
|
|
6432
|
+
// ---------------------------------------------------------------------------
|
|
6433
|
+
// Pulls the allowlisted query params off a URL. Delegates to the SDK's own
|
|
6434
|
+
// parser, which lowercases keys (so `?UTM_Source=` and `?utm_source=` land on one
|
|
6435
|
+
// attribute), drops empty values, and carries the fallback for browsers without
|
|
6436
|
+
// URLSearchParams. Tolerates an empty href, so SSR yields no params rather than
|
|
6437
|
+
// throwing.
|
|
6438
|
+
var allowedQueryParams = function allowedQueryParams(href) {
|
|
6439
|
+
return queryStringParser(href, ALLOWED_QUERY_PARAMS);
|
|
6440
|
+
};
|
|
6441
|
+
// The captured params, in allowlist order. Ordering comes from the constant
|
|
6442
|
+
// rather than a sort: it is deterministic without needing a comparator, and it
|
|
6443
|
+
// does not depend on the object's insertion order, so reordering the query string
|
|
6444
|
+
// cannot produce a different key.
|
|
6445
|
+
var capturedNames = function capturedNames(params) {
|
|
6446
|
+
return ALLOWED_QUERY_PARAMS.filter(function (name) {
|
|
6447
|
+
return name in params;
|
|
6448
|
+
});
|
|
6449
|
+
};
|
|
6450
|
+
// The dedup key: pathname plus the allowlisted params in a fixed order, so that
|
|
6451
|
+
// reordering the query string is not a new page. Params outside the allowlist
|
|
6452
|
+
// never make it into `page.params` and so cannot key a view — nor can the hash.
|
|
6453
|
+
//
|
|
6454
|
+
// Values are re-encoded because queryStringParser hands them back DECODED. A
|
|
6455
|
+
// value holding the pair delimiters would otherwise serialize exactly like two
|
|
6456
|
+
// separate params — `{q: 'a&search=b'}` and `{q: 'a', search: 'b'}` both becoming
|
|
6457
|
+
// `q=a&search=b` — and dedup would treat a real navigation between them as the
|
|
6458
|
+
// same page and drop the view. `q`, `search` and `redirect_uri` carry `&` and `=`
|
|
6459
|
+
// routinely, so this is reachable rather than theoretical.
|
|
6460
|
+
var pageKey = function pageKey(page) {
|
|
6461
|
+
var query = capturedNames(page.params).map(function (name) {
|
|
6462
|
+
return "".concat(name, "=").concat(encodeURIComponent(page.params[name]));
|
|
6463
|
+
}).join('&');
|
|
6464
|
+
return query ? "".concat(page.path, "?").concat(query) : page.path;
|
|
6465
|
+
};
|
|
6466
|
+
// Dedup keys on the pageKey above: a change to any captured param is a new page
|
|
6467
|
+
// (`?page=2` is a distinct pagination view), while a hash-only change, or a
|
|
6468
|
+
// change confined to params we do not capture, is the same page.
|
|
6469
|
+
var isNewPage = function isNewPage(lastKey, candidateKey) {
|
|
6470
|
+
return candidateKey !== lastKey;
|
|
6471
|
+
};
|
|
6472
|
+
var supportsHistoryTracking = function supportsHistoryTracking(win) {
|
|
6473
|
+
return !!win && win.history !== undefined && typeof win.history.pushState === 'function' && typeof win.addEventListener === 'function';
|
|
6474
|
+
};
|
|
6475
|
+
// Mirrors the event shape of the public mParticle.logPageView(), but carries the
|
|
6476
|
+
// path and query params captured when the navigation was accepted rather than the
|
|
6477
|
+
// live location.
|
|
6478
|
+
var buildPageViewEvent = function buildPageViewEvent(_a) {
|
|
6479
|
+
var params = _a.params,
|
|
6480
|
+
hostname = _a.hostname,
|
|
6481
|
+
title = _a.title,
|
|
6482
|
+
path = _a.path;
|
|
6483
|
+
return {
|
|
6484
|
+
messageType: MessageType$1.PageView,
|
|
6485
|
+
name: 'PageView',
|
|
6486
|
+
// Params spread first, then the core fields by name, so a core field always
|
|
6487
|
+
// wins. No allowlist entry collides with hostname/title/path today; naming
|
|
6488
|
+
// them here is what keeps a later addition from silently overwriting one.
|
|
6489
|
+
data: __assign(__assign({}, params), {
|
|
6490
|
+
hostname: hostname,
|
|
6491
|
+
title: title,
|
|
6492
|
+
path: path
|
|
6493
|
+
}),
|
|
6494
|
+
eventType: EventType.Unknown
|
|
6378
6495
|
};
|
|
6379
|
-
|
|
6380
|
-
|
|
6381
|
-
|
|
6382
|
-
|
|
6383
|
-
|
|
6384
|
-
|
|
6496
|
+
};
|
|
6497
|
+
// ---------------------------------------------------------------------------
|
|
6498
|
+
// Window-scoped APV state. Every read and write goes through these helpers, so
|
|
6499
|
+
// neither the tracker nor mp-instance touches `window` directly and
|
|
6500
|
+
// `typeof window` is checked in exactly one place.
|
|
6501
|
+
// ---------------------------------------------------------------------------
|
|
6502
|
+
var apvWindow = function apvWindow() {
|
|
6503
|
+
return typeof window === 'undefined' ? null : window;
|
|
6504
|
+
};
|
|
6505
|
+
var freshState = function freshState() {
|
|
6506
|
+
return {
|
|
6507
|
+
initialPageViewFired: false
|
|
6385
6508
|
};
|
|
6386
|
-
|
|
6387
|
-
|
|
6388
|
-
|
|
6389
|
-
|
|
6390
|
-
|
|
6391
|
-
|
|
6392
|
-
|
|
6509
|
+
};
|
|
6510
|
+
// Reads tolerate absent state, so a read never mutates `window`. Only the
|
|
6511
|
+
// writers below create it.
|
|
6512
|
+
var readState = function readState() {
|
|
6513
|
+
var win = apvWindow();
|
|
6514
|
+
return win ? win[WIN_APV_KEY] : undefined;
|
|
6515
|
+
};
|
|
6516
|
+
var writeState = function writeState() {
|
|
6517
|
+
var win = apvWindow();
|
|
6518
|
+
if (!win) {
|
|
6519
|
+
return null;
|
|
6520
|
+
}
|
|
6521
|
+
if (!win[WIN_APV_KEY]) {
|
|
6522
|
+
win[WIN_APV_KEY] = freshState();
|
|
6523
|
+
}
|
|
6524
|
+
return win[WIN_APV_KEY];
|
|
6525
|
+
};
|
|
6526
|
+
var getActiveTracker = function getActiveTracker() {
|
|
6527
|
+
var state = readState();
|
|
6528
|
+
return state ? state.tracker : undefined;
|
|
6529
|
+
};
|
|
6530
|
+
var hasInitialPageViewFired = function hasInitialPageViewFired() {
|
|
6531
|
+
var state = readState();
|
|
6532
|
+
return !!(state && state.initialPageViewFired);
|
|
6533
|
+
};
|
|
6534
|
+
var markInitialPageViewFired = function markInitialPageViewFired() {
|
|
6535
|
+
var state = writeState();
|
|
6536
|
+
if (state) {
|
|
6537
|
+
state.initialPageViewFired = true;
|
|
6538
|
+
}
|
|
6539
|
+
};
|
|
6540
|
+
// Returns the page to its pre-APV state: stops the active tracker (restoring the
|
|
6541
|
+
// history methods it patched), then swaps in fresh state. The state object is the
|
|
6542
|
+
// authoritative handle, so this reaches trackers whose owning module is gone.
|
|
6543
|
+
var resetPageViewTracking = function resetPageViewTracking() {
|
|
6544
|
+
var win = apvWindow();
|
|
6545
|
+
if (!win) {
|
|
6546
|
+
return;
|
|
6547
|
+
}
|
|
6548
|
+
var active = getActiveTracker();
|
|
6549
|
+
if (active) {
|
|
6550
|
+
active.teardown();
|
|
6551
|
+
}
|
|
6552
|
+
// One reassignment replaces every flag at once, so nothing can be left behind
|
|
6553
|
+
// whatever shape the previous state was in.
|
|
6554
|
+
win[WIN_APV_KEY] = freshState();
|
|
6555
|
+
};
|
|
6556
|
+
var setActiveTracker = function setActiveTracker(tracker) {
|
|
6557
|
+
var state = writeState();
|
|
6558
|
+
if (state) {
|
|
6559
|
+
state.tracker = tracker;
|
|
6560
|
+
}
|
|
6561
|
+
};
|
|
6562
|
+
var clearActiveTracker = function clearActiveTracker(tracker) {
|
|
6563
|
+
var state = readState();
|
|
6564
|
+
if (state && state.tracker === tracker) {
|
|
6565
|
+
state.tracker = undefined;
|
|
6566
|
+
}
|
|
6567
|
+
};
|
|
6568
|
+
var currentPage = function currentPage() {
|
|
6569
|
+
return {
|
|
6570
|
+
path: window.location.pathname,
|
|
6571
|
+
params: allowedQueryParams(getHref())
|
|
6393
6572
|
};
|
|
6394
|
-
|
|
6395
|
-
|
|
6396
|
-
|
|
6573
|
+
};
|
|
6574
|
+
// Log-safe description of a page: the path, plus the NAMES of the captured
|
|
6575
|
+
// params. Values are deliberately omitted — verbose logging goes to the console,
|
|
6576
|
+
// and session-replay tooling ships console output off-domain, which is not a
|
|
6577
|
+
// place for an OAuth code or a consumer's search terms.
|
|
6578
|
+
// Only reachable before init() assigns lastPage, which is ahead of any navigation
|
|
6579
|
+
// handler being able to run, so this returns nothing rather than a sentinel.
|
|
6580
|
+
var describePage = function describePage(page) {
|
|
6581
|
+
if (!page) {
|
|
6582
|
+
return '';
|
|
6583
|
+
}
|
|
6584
|
+
var names = capturedNames(page.params);
|
|
6585
|
+
return names.length ? "".concat(page.path, " (params: ").concat(names.join(), ")") : page.path;
|
|
6586
|
+
};
|
|
6587
|
+
// ---------------------------------------------------------------------------
|
|
6588
|
+
// History patching
|
|
6589
|
+
// ---------------------------------------------------------------------------
|
|
6590
|
+
// Wraps pushState/replaceState so `onNavigate` runs after the real method, and
|
|
6591
|
+
// returns the single function that undoes it — or null when nothing was
|
|
6592
|
+
// installed (history is already wrapped, or a frozen/sealed History rejected the
|
|
6593
|
+
// assignment). Handing back one undo closure keeps the wrapper and original
|
|
6594
|
+
// references out of the tracker entirely: there is no half-patched state for a
|
|
6595
|
+
// caller to inspect, and no way to restore the wrong pair.
|
|
6596
|
+
var patchHistory = function patchHistory(onNavigate, log) {
|
|
6597
|
+
if (window.history.pushState[WRAPPED_MARKER]) {
|
|
6598
|
+
log('[patch] history already wrapped, skipping to avoid double-wrap — STACKED WRAPPER DETECTED');
|
|
6599
|
+
return null;
|
|
6600
|
+
}
|
|
6601
|
+
var originals = {};
|
|
6602
|
+
var wrappers = {};
|
|
6603
|
+
HISTORY_METHODS.forEach(function (name) {
|
|
6604
|
+
var original = window.history[name];
|
|
6605
|
+
originals[name] = original;
|
|
6606
|
+
var wrapper = function wrapper() {
|
|
6607
|
+
var args = [];
|
|
6608
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6609
|
+
args[_i] = arguments[_i];
|
|
6610
|
+
}
|
|
6611
|
+
var result = original.apply(this, args);
|
|
6612
|
+
onNavigate(name);
|
|
6613
|
+
return result;
|
|
6614
|
+
};
|
|
6615
|
+
Object.defineProperty(wrapper, WRAPPED_MARKER, {
|
|
6616
|
+
value: true,
|
|
6617
|
+
enumerable: false
|
|
6397
6618
|
});
|
|
6398
|
-
|
|
6399
|
-
|
|
6400
|
-
|
|
6401
|
-
|
|
6402
|
-
|
|
6403
|
-
|
|
6404
|
-
|
|
6405
|
-
|
|
6406
|
-
|
|
6407
|
-
|
|
6619
|
+
wrappers[name] = wrapper;
|
|
6620
|
+
});
|
|
6621
|
+
// Restore per method: a third party may have patched one of the two on top of
|
|
6622
|
+
// ours after we installed. Clobbering theirs would break their tracking, so
|
|
6623
|
+
// leave anything that is no longer ours in place.
|
|
6624
|
+
var restore = function restore() {
|
|
6625
|
+
return HISTORY_METHODS.forEach(function (name) {
|
|
6626
|
+
if (window.history[name] === wrappers[name]) {
|
|
6627
|
+
window.history[name] = originals[name];
|
|
6628
|
+
log("[teardown] restored original ".concat(name));
|
|
6629
|
+
} else {
|
|
6630
|
+
log("[teardown] ".concat(name, " no longer ours; leaving in place, gating callback to no-op"));
|
|
6631
|
+
}
|
|
6408
6632
|
});
|
|
6409
6633
|
};
|
|
6410
|
-
|
|
6411
|
-
|
|
6412
|
-
|
|
6413
|
-
|
|
6414
|
-
|
|
6415
|
-
|
|
6416
|
-
|
|
6417
|
-
|
|
6418
|
-
|
|
6419
|
-
|
|
6420
|
-
};
|
|
6421
|
-
self.logCommerceEvent(event, attrs);
|
|
6634
|
+
try {
|
|
6635
|
+
HISTORY_METHODS.forEach(function (name) {
|
|
6636
|
+
window.history[name] = wrappers[name];
|
|
6637
|
+
});
|
|
6638
|
+
} catch (e) {
|
|
6639
|
+
log("[error] failed to patch history methods (frozen/sealed), rolling back: ".concat(e));
|
|
6640
|
+
try {
|
|
6641
|
+
restore();
|
|
6642
|
+
} catch (restoreError) {
|
|
6643
|
+
log("[error] failed to restore history methods after patch failure: ".concat(restoreError));
|
|
6422
6644
|
}
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
|
|
6426
|
-
|
|
6427
|
-
|
|
6428
|
-
|
|
6429
|
-
|
|
6430
|
-
|
|
6431
|
-
|
|
6432
|
-
|
|
6645
|
+
return null;
|
|
6646
|
+
}
|
|
6647
|
+
return restore;
|
|
6648
|
+
};
|
|
6649
|
+
// ---------------------------------------------------------------------------
|
|
6650
|
+
// Tracker
|
|
6651
|
+
// ---------------------------------------------------------------------------
|
|
6652
|
+
var PageViewTracker = /** @class */function () {
|
|
6653
|
+
function PageViewTracker(mpInstance) {
|
|
6654
|
+
this.lastPage = null;
|
|
6655
|
+
this.active = false;
|
|
6656
|
+
this.pendingNavigations = [];
|
|
6657
|
+
this.undoHistoryPatch = null;
|
|
6658
|
+
this.popStateListener = null;
|
|
6659
|
+
this.mpInstance = mpInstance;
|
|
6660
|
+
}
|
|
6661
|
+
Object.defineProperty(PageViewTracker.prototype, "isActive", {
|
|
6662
|
+
// True while this tracker owns the history patch and is listening for
|
|
6663
|
+
// navigations. Flips to false on teardown, including the teardown a
|
|
6664
|
+
// successor tracker performs during a handoff. Read-only, and the one thing
|
|
6665
|
+
// worth checking on `window.__mpApv__.tracker` from a console.
|
|
6666
|
+
get: function get() {
|
|
6667
|
+
return this.active;
|
|
6668
|
+
},
|
|
6669
|
+
enumerable: false,
|
|
6670
|
+
configurable: true
|
|
6671
|
+
});
|
|
6672
|
+
PageViewTracker.prototype.init = function () {
|
|
6673
|
+
var _this = this;
|
|
6674
|
+
this.log('[init] PageViewTracker Init');
|
|
6675
|
+
if (!supportsHistoryTracking(apvWindow())) {
|
|
6676
|
+
this.log('[init] unsupported environment (no History API), not starting');
|
|
6677
|
+
return;
|
|
6678
|
+
}
|
|
6679
|
+
// Take over from whichever tracker is currently active: one left behind by
|
|
6680
|
+
// a previous module load, or this same tracker on a repeat
|
|
6681
|
+
// mParticle.init(). Their pending navigations are transferred rather than
|
|
6682
|
+
// dropped — a route change may have queued a deferred fire that has not
|
|
6683
|
+
// flushed yet, and dropping it loses a page view entirely.
|
|
6684
|
+
var active = getActiveTracker();
|
|
6685
|
+
var inheritedPages = this.retire(active);
|
|
6686
|
+
if (this.active && active !== this) {
|
|
6687
|
+
inheritedPages = inheritedPages.concat(this.retire(this));
|
|
6688
|
+
}
|
|
6689
|
+
this.active = true;
|
|
6690
|
+
this.lastPage = currentPage();
|
|
6691
|
+
this.log("[init] seeded lastPage: ".concat(describePage(this.lastPage)));
|
|
6692
|
+
this.undoHistoryPatch = patchHistory(function (source) {
|
|
6693
|
+
return _this.safeHandleNavigation(source);
|
|
6694
|
+
}, function (message) {
|
|
6695
|
+
return _this.log(message);
|
|
6696
|
+
});
|
|
6697
|
+
this.popStateListener = function () {
|
|
6698
|
+
return _this.safeHandleNavigation('popstate');
|
|
6699
|
+
};
|
|
6700
|
+
window.addEventListener('popstate', this.popStateListener);
|
|
6701
|
+
setActiveTracker(this);
|
|
6702
|
+
this.log('[init] patched pushState/replaceState + listening for popstate');
|
|
6703
|
+
inheritedPages.forEach(function (page) {
|
|
6704
|
+
return _this.scheduleFire(page);
|
|
6705
|
+
});
|
|
6706
|
+
};
|
|
6707
|
+
PageViewTracker.prototype.teardown = function () {
|
|
6708
|
+
// Discard pending deferred fires (e.g. AutoLogPageView switched off on
|
|
6709
|
+
// re-init). A handoff calls takePendingNavigations() first, so by this
|
|
6710
|
+
// point those paths are already transferred rather than dropped.
|
|
6711
|
+
this.takePendingNavigations();
|
|
6712
|
+
if (this.popStateListener) {
|
|
6713
|
+
window.removeEventListener('popstate', this.popStateListener);
|
|
6714
|
+
this.popStateListener = null;
|
|
6715
|
+
}
|
|
6716
|
+
if (this.undoHistoryPatch) {
|
|
6717
|
+
this.undoHistoryPatch();
|
|
6718
|
+
this.undoHistoryPatch = null;
|
|
6719
|
+
}
|
|
6720
|
+
this.active = false;
|
|
6721
|
+
clearActiveTracker(this);
|
|
6722
|
+
};
|
|
6723
|
+
// Stops the outgoing tracker and returns the pages it had queued so this
|
|
6724
|
+
// tracker can re-schedule them once it is active. Private, but reachable
|
|
6725
|
+
// across instances: the handoff protocol stays internal to the class.
|
|
6726
|
+
PageViewTracker.prototype.retire = function (outgoing) {
|
|
6727
|
+
if (!outgoing) {
|
|
6728
|
+
return [];
|
|
6729
|
+
}
|
|
6730
|
+
this.log(outgoing === this ? '[init] retiring this tracker for a repeat mParticle.init() — transferring pending navigations and tearing down' : '[init] retiring a tracker from a previous module load — transferring pending navigations and tearing down');
|
|
6731
|
+
var pages = outgoing.takePendingNavigations();
|
|
6732
|
+
outgoing.teardown();
|
|
6733
|
+
return pages;
|
|
6734
|
+
};
|
|
6735
|
+
// Cancels this tracker's deferred fires and hands back their captured pages.
|
|
6736
|
+
PageViewTracker.prototype.takePendingNavigations = function () {
|
|
6737
|
+
var pending = this.pendingNavigations;
|
|
6738
|
+
this.pendingNavigations = [];
|
|
6739
|
+
pending.forEach(function (_a) {
|
|
6740
|
+
var timeoutId = _a.timeoutId;
|
|
6741
|
+
return clearTimeout(timeoutId);
|
|
6742
|
+
});
|
|
6743
|
+
return pending.map(function (_a) {
|
|
6744
|
+
var page = _a.page;
|
|
6745
|
+
return page;
|
|
6746
|
+
});
|
|
6747
|
+
};
|
|
6748
|
+
PageViewTracker.prototype.safeHandleNavigation = function (source) {
|
|
6749
|
+
// An orphaned wrapper still calls in: teardown can only restore a history
|
|
6750
|
+
// method that is still ours, so one a third party patched over stays
|
|
6751
|
+
// installed and keeps firing at a dead tracker. Bail before touching
|
|
6752
|
+
// lastPath or queueing a fire the flush would just abort. Guarding here
|
|
6753
|
+
// rather than at each wrapper also covers the popstate path.
|
|
6754
|
+
if (!this.active) {
|
|
6755
|
+
return;
|
|
6756
|
+
}
|
|
6757
|
+
try {
|
|
6758
|
+
this.handleNavigation(source);
|
|
6759
|
+
} catch (e) {
|
|
6760
|
+
this.log("[error] navigation handler threw (".concat(source, "), page view skipped: ").concat(e));
|
|
6761
|
+
}
|
|
6762
|
+
};
|
|
6763
|
+
PageViewTracker.prototype.handleNavigation = function (source) {
|
|
6764
|
+
var candidate = currentPage();
|
|
6765
|
+
var lastKey = this.lastPage ? pageKey(this.lastPage) : null;
|
|
6766
|
+
this.log("[detect] navigation signal (source: ".concat(source, ", candidate: ").concat(describePage(candidate), ", last: ").concat(describePage(this.lastPage), ")"));
|
|
6767
|
+
if (!isNewPage(lastKey, pageKey(candidate))) {
|
|
6768
|
+
this.log("[dedupe] page unchanged, skipping (source: ".concat(source, ", page: ").concat(describePage(candidate), ")"));
|
|
6769
|
+
return;
|
|
6770
|
+
}
|
|
6771
|
+
this.log("[accept] page changed, scheduling fire (source: ".concat(source, ", from: ").concat(describePage(this.lastPage), ", to: ").concat(describePage(candidate), ")"));
|
|
6772
|
+
this.lastPage = candidate;
|
|
6773
|
+
this.scheduleFire(candidate);
|
|
6774
|
+
};
|
|
6775
|
+
// Deferred by a macrotask so the router's post-navigation render commit has a
|
|
6776
|
+
// chance to update document.title before the event is built. The path and
|
|
6777
|
+
// query params are snapshotted now because they are already settled, whereas a
|
|
6778
|
+
// same-tick navigation would overwrite window.location before the flush reads
|
|
6779
|
+
// it.
|
|
6780
|
+
PageViewTracker.prototype.scheduleFire = function (page) {
|
|
6781
|
+
var _this = this;
|
|
6782
|
+
var timeoutId = setTimeout(function () {
|
|
6783
|
+
_this.pendingNavigations = _this.pendingNavigations.filter(function (p) {
|
|
6784
|
+
return p.timeoutId !== timeoutId;
|
|
6785
|
+
});
|
|
6786
|
+
if (!_this.active) {
|
|
6787
|
+
_this.log('[defer] fire aborted, tracker inactive (torn down before flush)');
|
|
6788
|
+
return;
|
|
6789
|
+
}
|
|
6790
|
+
_this.mpInstance._SessionManager.resetSessionTimer();
|
|
6791
|
+
_this.firePageView(page);
|
|
6792
|
+
}, 0);
|
|
6793
|
+
this.pendingNavigations.push({
|
|
6794
|
+
page: page,
|
|
6795
|
+
timeoutId: timeoutId
|
|
6796
|
+
});
|
|
6797
|
+
};
|
|
6798
|
+
PageViewTracker.prototype.firePageView = function (page) {
|
|
6799
|
+
var title = window.document.title;
|
|
6800
|
+
var event = buildPageViewEvent(__assign(__assign({}, page), {
|
|
6801
|
+
hostname: window.location.hostname,
|
|
6802
|
+
title: title
|
|
6803
|
+
}));
|
|
6804
|
+
this.log("[fire] deferred flush -> _Events.logEvent(PageView) (page: ".concat(describePage(page), ", title: ").concat(title, ")"));
|
|
6805
|
+
this.mpInstance._Events.logEvent(event);
|
|
6806
|
+
};
|
|
6807
|
+
PageViewTracker.prototype.log = function (message) {
|
|
6808
|
+
this.mpInstance.Logger.verbose("mParticle APV: ".concat(message));
|
|
6809
|
+
};
|
|
6810
|
+
return PageViewTracker;
|
|
6811
|
+
}();
|
|
6812
|
+
|
|
6813
|
+
var Messages$3 = Constants.Messages;
|
|
6814
|
+
function Events(mpInstance) {
|
|
6815
|
+
var self = this;
|
|
6816
|
+
this.logEvent = function (event, options) {
|
|
6817
|
+
mpInstance.Logger.verbose(Messages$3.InformationMessages.StartingLogEvent + ': ' + event.name);
|
|
6818
|
+
if (mpInstance._Helpers.canLog()) {
|
|
6819
|
+
var uploadObject = mpInstance._ServerModel.createEventObject(event);
|
|
6820
|
+
mpInstance._APIClient.sendEventToServer(uploadObject, options);
|
|
6821
|
+
} else {
|
|
6822
|
+
mpInstance.Logger.verbose(Messages$3.InformationMessages.AbandonLogEvent);
|
|
6823
|
+
}
|
|
6824
|
+
};
|
|
6825
|
+
this.startTracking = function (callback) {
|
|
6826
|
+
if (!mpInstance._Store.isTracking) {
|
|
6827
|
+
if ('geolocation' in navigator) {
|
|
6828
|
+
mpInstance._Store.watchPositionId = navigator.geolocation.watchPosition(successTracking, errorTracking);
|
|
6829
|
+
}
|
|
6830
|
+
} else {
|
|
6831
|
+
var position = {
|
|
6832
|
+
coords: {
|
|
6833
|
+
latitude: mpInstance._Store.currentPosition.lat,
|
|
6834
|
+
longitude: mpInstance._Store.currentPosition.lng
|
|
6835
|
+
}
|
|
6836
|
+
};
|
|
6837
|
+
triggerCallback(callback, position);
|
|
6838
|
+
}
|
|
6839
|
+
function successTracking(position) {
|
|
6840
|
+
mpInstance._Store.currentPosition = {
|
|
6841
|
+
lat: position.coords.latitude,
|
|
6842
|
+
lng: position.coords.longitude
|
|
6843
|
+
};
|
|
6844
|
+
triggerCallback(callback, position);
|
|
6845
|
+
// prevents callback from being fired multiple times
|
|
6846
|
+
callback = null;
|
|
6847
|
+
mpInstance._Store.isTracking = true;
|
|
6848
|
+
}
|
|
6849
|
+
function errorTracking() {
|
|
6850
|
+
triggerCallback(callback);
|
|
6851
|
+
// prevents callback from being fired multiple times
|
|
6852
|
+
callback = null;
|
|
6853
|
+
mpInstance._Store.isTracking = false;
|
|
6854
|
+
}
|
|
6855
|
+
function triggerCallback(callback, position) {
|
|
6856
|
+
if (callback) {
|
|
6857
|
+
try {
|
|
6858
|
+
if (position) {
|
|
6859
|
+
callback(position);
|
|
6860
|
+
} else {
|
|
6861
|
+
callback();
|
|
6862
|
+
}
|
|
6863
|
+
} catch (e) {
|
|
6864
|
+
mpInstance.Logger.error('Error invoking the callback passed to startTrackingLocation.');
|
|
6865
|
+
mpInstance.Logger.error(e);
|
|
6866
|
+
}
|
|
6867
|
+
}
|
|
6868
|
+
}
|
|
6869
|
+
};
|
|
6870
|
+
this.stopTracking = function () {
|
|
6871
|
+
if (mpInstance._Store.isTracking) {
|
|
6872
|
+
navigator.geolocation.clearWatch(mpInstance._Store.watchPositionId);
|
|
6873
|
+
mpInstance._Store.currentPosition = null;
|
|
6874
|
+
mpInstance._Store.isTracking = false;
|
|
6875
|
+
}
|
|
6876
|
+
};
|
|
6877
|
+
this.logOptOut = function () {
|
|
6878
|
+
mpInstance.Logger.verbose(Messages$3.InformationMessages.StartingLogOptOut);
|
|
6879
|
+
var event = mpInstance._ServerModel.createEventObject({
|
|
6880
|
+
messageType: Types.MessageType.OptOut,
|
|
6881
|
+
eventType: Types.EventType.Other
|
|
6882
|
+
});
|
|
6883
|
+
mpInstance._APIClient.sendEventToServer(event);
|
|
6884
|
+
};
|
|
6885
|
+
this.logAST = function () {
|
|
6886
|
+
self.logEvent({
|
|
6887
|
+
messageType: Types.MessageType.AppStateTransition
|
|
6888
|
+
});
|
|
6889
|
+
};
|
|
6890
|
+
// The auto page view for the landing page. The SPA navigations that follow it
|
|
6891
|
+
// come from PageViewTracker instead, so both emitters attach the same
|
|
6892
|
+
// allowlisted query params — and this is the one that matters for campaign
|
|
6893
|
+
// attribution, since utm_*/gclid live on the entry URL.
|
|
6894
|
+
this.logPageView = function () {
|
|
6895
|
+
self.logEvent({
|
|
6896
|
+
messageType: Types.MessageType.PageView,
|
|
6897
|
+
name: 'PageView',
|
|
6898
|
+
data: __assign(__assign({}, allowedQueryParams(getHref())), {
|
|
6899
|
+
hostname: window.location.hostname,
|
|
6900
|
+
title: window.document.title
|
|
6901
|
+
}),
|
|
6902
|
+
eventType: Types.EventType.Unknown
|
|
6903
|
+
});
|
|
6904
|
+
};
|
|
6905
|
+
this.logCheckoutEvent = function (step, option, attrs, customFlags) {
|
|
6906
|
+
var event = mpInstance._Ecommerce.createCommerceEventObject(customFlags);
|
|
6907
|
+
if (event) {
|
|
6908
|
+
event.EventName += mpInstance._Ecommerce.getProductActionEventName(Types.ProductActionType.Checkout);
|
|
6909
|
+
event.EventCategory = Types.CommerceEventType.ProductCheckout;
|
|
6910
|
+
event.ProductAction = {
|
|
6911
|
+
ProductActionType: Types.ProductActionType.Checkout,
|
|
6912
|
+
CheckoutStep: step,
|
|
6913
|
+
CheckoutOptions: option,
|
|
6914
|
+
ProductList: []
|
|
6915
|
+
};
|
|
6916
|
+
self.logCommerceEvent(event, attrs);
|
|
6917
|
+
}
|
|
6918
|
+
};
|
|
6919
|
+
this.logProductActionEvent = function (productActionType, product, customAttrs, customFlags, transactionAttributes, options) {
|
|
6920
|
+
var event = mpInstance._Ecommerce.createCommerceEventObject(customFlags, options);
|
|
6921
|
+
var productList = Array.isArray(product) ? product : [product];
|
|
6922
|
+
productList.forEach(function (product) {
|
|
6923
|
+
if (product.TotalAmount) {
|
|
6924
|
+
product.TotalAmount = mpInstance._Ecommerce.sanitizeAmount(product.TotalAmount, 'TotalAmount');
|
|
6925
|
+
}
|
|
6926
|
+
if (product.Position) {
|
|
6927
|
+
product.Position = mpInstance._Ecommerce.sanitizeAmount(product.Position, 'Position');
|
|
6433
6928
|
}
|
|
6434
6929
|
if (product.Price) {
|
|
6435
6930
|
product.Price = mpInstance._Ecommerce.sanitizeAmount(product.Price, 'Price');
|
|
@@ -6607,391 +7102,11 @@ var mParticle = (function () {
|
|
|
6607
7102
|
};
|
|
6608
7103
|
}
|
|
6609
7104
|
|
|
6610
|
-
function
|
|
6611
|
-
|
|
6612
|
-
var info = gen[key](arg);
|
|
6613
|
-
var value = info.value;
|
|
6614
|
-
} catch (error) {
|
|
6615
|
-
reject(error);
|
|
6616
|
-
return;
|
|
6617
|
-
}
|
|
6618
|
-
if (info.done) {
|
|
6619
|
-
resolve(value);
|
|
6620
|
-
} else {
|
|
6621
|
-
Promise.resolve(value).then(_next, _throw);
|
|
6622
|
-
}
|
|
7105
|
+
function isAttributeKeyAllowed(kitBlocker, key) {
|
|
7106
|
+
return !(kitBlocker === null || kitBlocker === void 0 ? void 0 : kitBlocker.isAttributeKeyBlocked(key));
|
|
6623
7107
|
}
|
|
6624
|
-
function
|
|
6625
|
-
return
|
|
6626
|
-
var self = this,
|
|
6627
|
-
args = arguments;
|
|
6628
|
-
return new Promise(function (resolve, reject) {
|
|
6629
|
-
var gen = fn.apply(self, args);
|
|
6630
|
-
function _next(value) {
|
|
6631
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
|
|
6632
|
-
}
|
|
6633
|
-
function _throw(err) {
|
|
6634
|
-
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
|
|
6635
|
-
}
|
|
6636
|
-
_next(undefined);
|
|
6637
|
-
});
|
|
6638
|
-
};
|
|
6639
|
-
}
|
|
6640
|
-
|
|
6641
|
-
var regeneratorRuntime$1 = {exports: {}};
|
|
6642
|
-
|
|
6643
|
-
var _typeof = {exports: {}};
|
|
6644
|
-
|
|
6645
|
-
_typeof.exports;
|
|
6646
|
-
|
|
6647
|
-
(function (module) {
|
|
6648
|
-
function _typeof(o) {
|
|
6649
|
-
"@babel/helpers - typeof";
|
|
6650
|
-
|
|
6651
|
-
return (module.exports = _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) {
|
|
6652
|
-
return typeof o;
|
|
6653
|
-
} : function (o) {
|
|
6654
|
-
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
6655
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports), _typeof(o);
|
|
6656
|
-
}
|
|
6657
|
-
module.exports = _typeof, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
6658
|
-
} (_typeof));
|
|
6659
|
-
|
|
6660
|
-
var _typeofExports = _typeof.exports;
|
|
6661
|
-
|
|
6662
|
-
regeneratorRuntime$1.exports;
|
|
6663
|
-
|
|
6664
|
-
(function (module) {
|
|
6665
|
-
var _typeof = _typeofExports["default"];
|
|
6666
|
-
function _regeneratorRuntime() {
|
|
6667
|
-
module.exports = _regeneratorRuntime = function _regeneratorRuntime() {
|
|
6668
|
-
return e;
|
|
6669
|
-
}, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
6670
|
-
var t,
|
|
6671
|
-
e = {},
|
|
6672
|
-
r = Object.prototype,
|
|
6673
|
-
n = r.hasOwnProperty,
|
|
6674
|
-
o = Object.defineProperty || function (t, e, r) {
|
|
6675
|
-
t[e] = r.value;
|
|
6676
|
-
},
|
|
6677
|
-
i = "function" == typeof Symbol ? Symbol : {},
|
|
6678
|
-
a = i.iterator || "@@iterator",
|
|
6679
|
-
c = i.asyncIterator || "@@asyncIterator",
|
|
6680
|
-
u = i.toStringTag || "@@toStringTag";
|
|
6681
|
-
function define(t, e, r) {
|
|
6682
|
-
return Object.defineProperty(t, e, {
|
|
6683
|
-
value: r,
|
|
6684
|
-
enumerable: !0,
|
|
6685
|
-
configurable: !0,
|
|
6686
|
-
writable: !0
|
|
6687
|
-
}), t[e];
|
|
6688
|
-
}
|
|
6689
|
-
try {
|
|
6690
|
-
define({}, "");
|
|
6691
|
-
} catch (t) {
|
|
6692
|
-
define = function define(t, e, r) {
|
|
6693
|
-
return t[e] = r;
|
|
6694
|
-
};
|
|
6695
|
-
}
|
|
6696
|
-
function wrap(t, e, r, n) {
|
|
6697
|
-
var i = e && e.prototype instanceof Generator ? e : Generator,
|
|
6698
|
-
a = Object.create(i.prototype),
|
|
6699
|
-
c = new Context(n || []);
|
|
6700
|
-
return o(a, "_invoke", {
|
|
6701
|
-
value: makeInvokeMethod(t, r, c)
|
|
6702
|
-
}), a;
|
|
6703
|
-
}
|
|
6704
|
-
function tryCatch(t, e, r) {
|
|
6705
|
-
try {
|
|
6706
|
-
return {
|
|
6707
|
-
type: "normal",
|
|
6708
|
-
arg: t.call(e, r)
|
|
6709
|
-
};
|
|
6710
|
-
} catch (t) {
|
|
6711
|
-
return {
|
|
6712
|
-
type: "throw",
|
|
6713
|
-
arg: t
|
|
6714
|
-
};
|
|
6715
|
-
}
|
|
6716
|
-
}
|
|
6717
|
-
e.wrap = wrap;
|
|
6718
|
-
var h = "suspendedStart",
|
|
6719
|
-
l = "suspendedYield",
|
|
6720
|
-
f = "executing",
|
|
6721
|
-
s = "completed",
|
|
6722
|
-
y = {};
|
|
6723
|
-
function Generator() {}
|
|
6724
|
-
function GeneratorFunction() {}
|
|
6725
|
-
function GeneratorFunctionPrototype() {}
|
|
6726
|
-
var p = {};
|
|
6727
|
-
define(p, a, function () {
|
|
6728
|
-
return this;
|
|
6729
|
-
});
|
|
6730
|
-
var d = Object.getPrototypeOf,
|
|
6731
|
-
v = d && d(d(values([])));
|
|
6732
|
-
v && v !== r && n.call(v, a) && (p = v);
|
|
6733
|
-
var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p);
|
|
6734
|
-
function defineIteratorMethods(t) {
|
|
6735
|
-
["next", "throw", "return"].forEach(function (e) {
|
|
6736
|
-
define(t, e, function (t) {
|
|
6737
|
-
return this._invoke(e, t);
|
|
6738
|
-
});
|
|
6739
|
-
});
|
|
6740
|
-
}
|
|
6741
|
-
function AsyncIterator(t, e) {
|
|
6742
|
-
function invoke(r, o, i, a) {
|
|
6743
|
-
var c = tryCatch(t[r], t, o);
|
|
6744
|
-
if ("throw" !== c.type) {
|
|
6745
|
-
var u = c.arg,
|
|
6746
|
-
h = u.value;
|
|
6747
|
-
return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) {
|
|
6748
|
-
invoke("next", t, i, a);
|
|
6749
|
-
}, function (t) {
|
|
6750
|
-
invoke("throw", t, i, a);
|
|
6751
|
-
}) : e.resolve(h).then(function (t) {
|
|
6752
|
-
u.value = t, i(u);
|
|
6753
|
-
}, function (t) {
|
|
6754
|
-
return invoke("throw", t, i, a);
|
|
6755
|
-
});
|
|
6756
|
-
}
|
|
6757
|
-
a(c.arg);
|
|
6758
|
-
}
|
|
6759
|
-
var r;
|
|
6760
|
-
o(this, "_invoke", {
|
|
6761
|
-
value: function value(t, n) {
|
|
6762
|
-
function callInvokeWithMethodAndArg() {
|
|
6763
|
-
return new e(function (e, r) {
|
|
6764
|
-
invoke(t, n, e, r);
|
|
6765
|
-
});
|
|
6766
|
-
}
|
|
6767
|
-
return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg();
|
|
6768
|
-
}
|
|
6769
|
-
});
|
|
6770
|
-
}
|
|
6771
|
-
function makeInvokeMethod(e, r, n) {
|
|
6772
|
-
var o = h;
|
|
6773
|
-
return function (i, a) {
|
|
6774
|
-
if (o === f) throw new Error("Generator is already running");
|
|
6775
|
-
if (o === s) {
|
|
6776
|
-
if ("throw" === i) throw a;
|
|
6777
|
-
return {
|
|
6778
|
-
value: t,
|
|
6779
|
-
done: !0
|
|
6780
|
-
};
|
|
6781
|
-
}
|
|
6782
|
-
for (n.method = i, n.arg = a;;) {
|
|
6783
|
-
var c = n.delegate;
|
|
6784
|
-
if (c) {
|
|
6785
|
-
var u = maybeInvokeDelegate(c, n);
|
|
6786
|
-
if (u) {
|
|
6787
|
-
if (u === y) continue;
|
|
6788
|
-
return u;
|
|
6789
|
-
}
|
|
6790
|
-
}
|
|
6791
|
-
if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) {
|
|
6792
|
-
if (o === h) throw o = s, n.arg;
|
|
6793
|
-
n.dispatchException(n.arg);
|
|
6794
|
-
} else "return" === n.method && n.abrupt("return", n.arg);
|
|
6795
|
-
o = f;
|
|
6796
|
-
var p = tryCatch(e, r, n);
|
|
6797
|
-
if ("normal" === p.type) {
|
|
6798
|
-
if (o = n.done ? s : l, p.arg === y) continue;
|
|
6799
|
-
return {
|
|
6800
|
-
value: p.arg,
|
|
6801
|
-
done: n.done
|
|
6802
|
-
};
|
|
6803
|
-
}
|
|
6804
|
-
"throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg);
|
|
6805
|
-
}
|
|
6806
|
-
};
|
|
6807
|
-
}
|
|
6808
|
-
function maybeInvokeDelegate(e, r) {
|
|
6809
|
-
var n = r.method,
|
|
6810
|
-
o = e.iterator[n];
|
|
6811
|
-
if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y;
|
|
6812
|
-
var i = tryCatch(o, e.iterator, r.arg);
|
|
6813
|
-
if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y;
|
|
6814
|
-
var a = i.arg;
|
|
6815
|
-
return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y);
|
|
6816
|
-
}
|
|
6817
|
-
function pushTryEntry(t) {
|
|
6818
|
-
var e = {
|
|
6819
|
-
tryLoc: t[0]
|
|
6820
|
-
};
|
|
6821
|
-
1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e);
|
|
6822
|
-
}
|
|
6823
|
-
function resetTryEntry(t) {
|
|
6824
|
-
var e = t.completion || {};
|
|
6825
|
-
e.type = "normal", delete e.arg, t.completion = e;
|
|
6826
|
-
}
|
|
6827
|
-
function Context(t) {
|
|
6828
|
-
this.tryEntries = [{
|
|
6829
|
-
tryLoc: "root"
|
|
6830
|
-
}], t.forEach(pushTryEntry, this), this.reset(!0);
|
|
6831
|
-
}
|
|
6832
|
-
function values(e) {
|
|
6833
|
-
if (e || "" === e) {
|
|
6834
|
-
var r = e[a];
|
|
6835
|
-
if (r) return r.call(e);
|
|
6836
|
-
if ("function" == typeof e.next) return e;
|
|
6837
|
-
if (!isNaN(e.length)) {
|
|
6838
|
-
var o = -1,
|
|
6839
|
-
i = function next() {
|
|
6840
|
-
for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next;
|
|
6841
|
-
return next.value = t, next.done = !0, next;
|
|
6842
|
-
};
|
|
6843
|
-
return i.next = i;
|
|
6844
|
-
}
|
|
6845
|
-
}
|
|
6846
|
-
throw new TypeError(_typeof(e) + " is not iterable");
|
|
6847
|
-
}
|
|
6848
|
-
return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", {
|
|
6849
|
-
value: GeneratorFunctionPrototype,
|
|
6850
|
-
configurable: !0
|
|
6851
|
-
}), o(GeneratorFunctionPrototype, "constructor", {
|
|
6852
|
-
value: GeneratorFunction,
|
|
6853
|
-
configurable: !0
|
|
6854
|
-
}), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) {
|
|
6855
|
-
var e = "function" == typeof t && t.constructor;
|
|
6856
|
-
return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name));
|
|
6857
|
-
}, e.mark = function (t) {
|
|
6858
|
-
return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t;
|
|
6859
|
-
}, e.awrap = function (t) {
|
|
6860
|
-
return {
|
|
6861
|
-
__await: t
|
|
6862
|
-
};
|
|
6863
|
-
}, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () {
|
|
6864
|
-
return this;
|
|
6865
|
-
}), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) {
|
|
6866
|
-
void 0 === i && (i = Promise);
|
|
6867
|
-
var a = new AsyncIterator(wrap(t, r, n, o), i);
|
|
6868
|
-
return e.isGeneratorFunction(r) ? a : a.next().then(function (t) {
|
|
6869
|
-
return t.done ? t.value : a.next();
|
|
6870
|
-
});
|
|
6871
|
-
}, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () {
|
|
6872
|
-
return this;
|
|
6873
|
-
}), define(g, "toString", function () {
|
|
6874
|
-
return "[object Generator]";
|
|
6875
|
-
}), e.keys = function (t) {
|
|
6876
|
-
var e = Object(t),
|
|
6877
|
-
r = [];
|
|
6878
|
-
for (var n in e) r.push(n);
|
|
6879
|
-
return r.reverse(), function next() {
|
|
6880
|
-
for (; r.length;) {
|
|
6881
|
-
var t = r.pop();
|
|
6882
|
-
if (t in e) return next.value = t, next.done = !1, next;
|
|
6883
|
-
}
|
|
6884
|
-
return next.done = !0, next;
|
|
6885
|
-
};
|
|
6886
|
-
}, e.values = values, Context.prototype = {
|
|
6887
|
-
constructor: Context,
|
|
6888
|
-
reset: function reset(e) {
|
|
6889
|
-
if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t);
|
|
6890
|
-
},
|
|
6891
|
-
stop: function stop() {
|
|
6892
|
-
this.done = !0;
|
|
6893
|
-
var t = this.tryEntries[0].completion;
|
|
6894
|
-
if ("throw" === t.type) throw t.arg;
|
|
6895
|
-
return this.rval;
|
|
6896
|
-
},
|
|
6897
|
-
dispatchException: function dispatchException(e) {
|
|
6898
|
-
if (this.done) throw e;
|
|
6899
|
-
var r = this;
|
|
6900
|
-
function handle(n, o) {
|
|
6901
|
-
return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o;
|
|
6902
|
-
}
|
|
6903
|
-
for (var o = this.tryEntries.length - 1; o >= 0; --o) {
|
|
6904
|
-
var i = this.tryEntries[o],
|
|
6905
|
-
a = i.completion;
|
|
6906
|
-
if ("root" === i.tryLoc) return handle("end");
|
|
6907
|
-
if (i.tryLoc <= this.prev) {
|
|
6908
|
-
var c = n.call(i, "catchLoc"),
|
|
6909
|
-
u = n.call(i, "finallyLoc");
|
|
6910
|
-
if (c && u) {
|
|
6911
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
6912
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
6913
|
-
} else if (c) {
|
|
6914
|
-
if (this.prev < i.catchLoc) return handle(i.catchLoc, !0);
|
|
6915
|
-
} else {
|
|
6916
|
-
if (!u) throw new Error("try statement without catch or finally");
|
|
6917
|
-
if (this.prev < i.finallyLoc) return handle(i.finallyLoc);
|
|
6918
|
-
}
|
|
6919
|
-
}
|
|
6920
|
-
}
|
|
6921
|
-
},
|
|
6922
|
-
abrupt: function abrupt(t, e) {
|
|
6923
|
-
for (var r = this.tryEntries.length - 1; r >= 0; --r) {
|
|
6924
|
-
var o = this.tryEntries[r];
|
|
6925
|
-
if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) {
|
|
6926
|
-
var i = o;
|
|
6927
|
-
break;
|
|
6928
|
-
}
|
|
6929
|
-
}
|
|
6930
|
-
i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null);
|
|
6931
|
-
var a = i ? i.completion : {};
|
|
6932
|
-
return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a);
|
|
6933
|
-
},
|
|
6934
|
-
complete: function complete(t, e) {
|
|
6935
|
-
if ("throw" === t.type) throw t.arg;
|
|
6936
|
-
return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y;
|
|
6937
|
-
},
|
|
6938
|
-
finish: function finish(t) {
|
|
6939
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
6940
|
-
var r = this.tryEntries[e];
|
|
6941
|
-
if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y;
|
|
6942
|
-
}
|
|
6943
|
-
},
|
|
6944
|
-
"catch": function _catch(t) {
|
|
6945
|
-
for (var e = this.tryEntries.length - 1; e >= 0; --e) {
|
|
6946
|
-
var r = this.tryEntries[e];
|
|
6947
|
-
if (r.tryLoc === t) {
|
|
6948
|
-
var n = r.completion;
|
|
6949
|
-
if ("throw" === n.type) {
|
|
6950
|
-
var o = n.arg;
|
|
6951
|
-
resetTryEntry(r);
|
|
6952
|
-
}
|
|
6953
|
-
return o;
|
|
6954
|
-
}
|
|
6955
|
-
}
|
|
6956
|
-
throw new Error("illegal catch attempt");
|
|
6957
|
-
},
|
|
6958
|
-
delegateYield: function delegateYield(e, r, n) {
|
|
6959
|
-
return this.delegate = {
|
|
6960
|
-
iterator: values(e),
|
|
6961
|
-
resultName: r,
|
|
6962
|
-
nextLoc: n
|
|
6963
|
-
}, "next" === this.method && (this.arg = t), y;
|
|
6964
|
-
}
|
|
6965
|
-
}, e;
|
|
6966
|
-
}
|
|
6967
|
-
module.exports = _regeneratorRuntime, module.exports.__esModule = true, module.exports["default"] = module.exports;
|
|
6968
|
-
} (regeneratorRuntime$1));
|
|
6969
|
-
|
|
6970
|
-
var regeneratorRuntimeExports = regeneratorRuntime$1.exports;
|
|
6971
|
-
|
|
6972
|
-
// TODO(Babel 8): Remove this file.
|
|
6973
|
-
|
|
6974
|
-
var runtime = regeneratorRuntimeExports();
|
|
6975
|
-
var regenerator = runtime;
|
|
6976
|
-
|
|
6977
|
-
// Copied from https://github.com/facebook/regenerator/blob/main/packages/runtime/runtime.js#L736=
|
|
6978
|
-
try {
|
|
6979
|
-
regeneratorRuntime = runtime;
|
|
6980
|
-
} catch (accidentalStrictMode) {
|
|
6981
|
-
if (typeof globalThis === "object") {
|
|
6982
|
-
globalThis.regeneratorRuntime = runtime;
|
|
6983
|
-
} else {
|
|
6984
|
-
Function("r", "regeneratorRuntime = r")(runtime);
|
|
6985
|
-
}
|
|
6986
|
-
}
|
|
6987
|
-
|
|
6988
|
-
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
6989
|
-
|
|
6990
|
-
function isAttributeKeyAllowed(kitBlocker, key) {
|
|
6991
|
-
return !(kitBlocker === null || kitBlocker === void 0 ? void 0 : kitBlocker.isAttributeKeyBlocked(key));
|
|
6992
|
-
}
|
|
6993
|
-
function isIdentityAllowed(kitBlocker, identityName) {
|
|
6994
|
-
return !(kitBlocker === null || kitBlocker === void 0 ? void 0 : kitBlocker.isIdentityBlocked(identityName));
|
|
7108
|
+
function isIdentityAllowed(kitBlocker, identityName) {
|
|
7109
|
+
return !(kitBlocker === null || kitBlocker === void 0 ? void 0 : kitBlocker.isIdentityBlocked(identityName));
|
|
6995
7110
|
}
|
|
6996
7111
|
function copyUserAttributeValue(value) {
|
|
6997
7112
|
return Array.isArray(value) ? value.slice() : value;
|
|
@@ -7131,11 +7246,27 @@ var mParticle = (function () {
|
|
|
7131
7246
|
});
|
|
7132
7247
|
}
|
|
7133
7248
|
|
|
7134
|
-
var
|
|
7135
|
-
|
|
7136
|
-
|
|
7137
|
-
|
|
7138
|
-
|
|
7249
|
+
var _a;
|
|
7250
|
+
var _b = Constants.IdentityMethods,
|
|
7251
|
+
Modify$2 = _b.Modify,
|
|
7252
|
+
Identify$1 = _b.Identify,
|
|
7253
|
+
Login$1 = _b.Login,
|
|
7254
|
+
Logout$1 = _b.Logout;
|
|
7255
|
+
// Maps an identity method to the kit callback that reports its completion.
|
|
7256
|
+
var identityCompleteKitMethods = (_a = {}, _a[Identify$1] = 'onIdentifyComplete', _a[Login$1] = 'onLoginComplete', _a[Logout$1] = 'onLogoutComplete', _a[Modify$2] = 'onModifyComplete', _a);
|
|
7257
|
+
function userAttributesMatchFilter(userAttributes, filterObject) {
|
|
7258
|
+
for (var attrName in userAttributes) {
|
|
7259
|
+
if (!userAttributes.hasOwnProperty(attrName)) {
|
|
7260
|
+
continue;
|
|
7261
|
+
}
|
|
7262
|
+
var attrHash = KitFilterHelper.hashAttributeConditionalForwarding(attrName);
|
|
7263
|
+
var valueHash = KitFilterHelper.hashAttributeConditionalForwarding(userAttributes[attrName]);
|
|
7264
|
+
if (attrHash === filterObject.userAttributeName && valueHash === filterObject.userAttributeValue) {
|
|
7265
|
+
return true;
|
|
7266
|
+
}
|
|
7267
|
+
}
|
|
7268
|
+
return false;
|
|
7269
|
+
}
|
|
7139
7270
|
function Forwarders(mpInstance, kitBlocker) {
|
|
7140
7271
|
var _this = this;
|
|
7141
7272
|
var self = this;
|
|
@@ -7178,31 +7309,14 @@ var mParticle = (function () {
|
|
|
7178
7309
|
if (!filterObject || !mpInstance._Helpers.isObject(filterObject) || !Object.keys(filterObject).length) {
|
|
7179
7310
|
return true;
|
|
7180
7311
|
}
|
|
7181
|
-
var attrHash, valueHash, userAttributes;
|
|
7182
7312
|
if (!user) {
|
|
7183
7313
|
return false;
|
|
7184
|
-
} else {
|
|
7185
|
-
userAttributes = user.getAllUserAttributes();
|
|
7186
7314
|
}
|
|
7187
|
-
var
|
|
7315
|
+
var userAttributes = user.getAllUserAttributes();
|
|
7188
7316
|
try {
|
|
7189
|
-
|
|
7190
|
-
|
|
7191
|
-
|
|
7192
|
-
attrHash = KitFilterHelper.hashAttributeConditionalForwarding(attrName);
|
|
7193
|
-
valueHash = KitFilterHelper.hashAttributeConditionalForwarding(userAttributes[attrName]);
|
|
7194
|
-
if (attrHash === filterObject.userAttributeName && valueHash === filterObject.userAttributeValue) {
|
|
7195
|
-
isMatch = true;
|
|
7196
|
-
break;
|
|
7197
|
-
}
|
|
7198
|
-
}
|
|
7199
|
-
}
|
|
7200
|
-
}
|
|
7201
|
-
if (filterObject) {
|
|
7202
|
-
return filterObject.includeOnMatch === isMatch;
|
|
7203
|
-
} else {
|
|
7204
|
-
return true;
|
|
7205
|
-
}
|
|
7317
|
+
var hasUserAttributes = userAttributes && mpInstance._Helpers.isObject(userAttributes) && Object.keys(userAttributes).length > 0;
|
|
7318
|
+
var isMatch = hasUserAttributes ? userAttributesMatchFilter(userAttributes, filterObject) : false;
|
|
7319
|
+
return filterObject.includeOnMatch === isMatch;
|
|
7206
7320
|
} catch (e) {
|
|
7207
7321
|
// in any error scenario, err on side of returning true and forwarding event
|
|
7208
7322
|
return true;
|
|
@@ -7234,39 +7348,38 @@ var mParticle = (function () {
|
|
|
7234
7348
|
}
|
|
7235
7349
|
};
|
|
7236
7350
|
this.sendEventToForwarders = function (event) {
|
|
7237
|
-
|
|
7238
|
-
|
|
7239
|
-
var hashedEventType;
|
|
7240
|
-
if (!mpInstance._Store.webviewBridgeEnabled && mpInstance._Store.activeForwarders) {
|
|
7241
|
-
hashedEventName = KitFilterHelper.hashEventName(event.EventName, event.EventCategory);
|
|
7242
|
-
hashedEventType = KitFilterHelper.hashEventType(event.EventCategory);
|
|
7243
|
-
for (var i = 0; i < mpInstance._Store.activeForwarders.length; i++) {
|
|
7244
|
-
var forwarder = mpInstance._Store.activeForwarders[i];
|
|
7245
|
-
if (isBlockedByForwardingRule(event.EventDataType, event.EventAttributes, forwarder)) {
|
|
7246
|
-
continue;
|
|
7247
|
-
}
|
|
7248
|
-
|
|
7249
|
-
// Clone the event object, as we could be sending different attributes to each forwarder
|
|
7250
|
-
clonedEvent = extend(true, {}, event);
|
|
7251
|
-
if (isBlockedByEventFilter(event.EventDataType, hashedEventName, hashedEventType, forwarder)) {
|
|
7252
|
-
continue;
|
|
7253
|
-
}
|
|
7254
|
-
clonedEvent.EventAttributes = filterEventAttributes(event.EventDataType, event.EventCategory, event.EventName, clonedEvent.EventAttributes, forwarder);
|
|
7255
|
-
|
|
7256
|
-
// Check user identity filtering rules
|
|
7257
|
-
clonedEvent.UserIdentities = filterUserIdentities(clonedEvent.UserIdentities, forwarder.userIdentityFilters);
|
|
7258
|
-
|
|
7259
|
-
// Check user attribute filtering rules
|
|
7260
|
-
clonedEvent.UserAttributes = KitFilterHelper.filterUserAttributes(clonedEvent.UserAttributes, forwarder.userAttributeFilters);
|
|
7261
|
-
if (forwarder.process) {
|
|
7262
|
-
mpInstance.Logger.verbose('Sending message to forwarder: ' + forwarder.name);
|
|
7263
|
-
var result = forwarder.process(clonedEvent);
|
|
7264
|
-
if (result) {
|
|
7265
|
-
mpInstance.Logger.verbose(result);
|
|
7266
|
-
}
|
|
7267
|
-
}
|
|
7268
|
-
}
|
|
7351
|
+
if (mpInstance._Store.webviewBridgeEnabled || !mpInstance._Store.activeForwarders) {
|
|
7352
|
+
return;
|
|
7269
7353
|
}
|
|
7354
|
+
var hashedEventName = KitFilterHelper.hashEventName(event.EventName, event.EventCategory);
|
|
7355
|
+
var hashedEventType = KitFilterHelper.hashEventType(event.EventCategory);
|
|
7356
|
+
var forwardEvent = function forwardEvent(forwarder) {
|
|
7357
|
+
if (isBlockedByForwardingRule(event.EventDataType, event.EventAttributes, forwarder)) {
|
|
7358
|
+
return;
|
|
7359
|
+
}
|
|
7360
|
+
// Clone the event object, as we could be sending different attributes to each forwarder
|
|
7361
|
+
var clonedEvent = extend(true, {}, event);
|
|
7362
|
+
if (isBlockedByEventFilter(event.EventDataType, hashedEventName, hashedEventType, forwarder)) {
|
|
7363
|
+
return;
|
|
7364
|
+
}
|
|
7365
|
+
clonedEvent.EventAttributes = filterEventAttributes(event.EventDataType, event.EventCategory, event.EventName, clonedEvent.EventAttributes, forwarder);
|
|
7366
|
+
// Check user identity filtering rules
|
|
7367
|
+
clonedEvent.UserIdentities = filterUserIdentities(clonedEvent.UserIdentities, forwarder.userIdentityFilters);
|
|
7368
|
+
// Check user attribute filtering rules
|
|
7369
|
+
clonedEvent.UserAttributes = KitFilterHelper.filterUserAttributes(clonedEvent.UserAttributes, forwarder.userAttributeFilters);
|
|
7370
|
+
if (!forwarder.process) {
|
|
7371
|
+
return;
|
|
7372
|
+
}
|
|
7373
|
+
mpInstance.Logger.verbose('Sending message to forwarder: ' + forwarder.name);
|
|
7374
|
+
var result = forwarder.process(clonedEvent);
|
|
7375
|
+
if (result) {
|
|
7376
|
+
mpInstance.Logger.verbose(result);
|
|
7377
|
+
}
|
|
7378
|
+
};
|
|
7379
|
+
// Not for...of: the downleveled loop is miscompiled in cjs/esm builds.
|
|
7380
|
+
mpInstance._Store.activeForwarders.forEach(function (forwarder) {
|
|
7381
|
+
forwardEvent(forwarder);
|
|
7382
|
+
});
|
|
7270
7383
|
};
|
|
7271
7384
|
this.handleForwarderUserAttributes = function (functionNameKey, key, value) {
|
|
7272
7385
|
if (kitBlocker && kitBlocker.isAttributeKeyBlocked(key) || !mpInstance._Store.activeForwarders.length) {
|
|
@@ -7278,7 +7391,7 @@ var mParticle = (function () {
|
|
|
7278
7391
|
return;
|
|
7279
7392
|
}
|
|
7280
7393
|
try {
|
|
7281
|
-
var result;
|
|
7394
|
+
var result = void 0;
|
|
7282
7395
|
if (functionNameKey === UserAttributeActionTypes.setUserAttribute) {
|
|
7283
7396
|
result = forwarder.setUserAttribute(key, value);
|
|
7284
7397
|
} else if (functionNameKey === UserAttributeActionTypes.removeUserAttribute) {
|
|
@@ -7292,7 +7405,6 @@ var mParticle = (function () {
|
|
|
7292
7405
|
}
|
|
7293
7406
|
});
|
|
7294
7407
|
};
|
|
7295
|
-
|
|
7296
7408
|
// TODO: https://go.mparticle.com/work/SQDSDKS-6036
|
|
7297
7409
|
this.setForwarderUserIdentities = function (userIdentities) {
|
|
7298
7410
|
mpInstance._Store.activeForwarders.forEach(function (forwarder) {
|
|
@@ -7319,38 +7431,19 @@ var mParticle = (function () {
|
|
|
7319
7431
|
});
|
|
7320
7432
|
};
|
|
7321
7433
|
this.setForwarderOnIdentityComplete = function (user, identityMethod) {
|
|
7322
|
-
var
|
|
7434
|
+
var kitMethodName = identityCompleteKitMethods[identityMethod];
|
|
7435
|
+
if (!kitMethodName) {
|
|
7436
|
+
return;
|
|
7437
|
+
}
|
|
7323
7438
|
mpInstance._Store.activeForwarders.forEach(function (forwarder) {
|
|
7439
|
+
var onIdentityComplete = forwarder[kitMethodName];
|
|
7440
|
+
if (!onIdentityComplete) {
|
|
7441
|
+
return;
|
|
7442
|
+
}
|
|
7324
7443
|
var filteredUser = filteredMparticleUser(user.getMPID(), forwarder, mpInstance, kitBlocker);
|
|
7325
|
-
var
|
|
7326
|
-
if (
|
|
7327
|
-
|
|
7328
|
-
result = forwarder.onIdentifyComplete(filteredUser, filteredUserIdentities);
|
|
7329
|
-
if (result) {
|
|
7330
|
-
mpInstance.Logger.verbose(result);
|
|
7331
|
-
}
|
|
7332
|
-
}
|
|
7333
|
-
} else if (identityMethod === Login$1) {
|
|
7334
|
-
if (forwarder.onLoginComplete) {
|
|
7335
|
-
result = forwarder.onLoginComplete(filteredUser, filteredUserIdentities);
|
|
7336
|
-
if (result) {
|
|
7337
|
-
mpInstance.Logger.verbose(result);
|
|
7338
|
-
}
|
|
7339
|
-
}
|
|
7340
|
-
} else if (identityMethod === Logout$1) {
|
|
7341
|
-
if (forwarder.onLogoutComplete) {
|
|
7342
|
-
result = forwarder.onLogoutComplete(filteredUser, filteredUserIdentities);
|
|
7343
|
-
if (result) {
|
|
7344
|
-
mpInstance.Logger.verbose(result);
|
|
7345
|
-
}
|
|
7346
|
-
}
|
|
7347
|
-
} else if (identityMethod === Modify$2) {
|
|
7348
|
-
if (forwarder.onModifyComplete) {
|
|
7349
|
-
result = forwarder.onModifyComplete(filteredUser, filteredUserIdentities);
|
|
7350
|
-
if (result) {
|
|
7351
|
-
mpInstance.Logger.verbose(result);
|
|
7352
|
-
}
|
|
7353
|
-
}
|
|
7444
|
+
var result = onIdentityComplete.call(forwarder, filteredUser, filteredUser.getUserIdentities());
|
|
7445
|
+
if (result) {
|
|
7446
|
+
mpInstance.Logger.verbose(result);
|
|
7354
7447
|
}
|
|
7355
7448
|
});
|
|
7356
7449
|
};
|
|
@@ -7360,7 +7453,6 @@ var mParticle = (function () {
|
|
|
7360
7453
|
this.setForwarderStatsQueue = function (queue) {
|
|
7361
7454
|
mpInstance._Persistence.forwardingStatsBatches.forwardingStatsEventQueue = queue;
|
|
7362
7455
|
};
|
|
7363
|
-
|
|
7364
7456
|
// Processing forwarders is a 2 step process:
|
|
7365
7457
|
// 1. Configure the kit
|
|
7366
7458
|
// 2. Initialize the kit
|
|
@@ -7376,7 +7468,6 @@ var mParticle = (function () {
|
|
|
7376
7468
|
self.initForwarders(mpInstance._Store.SDKConfig.identifyRequest.userIdentities, forwardingStatsCallback);
|
|
7377
7469
|
}
|
|
7378
7470
|
};
|
|
7379
|
-
|
|
7380
7471
|
// These are kits that are enabled via the mParticle UI.
|
|
7381
7472
|
// A kit that is UI-enabled will have a kit configuration that returns from
|
|
7382
7473
|
// the server, or in rare cases, is passed in by the developer.
|
|
@@ -7423,25 +7514,23 @@ var mParticle = (function () {
|
|
|
7423
7514
|
this.configureUIEnabledKit = function (configuration, kits) {
|
|
7424
7515
|
var newKit = null;
|
|
7425
7516
|
var config = configuration;
|
|
7426
|
-
for (var
|
|
7517
|
+
for (var name_1 in kits) {
|
|
7427
7518
|
// Configs are returned with suffixes also. We need to consider the
|
|
7428
7519
|
// config suffix here to match the constructor suffix
|
|
7429
7520
|
var kitNameWithConfigSuffix = void 0;
|
|
7430
7521
|
if (config.suffix) {
|
|
7431
7522
|
kitNameWithConfigSuffix = "".concat(config.name, "-").concat(config.suffix);
|
|
7432
7523
|
}
|
|
7433
|
-
if (
|
|
7524
|
+
if (name_1 === kitNameWithConfigSuffix || name_1 === config.name) {
|
|
7434
7525
|
if (config.isDebug === mpInstance._Store.SDKConfig.isDevelopmentMode || config.isSandbox === mpInstance._Store.SDKConfig.isDevelopmentMode) {
|
|
7435
|
-
newKit = this.returnConfiguredKit(kits[
|
|
7526
|
+
newKit = this.returnConfiguredKit(kits[name_1], config);
|
|
7436
7527
|
mpInstance._Store.configuredForwarders.push(newKit);
|
|
7437
7528
|
break;
|
|
7438
7529
|
}
|
|
7439
7530
|
}
|
|
7440
7531
|
}
|
|
7441
7532
|
};
|
|
7442
|
-
|
|
7443
7533
|
// Unlike UI enabled kits, sideloaded kits are always added to active forwarders.
|
|
7444
|
-
|
|
7445
7534
|
// TODO: Sideloading kits currently require the use of a register method
|
|
7446
7535
|
// which requires an object on which to be registered.
|
|
7447
7536
|
// In the future, when all kits are moved to the mpConfig rather than
|
|
@@ -7450,7 +7539,7 @@ var mParticle = (function () {
|
|
|
7450
7539
|
this.processSideloadedKits = function (mpConfig) {
|
|
7451
7540
|
try {
|
|
7452
7541
|
if (Array.isArray(mpConfig.sideloadedKits)) {
|
|
7453
|
-
var
|
|
7542
|
+
var registeredSideloadedKits_1 = {
|
|
7454
7543
|
kits: {}
|
|
7455
7544
|
};
|
|
7456
7545
|
var unregisteredSideloadedKits = mpConfig.sideloadedKits;
|
|
@@ -7458,25 +7547,23 @@ var mParticle = (function () {
|
|
|
7458
7547
|
try {
|
|
7459
7548
|
// Register each sideloaded kit, which adds a key of the sideloaded kit name
|
|
7460
7549
|
// and a value of the sideloaded kit constructor.
|
|
7461
|
-
unregisteredKit.kitInstance.register(
|
|
7550
|
+
unregisteredKit.kitInstance.register(registeredSideloadedKits_1);
|
|
7462
7551
|
var kitName = unregisteredKit.kitInstance.name;
|
|
7463
7552
|
// Then add the kit filters to each registered kit.
|
|
7464
|
-
|
|
7553
|
+
registeredSideloadedKits_1.kits[kitName].filters = unregisteredKit.filterDictionary;
|
|
7465
7554
|
} catch (e) {
|
|
7466
7555
|
console.error('Error registering sideloaded kit ' + unregisteredKit.kitInstance.name);
|
|
7467
7556
|
}
|
|
7468
7557
|
});
|
|
7469
|
-
|
|
7470
7558
|
// Then configure each registered kit
|
|
7471
|
-
for (var registeredKitKey in
|
|
7472
|
-
var registeredKit =
|
|
7559
|
+
for (var registeredKitKey in registeredSideloadedKits_1.kits) {
|
|
7560
|
+
var registeredKit = registeredSideloadedKits_1.kits[registeredKitKey];
|
|
7473
7561
|
self.configureSideloadedKit(registeredKit);
|
|
7474
7562
|
}
|
|
7475
|
-
|
|
7476
7563
|
// If Sideloaded Kits are successfully registered,
|
|
7477
7564
|
// record this in the Store.
|
|
7478
|
-
if (!isEmpty(
|
|
7479
|
-
var kitKeys = Object.keys(
|
|
7565
|
+
if (!isEmpty(registeredSideloadedKits_1.kits)) {
|
|
7566
|
+
var kitKeys = Object.keys(registeredSideloadedKits_1.kits);
|
|
7480
7567
|
mpInstance._Store.sideloadedKitsCount = kitKeys.length;
|
|
7481
7568
|
}
|
|
7482
7569
|
}
|
|
@@ -7484,16 +7571,16 @@ var mParticle = (function () {
|
|
|
7484
7571
|
mpInstance.Logger.error('Sideloaded Kits not configured propertly. Kits may not be initialized. ' + e);
|
|
7485
7572
|
}
|
|
7486
7573
|
};
|
|
7487
|
-
|
|
7488
7574
|
// kits can be included via mParticle UI, or via sideloaded kit config API
|
|
7489
7575
|
this.configureSideloadedKit = function (kitConstructor) {
|
|
7490
7576
|
mpInstance._Store.configuredForwarders.push(this.returnConfiguredKit(kitConstructor, kitConstructor.filters));
|
|
7491
7577
|
};
|
|
7492
|
-
this.returnConfiguredKit = function (forwarder) {
|
|
7493
|
-
|
|
7578
|
+
this.returnConfiguredKit = function (forwarder, config) {
|
|
7579
|
+
if (config === void 0) {
|
|
7580
|
+
config = {};
|
|
7581
|
+
}
|
|
7494
7582
|
var newForwarder = new forwarder.constructor();
|
|
7495
7583
|
newForwarder.id = config.moduleId;
|
|
7496
|
-
|
|
7497
7584
|
// TODO: isSandbox, hasSandbox is never used in any kit or in core SDK.
|
|
7498
7585
|
// isVisible. Investigate is only used in 1 place. It is always true if
|
|
7499
7586
|
// it is sent to JS. Investigate further to determine if these can be removed.
|
|
@@ -7532,14 +7619,13 @@ var mParticle = (function () {
|
|
|
7532
7619
|
mpInstance.Logger.error('Cookie Sync configs not configured propertly. Cookie Sync may not be initialized. ' + e);
|
|
7533
7620
|
}
|
|
7534
7621
|
};
|
|
7535
|
-
this.sendSingleForwardingStatsToServer =
|
|
7536
|
-
|
|
7537
|
-
var _mpInstance$Logger;
|
|
7622
|
+
this.sendSingleForwardingStatsToServer = function (forwardingStatsData) {
|
|
7623
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
7538
7624
|
var fetchPayload, response, message;
|
|
7539
|
-
|
|
7540
|
-
|
|
7625
|
+
var _a;
|
|
7626
|
+
return __generator(this, function (_b) {
|
|
7627
|
+
switch (_b.label) {
|
|
7541
7628
|
case 0:
|
|
7542
|
-
// https://go.mparticle.com/work/SQDSDKS-6568
|
|
7543
7629
|
fetchPayload = {
|
|
7544
7630
|
method: 'post',
|
|
7545
7631
|
body: JSON.stringify(forwardingStatsData),
|
|
@@ -7548,10 +7634,9 @@ var mParticle = (function () {
|
|
|
7548
7634
|
'Content-Type': 'text/plain;charset=UTF-8'
|
|
7549
7635
|
}
|
|
7550
7636
|
};
|
|
7551
|
-
|
|
7552
|
-
|
|
7553
|
-
|
|
7554
|
-
response = _context.sent;
|
|
7637
|
+
return [4 /*yield*/, this.forwarderStatsUploader.upload(fetchPayload)];
|
|
7638
|
+
case 1:
|
|
7639
|
+
response = _b.sent();
|
|
7555
7640
|
// This is a fire and forget, so we only need to log the response based on the code, and not return any response body
|
|
7556
7641
|
if (response.status === 202) {
|
|
7557
7642
|
// https://go.mparticle.com/work/SQDSDKS-6670
|
|
@@ -7559,17 +7644,12 @@ var mParticle = (function () {
|
|
|
7559
7644
|
} else {
|
|
7560
7645
|
message = 'Issue with forwarding stats to mParticle Servers, received HTTP Code of ' + response.statusText;
|
|
7561
7646
|
}
|
|
7562
|
-
mpInstance === null || mpInstance === void 0
|
|
7563
|
-
|
|
7564
|
-
case "end":
|
|
7565
|
-
return _context.stop();
|
|
7647
|
+
(_a = mpInstance === null || mpInstance === void 0 ? void 0 : mpInstance.Logger) === null || _a === void 0 ? void 0 : _a.verbose(message);
|
|
7648
|
+
return [2 /*return*/];
|
|
7566
7649
|
}
|
|
7567
|
-
}
|
|
7568
|
-
})
|
|
7569
|
-
|
|
7570
|
-
return _ref.apply(this, arguments);
|
|
7571
|
-
};
|
|
7572
|
-
}();
|
|
7650
|
+
});
|
|
7651
|
+
});
|
|
7652
|
+
};
|
|
7573
7653
|
}
|
|
7574
7654
|
|
|
7575
7655
|
// TODO: This file is no longer the server model because the web SDK payload
|
|
@@ -7904,37 +7984,6 @@ var mParticle = (function () {
|
|
|
7904
7984
|
}
|
|
7905
7985
|
}
|
|
7906
7986
|
|
|
7907
|
-
function _toPrimitive(input, hint) {
|
|
7908
|
-
if (_typeof$1(input) !== "object" || input === null) return input;
|
|
7909
|
-
var prim = input[Symbol.toPrimitive];
|
|
7910
|
-
if (prim !== undefined) {
|
|
7911
|
-
var res = prim.call(input, hint || "default");
|
|
7912
|
-
if (_typeof$1(res) !== "object") return res;
|
|
7913
|
-
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
7914
|
-
}
|
|
7915
|
-
return (hint === "string" ? String : Number)(input);
|
|
7916
|
-
}
|
|
7917
|
-
|
|
7918
|
-
function _toPropertyKey(arg) {
|
|
7919
|
-
var key = _toPrimitive(arg, "string");
|
|
7920
|
-
return _typeof$1(key) === "symbol" ? key : String(key);
|
|
7921
|
-
}
|
|
7922
|
-
|
|
7923
|
-
function _defineProperty(obj, key, value) {
|
|
7924
|
-
key = _toPropertyKey(key);
|
|
7925
|
-
if (key in obj) {
|
|
7926
|
-
Object.defineProperty(obj, key, {
|
|
7927
|
-
value: value,
|
|
7928
|
-
enumerable: true,
|
|
7929
|
-
configurable: true,
|
|
7930
|
-
writable: true
|
|
7931
|
-
});
|
|
7932
|
-
} else {
|
|
7933
|
-
obj[key] = value;
|
|
7934
|
-
}
|
|
7935
|
-
return obj;
|
|
7936
|
-
}
|
|
7937
|
-
|
|
7938
7987
|
var AudienceManager = /** @class */function () {
|
|
7939
7988
|
function AudienceManager(userAudienceUrl, apiKey, logger) {
|
|
7940
7989
|
this.url = '';
|
|
@@ -8061,8 +8110,6 @@ var mParticle = (function () {
|
|
|
8061
8110
|
}
|
|
8062
8111
|
};
|
|
8063
8112
|
|
|
8064
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
8065
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
8066
8113
|
var Messages$2 = Constants.Messages,
|
|
8067
8114
|
HTTPCodes$2 = Constants.HTTPCodes,
|
|
8068
8115
|
FeatureFlags$1 = Constants.FeatureFlags,
|
|
@@ -8074,23 +8121,20 @@ var mParticle = (function () {
|
|
|
8074
8121
|
Login = IdentityMethods$1.Login,
|
|
8075
8122
|
Logout = IdentityMethods$1.Logout;
|
|
8076
8123
|
function Identity(mpInstance) {
|
|
8077
|
-
var
|
|
8078
|
-
getFeatureFlag =
|
|
8079
|
-
extend =
|
|
8124
|
+
var _a = mpInstance._Helpers,
|
|
8125
|
+
getFeatureFlag = _a.getFeatureFlag,
|
|
8126
|
+
extend = _a.extend;
|
|
8080
8127
|
var self = this;
|
|
8081
8128
|
this.idCache = null;
|
|
8082
8129
|
this.audienceManager = null;
|
|
8083
|
-
|
|
8084
8130
|
// https://go.mparticle.com/work/SQDSDKS-6353
|
|
8085
8131
|
this.IdentityRequest = {
|
|
8086
8132
|
preProcessIdentityRequest: function preProcessIdentityRequest(identityApiData, callback, method) {
|
|
8087
8133
|
mpInstance.Logger.verbose(Messages$2.InformationMessages.StartingLogEvent + ': ' + method);
|
|
8088
|
-
|
|
8089
8134
|
// First, remove any falsy identity values and warn about them
|
|
8090
8135
|
var removedFalsyIdentityData = mpInstance._Helpers.Validators.removeFalsyIdentityValues(identityApiData, mpInstance.Logger);
|
|
8091
|
-
|
|
8092
8136
|
// Normalize convenience aliases (email_sha256 → other, mobile_sha256 → other2)
|
|
8093
|
-
var cleanedIdentityApiData = removedFalsyIdentityData
|
|
8137
|
+
var cleanedIdentityApiData = (removedFalsyIdentityData === null || removedFalsyIdentityData === void 0 ? void 0 : removedFalsyIdentityData.userIdentities) ? __assign(__assign({}, removedFalsyIdentityData), {
|
|
8094
8138
|
userIdentities: normalizeUserIdentityKeys(removedFalsyIdentityData.userIdentities)
|
|
8095
8139
|
}) : removedFalsyIdentityData;
|
|
8096
8140
|
var identityValidationResult = mpInstance._Helpers.Validators.validateIdentities(cleanedIdentityApiData, method);
|
|
@@ -8102,7 +8146,7 @@ var mParticle = (function () {
|
|
|
8102
8146
|
};
|
|
8103
8147
|
}
|
|
8104
8148
|
if (callback && !mpInstance._Helpers.Validators.isFunction(callback)) {
|
|
8105
|
-
var error = 'The optional callback must be a function. You tried entering a(n) ' + _typeof
|
|
8149
|
+
var error = 'The optional callback must be a function. You tried entering a(n) ' + _typeof(callback);
|
|
8106
8150
|
mpInstance.Logger.error(error);
|
|
8107
8151
|
return {
|
|
8108
8152
|
valid: false,
|
|
@@ -8146,9 +8190,8 @@ var mParticle = (function () {
|
|
|
8146
8190
|
},
|
|
8147
8191
|
createIdentityChanges: function createIdentityChanges(previousIdentities, newIdentities) {
|
|
8148
8192
|
var identityChanges = [];
|
|
8149
|
-
var key;
|
|
8150
8193
|
if (newIdentities && isObject(newIdentities) && previousIdentities && isObject(previousIdentities)) {
|
|
8151
|
-
for (key in newIdentities) {
|
|
8194
|
+
for (var key in newIdentities) {
|
|
8152
8195
|
identityChanges.push({
|
|
8153
8196
|
old_value: previousIdentities[key] || null,
|
|
8154
8197
|
new_value: newIdentities[key],
|
|
@@ -8198,7 +8241,7 @@ var mParticle = (function () {
|
|
|
8198
8241
|
},
|
|
8199
8242
|
convertToNative: function convertToNative(identityApiData) {
|
|
8200
8243
|
var nativeIdentityRequest = [];
|
|
8201
|
-
if (identityApiData
|
|
8244
|
+
if (identityApiData === null || identityApiData === void 0 ? void 0 : identityApiData.userIdentities) {
|
|
8202
8245
|
for (var key in identityApiData.userIdentities) {
|
|
8203
8246
|
if (identityApiData.userIdentities.hasOwnProperty(key)) {
|
|
8204
8247
|
nativeIdentityRequest.push({
|
|
@@ -8211,6 +8254,7 @@ var mParticle = (function () {
|
|
|
8211
8254
|
UserIdentities: nativeIdentityRequest
|
|
8212
8255
|
};
|
|
8213
8256
|
}
|
|
8257
|
+
return undefined;
|
|
8214
8258
|
}
|
|
8215
8259
|
};
|
|
8216
8260
|
/**
|
|
@@ -8228,9 +8272,9 @@ var mParticle = (function () {
|
|
|
8228
8272
|
*/
|
|
8229
8273
|
identify: function identify(identityApiData, callback) {
|
|
8230
8274
|
// https://go.mparticle.com/work/SQDSDKS-6337
|
|
8231
|
-
var mpid
|
|
8232
|
-
|
|
8233
|
-
|
|
8275
|
+
var mpid;
|
|
8276
|
+
var currentUser = mpInstance.Identity.getCurrentUser();
|
|
8277
|
+
var preProcessResult = mpInstance._Identity.IdentityRequest.preProcessIdentityRequest(identityApiData, callback, Identify);
|
|
8234
8278
|
if (currentUser) {
|
|
8235
8279
|
mpid = currentUser.getMPID();
|
|
8236
8280
|
}
|
|
@@ -8266,29 +8310,30 @@ var mParticle = (function () {
|
|
|
8266
8310
|
*/
|
|
8267
8311
|
logout: function logout(identityApiData, callback) {
|
|
8268
8312
|
// https://go.mparticle.com/work/SQDSDKS-6337
|
|
8269
|
-
var mpid
|
|
8270
|
-
|
|
8271
|
-
|
|
8313
|
+
var mpid;
|
|
8314
|
+
var currentUser = mpInstance.Identity.getCurrentUser();
|
|
8315
|
+
var preProcessResult = mpInstance._Identity.IdentityRequest.preProcessIdentityRequest(identityApiData, callback, Logout);
|
|
8272
8316
|
if (currentUser) {
|
|
8273
8317
|
mpid = currentUser.getMPID();
|
|
8274
8318
|
}
|
|
8275
8319
|
if (preProcessResult.valid) {
|
|
8276
|
-
var
|
|
8277
|
-
|
|
8320
|
+
var evt_1;
|
|
8321
|
+
var identityApiRequest = mpInstance._Identity.IdentityRequest.createIdentityRequest(preProcessResult.cleanedIdentities, Constants.platform, Constants.sdkVendor, Constants.sdkVersion, mpInstance._Store.deviceId, mpInstance._Store.context, mpid);
|
|
8278
8322
|
if (mpInstance._Helpers.canLog()) {
|
|
8279
8323
|
if (mpInstance._Store.webviewBridgeEnabled) {
|
|
8280
8324
|
mpInstance._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Logout, JSON.stringify(mpInstance._Identity.IdentityRequest.convertToNative(identityApiData)));
|
|
8281
8325
|
mpInstance._Helpers.invokeCallback(callback, HTTPCodes$2.nativeIdentityRequest, 'Logout request sent to native sdk');
|
|
8282
8326
|
} else {
|
|
8283
8327
|
mpInstance._IdentityAPIClient.sendIdentityRequest(identityApiRequest, Logout, callback, identityApiData, self.parseIdentityResponse, mpid);
|
|
8284
|
-
|
|
8328
|
+
evt_1 = mpInstance._ServerModel.createEventObject({
|
|
8285
8329
|
messageType: Types.MessageType.Profile
|
|
8286
8330
|
});
|
|
8287
|
-
|
|
8331
|
+
evt_1.ProfileMessageType = Types.ProfileMessageType.Logout;
|
|
8288
8332
|
if (mpInstance._Store.activeForwarders.length) {
|
|
8289
8333
|
mpInstance._Store.activeForwarders.forEach(function (forwarder) {
|
|
8290
|
-
|
|
8291
|
-
|
|
8334
|
+
var kit = forwarder;
|
|
8335
|
+
if (kit.logOut) {
|
|
8336
|
+
kit.logOut(evt_1);
|
|
8292
8337
|
}
|
|
8293
8338
|
});
|
|
8294
8339
|
}
|
|
@@ -8310,9 +8355,9 @@ var mParticle = (function () {
|
|
|
8310
8355
|
*/
|
|
8311
8356
|
login: function login(identityApiData, callback) {
|
|
8312
8357
|
// https://go.mparticle.com/work/SQDSDKS-6337
|
|
8313
|
-
var mpid
|
|
8314
|
-
|
|
8315
|
-
|
|
8358
|
+
var mpid;
|
|
8359
|
+
var currentUser = mpInstance.Identity.getCurrentUser();
|
|
8360
|
+
var preProcessResult = mpInstance._Identity.IdentityRequest.preProcessIdentityRequest(identityApiData, callback, Login);
|
|
8316
8361
|
if (currentUser) {
|
|
8317
8362
|
mpid = currentUser.getMPID();
|
|
8318
8363
|
}
|
|
@@ -8348,21 +8393,21 @@ var mParticle = (function () {
|
|
|
8348
8393
|
*/
|
|
8349
8394
|
modify: function modify(identityApiData, callback) {
|
|
8350
8395
|
// https://go.mparticle.com/work/SQDSDKS-6337
|
|
8351
|
-
var mpid
|
|
8352
|
-
|
|
8353
|
-
|
|
8396
|
+
var mpid;
|
|
8397
|
+
var currentUser = mpInstance.Identity.getCurrentUser();
|
|
8398
|
+
var preProcessResult = mpInstance._Identity.IdentityRequest.preProcessIdentityRequest(identityApiData, callback, Modify$1);
|
|
8354
8399
|
if (currentUser) {
|
|
8355
8400
|
mpid = currentUser.getMPID();
|
|
8356
8401
|
}
|
|
8357
8402
|
if (preProcessResult.valid) {
|
|
8358
|
-
var newUserIdentities = identityApiData
|
|
8403
|
+
var newUserIdentities = (identityApiData === null || identityApiData === void 0 ? void 0 : identityApiData.userIdentities) ? preProcessResult.cleanedIdentities.userIdentities : {};
|
|
8359
8404
|
var identityApiRequest = mpInstance._Identity.IdentityRequest.createModifyIdentityRequest(currentUser ? currentUser.getUserIdentities().userIdentities : {}, newUserIdentities, Constants.platform, Constants.sdkVendor, Constants.sdkVersion, mpInstance._Store.context);
|
|
8360
8405
|
if (mpInstance._Helpers.canLog()) {
|
|
8361
8406
|
if (mpInstance._Store.webviewBridgeEnabled) {
|
|
8362
8407
|
mpInstance._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Modify, JSON.stringify(mpInstance._Identity.IdentityRequest.convertToNative(identityApiData)));
|
|
8363
8408
|
mpInstance._Helpers.invokeCallback(callback, HTTPCodes$2.nativeIdentityRequest, 'Modify request sent to native sdk');
|
|
8364
8409
|
} else {
|
|
8365
|
-
mpInstance._IdentityAPIClient.sendIdentityRequest(identityApiRequest, Modify$1, callback, identityApiData, self.parseIdentityResponse, mpid
|
|
8410
|
+
mpInstance._IdentityAPIClient.sendIdentityRequest(identityApiRequest, Modify$1, callback, identityApiData, self.parseIdentityResponse, mpid);
|
|
8366
8411
|
}
|
|
8367
8412
|
} else {
|
|
8368
8413
|
mpInstance._Helpers.invokeCallback(callback, HTTPCodes$2.loggingDisabledOrMissingAPIKey, Messages$2.InformationMessages.AbandonLogEvent);
|
|
@@ -8503,15 +8548,15 @@ var mParticle = (function () {
|
|
|
8503
8548
|
using the sourceUser's firstSeenTime as the startTime, and its lastSeenTime as the endTime.
|
|
8504
8549
|
|
|
8505
8550
|
In the unlikely scenario that the sourceUser does not have a firstSeenTime, which will only
|
|
8506
|
-
be the case if they have not been the current user since this functionality was added, the
|
|
8551
|
+
be the case if they have not been the current user since this functionality was added, the
|
|
8507
8552
|
startTime will be populated with the earliest firstSeenTime out of any stored user. Similarly,
|
|
8508
8553
|
if the sourceUser does not have a lastSeenTime, the endTime will be populated with the current time
|
|
8509
8554
|
|
|
8510
8555
|
There is a limit to how old the startTime can be, represented by the config field 'aliasMaxWindow', in days.
|
|
8511
|
-
If the startTime falls before the limit, it will be adjusted to the oldest allowed startTime.
|
|
8512
|
-
In rare cases, where the sourceUser's lastSeenTime also falls outside of the aliasMaxWindow limit,
|
|
8513
|
-
after applying this adjustment it will be impossible to create an aliasRequest passes the aliasUsers()
|
|
8514
|
-
validation that the startTime must be less than the endTime
|
|
8556
|
+
If the startTime falls before the limit, it will be adjusted to the oldest allowed startTime.
|
|
8557
|
+
In rare cases, where the sourceUser's lastSeenTime also falls outside of the aliasMaxWindow limit,
|
|
8558
|
+
after applying this adjustment it will be impossible to create an aliasRequest passes the aliasUsers()
|
|
8559
|
+
validation that the startTime must be less than the endTime
|
|
8515
8560
|
*/
|
|
8516
8561
|
createAliasRequest: function createAliasRequest(sourceUser, destinationUser, scope) {
|
|
8517
8562
|
try {
|
|
@@ -8519,27 +8564,27 @@ var mParticle = (function () {
|
|
|
8519
8564
|
mpInstance.Logger.error("'destinationUser' and 'sourceUser' must both be present");
|
|
8520
8565
|
return null;
|
|
8521
8566
|
}
|
|
8522
|
-
var
|
|
8523
|
-
if (!
|
|
8567
|
+
var startTime_1 = sourceUser.getFirstSeenTime();
|
|
8568
|
+
if (!startTime_1) {
|
|
8524
8569
|
mpInstance.Identity.getUsers().forEach(function (user) {
|
|
8525
|
-
if (user.getFirstSeenTime() && (!
|
|
8526
|
-
|
|
8570
|
+
if (user.getFirstSeenTime() && (!startTime_1 || user.getFirstSeenTime() < startTime_1)) {
|
|
8571
|
+
startTime_1 = user.getFirstSeenTime();
|
|
8527
8572
|
}
|
|
8528
8573
|
});
|
|
8529
8574
|
}
|
|
8530
8575
|
var minFirstSeenTimeMs = new Date().getTime() - mpInstance._Store.SDKConfig.aliasMaxWindow * 24 * 60 * 60 * 1000;
|
|
8531
8576
|
var endTime = sourceUser.getLastSeenTime() || new Date().getTime();
|
|
8532
8577
|
//if the startTime is greater than $maxAliasWindow ago, adjust the startTime to the earliest allowed
|
|
8533
|
-
if (
|
|
8534
|
-
|
|
8535
|
-
if (endTime <
|
|
8578
|
+
if (startTime_1 < minFirstSeenTimeMs) {
|
|
8579
|
+
startTime_1 = minFirstSeenTimeMs;
|
|
8580
|
+
if (endTime < startTime_1) {
|
|
8536
8581
|
mpInstance.Logger.warning('Source User has not been seen in the last ' + mpInstance._Store.SDKConfig.maxAliasWindow + ' days, Alias Request will likely fail');
|
|
8537
8582
|
}
|
|
8538
8583
|
}
|
|
8539
8584
|
return {
|
|
8540
8585
|
destinationMpid: destinationUser.getMPID(),
|
|
8541
8586
|
sourceMpid: sourceUser.getMPID(),
|
|
8542
|
-
startTime:
|
|
8587
|
+
startTime: startTime_1,
|
|
8543
8588
|
endTime: endTime,
|
|
8544
8589
|
scope: scope || 'device'
|
|
8545
8590
|
};
|
|
@@ -8549,7 +8594,6 @@ var mParticle = (function () {
|
|
|
8549
8594
|
}
|
|
8550
8595
|
}
|
|
8551
8596
|
};
|
|
8552
|
-
|
|
8553
8597
|
// https://go.mparticle.com/work/SQDSDKS-6354
|
|
8554
8598
|
/**
|
|
8555
8599
|
* Invoke these methods on the mParticle.Identity.getCurrentUser() object.
|
|
@@ -8557,7 +8601,6 @@ var mParticle = (function () {
|
|
|
8557
8601
|
* @class mParticle.Identity.getCurrentUser()
|
|
8558
8602
|
*/
|
|
8559
8603
|
this.mParticleUser = function (mpid, _isLoggedIn) {
|
|
8560
|
-
var self = this;
|
|
8561
8604
|
return {
|
|
8562
8605
|
/**
|
|
8563
8606
|
* Get user identities for current user
|
|
@@ -8634,8 +8677,8 @@ var mParticle = (function () {
|
|
|
8634
8677
|
}));
|
|
8635
8678
|
} else {
|
|
8636
8679
|
var userAttributes = this.getAllUserAttributes();
|
|
8637
|
-
var previousUserAttributeValue;
|
|
8638
|
-
var isNewAttribute;
|
|
8680
|
+
var previousUserAttributeValue = void 0;
|
|
8681
|
+
var isNewAttribute = void 0;
|
|
8639
8682
|
var existingProp = mpInstance._Helpers.findKeyInObject(userAttributes, key);
|
|
8640
8683
|
if (existingProp) {
|
|
8641
8684
|
isNewAttribute = false;
|
|
@@ -8669,7 +8712,7 @@ var mParticle = (function () {
|
|
|
8669
8712
|
}
|
|
8670
8713
|
}
|
|
8671
8714
|
} else {
|
|
8672
|
-
mpInstance.Logger.error('Must pass an object into setUserAttributes. You passed a ' + _typeof
|
|
8715
|
+
mpInstance.Logger.error('Must pass an object into setUserAttributes. You passed a ' + _typeof(userAttributes));
|
|
8673
8716
|
}
|
|
8674
8717
|
},
|
|
8675
8718
|
/**
|
|
@@ -8678,7 +8721,8 @@ var mParticle = (function () {
|
|
|
8678
8721
|
* @param {String} key
|
|
8679
8722
|
*/
|
|
8680
8723
|
removeUserAttribute: function removeUserAttribute(key) {
|
|
8681
|
-
var cookies
|
|
8724
|
+
var cookies;
|
|
8725
|
+
var userAttributes;
|
|
8682
8726
|
mpInstance._SessionManager.resetSessionTimer();
|
|
8683
8727
|
if (!mpInstance._Helpers.Validators.isValidKeyValue(key)) {
|
|
8684
8728
|
mpInstance.Logger.error(Messages$2.ErrorMessages.BadKey);
|
|
@@ -8700,7 +8744,7 @@ var mParticle = (function () {
|
|
|
8700
8744
|
delete userAttributes[key];
|
|
8701
8745
|
if (cookies && cookies[mpid]) {
|
|
8702
8746
|
cookies[mpid].ua = userAttributes;
|
|
8703
|
-
mpInstance._Persistence.savePersistence(cookies
|
|
8747
|
+
mpInstance._Persistence.savePersistence(cookies);
|
|
8704
8748
|
}
|
|
8705
8749
|
self.sendUserAttributeChangeEvent(key, null, deletedUAKeyCopy, false, true, this);
|
|
8706
8750
|
mpInstance._Forwarders.initForwarders(self.IdentityAPI.getCurrentUser().getUserIdentities(), mpInstance._APIClient.prepareForwardingStats);
|
|
@@ -8721,7 +8765,7 @@ var mParticle = (function () {
|
|
|
8721
8765
|
return;
|
|
8722
8766
|
}
|
|
8723
8767
|
if (!Array.isArray(newValue)) {
|
|
8724
|
-
mpInstance.Logger.error('The value you passed in to setUserAttributeList must be an array. You passed in a ' +
|
|
8768
|
+
mpInstance.Logger.error('The value you passed in to setUserAttributeList must be an array. You passed in a ' + _typeof(newValue));
|
|
8725
8769
|
return;
|
|
8726
8770
|
}
|
|
8727
8771
|
var arrayCopy = newValue.slice();
|
|
@@ -8732,9 +8776,9 @@ var mParticle = (function () {
|
|
|
8732
8776
|
}));
|
|
8733
8777
|
} else {
|
|
8734
8778
|
var userAttributes = this.getAllUserAttributes();
|
|
8735
|
-
var previousUserAttributeValue;
|
|
8736
|
-
var isNewAttribute;
|
|
8737
|
-
var userAttributeChange;
|
|
8779
|
+
var previousUserAttributeValue = void 0;
|
|
8780
|
+
var isNewAttribute = void 0;
|
|
8781
|
+
var userAttributeChange = void 0;
|
|
8738
8782
|
var existingProp = mpInstance._Helpers.findKeyInObject(userAttributes, key);
|
|
8739
8783
|
if (existingProp) {
|
|
8740
8784
|
isNewAttribute = false;
|
|
@@ -8745,7 +8789,6 @@ var mParticle = (function () {
|
|
|
8745
8789
|
}
|
|
8746
8790
|
userAttributes[key] = arrayCopy;
|
|
8747
8791
|
mpInstance._Store.setUserAttributes(mpid, userAttributes);
|
|
8748
|
-
|
|
8749
8792
|
// If the new attributeList length is different than the previous, then there is a change event.
|
|
8750
8793
|
// Loop through new attributes list, see if they are all in the same index as previous user attributes list
|
|
8751
8794
|
// If there are any changes, break, and immediately send a userAttributeChangeEvent with full array as a value
|
|
@@ -8796,8 +8839,8 @@ var mParticle = (function () {
|
|
|
8796
8839
|
* @return {Object} an object of only keys with array values. Example: { attr1: [1, 2, 3], attr2: ['a', 'b', 'c'] }
|
|
8797
8840
|
*/
|
|
8798
8841
|
getUserAttributesLists: function getUserAttributesLists() {
|
|
8799
|
-
var userAttributes
|
|
8800
|
-
|
|
8842
|
+
var userAttributes;
|
|
8843
|
+
var userAttributesLists = {};
|
|
8801
8844
|
userAttributes = this.getAllUserAttributes();
|
|
8802
8845
|
for (var key in userAttributes) {
|
|
8803
8846
|
if (userAttributes.hasOwnProperty(key) && Array.isArray(userAttributes[key])) {
|
|
@@ -8818,10 +8861,11 @@ var mParticle = (function () {
|
|
|
8818
8861
|
if (userAttributes) {
|
|
8819
8862
|
for (var prop in userAttributes) {
|
|
8820
8863
|
if (userAttributes.hasOwnProperty(prop)) {
|
|
8821
|
-
|
|
8822
|
-
|
|
8864
|
+
var attrValue = userAttributes[prop];
|
|
8865
|
+
if (Array.isArray(attrValue)) {
|
|
8866
|
+
userAttributesCopy[prop] = attrValue.slice();
|
|
8823
8867
|
} else {
|
|
8824
|
-
userAttributesCopy[prop] =
|
|
8868
|
+
userAttributesCopy[prop] = attrValue;
|
|
8825
8869
|
}
|
|
8826
8870
|
}
|
|
8827
8871
|
}
|
|
@@ -8880,13 +8924,12 @@ var mParticle = (function () {
|
|
|
8880
8924
|
return;
|
|
8881
8925
|
}
|
|
8882
8926
|
if (self.audienceManager === null) {
|
|
8883
|
-
self.audienceManager = new AudienceManager(mpInstance._Store.SDKConfig.userAudienceUrl, mpInstance._Store.devToken, mpInstance.Logger
|
|
8927
|
+
self.audienceManager = new AudienceManager(mpInstance._Store.SDKConfig.userAudienceUrl, mpInstance._Store.devToken, mpInstance.Logger);
|
|
8884
8928
|
}
|
|
8885
8929
|
self.audienceManager.sendGetUserAudienceRequest(mpid, callback);
|
|
8886
8930
|
}
|
|
8887
8931
|
};
|
|
8888
8932
|
};
|
|
8889
|
-
|
|
8890
8933
|
/**
|
|
8891
8934
|
* Invoke these methods on the mParticle.Identity.getCurrentUser().getCart() object.
|
|
8892
8935
|
* Example: mParticle.Identity.getCurrentUser().getCart().add(...);
|
|
@@ -8943,9 +8986,9 @@ var mParticle = (function () {
|
|
|
8943
8986
|
}
|
|
8944
8987
|
};
|
|
8945
8988
|
};
|
|
8946
|
-
|
|
8947
8989
|
// https://go.mparticle.com/work/SQDSDKS-6355
|
|
8948
8990
|
this.parseIdentityResponse = function (identityResponse, previousMPID, callback, identityApiData, method, knownIdentities, parsingCachedResponse) {
|
|
8991
|
+
var _a, _b, _c;
|
|
8949
8992
|
var prevUser = mpInstance.Identity.getUser(previousMPID);
|
|
8950
8993
|
var prevUserMPID = prevUser ? prevUser.getMPID() : null;
|
|
8951
8994
|
var previousUIByName = prevUser ? prevUser.getUserIdentities().userIdentities : {};
|
|
@@ -8955,11 +8998,9 @@ var mParticle = (function () {
|
|
|
8955
8998
|
var newIdentitiesByType = {};
|
|
8956
8999
|
mpInstance._Store.identityCallInFlight = false;
|
|
8957
9000
|
try {
|
|
8958
|
-
var _identityResponse$res, _identityApiResult, _mpInstance$_APIClien;
|
|
8959
9001
|
mpInstance.Logger.verbose('Parsing "' + method + '" identity response from server');
|
|
8960
|
-
identityApiResult = (
|
|
8961
|
-
mpInstance._Store.isLoggedIn = (
|
|
8962
|
-
|
|
9002
|
+
identityApiResult = (_a = identityResponse.responseText) !== null && _a !== void 0 ? _a : null;
|
|
9003
|
+
mpInstance._Store.isLoggedIn = (identityApiResult === null || identityApiResult === void 0 ? void 0 : identityApiResult.is_logged_in) || false;
|
|
8963
9004
|
// https://go.mparticle.com/work/SQDSDKS-6504
|
|
8964
9005
|
// set currentUser
|
|
8965
9006
|
if (hasMPIDChanged(prevUser, identityApiResult)) {
|
|
@@ -8969,12 +9010,10 @@ var mParticle = (function () {
|
|
|
8969
9010
|
mpInstance._Persistence.setLastSeenTime(previousMPID);
|
|
8970
9011
|
}
|
|
8971
9012
|
mpidIsNotInCookies = !mpInstance._Persistence.getFirstSeenTime(identityApiResult.mpid);
|
|
8972
|
-
|
|
8973
9013
|
// https://go.mparticle.com/work/SQDSDKS-6329
|
|
8974
9014
|
mpInstance._Persistence.setFirstSeenTime(identityApiResult.mpid);
|
|
8975
9015
|
}
|
|
8976
9016
|
if (identityResponse.status === HTTP_OK) {
|
|
8977
|
-
var _mpInstance$_CookieCo;
|
|
8978
9017
|
if (getFeatureFlag(CacheIdentity)) {
|
|
8979
9018
|
cacheOrClearIdCache(method, knownIdentities, self.idCache, identityResponse, parsingCachedResponse);
|
|
8980
9019
|
}
|
|
@@ -8998,18 +9037,15 @@ var mParticle = (function () {
|
|
|
8998
9037
|
if (identityApiData && !isEmpty(identityApiData.userIdentities)) {
|
|
8999
9038
|
newIdentitiesByType = self.IdentityRequest.combineUserIdentities(incomingUIByName, identityApiData.userIdentities);
|
|
9000
9039
|
}
|
|
9001
|
-
|
|
9002
9040
|
// https://go.mparticle.com/work/SQDSDKS-6041
|
|
9003
9041
|
mpInstance._Store.setUserIdentities(identityApiResult.mpid, newIdentitiesByType);
|
|
9004
9042
|
mpInstance._Persistence.update();
|
|
9005
9043
|
mpInstance._Store.syncPersistenceData();
|
|
9006
9044
|
mpInstance._Persistence.findPrevCookiesBasedOnUI(identityApiData);
|
|
9007
|
-
|
|
9008
9045
|
// https://go.mparticle.com/work/SQDSDKS-6357
|
|
9009
9046
|
mpInstance._Store.context = identityApiResult.context || mpInstance._Store.context;
|
|
9010
9047
|
}
|
|
9011
9048
|
newUser = mpInstance.Identity.getCurrentUser();
|
|
9012
|
-
|
|
9013
9049
|
// https://go.mparticle.com/work/SQDSDKS-6359
|
|
9014
9050
|
tryOnUserAlias(prevUser, newUser, identityApiData, mpInstance.Logger, mpInstance._ErrorReportingDispatcher);
|
|
9015
9051
|
var persistence = mpInstance._Persistence.getPersistence();
|
|
@@ -9020,14 +9056,12 @@ var mParticle = (function () {
|
|
|
9020
9056
|
}
|
|
9021
9057
|
var newIdentitiesByName = IdentityType.getNewIdentitiesByName(newIdentitiesByType);
|
|
9022
9058
|
var uiByName = method === Modify$1 ? previousUIByName : incomingUIByName;
|
|
9023
|
-
|
|
9024
9059
|
// Sync $NoTargeting before sendUserIdentityChangeEvent
|
|
9025
9060
|
// because UIC events call sendEventToServer which triggers
|
|
9026
9061
|
// processQueuedEvents, draining the event queue. The
|
|
9027
9062
|
// attribute must be in the store before that happens so
|
|
9028
9063
|
// appendUserInfo picks it up.
|
|
9029
|
-
(
|
|
9030
|
-
|
|
9064
|
+
(_b = mpInstance._CookieConsentManager) === null || _b === void 0 ? void 0 : _b.syncNoTargetingAttribute(newUser);
|
|
9031
9065
|
// https://go.mparticle.com/work/SQDSDKS-6501
|
|
9032
9066
|
self.sendUserIdentityChangeEvent(newIdentitiesByName, method, identityApiResult.mpid, uiByName);
|
|
9033
9067
|
}
|
|
@@ -9039,9 +9073,8 @@ var mParticle = (function () {
|
|
|
9039
9073
|
mpInstance.Logger.error('Received HTTP response code of ' + identityResponse.status + ' - ' + identityApiResult.errors[0].message);
|
|
9040
9074
|
}
|
|
9041
9075
|
mpInstance.Logger.verbose('Successfully parsed Identity Response');
|
|
9042
|
-
|
|
9043
9076
|
// https://go.mparticle.com/work/SQDSDKS-6654
|
|
9044
|
-
(
|
|
9077
|
+
(_c = mpInstance._APIClient) === null || _c === void 0 ? void 0 : _c.processQueuedEvents();
|
|
9045
9078
|
} catch (e) {
|
|
9046
9079
|
if (callback) {
|
|
9047
9080
|
mpInstance._Helpers.invokeCallback(callback, identityResponse.status, identityApiResult || null);
|
|
@@ -9052,36 +9085,33 @@ var mParticle = (function () {
|
|
|
9052
9085
|
mpInstance._RoktManager.onIdentityComplete();
|
|
9053
9086
|
mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue, mpInstance.Logger);
|
|
9054
9087
|
};
|
|
9055
|
-
|
|
9056
9088
|
// send a user identity change request on identify, login, logout, modify when any values change.
|
|
9057
9089
|
// compare what identities exist vs what is previously was for the specific user if they were in memory before.
|
|
9058
9090
|
// if it's the first time the user is logging in, send a user identity change request with
|
|
9059
9091
|
this.sendUserIdentityChangeEvent = function (newUserIdentities, method, mpid, prevUserIdentities) {
|
|
9092
|
+
var _a;
|
|
9060
9093
|
if (!mpid) {
|
|
9061
9094
|
// https://go.mparticle.com/work/SQDSDKS-6501
|
|
9062
9095
|
if (method !== Modify$1) {
|
|
9063
9096
|
return;
|
|
9064
9097
|
}
|
|
9065
9098
|
}
|
|
9066
|
-
|
|
9067
9099
|
// https://go.mparticle.com/work/SQDSDKS-6354
|
|
9068
9100
|
var currentUserInMemory = this.IdentityAPI.getUser(mpid);
|
|
9069
9101
|
for (var identityType in newUserIdentities) {
|
|
9070
9102
|
// Verifies a change actually happened
|
|
9071
9103
|
if (prevUserIdentities[identityType] !== newUserIdentities[identityType]) {
|
|
9072
|
-
var _mpInstance$_APIClien2;
|
|
9073
9104
|
// If a new identity type was introduced when the identity changes
|
|
9074
9105
|
// we need to notify the server so that the user profile is updated in
|
|
9075
9106
|
// the mParticle UI.
|
|
9076
9107
|
var isNewUserIdentityType = !prevUserIdentities[identityType];
|
|
9077
9108
|
var userIdentityChangeEvent = self.createUserIdentityChange(identityType, newUserIdentities[identityType], prevUserIdentities[identityType], isNewUserIdentityType, currentUserInMemory);
|
|
9078
|
-
(
|
|
9109
|
+
(_a = mpInstance._APIClient) === null || _a === void 0 ? void 0 : _a.sendEventToServer(userIdentityChangeEvent);
|
|
9079
9110
|
}
|
|
9080
9111
|
}
|
|
9081
9112
|
};
|
|
9082
9113
|
this.createUserIdentityChange = function (identityType, newIdentity, oldIdentity, isIdentityTypeNewToBatch, userInMemory) {
|
|
9083
9114
|
var userIdentityChangeEvent;
|
|
9084
|
-
|
|
9085
9115
|
// https://go.mparticle.com/work/SQDSDKS-6439
|
|
9086
9116
|
userIdentityChangeEvent = mpInstance._ServerModel.createEventObject({
|
|
9087
9117
|
messageType: Types.MessageType.UserIdentityChange,
|
|
@@ -9102,10 +9132,10 @@ var mParticle = (function () {
|
|
|
9102
9132
|
return userIdentityChangeEvent;
|
|
9103
9133
|
};
|
|
9104
9134
|
this.sendUserAttributeChangeEvent = function (attributeKey, newUserAttributeValue, previousUserAttributeValue, isNewAttribute, deleted, user) {
|
|
9135
|
+
var _a;
|
|
9105
9136
|
var userAttributeChangeEvent = self.createUserAttributeChange(attributeKey, newUserAttributeValue, previousUserAttributeValue, isNewAttribute, deleted, user);
|
|
9106
9137
|
if (userAttributeChangeEvent) {
|
|
9107
|
-
|
|
9108
|
-
(_mpInstance$_APIClien3 = mpInstance._APIClient) === null || _mpInstance$_APIClien3 === void 0 || _mpInstance$_APIClien3.sendEventToServer(userAttributeChangeEvent);
|
|
9138
|
+
(_a = mpInstance._APIClient) === null || _a === void 0 ? void 0 : _a.sendEventToServer(userAttributeChangeEvent);
|
|
9109
9139
|
}
|
|
9110
9140
|
};
|
|
9111
9141
|
this.createUserAttributeChange = function (key, newValue, previousUserAttributeValue, isNewAttribute, deleted, user) {
|
|
@@ -9129,20 +9159,19 @@ var mParticle = (function () {
|
|
|
9129
9159
|
return userAttributeChangeEvent;
|
|
9130
9160
|
};
|
|
9131
9161
|
this.reinitForwardersOnUserChange = function (prevUser, newUser) {
|
|
9162
|
+
var _a;
|
|
9132
9163
|
if (hasMPIDAndUserLoginChanged(prevUser, newUser)) {
|
|
9133
|
-
|
|
9134
|
-
(_mpInstance$_Forwarde = mpInstance._Forwarders) === null || _mpInstance$_Forwarde === void 0 || _mpInstance$_Forwarde.initForwarders(newUser.getUserIdentities().userIdentities, mpInstance._APIClient.prepareForwardingStats);
|
|
9164
|
+
(_a = mpInstance._Forwarders) === null || _a === void 0 ? void 0 : _a.initForwarders(newUser.getUserIdentities().userIdentities, mpInstance._APIClient.prepareForwardingStats);
|
|
9135
9165
|
}
|
|
9136
9166
|
};
|
|
9137
9167
|
this.setForwarderCallbacks = function (user, method) {
|
|
9138
|
-
var
|
|
9168
|
+
var _a, _b, _c;
|
|
9139
9169
|
// https://go.mparticle.com/work/SQDSDKS-6036
|
|
9140
|
-
(
|
|
9141
|
-
(
|
|
9142
|
-
(
|
|
9170
|
+
(_a = mpInstance._Forwarders) === null || _a === void 0 ? void 0 : _a.setForwarderUserIdentities(user.getUserIdentities().userIdentities);
|
|
9171
|
+
(_b = mpInstance._Forwarders) === null || _b === void 0 ? void 0 : _b.setForwarderOnIdentityComplete(user, method);
|
|
9172
|
+
(_c = mpInstance._Forwarders) === null || _c === void 0 ? void 0 : _c.setForwarderOnUserIdentified(user);
|
|
9143
9173
|
};
|
|
9144
9174
|
}
|
|
9145
|
-
|
|
9146
9175
|
// https://go.mparticle.com/work/SQDSDKS-6359
|
|
9147
9176
|
function tryOnUserAlias(previousUser, newUser, identityApiData, logger, errorReporter) {
|
|
9148
9177
|
if (identityApiData && identityApiData.onUserAlias && isFunction(identityApiData.onUserAlias)) {
|
|
@@ -9860,7 +9889,7 @@ var mParticle = (function () {
|
|
|
9860
9889
|
if (typeof matchedAttributes === 'boolean' && matchedAttributes) {
|
|
9861
9890
|
return false;
|
|
9862
9891
|
}
|
|
9863
|
-
if (_typeof
|
|
9892
|
+
if (_typeof(matchedAttributes) === "object") {
|
|
9864
9893
|
if (matchedAttributes[key] === true) {
|
|
9865
9894
|
return false;
|
|
9866
9895
|
} else {
|
|
@@ -10763,767 +10792,434 @@ var mParticle = (function () {
|
|
|
10763
10792
|
if (finalUserIdentities.email && !enrichedAttributes.email) {
|
|
10764
10793
|
enrichedAttributes.email = finalUserIdentities.email;
|
|
10765
10794
|
}
|
|
10766
|
-
// Propagate emailsha256 from current user identities if not already in attributes
|
|
10767
|
-
if (isValidHashedEmailIdentityType) {
|
|
10768
|
-
hashedEmail = finalUserIdentities[this.mappedEmailShaIdentityType];
|
|
10769
|
-
if (hashedEmail && !enrichedAttributes.emailsha256 && !enrichedAttributes[this.mappedEmailShaIdentityType]) {
|
|
10770
|
-
enrichedAttributes.emailsha256 = hashedEmail;
|
|
10771
|
-
}
|
|
10772
|
-
}
|
|
10773
|
-
if (!enrichedAttributes[PASSBACK_CONVERSION_TRACKING_ID]) {
|
|
10774
|
-
(_p = this.integrationCapture) === null || _p === void 0 ? void 0 : _p.capture();
|
|
10775
|
-
capturedAttrs = (_q = this.integrationCapture) === null || _q === void 0 ? void 0 : _q.getClickIdsAsIntegrationAttributes();
|
|
10776
|
-
passbackId = (_r = capturedAttrs === null || capturedAttrs === void 0 ? void 0 : capturedAttrs[PARTNER_MODULE_IDS.Rokt]) === null || _r === void 0 ? void 0 : _r[PASSBACK_CONVERSION_TRACKING_ID];
|
|
10777
|
-
if (passbackId) {
|
|
10778
|
-
enrichedAttributes[PASSBACK_CONVERSION_TRACKING_ID] = passbackId;
|
|
10779
|
-
}
|
|
10780
|
-
}
|
|
10781
|
-
this.filters.filteredUser = this.currentUser || this.filters.filteredUser || null;
|
|
10782
|
-
enrichedOptions = __assign(__assign({}, options), {
|
|
10783
|
-
attributes: enrichedAttributes
|
|
10784
|
-
});
|
|
10785
|
-
return [2 /*return*/, this.kit.selectPlacements(enrichedOptions)];
|
|
10786
|
-
} catch (error) {
|
|
10787
|
-
return [2 /*return*/, Promise.reject(error instanceof Error ? error : new Error('Unknown error occurred'))];
|
|
10788
|
-
}
|
|
10789
|
-
return [2 /*return*/];
|
|
10790
|
-
});
|
|
10791
|
-
});
|
|
10792
|
-
};
|
|
10793
|
-
/**
|
|
10794
|
-
* Hashes attributes and returns both original and hashed versions
|
|
10795
|
-
* with Rokt-compatible key names (like emailsha256, mobilesha256)
|
|
10796
|
-
*
|
|
10797
|
-
*
|
|
10798
|
-
* @param {RoktAttributes} attributes - Attributes to hash
|
|
10799
|
-
* @returns {Promise<RoktAttributes>} Object with both original and hashed attributes
|
|
10800
|
-
*
|
|
10801
|
-
*/
|
|
10802
|
-
RoktManager.prototype.hashAttributes = function (attributes) {
|
|
10803
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
10804
|
-
var keys, hashPromises, results, hashedAttributes, _i, results_1, _a, key, attributeValue, hashedValue, error_1;
|
|
10805
|
-
var _this = this;
|
|
10806
|
-
return __generator(this, function (_b) {
|
|
10807
|
-
switch (_b.label) {
|
|
10808
|
-
case 0:
|
|
10809
|
-
_b.trys.push([0, 2,, 3]);
|
|
10810
|
-
if (!attributes || _typeof$1(attributes) !== 'object') {
|
|
10811
|
-
return [2 /*return*/, {}];
|
|
10812
|
-
}
|
|
10813
|
-
keys = Object.keys(attributes);
|
|
10814
|
-
if (keys.length === 0) {
|
|
10815
|
-
return [2 /*return*/, {}];
|
|
10816
|
-
}
|
|
10817
|
-
hashPromises = keys.map(function (key) {
|
|
10818
|
-
return __awaiter(_this, void 0, void 0, function () {
|
|
10819
|
-
var attributeValue, hashedValue;
|
|
10820
|
-
return __generator(this, function (_a) {
|
|
10821
|
-
switch (_a.label) {
|
|
10822
|
-
case 0:
|
|
10823
|
-
attributeValue = attributes[key];
|
|
10824
|
-
return [4 /*yield*/, this.hashSha256(attributeValue)];
|
|
10825
|
-
case 1:
|
|
10826
|
-
hashedValue = _a.sent();
|
|
10827
|
-
return [2 /*return*/, {
|
|
10828
|
-
key: key,
|
|
10829
|
-
attributeValue: attributeValue,
|
|
10830
|
-
hashedValue: hashedValue
|
|
10831
|
-
}];
|
|
10832
|
-
}
|
|
10833
|
-
});
|
|
10834
|
-
});
|
|
10835
|
-
});
|
|
10836
|
-
return [4 /*yield*/, Promise.all(hashPromises)];
|
|
10837
|
-
case 1:
|
|
10838
|
-
results = _b.sent();
|
|
10839
|
-
hashedAttributes = {};
|
|
10840
|
-
for (_i = 0, results_1 = results; _i < results_1.length; _i++) {
|
|
10841
|
-
_a = results_1[_i], key = _a.key, attributeValue = _a.attributeValue, hashedValue = _a.hashedValue;
|
|
10842
|
-
hashedAttributes[key] = attributeValue;
|
|
10843
|
-
if (hashedValue) {
|
|
10844
|
-
hashedAttributes["".concat(key, "sha256")] = hashedValue;
|
|
10845
|
-
}
|
|
10846
|
-
}
|
|
10847
|
-
return [2 /*return*/, hashedAttributes];
|
|
10848
|
-
case 2:
|
|
10849
|
-
error_1 = _b.sent();
|
|
10850
|
-
this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(getErrorMessage(error_1)));
|
|
10851
|
-
return [2 /*return*/, {}];
|
|
10852
|
-
case 3:
|
|
10853
|
-
return [2 /*return*/];
|
|
10854
|
-
}
|
|
10855
|
-
});
|
|
10856
|
-
});
|
|
10857
|
-
};
|
|
10858
|
-
|
|
10859
|
-
RoktManager.prototype.setExtensionData = function (extensionData) {
|
|
10860
|
-
if (!this.isReady()) {
|
|
10861
|
-
this.deferredCall('setExtensionData', extensionData);
|
|
10862
|
-
return;
|
|
10863
|
-
}
|
|
10864
|
-
try {
|
|
10865
|
-
this.kit.setExtensionData(extensionData);
|
|
10866
|
-
} catch (error) {
|
|
10867
|
-
throw new Error('Error setting extension data: ' + getErrorMessage(error));
|
|
10868
|
-
}
|
|
10869
|
-
};
|
|
10870
|
-
RoktManager.prototype.use = function (name) {
|
|
10871
|
-
if (!this.isReady()) {
|
|
10872
|
-
return this.deferredCall('use', name);
|
|
10873
|
-
}
|
|
10874
|
-
try {
|
|
10875
|
-
return this.kit.use(name);
|
|
10876
|
-
} catch (error) {
|
|
10877
|
-
return Promise.reject(error instanceof Error ? error : new Error('Error using extension: ' + name));
|
|
10878
|
-
}
|
|
10879
|
-
};
|
|
10880
|
-
RoktManager.prototype.onShoppableAdsReady = function (callback) {
|
|
10881
|
-
if (!this.kit || !this.isShoppableAdsLoaded) {
|
|
10882
|
-
this.deferredCall('onShoppableAdsReady', callback);
|
|
10883
|
-
return;
|
|
10884
|
-
}
|
|
10885
|
-
try {
|
|
10886
|
-
this.kit.onShoppableAdsReady(callback);
|
|
10887
|
-
} catch (error) {
|
|
10888
|
-
this.logger.error("Failed to register onShoppableAdsReady callback: ".concat(getErrorMessage(error)));
|
|
10889
|
-
}
|
|
10890
|
-
};
|
|
10891
|
-
RoktManager.prototype.flushOnShoppableAdsReadyMessageQueue = function (kit) {
|
|
10892
|
-
var _this = this;
|
|
10893
|
-
this.kit = kit;
|
|
10894
|
-
this.messageQueue.forEach(function (message, key) {
|
|
10895
|
-
var _a;
|
|
10896
|
-
if (message.methodName === ON_SHOPPABLE_ADS_READY_METHOD) {
|
|
10897
|
-
try {
|
|
10898
|
-
kit.onShoppableAdsReady(message.payload);
|
|
10899
|
-
} catch (e) {
|
|
10900
|
-
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error('RoktManager: Error flushing onShoppableAdsReady: ' + e);
|
|
10901
|
-
}
|
|
10902
|
-
_this.messageQueue["delete"](key);
|
|
10903
|
-
}
|
|
10904
|
-
});
|
|
10905
|
-
this.isShoppableAdsLoaded = true;
|
|
10906
|
-
};
|
|
10907
|
-
/**
|
|
10908
|
-
* Hashes an attribute using SHA-256
|
|
10909
|
-
*
|
|
10910
|
-
* @param {string | number | boolean | undefined | null} attribute - The value to hash
|
|
10911
|
-
* @returns {Promise<string | undefined | null>} SHA-256 hashed value or undefined/null
|
|
10912
|
-
*
|
|
10913
|
-
*/
|
|
10914
|
-
RoktManager.prototype.hashSha256 = function (attribute) {
|
|
10915
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
10916
|
-
var normalizedValue, error_2;
|
|
10917
|
-
return __generator(this, function (_a) {
|
|
10918
|
-
switch (_a.label) {
|
|
10919
|
-
case 0:
|
|
10920
|
-
if (attribute === null || attribute === undefined) {
|
|
10921
|
-
this.logger.warning("hashSha256 received null/undefined as input");
|
|
10922
|
-
return [2 /*return*/, attribute];
|
|
10923
|
-
}
|
|
10924
|
-
_a.label = 1;
|
|
10925
|
-
case 1:
|
|
10926
|
-
_a.trys.push([1, 3,, 4]);
|
|
10927
|
-
normalizedValue = String(attribute).trim().toLocaleLowerCase();
|
|
10928
|
-
return [4 /*yield*/, this.sha256Hex(normalizedValue)];
|
|
10929
|
-
case 2:
|
|
10930
|
-
return [2 /*return*/, _a.sent()];
|
|
10931
|
-
case 3:
|
|
10932
|
-
error_2 = _a.sent();
|
|
10933
|
-
this.logger.error("Failed to hashSha256, returning undefined: ".concat(getErrorMessage(error_2)));
|
|
10934
|
-
return [2 /*return*/, undefined];
|
|
10935
|
-
case 4:
|
|
10936
|
-
return [2 /*return*/];
|
|
10937
|
-
}
|
|
10938
|
-
});
|
|
10939
|
-
});
|
|
10940
|
-
};
|
|
10941
|
-
|
|
10942
|
-
RoktManager.prototype.getLocalSessionAttributes = function () {
|
|
10943
|
-
return this.store.getLocalSessionAttributes();
|
|
10944
|
-
};
|
|
10945
|
-
RoktManager.prototype.setLocalSessionAttribute = function (key, value) {
|
|
10946
|
-
this.store.setLocalSessionAttribute(key, value);
|
|
10947
|
-
};
|
|
10948
|
-
RoktManager.prototype.isReady = function () {
|
|
10949
|
-
// The Rokt Manager is ready when a kit is attached and has a launcher
|
|
10950
|
-
return Boolean(this.kit && this.kit.launcher);
|
|
10951
|
-
};
|
|
10952
|
-
RoktManager.prototype.setUserAttributes = function (attributes) {
|
|
10953
|
-
var reservedAttributes = ['sandbox'];
|
|
10954
|
-
var filteredAttributes = {};
|
|
10955
|
-
for (var key in attributes) {
|
|
10956
|
-
if (attributes.hasOwnProperty(key) && reservedAttributes.indexOf(key) === -1) {
|
|
10957
|
-
var value = attributes[key];
|
|
10958
|
-
filteredAttributes[key] = Array.isArray(value) ? JSON.stringify(value) : value;
|
|
10959
|
-
}
|
|
10960
|
-
}
|
|
10961
|
-
try {
|
|
10962
|
-
this.currentUser.setUserAttributes(filteredAttributes);
|
|
10963
|
-
} catch (error) {
|
|
10964
|
-
this.logger.error('Error setting user attributes: ' + error);
|
|
10965
|
-
}
|
|
10966
|
-
};
|
|
10967
|
-
RoktManager.prototype.mapPlacementAttributes = function (attributes, placementAttributesMapping) {
|
|
10968
|
-
var mappingLookup = {};
|
|
10969
|
-
for (var _i = 0, placementAttributesMapping_1 = placementAttributesMapping; _i < placementAttributesMapping_1.length; _i++) {
|
|
10970
|
-
var mapping = placementAttributesMapping_1[_i];
|
|
10971
|
-
mappingLookup[mapping.map] = mapping.value;
|
|
10972
|
-
}
|
|
10973
|
-
var mappedAttributes = {};
|
|
10974
|
-
for (var key in attributes) {
|
|
10975
|
-
if (attributes.hasOwnProperty(key)) {
|
|
10976
|
-
var newKey = mappingLookup[key] || key;
|
|
10977
|
-
mappedAttributes[newKey] = attributes[key];
|
|
10978
|
-
}
|
|
10979
|
-
}
|
|
10980
|
-
return mappedAttributes;
|
|
10981
|
-
};
|
|
10982
|
-
RoktManager.prototype.onIdentityComplete = function () {
|
|
10983
|
-
if (this.isReady()) {
|
|
10984
|
-
this.currentUser = this.identityService.getCurrentUser();
|
|
10985
|
-
// Process any queued selectPlacements calls that were waiting for identity
|
|
10986
|
-
this.processMessageQueue();
|
|
10987
|
-
}
|
|
10988
|
-
};
|
|
10989
|
-
RoktManager.prototype.processMessageQueue = function () {
|
|
10990
|
-
var _this = this;
|
|
10991
|
-
var _a;
|
|
10992
|
-
if (!this.isReady() || this.messageQueue.size === 0) {
|
|
10993
|
-
return;
|
|
10994
|
-
}
|
|
10995
|
-
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.verbose("RoktManager: Processing ".concat(this.messageQueue.size, " queued messages"));
|
|
10996
|
-
var messagesToProcess = Array.from(this.messageQueue.values());
|
|
10997
|
-
// Clear the queue immediately to prevent re-processing
|
|
10998
|
-
this.messageQueue.clear();
|
|
10999
|
-
messagesToProcess.forEach(function (message) {
|
|
11000
|
-
var _a, _b, _c, _d;
|
|
11001
|
-
if (!(message.methodName in _this) || !isFunction(_this[message.methodName])) {
|
|
11002
|
-
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Method ".concat(message.methodName, " not found"));
|
|
11003
|
-
return;
|
|
11004
|
-
}
|
|
11005
|
-
if ((_b = _this.logger) === null || _b === void 0 ? void 0 : _b.isVerbose()) {
|
|
11006
|
-
var payloadToLog = obfuscateDevData(message.payload, (_d = (_c = _this.store) === null || _c === void 0 ? void 0 : _c.SDKConfig) === null || _d === void 0 ? void 0 : _d.isDevelopmentMode);
|
|
11007
|
-
_this.logger.verbose("RoktManager: Processing queued message: ".concat(message.methodName, " with payload: ").concat(JSON.stringify(payloadToLog)));
|
|
11008
|
-
}
|
|
11009
|
-
// Capture resolve/reject functions before async processing
|
|
11010
|
-
var resolve = message.resolve;
|
|
11011
|
-
var reject = message.reject;
|
|
11012
|
-
var handleError = function handleError(error) {
|
|
11013
|
-
var _a;
|
|
11014
|
-
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Error processing message '".concat(message.methodName, "': ").concat(getErrorMessage(error)));
|
|
11015
|
-
if (reject) {
|
|
11016
|
-
reject(error);
|
|
11017
|
-
}
|
|
11018
|
-
};
|
|
11019
|
-
try {
|
|
11020
|
-
var result = _this[message.methodName](message.payload);
|
|
11021
|
-
// Handle both sync and async methods
|
|
11022
|
-
Promise.resolve(result).then(function (resolvedResult) {
|
|
11023
|
-
if (resolve) {
|
|
11024
|
-
resolve(resolvedResult);
|
|
11025
|
-
}
|
|
11026
|
-
})["catch"](handleError);
|
|
11027
|
-
} catch (error) {
|
|
11028
|
-
handleError(error);
|
|
11029
|
-
}
|
|
11030
|
-
});
|
|
11031
|
-
};
|
|
11032
|
-
RoktManager.prototype.queueMessage = function (message) {
|
|
11033
|
-
this.messageQueue.set(message.messageId, message);
|
|
11034
|
-
};
|
|
11035
|
-
RoktManager.prototype.deferredCall = function (methodName, payload) {
|
|
11036
|
-
var _this = this;
|
|
11037
|
-
return new Promise(function (resolve, reject) {
|
|
11038
|
-
var messageId = "".concat(methodName, "_").concat(generateUniqueId());
|
|
11039
|
-
_this.queueMessage({
|
|
11040
|
-
messageId: messageId,
|
|
11041
|
-
methodName: methodName,
|
|
11042
|
-
payload: payload,
|
|
11043
|
-
resolve: resolve,
|
|
11044
|
-
reject: reject
|
|
11045
|
-
});
|
|
11046
|
-
});
|
|
11047
|
-
};
|
|
11048
|
-
/**
|
|
11049
|
-
* Hashes a string input using SHA-256 and returns the hex digest
|
|
11050
|
-
* Uses the Web Crypto API for secure hashing
|
|
11051
|
-
*
|
|
11052
|
-
* @param {string} input - The string to hash
|
|
11053
|
-
* @returns {Promise<string>} The SHA-256 hash as a hexadecimal string
|
|
11054
|
-
*/
|
|
11055
|
-
RoktManager.prototype.sha256Hex = function (input) {
|
|
11056
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
11057
|
-
var encoder, encodedInput, digest;
|
|
11058
|
-
return __generator(this, function (_a) {
|
|
11059
|
-
switch (_a.label) {
|
|
11060
|
-
case 0:
|
|
11061
|
-
encoder = new TextEncoder();
|
|
11062
|
-
encodedInput = encoder.encode(input);
|
|
11063
|
-
return [4 /*yield*/, crypto.subtle.digest('SHA-256', encodedInput)];
|
|
11064
|
-
case 1:
|
|
11065
|
-
digest = _a.sent();
|
|
11066
|
-
return [2 /*return*/, this.arrayBufferToHex(digest)];
|
|
11067
|
-
}
|
|
11068
|
-
});
|
|
11069
|
-
});
|
|
11070
|
-
};
|
|
11071
|
-
/**
|
|
11072
|
-
* Converts an ArrayBuffer to a hexadecimal string representation
|
|
11073
|
-
* Each byte is converted to a 2-character hex string with leading zeros
|
|
11074
|
-
*
|
|
11075
|
-
* @param {ArrayBuffer} buffer - The buffer to convert
|
|
11076
|
-
* @returns {string} The hexadecimal string representation
|
|
11077
|
-
*/
|
|
11078
|
-
RoktManager.prototype.arrayBufferToHex = function (buffer) {
|
|
11079
|
-
var bytes = new Uint8Array(buffer);
|
|
11080
|
-
var hexString = '';
|
|
11081
|
-
for (var i = 0; i < bytes.length; i++) {
|
|
11082
|
-
var hexByte = bytes[i].toString(16).padStart(2, '0');
|
|
11083
|
-
hexString += hexByte;
|
|
11084
|
-
}
|
|
11085
|
-
return hexString;
|
|
11086
|
-
};
|
|
11087
|
-
/**
|
|
11088
|
-
* Checks if an identity value has changed by comparing current and new values
|
|
11089
|
-
*
|
|
11090
|
-
* @param {string | undefined} currentValue - The current identity value
|
|
11091
|
-
* @param {string | undefined} newValue - The new identity value to compare against
|
|
11092
|
-
* @returns {boolean} True if the identity has changed (new value exists and differs from current), false otherwise
|
|
11093
|
-
*/
|
|
11094
|
-
RoktManager.prototype.hasIdentityChanged = function (currentValue, newValue) {
|
|
11095
|
-
if (!newValue) {
|
|
11096
|
-
return false;
|
|
11097
|
-
}
|
|
11098
|
-
if (!currentValue) {
|
|
11099
|
-
return true; // New value exists but no current value
|
|
11100
|
-
}
|
|
11101
|
-
|
|
11102
|
-
if (currentValue !== newValue) {
|
|
11103
|
-
return true; // Values are different
|
|
11104
|
-
}
|
|
11105
|
-
|
|
11106
|
-
return false; // Values are the same
|
|
11107
|
-
};
|
|
11108
|
-
|
|
11109
|
-
return RoktManager;
|
|
11110
|
-
}();
|
|
11111
|
-
|
|
11112
|
-
/**
|
|
11113
|
-
* CookieConsentManager handles storage and access of consent flags (noFunctional, noTargeting)
|
|
11114
|
-
* that are passed via launcherOptions during SDK initialization.
|
|
11115
|
-
*
|
|
11116
|
-
* These flags allow Rokt integration to respect user privacy choices.
|
|
11117
|
-
*
|
|
11118
|
-
* Default behavior: Both flags default to false, meaning all features are allowed
|
|
11119
|
-
* unless explicitly opted out by the user.
|
|
11120
|
-
*/
|
|
11121
|
-
var CookieConsentManager = /** @class */function () {
|
|
11122
|
-
function CookieConsentManager(flags) {
|
|
11123
|
-
this.flags = flags;
|
|
11124
|
-
this.flags = {
|
|
11125
|
-
noFunctional: flags.noFunctional === true,
|
|
11126
|
-
noTargeting: flags.noTargeting === true
|
|
11127
|
-
};
|
|
11128
|
-
}
|
|
11129
|
-
/**
|
|
11130
|
-
* Returns true if third-party targeting is disabled.
|
|
11131
|
-
* Targeting is allowed when noTargeting is false (default).
|
|
11132
|
-
*/
|
|
11133
|
-
CookieConsentManager.prototype.getNoTargeting = function () {
|
|
11134
|
-
return this.flags.noTargeting;
|
|
11135
|
-
};
|
|
11136
|
-
/**
|
|
11137
|
-
* Returns true if functional tracking is disabled.
|
|
11138
|
-
* Functional tracking is allowed when noFunctional is false (default).
|
|
11139
|
-
*/
|
|
11140
|
-
CookieConsentManager.prototype.getNoFunctional = function () {
|
|
11141
|
-
return this.flags.noFunctional;
|
|
11142
|
-
};
|
|
11143
|
-
CookieConsentManager.prototype.syncNoTargetingAttribute = function (user) {
|
|
11144
|
-
if (!user) return;
|
|
11145
|
-
if (this.flags.noTargeting) {
|
|
11146
|
-
user.setUserAttribute(NO_TARGETING_ATTRIBUTE, true);
|
|
11147
|
-
} else if (user.getAllUserAttributes().hasOwnProperty(NO_TARGETING_ATTRIBUTE)) {
|
|
11148
|
-
user.removeUserAttribute(NO_TARGETING_ATTRIBUTE);
|
|
11149
|
-
}
|
|
11150
|
-
};
|
|
11151
|
-
return CookieConsentManager;
|
|
11152
|
-
}();
|
|
11153
|
-
|
|
11154
|
-
var ErrorReportingDispatcher = /** @class */function () {
|
|
11155
|
-
function ErrorReportingDispatcher() {
|
|
11156
|
-
this.services = [];
|
|
11157
|
-
}
|
|
11158
|
-
ErrorReportingDispatcher.prototype.register = function (service) {
|
|
11159
|
-
this.services.push(service);
|
|
11160
|
-
};
|
|
11161
|
-
ErrorReportingDispatcher.prototype.report = function (error) {
|
|
11162
|
-
var _this = this;
|
|
11163
|
-
this.services.forEach(function (s) {
|
|
11164
|
-
var _a;
|
|
11165
|
-
try {
|
|
11166
|
-
s.report(error);
|
|
11167
|
-
} catch (e) {
|
|
11168
|
-
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error('Error in ErrorReportingService: ' + e);
|
|
11169
|
-
}
|
|
11170
|
-
});
|
|
11171
|
-
};
|
|
11172
|
-
return ErrorReportingDispatcher;
|
|
11173
|
-
}();
|
|
11174
|
-
|
|
11175
|
-
var LoggingDispatcher = /** @class */function () {
|
|
11176
|
-
function LoggingDispatcher() {
|
|
11177
|
-
this.services = [];
|
|
11178
|
-
}
|
|
11179
|
-
LoggingDispatcher.prototype.register = function (service) {
|
|
11180
|
-
this.services.push(service);
|
|
11181
|
-
};
|
|
11182
|
-
LoggingDispatcher.prototype.log = function (entry) {
|
|
11183
|
-
var _this = this;
|
|
11184
|
-
this.services.forEach(function (s) {
|
|
11185
|
-
var _a;
|
|
11186
|
-
try {
|
|
11187
|
-
s.log(entry);
|
|
11188
|
-
} catch (e) {
|
|
11189
|
-
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error('Error in LoggingService: ' + e);
|
|
11190
|
-
}
|
|
11191
|
-
});
|
|
11192
|
-
};
|
|
11193
|
-
return LoggingDispatcher;
|
|
11194
|
-
}();
|
|
11195
|
-
|
|
11196
|
-
var HISTORY_METHODS = ['pushState', 'replaceState'];
|
|
11197
|
-
var WRAPPED_MARKER = '__mpApvWrapped__';
|
|
11198
|
-
// All APV state hangs off one window key, and it is the public debugging
|
|
11199
|
-
// contract: `window.__mpApv__` is what you inspect in a console to see whether
|
|
11200
|
-
// tracking is live.
|
|
11201
|
-
//
|
|
11202
|
-
// It lives on `window` rather than in module scope because Next.js re-executes
|
|
11203
|
-
// the SDK bundle on every SPA navigation: module-level state is reset each time,
|
|
11204
|
-
// but `window` persists for the lifetime of the tab.
|
|
11205
|
-
//
|
|
11206
|
-
// One object rather than a key per flag, so resetting is a single reassignment.
|
|
11207
|
-
// Nothing has to be deleted, and there is no ordering in which half the state
|
|
11208
|
-
// survives the reset.
|
|
11209
|
-
var WIN_APV_KEY = '__mpApv__';
|
|
11210
|
-
// ---------------------------------------------------------------------------
|
|
11211
|
-
// Pure helpers. No `this`, no globals, no side effects — callable and assertable
|
|
11212
|
-
// on their own, which is where the interesting rules live.
|
|
11213
|
-
// ---------------------------------------------------------------------------
|
|
11214
|
-
// Dedup keys on pathname only: a query-string- or hash-only change is the same
|
|
11215
|
-
// page and must not fire a view.
|
|
11216
|
-
var isNewPage = function isNewPage(lastPath, candidatePath) {
|
|
11217
|
-
return candidatePath !== lastPath;
|
|
11218
|
-
};
|
|
11219
|
-
var supportsHistoryTracking = function supportsHistoryTracking(win) {
|
|
11220
|
-
return !!win && win.history !== undefined && typeof win.history.pushState === 'function' && typeof win.addEventListener === 'function';
|
|
11221
|
-
};
|
|
11222
|
-
// Mirrors the event shape of the public mParticle.logPageView(), but carries the
|
|
11223
|
-
// path captured when the navigation was accepted rather than the live location.
|
|
11224
|
-
var buildPageViewEvent = function buildPageViewEvent(data) {
|
|
11225
|
-
return {
|
|
11226
|
-
messageType: MessageType$1.PageView,
|
|
11227
|
-
name: 'PageView',
|
|
11228
|
-
data: __assign({}, data),
|
|
11229
|
-
eventType: EventType.Unknown
|
|
11230
|
-
};
|
|
11231
|
-
};
|
|
11232
|
-
// ---------------------------------------------------------------------------
|
|
11233
|
-
// Window-scoped APV state. Every read and write goes through these helpers, so
|
|
11234
|
-
// neither the tracker nor mp-instance touches `window` directly and
|
|
11235
|
-
// `typeof window` is checked in exactly one place.
|
|
11236
|
-
// ---------------------------------------------------------------------------
|
|
11237
|
-
var apvWindow = function apvWindow() {
|
|
11238
|
-
return typeof window === 'undefined' ? null : window;
|
|
11239
|
-
};
|
|
11240
|
-
var freshState = function freshState() {
|
|
11241
|
-
return {
|
|
11242
|
-
initialPageViewFired: false
|
|
11243
|
-
};
|
|
11244
|
-
};
|
|
11245
|
-
// Reads tolerate absent state, so a read never mutates `window`. Only the
|
|
11246
|
-
// writers below create it.
|
|
11247
|
-
var readState = function readState() {
|
|
11248
|
-
var win = apvWindow();
|
|
11249
|
-
return win ? win[WIN_APV_KEY] : undefined;
|
|
11250
|
-
};
|
|
11251
|
-
var writeState = function writeState() {
|
|
11252
|
-
var win = apvWindow();
|
|
11253
|
-
if (!win) {
|
|
11254
|
-
return null;
|
|
11255
|
-
}
|
|
11256
|
-
if (!win[WIN_APV_KEY]) {
|
|
11257
|
-
win[WIN_APV_KEY] = freshState();
|
|
11258
|
-
}
|
|
11259
|
-
return win[WIN_APV_KEY];
|
|
11260
|
-
};
|
|
11261
|
-
var getActiveTracker = function getActiveTracker() {
|
|
11262
|
-
var state = readState();
|
|
11263
|
-
return state ? state.tracker : undefined;
|
|
11264
|
-
};
|
|
11265
|
-
var hasInitialPageViewFired = function hasInitialPageViewFired() {
|
|
11266
|
-
var state = readState();
|
|
11267
|
-
return !!(state && state.initialPageViewFired);
|
|
11268
|
-
};
|
|
11269
|
-
var markInitialPageViewFired = function markInitialPageViewFired() {
|
|
11270
|
-
var state = writeState();
|
|
11271
|
-
if (state) {
|
|
11272
|
-
state.initialPageViewFired = true;
|
|
11273
|
-
}
|
|
11274
|
-
};
|
|
11275
|
-
// Returns the page to its pre-APV state: stops the active tracker (restoring the
|
|
11276
|
-
// history methods it patched), then swaps in fresh state. The state object is the
|
|
11277
|
-
// authoritative handle, so this reaches trackers whose owning module is gone.
|
|
11278
|
-
var resetPageViewTracking = function resetPageViewTracking() {
|
|
11279
|
-
var win = apvWindow();
|
|
11280
|
-
if (!win) {
|
|
11281
|
-
return;
|
|
11282
|
-
}
|
|
11283
|
-
var active = getActiveTracker();
|
|
11284
|
-
if (active) {
|
|
11285
|
-
active.teardown();
|
|
11286
|
-
}
|
|
11287
|
-
// One reassignment replaces every flag at once, so nothing can be left behind
|
|
11288
|
-
// whatever shape the previous state was in.
|
|
11289
|
-
win[WIN_APV_KEY] = freshState();
|
|
11290
|
-
};
|
|
11291
|
-
var setActiveTracker = function setActiveTracker(tracker) {
|
|
11292
|
-
var state = writeState();
|
|
11293
|
-
if (state) {
|
|
11294
|
-
state.tracker = tracker;
|
|
11295
|
-
}
|
|
11296
|
-
};
|
|
11297
|
-
var clearActiveTracker = function clearActiveTracker(tracker) {
|
|
11298
|
-
var state = readState();
|
|
11299
|
-
if (state && state.tracker === tracker) {
|
|
11300
|
-
state.tracker = undefined;
|
|
11301
|
-
}
|
|
11302
|
-
};
|
|
11303
|
-
var currentPathname = function currentPathname() {
|
|
11304
|
-
return window.location.pathname;
|
|
11305
|
-
};
|
|
11306
|
-
// ---------------------------------------------------------------------------
|
|
11307
|
-
// History patching
|
|
11308
|
-
// ---------------------------------------------------------------------------
|
|
11309
|
-
// Wraps pushState/replaceState so `onNavigate` runs after the real method, and
|
|
11310
|
-
// returns the single function that undoes it — or null when nothing was
|
|
11311
|
-
// installed (history is already wrapped, or a frozen/sealed History rejected the
|
|
11312
|
-
// assignment). Handing back one undo closure keeps the wrapper and original
|
|
11313
|
-
// references out of the tracker entirely: there is no half-patched state for a
|
|
11314
|
-
// caller to inspect, and no way to restore the wrong pair.
|
|
11315
|
-
var patchHistory = function patchHistory(onNavigate, log) {
|
|
11316
|
-
if (window.history.pushState[WRAPPED_MARKER]) {
|
|
11317
|
-
log('[patch] history already wrapped, skipping to avoid double-wrap — STACKED WRAPPER DETECTED');
|
|
11318
|
-
return null;
|
|
11319
|
-
}
|
|
11320
|
-
var originals = {};
|
|
11321
|
-
var wrappers = {};
|
|
11322
|
-
HISTORY_METHODS.forEach(function (name) {
|
|
11323
|
-
var original = window.history[name];
|
|
11324
|
-
originals[name] = original;
|
|
11325
|
-
var wrapper = function wrapper() {
|
|
11326
|
-
var args = [];
|
|
11327
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11328
|
-
args[_i] = arguments[_i];
|
|
11329
|
-
}
|
|
11330
|
-
var result = original.apply(this, args);
|
|
11331
|
-
onNavigate(name);
|
|
11332
|
-
return result;
|
|
11333
|
-
};
|
|
11334
|
-
Object.defineProperty(wrapper, WRAPPED_MARKER, {
|
|
11335
|
-
value: true,
|
|
11336
|
-
enumerable: false
|
|
11337
|
-
});
|
|
11338
|
-
wrappers[name] = wrapper;
|
|
11339
|
-
});
|
|
11340
|
-
// Restore per method: a third party may have patched one of the two on top of
|
|
11341
|
-
// ours after we installed. Clobbering theirs would break their tracking, so
|
|
11342
|
-
// leave anything that is no longer ours in place.
|
|
11343
|
-
var restore = function restore() {
|
|
11344
|
-
return HISTORY_METHODS.forEach(function (name) {
|
|
11345
|
-
if (window.history[name] === wrappers[name]) {
|
|
11346
|
-
window.history[name] = originals[name];
|
|
11347
|
-
log("[teardown] restored original ".concat(name));
|
|
11348
|
-
} else {
|
|
11349
|
-
log("[teardown] ".concat(name, " no longer ours; leaving in place, gating callback to no-op"));
|
|
11350
|
-
}
|
|
10795
|
+
// Propagate emailsha256 from current user identities if not already in attributes
|
|
10796
|
+
if (isValidHashedEmailIdentityType) {
|
|
10797
|
+
hashedEmail = finalUserIdentities[this.mappedEmailShaIdentityType];
|
|
10798
|
+
if (hashedEmail && !enrichedAttributes.emailsha256 && !enrichedAttributes[this.mappedEmailShaIdentityType]) {
|
|
10799
|
+
enrichedAttributes.emailsha256 = hashedEmail;
|
|
10800
|
+
}
|
|
10801
|
+
}
|
|
10802
|
+
if (!enrichedAttributes[PASSBACK_CONVERSION_TRACKING_ID]) {
|
|
10803
|
+
(_p = this.integrationCapture) === null || _p === void 0 ? void 0 : _p.capture();
|
|
10804
|
+
capturedAttrs = (_q = this.integrationCapture) === null || _q === void 0 ? void 0 : _q.getClickIdsAsIntegrationAttributes();
|
|
10805
|
+
passbackId = (_r = capturedAttrs === null || capturedAttrs === void 0 ? void 0 : capturedAttrs[PARTNER_MODULE_IDS.Rokt]) === null || _r === void 0 ? void 0 : _r[PASSBACK_CONVERSION_TRACKING_ID];
|
|
10806
|
+
if (passbackId) {
|
|
10807
|
+
enrichedAttributes[PASSBACK_CONVERSION_TRACKING_ID] = passbackId;
|
|
10808
|
+
}
|
|
10809
|
+
}
|
|
10810
|
+
this.filters.filteredUser = this.currentUser || this.filters.filteredUser || null;
|
|
10811
|
+
enrichedOptions = __assign(__assign({}, options), {
|
|
10812
|
+
attributes: enrichedAttributes
|
|
10813
|
+
});
|
|
10814
|
+
return [2 /*return*/, this.kit.selectPlacements(enrichedOptions)];
|
|
10815
|
+
} catch (error) {
|
|
10816
|
+
return [2 /*return*/, Promise.reject(error instanceof Error ? error : new Error('Unknown error occurred'))];
|
|
10817
|
+
}
|
|
10818
|
+
return [2 /*return*/];
|
|
10819
|
+
});
|
|
11351
10820
|
});
|
|
11352
10821
|
};
|
|
11353
|
-
|
|
11354
|
-
|
|
11355
|
-
|
|
10822
|
+
/**
|
|
10823
|
+
* Hashes attributes and returns both original and hashed versions
|
|
10824
|
+
* with Rokt-compatible key names (like emailsha256, mobilesha256)
|
|
10825
|
+
*
|
|
10826
|
+
*
|
|
10827
|
+
* @param {RoktAttributes} attributes - Attributes to hash
|
|
10828
|
+
* @returns {Promise<RoktAttributes>} Object with both original and hashed attributes
|
|
10829
|
+
*
|
|
10830
|
+
*/
|
|
10831
|
+
RoktManager.prototype.hashAttributes = function (attributes) {
|
|
10832
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
10833
|
+
var keys, hashPromises, results, hashedAttributes, _i, results_1, _a, key, attributeValue, hashedValue, error_1;
|
|
10834
|
+
var _this = this;
|
|
10835
|
+
return __generator(this, function (_b) {
|
|
10836
|
+
switch (_b.label) {
|
|
10837
|
+
case 0:
|
|
10838
|
+
_b.trys.push([0, 2,, 3]);
|
|
10839
|
+
if (!attributes || _typeof(attributes) !== 'object') {
|
|
10840
|
+
return [2 /*return*/, {}];
|
|
10841
|
+
}
|
|
10842
|
+
keys = Object.keys(attributes);
|
|
10843
|
+
if (keys.length === 0) {
|
|
10844
|
+
return [2 /*return*/, {}];
|
|
10845
|
+
}
|
|
10846
|
+
hashPromises = keys.map(function (key) {
|
|
10847
|
+
return __awaiter(_this, void 0, void 0, function () {
|
|
10848
|
+
var attributeValue, hashedValue;
|
|
10849
|
+
return __generator(this, function (_a) {
|
|
10850
|
+
switch (_a.label) {
|
|
10851
|
+
case 0:
|
|
10852
|
+
attributeValue = attributes[key];
|
|
10853
|
+
return [4 /*yield*/, this.hashSha256(attributeValue)];
|
|
10854
|
+
case 1:
|
|
10855
|
+
hashedValue = _a.sent();
|
|
10856
|
+
return [2 /*return*/, {
|
|
10857
|
+
key: key,
|
|
10858
|
+
attributeValue: attributeValue,
|
|
10859
|
+
hashedValue: hashedValue
|
|
10860
|
+
}];
|
|
10861
|
+
}
|
|
10862
|
+
});
|
|
10863
|
+
});
|
|
10864
|
+
});
|
|
10865
|
+
return [4 /*yield*/, Promise.all(hashPromises)];
|
|
10866
|
+
case 1:
|
|
10867
|
+
results = _b.sent();
|
|
10868
|
+
hashedAttributes = {};
|
|
10869
|
+
for (_i = 0, results_1 = results; _i < results_1.length; _i++) {
|
|
10870
|
+
_a = results_1[_i], key = _a.key, attributeValue = _a.attributeValue, hashedValue = _a.hashedValue;
|
|
10871
|
+
hashedAttributes[key] = attributeValue;
|
|
10872
|
+
if (hashedValue) {
|
|
10873
|
+
hashedAttributes["".concat(key, "sha256")] = hashedValue;
|
|
10874
|
+
}
|
|
10875
|
+
}
|
|
10876
|
+
return [2 /*return*/, hashedAttributes];
|
|
10877
|
+
case 2:
|
|
10878
|
+
error_1 = _b.sent();
|
|
10879
|
+
this.logger.error("Failed to hashAttributes, returning an empty object: ".concat(getErrorMessage(error_1)));
|
|
10880
|
+
return [2 /*return*/, {}];
|
|
10881
|
+
case 3:
|
|
10882
|
+
return [2 /*return*/];
|
|
10883
|
+
}
|
|
10884
|
+
});
|
|
11356
10885
|
});
|
|
11357
|
-
}
|
|
11358
|
-
|
|
10886
|
+
};
|
|
10887
|
+
|
|
10888
|
+
RoktManager.prototype.setExtensionData = function (extensionData) {
|
|
10889
|
+
if (!this.isReady()) {
|
|
10890
|
+
this.deferredCall('setExtensionData', extensionData);
|
|
10891
|
+
return;
|
|
10892
|
+
}
|
|
11359
10893
|
try {
|
|
11360
|
-
|
|
11361
|
-
} catch (
|
|
11362
|
-
|
|
10894
|
+
this.kit.setExtensionData(extensionData);
|
|
10895
|
+
} catch (error) {
|
|
10896
|
+
throw new Error('Error setting extension data: ' + getErrorMessage(error));
|
|
11363
10897
|
}
|
|
11364
|
-
|
|
11365
|
-
|
|
11366
|
-
|
|
11367
|
-
|
|
11368
|
-
|
|
11369
|
-
|
|
11370
|
-
|
|
11371
|
-
|
|
11372
|
-
|
|
11373
|
-
|
|
11374
|
-
|
|
11375
|
-
|
|
11376
|
-
this.
|
|
11377
|
-
|
|
11378
|
-
this.mpInstance = mpInstance;
|
|
11379
|
-
}
|
|
11380
|
-
Object.defineProperty(PageViewTracker.prototype, "isActive", {
|
|
11381
|
-
// True while this tracker owns the history patch and is listening for
|
|
11382
|
-
// navigations. Flips to false on teardown, including the teardown a
|
|
11383
|
-
// successor tracker performs during a handoff. Read-only, and the one thing
|
|
11384
|
-
// worth checking on `window.__mpApv__.tracker` from a console.
|
|
11385
|
-
get: function get() {
|
|
11386
|
-
return this.active;
|
|
11387
|
-
},
|
|
11388
|
-
enumerable: false,
|
|
11389
|
-
configurable: true
|
|
11390
|
-
});
|
|
11391
|
-
PageViewTracker.prototype.init = function () {
|
|
11392
|
-
var _this = this;
|
|
11393
|
-
this.log('[init] PageViewTracker Init');
|
|
11394
|
-
if (!supportsHistoryTracking(apvWindow())) {
|
|
11395
|
-
this.log('[init] unsupported environment (no History API), not starting');
|
|
10898
|
+
};
|
|
10899
|
+
RoktManager.prototype.use = function (name) {
|
|
10900
|
+
if (!this.isReady()) {
|
|
10901
|
+
return this.deferredCall('use', name);
|
|
10902
|
+
}
|
|
10903
|
+
try {
|
|
10904
|
+
return this.kit.use(name);
|
|
10905
|
+
} catch (error) {
|
|
10906
|
+
return Promise.reject(error instanceof Error ? error : new Error('Error using extension: ' + name));
|
|
10907
|
+
}
|
|
10908
|
+
};
|
|
10909
|
+
RoktManager.prototype.onShoppableAdsReady = function (callback) {
|
|
10910
|
+
if (!this.kit || !this.isShoppableAdsLoaded) {
|
|
10911
|
+
this.deferredCall('onShoppableAdsReady', callback);
|
|
11396
10912
|
return;
|
|
11397
10913
|
}
|
|
11398
|
-
|
|
11399
|
-
|
|
11400
|
-
|
|
11401
|
-
|
|
11402
|
-
// flushed yet, and dropping it loses a page view entirely.
|
|
11403
|
-
var active = getActiveTracker();
|
|
11404
|
-
var inheritedPaths = this.retire(active);
|
|
11405
|
-
if (this.active && active !== this) {
|
|
11406
|
-
inheritedPaths = inheritedPaths.concat(this.retire(this));
|
|
10914
|
+
try {
|
|
10915
|
+
this.kit.onShoppableAdsReady(callback);
|
|
10916
|
+
} catch (error) {
|
|
10917
|
+
this.logger.error("Failed to register onShoppableAdsReady callback: ".concat(getErrorMessage(error)));
|
|
11407
10918
|
}
|
|
11408
|
-
|
|
11409
|
-
|
|
11410
|
-
|
|
11411
|
-
this.
|
|
11412
|
-
|
|
11413
|
-
|
|
11414
|
-
|
|
10919
|
+
};
|
|
10920
|
+
RoktManager.prototype.flushOnShoppableAdsReadyMessageQueue = function (kit) {
|
|
10921
|
+
var _this = this;
|
|
10922
|
+
this.kit = kit;
|
|
10923
|
+
this.messageQueue.forEach(function (message, key) {
|
|
10924
|
+
var _a;
|
|
10925
|
+
if (message.methodName === ON_SHOPPABLE_ADS_READY_METHOD) {
|
|
10926
|
+
try {
|
|
10927
|
+
kit.onShoppableAdsReady(message.payload);
|
|
10928
|
+
} catch (e) {
|
|
10929
|
+
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error('RoktManager: Error flushing onShoppableAdsReady: ' + e);
|
|
10930
|
+
}
|
|
10931
|
+
_this.messageQueue["delete"](key);
|
|
10932
|
+
}
|
|
11415
10933
|
});
|
|
11416
|
-
this.
|
|
11417
|
-
|
|
11418
|
-
|
|
11419
|
-
|
|
11420
|
-
|
|
11421
|
-
|
|
11422
|
-
|
|
11423
|
-
|
|
10934
|
+
this.isShoppableAdsLoaded = true;
|
|
10935
|
+
};
|
|
10936
|
+
/**
|
|
10937
|
+
* Hashes an attribute using SHA-256
|
|
10938
|
+
*
|
|
10939
|
+
* @param {string | number | boolean | undefined | null} attribute - The value to hash
|
|
10940
|
+
* @returns {Promise<string | undefined | null>} SHA-256 hashed value or undefined/null
|
|
10941
|
+
*
|
|
10942
|
+
*/
|
|
10943
|
+
RoktManager.prototype.hashSha256 = function (attribute) {
|
|
10944
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
10945
|
+
var normalizedValue, error_2;
|
|
10946
|
+
return __generator(this, function (_a) {
|
|
10947
|
+
switch (_a.label) {
|
|
10948
|
+
case 0:
|
|
10949
|
+
if (attribute === null || attribute === undefined) {
|
|
10950
|
+
this.logger.warning("hashSha256 received null/undefined as input");
|
|
10951
|
+
return [2 /*return*/, attribute];
|
|
10952
|
+
}
|
|
10953
|
+
_a.label = 1;
|
|
10954
|
+
case 1:
|
|
10955
|
+
_a.trys.push([1, 3,, 4]);
|
|
10956
|
+
normalizedValue = String(attribute).trim().toLocaleLowerCase();
|
|
10957
|
+
return [4 /*yield*/, this.sha256Hex(normalizedValue)];
|
|
10958
|
+
case 2:
|
|
10959
|
+
return [2 /*return*/, _a.sent()];
|
|
10960
|
+
case 3:
|
|
10961
|
+
error_2 = _a.sent();
|
|
10962
|
+
this.logger.error("Failed to hashSha256, returning undefined: ".concat(getErrorMessage(error_2)));
|
|
10963
|
+
return [2 /*return*/, undefined];
|
|
10964
|
+
case 4:
|
|
10965
|
+
return [2 /*return*/];
|
|
10966
|
+
}
|
|
10967
|
+
});
|
|
11424
10968
|
});
|
|
11425
10969
|
};
|
|
11426
|
-
|
|
11427
|
-
|
|
11428
|
-
|
|
11429
|
-
|
|
11430
|
-
|
|
11431
|
-
|
|
11432
|
-
|
|
11433
|
-
|
|
10970
|
+
|
|
10971
|
+
RoktManager.prototype.getLocalSessionAttributes = function () {
|
|
10972
|
+
return this.store.getLocalSessionAttributes();
|
|
10973
|
+
};
|
|
10974
|
+
RoktManager.prototype.setLocalSessionAttribute = function (key, value) {
|
|
10975
|
+
this.store.setLocalSessionAttribute(key, value);
|
|
10976
|
+
};
|
|
10977
|
+
RoktManager.prototype.isReady = function () {
|
|
10978
|
+
// The Rokt Manager is ready when a kit is attached and has a launcher
|
|
10979
|
+
return Boolean(this.kit && this.kit.launcher);
|
|
10980
|
+
};
|
|
10981
|
+
RoktManager.prototype.setUserAttributes = function (attributes) {
|
|
10982
|
+
var reservedAttributes = ['sandbox'];
|
|
10983
|
+
var filteredAttributes = {};
|
|
10984
|
+
for (var key in attributes) {
|
|
10985
|
+
if (attributes.hasOwnProperty(key) && reservedAttributes.indexOf(key) === -1) {
|
|
10986
|
+
var value = attributes[key];
|
|
10987
|
+
filteredAttributes[key] = Array.isArray(value) ? JSON.stringify(value) : value;
|
|
10988
|
+
}
|
|
10989
|
+
}
|
|
10990
|
+
try {
|
|
10991
|
+
this.currentUser.setUserAttributes(filteredAttributes);
|
|
10992
|
+
} catch (error) {
|
|
10993
|
+
this.logger.error('Error setting user attributes: ' + error);
|
|
10994
|
+
}
|
|
10995
|
+
};
|
|
10996
|
+
RoktManager.prototype.mapPlacementAttributes = function (attributes, placementAttributesMapping) {
|
|
10997
|
+
var mappingLookup = {};
|
|
10998
|
+
for (var _i = 0, placementAttributesMapping_1 = placementAttributesMapping; _i < placementAttributesMapping_1.length; _i++) {
|
|
10999
|
+
var mapping = placementAttributesMapping_1[_i];
|
|
11000
|
+
mappingLookup[mapping.map] = mapping.value;
|
|
11434
11001
|
}
|
|
11435
|
-
|
|
11436
|
-
|
|
11437
|
-
|
|
11002
|
+
var mappedAttributes = {};
|
|
11003
|
+
for (var key in attributes) {
|
|
11004
|
+
if (attributes.hasOwnProperty(key)) {
|
|
11005
|
+
var newKey = mappingLookup[key] || key;
|
|
11006
|
+
mappedAttributes[newKey] = attributes[key];
|
|
11007
|
+
}
|
|
11438
11008
|
}
|
|
11439
|
-
|
|
11440
|
-
clearActiveTracker(this);
|
|
11009
|
+
return mappedAttributes;
|
|
11441
11010
|
};
|
|
11442
|
-
|
|
11443
|
-
|
|
11444
|
-
|
|
11445
|
-
|
|
11446
|
-
|
|
11447
|
-
return [];
|
|
11011
|
+
RoktManager.prototype.onIdentityComplete = function () {
|
|
11012
|
+
if (this.isReady()) {
|
|
11013
|
+
this.currentUser = this.identityService.getCurrentUser();
|
|
11014
|
+
// Process any queued selectPlacements calls that were waiting for identity
|
|
11015
|
+
this.processMessageQueue();
|
|
11448
11016
|
}
|
|
11449
|
-
this.log(outgoing === this ? '[init] retiring this tracker for a repeat mParticle.init() — transferring pending navigations and tearing down' : '[init] retiring a tracker from a previous module load — transferring pending navigations and tearing down');
|
|
11450
|
-
var paths = outgoing.takePendingNavigations();
|
|
11451
|
-
outgoing.teardown();
|
|
11452
|
-
return paths;
|
|
11453
11017
|
};
|
|
11454
|
-
|
|
11455
|
-
|
|
11456
|
-
var
|
|
11457
|
-
this.
|
|
11458
|
-
|
|
11459
|
-
|
|
11018
|
+
RoktManager.prototype.processMessageQueue = function () {
|
|
11019
|
+
var _this = this;
|
|
11020
|
+
var _a;
|
|
11021
|
+
if (!this.isReady() || this.messageQueue.size === 0) {
|
|
11022
|
+
return;
|
|
11023
|
+
}
|
|
11024
|
+
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.verbose("RoktManager: Processing ".concat(this.messageQueue.size, " queued messages"));
|
|
11025
|
+
var messagesToProcess = Array.from(this.messageQueue.values());
|
|
11026
|
+
// Clear the queue immediately to prevent re-processing
|
|
11027
|
+
this.messageQueue.clear();
|
|
11028
|
+
messagesToProcess.forEach(function (message) {
|
|
11029
|
+
var _a, _b, _c, _d;
|
|
11030
|
+
if (!(message.methodName in _this) || !isFunction(_this[message.methodName])) {
|
|
11031
|
+
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Method ".concat(message.methodName, " not found"));
|
|
11032
|
+
return;
|
|
11033
|
+
}
|
|
11034
|
+
if ((_b = _this.logger) === null || _b === void 0 ? void 0 : _b.isVerbose()) {
|
|
11035
|
+
var payloadToLog = obfuscateDevData(message.payload, (_d = (_c = _this.store) === null || _c === void 0 ? void 0 : _c.SDKConfig) === null || _d === void 0 ? void 0 : _d.isDevelopmentMode);
|
|
11036
|
+
_this.logger.verbose("RoktManager: Processing queued message: ".concat(message.methodName, " with payload: ").concat(JSON.stringify(payloadToLog)));
|
|
11037
|
+
}
|
|
11038
|
+
// Capture resolve/reject functions before async processing
|
|
11039
|
+
var resolve = message.resolve;
|
|
11040
|
+
var reject = message.reject;
|
|
11041
|
+
var handleError = function handleError(error) {
|
|
11042
|
+
var _a;
|
|
11043
|
+
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Error processing message '".concat(message.methodName, "': ").concat(getErrorMessage(error)));
|
|
11044
|
+
if (reject) {
|
|
11045
|
+
reject(error);
|
|
11046
|
+
}
|
|
11047
|
+
};
|
|
11048
|
+
try {
|
|
11049
|
+
var result = _this[message.methodName](message.payload);
|
|
11050
|
+
// Handle both sync and async methods
|
|
11051
|
+
Promise.resolve(result).then(function (resolvedResult) {
|
|
11052
|
+
if (resolve) {
|
|
11053
|
+
resolve(resolvedResult);
|
|
11054
|
+
}
|
|
11055
|
+
})["catch"](handleError);
|
|
11056
|
+
} catch (error) {
|
|
11057
|
+
handleError(error);
|
|
11058
|
+
}
|
|
11460
11059
|
});
|
|
11461
|
-
|
|
11462
|
-
|
|
11060
|
+
};
|
|
11061
|
+
RoktManager.prototype.queueMessage = function (message) {
|
|
11062
|
+
this.messageQueue.set(message.messageId, message);
|
|
11063
|
+
};
|
|
11064
|
+
RoktManager.prototype.deferredCall = function (methodName, payload) {
|
|
11065
|
+
var _this = this;
|
|
11066
|
+
return new Promise(function (resolve, reject) {
|
|
11067
|
+
var messageId = "".concat(methodName, "_").concat(generateUniqueId());
|
|
11068
|
+
_this.queueMessage({
|
|
11069
|
+
messageId: messageId,
|
|
11070
|
+
methodName: methodName,
|
|
11071
|
+
payload: payload,
|
|
11072
|
+
resolve: resolve,
|
|
11073
|
+
reject: reject
|
|
11074
|
+
});
|
|
11463
11075
|
});
|
|
11464
11076
|
};
|
|
11465
|
-
|
|
11466
|
-
|
|
11467
|
-
|
|
11468
|
-
|
|
11469
|
-
|
|
11470
|
-
|
|
11471
|
-
|
|
11472
|
-
|
|
11077
|
+
/**
|
|
11078
|
+
* Hashes a string input using SHA-256 and returns the hex digest
|
|
11079
|
+
* Uses the Web Crypto API for secure hashing
|
|
11080
|
+
*
|
|
11081
|
+
* @param {string} input - The string to hash
|
|
11082
|
+
* @returns {Promise<string>} The SHA-256 hash as a hexadecimal string
|
|
11083
|
+
*/
|
|
11084
|
+
RoktManager.prototype.sha256Hex = function (input) {
|
|
11085
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
11086
|
+
var encoder, encodedInput, digest;
|
|
11087
|
+
return __generator(this, function (_a) {
|
|
11088
|
+
switch (_a.label) {
|
|
11089
|
+
case 0:
|
|
11090
|
+
encoder = new TextEncoder();
|
|
11091
|
+
encodedInput = encoder.encode(input);
|
|
11092
|
+
return [4 /*yield*/, crypto.subtle.digest('SHA-256', encodedInput)];
|
|
11093
|
+
case 1:
|
|
11094
|
+
digest = _a.sent();
|
|
11095
|
+
return [2 /*return*/, this.arrayBufferToHex(digest)];
|
|
11096
|
+
}
|
|
11097
|
+
});
|
|
11098
|
+
});
|
|
11099
|
+
};
|
|
11100
|
+
/**
|
|
11101
|
+
* Converts an ArrayBuffer to a hexadecimal string representation
|
|
11102
|
+
* Each byte is converted to a 2-character hex string with leading zeros
|
|
11103
|
+
*
|
|
11104
|
+
* @param {ArrayBuffer} buffer - The buffer to convert
|
|
11105
|
+
* @returns {string} The hexadecimal string representation
|
|
11106
|
+
*/
|
|
11107
|
+
RoktManager.prototype.arrayBufferToHex = function (buffer) {
|
|
11108
|
+
var bytes = new Uint8Array(buffer);
|
|
11109
|
+
var hexString = '';
|
|
11110
|
+
for (var i = 0; i < bytes.length; i++) {
|
|
11111
|
+
var hexByte = bytes[i].toString(16).padStart(2, '0');
|
|
11112
|
+
hexString += hexByte;
|
|
11473
11113
|
}
|
|
11474
|
-
|
|
11475
|
-
|
|
11476
|
-
|
|
11477
|
-
|
|
11114
|
+
return hexString;
|
|
11115
|
+
};
|
|
11116
|
+
/**
|
|
11117
|
+
* Checks if an identity value has changed by comparing current and new values
|
|
11118
|
+
*
|
|
11119
|
+
* @param {string | undefined} currentValue - The current identity value
|
|
11120
|
+
* @param {string | undefined} newValue - The new identity value to compare against
|
|
11121
|
+
* @returns {boolean} True if the identity has changed (new value exists and differs from current), false otherwise
|
|
11122
|
+
*/
|
|
11123
|
+
RoktManager.prototype.hasIdentityChanged = function (currentValue, newValue) {
|
|
11124
|
+
if (!newValue) {
|
|
11125
|
+
return false;
|
|
11126
|
+
}
|
|
11127
|
+
if (!currentValue) {
|
|
11128
|
+
return true; // New value exists but no current value
|
|
11129
|
+
}
|
|
11130
|
+
|
|
11131
|
+
if (currentValue !== newValue) {
|
|
11132
|
+
return true; // Values are different
|
|
11478
11133
|
}
|
|
11134
|
+
|
|
11135
|
+
return false; // Values are the same
|
|
11479
11136
|
};
|
|
11480
|
-
|
|
11481
|
-
|
|
11482
|
-
|
|
11483
|
-
|
|
11484
|
-
|
|
11485
|
-
|
|
11137
|
+
|
|
11138
|
+
return RoktManager;
|
|
11139
|
+
}();
|
|
11140
|
+
|
|
11141
|
+
/**
|
|
11142
|
+
* CookieConsentManager handles storage and access of consent flags (noFunctional, noTargeting)
|
|
11143
|
+
* that are passed via launcherOptions during SDK initialization.
|
|
11144
|
+
*
|
|
11145
|
+
* These flags allow Rokt integration to respect user privacy choices.
|
|
11146
|
+
*
|
|
11147
|
+
* Default behavior: Both flags default to false, meaning all features are allowed
|
|
11148
|
+
* unless explicitly opted out by the user.
|
|
11149
|
+
*/
|
|
11150
|
+
var CookieConsentManager = /** @class */function () {
|
|
11151
|
+
function CookieConsentManager(flags) {
|
|
11152
|
+
this.flags = flags;
|
|
11153
|
+
this.flags = {
|
|
11154
|
+
noFunctional: flags.noFunctional === true,
|
|
11155
|
+
noTargeting: flags.noTargeting === true
|
|
11156
|
+
};
|
|
11157
|
+
}
|
|
11158
|
+
/**
|
|
11159
|
+
* Returns true if third-party targeting is disabled.
|
|
11160
|
+
* Targeting is allowed when noTargeting is false (default).
|
|
11161
|
+
*/
|
|
11162
|
+
CookieConsentManager.prototype.getNoTargeting = function () {
|
|
11163
|
+
return this.flags.noTargeting;
|
|
11164
|
+
};
|
|
11165
|
+
/**
|
|
11166
|
+
* Returns true if functional tracking is disabled.
|
|
11167
|
+
* Functional tracking is allowed when noFunctional is false (default).
|
|
11168
|
+
*/
|
|
11169
|
+
CookieConsentManager.prototype.getNoFunctional = function () {
|
|
11170
|
+
return this.flags.noFunctional;
|
|
11171
|
+
};
|
|
11172
|
+
CookieConsentManager.prototype.syncNoTargetingAttribute = function (user) {
|
|
11173
|
+
if (!user) return;
|
|
11174
|
+
if (this.flags.noTargeting) {
|
|
11175
|
+
user.setUserAttribute(NO_TARGETING_ATTRIBUTE, true);
|
|
11176
|
+
} else if (user.getAllUserAttributes().hasOwnProperty(NO_TARGETING_ATTRIBUTE)) {
|
|
11177
|
+
user.removeUserAttribute(NO_TARGETING_ATTRIBUTE);
|
|
11486
11178
|
}
|
|
11487
|
-
this.log("[accept] pathname changed, scheduling fire (source: ".concat(source, ", from: ").concat(this.lastPath, ", to: ").concat(candidatePath, ")"));
|
|
11488
|
-
this.lastPath = candidatePath;
|
|
11489
|
-
this.scheduleFire(candidatePath);
|
|
11490
11179
|
};
|
|
11491
|
-
|
|
11492
|
-
|
|
11493
|
-
|
|
11494
|
-
|
|
11495
|
-
|
|
11180
|
+
return CookieConsentManager;
|
|
11181
|
+
}();
|
|
11182
|
+
|
|
11183
|
+
var ErrorReportingDispatcher = /** @class */function () {
|
|
11184
|
+
function ErrorReportingDispatcher() {
|
|
11185
|
+
this.services = [];
|
|
11186
|
+
}
|
|
11187
|
+
ErrorReportingDispatcher.prototype.register = function (service) {
|
|
11188
|
+
this.services.push(service);
|
|
11189
|
+
};
|
|
11190
|
+
ErrorReportingDispatcher.prototype.report = function (error) {
|
|
11496
11191
|
var _this = this;
|
|
11497
|
-
|
|
11498
|
-
|
|
11499
|
-
|
|
11500
|
-
|
|
11501
|
-
|
|
11502
|
-
_this.
|
|
11503
|
-
return;
|
|
11192
|
+
this.services.forEach(function (s) {
|
|
11193
|
+
var _a;
|
|
11194
|
+
try {
|
|
11195
|
+
s.report(error);
|
|
11196
|
+
} catch (e) {
|
|
11197
|
+
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error('Error in ErrorReportingService: ' + e);
|
|
11504
11198
|
}
|
|
11505
|
-
_this.mpInstance._SessionManager.resetSessionTimer();
|
|
11506
|
-
_this.firePageView(path);
|
|
11507
|
-
}, 0);
|
|
11508
|
-
this.pendingNavigations.push({
|
|
11509
|
-
path: path,
|
|
11510
|
-
timeoutId: timeoutId
|
|
11511
11199
|
});
|
|
11512
11200
|
};
|
|
11513
|
-
|
|
11514
|
-
|
|
11515
|
-
|
|
11516
|
-
|
|
11517
|
-
|
|
11518
|
-
|
|
11519
|
-
|
|
11520
|
-
|
|
11521
|
-
this.
|
|
11201
|
+
return ErrorReportingDispatcher;
|
|
11202
|
+
}();
|
|
11203
|
+
|
|
11204
|
+
var LoggingDispatcher = /** @class */function () {
|
|
11205
|
+
function LoggingDispatcher() {
|
|
11206
|
+
this.services = [];
|
|
11207
|
+
}
|
|
11208
|
+
LoggingDispatcher.prototype.register = function (service) {
|
|
11209
|
+
this.services.push(service);
|
|
11522
11210
|
};
|
|
11523
|
-
|
|
11524
|
-
|
|
11211
|
+
LoggingDispatcher.prototype.log = function (entry) {
|
|
11212
|
+
var _this = this;
|
|
11213
|
+
this.services.forEach(function (s) {
|
|
11214
|
+
var _a;
|
|
11215
|
+
try {
|
|
11216
|
+
s.log(entry);
|
|
11217
|
+
} catch (e) {
|
|
11218
|
+
(_a = _this.logger) === null || _a === void 0 ? void 0 : _a.error('Error in LoggingService: ' + e);
|
|
11219
|
+
}
|
|
11220
|
+
});
|
|
11525
11221
|
};
|
|
11526
|
-
return
|
|
11222
|
+
return LoggingDispatcher;
|
|
11527
11223
|
}();
|
|
11528
11224
|
|
|
11529
11225
|
var Messages = Constants.Messages,
|
|
@@ -11989,11 +11685,11 @@ var mParticle = (function () {
|
|
|
11989
11685
|
title: window.document.title
|
|
11990
11686
|
};
|
|
11991
11687
|
} else if (!self._Helpers.isObject(attrs)) {
|
|
11992
|
-
self.Logger.error('The attributes argument must be an object. A ' + _typeof
|
|
11688
|
+
self.Logger.error('The attributes argument must be an object. A ' + _typeof(attrs) + ' was entered. Please correct and retry.');
|
|
11993
11689
|
return;
|
|
11994
11690
|
}
|
|
11995
11691
|
if (customFlags && !self._Helpers.isObject(customFlags)) {
|
|
11996
|
-
self.Logger.error('The customFlags argument must be an object. A ' + _typeof
|
|
11692
|
+
self.Logger.error('The customFlags argument must be an object. A ' + _typeof(customFlags) + ' was entered. Please correct and retry.');
|
|
11997
11693
|
return;
|
|
11998
11694
|
}
|
|
11999
11695
|
}
|
|
@@ -12423,17 +12119,17 @@ var mParticle = (function () {
|
|
|
12423
12119
|
self._Store.integrationAttributes[integrationId][key] = attrs[key];
|
|
12424
12120
|
}
|
|
12425
12121
|
} else {
|
|
12426
|
-
self.Logger.error('Values for integration attributes must be strings. You entered a ' + _typeof
|
|
12122
|
+
self.Logger.error('Values for integration attributes must be strings. You entered a ' + _typeof(attrs[key]));
|
|
12427
12123
|
continue;
|
|
12428
12124
|
}
|
|
12429
12125
|
} else {
|
|
12430
|
-
self.Logger.error('Keys must be strings, you entered a ' + _typeof
|
|
12126
|
+
self.Logger.error('Keys must be strings, you entered a ' + _typeof(key));
|
|
12431
12127
|
continue;
|
|
12432
12128
|
}
|
|
12433
12129
|
}
|
|
12434
12130
|
}
|
|
12435
12131
|
} else {
|
|
12436
|
-
self.Logger.error('Attrs must be an object with keys and values. You entered a ' + _typeof
|
|
12132
|
+
self.Logger.error('Attrs must be an object with keys and values. You entered a ' + _typeof(attrs));
|
|
12437
12133
|
return;
|
|
12438
12134
|
}
|
|
12439
12135
|
self._Persistence.update();
|