@mparticle/web-sdk 2.79.2 → 2.80.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +52 -0
- package/dist/mparticle.common.js +156 -56
- package/dist/mparticle.esm.js +156 -56
- package/dist/mparticle.js +941 -708
- package/dist/types/src/filteredMparticleUser.d.ts +15 -7
- package/dist/types/src/forwardingStatsUploader.d.ts +4 -4
- package/dist/types/src/mp-instance.d.ts +3 -2
- package/dist/types/src/nativeSdkHelpers.d.ts +3 -12
- package/dist/types/src/nativeSdkHelpers.interfaces.d.ts +15 -1
- package/dist/types/src/pageViewTracker.d.ts +35 -24
- package/dist/types/src/persistence.d.ts +3 -44
- package/dist/types/src/persistence.interfaces.d.ts +10 -10
- package/dist/types/src/sdkRuntimeModels.d.ts +5 -3
- package/dist/types/src/store.d.ts +3 -0
- package/package.json +1 -1
- package/src/events.ts +9 -1
- package/src/filteredMparticleUser.ts +160 -0
- package/src/{forwardingStatsUploader.js → forwardingStatsUploader.ts} +25 -12
- package/src/mp-instance.ts +27 -25
- package/src/nativeSdkHelpers.interfaces.ts +21 -1
- package/src/{nativeSdkHelpers.js → nativeSdkHelpers.ts} +59 -34
- package/src/pageViewTracker.ts +475 -281
- package/src/persistence.interfaces.ts +10 -10
- package/src/persistence.ts +1210 -0
- package/src/sdkRuntimeModels.ts +5 -3
- package/src/store.ts +3 -0
- package/src/filteredMparticleUser.js +0 -101
- 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.0";
|
|
208
208
|
|
|
209
209
|
var Constants = {
|
|
210
210
|
sdkVersion: version,
|
|
@@ -3866,7 +3866,7 @@ var mParticle = (function () {
|
|
|
3866
3866
|
filteredUserIdentities.push(identity);
|
|
3867
3867
|
}
|
|
3868
3868
|
}
|
|
3869
|
-
function buildFilteredUserIdentities(userIdentitiesObject, filterList, inArray) {
|
|
3869
|
+
function buildFilteredUserIdentities$1(userIdentitiesObject, filterList, inArray) {
|
|
3870
3870
|
var filteredUserIdentities = [];
|
|
3871
3871
|
if (!userIdentitiesObject || !Object.keys(userIdentitiesObject).length) {
|
|
3872
3872
|
return filteredUserIdentities;
|
|
@@ -3988,7 +3988,7 @@ var mParticle = (function () {
|
|
|
3988
3988
|
return xhr;
|
|
3989
3989
|
};
|
|
3990
3990
|
this.filterUserIdentities = function (userIdentitiesObject, filterList) {
|
|
3991
|
-
return buildFilteredUserIdentities(userIdentitiesObject, filterList, self.inArray);
|
|
3991
|
+
return buildFilteredUserIdentities$1(userIdentitiesObject, filterList, self.inArray);
|
|
3992
3992
|
};
|
|
3993
3993
|
this.filterUserIdentitiesForForwarders = KitFilterHelper.filterUserIdentities;
|
|
3994
3994
|
this.filterUserAttributes = KitFilterHelper.filterUserAttributes;
|
|
@@ -4056,6 +4056,15 @@ var mParticle = (function () {
|
|
|
4056
4056
|
var Messages$8 = Constants.Messages;
|
|
4057
4057
|
var androidBridgeNameBase = 'mParticleAndroid';
|
|
4058
4058
|
var iosBridgeNameBase = 'mParticle';
|
|
4059
|
+
function getAndroidBridge(name) {
|
|
4060
|
+
if (!Object.prototype.hasOwnProperty.call(window, name)) {
|
|
4061
|
+
return undefined;
|
|
4062
|
+
}
|
|
4063
|
+
return window[name];
|
|
4064
|
+
}
|
|
4065
|
+
function getInstanceNamedValue(instance, name) {
|
|
4066
|
+
return instance[name];
|
|
4067
|
+
}
|
|
4059
4068
|
function NativeSdkHelpers(mpInstance) {
|
|
4060
4069
|
var self = this;
|
|
4061
4070
|
this.initializeSessionAttributes = function (apiKey) {
|
|
@@ -4074,14 +4083,14 @@ var mParticle = (function () {
|
|
|
4074
4083
|
}
|
|
4075
4084
|
};
|
|
4076
4085
|
this.isBridgeV2Available = function (bridgeName) {
|
|
4086
|
+
var _a, _b;
|
|
4077
4087
|
if (!bridgeName) {
|
|
4078
4088
|
return false;
|
|
4079
4089
|
}
|
|
4080
4090
|
var androidBridgeName = androidBridgeNameBase + '_' + bridgeName + '_v2';
|
|
4081
4091
|
var iosBridgeName = iosBridgeNameBase + '_' + bridgeName + '_v2';
|
|
4082
|
-
|
|
4083
4092
|
// iOS v2 bridge
|
|
4084
|
-
if (window.webkit
|
|
4093
|
+
if ((_b = (_a = window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b.hasOwnProperty(iosBridgeName)) {
|
|
4085
4094
|
return true;
|
|
4086
4095
|
}
|
|
4087
4096
|
// other iOS v2 bridge
|
|
@@ -4101,7 +4110,6 @@ var mParticle = (function () {
|
|
|
4101
4110
|
if (minWebviewBridgeVersion === 2) {
|
|
4102
4111
|
return mpInstance._Store.bridgeV2Available;
|
|
4103
4112
|
}
|
|
4104
|
-
|
|
4105
4113
|
// iOS BridgeV1 can be available via mParticle.isIOS, but return false if uiwebviewBridgeName doesn't match requiredWebviewBridgeName
|
|
4106
4114
|
if (window.mParticle) {
|
|
4107
4115
|
if (window.mParticle.uiwebviewBridgeName && window.mParticle.uiwebviewBridgeName !== iosBridgeNameBase + '_' + requiredWebviewBridgeName + '_v2') {
|
|
@@ -4150,19 +4158,19 @@ var mParticle = (function () {
|
|
|
4150
4158
|
iframe.parentNode.removeChild(iframe);
|
|
4151
4159
|
};
|
|
4152
4160
|
this.sendViaBridgeV2 = function (path, value, requiredWebviewBridgeName) {
|
|
4161
|
+
var _a, _b;
|
|
4153
4162
|
if (!requiredWebviewBridgeName) {
|
|
4154
4163
|
return;
|
|
4155
4164
|
}
|
|
4156
4165
|
var androidBridgeName = androidBridgeNameBase + '_' + requiredWebviewBridgeName + '_v2',
|
|
4157
|
-
androidBridge =
|
|
4158
|
-
iosBridgeName = iosBridgeNameBase + '_' + requiredWebviewBridgeName + '_v2'
|
|
4159
|
-
|
|
4160
|
-
|
|
4161
|
-
if (window.webkit && window.webkit.messageHandlers && window.webkit.messageHandlers[iosBridgeName]) {
|
|
4166
|
+
androidBridge = getAndroidBridge(androidBridgeName),
|
|
4167
|
+
iosBridgeName = iosBridgeNameBase + '_' + requiredWebviewBridgeName + '_v2';
|
|
4168
|
+
var iOSBridgeMessageHandler, iOSBridgeNonMessageHandler;
|
|
4169
|
+
if ((_b = (_a = window.webkit) === null || _a === void 0 ? void 0 : _a.messageHandlers) === null || _b === void 0 ? void 0 : _b[iosBridgeName]) {
|
|
4162
4170
|
iOSBridgeMessageHandler = window.webkit.messageHandlers[iosBridgeName];
|
|
4163
4171
|
}
|
|
4164
4172
|
if (mpInstance.uiwebviewBridgeName === iosBridgeName) {
|
|
4165
|
-
iOSBridgeNonMessageHandler = mpInstance
|
|
4173
|
+
iOSBridgeNonMessageHandler = getInstanceNamedValue(mpInstance, iosBridgeName);
|
|
4166
4174
|
}
|
|
4167
4175
|
if (androidBridge && androidBridge.hasOwnProperty(path)) {
|
|
4168
4176
|
mpInstance.Logger.verbose(Messages$8.InformationMessages.SendAndroid + path);
|
|
@@ -5597,90 +5605,101 @@ var mParticle = (function () {
|
|
|
5597
5605
|
Base64CookieKeys = Constants.Base64CookieKeys,
|
|
5598
5606
|
SDKv2NonMPIDCookieKeys = Constants.SDKv2NonMPIDCookieKeys,
|
|
5599
5607
|
StorageNames = Constants.StorageNames;
|
|
5608
|
+
function getMParticleManager() {
|
|
5609
|
+
return window.mParticle;
|
|
5610
|
+
}
|
|
5600
5611
|
function _Persistence(mpInstance) {
|
|
5601
5612
|
var self = this;
|
|
5602
|
-
|
|
5603
5613
|
// https://go.mparticle.com/work/SQDSDKS-5022
|
|
5604
5614
|
this.useLocalStorage = function () {
|
|
5605
5615
|
return !mpInstance._Store.SDKConfig.useCookieStorage && mpInstance._Store.isLocalStorageAvailable;
|
|
5606
5616
|
};
|
|
5617
|
+
function setFirstRunFromExistingData(localStorageData, cookies) {
|
|
5618
|
+
if (!localStorageData && !cookies) {
|
|
5619
|
+
mpInstance._Store.isFirstRun = true;
|
|
5620
|
+
mpInstance._Store.mpid = 0;
|
|
5621
|
+
return;
|
|
5622
|
+
}
|
|
5623
|
+
mpInstance._Store.isFirstRun = false;
|
|
5624
|
+
}
|
|
5625
|
+
function mergeStorageSources(localStorageData, cookies) {
|
|
5626
|
+
if (localStorageData && cookies) {
|
|
5627
|
+
// https://go.mparticle.com/work/SQDSDKS-6047
|
|
5628
|
+
return extend(false, localStorageData, cookies);
|
|
5629
|
+
}
|
|
5630
|
+
return localStorageData || cookies;
|
|
5631
|
+
}
|
|
5632
|
+
// For migrating from localStorage to cookies -- If an instance switches from
|
|
5633
|
+
// localStorage to cookies, then no mParticle cookie exists yet and there is
|
|
5634
|
+
// localStorage. Get the localStorage, set them to cookies, then delete the
|
|
5635
|
+
// localStorage item.
|
|
5636
|
+
function migrateLocalStorageToCookies(storage, localStorageData, cookies) {
|
|
5637
|
+
var allData;
|
|
5638
|
+
if (localStorageData) {
|
|
5639
|
+
allData = mergeStorageSources(localStorageData, cookies);
|
|
5640
|
+
storage.removeItem(mpInstance._Store.storageName);
|
|
5641
|
+
} else if (cookies) {
|
|
5642
|
+
allData = cookies;
|
|
5643
|
+
}
|
|
5644
|
+
self.storeDataInMemory(allData);
|
|
5645
|
+
return allData;
|
|
5646
|
+
}
|
|
5647
|
+
// For migrating from cookie to localStorage -- If an instance is newly
|
|
5648
|
+
// switching from cookies to localStorage, then no mParticle localStorage
|
|
5649
|
+
// exists yet and there are cookies. Get the cookies, set them to
|
|
5650
|
+
// localStorage, then delete the cookies.
|
|
5651
|
+
function migrateCookiesToLocalStorage(localStorageData, cookies) {
|
|
5652
|
+
if (!cookies) {
|
|
5653
|
+
self.storeDataInMemory(localStorageData);
|
|
5654
|
+
return;
|
|
5655
|
+
}
|
|
5656
|
+
var allData = mergeStorageSources(localStorageData, cookies);
|
|
5657
|
+
self.storeDataInMemory(allData);
|
|
5658
|
+
self.expireCookies(mpInstance._Store.storageName);
|
|
5659
|
+
return allData;
|
|
5660
|
+
}
|
|
5661
|
+
function loadPersistenceIntoMemory(localStorageData, cookies) {
|
|
5662
|
+
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
5663
|
+
self.storeDataInMemory(cookies);
|
|
5664
|
+
return;
|
|
5665
|
+
}
|
|
5666
|
+
if (mpInstance._Store.SDKConfig.useCookieStorage) {
|
|
5667
|
+
return migrateLocalStorageToCookies(window.localStorage, localStorageData, cookies);
|
|
5668
|
+
}
|
|
5669
|
+
return migrateCookiesToLocalStorage(localStorageData, cookies);
|
|
5670
|
+
}
|
|
5671
|
+
function copyNonCurrentUserMpids(allData) {
|
|
5672
|
+
for (var key in allData) {
|
|
5673
|
+
if (allData.hasOwnProperty(key) && !SDKv2NonMPIDCookieKeys[key]) {
|
|
5674
|
+
mpInstance._Store.nonCurrentUserMPIDs[key] = allData[key];
|
|
5675
|
+
}
|
|
5676
|
+
}
|
|
5677
|
+
}
|
|
5678
|
+
function clearCorruptStorage() {
|
|
5679
|
+
if (self.useLocalStorage() && mpInstance._Store.isLocalStorageAvailable) {
|
|
5680
|
+
localStorage.removeItem(mpInstance._Store.storageName);
|
|
5681
|
+
return;
|
|
5682
|
+
}
|
|
5683
|
+
self.expireCookies(mpInstance._Store.storageName);
|
|
5684
|
+
}
|
|
5607
5685
|
this.initializeStorage = function () {
|
|
5608
5686
|
try {
|
|
5609
|
-
var
|
|
5610
|
-
|
|
5611
|
-
cookies = self.getCookie(),
|
|
5612
|
-
allData;
|
|
5613
|
-
|
|
5687
|
+
var localStorageData = self.getLocalStorage();
|
|
5688
|
+
var cookies = self.getCookie();
|
|
5614
5689
|
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
5615
|
-
|
|
5616
|
-
if (!localStorageData && !cookies) {
|
|
5617
|
-
mpInstance._Store.isFirstRun = true;
|
|
5618
|
-
mpInstance._Store.mpid = 0;
|
|
5619
|
-
} else {
|
|
5620
|
-
mpInstance._Store.isFirstRun = false;
|
|
5621
|
-
}
|
|
5622
|
-
|
|
5690
|
+
setFirstRunFromExistingData(localStorageData, cookies);
|
|
5623
5691
|
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
5624
5692
|
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
5625
5693
|
mpInstance._Store.SDKConfig.useCookieStorage = true;
|
|
5626
5694
|
}
|
|
5627
|
-
|
|
5628
|
-
// https://go.mparticle.com/work/SQDSDKS-6046
|
|
5629
|
-
if (mpInstance._Store.isLocalStorageAvailable) {
|
|
5630
|
-
storage = window.localStorage;
|
|
5631
|
-
if (mpInstance._Store.SDKConfig.useCookieStorage) {
|
|
5632
|
-
// For migrating from localStorage to cookies -- If an instance switches from localStorage to cookies, then
|
|
5633
|
-
// no mParticle cookie exists yet and there is localStorage. Get the localStorage, set them to cookies, then delete the localStorage item.
|
|
5634
|
-
if (localStorageData) {
|
|
5635
|
-
if (cookies) {
|
|
5636
|
-
// https://go.mparticle.com/work/SQDSDKS-6047
|
|
5637
|
-
allData = extend(false, localStorageData, cookies);
|
|
5638
|
-
} else {
|
|
5639
|
-
allData = localStorageData;
|
|
5640
|
-
}
|
|
5641
|
-
storage.removeItem(mpInstance._Store.storageName);
|
|
5642
|
-
} else if (cookies) {
|
|
5643
|
-
allData = cookies;
|
|
5644
|
-
}
|
|
5645
|
-
self.storeDataInMemory(allData);
|
|
5646
|
-
} else {
|
|
5647
|
-
// For migrating from cookie to localStorage -- If an instance is newly switching from cookies to localStorage, then
|
|
5648
|
-
// no mParticle localStorage exists yet and there are cookies. Get the cookies, set them to localStorage, then delete the cookies.
|
|
5649
|
-
if (cookies) {
|
|
5650
|
-
if (localStorageData) {
|
|
5651
|
-
// https://go.mparticle.com/work/SQDSDKS-6047
|
|
5652
|
-
allData = extend(false, localStorageData, cookies);
|
|
5653
|
-
} else {
|
|
5654
|
-
allData = cookies;
|
|
5655
|
-
}
|
|
5656
|
-
self.storeDataInMemory(allData);
|
|
5657
|
-
self.expireCookies(mpInstance._Store.storageName);
|
|
5658
|
-
} else {
|
|
5659
|
-
self.storeDataInMemory(localStorageData);
|
|
5660
|
-
}
|
|
5661
|
-
}
|
|
5662
|
-
} else {
|
|
5663
|
-
self.storeDataInMemory(cookies);
|
|
5664
|
-
}
|
|
5665
|
-
|
|
5666
5695
|
// https://go.mparticle.com/work/SQDSDKS-6046
|
|
5667
|
-
|
|
5668
|
-
|
|
5669
|
-
if (allData.hasOwnProperty(key)) {
|
|
5670
|
-
if (!SDKv2NonMPIDCookieKeys[key]) {
|
|
5671
|
-
mpInstance._Store.nonCurrentUserMPIDs[key] = allData[key];
|
|
5672
|
-
}
|
|
5673
|
-
}
|
|
5674
|
-
}
|
|
5696
|
+
var allData = loadPersistenceIntoMemory(localStorageData, cookies);
|
|
5697
|
+
copyNonCurrentUserMpids(allData);
|
|
5675
5698
|
self.update();
|
|
5676
5699
|
} catch (e) {
|
|
5677
5700
|
// If cookies or local storage is corrupt, we want to remove it
|
|
5678
5701
|
// so that in the future, initializeStorage will work
|
|
5679
|
-
|
|
5680
|
-
localStorage.removeItem(mpInstance._Store.storageName);
|
|
5681
|
-
} else {
|
|
5682
|
-
self.expireCookies(mpInstance._Store.storageName);
|
|
5683
|
-
}
|
|
5702
|
+
clearCorruptStorage();
|
|
5684
5703
|
mpInstance.Logger.error('Error initializing storage: ' + e);
|
|
5685
5704
|
}
|
|
5686
5705
|
};
|
|
@@ -5692,86 +5711,83 @@ var mParticle = (function () {
|
|
|
5692
5711
|
self.setLocalStorage();
|
|
5693
5712
|
}
|
|
5694
5713
|
};
|
|
5695
|
-
|
|
5714
|
+
function applyEmptyPersistenceDefaults() {
|
|
5715
|
+
mpInstance.Logger.verbose(Messages$4.InformationMessages.CookieNotFound);
|
|
5716
|
+
mpInstance._Store.clientId = mpInstance._Store.clientId || mpInstance._Helpers.generateUniqueId();
|
|
5717
|
+
mpInstance._Store.deviceId = mpInstance._Store.deviceId || mpInstance._Helpers.generateUniqueId();
|
|
5718
|
+
}
|
|
5719
|
+
function hydrateStoreFromPersistence(obj, currentMPID) {
|
|
5720
|
+
// Set MPID first, then change object to match MPID data
|
|
5721
|
+
if (currentMPID) {
|
|
5722
|
+
mpInstance._Store.mpid = currentMPID;
|
|
5723
|
+
} else {
|
|
5724
|
+
mpInstance._Store.mpid = obj.cu || 0;
|
|
5725
|
+
}
|
|
5726
|
+
obj.gs = obj.gs || {};
|
|
5727
|
+
mpInstance._Store.sessionId = obj.gs.sid || mpInstance._Store.sessionId;
|
|
5728
|
+
mpInstance._Store.isEnabled = typeof obj.gs.ie !== 'undefined' ? obj.gs.ie : mpInstance._Store.isEnabled;
|
|
5729
|
+
mpInstance._Store.sessionAttributes = obj.gs.sa || mpInstance._Store.sessionAttributes;
|
|
5730
|
+
mpInstance._Store.localSessionAttributes = obj.gs.lsa || mpInstance._Store.localSessionAttributes;
|
|
5731
|
+
mpInstance._Store.serverSettings = obj.gs.ss || mpInstance._Store.serverSettings;
|
|
5732
|
+
mpInstance._Store.devToken = mpInstance._Store.devToken || obj.gs.dt;
|
|
5733
|
+
mpInstance._Store.SDKConfig.appVersion = mpInstance._Store.SDKConfig.appVersion || obj.gs.av;
|
|
5734
|
+
mpInstance._Store.clientId = obj.gs.cgid || mpInstance._Store.clientId || mpInstance._Helpers.generateUniqueId();
|
|
5735
|
+
// For most persistence values, we prioritize localstorage/cookie values over
|
|
5736
|
+
// Store. However, we allow device ID to be overriden via a config value and
|
|
5737
|
+
// thus the priority of the deviceId value is
|
|
5738
|
+
// 1. value passed via config.deviceId
|
|
5739
|
+
// 2. previous value in persistence
|
|
5740
|
+
// 3. generate new guid
|
|
5741
|
+
mpInstance._Store.deviceId = mpInstance._Store.deviceId || obj.gs.das || mpInstance._Helpers.generateUniqueId();
|
|
5742
|
+
mpInstance._Store.integrationAttributes = obj.gs.ia || {};
|
|
5743
|
+
mpInstance._Store.context = obj.gs.c || mpInstance._Store.context;
|
|
5744
|
+
mpInstance._Store.currentSessionMPIDs = obj.gs.csm || mpInstance._Store.currentSessionMPIDs;
|
|
5745
|
+
mpInstance._Store.isLoggedIn = obj.l === true;
|
|
5746
|
+
if (obj.gs.les) {
|
|
5747
|
+
mpInstance._Store.dateLastEventSent = new Date(obj.gs.les);
|
|
5748
|
+
}
|
|
5749
|
+
mpInstance._Store.sessionStartDate = obj.gs.ssd ? new Date(obj.gs.ssd) : new Date();
|
|
5750
|
+
if (currentMPID) {
|
|
5751
|
+
obj = obj[currentMPID];
|
|
5752
|
+
} else {
|
|
5753
|
+
obj = obj[obj.cu];
|
|
5754
|
+
}
|
|
5755
|
+
}
|
|
5696
5756
|
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
5697
5757
|
this.storeDataInMemory = function (obj, currentMPID) {
|
|
5698
5758
|
try {
|
|
5699
5759
|
if (!obj) {
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
mpInstance._Store.deviceId = mpInstance._Store.deviceId || mpInstance._Helpers.generateUniqueId();
|
|
5703
|
-
} else {
|
|
5704
|
-
// Set MPID first, then change object to match MPID data
|
|
5705
|
-
if (currentMPID) {
|
|
5706
|
-
mpInstance._Store.mpid = currentMPID;
|
|
5707
|
-
} else {
|
|
5708
|
-
mpInstance._Store.mpid = obj.cu || 0;
|
|
5709
|
-
}
|
|
5710
|
-
obj.gs = obj.gs || {};
|
|
5711
|
-
mpInstance._Store.sessionId = obj.gs.sid || mpInstance._Store.sessionId;
|
|
5712
|
-
mpInstance._Store.isEnabled = typeof obj.gs.ie !== 'undefined' ? obj.gs.ie : mpInstance._Store.isEnabled;
|
|
5713
|
-
mpInstance._Store.sessionAttributes = obj.gs.sa || mpInstance._Store.sessionAttributes;
|
|
5714
|
-
mpInstance._Store.localSessionAttributes = obj.gs.lsa || mpInstance._Store.localSessionAttributes;
|
|
5715
|
-
mpInstance._Store.serverSettings = obj.gs.ss || mpInstance._Store.serverSettings;
|
|
5716
|
-
mpInstance._Store.devToken = mpInstance._Store.devToken || obj.gs.dt;
|
|
5717
|
-
mpInstance._Store.SDKConfig.appVersion = mpInstance._Store.SDKConfig.appVersion || obj.gs.av;
|
|
5718
|
-
mpInstance._Store.clientId = obj.gs.cgid || mpInstance._Store.clientId || mpInstance._Helpers.generateUniqueId();
|
|
5719
|
-
|
|
5720
|
-
// For most persistence values, we prioritize localstorage/cookie values over
|
|
5721
|
-
// Store. However, we allow device ID to be overriden via a config value and
|
|
5722
|
-
// thus the priority of the deviceId value is
|
|
5723
|
-
// 1. value passed via config.deviceId
|
|
5724
|
-
// 2. previous value in persistence
|
|
5725
|
-
// 3. generate new guid
|
|
5726
|
-
mpInstance._Store.deviceId = mpInstance._Store.deviceId || obj.gs.das || mpInstance._Helpers.generateUniqueId();
|
|
5727
|
-
mpInstance._Store.integrationAttributes = obj.gs.ia || {};
|
|
5728
|
-
mpInstance._Store.context = obj.gs.c || mpInstance._Store.context;
|
|
5729
|
-
mpInstance._Store.currentSessionMPIDs = obj.gs.csm || mpInstance._Store.currentSessionMPIDs;
|
|
5730
|
-
mpInstance._Store.isLoggedIn = obj.l === true;
|
|
5731
|
-
if (obj.gs.les) {
|
|
5732
|
-
mpInstance._Store.dateLastEventSent = new Date(obj.gs.les);
|
|
5733
|
-
}
|
|
5734
|
-
if (obj.gs.ssd) {
|
|
5735
|
-
mpInstance._Store.sessionStartDate = new Date(obj.gs.ssd);
|
|
5736
|
-
} else {
|
|
5737
|
-
mpInstance._Store.sessionStartDate = new Date();
|
|
5738
|
-
}
|
|
5739
|
-
if (currentMPID) {
|
|
5740
|
-
obj = obj[currentMPID];
|
|
5741
|
-
} else {
|
|
5742
|
-
obj = obj[obj.cu];
|
|
5743
|
-
}
|
|
5760
|
+
applyEmptyPersistenceDefaults();
|
|
5761
|
+
return;
|
|
5744
5762
|
}
|
|
5763
|
+
hydrateStoreFromPersistence(obj, currentMPID);
|
|
5745
5764
|
} catch (e) {
|
|
5746
5765
|
mpInstance.Logger.error(Messages$4.ErrorMessages.CookieParseError);
|
|
5747
5766
|
}
|
|
5748
5767
|
};
|
|
5749
|
-
|
|
5750
5768
|
// https://go.mparticle.com/work/SQDSDKS-5022
|
|
5751
5769
|
this.determineLocalStorageAvailability = function (storage) {
|
|
5752
|
-
var
|
|
5753
|
-
if (
|
|
5754
|
-
|
|
5770
|
+
var mParticleManager = getMParticleManager();
|
|
5771
|
+
if (mParticleManager === null || mParticleManager === void 0 ? void 0 : mParticleManager._forceNoLocalStorage) {
|
|
5772
|
+
return false;
|
|
5755
5773
|
}
|
|
5756
5774
|
try {
|
|
5757
5775
|
storage.setItem('mparticle', 'test');
|
|
5758
|
-
result = storage.getItem('mparticle') === 'test';
|
|
5776
|
+
var result = storage.getItem('mparticle') === 'test';
|
|
5759
5777
|
storage.removeItem('mparticle');
|
|
5760
|
-
return result && storage;
|
|
5778
|
+
return Boolean(result && storage);
|
|
5761
5779
|
} catch (e) {
|
|
5762
5780
|
return false;
|
|
5763
5781
|
}
|
|
5764
5782
|
};
|
|
5765
|
-
|
|
5766
5783
|
// https://go.mparticle.com/work/SQDSDKS-6021
|
|
5767
5784
|
this.setLocalStorage = function () {
|
|
5768
|
-
var
|
|
5785
|
+
var _a;
|
|
5769
5786
|
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
5770
5787
|
return;
|
|
5771
5788
|
}
|
|
5772
|
-
|
|
5773
5789
|
// Block mprtcl-v4 localStorage when noFunctional is true
|
|
5774
|
-
if ((
|
|
5790
|
+
if ((_a = mpInstance._CookieConsentManager) === null || _a === void 0 ? void 0 : _a.getNoFunctional()) {
|
|
5775
5791
|
return;
|
|
5776
5792
|
}
|
|
5777
5793
|
var key = mpInstance._Store.storageName,
|
|
@@ -5821,16 +5837,16 @@ var mParticle = (function () {
|
|
|
5821
5837
|
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
5822
5838
|
return null;
|
|
5823
5839
|
}
|
|
5824
|
-
var key = mpInstance._Store.storageName
|
|
5825
|
-
|
|
5826
|
-
|
|
5827
|
-
|
|
5828
|
-
|
|
5829
|
-
|
|
5830
|
-
|
|
5831
|
-
|
|
5832
|
-
|
|
5833
|
-
|
|
5840
|
+
var key = mpInstance._Store.storageName;
|
|
5841
|
+
var decodedPersistence = self.decodePersistence(window.localStorage.getItem(key));
|
|
5842
|
+
if (!decodedPersistence) {
|
|
5843
|
+
return null;
|
|
5844
|
+
}
|
|
5845
|
+
var parsedPersistence = JSON.parse(decodedPersistence);
|
|
5846
|
+
var obj = {};
|
|
5847
|
+
for (var key_1 in parsedPersistence) {
|
|
5848
|
+
if (parsedPersistence.hasOwnProperty(key_1)) {
|
|
5849
|
+
obj[key_1] = parsedPersistence[key_1];
|
|
5834
5850
|
}
|
|
5835
5851
|
}
|
|
5836
5852
|
if (Object.keys(obj).length) {
|
|
@@ -5838,9 +5854,6 @@ var mParticle = (function () {
|
|
|
5838
5854
|
}
|
|
5839
5855
|
return null;
|
|
5840
5856
|
};
|
|
5841
|
-
function removeLocalStorage(localStorageName) {
|
|
5842
|
-
localStorage.removeItem(localStorageName);
|
|
5843
|
-
}
|
|
5844
5857
|
this.expireCookies = function (cookieName) {
|
|
5845
5858
|
var date = new Date(),
|
|
5846
5859
|
expires,
|
|
@@ -5895,13 +5908,12 @@ var mParticle = (function () {
|
|
|
5895
5908
|
return null;
|
|
5896
5909
|
}
|
|
5897
5910
|
};
|
|
5898
|
-
|
|
5899
5911
|
// https://go.mparticle.com/work/SQDSDKS-5022
|
|
5900
5912
|
// https://go.mparticle.com/work/SQDSDKS-6021
|
|
5901
5913
|
this.setCookie = function () {
|
|
5902
|
-
var
|
|
5914
|
+
var _a;
|
|
5903
5915
|
// Block mprtcl-v4 cookies when noFunctional is true
|
|
5904
|
-
if ((
|
|
5916
|
+
if ((_a = mpInstance._CookieConsentManager) === null || _a === void 0 ? void 0 : _a.getNoFunctional()) {
|
|
5905
5917
|
return;
|
|
5906
5918
|
}
|
|
5907
5919
|
var mpid,
|
|
@@ -5912,7 +5924,7 @@ var mParticle = (function () {
|
|
|
5912
5924
|
var date = new Date(),
|
|
5913
5925
|
key = mpInstance._Store.storageName,
|
|
5914
5926
|
cookies = self.getCookie() || {},
|
|
5915
|
-
expires = new Date(date.getTime() + mpInstance._Store.SDKConfig.cookieExpiration * 24 * 60 * 60 * 1000).
|
|
5927
|
+
expires = new Date(date.getTime() + mpInstance._Store.SDKConfig.cookieExpiration * 24 * 60 * 60 * 1000).toUTCString(),
|
|
5916
5928
|
cookieDomain,
|
|
5917
5929
|
domain,
|
|
5918
5930
|
encodedCookiesWithExpirationAndPath;
|
|
@@ -5939,7 +5951,6 @@ var mParticle = (function () {
|
|
|
5939
5951
|
mpInstance.Logger.verbose(Messages$4.InformationMessages.CookieSet);
|
|
5940
5952
|
window.document.cookie = encodeURIComponent(key) + '=' + encodedCookiesWithExpirationAndPath;
|
|
5941
5953
|
};
|
|
5942
|
-
|
|
5943
5954
|
/* This function determines if a cookie is greater than the configured maxCookieSize.
|
|
5944
5955
|
- If it is, we remove an MPID and its associated UI/UA/CSD from the cookie.
|
|
5945
5956
|
- Once removed, check size, and repeat.
|
|
@@ -5951,171 +5962,258 @@ var mParticle = (function () {
|
|
|
5951
5962
|
b. Then remove MPIDs based on order in currentSessionMPIDs array, which
|
|
5952
5963
|
stores MPIDs based on earliest login.
|
|
5953
5964
|
*/
|
|
5954
|
-
|
|
5955
|
-
|
|
5956
|
-
|
|
5957
|
-
|
|
5958
|
-
|
|
5959
|
-
|
|
5960
|
-
|
|
5961
|
-
|
|
5962
|
-
if (encodedCookiesWithExpirationAndPath.length > maxCookieSize) {
|
|
5963
|
-
if (!SDKv2NonMPIDCookieKeys[key] && key !== persistence.cu) {
|
|
5964
|
-
delete persistence[key];
|
|
5965
|
-
}
|
|
5966
|
-
}
|
|
5967
|
-
}
|
|
5965
|
+
function isEncodedCookieTooLarge(encoded, maxCookieSize) {
|
|
5966
|
+
return encoded.length > maxCookieSize;
|
|
5967
|
+
}
|
|
5968
|
+
function removeUnsessionedMpidsWhenOversized(persistence, expires, domain, maxCookieSize) {
|
|
5969
|
+
var encodedCookiesWithExpirationAndPath;
|
|
5970
|
+
for (var key in persistence) {
|
|
5971
|
+
if (!persistence.hasOwnProperty(key)) {
|
|
5972
|
+
continue;
|
|
5968
5973
|
}
|
|
5969
|
-
|
|
5970
|
-
|
|
5971
|
-
|
|
5972
|
-
for (var potentialMPID in persistence) {
|
|
5973
|
-
if (persistence.hasOwnProperty(potentialMPID)) {
|
|
5974
|
-
if (!SDKv2NonMPIDCookieKeys[potentialMPID] && potentialMPID !== persistence.cu) {
|
|
5975
|
-
MPIDsOnCookie[potentialMPID] = 1;
|
|
5976
|
-
}
|
|
5977
|
-
}
|
|
5974
|
+
encodedCookiesWithExpirationAndPath = createFullEncodedCookie(persistence, expires, domain);
|
|
5975
|
+
if (!isEncodedCookieTooLarge(encodedCookiesWithExpirationAndPath, maxCookieSize)) {
|
|
5976
|
+
continue;
|
|
5978
5977
|
}
|
|
5979
|
-
|
|
5980
|
-
|
|
5981
|
-
for (var mpid in MPIDsOnCookie) {
|
|
5982
|
-
encodedCookiesWithExpirationAndPath = createFullEncodedCookie(persistence, expires, domain);
|
|
5983
|
-
if (encodedCookiesWithExpirationAndPath.length > maxCookieSize) {
|
|
5984
|
-
if (MPIDsOnCookie.hasOwnProperty(mpid)) {
|
|
5985
|
-
if (currentSessionMPIDs.indexOf(mpid) === -1) {
|
|
5986
|
-
delete persistence[mpid];
|
|
5987
|
-
}
|
|
5988
|
-
}
|
|
5989
|
-
}
|
|
5990
|
-
}
|
|
5978
|
+
if (SDKv2NonMPIDCookieKeys[key] || key === persistence.cu) {
|
|
5979
|
+
continue;
|
|
5991
5980
|
}
|
|
5992
|
-
|
|
5993
|
-
|
|
5994
|
-
|
|
5995
|
-
|
|
5996
|
-
|
|
5997
|
-
|
|
5998
|
-
|
|
5999
|
-
|
|
6000
|
-
|
|
6001
|
-
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.');
|
|
6002
|
-
}
|
|
6003
|
-
} else {
|
|
6004
|
-
break;
|
|
6005
|
-
}
|
|
5981
|
+
delete persistence[key];
|
|
5982
|
+
}
|
|
5983
|
+
return encodedCookiesWithExpirationAndPath;
|
|
5984
|
+
}
|
|
5985
|
+
function collectRemovableMpids(persistence) {
|
|
5986
|
+
var MPIDsOnCookie = {};
|
|
5987
|
+
for (var potentialMPID in persistence) {
|
|
5988
|
+
if (!persistence.hasOwnProperty(potentialMPID)) {
|
|
5989
|
+
continue;
|
|
6006
5990
|
}
|
|
5991
|
+
if (SDKv2NonMPIDCookieKeys[potentialMPID] || potentialMPID === persistence.cu) {
|
|
5992
|
+
continue;
|
|
5993
|
+
}
|
|
5994
|
+
MPIDsOnCookie[potentialMPID] = 1;
|
|
5995
|
+
}
|
|
5996
|
+
return MPIDsOnCookie;
|
|
5997
|
+
}
|
|
5998
|
+
function removeMpidsNotInCurrentSession(persistence, MPIDsOnCookie, currentSessionMPIDs, expires, domain, maxCookieSize) {
|
|
5999
|
+
var encodedCookiesWithExpirationAndPath;
|
|
6000
|
+
for (var mpid in MPIDsOnCookie) {
|
|
6001
|
+
encodedCookiesWithExpirationAndPath = createFullEncodedCookie(persistence, expires, domain);
|
|
6002
|
+
if (!isEncodedCookieTooLarge(encodedCookiesWithExpirationAndPath, maxCookieSize)) {
|
|
6003
|
+
continue;
|
|
6004
|
+
}
|
|
6005
|
+
if (!MPIDsOnCookie.hasOwnProperty(mpid)) {
|
|
6006
|
+
continue;
|
|
6007
|
+
}
|
|
6008
|
+
if (currentSessionMPIDs.indexOf(mpid) === -1) {
|
|
6009
|
+
delete persistence[mpid];
|
|
6010
|
+
}
|
|
6011
|
+
}
|
|
6012
|
+
return encodedCookiesWithExpirationAndPath;
|
|
6013
|
+
}
|
|
6014
|
+
function logAndRemoveOversizedMpid(persistence, MPIDtoRemove, maxCookieSize) {
|
|
6015
|
+
if (persistence[MPIDtoRemove]) {
|
|
6016
|
+
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));
|
|
6017
|
+
delete persistence[MPIDtoRemove];
|
|
6018
|
+
return;
|
|
6019
|
+
}
|
|
6020
|
+
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.');
|
|
6021
|
+
}
|
|
6022
|
+
function removeCurrentSessionMpidsByAge(persistence, currentSessionMPIDs, expires, domain, maxCookieSize) {
|
|
6023
|
+
var encodedCookiesWithExpirationAndPath;
|
|
6024
|
+
for (var i = 0; i < currentSessionMPIDs.length; i++) {
|
|
6025
|
+
encodedCookiesWithExpirationAndPath = createFullEncodedCookie(persistence, expires, domain);
|
|
6026
|
+
if (!isEncodedCookieTooLarge(encodedCookiesWithExpirationAndPath, maxCookieSize)) {
|
|
6027
|
+
break;
|
|
6028
|
+
}
|
|
6029
|
+
logAndRemoveOversizedMpid(persistence, currentSessionMPIDs[i], maxCookieSize);
|
|
6007
6030
|
}
|
|
6008
6031
|
return encodedCookiesWithExpirationAndPath;
|
|
6032
|
+
}
|
|
6033
|
+
this.reduceAndEncodePersistence = function (persistence, expires, domain, maxCookieSize) {
|
|
6034
|
+
var currentSessionMPIDs = persistence.gs.csm ? persistence.gs.csm : [];
|
|
6035
|
+
if (!currentSessionMPIDs.length) {
|
|
6036
|
+
return removeUnsessionedMpidsWhenOversized(persistence, expires, domain, maxCookieSize);
|
|
6037
|
+
}
|
|
6038
|
+
var MPIDsOnCookie = collectRemovableMpids(persistence);
|
|
6039
|
+
if (Object.keys(MPIDsOnCookie).length) {
|
|
6040
|
+
removeMpidsNotInCurrentSession(persistence, MPIDsOnCookie, currentSessionMPIDs, expires, domain, maxCookieSize);
|
|
6041
|
+
}
|
|
6042
|
+
return removeCurrentSessionMpidsByAge(persistence, currentSessionMPIDs, expires, domain, maxCookieSize);
|
|
6009
6043
|
};
|
|
6010
6044
|
function createFullEncodedCookie(persistence, expires, domain) {
|
|
6011
6045
|
return self.encodePersistence(JSON.stringify(persistence)) + ';expires=' + expires + ';path=/' + domain;
|
|
6012
6046
|
}
|
|
6013
|
-
|
|
6014
|
-
var
|
|
6047
|
+
function cookieUiMatchesRequestedIdentity(cookieUIs, requestedIdentityType, requestedValue) {
|
|
6048
|
+
for (var cookieUIType in cookieUIs) {
|
|
6049
|
+
if (requestedIdentityType === cookieUIType && requestedValue === cookieUIs[cookieUIType]) {
|
|
6050
|
+
return true;
|
|
6051
|
+
}
|
|
6052
|
+
}
|
|
6053
|
+
return false;
|
|
6054
|
+
}
|
|
6055
|
+
function findMpidForRequestedIdentity(persistence, requestedIdentityType, requestedValue) {
|
|
6015
6056
|
var matchedUser;
|
|
6016
|
-
|
|
6017
|
-
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6021
|
-
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
for (var cookieUIType in cookieUIs) {
|
|
6025
|
-
if (requestedIdentityType === cookieUIType && identityApiData.userIdentities[requestedIdentityType] === cookieUIs[cookieUIType]) {
|
|
6026
|
-
matchedUser = key;
|
|
6027
|
-
break;
|
|
6028
|
-
}
|
|
6029
|
-
}
|
|
6030
|
-
}
|
|
6031
|
-
}
|
|
6032
|
-
}
|
|
6057
|
+
for (var key in persistence) {
|
|
6058
|
+
// any value in persistence that has an MPID key will be an MPID to search through
|
|
6059
|
+
// other keys on the cookie are currentSessionMPIDs and currentMPID which should not be searched
|
|
6060
|
+
if (!persistence[key].mpid) {
|
|
6061
|
+
continue;
|
|
6062
|
+
}
|
|
6063
|
+
if (cookieUiMatchesRequestedIdentity(persistence[key].ui, requestedIdentityType, requestedValue)) {
|
|
6064
|
+
matchedUser = key;
|
|
6033
6065
|
}
|
|
6034
6066
|
}
|
|
6067
|
+
return matchedUser;
|
|
6068
|
+
}
|
|
6069
|
+
function findMpidMatchingIdentities(persistence, identityApiData) {
|
|
6070
|
+
var matchedUser;
|
|
6071
|
+
for (var requestedIdentityType in identityApiData.userIdentities) {
|
|
6072
|
+
if (!persistence || !Object.keys(persistence).length) {
|
|
6073
|
+
continue;
|
|
6074
|
+
}
|
|
6075
|
+
var match = findMpidForRequestedIdentity(persistence, requestedIdentityType, identityApiData.userIdentities[requestedIdentityType]);
|
|
6076
|
+
if (match) {
|
|
6077
|
+
matchedUser = match;
|
|
6078
|
+
}
|
|
6079
|
+
}
|
|
6080
|
+
return matchedUser;
|
|
6081
|
+
}
|
|
6082
|
+
this.findPrevCookiesBasedOnUI = function (identityApiData) {
|
|
6083
|
+
var persistence = mpInstance._Persistence.getPersistence();
|
|
6084
|
+
if (!identityApiData) {
|
|
6085
|
+
return;
|
|
6086
|
+
}
|
|
6087
|
+
var matchedUser = findMpidMatchingIdentities(persistence, identityApiData);
|
|
6035
6088
|
if (matchedUser) {
|
|
6036
6089
|
self.storeDataInMemory(persistence, matchedUser);
|
|
6037
6090
|
}
|
|
6038
6091
|
};
|
|
6039
|
-
|
|
6040
|
-
|
|
6041
|
-
|
|
6042
|
-
|
|
6043
|
-
|
|
6044
|
-
|
|
6045
|
-
|
|
6046
|
-
|
|
6047
|
-
|
|
6048
|
-
|
|
6049
|
-
|
|
6050
|
-
|
|
6051
|
-
|
|
6052
|
-
|
|
6053
|
-
|
|
6054
|
-
|
|
6055
|
-
|
|
6056
|
-
|
|
6057
|
-
|
|
6058
|
-
|
|
6092
|
+
function isNonEmptyArrayOrObject(value) {
|
|
6093
|
+
if (Array.isArray(value)) {
|
|
6094
|
+
return value.length > 0;
|
|
6095
|
+
}
|
|
6096
|
+
if (!mpInstance._Helpers.isObject(value)) {
|
|
6097
|
+
return false;
|
|
6098
|
+
}
|
|
6099
|
+
return Object.keys(value).length > 0;
|
|
6100
|
+
}
|
|
6101
|
+
function encodeGsBase64Field(gs, key) {
|
|
6102
|
+
if (!gs[key] || !isNonEmptyArrayOrObject(gs[key])) {
|
|
6103
|
+
delete gs[key];
|
|
6104
|
+
return;
|
|
6105
|
+
}
|
|
6106
|
+
gs[key] = Base64.encode(JSON.stringify(gs[key]));
|
|
6107
|
+
}
|
|
6108
|
+
function encodeGlobalSettings(gs) {
|
|
6109
|
+
for (var key in gs) {
|
|
6110
|
+
if (!gs.hasOwnProperty(key)) {
|
|
6111
|
+
continue;
|
|
6059
6112
|
}
|
|
6113
|
+
if (Base64CookieKeys[key]) {
|
|
6114
|
+
encodeGsBase64Field(gs, key);
|
|
6115
|
+
continue;
|
|
6116
|
+
}
|
|
6117
|
+
if (key === 'ie') {
|
|
6118
|
+
gs[key] = gs[key] ? 1 : 0;
|
|
6119
|
+
continue;
|
|
6120
|
+
}
|
|
6121
|
+
if (!gs[key]) {
|
|
6122
|
+
delete gs[key];
|
|
6123
|
+
}
|
|
6124
|
+
}
|
|
6125
|
+
}
|
|
6126
|
+
function encodeMpidBase64Field(container, key) {
|
|
6127
|
+
var value = container[key];
|
|
6128
|
+
if (mpInstance._Helpers.isObject(value) && Object.keys(value).length) {
|
|
6129
|
+
container[key] = Base64.encode(JSON.stringify(value));
|
|
6130
|
+
return;
|
|
6060
6131
|
}
|
|
6132
|
+
delete container[key];
|
|
6133
|
+
}
|
|
6134
|
+
function encodeMpidRecord(record) {
|
|
6135
|
+
for (var key in record) {
|
|
6136
|
+
if (!record.hasOwnProperty(key)) {
|
|
6137
|
+
continue;
|
|
6138
|
+
}
|
|
6139
|
+
if (Base64CookieKeys[key]) {
|
|
6140
|
+
encodeMpidBase64Field(record, key);
|
|
6141
|
+
}
|
|
6142
|
+
}
|
|
6143
|
+
}
|
|
6144
|
+
function encodeMpidRecords(persistence) {
|
|
6061
6145
|
for (var mpid in persistence) {
|
|
6062
|
-
if (persistence.hasOwnProperty(mpid)) {
|
|
6063
|
-
|
|
6064
|
-
|
|
6065
|
-
|
|
6066
|
-
|
|
6067
|
-
if (mpInstance._Helpers.isObject(persistence[mpid][key]) && Object.keys(persistence[mpid][key]).length) {
|
|
6068
|
-
persistence[mpid][key] = Base64.encode(JSON.stringify(persistence[mpid][key]));
|
|
6069
|
-
} else {
|
|
6070
|
-
delete persistence[mpid][key];
|
|
6071
|
-
}
|
|
6072
|
-
}
|
|
6073
|
-
}
|
|
6074
|
-
}
|
|
6075
|
-
}
|
|
6146
|
+
if (!persistence.hasOwnProperty(mpid)) {
|
|
6147
|
+
continue;
|
|
6148
|
+
}
|
|
6149
|
+
if (SDKv2NonMPIDCookieKeys[mpid]) {
|
|
6150
|
+
continue;
|
|
6076
6151
|
}
|
|
6152
|
+
encodeMpidRecord(persistence[mpid]);
|
|
6077
6153
|
}
|
|
6154
|
+
}
|
|
6155
|
+
this.encodePersistence = function (persistenceString) {
|
|
6156
|
+
var persistence = JSON.parse(persistenceString);
|
|
6157
|
+
encodeGlobalSettings(persistence.gs);
|
|
6158
|
+
encodeMpidRecords(persistence);
|
|
6078
6159
|
return createCookieString(JSON.stringify(persistence));
|
|
6079
6160
|
};
|
|
6080
|
-
|
|
6161
|
+
function decodeGlobalSettings(gs) {
|
|
6162
|
+
for (var key in gs) {
|
|
6163
|
+
if (!gs.hasOwnProperty(key)) {
|
|
6164
|
+
continue;
|
|
6165
|
+
}
|
|
6166
|
+
if (Base64CookieKeys[key]) {
|
|
6167
|
+
gs[key] = JSON.parse(Base64.decode(gs[key]));
|
|
6168
|
+
continue;
|
|
6169
|
+
}
|
|
6170
|
+
if (key === 'ie') {
|
|
6171
|
+
gs[key] = Boolean(gs[key]);
|
|
6172
|
+
}
|
|
6173
|
+
}
|
|
6174
|
+
}
|
|
6175
|
+
function decodeMpidRecord(record) {
|
|
6176
|
+
for (var key in record) {
|
|
6177
|
+
if (!record.hasOwnProperty(key)) {
|
|
6178
|
+
continue;
|
|
6179
|
+
}
|
|
6180
|
+
if (!Base64CookieKeys[key]) {
|
|
6181
|
+
continue;
|
|
6182
|
+
}
|
|
6183
|
+
if (record[key].length) {
|
|
6184
|
+
record[key] = JSON.parse(Base64.decode(record[key]));
|
|
6185
|
+
}
|
|
6186
|
+
}
|
|
6187
|
+
}
|
|
6188
|
+
function decodeMpidRecords(persistence) {
|
|
6189
|
+
for (var mpid in persistence) {
|
|
6190
|
+
if (!persistence.hasOwnProperty(mpid)) {
|
|
6191
|
+
continue;
|
|
6192
|
+
}
|
|
6193
|
+
if (!SDKv2NonMPIDCookieKeys[mpid]) {
|
|
6194
|
+
decodeMpidRecord(persistence[mpid]);
|
|
6195
|
+
continue;
|
|
6196
|
+
}
|
|
6197
|
+
if (mpid === 'l') {
|
|
6198
|
+
persistence[mpid] = Boolean(persistence[mpid]);
|
|
6199
|
+
}
|
|
6200
|
+
}
|
|
6201
|
+
}
|
|
6081
6202
|
// TODO: This should actually be decodePersistenceString or
|
|
6082
6203
|
// we should refactor this to take a string and return an object
|
|
6083
|
-
this.decodePersistence = function (
|
|
6204
|
+
this.decodePersistence = function (persistenceString) {
|
|
6084
6205
|
try {
|
|
6085
|
-
if (
|
|
6086
|
-
|
|
6087
|
-
|
|
6088
|
-
|
|
6089
|
-
|
|
6090
|
-
|
|
6091
|
-
|
|
6092
|
-
} else if (key === 'ie') {
|
|
6093
|
-
persistence.gs[key] = Boolean(persistence.gs[key]);
|
|
6094
|
-
}
|
|
6095
|
-
}
|
|
6096
|
-
}
|
|
6097
|
-
for (var mpid in persistence) {
|
|
6098
|
-
if (persistence.hasOwnProperty(mpid)) {
|
|
6099
|
-
if (!SDKv2NonMPIDCookieKeys[mpid]) {
|
|
6100
|
-
for (key in persistence[mpid]) {
|
|
6101
|
-
if (persistence[mpid].hasOwnProperty(key)) {
|
|
6102
|
-
if (Base64CookieKeys[key]) {
|
|
6103
|
-
if (persistence[mpid][key].length) {
|
|
6104
|
-
persistence[mpid][key] = JSON.parse(Base64.decode(persistence[mpid][key]));
|
|
6105
|
-
}
|
|
6106
|
-
}
|
|
6107
|
-
}
|
|
6108
|
-
}
|
|
6109
|
-
} else if (mpid === 'l') {
|
|
6110
|
-
persistence[mpid] = Boolean(persistence[mpid]);
|
|
6111
|
-
}
|
|
6112
|
-
}
|
|
6113
|
-
}
|
|
6114
|
-
}
|
|
6115
|
-
return JSON.stringify(persistence);
|
|
6206
|
+
if (!persistenceString) {
|
|
6207
|
+
return;
|
|
6208
|
+
}
|
|
6209
|
+
var persistence = JSON.parse(revertCookieString(persistenceString));
|
|
6210
|
+
if (mpInstance._Helpers.isObject(persistence) && Object.keys(persistence).length) {
|
|
6211
|
+
decodeGlobalSettings(persistence.gs);
|
|
6212
|
+
decodeMpidRecords(persistence);
|
|
6116
6213
|
}
|
|
6214
|
+
return JSON.stringify(persistence);
|
|
6117
6215
|
} catch (e) {
|
|
6118
|
-
mpInstance.Logger.error('Problem with decoding cookie'
|
|
6216
|
+
mpInstance.Logger.error('Problem with decoding cookie');
|
|
6119
6217
|
}
|
|
6120
6218
|
};
|
|
6121
6219
|
this.getCookieDomain = function () {
|
|
@@ -6130,7 +6228,6 @@ var mParticle = (function () {
|
|
|
6130
6228
|
}
|
|
6131
6229
|
}
|
|
6132
6230
|
};
|
|
6133
|
-
|
|
6134
6231
|
// 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.
|
|
6135
6232
|
// For example subdomain.domain.co.uk would try the following combinations:
|
|
6136
6233
|
// "co.uk" -> fail
|
|
@@ -6176,18 +6273,17 @@ var mParticle = (function () {
|
|
|
6176
6273
|
}
|
|
6177
6274
|
}
|
|
6178
6275
|
};
|
|
6179
|
-
|
|
6180
6276
|
// https://go.mparticle.com/work/SQDSDKS-6021
|
|
6181
6277
|
this.savePersistence = function (persistence) {
|
|
6182
|
-
var
|
|
6278
|
+
var _a;
|
|
6183
6279
|
// Block mprtcl-v4 persistence when noFunctional is true
|
|
6184
|
-
if ((
|
|
6280
|
+
if ((_a = mpInstance._CookieConsentManager) === null || _a === void 0 ? void 0 : _a.getNoFunctional()) {
|
|
6185
6281
|
return;
|
|
6186
6282
|
}
|
|
6187
6283
|
var encodedPersistence = self.encodePersistence(JSON.stringify(persistence)),
|
|
6188
6284
|
date = new Date(),
|
|
6189
6285
|
key = mpInstance._Store.storageName,
|
|
6190
|
-
expires = new Date(date.getTime() + mpInstance._Store.SDKConfig.cookieExpiration * 24 * 60 * 60 * 1000).
|
|
6286
|
+
expires = new Date(date.getTime() + mpInstance._Store.SDKConfig.cookieExpiration * 24 * 60 * 60 * 1000).toUTCString(),
|
|
6191
6287
|
cookieDomain = self.getCookieDomain(),
|
|
6192
6288
|
domain;
|
|
6193
6289
|
if (cookieDomain === '') {
|
|
@@ -6223,7 +6319,6 @@ var mParticle = (function () {
|
|
|
6223
6319
|
return null;
|
|
6224
6320
|
}
|
|
6225
6321
|
};
|
|
6226
|
-
|
|
6227
6322
|
/**
|
|
6228
6323
|
* set the "first seen" time for a user. the time will only be set once for a given
|
|
6229
6324
|
* mpid after which subsequent calls will be ignored
|
|
@@ -6247,69 +6342,487 @@ var mParticle = (function () {
|
|
|
6247
6342
|
}
|
|
6248
6343
|
}
|
|
6249
6344
|
};
|
|
6250
|
-
|
|
6251
|
-
|
|
6252
|
-
*
|
|
6253
|
-
*
|
|
6254
|
-
|
|
6255
|
-
|
|
6256
|
-
|
|
6257
|
-
|
|
6258
|
-
|
|
6345
|
+
/**
|
|
6346
|
+
* returns the "last seen" time for a user. If the mpid represents the current user, the
|
|
6347
|
+
* return value will always be the current time, otherwise it will be to stored "last seen"
|
|
6348
|
+
* time
|
|
6349
|
+
*/
|
|
6350
|
+
this.getLastSeenTime = function (mpid) {
|
|
6351
|
+
if (!mpid) {
|
|
6352
|
+
return null;
|
|
6353
|
+
}
|
|
6354
|
+
if (mpid === mpInstance.Identity.getCurrentUser().getMPID()) {
|
|
6355
|
+
//if the mpid is the current user, its last seen time is the current time
|
|
6356
|
+
return new Date().getTime();
|
|
6357
|
+
} else {
|
|
6358
|
+
var persistence = self.getPersistence();
|
|
6359
|
+
if (persistence && persistence[mpid] && persistence[mpid].lst) {
|
|
6360
|
+
return persistence[mpid].lst;
|
|
6361
|
+
}
|
|
6362
|
+
return null;
|
|
6363
|
+
}
|
|
6364
|
+
};
|
|
6365
|
+
this.setLastSeenTime = function (mpid, time) {
|
|
6366
|
+
if (!mpid) {
|
|
6367
|
+
return;
|
|
6368
|
+
}
|
|
6369
|
+
// https://go.mparticle.com/work/SQDSDKS-6329
|
|
6370
|
+
if (!time) {
|
|
6371
|
+
time = new Date().getTime();
|
|
6372
|
+
}
|
|
6373
|
+
var persistence = self.getPersistence();
|
|
6374
|
+
if (persistence && persistence[mpid]) {
|
|
6375
|
+
persistence[mpid].lst = time;
|
|
6376
|
+
self.savePersistence(persistence);
|
|
6377
|
+
}
|
|
6378
|
+
};
|
|
6379
|
+
this.getDeviceId = function () {
|
|
6380
|
+
return mpInstance._Store.deviceId;
|
|
6381
|
+
};
|
|
6382
|
+
this.setDeviceId = function (guid) {
|
|
6383
|
+
mpInstance._Store.deviceId = guid;
|
|
6384
|
+
self.update();
|
|
6385
|
+
};
|
|
6386
|
+
this.resetPersistence = function () {
|
|
6387
|
+
localStorage.clear();
|
|
6388
|
+
self.expireCookies(StorageNames.cookieName);
|
|
6389
|
+
self.expireCookies(StorageNames.cookieNameV2);
|
|
6390
|
+
self.expireCookies(StorageNames.cookieNameV3);
|
|
6391
|
+
self.expireCookies(StorageNames.cookieNameV4);
|
|
6392
|
+
self.expireCookies(mpInstance._Store.storageName);
|
|
6393
|
+
var mParticleManager = getMParticleManager();
|
|
6394
|
+
if (mParticleManager === null || mParticleManager === void 0 ? void 0 : mParticleManager._isTestEnv) {
|
|
6395
|
+
var testWorkspaceToken = 'abcdef';
|
|
6396
|
+
localStorage.removeItem(mpInstance._Helpers.createMainStorageName(testWorkspaceToken));
|
|
6397
|
+
self.expireCookies(mpInstance._Helpers.createMainStorageName(testWorkspaceToken));
|
|
6398
|
+
}
|
|
6399
|
+
};
|
|
6400
|
+
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
6401
|
+
// Forwarder Batching Code
|
|
6402
|
+
this.forwardingStatsBatches = {
|
|
6403
|
+
uploadsTable: {},
|
|
6404
|
+
forwardingStatsEventQueue: []
|
|
6405
|
+
};
|
|
6406
|
+
}
|
|
6407
|
+
|
|
6408
|
+
var HISTORY_METHODS = ['pushState', 'replaceState'];
|
|
6409
|
+
var WRAPPED_MARKER = '__mpApvWrapped__';
|
|
6410
|
+
// All APV state hangs off one window key, and it is the public debugging
|
|
6411
|
+
// contract: `window.__mpApv__` is what you inspect in a console to see whether
|
|
6412
|
+
// tracking is live.
|
|
6413
|
+
//
|
|
6414
|
+
// It lives on `window` rather than in module scope because Next.js re-executes
|
|
6415
|
+
// the SDK bundle on every SPA navigation: module-level state is reset each time,
|
|
6416
|
+
// but `window` persists for the lifetime of the tab.
|
|
6417
|
+
//
|
|
6418
|
+
// One object rather than a key per flag, so resetting is a single reassignment.
|
|
6419
|
+
// Nothing has to be deleted, and there is no ordering in which half the state
|
|
6420
|
+
// survives the reset.
|
|
6421
|
+
var WIN_APV_KEY = '__mpApv__';
|
|
6422
|
+
// The query params an auto page view may carry. An allowlist, not a denylist:
|
|
6423
|
+
// partner URLs routinely hold order ids, email addresses and session tokens, and
|
|
6424
|
+
// none of those should reach the event stream because someone forgot to exclude
|
|
6425
|
+
// them. Anything absent from this list is dropped.
|
|
6426
|
+
//
|
|
6427
|
+
// SECURITY: `code`, `state` and `nonce` are the OAuth 2.0 / OIDC authorization
|
|
6428
|
+
// code and the CSRF/replay tokens. They are credentials until redeemed, and
|
|
6429
|
+
// attaching them here persists them in the event store and forwards them to
|
|
6430
|
+
// every configured kit. They are on the list by explicit product decision —
|
|
6431
|
+
// deleting that line is the whole of the fix if that decision is revisited.
|
|
6432
|
+
var ALLOWED_QUERY_PARAMS = [
|
|
6433
|
+
// Campaign attribution
|
|
6434
|
+
'utm_source', 'utm_medium', 'utm_campaign', 'utm_term', 'utm_content', 'utm_id',
|
|
6435
|
+
// Ad-network click ids
|
|
6436
|
+
'gclid', 'gbraid', 'wbraid', 'fbclid', 'msclkid', 'ttclid', 'twclid', 'li_fat_id', 'dclid',
|
|
6437
|
+
// OAuth / OIDC — see the SECURITY note above
|
|
6438
|
+
'client_id', 'redirect_uri', 'response_type', 'scope', 'state', 'code', 'nonce',
|
|
6439
|
+
// Pagination and search
|
|
6440
|
+
'page', 'limit', 'offset', 'cursor', 'per_page', 'q', 'search',
|
|
6441
|
+
// Referral
|
|
6442
|
+
'ref', 'referrer'];
|
|
6443
|
+
// ---------------------------------------------------------------------------
|
|
6444
|
+
// Pure helpers. No `this`, no globals, no side effects — callable and assertable
|
|
6445
|
+
// on their own, which is where the interesting rules live.
|
|
6446
|
+
// ---------------------------------------------------------------------------
|
|
6447
|
+
// Pulls the allowlisted query params off a URL. Delegates to the SDK's own
|
|
6448
|
+
// parser, which lowercases keys (so `?UTM_Source=` and `?utm_source=` land on one
|
|
6449
|
+
// attribute), drops empty values, and carries the fallback for browsers without
|
|
6450
|
+
// URLSearchParams. Tolerates an empty href, so SSR yields no params rather than
|
|
6451
|
+
// throwing.
|
|
6452
|
+
var allowedQueryParams = function allowedQueryParams(href) {
|
|
6453
|
+
return queryStringParser(href, ALLOWED_QUERY_PARAMS);
|
|
6454
|
+
};
|
|
6455
|
+
// The captured params, in allowlist order. Ordering comes from the constant
|
|
6456
|
+
// rather than a sort: it is deterministic without needing a comparator, and it
|
|
6457
|
+
// does not depend on the object's insertion order, so reordering the query string
|
|
6458
|
+
// cannot produce a different key.
|
|
6459
|
+
var capturedNames = function capturedNames(params) {
|
|
6460
|
+
return ALLOWED_QUERY_PARAMS.filter(function (name) {
|
|
6461
|
+
return name in params;
|
|
6462
|
+
});
|
|
6463
|
+
};
|
|
6464
|
+
// The dedup key: pathname plus the allowlisted params in a fixed order, so that
|
|
6465
|
+
// reordering the query string is not a new page. Params outside the allowlist
|
|
6466
|
+
// never make it into `page.params` and so cannot key a view — nor can the hash.
|
|
6467
|
+
//
|
|
6468
|
+
// Values are re-encoded because queryStringParser hands them back DECODED. A
|
|
6469
|
+
// value holding the pair delimiters would otherwise serialize exactly like two
|
|
6470
|
+
// separate params — `{q: 'a&search=b'}` and `{q: 'a', search: 'b'}` both becoming
|
|
6471
|
+
// `q=a&search=b` — and dedup would treat a real navigation between them as the
|
|
6472
|
+
// same page and drop the view. `q`, `search` and `redirect_uri` carry `&` and `=`
|
|
6473
|
+
// routinely, so this is reachable rather than theoretical.
|
|
6474
|
+
var pageKey = function pageKey(page) {
|
|
6475
|
+
var query = capturedNames(page.params).map(function (name) {
|
|
6476
|
+
return "".concat(name, "=").concat(encodeURIComponent(page.params[name]));
|
|
6477
|
+
}).join('&');
|
|
6478
|
+
return query ? "".concat(page.path, "?").concat(query) : page.path;
|
|
6479
|
+
};
|
|
6480
|
+
// Dedup keys on the pageKey above: a change to any captured param is a new page
|
|
6481
|
+
// (`?page=2` is a distinct pagination view), while a hash-only change, or a
|
|
6482
|
+
// change confined to params we do not capture, is the same page.
|
|
6483
|
+
var isNewPage = function isNewPage(lastKey, candidateKey) {
|
|
6484
|
+
return candidateKey !== lastKey;
|
|
6485
|
+
};
|
|
6486
|
+
var supportsHistoryTracking = function supportsHistoryTracking(win) {
|
|
6487
|
+
return !!win && win.history !== undefined && typeof win.history.pushState === 'function' && typeof win.addEventListener === 'function';
|
|
6488
|
+
};
|
|
6489
|
+
// Mirrors the event shape of the public mParticle.logPageView(), but carries the
|
|
6490
|
+
// path and query params captured when the navigation was accepted rather than the
|
|
6491
|
+
// live location.
|
|
6492
|
+
var buildPageViewEvent = function buildPageViewEvent(_a) {
|
|
6493
|
+
var params = _a.params,
|
|
6494
|
+
hostname = _a.hostname,
|
|
6495
|
+
title = _a.title,
|
|
6496
|
+
path = _a.path;
|
|
6497
|
+
return {
|
|
6498
|
+
messageType: MessageType$1.PageView,
|
|
6499
|
+
name: 'PageView',
|
|
6500
|
+
// Params spread first, then the core fields by name, so a core field always
|
|
6501
|
+
// wins. No allowlist entry collides with hostname/title/path today; naming
|
|
6502
|
+
// them here is what keeps a later addition from silently overwriting one.
|
|
6503
|
+
data: __assign(__assign({}, params), {
|
|
6504
|
+
hostname: hostname,
|
|
6505
|
+
title: title,
|
|
6506
|
+
path: path
|
|
6507
|
+
}),
|
|
6508
|
+
eventType: EventType.Unknown
|
|
6509
|
+
};
|
|
6510
|
+
};
|
|
6511
|
+
// ---------------------------------------------------------------------------
|
|
6512
|
+
// Window-scoped APV state. Every read and write goes through these helpers, so
|
|
6513
|
+
// neither the tracker nor mp-instance touches `window` directly and
|
|
6514
|
+
// `typeof window` is checked in exactly one place.
|
|
6515
|
+
// ---------------------------------------------------------------------------
|
|
6516
|
+
var apvWindow = function apvWindow() {
|
|
6517
|
+
return typeof window === 'undefined' ? null : window;
|
|
6518
|
+
};
|
|
6519
|
+
var freshState = function freshState() {
|
|
6520
|
+
return {
|
|
6521
|
+
initialPageViewFired: false
|
|
6522
|
+
};
|
|
6523
|
+
};
|
|
6524
|
+
// Reads tolerate absent state, so a read never mutates `window`. Only the
|
|
6525
|
+
// writers below create it.
|
|
6526
|
+
var readState = function readState() {
|
|
6527
|
+
var win = apvWindow();
|
|
6528
|
+
return win ? win[WIN_APV_KEY] : undefined;
|
|
6529
|
+
};
|
|
6530
|
+
var writeState = function writeState() {
|
|
6531
|
+
var win = apvWindow();
|
|
6532
|
+
if (!win) {
|
|
6533
|
+
return null;
|
|
6534
|
+
}
|
|
6535
|
+
if (!win[WIN_APV_KEY]) {
|
|
6536
|
+
win[WIN_APV_KEY] = freshState();
|
|
6537
|
+
}
|
|
6538
|
+
return win[WIN_APV_KEY];
|
|
6539
|
+
};
|
|
6540
|
+
var getActiveTracker = function getActiveTracker() {
|
|
6541
|
+
var state = readState();
|
|
6542
|
+
return state ? state.tracker : undefined;
|
|
6543
|
+
};
|
|
6544
|
+
var hasInitialPageViewFired = function hasInitialPageViewFired() {
|
|
6545
|
+
var state = readState();
|
|
6546
|
+
return !!(state && state.initialPageViewFired);
|
|
6547
|
+
};
|
|
6548
|
+
var markInitialPageViewFired = function markInitialPageViewFired() {
|
|
6549
|
+
var state = writeState();
|
|
6550
|
+
if (state) {
|
|
6551
|
+
state.initialPageViewFired = true;
|
|
6552
|
+
}
|
|
6553
|
+
};
|
|
6554
|
+
// Returns the page to its pre-APV state: stops the active tracker (restoring the
|
|
6555
|
+
// history methods it patched), then swaps in fresh state. The state object is the
|
|
6556
|
+
// authoritative handle, so this reaches trackers whose owning module is gone.
|
|
6557
|
+
var resetPageViewTracking = function resetPageViewTracking() {
|
|
6558
|
+
var win = apvWindow();
|
|
6559
|
+
if (!win) {
|
|
6560
|
+
return;
|
|
6561
|
+
}
|
|
6562
|
+
var active = getActiveTracker();
|
|
6563
|
+
if (active) {
|
|
6564
|
+
active.teardown();
|
|
6565
|
+
}
|
|
6566
|
+
// One reassignment replaces every flag at once, so nothing can be left behind
|
|
6567
|
+
// whatever shape the previous state was in.
|
|
6568
|
+
win[WIN_APV_KEY] = freshState();
|
|
6569
|
+
};
|
|
6570
|
+
var setActiveTracker = function setActiveTracker(tracker) {
|
|
6571
|
+
var state = writeState();
|
|
6572
|
+
if (state) {
|
|
6573
|
+
state.tracker = tracker;
|
|
6574
|
+
}
|
|
6575
|
+
};
|
|
6576
|
+
var clearActiveTracker = function clearActiveTracker(tracker) {
|
|
6577
|
+
var state = readState();
|
|
6578
|
+
if (state && state.tracker === tracker) {
|
|
6579
|
+
state.tracker = undefined;
|
|
6580
|
+
}
|
|
6581
|
+
};
|
|
6582
|
+
var currentPage = function currentPage() {
|
|
6583
|
+
return {
|
|
6584
|
+
path: window.location.pathname,
|
|
6585
|
+
params: allowedQueryParams(getHref())
|
|
6586
|
+
};
|
|
6587
|
+
};
|
|
6588
|
+
// Log-safe description of a page: the path, plus the NAMES of the captured
|
|
6589
|
+
// params. Values are deliberately omitted — verbose logging goes to the console,
|
|
6590
|
+
// and session-replay tooling ships console output off-domain, which is not a
|
|
6591
|
+
// place for an OAuth code or a consumer's search terms.
|
|
6592
|
+
// Only reachable before init() assigns lastPage, which is ahead of any navigation
|
|
6593
|
+
// handler being able to run, so this returns nothing rather than a sentinel.
|
|
6594
|
+
var describePage = function describePage(page) {
|
|
6595
|
+
if (!page) {
|
|
6596
|
+
return '';
|
|
6597
|
+
}
|
|
6598
|
+
var names = capturedNames(page.params);
|
|
6599
|
+
return names.length ? "".concat(page.path, " (params: ").concat(names.join(), ")") : page.path;
|
|
6600
|
+
};
|
|
6601
|
+
// ---------------------------------------------------------------------------
|
|
6602
|
+
// History patching
|
|
6603
|
+
// ---------------------------------------------------------------------------
|
|
6604
|
+
// Wraps pushState/replaceState so `onNavigate` runs after the real method, and
|
|
6605
|
+
// returns the single function that undoes it — or null when nothing was
|
|
6606
|
+
// installed (history is already wrapped, or a frozen/sealed History rejected the
|
|
6607
|
+
// assignment). Handing back one undo closure keeps the wrapper and original
|
|
6608
|
+
// references out of the tracker entirely: there is no half-patched state for a
|
|
6609
|
+
// caller to inspect, and no way to restore the wrong pair.
|
|
6610
|
+
var patchHistory = function patchHistory(onNavigate, log) {
|
|
6611
|
+
if (window.history.pushState[WRAPPED_MARKER]) {
|
|
6612
|
+
log('[patch] history already wrapped, skipping to avoid double-wrap — STACKED WRAPPER DETECTED');
|
|
6613
|
+
return null;
|
|
6614
|
+
}
|
|
6615
|
+
var originals = {};
|
|
6616
|
+
var wrappers = {};
|
|
6617
|
+
HISTORY_METHODS.forEach(function (name) {
|
|
6618
|
+
var original = window.history[name];
|
|
6619
|
+
originals[name] = original;
|
|
6620
|
+
var wrapper = function wrapper() {
|
|
6621
|
+
var args = [];
|
|
6622
|
+
for (var _i = 0; _i < arguments.length; _i++) {
|
|
6623
|
+
args[_i] = arguments[_i];
|
|
6624
|
+
}
|
|
6625
|
+
var result = original.apply(this, args);
|
|
6626
|
+
onNavigate(name);
|
|
6627
|
+
return result;
|
|
6628
|
+
};
|
|
6629
|
+
Object.defineProperty(wrapper, WRAPPED_MARKER, {
|
|
6630
|
+
value: true,
|
|
6631
|
+
enumerable: false
|
|
6632
|
+
});
|
|
6633
|
+
wrappers[name] = wrapper;
|
|
6634
|
+
});
|
|
6635
|
+
// Restore per method: a third party may have patched one of the two on top of
|
|
6636
|
+
// ours after we installed. Clobbering theirs would break their tracking, so
|
|
6637
|
+
// leave anything that is no longer ours in place.
|
|
6638
|
+
var restore = function restore() {
|
|
6639
|
+
return HISTORY_METHODS.forEach(function (name) {
|
|
6640
|
+
if (window.history[name] === wrappers[name]) {
|
|
6641
|
+
window.history[name] = originals[name];
|
|
6642
|
+
log("[teardown] restored original ".concat(name));
|
|
6643
|
+
} else {
|
|
6644
|
+
log("[teardown] ".concat(name, " no longer ours; leaving in place, gating callback to no-op"));
|
|
6645
|
+
}
|
|
6646
|
+
});
|
|
6647
|
+
};
|
|
6648
|
+
try {
|
|
6649
|
+
HISTORY_METHODS.forEach(function (name) {
|
|
6650
|
+
window.history[name] = wrappers[name];
|
|
6651
|
+
});
|
|
6652
|
+
} catch (e) {
|
|
6653
|
+
log("[error] failed to patch history methods (frozen/sealed), rolling back: ".concat(e));
|
|
6654
|
+
try {
|
|
6655
|
+
restore();
|
|
6656
|
+
} catch (restoreError) {
|
|
6657
|
+
log("[error] failed to restore history methods after patch failure: ".concat(restoreError));
|
|
6658
|
+
}
|
|
6659
|
+
return null;
|
|
6660
|
+
}
|
|
6661
|
+
return restore;
|
|
6662
|
+
};
|
|
6663
|
+
// ---------------------------------------------------------------------------
|
|
6664
|
+
// Tracker
|
|
6665
|
+
// ---------------------------------------------------------------------------
|
|
6666
|
+
var PageViewTracker = /** @class */function () {
|
|
6667
|
+
function PageViewTracker(mpInstance) {
|
|
6668
|
+
this.lastPage = null;
|
|
6669
|
+
this.active = false;
|
|
6670
|
+
this.pendingNavigations = [];
|
|
6671
|
+
this.undoHistoryPatch = null;
|
|
6672
|
+
this.popStateListener = null;
|
|
6673
|
+
this.mpInstance = mpInstance;
|
|
6674
|
+
}
|
|
6675
|
+
Object.defineProperty(PageViewTracker.prototype, "isActive", {
|
|
6676
|
+
// True while this tracker owns the history patch and is listening for
|
|
6677
|
+
// navigations. Flips to false on teardown, including the teardown a
|
|
6678
|
+
// successor tracker performs during a handoff. Read-only, and the one thing
|
|
6679
|
+
// worth checking on `window.__mpApv__.tracker` from a console.
|
|
6680
|
+
get: function get() {
|
|
6681
|
+
return this.active;
|
|
6682
|
+
},
|
|
6683
|
+
enumerable: false,
|
|
6684
|
+
configurable: true
|
|
6685
|
+
});
|
|
6686
|
+
PageViewTracker.prototype.init = function () {
|
|
6687
|
+
var _this = this;
|
|
6688
|
+
this.log('[init] PageViewTracker Init');
|
|
6689
|
+
if (!supportsHistoryTracking(apvWindow())) {
|
|
6690
|
+
this.log('[init] unsupported environment (no History API), not starting');
|
|
6691
|
+
return;
|
|
6692
|
+
}
|
|
6693
|
+
// Take over from whichever tracker is currently active: one left behind by
|
|
6694
|
+
// a previous module load, or this same tracker on a repeat
|
|
6695
|
+
// mParticle.init(). Their pending navigations are transferred rather than
|
|
6696
|
+
// dropped — a route change may have queued a deferred fire that has not
|
|
6697
|
+
// flushed yet, and dropping it loses a page view entirely.
|
|
6698
|
+
var active = getActiveTracker();
|
|
6699
|
+
var inheritedPages = this.retire(active);
|
|
6700
|
+
if (this.active && active !== this) {
|
|
6701
|
+
inheritedPages = inheritedPages.concat(this.retire(this));
|
|
6702
|
+
}
|
|
6703
|
+
this.active = true;
|
|
6704
|
+
this.lastPage = currentPage();
|
|
6705
|
+
this.log("[init] seeded lastPage: ".concat(describePage(this.lastPage)));
|
|
6706
|
+
this.undoHistoryPatch = patchHistory(function (source) {
|
|
6707
|
+
return _this.safeHandleNavigation(source);
|
|
6708
|
+
}, function (message) {
|
|
6709
|
+
return _this.log(message);
|
|
6710
|
+
});
|
|
6711
|
+
this.popStateListener = function () {
|
|
6712
|
+
return _this.safeHandleNavigation('popstate');
|
|
6713
|
+
};
|
|
6714
|
+
window.addEventListener('popstate', this.popStateListener);
|
|
6715
|
+
setActiveTracker(this);
|
|
6716
|
+
this.log('[init] patched pushState/replaceState + listening for popstate');
|
|
6717
|
+
inheritedPages.forEach(function (page) {
|
|
6718
|
+
return _this.scheduleFire(page);
|
|
6719
|
+
});
|
|
6720
|
+
};
|
|
6721
|
+
PageViewTracker.prototype.teardown = function () {
|
|
6722
|
+
// Discard pending deferred fires (e.g. AutoLogPageView switched off on
|
|
6723
|
+
// re-init). A handoff calls takePendingNavigations() first, so by this
|
|
6724
|
+
// point those paths are already transferred rather than dropped.
|
|
6725
|
+
this.takePendingNavigations();
|
|
6726
|
+
if (this.popStateListener) {
|
|
6727
|
+
window.removeEventListener('popstate', this.popStateListener);
|
|
6728
|
+
this.popStateListener = null;
|
|
6259
6729
|
}
|
|
6260
|
-
if (
|
|
6261
|
-
|
|
6262
|
-
|
|
6263
|
-
} else {
|
|
6264
|
-
var persistence = self.getPersistence();
|
|
6265
|
-
if (persistence && persistence[mpid] && persistence[mpid].lst) {
|
|
6266
|
-
return persistence[mpid].lst;
|
|
6267
|
-
}
|
|
6268
|
-
return null;
|
|
6730
|
+
if (this.undoHistoryPatch) {
|
|
6731
|
+
this.undoHistoryPatch();
|
|
6732
|
+
this.undoHistoryPatch = null;
|
|
6269
6733
|
}
|
|
6734
|
+
this.active = false;
|
|
6735
|
+
clearActiveTracker(this);
|
|
6270
6736
|
};
|
|
6271
|
-
|
|
6272
|
-
|
|
6273
|
-
|
|
6737
|
+
// Stops the outgoing tracker and returns the pages it had queued so this
|
|
6738
|
+
// tracker can re-schedule them once it is active. Private, but reachable
|
|
6739
|
+
// across instances: the handoff protocol stays internal to the class.
|
|
6740
|
+
PageViewTracker.prototype.retire = function (outgoing) {
|
|
6741
|
+
if (!outgoing) {
|
|
6742
|
+
return [];
|
|
6274
6743
|
}
|
|
6275
|
-
|
|
6276
|
-
|
|
6277
|
-
|
|
6744
|
+
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');
|
|
6745
|
+
var pages = outgoing.takePendingNavigations();
|
|
6746
|
+
outgoing.teardown();
|
|
6747
|
+
return pages;
|
|
6748
|
+
};
|
|
6749
|
+
// Cancels this tracker's deferred fires and hands back their captured pages.
|
|
6750
|
+
PageViewTracker.prototype.takePendingNavigations = function () {
|
|
6751
|
+
var pending = this.pendingNavigations;
|
|
6752
|
+
this.pendingNavigations = [];
|
|
6753
|
+
pending.forEach(function (_a) {
|
|
6754
|
+
var timeoutId = _a.timeoutId;
|
|
6755
|
+
return clearTimeout(timeoutId);
|
|
6756
|
+
});
|
|
6757
|
+
return pending.map(function (_a) {
|
|
6758
|
+
var page = _a.page;
|
|
6759
|
+
return page;
|
|
6760
|
+
});
|
|
6761
|
+
};
|
|
6762
|
+
PageViewTracker.prototype.safeHandleNavigation = function (source) {
|
|
6763
|
+
// An orphaned wrapper still calls in: teardown can only restore a history
|
|
6764
|
+
// method that is still ours, so one a third party patched over stays
|
|
6765
|
+
// installed and keeps firing at a dead tracker. Bail before touching
|
|
6766
|
+
// lastPath or queueing a fire the flush would just abort. Guarding here
|
|
6767
|
+
// rather than at each wrapper also covers the popstate path.
|
|
6768
|
+
if (!this.active) {
|
|
6769
|
+
return;
|
|
6278
6770
|
}
|
|
6279
|
-
|
|
6280
|
-
|
|
6281
|
-
|
|
6282
|
-
|
|
6771
|
+
try {
|
|
6772
|
+
this.handleNavigation(source);
|
|
6773
|
+
} catch (e) {
|
|
6774
|
+
this.log("[error] navigation handler threw (".concat(source, "), page view skipped: ").concat(e));
|
|
6283
6775
|
}
|
|
6284
6776
|
};
|
|
6285
|
-
|
|
6286
|
-
|
|
6777
|
+
PageViewTracker.prototype.handleNavigation = function (source) {
|
|
6778
|
+
var candidate = currentPage();
|
|
6779
|
+
var lastKey = this.lastPage ? pageKey(this.lastPage) : null;
|
|
6780
|
+
this.log("[detect] navigation signal (source: ".concat(source, ", candidate: ").concat(describePage(candidate), ", last: ").concat(describePage(this.lastPage), ")"));
|
|
6781
|
+
if (!isNewPage(lastKey, pageKey(candidate))) {
|
|
6782
|
+
this.log("[dedupe] page unchanged, skipping (source: ".concat(source, ", page: ").concat(describePage(candidate), ")"));
|
|
6783
|
+
return;
|
|
6784
|
+
}
|
|
6785
|
+
this.log("[accept] page changed, scheduling fire (source: ".concat(source, ", from: ").concat(describePage(this.lastPage), ", to: ").concat(describePage(candidate), ")"));
|
|
6786
|
+
this.lastPage = candidate;
|
|
6787
|
+
this.scheduleFire(candidate);
|
|
6287
6788
|
};
|
|
6288
|
-
|
|
6289
|
-
|
|
6290
|
-
|
|
6789
|
+
// Deferred by a macrotask so the router's post-navigation render commit has a
|
|
6790
|
+
// chance to update document.title before the event is built. The path and
|
|
6791
|
+
// query params are snapshotted now because they are already settled, whereas a
|
|
6792
|
+
// same-tick navigation would overwrite window.location before the flush reads
|
|
6793
|
+
// it.
|
|
6794
|
+
PageViewTracker.prototype.scheduleFire = function (page) {
|
|
6795
|
+
var _this = this;
|
|
6796
|
+
var timeoutId = setTimeout(function () {
|
|
6797
|
+
_this.pendingNavigations = _this.pendingNavigations.filter(function (p) {
|
|
6798
|
+
return p.timeoutId !== timeoutId;
|
|
6799
|
+
});
|
|
6800
|
+
if (!_this.active) {
|
|
6801
|
+
_this.log('[defer] fire aborted, tracker inactive (torn down before flush)');
|
|
6802
|
+
return;
|
|
6803
|
+
}
|
|
6804
|
+
_this.mpInstance._SessionManager.resetSessionTimer();
|
|
6805
|
+
_this.firePageView(page);
|
|
6806
|
+
}, 0);
|
|
6807
|
+
this.pendingNavigations.push({
|
|
6808
|
+
page: page,
|
|
6809
|
+
timeoutId: timeoutId
|
|
6810
|
+
});
|
|
6291
6811
|
};
|
|
6292
|
-
|
|
6293
|
-
|
|
6294
|
-
|
|
6295
|
-
|
|
6296
|
-
|
|
6297
|
-
|
|
6298
|
-
|
|
6299
|
-
|
|
6300
|
-
var testWorkspaceToken = 'abcdef';
|
|
6301
|
-
removeLocalStorage(mpInstance._Helpers.createMainStorageName(testWorkspaceToken));
|
|
6302
|
-
self.expireCookies(mpInstance._Helpers.createMainStorageName(testWorkspaceToken));
|
|
6303
|
-
}
|
|
6812
|
+
PageViewTracker.prototype.firePageView = function (page) {
|
|
6813
|
+
var title = window.document.title;
|
|
6814
|
+
var event = buildPageViewEvent(__assign(__assign({}, page), {
|
|
6815
|
+
hostname: window.location.hostname,
|
|
6816
|
+
title: title
|
|
6817
|
+
}));
|
|
6818
|
+
this.log("[fire] deferred flush -> _Events.logEvent(PageView) (page: ".concat(describePage(page), ", title: ").concat(title, ")"));
|
|
6819
|
+
this.mpInstance._Events.logEvent(event);
|
|
6304
6820
|
};
|
|
6305
|
-
|
|
6306
|
-
|
|
6307
|
-
// Forwarder Batching Code
|
|
6308
|
-
this.forwardingStatsBatches = {
|
|
6309
|
-
uploadsTable: {},
|
|
6310
|
-
forwardingStatsEventQueue: []
|
|
6821
|
+
PageViewTracker.prototype.log = function (message) {
|
|
6822
|
+
this.mpInstance.Logger.verbose("mParticle APV: ".concat(message));
|
|
6311
6823
|
};
|
|
6312
|
-
|
|
6824
|
+
return PageViewTracker;
|
|
6825
|
+
}();
|
|
6313
6826
|
|
|
6314
6827
|
var Messages$3 = Constants.Messages;
|
|
6315
6828
|
function Events(mpInstance) {
|
|
@@ -6388,14 +6901,18 @@ var mParticle = (function () {
|
|
|
6388
6901
|
messageType: Types.MessageType.AppStateTransition
|
|
6389
6902
|
});
|
|
6390
6903
|
};
|
|
6904
|
+
// The auto page view for the landing page. The SPA navigations that follow it
|
|
6905
|
+
// come from PageViewTracker instead, so both emitters attach the same
|
|
6906
|
+
// allowlisted query params — and this is the one that matters for campaign
|
|
6907
|
+
// attribution, since utm_*/gclid live on the entry URL.
|
|
6391
6908
|
this.logPageView = function () {
|
|
6392
6909
|
self.logEvent({
|
|
6393
6910
|
messageType: Types.MessageType.PageView,
|
|
6394
6911
|
name: 'PageView',
|
|
6395
|
-
data: {
|
|
6912
|
+
data: __assign(__assign({}, allowedQueryParams(getHref())), {
|
|
6396
6913
|
hostname: window.location.hostname,
|
|
6397
6914
|
title: window.document.title
|
|
6398
|
-
},
|
|
6915
|
+
}),
|
|
6399
6916
|
eventType: Types.EventType.Unknown
|
|
6400
6917
|
});
|
|
6401
6918
|
};
|
|
@@ -6979,20 +7496,61 @@ var mParticle = (function () {
|
|
|
6979
7496
|
|
|
6980
7497
|
var _regeneratorRuntime = /*@__PURE__*/getDefaultExportFromCjs(regenerator);
|
|
6981
7498
|
|
|
7499
|
+
function isAttributeKeyAllowed(kitBlocker, key) {
|
|
7500
|
+
return !(kitBlocker === null || kitBlocker === void 0 ? void 0 : kitBlocker.isAttributeKeyBlocked(key));
|
|
7501
|
+
}
|
|
7502
|
+
function isIdentityAllowed(kitBlocker, identityName) {
|
|
7503
|
+
return !(kitBlocker === null || kitBlocker === void 0 ? void 0 : kitBlocker.isIdentityBlocked(identityName));
|
|
7504
|
+
}
|
|
7505
|
+
function copyUserAttributeValue(value) {
|
|
7506
|
+
return Array.isArray(value) ? value.slice() : value;
|
|
7507
|
+
}
|
|
7508
|
+
function buildUserAttributesCopy(userAttributes, kitBlocker) {
|
|
7509
|
+
var userAttributesCopy = {};
|
|
7510
|
+
if (!userAttributes) {
|
|
7511
|
+
return userAttributesCopy;
|
|
7512
|
+
}
|
|
7513
|
+
for (var prop in userAttributes) {
|
|
7514
|
+
if (!userAttributes.hasOwnProperty(prop) || !isAttributeKeyAllowed(kitBlocker, prop)) {
|
|
7515
|
+
continue;
|
|
7516
|
+
}
|
|
7517
|
+
userAttributesCopy[prop] = copyUserAttributeValue(userAttributes[prop]);
|
|
7518
|
+
}
|
|
7519
|
+
return userAttributesCopy;
|
|
7520
|
+
}
|
|
7521
|
+
function buildUserAttributeLists(userAttributes, kitBlocker) {
|
|
7522
|
+
var userAttributesLists = {};
|
|
7523
|
+
for (var key in userAttributes) {
|
|
7524
|
+
if (!userAttributes.hasOwnProperty(key) || !Array.isArray(userAttributes[key]) || !isAttributeKeyAllowed(kitBlocker, key)) {
|
|
7525
|
+
continue;
|
|
7526
|
+
}
|
|
7527
|
+
userAttributesLists[key] = userAttributes[key].slice();
|
|
7528
|
+
}
|
|
7529
|
+
return userAttributesLists;
|
|
7530
|
+
}
|
|
7531
|
+
function buildFilteredUserIdentities(identities, kitBlocker, parseNumber) {
|
|
7532
|
+
var currentUserIdentities = {};
|
|
7533
|
+
var identitiesByType = identities;
|
|
7534
|
+
for (var identityType in identitiesByType) {
|
|
7535
|
+
if (!identitiesByType.hasOwnProperty(identityType)) {
|
|
7536
|
+
continue;
|
|
7537
|
+
}
|
|
7538
|
+
var identityName = Types.IdentityType.getIdentityName(parseNumber(identityType));
|
|
7539
|
+
if (!isIdentityAllowed(kitBlocker, identityName)) {
|
|
7540
|
+
continue;
|
|
7541
|
+
}
|
|
7542
|
+
currentUserIdentities[identityName] = identitiesByType[identityType];
|
|
7543
|
+
}
|
|
7544
|
+
return currentUserIdentities;
|
|
7545
|
+
}
|
|
6982
7546
|
function filteredMparticleUser(mpid, forwarder, mpInstance, kitBlocker) {
|
|
6983
|
-
|
|
7547
|
+
function getAllUserAttributes() {
|
|
7548
|
+
var userAttributesCopy = buildUserAttributesCopy(mpInstance._Store.getUserAttributes(mpid), kitBlocker);
|
|
7549
|
+
return mpInstance._Helpers.filterUserAttributes(userAttributesCopy, forwarder.userAttributeFilters);
|
|
7550
|
+
}
|
|
6984
7551
|
return {
|
|
6985
7552
|
getUserIdentities: function getUserIdentities() {
|
|
6986
|
-
var currentUserIdentities =
|
|
6987
|
-
var identities = mpInstance._Store.getUserIdentities(mpid);
|
|
6988
|
-
for (var identityType in identities) {
|
|
6989
|
-
if (identities.hasOwnProperty(identityType)) {
|
|
6990
|
-
var identityName = Types.IdentityType.getIdentityName(mpInstance._Helpers.parseNumber(identityType));
|
|
6991
|
-
if (!kitBlocker || kitBlocker && !kitBlocker.isIdentityBlocked(identityName))
|
|
6992
|
-
//if identity type is not blocked
|
|
6993
|
-
currentUserIdentities[identityName] = identities[identityType];
|
|
6994
|
-
}
|
|
6995
|
-
}
|
|
7553
|
+
var currentUserIdentities = buildFilteredUserIdentities(mpInstance._Store.getUserIdentities(mpid), kitBlocker, mpInstance._Helpers.parseNumber);
|
|
6996
7554
|
currentUserIdentities = mpInstance._Helpers.filterUserIdentitiesForForwarders(currentUserIdentities, forwarder.userIdentityFilters);
|
|
6997
7555
|
return {
|
|
6998
7556
|
userIdentities: currentUserIdentities
|
|
@@ -7002,38 +7560,10 @@ var mParticle = (function () {
|
|
|
7002
7560
|
return mpid;
|
|
7003
7561
|
},
|
|
7004
7562
|
getUserAttributesLists: function getUserAttributesLists(forwarder) {
|
|
7005
|
-
var
|
|
7006
|
-
|
|
7007
|
-
userAttributes = self.getAllUserAttributes();
|
|
7008
|
-
for (var key in userAttributes) {
|
|
7009
|
-
if (userAttributes.hasOwnProperty(key) && Array.isArray(userAttributes[key])) {
|
|
7010
|
-
if (!kitBlocker || kitBlocker && !kitBlocker.isAttributeKeyBlocked(key)) {
|
|
7011
|
-
userAttributesLists[key] = userAttributes[key].slice();
|
|
7012
|
-
}
|
|
7013
|
-
}
|
|
7014
|
-
}
|
|
7015
|
-
userAttributesLists = mpInstance._Helpers.filterUserAttributes(userAttributesLists, forwarder.userAttributeFilters);
|
|
7016
|
-
return userAttributesLists;
|
|
7563
|
+
var userAttributesLists = buildUserAttributeLists(getAllUserAttributes(), kitBlocker);
|
|
7564
|
+
return mpInstance._Helpers.filterUserAttributes(userAttributesLists, forwarder.userAttributeFilters);
|
|
7017
7565
|
},
|
|
7018
|
-
getAllUserAttributes:
|
|
7019
|
-
var userAttributesCopy = {};
|
|
7020
|
-
var userAttributes = mpInstance._Store.getUserAttributes(mpid);
|
|
7021
|
-
if (userAttributes) {
|
|
7022
|
-
for (var prop in userAttributes) {
|
|
7023
|
-
if (userAttributes.hasOwnProperty(prop)) {
|
|
7024
|
-
if (!kitBlocker || kitBlocker && !kitBlocker.isAttributeKeyBlocked(prop)) {
|
|
7025
|
-
if (Array.isArray(userAttributes[prop])) {
|
|
7026
|
-
userAttributesCopy[prop] = userAttributes[prop].slice();
|
|
7027
|
-
} else {
|
|
7028
|
-
userAttributesCopy[prop] = userAttributes[prop];
|
|
7029
|
-
}
|
|
7030
|
-
}
|
|
7031
|
-
}
|
|
7032
|
-
}
|
|
7033
|
-
}
|
|
7034
|
-
userAttributesCopy = mpInstance._Helpers.filterUserAttributes(userAttributesCopy, forwarder.userAttributeFilters);
|
|
7035
|
-
return userAttributesCopy;
|
|
7036
|
-
}
|
|
7566
|
+
getAllUserAttributes: getAllUserAttributes
|
|
7037
7567
|
};
|
|
7038
7568
|
}
|
|
7039
7569
|
|
|
@@ -7839,7 +8369,7 @@ var mParticle = (function () {
|
|
|
7839
8369
|
|
|
7840
8370
|
function forwardingStatsUploader(mpInstance) {
|
|
7841
8371
|
this.startForwardingStatsTimer = function () {
|
|
7842
|
-
mParticle._forwardingStatsTimer = setInterval(function () {
|
|
8372
|
+
window.mParticle._forwardingStatsTimer = setInterval(function () {
|
|
7843
8373
|
prepareAndSendForwardingStatsBatch();
|
|
7844
8374
|
}, mpInstance._Store.SDKConfig.forwarderStatsTimeout);
|
|
7845
8375
|
};
|
|
@@ -7859,12 +8389,12 @@ var mParticle = (function () {
|
|
|
7859
8389
|
if (uploadsTable.hasOwnProperty(date)) {
|
|
7860
8390
|
if (uploadsTable[date].uploading === false) {
|
|
7861
8391
|
var xhrCallback = function xhrCallback() {
|
|
7862
|
-
if (
|
|
7863
|
-
if (
|
|
7864
|
-
mpInstance.Logger.verbose('Successfully sent ' +
|
|
8392
|
+
if (xhr_1.readyState === 4) {
|
|
8393
|
+
if (xhr_1.status === 200 || xhr_1.status === 202) {
|
|
8394
|
+
mpInstance.Logger.verbose('Successfully sent ' + xhr_1.statusText + ' from server');
|
|
7865
8395
|
delete uploadsTable[date];
|
|
7866
|
-
} else if (
|
|
7867
|
-
if (
|
|
8396
|
+
} else if (xhr_1.status.toString()[0] === '4') {
|
|
8397
|
+
if (xhr_1.status !== 429) {
|
|
7868
8398
|
delete uploadsTable[date];
|
|
7869
8399
|
}
|
|
7870
8400
|
} else {
|
|
@@ -7872,10 +8402,10 @@ var mParticle = (function () {
|
|
|
7872
8402
|
}
|
|
7873
8403
|
}
|
|
7874
8404
|
};
|
|
7875
|
-
var
|
|
8405
|
+
var xhr_1 = mpInstance._Helpers.createXHR(xhrCallback);
|
|
7876
8406
|
var forwardingStatsData = uploadsTable[date].data;
|
|
7877
8407
|
uploadsTable[date].uploading = true;
|
|
7878
|
-
mpInstance._APIClient.sendBatchForwardingStatsToServer(forwardingStatsData,
|
|
8408
|
+
mpInstance._APIClient.sendBatchForwardingStatsToServer(forwardingStatsData, xhr_1);
|
|
7879
8409
|
}
|
|
7880
8410
|
}
|
|
7881
8411
|
})(date);
|
|
@@ -11172,298 +11702,6 @@ var mParticle = (function () {
|
|
|
11172
11702
|
return LoggingDispatcher;
|
|
11173
11703
|
}();
|
|
11174
11704
|
|
|
11175
|
-
var WRAPPED_MARKER = '__mpApvWrapped__';
|
|
11176
|
-
// window key under which the single active tracker is stored.
|
|
11177
|
-
// Survives module re-evaluation (Next.js re-executes the bundle on every SPA
|
|
11178
|
-
// navigation, resetting all module-level state, but window persists for the
|
|
11179
|
-
// lifetime of the tab).
|
|
11180
|
-
var WIN_TRACKER_KEY = '__mpApvTracker__';
|
|
11181
|
-
// Guards the initial page view so repeated mParticle.init() calls from SPA
|
|
11182
|
-
// re-renders don't fire duplicate logPageView() events for the same page.
|
|
11183
|
-
var WIN_INIT_PV_KEY = '__mpApvInitPVLogged__';
|
|
11184
|
-
var PageViewTracker = /** @class */function () {
|
|
11185
|
-
function PageViewTracker(mpInstance) {
|
|
11186
|
-
this.lastPath = null;
|
|
11187
|
-
this._isActive = false;
|
|
11188
|
-
this.pendingNavigations = [];
|
|
11189
|
-
this.originalPushState = null;
|
|
11190
|
-
this.originalReplaceState = null;
|
|
11191
|
-
this.pushStateWrapper = null;
|
|
11192
|
-
this.replaceStateWrapper = null;
|
|
11193
|
-
this.popStateListener = null;
|
|
11194
|
-
this.mpInstance = mpInstance;
|
|
11195
|
-
}
|
|
11196
|
-
PageViewTracker.hasInitialPageViewFired = function () {
|
|
11197
|
-
return !!window[WIN_INIT_PV_KEY];
|
|
11198
|
-
};
|
|
11199
|
-
PageViewTracker.markInitialPageViewFired = function () {
|
|
11200
|
-
window[WIN_INIT_PV_KEY] = true;
|
|
11201
|
-
};
|
|
11202
|
-
// Tears down any window-registered tracker that differs from instanceTracker
|
|
11203
|
-
// (e.g. left by a previous module load), then clears both APV window flags.
|
|
11204
|
-
// Call from _resetForTests after tearing down the instance-level tracker.
|
|
11205
|
-
PageViewTracker.resetWindowState = function (instanceTracker) {
|
|
11206
|
-
var windowTracker = getWindowTracker();
|
|
11207
|
-
if (windowTracker && windowTracker !== instanceTracker) {
|
|
11208
|
-
windowTracker.teardown();
|
|
11209
|
-
}
|
|
11210
|
-
if (typeof window !== 'undefined') {
|
|
11211
|
-
delete window[WIN_INIT_PV_KEY];
|
|
11212
|
-
}
|
|
11213
|
-
setWindowTracker(undefined);
|
|
11214
|
-
};
|
|
11215
|
-
Object.defineProperty(PageViewTracker.prototype, "isActive", {
|
|
11216
|
-
get: function get() {
|
|
11217
|
-
return this._isActive;
|
|
11218
|
-
},
|
|
11219
|
-
enumerable: false,
|
|
11220
|
-
configurable: true
|
|
11221
|
-
});
|
|
11222
|
-
PageViewTracker.prototype.isSupportedEnvironment = function () {
|
|
11223
|
-
return typeof window !== 'undefined' && typeof window.history !== 'undefined' && typeof window.history.pushState === 'function' && typeof window.addEventListener === 'function';
|
|
11224
|
-
};
|
|
11225
|
-
PageViewTracker.prototype.init = function () {
|
|
11226
|
-
var _this = this;
|
|
11227
|
-
this.mpInstance.Logger.verbose('mParticle APV: [init] PageViewTracker Init');
|
|
11228
|
-
if (!this.isSupportedEnvironment()) {
|
|
11229
|
-
this.mpInstance.Logger.verbose('mParticle APV: [init] unsupported environment (no History API), not starting');
|
|
11230
|
-
return;
|
|
11231
|
-
}
|
|
11232
|
-
// Tear down any tracker left over from a previous module load.
|
|
11233
|
-
// window[WIN_TRACKER_KEY] outlives module re-evaluation; this is the
|
|
11234
|
-
// only way to reach a tracker instance in a dead module scope.
|
|
11235
|
-
// Transfer any pending navigations first so a route change that queued a
|
|
11236
|
-
// deferred fire before module re-evaluation occurs is not silently dropped.
|
|
11237
|
-
var prev = getWindowTracker();
|
|
11238
|
-
var inheritedPaths = [];
|
|
11239
|
-
if (prev && prev !== this) {
|
|
11240
|
-
this.mpInstance.Logger.verbose('mParticle APV: [init] found stale tracker from previous module load — transferring pending navigations and tearing down');
|
|
11241
|
-
inheritedPaths = prev.takePendingNavigations();
|
|
11242
|
-
prev.teardown();
|
|
11243
|
-
}
|
|
11244
|
-
if (this._isActive) {
|
|
11245
|
-
this.mpInstance.Logger.verbose('mParticle APV: [init] starting (teardown-first for idempotency)');
|
|
11246
|
-
// Preserve pending navigations through the self-teardown so a route
|
|
11247
|
-
// change queued before mParticle.init() was called again is not lost.
|
|
11248
|
-
inheritedPaths = __spreadArray(__spreadArray([], inheritedPaths, true), this.takePendingNavigations(), true);
|
|
11249
|
-
this.teardown();
|
|
11250
|
-
}
|
|
11251
|
-
this._isActive = true;
|
|
11252
|
-
this.lastPath = this.getCurrentKey();
|
|
11253
|
-
this.mpInstance.Logger.verbose("mParticle APV: [init] seeded lastPath: ".concat(this.lastPath));
|
|
11254
|
-
this.patchHistoryMethods();
|
|
11255
|
-
this.addNavigationListeners();
|
|
11256
|
-
setWindowTracker(this);
|
|
11257
|
-
this.mpInstance.Logger.verbose('mParticle APV: [init] patched pushState/replaceState + listening for popstate');
|
|
11258
|
-
// Re-fire navigations that the stale tracker had queued but not yet flushed
|
|
11259
|
-
// when module re-evaluation occurred. Title is read at flush time so the
|
|
11260
|
-
// router's post-navigation render commit still has a chance to update it.
|
|
11261
|
-
inheritedPaths.forEach(function (path) {
|
|
11262
|
-
var timeoutId = setTimeout(function () {
|
|
11263
|
-
_this.pendingNavigations = _this.pendingNavigations.filter(function (p) {
|
|
11264
|
-
return p.timeoutId !== timeoutId;
|
|
11265
|
-
});
|
|
11266
|
-
if (!_this._isActive) return;
|
|
11267
|
-
_this.mpInstance._SessionManager.resetSessionTimer();
|
|
11268
|
-
_this.firePageView(path);
|
|
11269
|
-
}, 0);
|
|
11270
|
-
_this.pendingNavigations.push({
|
|
11271
|
-
path: path,
|
|
11272
|
-
timeoutId: timeoutId
|
|
11273
|
-
});
|
|
11274
|
-
});
|
|
11275
|
-
};
|
|
11276
|
-
PageViewTracker.prototype.patchHistoryMethods = function () {
|
|
11277
|
-
var self = this;
|
|
11278
|
-
var installed = window.history.pushState;
|
|
11279
|
-
if (installed[WRAPPED_MARKER]) {
|
|
11280
|
-
this.mpInstance.Logger.verbose('mParticle APV: [patch] history already wrapped, skipping to avoid double-wrap — STACKED WRAPPER DETECTED');
|
|
11281
|
-
return;
|
|
11282
|
-
}
|
|
11283
|
-
var originalPushState = window.history.pushState;
|
|
11284
|
-
var originalReplaceState = window.history.replaceState;
|
|
11285
|
-
this.originalPushState = originalPushState;
|
|
11286
|
-
this.originalReplaceState = originalReplaceState;
|
|
11287
|
-
var pushStateWrapper = function pushStateWrapper() {
|
|
11288
|
-
var args = [];
|
|
11289
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11290
|
-
args[_i] = arguments[_i];
|
|
11291
|
-
}
|
|
11292
|
-
var result = originalPushState.apply(this, args);
|
|
11293
|
-
if (self._isActive) {
|
|
11294
|
-
self.safeHandleNavigation('pushState');
|
|
11295
|
-
}
|
|
11296
|
-
return result;
|
|
11297
|
-
};
|
|
11298
|
-
var replaceStateWrapper = function replaceStateWrapper() {
|
|
11299
|
-
var args = [];
|
|
11300
|
-
for (var _i = 0; _i < arguments.length; _i++) {
|
|
11301
|
-
args[_i] = arguments[_i];
|
|
11302
|
-
}
|
|
11303
|
-
var result = originalReplaceState.apply(this, args);
|
|
11304
|
-
if (self._isActive) {
|
|
11305
|
-
self.safeHandleNavigation('replaceState');
|
|
11306
|
-
}
|
|
11307
|
-
return result;
|
|
11308
|
-
};
|
|
11309
|
-
Object.defineProperty(pushStateWrapper, WRAPPED_MARKER, {
|
|
11310
|
-
value: true,
|
|
11311
|
-
enumerable: false
|
|
11312
|
-
});
|
|
11313
|
-
Object.defineProperty(replaceStateWrapper, WRAPPED_MARKER, {
|
|
11314
|
-
value: true,
|
|
11315
|
-
enumerable: false
|
|
11316
|
-
});
|
|
11317
|
-
this.pushStateWrapper = pushStateWrapper;
|
|
11318
|
-
this.replaceStateWrapper = replaceStateWrapper;
|
|
11319
|
-
try {
|
|
11320
|
-
window.history.pushState = pushStateWrapper;
|
|
11321
|
-
window.history.replaceState = replaceStateWrapper;
|
|
11322
|
-
} catch (e) {
|
|
11323
|
-
this.mpInstance.Logger.verbose("mParticle APV: [error] failed to patch history methods (frozen/sealed), rolling back: ".concat(e));
|
|
11324
|
-
try {
|
|
11325
|
-
if (window.history.pushState === pushStateWrapper) {
|
|
11326
|
-
window.history.pushState = originalPushState;
|
|
11327
|
-
}
|
|
11328
|
-
if (window.history.replaceState === replaceStateWrapper) {
|
|
11329
|
-
window.history.replaceState = originalReplaceState;
|
|
11330
|
-
}
|
|
11331
|
-
} catch (restoreError) {
|
|
11332
|
-
this.mpInstance.Logger.verbose("mParticle APV: [error] failed to restore history methods after patch failure: ".concat(restoreError));
|
|
11333
|
-
}
|
|
11334
|
-
this.pushStateWrapper = null;
|
|
11335
|
-
this.replaceStateWrapper = null;
|
|
11336
|
-
this.originalPushState = null;
|
|
11337
|
-
this.originalReplaceState = null;
|
|
11338
|
-
}
|
|
11339
|
-
};
|
|
11340
|
-
PageViewTracker.prototype.addNavigationListeners = function () {
|
|
11341
|
-
var _this = this;
|
|
11342
|
-
this.popStateListener = function () {
|
|
11343
|
-
return _this.safeHandleNavigation('popstate');
|
|
11344
|
-
};
|
|
11345
|
-
window.addEventListener('popstate', this.popStateListener);
|
|
11346
|
-
};
|
|
11347
|
-
PageViewTracker.prototype.safeHandleNavigation = function (source) {
|
|
11348
|
-
try {
|
|
11349
|
-
this.handleNavigation(source);
|
|
11350
|
-
} catch (e) {
|
|
11351
|
-
this.mpInstance.Logger.verbose("mParticle APV: [error] navigation handler threw (".concat(source, "), page view skipped: ").concat(e));
|
|
11352
|
-
}
|
|
11353
|
-
};
|
|
11354
|
-
PageViewTracker.prototype.getCurrentKey = function () {
|
|
11355
|
-
return window.location.pathname;
|
|
11356
|
-
};
|
|
11357
|
-
PageViewTracker.prototype.handleNavigation = function (source) {
|
|
11358
|
-
var _this = this;
|
|
11359
|
-
var candidatePath = this.getCurrentKey();
|
|
11360
|
-
this.mpInstance.Logger.verbose("mParticle APV: [detect] navigation signal (source: ".concat(source, ", candidatePath: ").concat(candidatePath, ", lastPath: ").concat(this.lastPath, ")"));
|
|
11361
|
-
if (candidatePath === this.lastPath) {
|
|
11362
|
-
this.mpInstance.Logger.verbose("mParticle APV: [dedupe] pathname unchanged, skipping (source: ".concat(source, ", path: ").concat(candidatePath, ")"));
|
|
11363
|
-
return;
|
|
11364
|
-
}
|
|
11365
|
-
this.mpInstance.Logger.verbose("mParticle APV: [accept] pathname changed, scheduling fire (source: ".concat(source, ", from: ").concat(this.lastPath, ", to: ").concat(candidatePath, ")"));
|
|
11366
|
-
this.lastPath = candidatePath;
|
|
11367
|
-
// Snapshot the path now: it is already settled at this point, and a
|
|
11368
|
-
// same-tick navigation would otherwise overwrite window.location
|
|
11369
|
-
// before the deferred flush reads it. The title is intentionally read
|
|
11370
|
-
// later (in the deferred flush) so the router's post-navigation render
|
|
11371
|
-
// commit has a chance to update document.title first.
|
|
11372
|
-
var capturedPath = candidatePath;
|
|
11373
|
-
var timeoutId = setTimeout(function () {
|
|
11374
|
-
_this.pendingNavigations = _this.pendingNavigations.filter(function (p) {
|
|
11375
|
-
return p.timeoutId !== timeoutId;
|
|
11376
|
-
});
|
|
11377
|
-
if (!_this._isActive) {
|
|
11378
|
-
_this.mpInstance.Logger.verbose('mParticle APV: [defer] fire aborted, tracker inactive (torn down before flush)');
|
|
11379
|
-
return;
|
|
11380
|
-
}
|
|
11381
|
-
_this.mpInstance._SessionManager.resetSessionTimer();
|
|
11382
|
-
_this.firePageView(capturedPath);
|
|
11383
|
-
}, 0);
|
|
11384
|
-
this.pendingNavigations.push({
|
|
11385
|
-
path: capturedPath,
|
|
11386
|
-
timeoutId: timeoutId
|
|
11387
|
-
});
|
|
11388
|
-
};
|
|
11389
|
-
// Mirrors the event shape of the public mParticle.logPageView(), but carries
|
|
11390
|
-
// the captured SPA path rather than reading the live location.
|
|
11391
|
-
PageViewTracker.prototype.firePageView = function (path) {
|
|
11392
|
-
var title = window.document.title;
|
|
11393
|
-
this.mpInstance.Logger.verbose("mParticle APV: [fire] deferred flush -> _Events.logEvent(PageView) (path: ".concat(path, ", title: ").concat(title, ")"));
|
|
11394
|
-
this.mpInstance._Events.logEvent({
|
|
11395
|
-
messageType: MessageType$1.PageView,
|
|
11396
|
-
name: 'PageView',
|
|
11397
|
-
data: {
|
|
11398
|
-
hostname: window.location.hostname,
|
|
11399
|
-
title: title,
|
|
11400
|
-
path: path
|
|
11401
|
-
},
|
|
11402
|
-
eventType: EventType.Unknown
|
|
11403
|
-
});
|
|
11404
|
-
};
|
|
11405
|
-
// Cancels pending deferred fires and returns their captured paths so a
|
|
11406
|
-
// successor tracker can re-schedule them. Call before teardown() during
|
|
11407
|
-
// module-replacement handoff.
|
|
11408
|
-
PageViewTracker.prototype.takePendingNavigations = function () {
|
|
11409
|
-
var paths = this.pendingNavigations.map(function (p) {
|
|
11410
|
-
return p.path;
|
|
11411
|
-
});
|
|
11412
|
-
this.pendingNavigations.forEach(function (p) {
|
|
11413
|
-
return clearTimeout(p.timeoutId);
|
|
11414
|
-
});
|
|
11415
|
-
this.pendingNavigations = [];
|
|
11416
|
-
return paths;
|
|
11417
|
-
};
|
|
11418
|
-
PageViewTracker.prototype.restoreHistoryMethod = function (methodName, original, wrapper) {
|
|
11419
|
-
if (!original) return;
|
|
11420
|
-
var stillOurs = wrapper !== null && window.history[methodName] === wrapper;
|
|
11421
|
-
if (stillOurs) {
|
|
11422
|
-
window.history[methodName] = original;
|
|
11423
|
-
this.mpInstance.Logger.verbose("mParticle APV: [teardown] restored original ".concat(methodName));
|
|
11424
|
-
} else {
|
|
11425
|
-
this.mpInstance.Logger.verbose("mParticle APV: [teardown] ".concat(methodName, " no longer ours; leaving in place, gating callback to no-op"));
|
|
11426
|
-
}
|
|
11427
|
-
};
|
|
11428
|
-
PageViewTracker.prototype.teardown = function () {
|
|
11429
|
-
// Cancel any pending deferred fires (e.g. when the feature flag is
|
|
11430
|
-
// disabled on re-init). For module-replacement, call takePendingNavigations()
|
|
11431
|
-
// before teardown() instead so paths are transferred, not discarded.
|
|
11432
|
-
this.pendingNavigations.forEach(function (p) {
|
|
11433
|
-
return clearTimeout(p.timeoutId);
|
|
11434
|
-
});
|
|
11435
|
-
this.pendingNavigations = [];
|
|
11436
|
-
if (this.popStateListener) {
|
|
11437
|
-
window.removeEventListener('popstate', this.popStateListener);
|
|
11438
|
-
this.popStateListener = null;
|
|
11439
|
-
}
|
|
11440
|
-
this.restoreHistoryMethod('pushState', this.originalPushState, this.pushStateWrapper);
|
|
11441
|
-
this.originalPushState = null;
|
|
11442
|
-
this.pushStateWrapper = null;
|
|
11443
|
-
this.restoreHistoryMethod('replaceState', this.originalReplaceState, this.replaceStateWrapper);
|
|
11444
|
-
this.originalReplaceState = null;
|
|
11445
|
-
this.replaceStateWrapper = null;
|
|
11446
|
-
this._isActive = false;
|
|
11447
|
-
if (getWindowTracker() === this) {
|
|
11448
|
-
setWindowTracker(undefined);
|
|
11449
|
-
}
|
|
11450
|
-
};
|
|
11451
|
-
return PageViewTracker;
|
|
11452
|
-
}();
|
|
11453
|
-
function getWindowTracker() {
|
|
11454
|
-
if (typeof window === 'undefined') return undefined;
|
|
11455
|
-
return window[WIN_TRACKER_KEY];
|
|
11456
|
-
}
|
|
11457
|
-
function setWindowTracker(tracker) {
|
|
11458
|
-
if (typeof window === 'undefined') return;
|
|
11459
|
-
var win = window;
|
|
11460
|
-
if (tracker) {
|
|
11461
|
-
win[WIN_TRACKER_KEY] = tracker;
|
|
11462
|
-
} else {
|
|
11463
|
-
delete win[WIN_TRACKER_KEY];
|
|
11464
|
-
}
|
|
11465
|
-
}
|
|
11466
|
-
|
|
11467
11705
|
var Messages = Constants.Messages,
|
|
11468
11706
|
HTTPCodes = Constants.HTTPCodes,
|
|
11469
11707
|
FeatureFlags = Constants.FeatureFlags,
|
|
@@ -11616,12 +11854,8 @@ var mParticle = (function () {
|
|
|
11616
11854
|
instance._Store = new Store(config, instance);
|
|
11617
11855
|
instance._Store.isLocalStorageAvailable = instance._Persistence.determineLocalStorageAvailability(window.localStorage);
|
|
11618
11856
|
instance._Events.stopTracking();
|
|
11619
|
-
|
|
11620
|
-
|
|
11621
|
-
instanceTracker.teardown();
|
|
11622
|
-
instance._PageViewTracker = undefined;
|
|
11623
|
-
}
|
|
11624
|
-
PageViewTracker.resetWindowState(instanceTracker);
|
|
11857
|
+
resetPageViewTracking();
|
|
11858
|
+
instance._PageViewTracker = undefined;
|
|
11625
11859
|
if (!keepPersistence) {
|
|
11626
11860
|
instance._Persistence.resetPersistence();
|
|
11627
11861
|
}
|
|
@@ -12548,24 +12782,23 @@ var mParticle = (function () {
|
|
|
12548
12782
|
// Logs a session start or session end event accordingly
|
|
12549
12783
|
mpInstance._SessionManager.initialize();
|
|
12550
12784
|
mpInstance._Events.logAST();
|
|
12551
|
-
// Note: APV
|
|
12552
|
-
//
|
|
12553
|
-
// out of scope
|
|
12785
|
+
// Note: APV state (the active tracker and the initial-page-view flag) is
|
|
12786
|
+
// window-scoped and assumes a single active SDK instance. Multiple-instance
|
|
12787
|
+
// support is out of scope.
|
|
12554
12788
|
if (getFeatureFlag(AutoLogPageView)) {
|
|
12555
12789
|
if (!mpInstance._PageViewTracker) {
|
|
12556
12790
|
mpInstance.Logger.verbose('mParticle APV: [sdk-init] creating new PageViewTracker for this instance');
|
|
12557
12791
|
mpInstance._PageViewTracker = new PageViewTracker(mpInstance);
|
|
12558
|
-
|
|
12559
|
-
|
|
12560
|
-
|
|
12561
|
-
|
|
12562
|
-
|
|
12563
|
-
|
|
12564
|
-
|
|
12565
|
-
mpInstance._Events.logPageView();
|
|
12566
|
-
}
|
|
12792
|
+
}
|
|
12793
|
+
// The initial page view fires once per hard page load, not once per
|
|
12794
|
+
// init(): the window flag survives the module re-evaluation Next.js
|
|
12795
|
+
// performs on every SPA navigation, so repeated init() calls from SPA
|
|
12796
|
+
// re-renders don't fire duplicate logPageView() events.
|
|
12797
|
+
if (hasInitialPageViewFired()) {
|
|
12798
|
+
mpInstance.Logger.verbose('mParticle APV: [sdk-init] initial page view already logged this page load, skipping');
|
|
12567
12799
|
} else {
|
|
12568
|
-
|
|
12800
|
+
markInitialPageViewFired();
|
|
12801
|
+
mpInstance._Events.logPageView();
|
|
12569
12802
|
}
|
|
12570
12803
|
mpInstance._PageViewTracker.init();
|
|
12571
12804
|
} else if (mpInstance._PageViewTracker) {
|