@mparticle/web-sdk 2.23.6 → 2.23.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mparticle.common.js +43 -31
- package/dist/mparticle.esm.js +43 -31
- package/dist/mparticle.js +109 -43
- package/package.json +5 -4
- package/src/apiClient.ts +5 -7
- package/src/constants.ts +8 -0
- package/src/events.js +2 -0
- package/src/forwarders.interfaces.ts +28 -6
- package/src/forwarders.js +54 -29
- package/src/helpers.js +1 -0
- package/src/identity.js +9 -5
- package/src/identityApiClient.js +3 -1
- package/src/mp-instance.js +3 -0
- package/src/persistence.js +19 -1
- package/src/sdkRuntimeModels.ts +1 -4
- package/src/serverModel.ts +9 -14
- package/src/sessionManager.ts +1 -0
- package/src/store.ts +1 -2
- package/src/types.js +0 -1
- package/src/utils.ts +4 -0
- package/src/validators.ts +10 -2
package/src/forwarders.js
CHANGED
|
@@ -2,6 +2,9 @@ import Types from './types';
|
|
|
2
2
|
import filteredMparticleUser from './filteredMparticleUser';
|
|
3
3
|
import { isEmpty } from './utils';
|
|
4
4
|
import KitFilterHelper from './kitFilterHelper';
|
|
5
|
+
import Constants from './constants';
|
|
6
|
+
|
|
7
|
+
const { Modify, Identify, Login, Logout } = Constants.IdentityMethods;
|
|
5
8
|
|
|
6
9
|
export default function Forwarders(mpInstance, kitBlocker) {
|
|
7
10
|
var self = this;
|
|
@@ -440,6 +443,7 @@ export default function Forwarders(mpInstance, kitBlocker) {
|
|
|
440
443
|
});
|
|
441
444
|
};
|
|
442
445
|
|
|
446
|
+
// TODO: https://go.mparticle.com/work/SQDSDKS-6036
|
|
443
447
|
this.setForwarderUserIdentities = function(userIdentities) {
|
|
444
448
|
mpInstance._Store.activeForwarders.forEach(function(forwarder) {
|
|
445
449
|
var filteredUserIdentities = mpInstance._Helpers.filterUserIdentities(
|
|
@@ -487,30 +491,45 @@ export default function Forwarders(mpInstance, kitBlocker) {
|
|
|
487
491
|
mpInstance,
|
|
488
492
|
kitBlocker
|
|
489
493
|
);
|
|
490
|
-
|
|
494
|
+
|
|
495
|
+
const filteredUserIdentities = filteredUser.getUserIdentities();
|
|
496
|
+
|
|
497
|
+
if (identityMethod === Identify) {
|
|
491
498
|
if (forwarder.onIdentifyComplete) {
|
|
492
|
-
result = forwarder.onIdentifyComplete(
|
|
499
|
+
result = forwarder.onIdentifyComplete(
|
|
500
|
+
filteredUser,
|
|
501
|
+
filteredUserIdentities
|
|
502
|
+
);
|
|
493
503
|
if (result) {
|
|
494
504
|
mpInstance.Logger.verbose(result);
|
|
495
505
|
}
|
|
496
506
|
}
|
|
497
|
-
} else if (identityMethod ===
|
|
507
|
+
} else if (identityMethod === Login) {
|
|
498
508
|
if (forwarder.onLoginComplete) {
|
|
499
|
-
result = forwarder.onLoginComplete(
|
|
509
|
+
result = forwarder.onLoginComplete(
|
|
510
|
+
filteredUser,
|
|
511
|
+
filteredUserIdentities
|
|
512
|
+
);
|
|
500
513
|
if (result) {
|
|
501
514
|
mpInstance.Logger.verbose(result);
|
|
502
515
|
}
|
|
503
516
|
}
|
|
504
|
-
} else if (identityMethod ===
|
|
517
|
+
} else if (identityMethod === Logout) {
|
|
505
518
|
if (forwarder.onLogoutComplete) {
|
|
506
|
-
result = forwarder.onLogoutComplete(
|
|
519
|
+
result = forwarder.onLogoutComplete(
|
|
520
|
+
filteredUser,
|
|
521
|
+
filteredUserIdentities
|
|
522
|
+
);
|
|
507
523
|
if (result) {
|
|
508
524
|
mpInstance.Logger.verbose(result);
|
|
509
525
|
}
|
|
510
526
|
}
|
|
511
|
-
} else if (identityMethod ===
|
|
527
|
+
} else if (identityMethod === Modify) {
|
|
512
528
|
if (forwarder.onModifyComplete) {
|
|
513
|
-
result = forwarder.onModifyComplete(
|
|
529
|
+
result = forwarder.onModifyComplete(
|
|
530
|
+
filteredUser,
|
|
531
|
+
filteredUserIdentities
|
|
532
|
+
);
|
|
514
533
|
if (result) {
|
|
515
534
|
mpInstance.Logger.verbose(result);
|
|
516
535
|
}
|
|
@@ -629,43 +648,49 @@ export default function Forwarders(mpInstance, kitBlocker) {
|
|
|
629
648
|
}
|
|
630
649
|
};
|
|
631
650
|
|
|
632
|
-
//
|
|
633
|
-
// They are automatically added to active forwarders.
|
|
651
|
+
// Unlike UI enabled kits, sideloaded kits are always added to active forwarders.
|
|
634
652
|
|
|
635
|
-
// TODO: Sideloading kits currently
|
|
653
|
+
// TODO: Sideloading kits currently require the use of a register method
|
|
636
654
|
// which requires an object on which to be registered.
|
|
637
|
-
// In the future, when all kits are moved to the
|
|
655
|
+
// In the future, when all kits are moved to the mpConfig rather than
|
|
638
656
|
// there being a separate process for MP configured kits and
|
|
639
657
|
// sideloaded kits, this will need to be refactored.
|
|
640
|
-
this.processSideloadedKits = function(
|
|
658
|
+
this.processSideloadedKits = function(mpConfig) {
|
|
641
659
|
try {
|
|
642
|
-
if (Array.isArray(
|
|
643
|
-
const
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
config.sideloadedKits.forEach(function(sideloadedKit) {
|
|
660
|
+
if (Array.isArray(mpConfig.sideloadedKits)) {
|
|
661
|
+
const registeredSideloadedKits = { kits: {} };
|
|
662
|
+
const unregisteredSideloadedKits = mpConfig.sideloadedKits;
|
|
663
|
+
|
|
664
|
+
unregisteredSideloadedKits.forEach(function(unregisteredKit) {
|
|
648
665
|
try {
|
|
649
|
-
|
|
666
|
+
// Register each sideloaded kit, which adds a key of the sideloaded kit name
|
|
667
|
+
// and a value of the sideloaded kit constructor.
|
|
668
|
+
unregisteredKit.kitInstance.register(
|
|
669
|
+
registeredSideloadedKits
|
|
670
|
+
);
|
|
671
|
+
const kitName = unregisteredKit.kitInstance.name;
|
|
672
|
+
// Then add the kit filters to each registered kit.
|
|
673
|
+
registeredSideloadedKits.kits[kitName].filters =
|
|
674
|
+
unregisteredKit.filterDictionary;
|
|
650
675
|
} catch (e) {
|
|
651
676
|
console.error(
|
|
652
677
|
'Error registering sideloaded kit ' +
|
|
653
|
-
|
|
678
|
+
unregisteredKit.kitInstance.name
|
|
654
679
|
);
|
|
655
680
|
}
|
|
656
681
|
});
|
|
657
682
|
|
|
658
|
-
// Then configure each kit
|
|
659
|
-
for (const registeredKitKey in
|
|
660
|
-
const
|
|
661
|
-
|
|
662
|
-
self.configureSideloadedKit(
|
|
683
|
+
// Then configure each registered kit
|
|
684
|
+
for (const registeredKitKey in registeredSideloadedKits.kits) {
|
|
685
|
+
const registeredKit =
|
|
686
|
+
registeredSideloadedKits.kits[registeredKitKey];
|
|
687
|
+
self.configureSideloadedKit(registeredKit);
|
|
663
688
|
}
|
|
664
689
|
|
|
665
690
|
// If Sideloaded Kits are successfully registered,
|
|
666
691
|
// record this in the Store.
|
|
667
|
-
if (!isEmpty(
|
|
668
|
-
const kitKeys = Object.keys(
|
|
692
|
+
if (!isEmpty(registeredSideloadedKits.kits)) {
|
|
693
|
+
const kitKeys = Object.keys(registeredSideloadedKits.kits);
|
|
669
694
|
mpInstance._Store.sideloadedKitsCount = kitKeys.length;
|
|
670
695
|
}
|
|
671
696
|
}
|
|
@@ -680,7 +705,7 @@ export default function Forwarders(mpInstance, kitBlocker) {
|
|
|
680
705
|
// kits can be included via mParticle UI, or via sideloaded kit config API
|
|
681
706
|
this.configureSideloadedKit = function(kitConstructor) {
|
|
682
707
|
mpInstance._Store.configuredForwarders.push(
|
|
683
|
-
this.returnConfiguredKit(kitConstructor)
|
|
708
|
+
this.returnConfiguredKit(kitConstructor, kitConstructor.filters)
|
|
684
709
|
);
|
|
685
710
|
};
|
|
686
711
|
|
package/src/helpers.js
CHANGED
package/src/identity.js
CHANGED
|
@@ -4,6 +4,8 @@ import Types from './types';
|
|
|
4
4
|
var Messages = Constants.Messages,
|
|
5
5
|
HTTPCodes = Constants.HTTPCodes;
|
|
6
6
|
|
|
7
|
+
const { Identify, Modify } = Constants.IdentityMethods;
|
|
8
|
+
|
|
7
9
|
export default function Identity(mpInstance) {
|
|
8
10
|
var self = this;
|
|
9
11
|
this.checkIdentitySwap = function(
|
|
@@ -1476,7 +1478,7 @@ export default function Identity(mpInstance) {
|
|
|
1476
1478
|
}
|
|
1477
1479
|
|
|
1478
1480
|
if (xhr.status === 200) {
|
|
1479
|
-
if (method ===
|
|
1481
|
+
if (method === Modify) {
|
|
1480
1482
|
newIdentitiesByType = mpInstance._Identity.IdentityRequest.combineUserIdentities(
|
|
1481
1483
|
previousUIByName,
|
|
1482
1484
|
identityApiData.userIdentities
|
|
@@ -1507,7 +1509,7 @@ export default function Identity(mpInstance) {
|
|
|
1507
1509
|
//will not have a value for "fst" until the current MPID changes, and in some cases,
|
|
1508
1510
|
//the current MPID will never change
|
|
1509
1511
|
if (
|
|
1510
|
-
method ===
|
|
1512
|
+
method === Identify &&
|
|
1511
1513
|
prevUser &&
|
|
1512
1514
|
identityApiResult.mpid === prevUser.getMPID()
|
|
1513
1515
|
) {
|
|
@@ -1568,6 +1570,7 @@ export default function Identity(mpInstance) {
|
|
|
1568
1570
|
);
|
|
1569
1571
|
}
|
|
1570
1572
|
|
|
1573
|
+
// https://go.mparticle.com/work/SQDSDKS-6041
|
|
1571
1574
|
mpInstance._Persistence.saveUserIdentitiesToPersistence(
|
|
1572
1575
|
identityApiResult.mpid,
|
|
1573
1576
|
newIdentitiesByType
|
|
@@ -1620,6 +1623,8 @@ export default function Identity(mpInstance) {
|
|
|
1620
1623
|
mpInstance._APIClient.prepareForwardingStats
|
|
1621
1624
|
);
|
|
1622
1625
|
}
|
|
1626
|
+
|
|
1627
|
+
// TODO: https://go.mparticle.com/work/SQDSDKS-6036
|
|
1623
1628
|
mpInstance._Forwarders.setForwarderUserIdentities(
|
|
1624
1629
|
newUser.getUserIdentities().userIdentities
|
|
1625
1630
|
);
|
|
@@ -1628,8 +1633,7 @@ export default function Identity(mpInstance) {
|
|
|
1628
1633
|
method
|
|
1629
1634
|
);
|
|
1630
1635
|
mpInstance._Forwarders.setForwarderOnUserIdentified(
|
|
1631
|
-
newUser
|
|
1632
|
-
method
|
|
1636
|
+
newUser
|
|
1633
1637
|
);
|
|
1634
1638
|
}
|
|
1635
1639
|
var newIdentitiesByName = {};
|
|
@@ -1646,7 +1650,7 @@ export default function Identity(mpInstance) {
|
|
|
1646
1650
|
newIdentitiesByName,
|
|
1647
1651
|
method,
|
|
1648
1652
|
identityApiResult.mpid,
|
|
1649
|
-
method ===
|
|
1653
|
+
method === Modify
|
|
1650
1654
|
? previousUIByNameCopy
|
|
1651
1655
|
: incomingMpidUIByNameCopy
|
|
1652
1656
|
);
|
package/src/identityApiClient.js
CHANGED
|
@@ -3,6 +3,8 @@ import Constants from './constants';
|
|
|
3
3
|
var HTTPCodes = Constants.HTTPCodes,
|
|
4
4
|
Messages = Constants.Messages;
|
|
5
5
|
|
|
6
|
+
const { Modify } = Constants.IdentityMethods;
|
|
7
|
+
|
|
6
8
|
export default function IdentityAPIClient(mpInstance) {
|
|
7
9
|
this.sendAliasRequest = function(aliasRequest, callback) {
|
|
8
10
|
var xhr,
|
|
@@ -107,7 +109,7 @@ export default function IdentityAPIClient(mpInstance) {
|
|
|
107
109
|
);
|
|
108
110
|
} else {
|
|
109
111
|
previousMPID = mpid || null;
|
|
110
|
-
if (method ===
|
|
112
|
+
if (method === Modify) {
|
|
111
113
|
xhr.open(
|
|
112
114
|
'post',
|
|
113
115
|
mpInstance._Helpers.createServiceUrl(
|
package/src/mp-instance.js
CHANGED
|
@@ -1330,6 +1330,7 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
|
1330
1330
|
|
|
1331
1331
|
mpInstance._Store.configurationLoaded = true;
|
|
1332
1332
|
|
|
1333
|
+
// https://go.mparticle.com/work/SQDSDKS-6044
|
|
1333
1334
|
if (!mpInstance._Store.webviewBridgeEnabled) {
|
|
1334
1335
|
// Load any settings/identities/attributes from cookie or localStorage
|
|
1335
1336
|
mpInstance._Persistence.initializeStorage();
|
|
@@ -1401,6 +1402,7 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
|
1401
1402
|
mpInstance._Events.logAST();
|
|
1402
1403
|
|
|
1403
1404
|
// Call mParticle._Store.SDKConfig.identityCallback when identify was not called due to a reload or a sessionId already existing
|
|
1405
|
+
// Any identity callback should always be ran regardless if an identity call is made
|
|
1404
1406
|
if (
|
|
1405
1407
|
!mpInstance._Store.identifyCalled &&
|
|
1406
1408
|
mpInstance._Store.SDKConfig.identityCallback &&
|
|
@@ -1455,6 +1457,7 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
|
1455
1457
|
mpInstance._preInit.readyQueue = [];
|
|
1456
1458
|
}
|
|
1457
1459
|
|
|
1460
|
+
// https://go.mparticle.com/work/SQDSDKS-6040
|
|
1458
1461
|
if (mpInstance._Store.isFirstRun) {
|
|
1459
1462
|
mpInstance._Store.isFirstRun = false;
|
|
1460
1463
|
}
|
package/src/persistence.js
CHANGED
|
@@ -10,6 +10,8 @@ var Base64 = Polyfill.Base64,
|
|
|
10
10
|
|
|
11
11
|
export default function _Persistence(mpInstance) {
|
|
12
12
|
var self = this;
|
|
13
|
+
|
|
14
|
+
// https://go.mparticle.com/work/SQDSDKS-5022
|
|
13
15
|
this.useLocalStorage = function() {
|
|
14
16
|
return (
|
|
15
17
|
!mpInstance._Store.SDKConfig.useCookieStorage &&
|
|
@@ -24,6 +26,7 @@ export default function _Persistence(mpInstance) {
|
|
|
24
26
|
cookies = self.getCookie(),
|
|
25
27
|
allData;
|
|
26
28
|
|
|
29
|
+
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
27
30
|
// Determine if there is any data in cookies or localStorage to figure out if it is the first time the browser is loading mParticle
|
|
28
31
|
if (!localStorageData && !cookies) {
|
|
29
32
|
mpInstance._Store.isFirstRun = true;
|
|
@@ -32,10 +35,12 @@ export default function _Persistence(mpInstance) {
|
|
|
32
35
|
mpInstance._Store.isFirstRun = false;
|
|
33
36
|
}
|
|
34
37
|
|
|
38
|
+
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
35
39
|
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
36
40
|
mpInstance._Store.SDKConfig.useCookieStorage = true;
|
|
37
41
|
}
|
|
38
42
|
|
|
43
|
+
// https://go.mparticle.com/work/SQDSDKS-6046
|
|
39
44
|
if (mpInstance._Store.isLocalStorageAvailable) {
|
|
40
45
|
storage = window.localStorage;
|
|
41
46
|
if (mpInstance._Store.SDKConfig.useCookieStorage) {
|
|
@@ -43,6 +48,7 @@ export default function _Persistence(mpInstance) {
|
|
|
43
48
|
// no mParticle cookie exists yet and there is localStorage. Get the localStorage, set them to cookies, then delete the localStorage item.
|
|
44
49
|
if (localStorageData) {
|
|
45
50
|
if (cookies) {
|
|
51
|
+
// https://go.mparticle.com/work/SQDSDKS-6047
|
|
46
52
|
allData = mpInstance._Helpers.extend(
|
|
47
53
|
false,
|
|
48
54
|
localStorageData,
|
|
@@ -61,6 +67,7 @@ export default function _Persistence(mpInstance) {
|
|
|
61
67
|
// no mParticle localStorage exists yet and there are cookies. Get the cookies, set them to localStorage, then delete the cookies.
|
|
62
68
|
if (cookies) {
|
|
63
69
|
if (localStorageData) {
|
|
70
|
+
// https://go.mparticle.com/work/SQDSDKS-6047
|
|
64
71
|
allData = mpInstance._Helpers.extend(
|
|
65
72
|
false,
|
|
66
73
|
localStorageData,
|
|
@@ -79,6 +86,7 @@ export default function _Persistence(mpInstance) {
|
|
|
79
86
|
self.storeDataInMemory(cookies);
|
|
80
87
|
}
|
|
81
88
|
|
|
89
|
+
// https://go.mparticle.com/work/SQDSDKS-6048
|
|
82
90
|
try {
|
|
83
91
|
if (mpInstance._Store.isLocalStorageAvailable) {
|
|
84
92
|
var encodedProducts = localStorage.getItem(
|
|
@@ -107,6 +115,8 @@ export default function _Persistence(mpInstance) {
|
|
|
107
115
|
);
|
|
108
116
|
}
|
|
109
117
|
|
|
118
|
+
// https://go.mparticle.com/work/SQDSDKS-6046
|
|
119
|
+
// Stores all non-current user MPID information into the store
|
|
110
120
|
for (var key in allData) {
|
|
111
121
|
if (allData.hasOwnProperty(key)) {
|
|
112
122
|
if (!SDKv2NonMPIDCookieKeys[key]) {
|
|
@@ -117,6 +127,8 @@ export default function _Persistence(mpInstance) {
|
|
|
117
127
|
}
|
|
118
128
|
self.update();
|
|
119
129
|
} catch (e) {
|
|
130
|
+
// If cookies or local storage is corrupt, we want to remove it
|
|
131
|
+
// so that in the future, initializeStorage will work
|
|
120
132
|
if (
|
|
121
133
|
self.useLocalStorage() &&
|
|
122
134
|
mpInstance._Store.isLocalStorageAvailable
|
|
@@ -154,6 +166,7 @@ export default function _Persistence(mpInstance) {
|
|
|
154
166
|
}
|
|
155
167
|
};
|
|
156
168
|
|
|
169
|
+
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
157
170
|
this.storeDataInMemory = function(obj, currentMPID) {
|
|
158
171
|
try {
|
|
159
172
|
if (!obj) {
|
|
@@ -235,6 +248,7 @@ export default function _Persistence(mpInstance) {
|
|
|
235
248
|
}
|
|
236
249
|
};
|
|
237
250
|
|
|
251
|
+
// https://go.mparticle.com/work/SQDSDKS-5022
|
|
238
252
|
this.determineLocalStorageAvailability = function(storage) {
|
|
239
253
|
var result;
|
|
240
254
|
|
|
@@ -310,6 +324,7 @@ export default function _Persistence(mpInstance) {
|
|
|
310
324
|
return parsedDecodedProducts;
|
|
311
325
|
};
|
|
312
326
|
|
|
327
|
+
// https://go.mparticle.com/work/SQDSDKS-6021
|
|
313
328
|
this.setLocalStorage = function() {
|
|
314
329
|
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
315
330
|
return;
|
|
@@ -492,7 +507,8 @@ export default function _Persistence(mpInstance) {
|
|
|
492
507
|
}
|
|
493
508
|
};
|
|
494
509
|
|
|
495
|
-
//
|
|
510
|
+
// https://go.mparticle.com/work/SQDSDKS-5022
|
|
511
|
+
// https://go.mparticle.com/work/SQDSDKS-6021
|
|
496
512
|
this.setCookie = function() {
|
|
497
513
|
var mpid,
|
|
498
514
|
currentUser = mpInstance.Identity.getCurrentUser();
|
|
@@ -996,6 +1012,7 @@ export default function _Persistence(mpInstance) {
|
|
|
996
1012
|
}
|
|
997
1013
|
};
|
|
998
1014
|
|
|
1015
|
+
// https://go.mparticle.com/work/SQDSDKS-6021
|
|
999
1016
|
this.savePersistence = function(persistence) {
|
|
1000
1017
|
var encodedPersistence = self.encodePersistence(
|
|
1001
1018
|
JSON.stringify(persistence)
|
|
@@ -1168,6 +1185,7 @@ export default function _Persistence(mpInstance) {
|
|
|
1168
1185
|
}
|
|
1169
1186
|
};
|
|
1170
1187
|
|
|
1188
|
+
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
1171
1189
|
// Forwarder Batching Code
|
|
1172
1190
|
this.forwardingStatsBatches = {
|
|
1173
1191
|
uploadsTable: {},
|
package/src/sdkRuntimeModels.ts
CHANGED
|
@@ -10,6 +10,7 @@ import { SDKConsentApi, SDKConsentState } from './consent';
|
|
|
10
10
|
import { IPersistence } from './persistence.interfaces';
|
|
11
11
|
import { IMPSideloadedKit } from './sideloadedKit';
|
|
12
12
|
import { ISessionManager } from './sessionManager';
|
|
13
|
+
import { Kit, MPForwarder } from './forwarders.interfaces';
|
|
13
14
|
|
|
14
15
|
// TODO: Resolve this with version in @mparticle/web-sdk
|
|
15
16
|
export type SDKEventCustomFlags = Dictionary<any>;
|
|
@@ -184,10 +185,6 @@ export type BooleanStringTitleCase = 'False' | 'True';
|
|
|
184
185
|
|
|
185
186
|
export type LogLevelType = 'none' | 'verbose' | 'warning' | 'error';
|
|
186
187
|
|
|
187
|
-
// TODO: Create true types for Kits and Kit Configs
|
|
188
|
-
export type Kit = Dictionary;
|
|
189
|
-
export type MPForwarder = Dictionary;
|
|
190
|
-
|
|
191
188
|
// TODO: This should eventually be moved into wherever init logic lives
|
|
192
189
|
// TODO: Replace/Merge this with MPConfiguration in @types/mparticle__web-sdk
|
|
193
190
|
// SDK Init Config represents the config that is passed into mParticle.init when
|
package/src/serverModel.ts
CHANGED
|
@@ -13,7 +13,12 @@ import {
|
|
|
13
13
|
SDKProduct,
|
|
14
14
|
SDKUserIdentity,
|
|
15
15
|
} from './sdkRuntimeModels';
|
|
16
|
-
import {
|
|
16
|
+
import {
|
|
17
|
+
parseNumber,
|
|
18
|
+
parseStringOrNumber,
|
|
19
|
+
Dictionary,
|
|
20
|
+
isValidCustomFlagProperty,
|
|
21
|
+
} from './utils';
|
|
17
22
|
import { ServerSettings } from './store';
|
|
18
23
|
import { MPID } from '@mparticle/web-sdk';
|
|
19
24
|
import {
|
|
@@ -145,22 +150,12 @@ function convertCustomFlags(event: SDKEvent, dto: IServerV2DTO) {
|
|
|
145
150
|
|
|
146
151
|
if (event.CustomFlags.hasOwnProperty(prop)) {
|
|
147
152
|
if (Array.isArray(event.CustomFlags[prop])) {
|
|
148
|
-
event.CustomFlags[prop].forEach(
|
|
149
|
-
|
|
150
|
-
if (
|
|
151
|
-
typeof customFlagProperty === 'number' ||
|
|
152
|
-
typeof customFlagProperty === 'string' ||
|
|
153
|
-
typeof customFlagProperty === 'boolean'
|
|
154
|
-
) {
|
|
153
|
+
event.CustomFlags[prop].forEach(customFlagProperty => {
|
|
154
|
+
if (isValidCustomFlagProperty(customFlagProperty)) {
|
|
155
155
|
valueArray.push(customFlagProperty.toString());
|
|
156
156
|
}
|
|
157
157
|
});
|
|
158
|
-
} else if (
|
|
159
|
-
// TODO: Can we use our utility functions here?
|
|
160
|
-
typeof event.CustomFlags[prop] === 'number' ||
|
|
161
|
-
typeof event.CustomFlags[prop] === 'string' ||
|
|
162
|
-
typeof event.CustomFlags[prop] === 'boolean'
|
|
163
|
-
) {
|
|
158
|
+
} else if (isValidCustomFlagProperty(event.CustomFlags[prop])) {
|
|
164
159
|
valueArray.push(event.CustomFlags[prop].toString());
|
|
165
160
|
}
|
|
166
161
|
|
package/src/sessionManager.ts
CHANGED
|
@@ -44,6 +44,7 @@ export default function SessionManager(
|
|
|
44
44
|
self.endSession();
|
|
45
45
|
self.startNewSession();
|
|
46
46
|
} else {
|
|
47
|
+
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
47
48
|
const persistence: IPersistenceMinified = mpInstance._Persistence.getPersistence();
|
|
48
49
|
if (persistence && !persistence.cu) {
|
|
49
50
|
mpInstance.Identity.identify(
|
package/src/store.ts
CHANGED
|
@@ -11,11 +11,9 @@ import { IKitConfigs } from './configAPIClient';
|
|
|
11
11
|
import Constants from './constants';
|
|
12
12
|
import {
|
|
13
13
|
DataPlanResult,
|
|
14
|
-
Kit,
|
|
15
14
|
KitBlockerOptions,
|
|
16
15
|
LogLevelType,
|
|
17
16
|
MParticleWebSDK,
|
|
18
|
-
MPForwarder,
|
|
19
17
|
SDKDataPlan,
|
|
20
18
|
SDKEvent,
|
|
21
19
|
SDKGeoLocation,
|
|
@@ -24,6 +22,7 @@ import {
|
|
|
24
22
|
} from './sdkRuntimeModels';
|
|
25
23
|
import { isNumber, isDataPlanSlug, Dictionary } from './utils';
|
|
26
24
|
import { SDKConsentState } from './consent';
|
|
25
|
+
import { Kit, MPForwarder } from './forwarders.interfaces';
|
|
27
26
|
|
|
28
27
|
// This represents the runtime configuration of the SDK AFTER
|
|
29
28
|
// initialization has been complete and all settings and
|
package/src/types.js
CHANGED
package/src/utils.ts
CHANGED
|
@@ -201,7 +201,10 @@ const converted = (s: string): string => {
|
|
|
201
201
|
|
|
202
202
|
const isString = (value: any): boolean => typeof value === 'string';
|
|
203
203
|
const isNumber = (value: any): boolean => typeof value === 'number';
|
|
204
|
+
const isBoolean = (value: any): boolean => typeof value === 'boolean';
|
|
204
205
|
const isFunction = (fn: any): boolean => typeof fn === 'function';
|
|
206
|
+
const isValidCustomFlagProperty = (value: any): boolean =>
|
|
207
|
+
isNumber(value) || isString(value) || isBoolean(value);
|
|
205
208
|
|
|
206
209
|
const toDataPlanSlug = (value: any): string =>
|
|
207
210
|
// Make sure we are only acting on strings or numbers
|
|
@@ -247,4 +250,5 @@ export {
|
|
|
247
250
|
isFunction,
|
|
248
251
|
isDataPlanSlug,
|
|
249
252
|
isEmpty,
|
|
253
|
+
isValidCustomFlagProperty,
|
|
250
254
|
};
|
package/src/validators.ts
CHANGED
|
@@ -1,5 +1,11 @@
|
|
|
1
1
|
import Types from './types';
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
isFunction,
|
|
4
|
+
isNumber,
|
|
5
|
+
isObject,
|
|
6
|
+
isStringOrNumber,
|
|
7
|
+
valueof,
|
|
8
|
+
} from './utils';
|
|
3
9
|
import Constants from './constants';
|
|
4
10
|
import { IdentityApiData } from '@mparticle/web-sdk';
|
|
5
11
|
|
|
@@ -10,6 +16,8 @@ type ValidationIdentitiesReturn = {
|
|
|
10
16
|
error?: valueof<typeof Constants.Messages.ValidationMessages>;
|
|
11
17
|
};
|
|
12
18
|
|
|
19
|
+
const { Modify } = Constants.IdentityMethods;
|
|
20
|
+
|
|
13
21
|
const Validators = {
|
|
14
22
|
// From ./utils
|
|
15
23
|
// Utility Functions for backwards compatability
|
|
@@ -43,7 +51,7 @@ const Validators = {
|
|
|
43
51
|
copyUserAttributes: 1,
|
|
44
52
|
};
|
|
45
53
|
if (identityApiData) {
|
|
46
|
-
if (method ===
|
|
54
|
+
if (method === Modify) {
|
|
47
55
|
if (
|
|
48
56
|
(isObject(identityApiData.userIdentities) &&
|
|
49
57
|
!Object.keys(identityApiData.userIdentities).length) ||
|