@mparticle/web-sdk 2.32.3 → 2.32.4
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 +14 -13
- package/dist/mparticle.esm.js +14 -13
- package/dist/mparticle.js +69 -79
- 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/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.4";
|
|
207
207
|
|
|
208
208
|
var Constants = {
|
|
209
209
|
sdkVersion: version,
|
|
@@ -2174,11 +2174,11 @@ var mParticle = (function () {
|
|
|
2174
2174
|
reject(xhr);
|
|
2175
2175
|
};
|
|
2176
2176
|
xhr.open(method, url);
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
|
|
2180
|
-
|
|
2181
|
-
}
|
|
2177
|
+
for (var key in headers) {
|
|
2178
|
+
if (headers.hasOwnProperty(key)) {
|
|
2179
|
+
xhr.setRequestHeader(key, headers[key]);
|
|
2180
|
+
}
|
|
2181
|
+
}
|
|
2182
2182
|
xhr.send(data);
|
|
2183
2183
|
})];
|
|
2184
2184
|
});
|
|
@@ -2205,7 +2205,7 @@ var mParticle = (function () {
|
|
|
2205
2205
|
var BatchUploader = /** @class */function () {
|
|
2206
2206
|
/**
|
|
2207
2207
|
* Creates an instance of a BatchUploader
|
|
2208
|
-
* @param {
|
|
2208
|
+
* @param {IMParticleWebSDKInstance} mpInstance - the mParticle SDK instance
|
|
2209
2209
|
* @param {number} uploadInterval - the desired upload interval in milliseconds
|
|
2210
2210
|
*/
|
|
2211
2211
|
function BatchUploader(mpInstance, uploadInterval) {
|
|
@@ -2388,6 +2388,12 @@ var mParticle = (function () {
|
|
|
2388
2388
|
* @param useBeacon whether to use the beacon API - used when the page is being unloaded
|
|
2389
2389
|
*/
|
|
2390
2390
|
BatchUploader.prototype.prepareAndUpload = function (triggerFuture, useBeacon) {
|
|
2391
|
+
if (triggerFuture === void 0) {
|
|
2392
|
+
triggerFuture = false;
|
|
2393
|
+
}
|
|
2394
|
+
if (useBeacon === void 0) {
|
|
2395
|
+
useBeacon = false;
|
|
2396
|
+
}
|
|
2391
2397
|
return __awaiter(this, void 0, void 0, function () {
|
|
2392
2398
|
var currentUser, currentEvents, newBatches, batchesToUpload, batchesThatDidNotUpload;
|
|
2393
2399
|
var _a, _b, _c;
|
|
@@ -9293,13 +9299,13 @@ var mParticle = (function () {
|
|
|
9293
9299
|
if (!clickIds) {
|
|
9294
9300
|
return mappedClickIds;
|
|
9295
9301
|
}
|
|
9296
|
-
for (var
|
|
9297
|
-
|
|
9298
|
-
|
|
9299
|
-
|
|
9300
|
-
|
|
9301
|
-
|
|
9302
|
-
|
|
9302
|
+
for (var key in clickIds) {
|
|
9303
|
+
if (clickIds.hasOwnProperty(key)) {
|
|
9304
|
+
var value = clickIds[key];
|
|
9305
|
+
var mappedKey = (_a = mappingList[key]) === null || _a === void 0 ? void 0 : _a.mappedKey;
|
|
9306
|
+
if (!isEmpty(mappedKey)) {
|
|
9307
|
+
mappedClickIds[mappedKey] = value;
|
|
9308
|
+
}
|
|
9303
9309
|
}
|
|
9304
9310
|
}
|
|
9305
9311
|
return mappedClickIds;
|
|
@@ -9307,15 +9313,11 @@ var mParticle = (function () {
|
|
|
9307
9313
|
IntegrationCapture.prototype.applyProcessors = function (clickIds, url, timestamp) {
|
|
9308
9314
|
var _a;
|
|
9309
9315
|
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;
|
|
9316
|
+
for (var key in clickIds) {
|
|
9317
|
+
if (clickIds.hasOwnProperty(key)) {
|
|
9318
|
+
var value = clickIds[key];
|
|
9319
|
+
var processor = (_a = integrationMapping[key]) === null || _a === void 0 ? void 0 : _a.processor;
|
|
9320
|
+
processedClickIds[key] = processor ? processor(value, url, timestamp) : value;
|
|
9319
9321
|
}
|
|
9320
9322
|
}
|
|
9321
9323
|
return processedClickIds;
|
|
@@ -9338,7 +9340,6 @@ var mParticle = (function () {
|
|
|
9338
9340
|
var ReportBatching = FeatureFlags.ReportBatching,
|
|
9339
9341
|
CaptureIntegrationSpecificIds = FeatureFlags.CaptureIntegrationSpecificIds;
|
|
9340
9342
|
var StartingInitialization = Messages.InformationMessages.StartingInitialization;
|
|
9341
|
-
|
|
9342
9343
|
/**
|
|
9343
9344
|
* <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
9345
|
* <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 +9352,6 @@ var mParticle = (function () {
|
|
|
9351
9352
|
*
|
|
9352
9353
|
* @class mParticle & mParticleInstance
|
|
9353
9354
|
*/
|
|
9354
|
-
|
|
9355
9355
|
function mParticleInstance(instanceName) {
|
|
9356
9356
|
var self = this;
|
|
9357
9357
|
// These classes are for internal use only. Not documented for public consumption
|
|
@@ -9373,17 +9373,15 @@ var mParticle = (function () {
|
|
|
9373
9373
|
forwarderConstructors: []
|
|
9374
9374
|
};
|
|
9375
9375
|
this._IntegrationCapture = new IntegrationCapture();
|
|
9376
|
-
|
|
9377
9376
|
// required for forwarders once they reference the mparticle instance
|
|
9378
|
-
this.IdentityType =
|
|
9379
|
-
this.EventType =
|
|
9380
|
-
this.CommerceEventType =
|
|
9381
|
-
this.PromotionType =
|
|
9382
|
-
this.ProductActionType =
|
|
9377
|
+
this.IdentityType = IdentityType;
|
|
9378
|
+
this.EventType = EventType;
|
|
9379
|
+
this.CommerceEventType = CommerceEventType;
|
|
9380
|
+
this.PromotionType = PromotionActionType;
|
|
9381
|
+
this.ProductActionType = ProductActionType;
|
|
9383
9382
|
this._Identity = new Identity(this);
|
|
9384
9383
|
this.Identity = this._Identity.IdentityAPI;
|
|
9385
9384
|
this.generateHash = this._Helpers.generateHash;
|
|
9386
|
-
|
|
9387
9385
|
// https://go.mparticle.com/work/SQDSDKS-6289
|
|
9388
9386
|
// TODO: Replace this with Store once Store is moved earlier in the init process
|
|
9389
9387
|
this.getDeviceId = this._Persistence.getDeviceId;
|
|
@@ -9400,7 +9398,6 @@ var mParticle = (function () {
|
|
|
9400
9398
|
console.warn('You did not pass a config object to init(). mParticle will not initialize properly');
|
|
9401
9399
|
}
|
|
9402
9400
|
runPreConfigFetchInitialization(this, apiKey, config);
|
|
9403
|
-
|
|
9404
9401
|
// config code - Fetch config when requestConfig = true, otherwise, proceed with SDKInitialization
|
|
9405
9402
|
// Since fetching the configuration is asynchronous, we must pass completeSDKInitialization
|
|
9406
9403
|
// to it for it to be run after fetched
|
|
@@ -9428,7 +9425,6 @@ var mParticle = (function () {
|
|
|
9428
9425
|
this.setLogLevel = function (newLogLevel) {
|
|
9429
9426
|
self.Logger.setLogLevel(newLogLevel);
|
|
9430
9427
|
};
|
|
9431
|
-
|
|
9432
9428
|
/**
|
|
9433
9429
|
* Resets the SDK to an uninitialized state and removes cookies/localStorage. You MUST call mParticle.init(apiKey, window.mParticle.config)
|
|
9434
9430
|
* before any other mParticle methods or the SDK will not function as intended.
|
|
@@ -9525,7 +9521,6 @@ var mParticle = (function () {
|
|
|
9525
9521
|
this.isInitialized = function () {
|
|
9526
9522
|
return self._Store ? self._Store.isInitialized : false;
|
|
9527
9523
|
};
|
|
9528
|
-
|
|
9529
9524
|
/**
|
|
9530
9525
|
* Gets the app name
|
|
9531
9526
|
* @method getAppName
|
|
@@ -9610,7 +9605,6 @@ var mParticle = (function () {
|
|
|
9610
9605
|
// Sends true as an over ride vs when endSession is called from the setInterval
|
|
9611
9606
|
self._SessionManager.endSession(true);
|
|
9612
9607
|
};
|
|
9613
|
-
|
|
9614
9608
|
/**
|
|
9615
9609
|
* Logs a Base Event to mParticle's servers
|
|
9616
9610
|
* @param {Object} event Base Event Object
|
|
@@ -9627,7 +9621,7 @@ var mParticle = (function () {
|
|
|
9627
9621
|
return;
|
|
9628
9622
|
}
|
|
9629
9623
|
if (!event.eventType) {
|
|
9630
|
-
event.eventType =
|
|
9624
|
+
event.eventType = EventType.Unknown;
|
|
9631
9625
|
}
|
|
9632
9626
|
if (!self._Helpers.canLog()) {
|
|
9633
9627
|
self.Logger.error(Messages.ErrorMessages.LoggingDisabled);
|
|
@@ -9655,10 +9649,10 @@ var mParticle = (function () {
|
|
|
9655
9649
|
return;
|
|
9656
9650
|
}
|
|
9657
9651
|
if (!eventType) {
|
|
9658
|
-
eventType =
|
|
9652
|
+
eventType = EventType.Unknown;
|
|
9659
9653
|
}
|
|
9660
9654
|
if (!self._Helpers.isEventType(eventType)) {
|
|
9661
|
-
self.Logger.error('Invalid event type: ' + eventType + ', must be one of: \n' + JSON.stringify(
|
|
9655
|
+
self.Logger.error('Invalid event type: ' + eventType + ', must be one of: \n' + JSON.stringify(EventType));
|
|
9662
9656
|
return;
|
|
9663
9657
|
}
|
|
9664
9658
|
if (!self._Helpers.canLog()) {
|
|
@@ -9666,7 +9660,7 @@ var mParticle = (function () {
|
|
|
9666
9660
|
return;
|
|
9667
9661
|
}
|
|
9668
9662
|
self._Events.logEvent({
|
|
9669
|
-
messageType:
|
|
9663
|
+
messageType: MessageType$1.PageEvent,
|
|
9670
9664
|
name: eventName,
|
|
9671
9665
|
data: eventInfo,
|
|
9672
9666
|
eventType: eventType,
|
|
@@ -9706,10 +9700,10 @@ var mParticle = (function () {
|
|
|
9706
9700
|
}
|
|
9707
9701
|
}
|
|
9708
9702
|
self._Events.logEvent({
|
|
9709
|
-
messageType:
|
|
9703
|
+
messageType: MessageType$1.CrashReport,
|
|
9710
9704
|
name: error.name ? error.name : 'Error',
|
|
9711
|
-
|
|
9712
|
-
|
|
9705
|
+
eventType: EventType.Other,
|
|
9706
|
+
data: data
|
|
9713
9707
|
});
|
|
9714
9708
|
};
|
|
9715
9709
|
/**
|
|
@@ -9767,10 +9761,10 @@ var mParticle = (function () {
|
|
|
9767
9761
|
}
|
|
9768
9762
|
}
|
|
9769
9763
|
self._Events.logEvent({
|
|
9770
|
-
messageType:
|
|
9764
|
+
messageType: MessageType$1.PageView,
|
|
9771
9765
|
name: eventName,
|
|
9772
9766
|
data: attrs,
|
|
9773
|
-
eventType:
|
|
9767
|
+
eventType: EventType.Unknown,
|
|
9774
9768
|
customFlags: customFlags
|
|
9775
9769
|
}, eventOptions);
|
|
9776
9770
|
};
|
|
@@ -9779,12 +9773,12 @@ var mParticle = (function () {
|
|
|
9779
9773
|
* @method upload
|
|
9780
9774
|
*/
|
|
9781
9775
|
this.upload = function () {
|
|
9776
|
+
var _a, _b;
|
|
9782
9777
|
if (self._Helpers.canLog()) {
|
|
9783
9778
|
if (self._Store.webviewBridgeEnabled) {
|
|
9784
9779
|
self._NativeSdkHelpers.sendToNative(Constants.NativeSdkPaths.Upload);
|
|
9785
9780
|
} 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);
|
|
9781
|
+
(_b = (_a = self._APIClient) === null || _a === void 0 ? void 0 : _a.uploader) === null || _b === void 0 ? void 0 : _b.prepareAndUpload(false, false);
|
|
9788
9782
|
}
|
|
9789
9783
|
}
|
|
9790
9784
|
};
|
|
@@ -9849,8 +9843,8 @@ var mParticle = (function () {
|
|
|
9849
9843
|
*/
|
|
9850
9844
|
add: function add(product, logEventBoolean) {
|
|
9851
9845
|
self.Logger.warning('Deprecated function eCommerce.Cart.add() will be removed in future releases');
|
|
9852
|
-
var mpid
|
|
9853
|
-
|
|
9846
|
+
var mpid;
|
|
9847
|
+
var currentUser = self.Identity.getCurrentUser();
|
|
9854
9848
|
if (currentUser) {
|
|
9855
9849
|
mpid = currentUser.getMPID();
|
|
9856
9850
|
}
|
|
@@ -9865,8 +9859,8 @@ var mParticle = (function () {
|
|
|
9865
9859
|
*/
|
|
9866
9860
|
remove: function remove(product, logEventBoolean) {
|
|
9867
9861
|
self.Logger.warning('Deprecated function eCommerce.Cart.remove() will be removed in future releases');
|
|
9868
|
-
var mpid
|
|
9869
|
-
|
|
9862
|
+
var mpid;
|
|
9863
|
+
var currentUser = self.Identity.getCurrentUser();
|
|
9870
9864
|
if (currentUser) {
|
|
9871
9865
|
mpid = currentUser.getMPID();
|
|
9872
9866
|
}
|
|
@@ -9879,8 +9873,8 @@ var mParticle = (function () {
|
|
|
9879
9873
|
*/
|
|
9880
9874
|
clear: function clear() {
|
|
9881
9875
|
self.Logger.warning('Deprecated function eCommerce.Cart.clear() will be removed in future releases');
|
|
9882
|
-
var mpid
|
|
9883
|
-
|
|
9876
|
+
var mpid;
|
|
9877
|
+
var currentUser = self.Identity.getCurrentUser();
|
|
9884
9878
|
if (currentUser) {
|
|
9885
9879
|
mpid = currentUser.getMPID();
|
|
9886
9880
|
}
|
|
@@ -10097,7 +10091,6 @@ var mParticle = (function () {
|
|
|
10097
10091
|
self.setSessionAttribute(key, value);
|
|
10098
10092
|
}, self);
|
|
10099
10093
|
if (queued) return;
|
|
10100
|
-
|
|
10101
10094
|
// Logs to cookie
|
|
10102
10095
|
// And logs to in-memory object
|
|
10103
10096
|
// Example: mParticle.setSessionAttribute('location', '33431');
|
|
@@ -10232,7 +10225,7 @@ var mParticle = (function () {
|
|
|
10232
10225
|
};
|
|
10233
10226
|
/*
|
|
10234
10227
|
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
|
|
10228
|
+
Some server side integrations require a client side value to be included in the payload to successfully
|
|
10236
10229
|
forward. This value can only be pulled from the client side partner SDK.
|
|
10237
10230
|
During the kit initialization, the kit:
|
|
10238
10231
|
* sets an integration delay to `true`
|
|
@@ -10246,14 +10239,12 @@ var mParticle = (function () {
|
|
|
10246
10239
|
*/
|
|
10247
10240
|
this._setIntegrationDelay = function (module, shouldDelayIntegration) {
|
|
10248
10241
|
self._preInit.integrationDelays[module] = shouldDelayIntegration;
|
|
10249
|
-
|
|
10250
10242
|
// If the integration delay is set to true, no further action needed
|
|
10251
10243
|
if (shouldDelayIntegration === true) {
|
|
10252
10244
|
return;
|
|
10253
10245
|
}
|
|
10254
10246
|
// If the integration delay is set to false, check to see if there are any
|
|
10255
10247
|
// other integration delays set to true. It not, process the queued events/.
|
|
10256
|
-
|
|
10257
10248
|
var integrationDelaysKeys = Object.keys(self._preInit.integrationDelays);
|
|
10258
10249
|
if (integrationDelaysKeys.length === 0) {
|
|
10259
10250
|
return;
|
|
@@ -10265,7 +10256,6 @@ var mParticle = (function () {
|
|
|
10265
10256
|
self._APIClient.processQueuedEvents();
|
|
10266
10257
|
}
|
|
10267
10258
|
};
|
|
10268
|
-
|
|
10269
10259
|
// Internal use only. Used by our wrapper SDKs to identify themselves during initialization.
|
|
10270
10260
|
this._setWrapperSDKInfo = function (name, version) {
|
|
10271
10261
|
var queued = queueIfNotInitialized(function () {
|
|
@@ -10281,7 +10271,6 @@ var mParticle = (function () {
|
|
|
10281
10271
|
}
|
|
10282
10272
|
};
|
|
10283
10273
|
}
|
|
10284
|
-
|
|
10285
10274
|
// Some (server) config settings need to be returned before they are set on SDKConfig in a self hosted environment
|
|
10286
10275
|
function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
10287
10276
|
var kitBlocker = createKitBlocker(config, mpInstance);
|
|
@@ -10290,7 +10279,6 @@ var mParticle = (function () {
|
|
|
10290
10279
|
mpInstance._Store.processConfig(config);
|
|
10291
10280
|
mpInstance._Identity.idCache = createIdentityCache(mpInstance);
|
|
10292
10281
|
removeExpiredIdentityCacheDates(mpInstance._Identity.idCache);
|
|
10293
|
-
|
|
10294
10282
|
// Web View Bridge is used for cases where the Web SDK is loaded within an iOS or Android device's
|
|
10295
10283
|
// Web View. The Web SDK simply acts as a passthrough to the mParticle Native SDK. It is not
|
|
10296
10284
|
// responsible for sending events directly to mParticle's servers. The Web SDK will not initialize
|
|
@@ -10299,11 +10287,9 @@ var mParticle = (function () {
|
|
|
10299
10287
|
mpInstance._NativeSdkHelpers.initializeSessionAttributes(apiKey);
|
|
10300
10288
|
} else {
|
|
10301
10289
|
// Main SDK initialization flow
|
|
10302
|
-
|
|
10303
10290
|
// Load any settings/identities/attributes from cookie or localStorage
|
|
10304
10291
|
mpInstance._Persistence.initializeStorage();
|
|
10305
10292
|
mpInstance._Store.syncPersistenceData();
|
|
10306
|
-
|
|
10307
10293
|
// Set up user identitiy variables for later use
|
|
10308
10294
|
var currentUser = mpInstance.Identity.getCurrentUser();
|
|
10309
10295
|
var currentUserMPID = currentUser ? currentUser.getMPID() : null;
|
|
@@ -10319,36 +10305,35 @@ var mParticle = (function () {
|
|
|
10319
10305
|
}
|
|
10320
10306
|
mpInstance._Forwarders.processForwarders(config, mpInstance._APIClient.prepareForwardingStats);
|
|
10321
10307
|
mpInstance._Forwarders.processPixelConfigs(config);
|
|
10322
|
-
|
|
10323
10308
|
// Checks if session is created, resumed, or needs to be ended
|
|
10324
10309
|
// Logs a session start or session end event accordingly
|
|
10325
10310
|
mpInstance._SessionManager.initialize();
|
|
10326
10311
|
mpInstance._Events.logAST();
|
|
10327
10312
|
processIdentityCallback(mpInstance, currentUser, currentUserMPID, currentUserIdentities);
|
|
10328
10313
|
}
|
|
10329
|
-
|
|
10330
10314
|
// We will continue to clear out the ready queue as part of the initial init flow
|
|
10331
10315
|
// if an identify request is unnecessary, such as if there is an existing session
|
|
10332
10316
|
if (mpInstance._Store.mpid && !mpInstance._Store.identifyCalled || mpInstance._Store.webviewBridgeEnabled) {
|
|
10333
10317
|
mpInstance._Store.isInitialized = true;
|
|
10334
10318
|
mpInstance._preInit.readyQueue = processReadyQueue(mpInstance._preInit.readyQueue);
|
|
10335
10319
|
}
|
|
10336
|
-
|
|
10337
10320
|
// https://go.mparticle.com/work/SQDSDKS-6040
|
|
10338
10321
|
if (mpInstance._Store.isFirstRun) {
|
|
10339
10322
|
mpInstance._Store.isFirstRun = false;
|
|
10340
10323
|
}
|
|
10341
10324
|
}
|
|
10325
|
+
// https://go.mparticle.com/work/SQDSDKS-7061
|
|
10342
10326
|
function createKitBlocker(config, mpInstance) {
|
|
10343
|
-
var kitBlocker
|
|
10344
|
-
|
|
10327
|
+
var kitBlocker;
|
|
10328
|
+
var dataPlanForKitBlocker;
|
|
10329
|
+
var kitBlockError;
|
|
10330
|
+
var kitBlockOptions;
|
|
10345
10331
|
/* There are three ways a data plan object for blocking can be passed to the SDK:
|
|
10346
10332
|
1. Manually via config.dataPlanOptions (this takes priority)
|
|
10347
10333
|
If not passed in manually, we user the server provided via either
|
|
10348
10334
|
2. Snippet via /mparticle.js endpoint (config.dataPlan.document)
|
|
10349
10335
|
3. Self hosting via /config endpoint (config.dataPlanResult)
|
|
10350
10336
|
*/
|
|
10351
|
-
|
|
10352
10337
|
if (config.dataPlanOptions) {
|
|
10353
10338
|
mpInstance.Logger.verbose('Customer provided data plan found');
|
|
10354
10339
|
kitBlockOptions = config.dataPlanOptions;
|
|
@@ -10406,7 +10391,6 @@ var mParticle = (function () {
|
|
|
10406
10391
|
mpInstance._Store = new Store(config, mpInstance, apiKey);
|
|
10407
10392
|
window.mParticle.Store = mpInstance._Store;
|
|
10408
10393
|
mpInstance.Logger.verbose(StartingInitialization);
|
|
10409
|
-
|
|
10410
10394
|
// Check to see if localStorage is available before main configuration runs
|
|
10411
10395
|
// since we will need this for the current implementation of user persistence
|
|
10412
10396
|
// TODO: Refactor this when we refactor User Identity Persistence
|
|
@@ -10649,25 +10633,26 @@ var mParticle = (function () {
|
|
|
10649
10633
|
if (!Array.prototype.filter) {
|
|
10650
10634
|
Array.prototype.filter = Polyfill.filter;
|
|
10651
10635
|
}
|
|
10636
|
+
// https://go.mparticle.com/work/SQDSDKS-6768
|
|
10652
10637
|
if (!Array.isArray) {
|
|
10638
|
+
// @ts-ignore
|
|
10653
10639
|
Array.prototype.isArray = Polyfill.isArray;
|
|
10654
10640
|
}
|
|
10655
|
-
function
|
|
10641
|
+
function mParticleInstanceManager() {
|
|
10656
10642
|
var self = this;
|
|
10657
10643
|
// Only leaving this here in case any clients are trying to access mParticle.Store, to prevent from throwing
|
|
10658
10644
|
this.Store = {};
|
|
10659
10645
|
this._instances = {};
|
|
10660
10646
|
this.IdentityType = Types.IdentityType;
|
|
10661
|
-
this.EventType =
|
|
10662
|
-
this.CommerceEventType =
|
|
10663
|
-
this.PromotionType =
|
|
10664
|
-
this.ProductActionType =
|
|
10647
|
+
this.EventType = EventType;
|
|
10648
|
+
this.CommerceEventType = CommerceEventType;
|
|
10649
|
+
this.PromotionType = PromotionActionType;
|
|
10650
|
+
this.ProductActionType = ProductActionType;
|
|
10665
10651
|
this.MPSideloadedKit = MPSideloadedKit;
|
|
10666
10652
|
if (typeof window !== 'undefined') {
|
|
10667
10653
|
this.isIOS = window.mParticle && window.mParticle.isIOS ? window.mParticle.isIOS : false;
|
|
10668
10654
|
this.config = window.mParticle && window.mParticle.config ? window.mParticle.config : {};
|
|
10669
10655
|
}
|
|
10670
|
-
|
|
10671
10656
|
/**
|
|
10672
10657
|
* Initializes the mParticle instance. If no instanceName is provided, an instance name of `default_instance` will be used.
|
|
10673
10658
|
* <p>
|
|
@@ -10685,7 +10670,7 @@ var mParticle = (function () {
|
|
|
10685
10670
|
instanceName = (!instanceName || instanceName.length === 0 ? Constants.DefaultInstance : instanceName).toLowerCase();
|
|
10686
10671
|
var client = self._instances[instanceName];
|
|
10687
10672
|
if (client === undefined) {
|
|
10688
|
-
client = new mParticleInstance(
|
|
10673
|
+
client = new mParticleInstance(instanceName);
|
|
10689
10674
|
self._instances[instanceName] = client;
|
|
10690
10675
|
}
|
|
10691
10676
|
client.init(apiKey, config, instanceName);
|
|
@@ -10923,12 +10908,17 @@ var mParticle = (function () {
|
|
|
10923
10908
|
self.getInstance()._setWrapperSDKInfo(name, version);
|
|
10924
10909
|
};
|
|
10925
10910
|
}
|
|
10926
|
-
var
|
|
10911
|
+
var mParticleManager = new mParticleInstanceManager();
|
|
10927
10912
|
if (typeof window !== 'undefined') {
|
|
10928
|
-
|
|
10913
|
+
// mParticle is the global object used to access the SDK and predates instance manager,
|
|
10914
|
+
// when mParticle was a singleton. We now support multiple instances. Calling methods
|
|
10915
|
+
// on mParticle directly will access the default instance, but mParticle can also be used
|
|
10916
|
+
// as the instance manager in self hosted mode.
|
|
10917
|
+
window.mParticle = mParticleManager;
|
|
10918
|
+
// https://go.mparticle.com/work/SQDSDKS-5053
|
|
10929
10919
|
window.mParticle._BatchValidator = new _BatchValidator();
|
|
10930
10920
|
}
|
|
10931
10921
|
|
|
10932
|
-
return
|
|
10922
|
+
return mParticleManager;
|
|
10933
10923
|
|
|
10934
10924
|
})();
|
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;
|
|
@@ -115,10 +115,10 @@ export interface IdentityModifyResultBody {
|
|
|
115
115
|
}
|
|
116
116
|
|
|
117
117
|
export interface mParticleUserCart {
|
|
118
|
-
add(product:
|
|
119
|
-
remove(product:
|
|
118
|
+
add(product: SDKProduct | SDKProduct[], logEvent: boolean): void;
|
|
119
|
+
remove(product: SDKProduct | SDKProduct[], logEvent: boolean): void;
|
|
120
120
|
clear(): void;
|
|
121
|
-
getCartProducts():
|
|
121
|
+
getCartProducts(): SDKProduct[];
|
|
122
122
|
}
|
|
123
123
|
|
|
124
124
|
// https://go.mparticle.com/work/SQDSDKS-5196
|