@mparticle/web-sdk 2.32.3 → 2.32.5
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 +15 -14
- package/dist/mparticle.esm.js +15 -14
- package/dist/mparticle.js +75 -80
- package/package.json +1 -1
- package/src/apiClient.ts +4 -3
- package/src/batchUploader.ts +9 -8
- package/src/configAPIClient.ts +3 -3
- package/src/consent.ts +2 -8
- package/src/cookieSyncManager.ts +2 -2
- package/src/events.interfaces.ts +3 -3
- package/src/identity-user-interfaces.ts +3 -3
- package/src/identityApiClient.ts +2 -2
- package/src/integrationCapture.ts +12 -10
- package/src/kitBlocking.ts +3 -2
- package/src/mockBatchCreator.ts +5 -6
- package/src/{mp-instance.js → mp-instance.ts} +107 -58
- package/src/{mparticle-instance-manager.js → mparticle-instance-manager.ts} +29 -16
- package/src/nativeSdkHelpers.interfaces.ts +1 -1
- package/src/pre-init-utils.ts +11 -0
- package/src/sdkRuntimeModels.ts +66 -41
- package/src/sdkToEventsApiConverter.ts +2 -2
- package/src/serverModel.ts +4 -4
- package/src/sessionManager.ts +2 -2
- package/src/store.ts +7 -6
- package/src/uploaders.ts +5 -3
- package/src/vault.ts +8 -3
package/dist/mparticle.js
CHANGED
|
@@ -203,7 +203,7 @@ var mParticle = (function () {
|
|
|
203
203
|
Base64: Base64$1
|
|
204
204
|
};
|
|
205
205
|
|
|
206
|
-
var version = "2.32.
|
|
206
|
+
var version = "2.32.5";
|
|
207
207
|
|
|
208
208
|
var Constants = {
|
|
209
209
|
sdkVersion: version,
|
|
@@ -2046,8 +2046,13 @@ var mParticle = (function () {
|
|
|
2046
2046
|
* @param item {StorableItem}
|
|
2047
2047
|
*/
|
|
2048
2048
|
BaseVault.prototype.store = function (item) {
|
|
2049
|
+
var stringifiedItem;
|
|
2049
2050
|
this.contents = item;
|
|
2050
|
-
|
|
2051
|
+
if (isNumber(item) || !isEmpty(item)) {
|
|
2052
|
+
stringifiedItem = JSON.stringify(item);
|
|
2053
|
+
} else {
|
|
2054
|
+
stringifiedItem = '';
|
|
2055
|
+
}
|
|
2051
2056
|
try {
|
|
2052
2057
|
this.storageObject.setItem(this._storageKey, stringifiedItem);
|
|
2053
2058
|
this.logger.verbose("Saving item to Storage: ".concat(stringifiedItem));
|
|
@@ -2174,11 +2179,11 @@ var mParticle = (function () {
|
|
|
2174
2179
|
reject(xhr);
|
|
2175
2180
|
};
|
|
2176
2181
|
xhr.open(method, url);
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
}
|
|
2182
|
+
for (var key in headers) {
|
|
2183
|
+
if (headers.hasOwnProperty(key)) {
|
|
2184
|
+
xhr.setRequestHeader(key, headers[key]);
|
|
2185
|
+
}
|
|
2186
|
+
}
|
|
2182
2187
|
xhr.send(data);
|
|
2183
2188
|
})];
|
|
2184
2189
|
});
|
|
@@ -2205,7 +2210,7 @@ var mParticle = (function () {
|
|
|
2205
2210
|
var BatchUploader = /** @class */function () {
|
|
2206
2211
|
/**
|
|
2207
2212
|
* Creates an instance of a BatchUploader
|
|
2208
|
-
* @param {
|
|
2213
|
+
* @param {IMParticleWebSDKInstance} mpInstance - the mParticle SDK instance
|
|
2209
2214
|
* @param {number} uploadInterval - the desired upload interval in milliseconds
|
|
2210
2215
|
*/
|
|
2211
2216
|
function BatchUploader(mpInstance, uploadInterval) {
|
|
@@ -2388,6 +2393,12 @@ var mParticle = (function () {
|
|
|
2388
2393
|
* @param useBeacon whether to use the beacon API - used when the page is being unloaded
|
|
2389
2394
|
*/
|
|
2390
2395
|
BatchUploader.prototype.prepareAndUpload = function (triggerFuture, useBeacon) {
|
|
2396
|
+
if (triggerFuture === void 0) {
|
|
2397
|
+
triggerFuture = false;
|
|
2398
|
+
}
|
|
2399
|
+
if (useBeacon === void 0) {
|
|
2400
|
+
useBeacon = false;
|
|
2401
|
+
}
|
|
2391
2402
|
return __awaiter(this, void 0, void 0, function () {
|
|
2392
2403
|
var currentUser, currentEvents, newBatches, batchesToUpload, batchesThatDidNotUpload;
|
|
2393
2404
|
var _a, _b, _c;
|
|
@@ -9293,13 +9304,13 @@ var mParticle = (function () {
|
|
|
9293
9304
|
if (!clickIds) {
|
|
9294
9305
|
return mappedClickIds;
|
|
9295
9306
|
}
|
|
9296
|
-
for (var
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9307
|
+
for (var key in clickIds) {
|
|
9308
|
+
if (clickIds.hasOwnProperty(key)) {
|
|
9309
|
+
var value = clickIds[key];
|
|
9310
|
+
var mappedKey = (_a = mappingList[key]) === null || _a === void 0 ? void 0 : _a.mappedKey;
|
|
9311
|
+
if (!isEmpty(mappedKey)) {
|
|
9312
|
+
mappedClickIds[mappedKey] = value;
|
|
9313
|
+
}
|
|
9303
9314
|
}
|
|
9304
9315
|
}
|
|
9305
9316
|
return mappedClickIds;
|
|
@@ -9307,15 +9318,11 @@ var mParticle = (function () {
|
|
|
9307
9318
|
IntegrationCapture.prototype.applyProcessors = function (clickIds, url, timestamp) {
|
|
9308
9319
|
var _a;
|
|
9309
9320
|
var processedClickIds = {};
|
|
9310
|
-
for (var
|
|
9311
|
-
|
|
9312
|
-
|
|
9313
|
-
|
|
9314
|
-
|
|
9315
|
-
if (processor) {
|
|
9316
|
-
processedClickIds[key] = processor(value, url, timestamp);
|
|
9317
|
-
} else {
|
|
9318
|
-
processedClickIds[key] = value;
|
|
9321
|
+
for (var key in clickIds) {
|
|
9322
|
+
if (clickIds.hasOwnProperty(key)) {
|
|
9323
|
+
var value = clickIds[key];
|
|
9324
|
+
var processor = (_a = integrationMapping[key]) === null || _a === void 0 ? void 0 : _a.processor;
|
|
9325
|
+
processedClickIds[key] = processor ? processor(value, url, timestamp) : value;
|
|
9319
9326
|
}
|
|
9320
9327
|
}
|
|
9321
9328
|
return processedClickIds;
|
|
@@ -9338,7 +9345,6 @@ var mParticle = (function () {
|
|
|
9338
9345
|
var ReportBatching = FeatureFlags.ReportBatching,
|
|
9339
9346
|
CaptureIntegrationSpecificIds = FeatureFlags.CaptureIntegrationSpecificIds;
|
|
9340
9347
|
var StartingInitialization = Messages.InformationMessages.StartingInitialization;
|
|
9341
|
-
|
|
9342
9348
|
/**
|
|
9343
9349
|
* <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>
|
|
9344
9350
|
* <p>In current versions of mParticle, if your site has one instance, that instance name is 'default_instance'. Any methods called on mParticle on a site with one instance will be mapped to the `default_instance`.</p>
|
|
@@ -9351,7 +9357,6 @@ var mParticle = (function () {
|
|
|
9351
9357
|
*
|
|
9352
9358
|
* @class mParticle & mParticleInstance
|
|
9353
9359
|
*/
|
|
9354
|
-
|
|
9355
9360
|
function mParticleInstance(instanceName) {
|
|
9356
9361
|
var self = this;
|
|
9357
9362
|
// These classes are for internal use only. Not documented for public consumption
|
|
@@ -9373,17 +9378,15 @@ var mParticle = (function () {
|
|
|
9373
9378
|
forwarderConstructors: []
|
|
9374
9379
|
};
|
|
9375
9380
|
this._IntegrationCapture = new IntegrationCapture();
|
|
9376
|
-
|
|
9377
9381
|
// required for forwarders once they reference the mparticle instance
|
|
9378
|
-
this.IdentityType =
|
|
9379
|
-
this.EventType =
|
|
9380
|
-
this.CommerceEventType =
|
|
9381
|
-
this.PromotionType =
|
|
9382
|
-
this.ProductActionType =
|
|
9382
|
+
this.IdentityType = IdentityType;
|
|
9383
|
+
this.EventType = EventType;
|
|
9384
|
+
this.CommerceEventType = CommerceEventType;
|
|
9385
|
+
this.PromotionType = PromotionActionType;
|
|
9386
|
+
this.ProductActionType = ProductActionType;
|
|
9383
9387
|
this._Identity = new Identity(this);
|
|
9384
9388
|
this.Identity = this._Identity.IdentityAPI;
|
|
9385
9389
|
this.generateHash = this._Helpers.generateHash;
|
|
9386
|
-
|
|
9387
9390
|
// https://go.mparticle.com/work/SQDSDKS-6289
|
|
9388
9391
|
// TODO: Replace this with Store once Store is moved earlier in the init process
|
|
9389
9392
|
this.getDeviceId = this._Persistence.getDeviceId;
|
|
@@ -9400,7 +9403,6 @@ var mParticle = (function () {
|
|
|
9400
9403
|
console.warn('You did not pass a config object to init(). mParticle will not initialize properly');
|
|
9401
9404
|
}
|
|
9402
9405
|
runPreConfigFetchInitialization(this, apiKey, config);
|
|
9403
|
-
|
|
9404
9406
|
// config code - Fetch config when requestConfig = true, otherwise, proceed with SDKInitialization
|
|
9405
9407
|
// Since fetching the configuration is asynchronous, we must pass completeSDKInitialization
|
|
9406
9408
|
// to it for it to be run after fetched
|
|
@@ -9428,7 +9430,6 @@ var mParticle = (function () {
|
|
|
9428
9430
|
this.setLogLevel = function (newLogLevel) {
|
|
9429
9431
|
self.Logger.setLogLevel(newLogLevel);
|
|
9430
9432
|
};
|
|
9431
|
-
|
|
9432
9433
|
/**
|
|
9433
9434
|
* Resets the SDK to an uninitialized state and removes cookies/localStorage. You MUST call mParticle.init(apiKey, window.mParticle.config)
|
|
9434
9435
|
* before any other mParticle methods or the SDK will not function as intended.
|
|
@@ -9525,7 +9526,6 @@ var mParticle = (function () {
|
|
|
9525
9526
|
this.isInitialized = function () {
|
|
9526
9527
|
return self._Store ? self._Store.isInitialized : false;
|
|
9527
9528
|
};
|
|
9528
|
-
|
|
9529
9529
|
/**
|
|
9530
9530
|
* Gets the app name
|
|
9531
9531
|
* @method getAppName
|
|
@@ -9610,7 +9610,6 @@ var mParticle = (function () {
|
|
|
9610
9610
|
// Sends true as an over ride vs when endSession is called from the setInterval
|
|
9611
9611
|
self._SessionManager.endSession(true);
|
|
9612
9612
|
};
|
|
9613
|
-
|
|
9614
9613
|
/**
|
|
9615
9614
|
* Logs a Base Event to mParticle's servers
|
|
9616
9615
|
* @param {Object} event Base Event Object
|
|
@@ -9627,7 +9626,7 @@ var mParticle = (function () {
|
|
|
9627
9626
|
return;
|
|
9628
9627
|
}
|
|
9629
9628
|
if (!event.eventType) {
|
|
9630
|
-
event.eventType =
|
|
9629
|
+
event.eventType = EventType.Unknown;
|
|
9631
9630
|
}
|
|
9632
9631
|
if (!self._Helpers.canLog()) {
|
|
9633
9632
|
self.Logger.error(Messages.ErrorMessages.LoggingDisabled);
|
|
@@ -9655,10 +9654,10 @@ var mParticle = (function () {
|
|
|
9655
9654
|
return;
|
|
9656
9655
|
}
|
|
9657
9656
|
if (!eventType) {
|
|
9658
|
-
eventType =
|
|
9657
|
+
eventType = EventType.Unknown;
|
|
9659
9658
|
}
|
|
9660
9659
|
if (!self._Helpers.isEventType(eventType)) {
|
|
9661
|
-
self.Logger.error('Invalid event type: ' + eventType + ', must be one of: \n' + JSON.stringify(
|
|
9660
|
+
self.Logger.error('Invalid event type: ' + eventType + ', must be one of: \n' + JSON.stringify(EventType));
|
|
9662
9661
|
return;
|
|
9663
9662
|
}
|
|
9664
9663
|
if (!self._Helpers.canLog()) {
|
|
@@ -9666,7 +9665,7 @@ var mParticle = (function () {
|
|
|
9666
9665
|
return;
|
|
9667
9666
|
}
|
|
9668
9667
|
self._Events.logEvent({
|
|
9669
|
-
messageType:
|
|
9668
|
+
messageType: MessageType$1.PageEvent,
|
|
9670
9669
|
name: eventName,
|
|
9671
9670
|
data: eventInfo,
|
|
9672
9671
|
eventType: eventType,
|
|
@@ -9706,10 +9705,10 @@ var mParticle = (function () {
|
|
|
9706
9705
|
}
|
|
9707
9706
|
}
|
|
9708
9707
|
self._Events.logEvent({
|
|
9709
|
-
messageType:
|
|
9708
|
+
messageType: MessageType$1.CrashReport,
|
|
9710
9709
|
name: error.name ? error.name : 'Error',
|
|
9711
|
-
|
|
9712
|
-
|
|
9710
|
+
eventType: EventType.Other,
|
|
9711
|
+
data: data
|
|
9713
9712
|
});
|
|
9714
9713
|
};
|
|
9715
9714
|
/**
|
|
@@ -9767,10 +9766,10 @@ var mParticle = (function () {
|
|
|
9767
9766
|
}
|
|
9768
9767
|
}
|
|
9769
9768
|
self._Events.logEvent({
|
|
9770
|
-
messageType:
|
|
9769
|
+
messageType: MessageType$1.PageView,
|
|
9771
9770
|
name: eventName,
|
|
9772
9771
|
data: attrs,
|
|
9773
|
-
eventType:
|
|
9772
|
+
eventType: EventType.Unknown,
|
|
9774
9773
|
customFlags: customFlags
|
|
9775
9774
|
}, eventOptions);
|
|
9776
9775
|
};
|
|
@@ -9779,12 +9778,12 @@ var mParticle = (function () {
|
|
|
9779
9778
|
* @method upload
|
|
9780
9779
|
*/
|
|
9781
9780
|
this.upload = function () {
|
|
9781
|
+
var _a, _b;
|
|
9782
9782
|
if (self._Helpers.canLog()) {
|
|
9783
9783
|
if (self._Store.webviewBridgeEnabled) {
|
|
9784
9784
|
self._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Upload);
|
|
9785
9785
|
} else {
|
|
9786
|
-
|
|
9787
|
-
(_self$_APIClient = self._APIClient) === null || _self$_APIClient === void 0 || (_self$_APIClient = _self$_APIClient.uploader) === null || _self$_APIClient === void 0 || _self$_APIClient.prepareAndUpload(false, false);
|
|
9786
|
+
(_b = (_a = self._APIClient) === null || _a === void 0 ? void 0 : _a.uploader) === null || _b === void 0 ? void 0 : _b.prepareAndUpload(false, false);
|
|
9788
9787
|
}
|
|
9789
9788
|
}
|
|
9790
9789
|
};
|
|
@@ -9849,8 +9848,8 @@ var mParticle = (function () {
|
|
|
9849
9848
|
*/
|
|
9850
9849
|
add: function add(product, logEventBoolean) {
|
|
9851
9850
|
self.Logger.warning('Deprecated function eCommerce.Cart.add() will be removed in future releases');
|
|
9852
|
-
var mpid
|
|
9853
|
-
|
|
9851
|
+
var mpid;
|
|
9852
|
+
var currentUser = self.Identity.getCurrentUser();
|
|
9854
9853
|
if (currentUser) {
|
|
9855
9854
|
mpid = currentUser.getMPID();
|
|
9856
9855
|
}
|
|
@@ -9865,8 +9864,8 @@ var mParticle = (function () {
|
|
|
9865
9864
|
*/
|
|
9866
9865
|
remove: function remove(product, logEventBoolean) {
|
|
9867
9866
|
self.Logger.warning('Deprecated function eCommerce.Cart.remove() will be removed in future releases');
|
|
9868
|
-
var mpid
|
|
9869
|
-
|
|
9867
|
+
var mpid;
|
|
9868
|
+
var currentUser = self.Identity.getCurrentUser();
|
|
9870
9869
|
if (currentUser) {
|
|
9871
9870
|
mpid = currentUser.getMPID();
|
|
9872
9871
|
}
|
|
@@ -9879,8 +9878,8 @@ var mParticle = (function () {
|
|
|
9879
9878
|
*/
|
|
9880
9879
|
clear: function clear() {
|
|
9881
9880
|
self.Logger.warning('Deprecated function eCommerce.Cart.clear() will be removed in future releases');
|
|
9882
|
-
var mpid
|
|
9883
|
-
|
|
9881
|
+
var mpid;
|
|
9882
|
+
var currentUser = self.Identity.getCurrentUser();
|
|
9884
9883
|
if (currentUser) {
|
|
9885
9884
|
mpid = currentUser.getMPID();
|
|
9886
9885
|
}
|
|
@@ -10097,7 +10096,6 @@ var mParticle = (function () {
|
|
|
10097
10096
|
self.setSessionAttribute(key, value);
|
|
10098
10097
|
}, self);
|
|
10099
10098
|
if (queued) return;
|
|
10100
|
-
|
|
10101
10099
|
// Logs to cookie
|
|
10102
10100
|
// And logs to in-memory object
|
|
10103
10101
|
// Example: mParticle.setSessionAttribute('location', '33431');
|
|
@@ -10232,7 +10230,7 @@ var mParticle = (function () {
|
|
|
10232
10230
|
};
|
|
10233
10231
|
/*
|
|
10234
10232
|
An integration delay is a workaround that prevents events from being sent when it is necessary to do so.
|
|
10235
|
-
Some server side integrations require a client side value to be included in the payload to successfully
|
|
10233
|
+
Some server side integrations require a client side value to be included in the payload to successfully
|
|
10236
10234
|
forward. This value can only be pulled from the client side partner SDK.
|
|
10237
10235
|
During the kit initialization, the kit:
|
|
10238
10236
|
* sets an integration delay to `true`
|
|
@@ -10246,14 +10244,12 @@ var mParticle = (function () {
|
|
|
10246
10244
|
*/
|
|
10247
10245
|
this._setIntegrationDelay = function (module, shouldDelayIntegration) {
|
|
10248
10246
|
self._preInit.integrationDelays[module] = shouldDelayIntegration;
|
|
10249
|
-
|
|
10250
10247
|
// If the integration delay is set to true, no further action needed
|
|
10251
10248
|
if (shouldDelayIntegration === true) {
|
|
10252
10249
|
return;
|
|
10253
10250
|
}
|
|
10254
10251
|
// If the integration delay is set to false, check to see if there are any
|
|
10255
10252
|
// other integration delays set to true. It not, process the queued events/.
|
|
10256
|
-
|
|
10257
10253
|
var integrationDelaysKeys = Object.keys(self._preInit.integrationDelays);
|
|
10258
10254
|
if (integrationDelaysKeys.length === 0) {
|
|
10259
10255
|
return;
|
|
@@ -10265,7 +10261,6 @@ var mParticle = (function () {
|
|
|
10265
10261
|
self._APIClient.processQueuedEvents();
|
|
10266
10262
|
}
|
|
10267
10263
|
};
|
|
10268
|
-
|
|
10269
10264
|
// Internal use only. Used by our wrapper SDKs to identify themselves during initialization.
|
|
10270
10265
|
this._setWrapperSDKInfo = function (name, version) {
|
|
10271
10266
|
var queued = queueIfNotInitialized(function () {
|
|
@@ -10281,7 +10276,6 @@ var mParticle = (function () {
|
|
|
10281
10276
|
}
|
|
10282
10277
|
};
|
|
10283
10278
|
}
|
|
10284
|
-
|
|
10285
10279
|
// Some (server) config settings need to be returned before they are set on SDKConfig in a self hosted environment
|
|
10286
10280
|
function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
10287
10281
|
var kitBlocker = createKitBlocker(config, mpInstance);
|
|
@@ -10290,7 +10284,6 @@ var mParticle = (function () {
|
|
|
10290
10284
|
mpInstance._Store.processConfig(config);
|
|
10291
10285
|
mpInstance._Identity.idCache = createIdentityCache(mpInstance);
|
|
10292
10286
|
removeExpiredIdentityCacheDates(mpInstance._Identity.idCache);
|
|
10293
|
-
|
|
10294
10287
|
// Web View Bridge is used for cases where the Web SDK is loaded within an iOS or Android device's
|
|
10295
10288
|
// Web View. The Web SDK simply acts as a passthrough to the mParticle Native SDK. It is not
|
|
10296
10289
|
// responsible for sending events directly to mParticle's servers. The Web SDK will not initialize
|
|
@@ -10299,11 +10292,9 @@ var mParticle = (function () {
|
|
|
10299
10292
|
mpInstance._NativeSdkHelpers.initializeSessionAttributes(apiKey);
|
|
10300
10293
|
} else {
|
|
10301
10294
|
// Main SDK initialization flow
|
|
10302
|
-
|
|
10303
10295
|
// Load any settings/identities/attributes from cookie or localStorage
|
|
10304
10296
|
mpInstance._Persistence.initializeStorage();
|
|
10305
10297
|
mpInstance._Store.syncPersistenceData();
|
|
10306
|
-
|
|
10307
10298
|
// Set up user identitiy variables for later use
|
|
10308
10299
|
var currentUser = mpInstance.Identity.getCurrentUser();
|
|
10309
10300
|
var currentUserMPID = currentUser ? currentUser.getMPID() : null;
|
|
@@ -10319,36 +10310,35 @@ var mParticle = (function () {
|
|
|
10319
10310
|
}
|
|
10320
10311
|
mpInstance._Forwarders.processForwarders(config, mpInstance._APIClient.prepareForwardingStats);
|
|
10321
10312
|
mpInstance._Forwarders.processPixelConfigs(config);
|
|
10322
|
-
|
|
10323
10313
|
// Checks if session is created, resumed, or needs to be ended
|
|
10324
10314
|
// Logs a session start or session end event accordingly
|
|
10325
10315
|
mpInstance._SessionManager.initialize();
|
|
10326
10316
|
mpInstance._Events.logAST();
|
|
10327
10317
|
processIdentityCallback(mpInstance, currentUser, currentUserMPID, currentUserIdentities);
|
|
10328
10318
|
}
|
|
10329
|
-
|
|
10330
10319
|
// We will continue to clear out the ready queue as part of the initial init flow
|
|
10331
10320
|
// if an identify request is unnecessary, such as if there is an existing session
|
|
10332
10321
|
if (mpInstance._Store.mpid && !mpInstance._Store.identifyCalled || mpInstance._Store.webviewBridgeEnabled) {
|
|
10333
10322
|
mpInstance._Store.isInitialized = true;
|
|
10334
10323
|
mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue);
|
|
10335
10324
|
}
|
|
10336
|
-
|
|
10337
10325
|
// https://go.mparticle.com/work/SQDSDKS-6040
|
|
10338
10326
|
if (mpInstance._Store.isFirstRun) {
|
|
10339
10327
|
mpInstance._Store.isFirstRun = false;
|
|
10340
10328
|
}
|
|
10341
10329
|
}
|
|
10330
|
+
// https://go.mparticle.com/work/SQDSDKS-7061
|
|
10342
10331
|
function createKitBlocker(config, mpInstance) {
|
|
10343
|
-
var kitBlocker
|
|
10344
|
-
|
|
10332
|
+
var kitBlocker;
|
|
10333
|
+
var dataPlanForKitBlocker;
|
|
10334
|
+
var kitBlockError;
|
|
10335
|
+
var kitBlockOptions;
|
|
10345
10336
|
/* There are three ways a data plan object for blocking can be passed to the SDK:
|
|
10346
10337
|
1. Manually via config.dataPlanOptions (this takes priority)
|
|
10347
10338
|
If not passed in manually, we user the server provided via either
|
|
10348
10339
|
2. Snippet via /mparticle.js endpoint (config.dataPlan.document)
|
|
10349
10340
|
3. Self hosting via /config endpoint (config.dataPlanResult)
|
|
10350
10341
|
*/
|
|
10351
|
-
|
|
10352
10342
|
if (config.dataPlanOptions) {
|
|
10353
10343
|
mpInstance.Logger.verbose('Customer provided data plan found');
|
|
10354
10344
|
kitBlockOptions = config.dataPlanOptions;
|
|
@@ -10406,7 +10396,6 @@ var mParticle = (function () {
|
|
|
10406
10396
|
mpInstance._Store = new Store(config, mpInstance, apiKey);
|
|
10407
10397
|
window.mParticle.Store = mpInstance._Store;
|
|
10408
10398
|
mpInstance.Logger.verbose(StartingInitialization);
|
|
10409
|
-
|
|
10410
10399
|
// Check to see if localStorage is available before main configuration runs
|
|
10411
10400
|
// since we will need this for the current implementation of user persistence
|
|
10412
10401
|
// TODO: Refactor this when we refactor User Identity Persistence
|
|
@@ -10649,25 +10638,26 @@ var mParticle = (function () {
|
|
|
10649
10638
|
if (!Array.prototype.filter) {
|
|
10650
10639
|
Array.prototype.filter = Polyfill.filter;
|
|
10651
10640
|
}
|
|
10641
|
+
// https://go.mparticle.com/work/SQDSDKS-6768
|
|
10652
10642
|
if (!Array.isArray) {
|
|
10643
|
+
// @ts-ignore
|
|
10653
10644
|
Array.prototype.isArray = Polyfill.isArray;
|
|
10654
10645
|
}
|
|
10655
|
-
function
|
|
10646
|
+
function mParticleInstanceManager() {
|
|
10656
10647
|
var self = this;
|
|
10657
10648
|
// Only leaving this here in case any clients are trying to access mParticle.Store, to prevent from throwing
|
|
10658
10649
|
this.Store = {};
|
|
10659
10650
|
this._instances = {};
|
|
10660
10651
|
this.IdentityType = Types.IdentityType;
|
|
10661
|
-
this.EventType =
|
|
10662
|
-
this.CommerceEventType =
|
|
10663
|
-
this.PromotionType =
|
|
10664
|
-
this.ProductActionType =
|
|
10652
|
+
this.EventType = EventType;
|
|
10653
|
+
this.CommerceEventType = CommerceEventType;
|
|
10654
|
+
this.PromotionType = PromotionActionType;
|
|
10655
|
+
this.ProductActionType = ProductActionType;
|
|
10665
10656
|
this.MPSideloadedKit = MPSideloadedKit;
|
|
10666
10657
|
if (typeof window !== 'undefined') {
|
|
10667
10658
|
this.isIOS = window.mParticle && window.mParticle.isIOS ? window.mParticle.isIOS : false;
|
|
10668
10659
|
this.config = window.mParticle && window.mParticle.config ? window.mParticle.config : {};
|
|
10669
10660
|
}
|
|
10670
|
-
|
|
10671
10661
|
/**
|
|
10672
10662
|
* Initializes the mParticle instance. If no instanceName is provided, an instance name of `default_instance` will be used.
|
|
10673
10663
|
* <p>
|
|
@@ -10685,7 +10675,7 @@ var mParticle = (function () {
|
|
|
10685
10675
|
instanceName = (!instanceName || instanceName.length === 0 ? Constants.DefaultInstance : instanceName).toLowerCase();
|
|
10686
10676
|
var client = self._instances[instanceName];
|
|
10687
10677
|
if (client === undefined) {
|
|
10688
|
-
client = new mParticleInstance(
|
|
10678
|
+
client = new mParticleInstance(instanceName);
|
|
10689
10679
|
self._instances[instanceName] = client;
|
|
10690
10680
|
}
|
|
10691
10681
|
client.init(apiKey, config, instanceName);
|
|
@@ -10923,12 +10913,17 @@ var mParticle = (function () {
|
|
|
10923
10913
|
self.getInstance()._setWrapperSDKInfo(name, version);
|
|
10924
10914
|
};
|
|
10925
10915
|
}
|
|
10926
|
-
var
|
|
10916
|
+
var mParticleManager = new mParticleInstanceManager();
|
|
10927
10917
|
if (typeof window !== 'undefined') {
|
|
10928
|
-
|
|
10918
|
+
// mParticle is the global object used to access the SDK and predates instance manager,
|
|
10919
|
+
// when mParticle was a singleton. We now support multiple instances. Calling methods
|
|
10920
|
+
// on mParticle directly will access the default instance, but mParticle can also be used
|
|
10921
|
+
// as the instance manager in self hosted mode.
|
|
10922
|
+
window.mParticle = mParticleManager;
|
|
10923
|
+
// https://go.mparticle.com/work/SQDSDKS-5053
|
|
10929
10924
|
window.mParticle._BatchValidator = new _BatchValidator();
|
|
10930
10925
|
}
|
|
10931
10926
|
|
|
10932
|
-
return
|
|
10927
|
+
return mParticleManager;
|
|
10933
10928
|
|
|
10934
10929
|
})();
|
package/package.json
CHANGED
package/src/apiClient.ts
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
import Constants from './constants';
|
|
2
2
|
import Types from './types';
|
|
3
3
|
import { BatchUploader } from './batchUploader';
|
|
4
|
-
import {
|
|
4
|
+
import { SDKEvent, SDKDataPlan } from './sdkRuntimeModels';
|
|
5
5
|
import KitBlocker from './kitBlocking';
|
|
6
|
-
import { Dictionary,
|
|
6
|
+
import { Dictionary, isEmpty, parseNumber } from './utils';
|
|
7
7
|
import { IUploadObject } from './serverModel';
|
|
8
8
|
import { MPForwarder } from './forwarders.interfaces';
|
|
9
9
|
import { IMParticleUser, ISDKUserAttributes } from './identity-user-interfaces';
|
|
10
10
|
import { AsyncUploader, FetchUploader, XHRUploader } from './uploaders';
|
|
11
|
+
import { IMParticleWebSDKInstance } from './mp-instance';
|
|
11
12
|
|
|
12
13
|
export interface IAPIClient {
|
|
13
14
|
uploader: BatchUploader | null;
|
|
@@ -43,7 +44,7 @@ export interface IForwardingStatsData {
|
|
|
43
44
|
|
|
44
45
|
export default function APIClient(
|
|
45
46
|
this: IAPIClient,
|
|
46
|
-
mpInstance:
|
|
47
|
+
mpInstance: IMParticleWebSDKInstance,
|
|
47
48
|
kitBlocker: KitBlocker
|
|
48
49
|
) {
|
|
49
50
|
this.uploader = null;
|
package/src/batchUploader.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Batch } from '@mparticle/event-models';
|
|
2
2
|
import Constants from './constants';
|
|
3
|
-
import { SDKEvent,
|
|
3
|
+
import { SDKEvent, SDKLoggerApi } from './sdkRuntimeModels';
|
|
4
4
|
import { convertEvents } from './sdkToEventsApiConverter';
|
|
5
5
|
import { MessageType } from './types';
|
|
6
6
|
import { getRampNumber, isEmpty } from './utils';
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
IFetchPayload,
|
|
13
13
|
} from './uploaders';
|
|
14
14
|
import { IMParticleUser } from './identity-user-interfaces';
|
|
15
|
+
import { IMParticleWebSDKInstance } from './mp-instance';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* BatchUploader contains all the logic to store/retrieve events and batches
|
|
@@ -36,7 +37,7 @@ export class BatchUploader {
|
|
|
36
37
|
uploadIntervalMillis: number;
|
|
37
38
|
eventsQueuedForProcessing: SDKEvent[];
|
|
38
39
|
batchesQueuedForProcessing: Batch[];
|
|
39
|
-
mpInstance:
|
|
40
|
+
mpInstance: IMParticleWebSDKInstance;
|
|
40
41
|
uploadUrl: string;
|
|
41
42
|
batchingEnabled: boolean;
|
|
42
43
|
private eventVault: SessionStorageVault<SDKEvent[]>;
|
|
@@ -46,10 +47,10 @@ export class BatchUploader {
|
|
|
46
47
|
|
|
47
48
|
/**
|
|
48
49
|
* Creates an instance of a BatchUploader
|
|
49
|
-
* @param {
|
|
50
|
+
* @param {IMParticleWebSDKInstance} mpInstance - the mParticle SDK instance
|
|
50
51
|
* @param {number} uploadInterval - the desired upload interval in milliseconds
|
|
51
52
|
*/
|
|
52
|
-
constructor(mpInstance:
|
|
53
|
+
constructor(mpInstance: IMParticleWebSDKInstance, uploadInterval: number) {
|
|
53
54
|
this.mpInstance = mpInstance;
|
|
54
55
|
this.uploadIntervalMillis = uploadInterval;
|
|
55
56
|
this.batchingEnabled =
|
|
@@ -208,7 +209,7 @@ export class BatchUploader {
|
|
|
208
209
|
private static createNewBatches(
|
|
209
210
|
sdkEvents: SDKEvent[],
|
|
210
211
|
defaultUser: IMParticleUser,
|
|
211
|
-
mpInstance:
|
|
212
|
+
mpInstance: IMParticleWebSDKInstance
|
|
212
213
|
): Batch[] | null {
|
|
213
214
|
if (!defaultUser || !sdkEvents || !sdkEvents.length) {
|
|
214
215
|
return null;
|
|
@@ -280,9 +281,9 @@ export class BatchUploader {
|
|
|
280
281
|
* @param triggerFuture whether to trigger the loop again - for manual/forced uploads this should be false
|
|
281
282
|
* @param useBeacon whether to use the beacon API - used when the page is being unloaded
|
|
282
283
|
*/
|
|
283
|
-
|
|
284
|
-
triggerFuture: boolean,
|
|
285
|
-
useBeacon: boolean
|
|
284
|
+
public async prepareAndUpload(
|
|
285
|
+
triggerFuture: boolean = false,
|
|
286
|
+
useBeacon: boolean = false,
|
|
286
287
|
): Promise<void> {
|
|
287
288
|
// Fetch current user so that events can be grouped by MPID
|
|
288
289
|
const currentUser = this.mpInstance.Identity.getCurrentUser();
|
package/src/configAPIClient.ts
CHANGED
|
@@ -2,7 +2,6 @@ import { DataPlanConfig } from '@mparticle/web-sdk';
|
|
|
2
2
|
import {
|
|
3
3
|
BooleanStringLowerCase,
|
|
4
4
|
DataPlanResult,
|
|
5
|
-
MParticleWebSDK,
|
|
6
5
|
SDKEventCustomFlags,
|
|
7
6
|
SDKInitConfig,
|
|
8
7
|
} from './sdkRuntimeModels';
|
|
@@ -14,6 +13,7 @@ import {
|
|
|
14
13
|
XHRUploader,
|
|
15
14
|
} from './uploaders';
|
|
16
15
|
import { IPixelConfiguration } from './cookieSyncManager';
|
|
16
|
+
import { IMParticleWebSDKInstance } from './mp-instance';
|
|
17
17
|
|
|
18
18
|
export interface IKitConfigs extends IKitFilterSettings {
|
|
19
19
|
name: string;
|
|
@@ -82,7 +82,7 @@ export interface IConfigResponse {
|
|
|
82
82
|
export interface IConfigAPIClient {
|
|
83
83
|
apiKey: string;
|
|
84
84
|
config: SDKInitConfig;
|
|
85
|
-
mpInstance:
|
|
85
|
+
mpInstance: IMParticleWebSDKInstance;
|
|
86
86
|
getSDKConfiguration: () => Promise<IConfigResponse>;
|
|
87
87
|
}
|
|
88
88
|
|
|
@@ -113,7 +113,7 @@ export default function ConfigAPIClient(
|
|
|
113
113
|
this: IConfigAPIClient,
|
|
114
114
|
apiKey: string,
|
|
115
115
|
config: SDKInitConfig,
|
|
116
|
-
mpInstance:
|
|
116
|
+
mpInstance: IMParticleWebSDKInstance
|
|
117
117
|
): void {
|
|
118
118
|
const baseUrl = 'https://' + mpInstance._Store.SDKConfig.configUrl;
|
|
119
119
|
const { isDevelopmentMode } = config;
|
package/src/consent.ts
CHANGED
|
@@ -4,11 +4,11 @@ import {
|
|
|
4
4
|
GDPRConsentState,
|
|
5
5
|
PrivacyConsentState,
|
|
6
6
|
} from '@mparticle/web-sdk';
|
|
7
|
-
import { MParticleWebSDK } from './sdkRuntimeModels';
|
|
8
7
|
import { Dictionary, isObject } from './utils';
|
|
9
8
|
import KitFilterHelper from './kitFilterHelper';
|
|
10
9
|
import Constants from './constants';
|
|
11
10
|
import { IMParticleUser } from './identity-user-interfaces';
|
|
11
|
+
import { IMParticleWebSDKInstance } from './mp-instance';
|
|
12
12
|
|
|
13
13
|
const { CCPAPurpose } = Constants;
|
|
14
14
|
|
|
@@ -36,12 +36,6 @@ export interface SDKConsentApi {
|
|
|
36
36
|
createGDPRConsent: ICreatePrivacyConsentFunction;
|
|
37
37
|
createCCPAConsent: ICreatePrivacyConsentFunction;
|
|
38
38
|
createConsentState: (consentState?: ConsentState) => ConsentState;
|
|
39
|
-
ConsentSerialization: IConsentSerialization;
|
|
40
|
-
createPrivacyConsent: ICreatePrivacyConsentFunction;
|
|
41
|
-
isEnabledForUserConsent: (
|
|
42
|
-
consentRules: IConsentRules,
|
|
43
|
-
user: IMParticleUser
|
|
44
|
-
) => boolean;
|
|
45
39
|
}
|
|
46
40
|
|
|
47
41
|
export interface IConsentSerialization {
|
|
@@ -120,7 +114,7 @@ export interface IConsent {
|
|
|
120
114
|
ConsentSerialization: IConsentSerialization;
|
|
121
115
|
}
|
|
122
116
|
|
|
123
|
-
export default function Consent(this: IConsent, mpInstance:
|
|
117
|
+
export default function Consent(this: IConsent, mpInstance: IMParticleWebSDKInstance) {
|
|
124
118
|
const self = this;
|
|
125
119
|
|
|
126
120
|
// this function is called when consent is required to
|
package/src/cookieSyncManager.ts
CHANGED
|
@@ -4,9 +4,9 @@ import {
|
|
|
4
4
|
createCookieSyncUrl,
|
|
5
5
|
} from './utils';
|
|
6
6
|
import Constants from './constants';
|
|
7
|
-
import { MParticleWebSDK } from './sdkRuntimeModels';
|
|
8
7
|
import { MPID } from '@mparticle/web-sdk';
|
|
9
8
|
import { IConsentRules } from './consent';
|
|
9
|
+
import { IMParticleWebSDKInstance } from './mp-instance';
|
|
10
10
|
|
|
11
11
|
const { Messages } = Constants;
|
|
12
12
|
const { InformationMessages } = Messages;
|
|
@@ -47,7 +47,7 @@ export interface ICookieSyncManager {
|
|
|
47
47
|
|
|
48
48
|
export default function CookieSyncManager(
|
|
49
49
|
this: ICookieSyncManager,
|
|
50
|
-
mpInstance:
|
|
50
|
+
mpInstance: IMParticleWebSDKInstance
|
|
51
51
|
) {
|
|
52
52
|
const self = this;
|
|
53
53
|
|
package/src/events.interfaces.ts
CHANGED
|
@@ -53,7 +53,7 @@ export interface IEvents {
|
|
|
53
53
|
logOptOut(): void;
|
|
54
54
|
logProductActionEvent(
|
|
55
55
|
productActionType: valueof<typeof ProductActionType>,
|
|
56
|
-
product: SDKProduct,
|
|
56
|
+
product: SDKProduct | SDKProduct[],
|
|
57
57
|
attrs?: SDKEventAttrs,
|
|
58
58
|
customFlags?: SDKEventCustomFlags,
|
|
59
59
|
transactionAttributes?: TransactionAttributes,
|
|
@@ -68,13 +68,13 @@ export interface IEvents {
|
|
|
68
68
|
): void;
|
|
69
69
|
logPurchaseEvent(
|
|
70
70
|
transactionAttributes: TransactionAttributes,
|
|
71
|
-
product: SDKProduct,
|
|
71
|
+
product: SDKProduct | SDKProduct[],
|
|
72
72
|
attrs?: SDKEventAttrs,
|
|
73
73
|
customFlags?: SDKEventCustomFlags
|
|
74
74
|
): void;
|
|
75
75
|
logRefundEvent(
|
|
76
76
|
transactionAttributes: TransactionAttributes,
|
|
77
|
-
product: SDKProduct,
|
|
77
|
+
product: SDKProduct | SDKProduct[],
|
|
78
78
|
attrs?: SDKEventAttrs,
|
|
79
79
|
customFlags?: SDKEventCustomFlags
|
|
80
80
|
): void;
|