@mparticle/web-sdk 2.26.0 → 2.26.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mparticle.common.js +27 -16
- package/dist/mparticle.esm.js +27 -16
- package/dist/mparticle.js +146 -118
- package/package.json +1 -1
- package/src/helpers.js +0 -1
- package/src/mockBatchCreator.ts +1 -2
- package/src/mp-instance.js +110 -173
- package/src/nativeSdkHelpers.js +18 -0
- package/src/sdkRuntimeModels.ts +2 -1
- package/src/sessionManager.ts +1 -0
- package/src/store.ts +78 -17
package/dist/mparticle.js
CHANGED
|
@@ -608,7 +608,7 @@ var mParticle = (function () {
|
|
|
608
608
|
Environment: Environment
|
|
609
609
|
};
|
|
610
610
|
|
|
611
|
-
var version = "2.26.
|
|
611
|
+
var version = "2.26.1";
|
|
612
612
|
|
|
613
613
|
var Constants = {
|
|
614
614
|
sdkVersion: version,
|
|
@@ -2977,7 +2977,6 @@ var mParticle = (function () {
|
|
|
2977
2977
|
this.inArray = inArray;
|
|
2978
2978
|
this.isObject = isObject;
|
|
2979
2979
|
this.decoded = decoded;
|
|
2980
|
-
this.returnConvertedBoolean = returnConvertedBoolean;
|
|
2981
2980
|
this.parseStringOrNumber = parseStringOrNumber;
|
|
2982
2981
|
this.generateHash = generateHash;
|
|
2983
2982
|
this.generateUniqueId = generateUniqueId;
|
|
@@ -2991,6 +2990,21 @@ var mParticle = (function () {
|
|
|
2991
2990
|
var iosBridgeNameBase = 'mParticle';
|
|
2992
2991
|
function NativeSdkHelpers(mpInstance) {
|
|
2993
2992
|
var self = this;
|
|
2993
|
+
this.initializeSessionAttributes = function (apiKey) {
|
|
2994
|
+
var SetSessionAttribute = Constants.NativeSdkPaths.SetSessionAttribute;
|
|
2995
|
+
var env = JSON.stringify({
|
|
2996
|
+
key: '$src_env',
|
|
2997
|
+
value: 'webview'
|
|
2998
|
+
});
|
|
2999
|
+
var key = JSON.stringify({
|
|
3000
|
+
key: '$src_key',
|
|
3001
|
+
value: apiKey
|
|
3002
|
+
});
|
|
3003
|
+
self.sendToNative(SetSessionAttribute, env);
|
|
3004
|
+
if (apiKey) {
|
|
3005
|
+
self.sendToNative(SetSessionAttribute, key);
|
|
3006
|
+
}
|
|
3007
|
+
};
|
|
2994
3008
|
this.isBridgeV2Available = function (bridgeName) {
|
|
2995
3009
|
if (!bridgeName) {
|
|
2996
3010
|
return false;
|
|
@@ -3232,6 +3246,7 @@ var mParticle = (function () {
|
|
|
3232
3246
|
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
3233
3247
|
var persistence = mpInstance._Persistence.getPersistence();
|
|
3234
3248
|
if (persistence && !persistence.cu) {
|
|
3249
|
+
// https://go.mparticle.com/work/SQDSDKS-6323
|
|
3235
3250
|
mpInstance.Identity.identify(mpInstance._Store.SDKConfig.identifyRequest, mpInstance._Store.SDKConfig.identityCallback);
|
|
3236
3251
|
mpInstance._Store.identifyCalled = true;
|
|
3237
3252
|
mpInstance._Store.SDKConfig.identityCallback = null;
|
|
@@ -3776,6 +3791,10 @@ var mParticle = (function () {
|
|
|
3776
3791
|
// TODO: Merge this with SDKStoreApi in sdkRuntimeModels
|
|
3777
3792
|
function Store(config, mpInstance, apiKey) {
|
|
3778
3793
|
var _this = this;
|
|
3794
|
+
var _a = mpInstance._Helpers,
|
|
3795
|
+
createMainStorageName = _a.createMainStorageName,
|
|
3796
|
+
createProductStorageName = _a.createProductStorageName;
|
|
3797
|
+
var isWebviewEnabled = mpInstance._NativeSdkHelpers.isWebviewEnabled;
|
|
3779
3798
|
var defaultStore = {
|
|
3780
3799
|
isEnabled: true,
|
|
3781
3800
|
sessionAttributes: {},
|
|
@@ -3851,12 +3870,16 @@ var mParticle = (function () {
|
|
|
3851
3870
|
if (!config.hasOwnProperty('flags')) {
|
|
3852
3871
|
this.SDKConfig.flags = {};
|
|
3853
3872
|
}
|
|
3854
|
-
|
|
3873
|
+
// We process the initial config that is passed via the SDK init
|
|
3874
|
+
// and then we will reprocess the config within the processConfig
|
|
3875
|
+
// function when the config is updated from the server
|
|
3876
|
+
// https://go.mparticle.com/work/SQDSDKS-6317
|
|
3877
|
+
this.SDKConfig.flags = processFlags(config);
|
|
3855
3878
|
if (config.deviceId) {
|
|
3856
3879
|
this.deviceId = config.deviceId;
|
|
3857
3880
|
}
|
|
3858
3881
|
if (config.hasOwnProperty('isDevelopmentMode')) {
|
|
3859
|
-
this.SDKConfig.isDevelopmentMode =
|
|
3882
|
+
this.SDKConfig.isDevelopmentMode = returnConvertedBoolean(config.isDevelopmentMode);
|
|
3860
3883
|
} else {
|
|
3861
3884
|
this.SDKConfig.isDevelopmentMode = false;
|
|
3862
3885
|
}
|
|
@@ -3977,6 +4000,10 @@ var mParticle = (function () {
|
|
|
3977
4000
|
}
|
|
3978
4001
|
}
|
|
3979
4002
|
}
|
|
4003
|
+
this.hasInvalidIdentifyRequest = function () {
|
|
4004
|
+
var identifyRequest = _this.SDKConfig.identifyRequest;
|
|
4005
|
+
return isObject(identifyRequest) && isObject(identifyRequest.userIdentities) && isEmpty(identifyRequest.userIdentities) || !identifyRequest;
|
|
4006
|
+
};
|
|
3980
4007
|
this.getDeviceId = function () {
|
|
3981
4008
|
return _this.deviceId;
|
|
3982
4009
|
};
|
|
@@ -3985,12 +4012,6 @@ var mParticle = (function () {
|
|
|
3985
4012
|
_this.persistenceData.gs.das = deviceId;
|
|
3986
4013
|
mpInstance._Persistence.update();
|
|
3987
4014
|
};
|
|
3988
|
-
this.nullifySession = function () {
|
|
3989
|
-
_this.sessionId = null;
|
|
3990
|
-
_this.dateLastEventSent = null;
|
|
3991
|
-
_this.sessionAttributes = {};
|
|
3992
|
-
mpInstance._Persistence.update();
|
|
3993
|
-
};
|
|
3994
4015
|
this.getFirstSeenTime = function (mpid) {
|
|
3995
4016
|
if (!mpid) {
|
|
3996
4017
|
return null;
|
|
@@ -4046,8 +4067,34 @@ var mParticle = (function () {
|
|
|
4046
4067
|
}
|
|
4047
4068
|
}
|
|
4048
4069
|
};
|
|
4070
|
+
this.nullifySession = function () {
|
|
4071
|
+
_this.sessionId = null;
|
|
4072
|
+
_this.dateLastEventSent = null;
|
|
4073
|
+
_this.sessionAttributes = {};
|
|
4074
|
+
mpInstance._Persistence.update();
|
|
4075
|
+
};
|
|
4076
|
+
this.processConfig = function (config) {
|
|
4077
|
+
var workspaceToken = config.workspaceToken,
|
|
4078
|
+
requiredWebviewBridgeName = config.requiredWebviewBridgeName;
|
|
4079
|
+
// We should reprocess the flags in case they have changed when we request an updated config
|
|
4080
|
+
// such as if the SDK is being self-hosted and the flags are different on the server config
|
|
4081
|
+
// https://go.mparticle.com/work/SQDSDKS-6317
|
|
4082
|
+
_this.SDKConfig.flags = processFlags(config);
|
|
4083
|
+
if (workspaceToken) {
|
|
4084
|
+
_this.SDKConfig.workspaceToken = workspaceToken;
|
|
4085
|
+
} else {
|
|
4086
|
+
mpInstance.Logger.warning('You should have a workspaceToken on your config object for security purposes.');
|
|
4087
|
+
}
|
|
4088
|
+
// add a new function to apply items to the store that require config to be returned
|
|
4089
|
+
_this.storageName = createMainStorageName(workspaceToken);
|
|
4090
|
+
_this.prodStorageName = createProductStorageName(workspaceToken);
|
|
4091
|
+
_this.SDKConfig.requiredWebviewBridgeName = requiredWebviewBridgeName || workspaceToken;
|
|
4092
|
+
_this.webviewBridgeEnabled = isWebviewEnabled(_this.SDKConfig.requiredWebviewBridgeName, _this.SDKConfig.minWebviewBridgeVersion);
|
|
4093
|
+
_this.configurationLoaded = true;
|
|
4094
|
+
};
|
|
4049
4095
|
}
|
|
4050
|
-
|
|
4096
|
+
// https://go.mparticle.com/work/SQDSDKS-6317
|
|
4097
|
+
function processFlags(config) {
|
|
4051
4098
|
var flags = {};
|
|
4052
4099
|
var _a = Constants.FeatureFlags,
|
|
4053
4100
|
ReportBatching = _a.ReportBatching,
|
|
@@ -4059,6 +4106,7 @@ var mParticle = (function () {
|
|
|
4059
4106
|
if (!config.flags) {
|
|
4060
4107
|
return {};
|
|
4061
4108
|
}
|
|
4109
|
+
// https://go.mparticle.com/work/SQDSDKS-6317
|
|
4062
4110
|
// Passed in config flags take priority over defaults
|
|
4063
4111
|
flags[ReportBatching] = config.flags[ReportBatching] || false;
|
|
4064
4112
|
// The server returns stringified numbers, sowe need to parse
|
|
@@ -6403,7 +6451,7 @@ var mParticle = (function () {
|
|
|
6403
6451
|
|
|
6404
6452
|
var Messages$2 = Constants.Messages,
|
|
6405
6453
|
HTTPCodes$2 = Constants.HTTPCodes,
|
|
6406
|
-
FeatureFlags = Constants.FeatureFlags;
|
|
6454
|
+
FeatureFlags$1 = Constants.FeatureFlags;
|
|
6407
6455
|
var ErrorMessages = Messages$2.ErrorMessages;
|
|
6408
6456
|
var _Constants$IdentityMe = Constants.IdentityMethods,
|
|
6409
6457
|
Identify = _Constants$IdentityMe.Identify,
|
|
@@ -7177,7 +7225,7 @@ var mParticle = (function () {
|
|
|
7177
7225
|
*/
|
|
7178
7226
|
getUserAudiences: function getUserAudiences(callback) {
|
|
7179
7227
|
// user audience API is feature flagged
|
|
7180
|
-
if (!mpInstance._Helpers.getFeatureFlag(FeatureFlags.AudienceAPI)) {
|
|
7228
|
+
if (!mpInstance._Helpers.getFeatureFlag(FeatureFlags$1.AudienceAPI)) {
|
|
7181
7229
|
mpInstance.Logger.error(ErrorMessages.AudienceAPINotEnabled);
|
|
7182
7230
|
return;
|
|
7183
7231
|
}
|
|
@@ -8360,7 +8408,10 @@ var mParticle = (function () {
|
|
|
8360
8408
|
}
|
|
8361
8409
|
|
|
8362
8410
|
var Messages = Constants.Messages,
|
|
8363
|
-
HTTPCodes = Constants.HTTPCodes
|
|
8411
|
+
HTTPCodes = Constants.HTTPCodes,
|
|
8412
|
+
FeatureFlags = Constants.FeatureFlags;
|
|
8413
|
+
var ReportBatching = FeatureFlags.ReportBatching;
|
|
8414
|
+
var StartingInitialization = Messages.InformationMessages.StartingInitialization;
|
|
8364
8415
|
|
|
8365
8416
|
/**
|
|
8366
8417
|
* <p>All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced <a href="https://docs.mparticle.com/developers/sdk/web/multiple-instances/">multiple instances</a>. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.</p>
|
|
@@ -8585,7 +8636,7 @@ var mParticle = (function () {
|
|
|
8585
8636
|
* @param {Function} [callback] A callback function that is called when the location is either allowed or rejected by the user. A position object of schema {coords: {latitude: number, longitude: number}} is passed to the callback
|
|
8586
8637
|
*/
|
|
8587
8638
|
this.startTrackingLocation = function (callback) {
|
|
8588
|
-
if (!
|
|
8639
|
+
if (!isFunction(callback)) {
|
|
8589
8640
|
self.Logger.warning('Warning: Location tracking is triggered, but not including a callback into the `startTrackingLocation` may result in events logged too quickly and not being associated with a location.');
|
|
8590
8641
|
}
|
|
8591
8642
|
self._SessionManager.resetSessionTimer();
|
|
@@ -9303,118 +9354,48 @@ var mParticle = (function () {
|
|
|
9303
9354
|
var kitBlocker = createKitBlocker(config, mpInstance);
|
|
9304
9355
|
mpInstance._APIClient = new APIClient(mpInstance, kitBlocker);
|
|
9305
9356
|
mpInstance._Forwarders = new Forwarders(mpInstance, kitBlocker);
|
|
9306
|
-
|
|
9307
|
-
|
|
9308
|
-
mpInstance._Store.SDKConfig.flags[Constants.FeatureFlags.EventBatchingIntervalMillis] = config.flags[Constants.FeatureFlags.EventBatchingIntervalMillis];
|
|
9309
|
-
}
|
|
9310
|
-
}
|
|
9311
|
-
|
|
9312
|
-
// add a new function to apply items to the store that require config to be returned
|
|
9313
|
-
mpInstance._Store.storageName = mpInstance._Helpers.createMainStorageName(config.workspaceToken);
|
|
9314
|
-
mpInstance._Store.prodStorageName = mpInstance._Helpers.createProductStorageName(config.workspaceToken);
|
|
9315
|
-
|
|
9316
|
-
// idCache is instantiated here as opposed to when _Identity is instantiated
|
|
9317
|
-
// because it depends on _Store.storageName, which is not sent until above
|
|
9318
|
-
// because it is a setting on config which returns asyncronously
|
|
9319
|
-
// in self hosted mode
|
|
9320
|
-
mpInstance._Identity.idCache = new LocalStorageVault("".concat(mpInstance._Store.storageName, "-id-cache"), {
|
|
9321
|
-
logger: mpInstance.Logger
|
|
9322
|
-
});
|
|
9357
|
+
mpInstance._Store.processConfig(config);
|
|
9358
|
+
mpInstance._Identity.idCache = createIdentityCache(mpInstance);
|
|
9323
9359
|
removeExpiredIdentityCacheDates(mpInstance._Identity.idCache);
|
|
9324
|
-
|
|
9325
|
-
|
|
9360
|
+
|
|
9361
|
+
// Web View Bridge is used for cases where the Web SDK is loaded within an iOS or Android device's
|
|
9362
|
+
// Web View. The Web SDK simply acts as a passthrough to the mParticle Native SDK. It is not
|
|
9363
|
+
// responsible for sending events directly to mParticle's servers. The Web SDK will not initialize
|
|
9364
|
+
// persistence or Identity directly.
|
|
9365
|
+
if (mpInstance._Store.webviewBridgeEnabled) {
|
|
9366
|
+
mpInstance._NativeSdkHelpers.initializeSessionAttributes(apiKey);
|
|
9326
9367
|
} else {
|
|
9327
|
-
|
|
9328
|
-
}
|
|
9329
|
-
if (config.hasOwnProperty('requiredWebviewBridgeName')) {
|
|
9330
|
-
mpInstance._Store.SDKConfig.requiredWebviewBridgeName = config.requiredWebviewBridgeName;
|
|
9331
|
-
} else if (config.hasOwnProperty('workspaceToken')) {
|
|
9332
|
-
mpInstance._Store.SDKConfig.requiredWebviewBridgeName = config.workspaceToken;
|
|
9333
|
-
}
|
|
9334
|
-
mpInstance._Store.webviewBridgeEnabled = mpInstance._NativeSdkHelpers.isWebviewEnabled(mpInstance._Store.SDKConfig.requiredWebviewBridgeName, mpInstance._Store.SDKConfig.minWebviewBridgeVersion);
|
|
9335
|
-
mpInstance._Store.configurationLoaded = true;
|
|
9368
|
+
// Main SDK initialization flow
|
|
9336
9369
|
|
|
9337
|
-
// https://go.mparticle.com/work/SQDSDKS-6044
|
|
9338
|
-
if (!mpInstance._Store.webviewBridgeEnabled) {
|
|
9339
9370
|
// Load any settings/identities/attributes from cookie or localStorage
|
|
9340
9371
|
mpInstance._Persistence.initializeStorage();
|
|
9341
|
-
}
|
|
9342
|
-
if (mpInstance._Store.webviewBridgeEnabled) {
|
|
9343
|
-
mpInstance._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.SetSessionAttribute, JSON.stringify({
|
|
9344
|
-
key: '$src_env',
|
|
9345
|
-
value: 'webview'
|
|
9346
|
-
}));
|
|
9347
|
-
if (apiKey) {
|
|
9348
|
-
mpInstance._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.SetSessionAttribute, JSON.stringify({
|
|
9349
|
-
key: '$src_key',
|
|
9350
|
-
value: apiKey
|
|
9351
|
-
}));
|
|
9352
|
-
}
|
|
9353
|
-
} else {
|
|
9354
|
-
var currentUser;
|
|
9355
9372
|
|
|
9356
|
-
//
|
|
9357
|
-
|
|
9358
|
-
|
|
9359
|
-
|
|
9360
|
-
|
|
9361
|
-
|
|
9362
|
-
|
|
9363
|
-
|
|
9364
|
-
modifiedUIforIdentityRequest[identityKey] = identities[identityKey];
|
|
9365
|
-
}
|
|
9366
|
-
}
|
|
9367
|
-
}
|
|
9368
|
-
mpInstance._Store.SDKConfig.identifyRequest = {
|
|
9369
|
-
userIdentities: modifiedUIforIdentityRequest
|
|
9370
|
-
};
|
|
9371
|
-
}
|
|
9372
|
-
currentUser = mpInstance.Identity.getCurrentUser();
|
|
9373
|
-
if (mpInstance._Helpers.getFeatureFlag(Constants.FeatureFlags.ReportBatching)) {
|
|
9373
|
+
// Set up user identitiy variables for later use
|
|
9374
|
+
var currentUser = mpInstance.Identity.getCurrentUser();
|
|
9375
|
+
var currentUserMPID = currentUser ? currentUser.getMPID() : null;
|
|
9376
|
+
var currentUserIdentities = currentUser ? currentUser.getUserIdentities().userIdentities : {};
|
|
9377
|
+
mpInstance._Store.SDKConfig.identifyRequest = mpInstance._Store.hasInvalidIdentifyRequest() ? {
|
|
9378
|
+
userIdentities: currentUserIdentities
|
|
9379
|
+
} : mpInstance._Store.SDKConfig.identifyRequest;
|
|
9380
|
+
if (mpInstance._Helpers.getFeatureFlag(ReportBatching)) {
|
|
9374
9381
|
mpInstance._ForwardingStatsUploader.startForwardingStatsTimer();
|
|
9375
9382
|
}
|
|
9376
9383
|
mpInstance._Forwarders.processForwarders(config, mpInstance._APIClient.prepareForwardingStats);
|
|
9377
9384
|
mpInstance._Forwarders.processPixelConfigs(config);
|
|
9385
|
+
|
|
9386
|
+
// Checks if session is created, resumed, or needs to be ended
|
|
9387
|
+
// Logs a session start or session end event accordingly
|
|
9378
9388
|
mpInstance._SessionManager.initialize();
|
|
9379
9389
|
mpInstance._Events.logAST();
|
|
9380
|
-
|
|
9381
|
-
// Call mParticle._Store.SDKConfig.identityCallback when identify was not called due to a reload or a sessionId already existing
|
|
9382
|
-
// Any identity callback should always be ran regardless if an identity call is made
|
|
9383
|
-
if (!mpInstance._Store.identifyCalled && mpInstance._Store.SDKConfig.identityCallback && currentUser && currentUser.getMPID()) {
|
|
9384
|
-
mpInstance._Store.SDKConfig.identityCallback({
|
|
9385
|
-
httpCode: HTTPCodes.activeSession,
|
|
9386
|
-
getUser: function getUser() {
|
|
9387
|
-
return mpInstance._Identity.mParticleUser(currentUser.getMPID());
|
|
9388
|
-
},
|
|
9389
|
-
getPreviousUser: function getPreviousUser() {
|
|
9390
|
-
var users = mpInstance.Identity.getUsers();
|
|
9391
|
-
var mostRecentUser = users.shift();
|
|
9392
|
-
if (mostRecentUser && currentUser && mostRecentUser.getMPID() === currentUser.getMPID()) {
|
|
9393
|
-
mostRecentUser = users.shift();
|
|
9394
|
-
}
|
|
9395
|
-
return mostRecentUser || null;
|
|
9396
|
-
},
|
|
9397
|
-
body: {
|
|
9398
|
-
mpid: currentUser.getMPID(),
|
|
9399
|
-
is_logged_in: mpInstance._Store.isLoggedIn,
|
|
9400
|
-
matched_identities: currentUser.getUserIdentities().userIdentities,
|
|
9401
|
-
context: null,
|
|
9402
|
-
is_ephemeral: false
|
|
9403
|
-
}
|
|
9404
|
-
});
|
|
9405
|
-
}
|
|
9390
|
+
processIdentityCallback(mpInstance, currentUser, currentUserMPID, currentUserIdentities);
|
|
9406
9391
|
}
|
|
9407
9392
|
mpInstance._Store.isInitialized = true;
|
|
9393
|
+
|
|
9408
9394
|
// Call any functions that are waiting for the library to be initialized
|
|
9409
|
-
|
|
9410
|
-
mpInstance._preInit.readyQueue
|
|
9411
|
-
|
|
9412
|
-
|
|
9413
|
-
} else if (Array.isArray(readyQueueItem)) {
|
|
9414
|
-
processPreloadedItem(readyQueueItem, mpInstance);
|
|
9415
|
-
}
|
|
9416
|
-
});
|
|
9417
|
-
mpInstance._preInit.readyQueue = [];
|
|
9395
|
+
try {
|
|
9396
|
+
mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue);
|
|
9397
|
+
} catch (error) {
|
|
9398
|
+
mpInstance.Logger.error(error);
|
|
9418
9399
|
}
|
|
9419
9400
|
|
|
9420
9401
|
// https://go.mparticle.com/work/SQDSDKS-6040
|
|
@@ -9479,11 +9460,16 @@ var mParticle = (function () {
|
|
|
9479
9460
|
}
|
|
9480
9461
|
return kitBlocker;
|
|
9481
9462
|
}
|
|
9463
|
+
function createIdentityCache(mpInstance) {
|
|
9464
|
+
return new LocalStorageVault("".concat(mpInstance._Store.storageName, "-id-cache"), {
|
|
9465
|
+
logger: mpInstance.Logger
|
|
9466
|
+
});
|
|
9467
|
+
}
|
|
9482
9468
|
function runPreConfigFetchInitialization(mpInstance, apiKey, config) {
|
|
9483
9469
|
mpInstance.Logger = new Logger(config);
|
|
9484
9470
|
mpInstance._Store = new Store(config, mpInstance, apiKey);
|
|
9485
9471
|
window.mParticle.Store = mpInstance._Store;
|
|
9486
|
-
mpInstance.Logger.verbose(
|
|
9472
|
+
mpInstance.Logger.verbose(StartingInitialization);
|
|
9487
9473
|
|
|
9488
9474
|
// Check to see if localStorage is available before main configuration runs
|
|
9489
9475
|
// since we will need this for the current implementation of user persistence
|
|
@@ -9495,9 +9481,40 @@ var mParticle = (function () {
|
|
|
9495
9481
|
mpInstance._Store.isLocalStorageAvailable = false;
|
|
9496
9482
|
}
|
|
9497
9483
|
}
|
|
9498
|
-
function
|
|
9499
|
-
|
|
9500
|
-
|
|
9484
|
+
function processIdentityCallback(mpInstance, currentUser, currentUserMPID, currentUserIdentities) {
|
|
9485
|
+
// https://go.mparticle.com/work/SQDSDKS-6323
|
|
9486
|
+
// Call mParticle._Store.SDKConfig.identityCallback when identify was not called
|
|
9487
|
+
// due to a reload or a sessionId already existing
|
|
9488
|
+
// Any identity callback should always be ran regardless if an identity call
|
|
9489
|
+
// is made
|
|
9490
|
+
if (!mpInstance._Store.identifyCalled && mpInstance._Store.SDKConfig.identityCallback && currentUser && currentUserMPID) {
|
|
9491
|
+
mpInstance._Store.SDKConfig.identityCallback({
|
|
9492
|
+
httpCode: HTTPCodes.activeSession,
|
|
9493
|
+
getUser: function getUser() {
|
|
9494
|
+
return mpInstance._Identity.mParticleUser(currentUserMPID);
|
|
9495
|
+
},
|
|
9496
|
+
getPreviousUser: function getPreviousUser() {
|
|
9497
|
+
var users = mpInstance.Identity.getUsers();
|
|
9498
|
+
var mostRecentUser = users.shift();
|
|
9499
|
+
var mostRecentUserMPID = mostRecentUser.getMPID();
|
|
9500
|
+
if (mostRecentUser && mostRecentUserMPID === currentUserMPID) {
|
|
9501
|
+
mostRecentUser = users.shift();
|
|
9502
|
+
}
|
|
9503
|
+
return mostRecentUser || null;
|
|
9504
|
+
},
|
|
9505
|
+
body: {
|
|
9506
|
+
mpid: currentUserMPID,
|
|
9507
|
+
is_logged_in: mpInstance._Store.isLoggedIn,
|
|
9508
|
+
matched_identities: currentUserIdentities,
|
|
9509
|
+
context: null,
|
|
9510
|
+
is_ephemeral: false
|
|
9511
|
+
}
|
|
9512
|
+
});
|
|
9513
|
+
}
|
|
9514
|
+
}
|
|
9515
|
+
function processPreloadedItem(readyQueueItem) {
|
|
9516
|
+
var args = readyQueueItem;
|
|
9517
|
+
var method = args.splice(0, 1)[0];
|
|
9501
9518
|
// if the first argument is a method on the base mParticle object, run it
|
|
9502
9519
|
if (mParticle[args[0]]) {
|
|
9503
9520
|
mParticle[method].apply(this, args);
|
|
@@ -9512,10 +9529,22 @@ var mParticle = (function () {
|
|
|
9512
9529
|
}
|
|
9513
9530
|
computedMPFunction.apply(this, args);
|
|
9514
9531
|
} catch (e) {
|
|
9515
|
-
|
|
9532
|
+
throw new Error('Unable to compute proper mParticle function ' + e);
|
|
9516
9533
|
}
|
|
9517
9534
|
}
|
|
9518
9535
|
}
|
|
9536
|
+
function processReadyQueue(readyQueue) {
|
|
9537
|
+
if (!isEmpty(readyQueue)) {
|
|
9538
|
+
readyQueue.forEach(function (readyQueueItem) {
|
|
9539
|
+
if (isFunction(readyQueueItem)) {
|
|
9540
|
+
readyQueueItem();
|
|
9541
|
+
} else if (Array.isArray(readyQueueItem)) {
|
|
9542
|
+
processPreloadedItem(readyQueueItem);
|
|
9543
|
+
}
|
|
9544
|
+
});
|
|
9545
|
+
return [];
|
|
9546
|
+
}
|
|
9547
|
+
}
|
|
9519
9548
|
function queueIfNotInitialized(func, self) {
|
|
9520
9549
|
if (!self.isInitialized()) {
|
|
9521
9550
|
self.ready(function () {
|
|
@@ -9547,7 +9576,6 @@ var mParticle = (function () {
|
|
|
9547
9576
|
createServiceUrl: mockFunction,
|
|
9548
9577
|
parseNumber: mockFunction,
|
|
9549
9578
|
isObject: mockFunction,
|
|
9550
|
-
returnConvertedBoolean: mockFunction,
|
|
9551
9579
|
Validators: null
|
|
9552
9580
|
},
|
|
9553
9581
|
_resetForTests: mockFunction,
|
package/package.json
CHANGED
package/src/helpers.js
CHANGED
|
@@ -441,7 +441,6 @@ export default function Helpers(mpInstance) {
|
|
|
441
441
|
this.inArray = utils.inArray;
|
|
442
442
|
this.isObject = utils.isObject;
|
|
443
443
|
this.decoded = utils.decoded;
|
|
444
|
-
this.returnConvertedBoolean = utils.returnConvertedBoolean;
|
|
445
444
|
this.parseStringOrNumber = utils.parseStringOrNumber;
|
|
446
445
|
this.generateHash = utils.generateHash;
|
|
447
446
|
this.generateUniqueId = utils.generateUniqueId;
|
package/src/mockBatchCreator.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { SDKEvent, BaseEvent, MParticleWebSDK } from './sdkRuntimeModels';
|
|
|
5
5
|
import { convertEvents } from './sdkToEventsApiConverter';
|
|
6
6
|
import * as EventsApi from '@mparticle/event-models';
|
|
7
7
|
import { Batch } from '@mparticle/event-models';
|
|
8
|
-
import { IMPSideloadedKit} from './sideloadedKit';
|
|
8
|
+
import { IMPSideloadedKit } from './sideloadedKit';
|
|
9
9
|
|
|
10
10
|
const mockFunction = function() {
|
|
11
11
|
return null;
|
|
@@ -27,7 +27,6 @@ export default class _BatchValidator {
|
|
|
27
27
|
createServiceUrl: mockFunction,
|
|
28
28
|
parseNumber: mockFunction,
|
|
29
29
|
isObject: mockFunction,
|
|
30
|
-
returnConvertedBoolean: mockFunction,
|
|
31
30
|
Validators: null,
|
|
32
31
|
},
|
|
33
32
|
_resetForTests: mockFunction,
|