@mparticle/web-sdk 3.29.1 → 3.31.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +262 -18
- package/dist/mparticle.common.js +1 -1
- package/dist/mparticle.esm.js +1 -1
- package/dist/mparticle.js +105 -56
- package/dist/types/src/buttonTracking/buttonTracker.d.ts +1 -0
- package/dist/types/src/buttonTracking/checkoutIntent.d.ts +6 -2
- package/dist/types/src/internal-types.d.ts +1 -1
- package/dist/types/src/reporting/types.d.ts +1 -0
- package/dist/types/src/roktManager.d.ts +4 -1
- package/package.json +1 -1
- package/src/buttonTracking/buttonTracker.ts +18 -2
- package/src/buttonTracking/checkoutIntent.ts +62 -7
- package/src/ecommerce.ts +3 -3
- package/src/events.ts +2 -2
- package/src/forwarders.ts +3 -3
- package/src/identity.ts +4 -3
- package/src/internal-types.ts +1 -0
- package/src/kitBlocking.ts +4 -3
- package/src/mp-instance.ts +6 -6
- package/src/persistence.ts +9 -9
- package/src/reporting/types.ts +1 -0
- package/src/roktManager.ts +22 -8
package/dist/mparticle.js
CHANGED
|
@@ -204,7 +204,7 @@ var mParticle = (function () {
|
|
|
204
204
|
Base64: Base64$1
|
|
205
205
|
};
|
|
206
206
|
|
|
207
|
-
var version = "3.
|
|
207
|
+
var version = "3.31.0";
|
|
208
208
|
|
|
209
209
|
var Constants = {
|
|
210
210
|
sdkVersion: version,
|
|
@@ -4515,7 +4515,8 @@ var mParticle = (function () {
|
|
|
4515
4515
|
UNHANDLED_EXCEPTION: 'UNHANDLED_EXCEPTION',
|
|
4516
4516
|
IDENTITY_REQUEST: 'IDENTITY_REQUEST',
|
|
4517
4517
|
IDENTITY_MISMATCH: 'IDENTITY_MISMATCH',
|
|
4518
|
-
MP_DEPRECATED_METHOD_USAGE: 'MP_DEPRECATED_METHOD_USAGE'
|
|
4518
|
+
MP_DEPRECATED_METHOD_USAGE: 'MP_DEPRECATED_METHOD_USAGE',
|
|
4519
|
+
SELECT_PLACEMENTS_IDENTITY_IN_FLIGHT: 'SELECT_PLACEMENTS_IDENTITY_IN_FLIGHT'
|
|
4519
4520
|
};
|
|
4520
4521
|
var WSDKErrorSeverity = {
|
|
4521
4522
|
ERROR: 'ERROR',
|
|
@@ -6125,7 +6126,7 @@ var mParticle = (function () {
|
|
|
6125
6126
|
mpInstance.Logger.error('Price is required when creating a product, and must be a string or a number');
|
|
6126
6127
|
return null;
|
|
6127
6128
|
} else {
|
|
6128
|
-
price =
|
|
6129
|
+
price = parseNumber(price);
|
|
6129
6130
|
}
|
|
6130
6131
|
if (position && !mpInstance._Helpers.Validators.isNumber(position)) {
|
|
6131
6132
|
mpInstance.Logger.error('Position must be a number, it will be set to null.');
|
|
@@ -6134,7 +6135,7 @@ var mParticle = (function () {
|
|
|
6134
6135
|
if (!mpInstance._Helpers.Validators.isStringOrNumber(quantity)) {
|
|
6135
6136
|
quantity = 1;
|
|
6136
6137
|
} else {
|
|
6137
|
-
quantity =
|
|
6138
|
+
quantity = parseNumber(quantity);
|
|
6138
6139
|
}
|
|
6139
6140
|
return {
|
|
6140
6141
|
Name: name,
|
|
@@ -6317,7 +6318,7 @@ var mParticle = (function () {
|
|
|
6317
6318
|
return 0;
|
|
6318
6319
|
}
|
|
6319
6320
|
// if amount is a string, it will be parsed into a number if possible, or set to 0
|
|
6320
|
-
return
|
|
6321
|
+
return parseNumber(amount);
|
|
6321
6322
|
};
|
|
6322
6323
|
}
|
|
6323
6324
|
|
|
@@ -7233,7 +7234,7 @@ var mParticle = (function () {
|
|
|
7233
7234
|
return null;
|
|
7234
7235
|
}
|
|
7235
7236
|
var record = JSON.parse(decoded);
|
|
7236
|
-
return
|
|
7237
|
+
return isObject(record) && Object.keys(record).length ? record : null;
|
|
7237
7238
|
}
|
|
7238
7239
|
this.getLocalStorage = function () {
|
|
7239
7240
|
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
@@ -7433,7 +7434,7 @@ var mParticle = (function () {
|
|
|
7433
7434
|
if (Array.isArray(value)) {
|
|
7434
7435
|
return value.length > 0;
|
|
7435
7436
|
}
|
|
7436
|
-
if (!
|
|
7437
|
+
if (!isObject(value)) {
|
|
7437
7438
|
return false;
|
|
7438
7439
|
}
|
|
7439
7440
|
return Object.keys(value).length > 0;
|
|
@@ -7465,7 +7466,7 @@ var mParticle = (function () {
|
|
|
7465
7466
|
}
|
|
7466
7467
|
function encodeMpidBase64Field(container, key) {
|
|
7467
7468
|
var value = container[key];
|
|
7468
|
-
if (
|
|
7469
|
+
if (isObject(value) && Object.keys(value).length) {
|
|
7469
7470
|
container[key] = Base64.encode(JSON.stringify(value));
|
|
7470
7471
|
return;
|
|
7471
7472
|
}
|
|
@@ -7536,7 +7537,7 @@ var mParticle = (function () {
|
|
|
7536
7537
|
continue;
|
|
7537
7538
|
}
|
|
7538
7539
|
if (!SDKv2NonMPIDCookieKeys[mpid]) {
|
|
7539
|
-
if (!
|
|
7540
|
+
if (!isObject(persistence[mpid])) {
|
|
7540
7541
|
delete persistence[mpid];
|
|
7541
7542
|
continue;
|
|
7542
7543
|
}
|
|
@@ -7556,7 +7557,7 @@ var mParticle = (function () {
|
|
|
7556
7557
|
return;
|
|
7557
7558
|
}
|
|
7558
7559
|
var persistence = JSON.parse(revertCookieString(persistenceString));
|
|
7559
|
-
if (
|
|
7560
|
+
if (isObject(persistence) && Object.keys(persistence).length) {
|
|
7560
7561
|
decodeGlobalSettings(persistence.gs);
|
|
7561
7562
|
decodeMpidRecords(persistence);
|
|
7562
7563
|
}
|
|
@@ -7601,7 +7602,7 @@ var mParticle = (function () {
|
|
|
7601
7602
|
if (csd) {
|
|
7602
7603
|
var persistence = self.getPersistence();
|
|
7603
7604
|
if (persistence) {
|
|
7604
|
-
if (
|
|
7605
|
+
if (isObject(persistence[mpid])) {
|
|
7605
7606
|
persistence[mpid].csd = csd;
|
|
7606
7607
|
} else {
|
|
7607
7608
|
persistence[mpid] = {
|
|
@@ -7682,7 +7683,7 @@ var mParticle = (function () {
|
|
|
7682
7683
|
}
|
|
7683
7684
|
var persistence = self.getPersistence();
|
|
7684
7685
|
if (persistence) {
|
|
7685
|
-
if (!
|
|
7686
|
+
if (!isObject(persistence[mpid])) {
|
|
7686
7687
|
persistence[mpid] = {};
|
|
7687
7688
|
}
|
|
7688
7689
|
if (!persistence[mpid].fst) {
|
|
@@ -7720,7 +7721,7 @@ var mParticle = (function () {
|
|
|
7720
7721
|
time = new Date().getTime();
|
|
7721
7722
|
}
|
|
7722
7723
|
var persistence = self.getPersistence();
|
|
7723
|
-
if (persistence &&
|
|
7724
|
+
if (persistence && isObject(persistence[mpid])) {
|
|
7724
7725
|
persistence[mpid].lst = time;
|
|
7725
7726
|
self.savePersistence(persistence);
|
|
7726
7727
|
}
|
|
@@ -7874,7 +7875,7 @@ var mParticle = (function () {
|
|
|
7874
7875
|
event.CustomFlags = event.CustomFlags || {};
|
|
7875
7876
|
event.CustomFlags['Rokt.CommerceEventType'] = Types.ProductActionType.getExpansionName(productActionType);
|
|
7876
7877
|
}
|
|
7877
|
-
if (
|
|
7878
|
+
if (isObject(transactionAttributes)) {
|
|
7878
7879
|
mpInstance._Ecommerce.convertTransactionAttributesToProductAction(transactionAttributes, event.ProductAction);
|
|
7879
7880
|
}
|
|
7880
7881
|
self.logCommerceEvent(event, customAttrs, options);
|
|
@@ -8251,7 +8252,7 @@ var mParticle = (function () {
|
|
|
8251
8252
|
}
|
|
8252
8253
|
};
|
|
8253
8254
|
this.isEnabledForUserAttributes = function (filterObject, user) {
|
|
8254
|
-
if (!filterObject || !
|
|
8255
|
+
if (!filterObject || !isObject(filterObject) || !Object.keys(filterObject).length) {
|
|
8255
8256
|
return true;
|
|
8256
8257
|
}
|
|
8257
8258
|
if (!user) {
|
|
@@ -8259,7 +8260,7 @@ var mParticle = (function () {
|
|
|
8259
8260
|
}
|
|
8260
8261
|
var userAttributes = user.getAllUserAttributes();
|
|
8261
8262
|
try {
|
|
8262
|
-
var hasUserAttributes = userAttributes &&
|
|
8263
|
+
var hasUserAttributes = userAttributes && isObject(userAttributes) && Object.keys(userAttributes).length > 0;
|
|
8263
8264
|
var isMatch = hasUserAttributes ? userAttributesMatchFilter(userAttributes, filterObject) : false;
|
|
8264
8265
|
return filterObject.includeOnMatch === isMatch;
|
|
8265
8266
|
} catch (e) {
|
|
@@ -9617,7 +9618,7 @@ var mParticle = (function () {
|
|
|
9617
9618
|
var userAttributes = this.getAllUserAttributes();
|
|
9618
9619
|
var previousUserAttributeValue = void 0;
|
|
9619
9620
|
var isNewAttribute = void 0;
|
|
9620
|
-
var existingProp =
|
|
9621
|
+
var existingProp = findKeyInObject(userAttributes, key);
|
|
9621
9622
|
if (existingProp) {
|
|
9622
9623
|
isNewAttribute = false;
|
|
9623
9624
|
previousUserAttributeValue = userAttributes[existingProp];
|
|
@@ -9674,7 +9675,7 @@ var mParticle = (function () {
|
|
|
9674
9675
|
} else {
|
|
9675
9676
|
cookies = mpInstance._Persistence.getPersistence();
|
|
9676
9677
|
userAttributes = this.getAllUserAttributes();
|
|
9677
|
-
var existingProp =
|
|
9678
|
+
var existingProp = findKeyInObject(userAttributes, key);
|
|
9678
9679
|
if (existingProp) {
|
|
9679
9680
|
key = existingProp;
|
|
9680
9681
|
}
|
|
@@ -9717,7 +9718,7 @@ var mParticle = (function () {
|
|
|
9717
9718
|
var previousUserAttributeValue = void 0;
|
|
9718
9719
|
var isNewAttribute = void 0;
|
|
9719
9720
|
var userAttributeChange = void 0;
|
|
9720
|
-
var existingProp =
|
|
9721
|
+
var existingProp = findKeyInObject(userAttributes, key);
|
|
9721
9722
|
if (existingProp) {
|
|
9722
9723
|
isNewAttribute = false;
|
|
9723
9724
|
previousUserAttributeValue = userAttributes[existingProp];
|
|
@@ -10771,7 +10772,7 @@ var mParticle = (function () {
|
|
|
10771
10772
|
var clonedEvent = __assign({}, event);
|
|
10772
10773
|
if (this.blockUserAttributes) {
|
|
10773
10774
|
var matchedAttributes = this.dataPlanMatchLookups['user_attributes'];
|
|
10774
|
-
if (
|
|
10775
|
+
if (isObject(matchedAttributes) && clonedEvent.UserAttributes) {
|
|
10775
10776
|
var plannedUserAttributes = {};
|
|
10776
10777
|
for (var _i = 0, _a = Object.keys(clonedEvent.UserAttributes); _i < _a.length; _i++) {
|
|
10777
10778
|
var ua = _a[_i];
|
|
@@ -10829,15 +10830,14 @@ var mParticle = (function () {
|
|
|
10829
10830
|
return false;
|
|
10830
10831
|
};
|
|
10831
10832
|
KitBlocker.prototype.transformUserIdentities = function (event) {
|
|
10832
|
-
var _this = this;
|
|
10833
10833
|
var _a;
|
|
10834
10834
|
var clonedEvent = __assign({}, event);
|
|
10835
10835
|
if (this.blockUserIdentities) {
|
|
10836
10836
|
var matchedIdentities_1 = this.dataPlanMatchLookups['user_identities'];
|
|
10837
|
-
if (
|
|
10837
|
+
if (isObject(matchedIdentities_1)) {
|
|
10838
10838
|
if ((_a = clonedEvent === null || clonedEvent === void 0 ? void 0 : clonedEvent.UserIdentities) === null || _a === void 0 ? void 0 : _a.length) {
|
|
10839
10839
|
clonedEvent.UserIdentities = clonedEvent.UserIdentities.filter(function (uiByType) {
|
|
10840
|
-
var identityName = Types.IdentityType.getIdentityName(
|
|
10840
|
+
var identityName = Types.IdentityType.getIdentityName(parseNumber(uiByType.Type));
|
|
10841
10841
|
return matchedIdentities_1[identityName];
|
|
10842
10842
|
});
|
|
10843
10843
|
}
|
|
@@ -11410,6 +11410,12 @@ var mParticle = (function () {
|
|
|
11410
11410
|
(_a = this.logger) === null || _a === void 0 ? void 0 : _a.error("RoktManager: Error in onCheckoutIntent: ".concat(getErrorMessage(e)));
|
|
11411
11411
|
}
|
|
11412
11412
|
};
|
|
11413
|
+
// Read at click time, so selectors from a kit that attaches later apply to
|
|
11414
|
+
// the next click.
|
|
11415
|
+
RoktManager.prototype.getCheckoutIntentSelectors = function () {
|
|
11416
|
+
var kit = this.kit;
|
|
11417
|
+
return kit ? kit.checkoutIntentSelectors : undefined;
|
|
11418
|
+
};
|
|
11413
11419
|
RoktManager.prototype.discardCheckoutIntents = function () {
|
|
11414
11420
|
this.pendingCheckoutIntents = [];
|
|
11415
11421
|
};
|
|
@@ -11470,26 +11476,33 @@ var mParticle = (function () {
|
|
|
11470
11476
|
* });
|
|
11471
11477
|
*/
|
|
11472
11478
|
RoktManager.prototype.selectPlacements = function (options) {
|
|
11473
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
11479
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
11474
11480
|
return __awaiter(this, void 0, void 0, function () {
|
|
11475
11481
|
var attributes, sandboxValue, mappedAttributes, attributesToLog, currentUserIdentities, currentEmail, newEmail, currentHashedEmail, newHashedEmail, isValidHashedEmailIdentityType, emailChanged, hashedEmailChanged, newIdentities_1, msg, msg, userAttributes_1, roktUser, roktUserIdentities, timeOnSite, totalTimeOnSite, enrichedAttributes, hashedEmail, capturedAttrs, passbackId, enrichedOptions;
|
|
11476
11482
|
var _this = this;
|
|
11477
|
-
return __generator(this, function (
|
|
11483
|
+
return __generator(this, function (_u) {
|
|
11478
11484
|
(_a = this.captureTiming) === null || _a === void 0 ? void 0 : _a.call(this, PerformanceMarkType.JointSdkSelectPlacements);
|
|
11479
|
-
|
|
11480
|
-
if (!this.isReady() || ((_b = this.store) === null || _b === void 0 ? void 0 : _b.identityCallInFlight)) {
|
|
11485
|
+
if (!this.isReady()) {
|
|
11481
11486
|
return [2 /*return*/, this.deferredCall('selectPlacements', options)];
|
|
11482
11487
|
}
|
|
11488
|
+
// Like the iOS and Android SDKs, this does not wait for an identity request, so the
|
|
11489
|
+
// selection can go out for the user from before it. The log counts how often that happens.
|
|
11490
|
+
if ((_b = this.store) === null || _b === void 0 ? void 0 : _b.identityCallInFlight) {
|
|
11491
|
+
(_c = this.loggingService) === null || _c === void 0 ? void 0 : _c.log({
|
|
11492
|
+
message: 'RoktManager: selectPlacements ran while an identity request was in flight',
|
|
11493
|
+
code: ErrorCodes.SELECT_PLACEMENTS_IDENTITY_IN_FLIGHT
|
|
11494
|
+
});
|
|
11495
|
+
}
|
|
11483
11496
|
try {
|
|
11484
11497
|
attributes = options.attributes;
|
|
11485
11498
|
sandboxValue = (attributes === null || attributes === void 0 ? void 0 : attributes.sandbox) || null;
|
|
11486
11499
|
mappedAttributes = this.mapPlacementAttributes(attributes, this.placementAttributesMapping);
|
|
11487
|
-
if ((
|
|
11488
|
-
attributesToLog = obfuscateDevData(attributes, (
|
|
11500
|
+
if ((_d = this.logger) === null || _d === void 0 ? void 0 : _d.isVerbose()) {
|
|
11501
|
+
attributesToLog = obfuscateDevData(attributes, (_f = (_e = this.store) === null || _e === void 0 ? void 0 : _e.SDKConfig) === null || _f === void 0 ? void 0 : _f.isDevelopmentMode);
|
|
11489
11502
|
this.logger.verbose("mParticle.Rokt selectPlacements called with attributes:\n".concat(JSON.stringify(attributesToLog, null, 2)));
|
|
11490
11503
|
}
|
|
11491
11504
|
this.currentUser = this.identityService.getCurrentUser();
|
|
11492
|
-
currentUserIdentities = ((
|
|
11505
|
+
currentUserIdentities = ((_h = (_g = this.currentUser) === null || _g === void 0 ? void 0 : _g.getUserIdentities()) === null || _h === void 0 ? void 0 : _h.userIdentities) || {};
|
|
11493
11506
|
currentEmail = currentUserIdentities.email;
|
|
11494
11507
|
newEmail = mappedAttributes.email;
|
|
11495
11508
|
currentHashedEmail = void 0;
|
|
@@ -11507,7 +11520,7 @@ var mParticle = (function () {
|
|
|
11507
11520
|
if (newEmail) {
|
|
11508
11521
|
msg = 'Email mismatch detected. Current email differs from email passed to selectPlacements call. Proceeding to call identify with email from selectPlacements call. Please verify your implementation.';
|
|
11509
11522
|
this.logger.warning(msg);
|
|
11510
|
-
(
|
|
11523
|
+
(_j = this.errorReporter) === null || _j === void 0 ? void 0 : _j.report({
|
|
11511
11524
|
message: msg,
|
|
11512
11525
|
code: ErrorCodes.IDENTITY_MISMATCH,
|
|
11513
11526
|
severity: WSDKErrorSeverity.WARNING
|
|
@@ -11518,7 +11531,7 @@ var mParticle = (function () {
|
|
|
11518
11531
|
newIdentities_1[this.mappedEmailShaIdentityType] = newHashedEmail;
|
|
11519
11532
|
msg = 'emailsha256 mismatch detected. Current mParticle hashedEmail differs from hashedEmail passed to selectPlacements call. Proceeding to call identify with hashedEmail from selectPlacements call. Please verify your implementation.';
|
|
11520
11533
|
this.logger.warning(msg);
|
|
11521
|
-
(
|
|
11534
|
+
(_k = this.errorReporter) === null || _k === void 0 ? void 0 : _k.report({
|
|
11522
11535
|
message: msg,
|
|
11523
11536
|
code: ErrorCodes.IDENTITY_MISMATCH,
|
|
11524
11537
|
severity: WSDKErrorSeverity.WARNING
|
|
@@ -11539,10 +11552,6 @@ var mParticle = (function () {
|
|
|
11539
11552
|
_this.logger.error('Background identify failed with HTTP ' + httpCode);
|
|
11540
11553
|
}
|
|
11541
11554
|
_this.setUserAttributes((_a = result === null || result === void 0 ? void 0 : result.getUser) === null || _a === void 0 ? void 0 : _a.call(result), userAttributes_1, newIdentities_1);
|
|
11542
|
-
// Drain any selectPlacements calls that were deferred while
|
|
11543
|
-
// identify was in-flight. By the time this callback fires,
|
|
11544
|
-
// identityCallInFlight has already been reset to false.
|
|
11545
|
-
_this.processMessageQueue();
|
|
11546
11555
|
});
|
|
11547
11556
|
} catch (error) {
|
|
11548
11557
|
this.logger.error('Background identify threw an error: ' + getErrorMessage(error));
|
|
@@ -11550,9 +11559,9 @@ var mParticle = (function () {
|
|
|
11550
11559
|
}
|
|
11551
11560
|
}
|
|
11552
11561
|
roktUser = this.currentUser && this.createFilteredUser ? this.createFilteredUser(this.currentUser.getMPID()) : null;
|
|
11553
|
-
roktUserIdentities = ((
|
|
11554
|
-
timeOnSite = (
|
|
11555
|
-
totalTimeOnSite = (
|
|
11562
|
+
roktUserIdentities = ((_l = roktUser === null || roktUser === void 0 ? void 0 : roktUser.getUserIdentities()) === null || _l === void 0 ? void 0 : _l.userIdentities) || {};
|
|
11563
|
+
timeOnSite = (_o = (_m = this.store) === null || _m === void 0 ? void 0 : _m.getTimeOnSite) === null || _o === void 0 ? void 0 : _o.call(_m);
|
|
11564
|
+
totalTimeOnSite = (_q = (_p = this.store) === null || _p === void 0 ? void 0 : _p.getTotalTimeOnSite) === null || _q === void 0 ? void 0 : _q.call(_p);
|
|
11556
11565
|
enrichedAttributes = __assign(__assign(__assign(__assign({}, mappedAttributes), sandboxValue !== null ? {
|
|
11557
11566
|
sandbox: sandboxValue
|
|
11558
11567
|
} : {}), timeOnSite ? {
|
|
@@ -11578,9 +11587,9 @@ var mParticle = (function () {
|
|
|
11578
11587
|
}
|
|
11579
11588
|
}
|
|
11580
11589
|
if (!enrichedAttributes[PASSBACK_CONVERSION_TRACKING_ID]) {
|
|
11581
|
-
(
|
|
11582
|
-
capturedAttrs = (
|
|
11583
|
-
passbackId = (
|
|
11590
|
+
(_r = this.integrationCapture) === null || _r === void 0 ? void 0 : _r.capture();
|
|
11591
|
+
capturedAttrs = (_s = this.integrationCapture) === null || _s === void 0 ? void 0 : _s.getClickIdsAsIntegrationAttributes();
|
|
11592
|
+
passbackId = (_t = capturedAttrs === null || capturedAttrs === void 0 ? void 0 : capturedAttrs[PARTNER_MODULE_IDS.Rokt]) === null || _t === void 0 ? void 0 : _t[PASSBACK_CONVERSION_TRACKING_ID];
|
|
11584
11593
|
if (passbackId) {
|
|
11585
11594
|
enrichedAttributes[PASSBACK_CONVERSION_TRACKING_ID] = passbackId;
|
|
11586
11595
|
}
|
|
@@ -11860,7 +11869,6 @@ var mParticle = (function () {
|
|
|
11860
11869
|
RoktManager.prototype.onIdentityComplete = function () {
|
|
11861
11870
|
if (this.isReady()) {
|
|
11862
11871
|
this.currentUser = this.identityService.getCurrentUser();
|
|
11863
|
-
// Process any queued selectPlacements calls that were waiting for identity
|
|
11864
11872
|
this.processMessageQueue();
|
|
11865
11873
|
}
|
|
11866
11874
|
};
|
|
@@ -13394,7 +13402,7 @@ var mParticle = (function () {
|
|
|
13394
13402
|
// places, submits or completes counts as the confirm click.
|
|
13395
13403
|
var linkCommits = new RegExp('^(?:(?:place|submit|complete)(?!(?: [^ ]+){0,2} (?:another|new|next)(?: |$))(?: [^ ]+){0,2} (?:order|purchase)|' + otherCommits + ')$');
|
|
13396
13404
|
var routeGatedCommits = new RegExp('^(?:buy now|purchase|register(?: now)?|complete (?:my |your )?registration|jetzt kaufen|kaufen|commander|(?:passer|valider) (?:la |ma )?commande|finalizar (?:la |mi )?compra|' + 'comprar ahora|acquista ora|nu kopen|\u4ECA\u3059\u3050\u8CFC\u5165|\u8CFC\u5165\u3059\u308B|\u3053\u306E\u5185\u5BB9\u3067\u7533\u3057\u8FBC\u3080)$');
|
|
13397
|
-
var steps = new RegExp('^(?:' + ["(?:let's |lets |go to |proceed to |secure )?(?:check ?out|checkout)(?: now| securely| as guest)?", '(?:continue|proceed) to (?:payment|review|billing|shipping|delivery|order review)|review (?:my |your )?order', 'guest checkout|(?:pay|continue|check ?out) (?:with|by) (?:card|credit card|debit card|credit or debit card)', 'zur kasse|zur kasse gehen|auschecken|weiter zur zahlung', 'passer \u00E0 la caisse|continuer vers le paiement|proc\u00E9der au paiement', 'ir a caja|continuar al pago|tramitar pedido', "procedi al checkout|procedi all'acquisto|procedi al pagamento|vai alla cassa", 'afrekenen|verder naar betalen|doorgaan naar betalen', '\u30EC\u30B8\u306B\u9032\u3080|\u3054?(?:\u8CFC\u5165|\u6CE8\u6587)\u624B\u7D9A\u304D(?:\u3078|\u306B)(?:\u9032\u3080)?|\u304A?\u652F\u6255\u3044(?:\u3078|\u306B)\u9032\u3080|(?:\u3054\u6CE8\u6587\u5185\u5BB9\u306E)?\u78BA\u8A8D\u753B\u9762\u3078(?:\u9032\u3080)?'].join('|') + ')$');
|
|
13405
|
+
var steps = new RegExp('^(?:' + ["(?:let's |lets |go to |proceed to |secure )?(?:check ?out|checkout)(?: now| securely| as guest)?", '(?:continue|proceed) to (?:payment|review|billing|shipping|delivery|order review)|review (?:my |your )?order', 'guest checkout|(?:pay|continue|check ?out) (?:with|by) (?:card|credit card|debit card|credit or debit card)', 'zur kasse|zur kasse gehen|auschecken|weiter zur zahlung', 'passer \u00E0 la caisse|continuer vers le paiement|proc\u00E9der au paiement', 'ir a caja|continuar al pago|tramitar pedido', "procedi al checkout|procedi all'acquisto|procedi al pagamento|vai alla cassa", 'afrekenen|verder naar betalen|doorgaan naar betalen', '\u30EC\u30B8\u306B\u9032\u3080|\u3054?(?:\u8CFC\u5165|\u6CE8\u6587)\u624B\u7D9A\u304D(?:(?:\u3078|\u306B)(?:\u9032\u3080)?)?|\u304A?\u652F\u6255\u3044(?:\u3078|\u306B)\u9032\u3080|(?:\u3054\u6CE8\u6587\u5185\u5BB9\u306E)?\u78BA\u8A8D\u753B\u9762\u3078(?:\u9032\u3080)?'].join('|') + ')$');
|
|
13398
13406
|
// "Save and continue" also saves profile, address and card forms, so it is a step only on a checkout segment's route
|
|
13399
13407
|
// that isn't an account or confirmation page.
|
|
13400
13408
|
var routeGatedSteps = /^save and continue$/;
|
|
@@ -13511,6 +13519,19 @@ var mParticle = (function () {
|
|
|
13511
13519
|
return openCartLabels.test(text);
|
|
13512
13520
|
}) ? 'open' : undefined;
|
|
13513
13521
|
}
|
|
13522
|
+
// A selector the browser can't parse is skipped rather than thrown.
|
|
13523
|
+
function matchesAnySelector(control, selectors) {
|
|
13524
|
+
if (!selectors) {
|
|
13525
|
+
return false;
|
|
13526
|
+
}
|
|
13527
|
+
return selectors.some(function (selector) {
|
|
13528
|
+
try {
|
|
13529
|
+
return control.matches(selector);
|
|
13530
|
+
} catch (e) {
|
|
13531
|
+
return false;
|
|
13532
|
+
}
|
|
13533
|
+
});
|
|
13534
|
+
}
|
|
13514
13535
|
// Every field the browser counts as the form's own, form-attribute fields included. Read through the native getter
|
|
13515
13536
|
// where the browser has one, since a field named "elements" shadows the form's own property.
|
|
13516
13537
|
function formFields(form) {
|
|
@@ -13534,11 +13555,14 @@ var mParticle = (function () {
|
|
|
13534
13555
|
}
|
|
13535
13556
|
// Classifies a clicked or submitting control found by findControl, in order:
|
|
13536
13557
|
// pickers, toggles and pay-later messages never count; a vendor's own wallet
|
|
13537
|
-
// button
|
|
13538
|
-
//
|
|
13539
|
-
//
|
|
13540
|
-
//
|
|
13541
|
-
|
|
13558
|
+
// button keeps its vendor kind; a control matching a kit-supplied commit
|
|
13559
|
+
// selector counts as a commit before any label rule, and one matching a
|
|
13560
|
+
// checkout-step selector as a step unless its labels make it a confirm, a
|
|
13561
|
+
// wallet or an add-to-cart click; a confirm label on any source
|
|
13562
|
+
// counts before the look-alike exclusions veto; then a wallet-named control,
|
|
13563
|
+
// wallet phrases and steps. An add-to-cart label, links included, or a control
|
|
13564
|
+
// that opens the cart on the page counts only where none of those do.
|
|
13565
|
+
function classifyIntent(control, pathname, selectors) {
|
|
13542
13566
|
var vendor = vendorButtonKind(control);
|
|
13543
13567
|
if (vendor === 'none') {
|
|
13544
13568
|
return undefined;
|
|
@@ -13549,6 +13573,27 @@ var mParticle = (function () {
|
|
|
13549
13573
|
source: 'vendor'
|
|
13550
13574
|
};
|
|
13551
13575
|
}
|
|
13576
|
+
if (selectors && !isQuietIntentControl(control, false)) {
|
|
13577
|
+
if (matchesAnySelector(control, selectors.commit)) {
|
|
13578
|
+
return {
|
|
13579
|
+
kind: 'commit',
|
|
13580
|
+
source: 'selector'
|
|
13581
|
+
};
|
|
13582
|
+
}
|
|
13583
|
+
if (matchesAnySelector(control, selectors.checkout_step)) {
|
|
13584
|
+
// A confirm, wallet or add-to-cart label still wins, so a class those
|
|
13585
|
+
// buttons share with a step button can't turn their clicks into steps.
|
|
13586
|
+
var byLabel = classifyLabels(control, pathname);
|
|
13587
|
+
return byLabel && (byLabel.kind === 'commit' || byLabel.kind === 'wallet' || byLabel.adds === true) ? byLabel : {
|
|
13588
|
+
kind: 'checkout_step',
|
|
13589
|
+
source: 'selector'
|
|
13590
|
+
};
|
|
13591
|
+
}
|
|
13592
|
+
}
|
|
13593
|
+
return classifyLabels(control, pathname);
|
|
13594
|
+
}
|
|
13595
|
+
// The label rules, read once the vendor and selector checks have passed.
|
|
13596
|
+
function classifyLabels(control, pathname) {
|
|
13552
13597
|
var texts = labels(control);
|
|
13553
13598
|
var cores = texts.map(coreLabel);
|
|
13554
13599
|
var cartAction = cartControlAction(control, cores);
|
|
@@ -14045,7 +14090,7 @@ var mParticle = (function () {
|
|
|
14045
14090
|
}
|
|
14046
14091
|
if (control && !withheld) {
|
|
14047
14092
|
// Checkout intent is only worked out when the kit can use it.
|
|
14048
|
-
var intent = signalsKit ? classifyIntent(control, pathname) : undefined;
|
|
14093
|
+
var intent = signalsKit ? classifyIntent(control, pathname, this.checkoutIntentSelectors()) : undefined;
|
|
14049
14094
|
kind = intent ? intent.kind : undefined;
|
|
14050
14095
|
source = intent ? intent.source : undefined;
|
|
14051
14096
|
adds = intent ? intent.adds : undefined;
|
|
@@ -14077,7 +14122,7 @@ var mParticle = (function () {
|
|
|
14077
14122
|
kind = 'commit';
|
|
14078
14123
|
source = 'submit';
|
|
14079
14124
|
} else if (control) {
|
|
14080
|
-
var intent = classifyIntent(control, pathname);
|
|
14125
|
+
var intent = classifyIntent(control, pathname, this.checkoutIntentSelectors());
|
|
14081
14126
|
kind = intent ? intent.kind : undefined;
|
|
14082
14127
|
source = intent ? intent.source : undefined;
|
|
14083
14128
|
adds = intent ? intent.adds : undefined;
|
|
@@ -14207,6 +14252,10 @@ var mParticle = (function () {
|
|
|
14207
14252
|
var roktManager = this.mpInstance._RoktManager;
|
|
14208
14253
|
return !this.hasRoktKit || !roktManager || roktManager.isCheckoutIntentSuppressed();
|
|
14209
14254
|
};
|
|
14255
|
+
ButtonTracker.prototype.checkoutIntentSelectors = function () {
|
|
14256
|
+
var roktManager = this.mpInstance._RoktManager;
|
|
14257
|
+
return roktManager ? roktManager.getCheckoutIntentSelectors() : undefined;
|
|
14258
|
+
};
|
|
14210
14259
|
ButtonTracker.prototype.linkClicksReachKit = function () {
|
|
14211
14260
|
var roktManager = this.mpInstance._RoktManager;
|
|
14212
14261
|
return !!roktManager && roktManager.areAutoLinkClicksForwarded();
|
|
@@ -14685,11 +14734,11 @@ var mParticle = (function () {
|
|
|
14685
14734
|
hostname: window.location.hostname,
|
|
14686
14735
|
title: window.document.title
|
|
14687
14736
|
};
|
|
14688
|
-
} else if (!
|
|
14737
|
+
} else if (!isObject(attrs)) {
|
|
14689
14738
|
self.Logger.error('The attributes argument must be an object. A ' + _typeof(attrs) + ' was entered. Please correct and retry.');
|
|
14690
14739
|
return;
|
|
14691
14740
|
}
|
|
14692
|
-
if (customFlags && !
|
|
14741
|
+
if (customFlags && !isObject(customFlags)) {
|
|
14693
14742
|
self.Logger.error('The customFlags argument must be an object. A ' + _typeof(customFlags) + ' was entered. Please correct and retry.');
|
|
14694
14743
|
return;
|
|
14695
14744
|
}
|
|
@@ -14953,7 +15002,7 @@ var mParticle = (function () {
|
|
|
14953
15002
|
value: value
|
|
14954
15003
|
}));
|
|
14955
15004
|
} else {
|
|
14956
|
-
var existingProp =
|
|
15005
|
+
var existingProp = findKeyInObject(self._Store.sessionAttributes, key);
|
|
14957
15006
|
if (existingProp) {
|
|
14958
15007
|
key = existingProp;
|
|
14959
15008
|
}
|
|
@@ -15018,14 +15067,14 @@ var mParticle = (function () {
|
|
|
15018
15067
|
}
|
|
15019
15068
|
if (attrs === null) {
|
|
15020
15069
|
self._Store.integrationAttributes[integrationId] = {};
|
|
15021
|
-
} else if (
|
|
15070
|
+
} else if (isObject(attrs)) {
|
|
15022
15071
|
if (Object.keys(attrs).length === 0) {
|
|
15023
15072
|
self._Store.integrationAttributes[integrationId] = {};
|
|
15024
15073
|
} else {
|
|
15025
15074
|
for (var key in attrs) {
|
|
15026
15075
|
if (typeof key === 'string') {
|
|
15027
15076
|
if (typeof attrs[key] === 'string') {
|
|
15028
|
-
if (
|
|
15077
|
+
if (isObject(self._Store.integrationAttributes[integrationId])) {
|
|
15029
15078
|
self._Store.integrationAttributes[integrationId][key] = attrs[key];
|
|
15030
15079
|
} else {
|
|
15031
15080
|
self._Store.integrationAttributes[integrationId] = {};
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { IButtonClick } from './buttonDescription';
|
|
2
2
|
export type CheckoutIntentKind = 'commit' | 'wallet' | 'checkout_step' | 'frame' | 'cart';
|
|
3
3
|
export type PaymentFrameFamily = 'apple_pay' | 'google_pay' | 'amazon_pay' | 'shop_pay' | 'card';
|
|
4
|
-
export type CheckoutIntentSource = 'vendor' | 'label' | 'brand' | 'frame' | 'submit' | 'name' | 'api';
|
|
4
|
+
export type CheckoutIntentSource = 'vendor' | 'label' | 'brand' | 'frame' | 'submit' | 'name' | 'api' | 'selector';
|
|
5
|
+
export interface ICheckoutIntentSelectors {
|
|
6
|
+
commit?: readonly string[];
|
|
7
|
+
checkout_step?: readonly string[];
|
|
8
|
+
}
|
|
5
9
|
export interface ICheckoutIntent {
|
|
6
10
|
kind: Exclude<CheckoutIntentKind, 'frame'>;
|
|
7
11
|
source: CheckoutIntentSource;
|
|
8
12
|
adds?: true;
|
|
9
13
|
}
|
|
10
|
-
export declare function classifyIntent(control: Element, pathname: string): ICheckoutIntent | undefined;
|
|
14
|
+
export declare function classifyIntent(control: Element, pathname: string, selectors?: ICheckoutIntentSelectors): ICheckoutIntent | undefined;
|
|
11
15
|
export declare function namesWallet(control: Element, click?: IButtonClick): boolean;
|
|
12
16
|
export declare function classifyIntentControl(control: Element, pathname: string): Exclude<CheckoutIntentKind, 'frame'> | undefined;
|
|
13
17
|
export interface IPaymentFrame {
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
*/
|
|
15
15
|
export * from './public-types';
|
|
16
16
|
export type { KitInterface, } from './forwarders.interfaces';
|
|
17
|
-
export type { RoktAttributeValue, RoktAttributeValueType, RoktAttributeValueArray, RoktAttributes, IRoktPartnerExtensionData, IRoktSelectPlacementsOptions, IRoktSelection, IRoktLauncher, IRoktMessage, RoktKitFilterSettings, IRoktKitSettings, IRoktKit, ICheckoutIntentSignal, IRoktOptions, IRoktLauncherOptions, } from './roktManager';
|
|
17
|
+
export type { RoktAttributeValue, RoktAttributeValueType, RoktAttributeValueArray, RoktAttributes, IRoktPartnerExtensionData, IRoktSelectPlacementsOptions, IRoktSelection, IRoktLauncher, IRoktMessage, RoktKitFilterSettings, IRoktKitSettings, IRoktKit, ICheckoutIntentSignal, ICheckoutIntentSelectors, IRoktOptions, IRoktLauncherOptions, } from './roktManager';
|
|
18
18
|
export type { ErrorCodes, WSDKErrorSeverity, } from './reporting/types';
|
|
19
19
|
export type { ISDKError, ISDKLogEntry, IErrorReportingService, ILoggingService, } from './reporting/types';
|
|
20
20
|
export type { SDKEvent, SDKProductAction, SDKProductActionType, SDKPromotionAction, SDKGeoLocation, SDKDataPlan, SDKLoggerApi, SDKConfigApi, IMParticleInstanceManager, } from './sdkRuntimeModels';
|
|
@@ -5,6 +5,7 @@ export declare const ErrorCodes: {
|
|
|
5
5
|
readonly IDENTITY_REQUEST: "IDENTITY_REQUEST";
|
|
6
6
|
readonly IDENTITY_MISMATCH: "IDENTITY_MISMATCH";
|
|
7
7
|
readonly MP_DEPRECATED_METHOD_USAGE: "MP_DEPRECATED_METHOD_USAGE";
|
|
8
|
+
readonly SELECT_PLACEMENTS_IDENTITY_IN_FLIGHT: "SELECT_PLACEMENTS_IDENTITY_IN_FLIGHT";
|
|
8
9
|
};
|
|
9
10
|
export type ErrorCodes = valueof<typeof ErrorCodes>;
|
|
10
11
|
export declare const WSDKErrorSeverity: {
|
|
@@ -9,7 +9,8 @@ import { MPID } from "@mparticle/web-sdk";
|
|
|
9
9
|
import { IErrorReportingService, ILoggingService } from "./reporting/types";
|
|
10
10
|
import { IRoktLauncherOptions } from "./roktLauncherOptions";
|
|
11
11
|
import IntegrationCapture from "./integrationCapture";
|
|
12
|
-
import type { CheckoutIntentKind, CheckoutIntentSource, PaymentFrameFamily } from "./buttonTracking/checkoutIntent";
|
|
12
|
+
import type { CheckoutIntentKind, CheckoutIntentSource, ICheckoutIntentSelectors, PaymentFrameFamily } from "./buttonTracking/checkoutIntent";
|
|
13
|
+
export type { ICheckoutIntentSelectors } from "./buttonTracking/checkoutIntent";
|
|
13
14
|
export type RoktAttributeValueArray = Array<string | number | boolean>;
|
|
14
15
|
export type RoktAttributeValueType = string | number | boolean | undefined | null;
|
|
15
16
|
export type RoktAttributeValue = RoktAttributeValueType | RoktAttributeValueArray;
|
|
@@ -75,6 +76,7 @@ export interface IRoktKit {
|
|
|
75
76
|
terminate?: () => Promise<void>;
|
|
76
77
|
onRouteChange?: () => void;
|
|
77
78
|
onCheckoutIntent?: (signal: ICheckoutIntentSignal) => void;
|
|
79
|
+
checkoutIntentSelectors?: ICheckoutIntentSelectors;
|
|
78
80
|
onPaymentPick?: (signal: IPaymentPickSignal) => void;
|
|
79
81
|
launcherOptions?: Dictionary<any>;
|
|
80
82
|
settings?: IRoktKitSettings;
|
|
@@ -144,6 +146,7 @@ export default class RoktManager {
|
|
|
144
146
|
isCheckoutIntentSuppressed(): boolean;
|
|
145
147
|
isCheckoutIntentLive(): boolean;
|
|
146
148
|
notifyCheckoutIntent(signal: ICheckoutIntentSignal, pathname?: string): void;
|
|
149
|
+
getCheckoutIntentSelectors(): ICheckoutIntentSelectors | undefined;
|
|
147
150
|
discardCheckoutIntents(): void;
|
|
148
151
|
notifyPaymentPick(signal: IPaymentPickSignal): void;
|
|
149
152
|
private flushCheckoutIntents;
|
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
CheckoutIntentSource,
|
|
16
16
|
classifyIntent,
|
|
17
17
|
classifyPaymentFrame,
|
|
18
|
+
ICheckoutIntentSelectors,
|
|
18
19
|
namesWallet,
|
|
19
20
|
PaymentFrameFamily,
|
|
20
21
|
} from './checkoutIntent';
|
|
@@ -450,7 +451,11 @@ export class ButtonTracker {
|
|
|
450
451
|
if (control && !withheld) {
|
|
451
452
|
// Checkout intent is only worked out when the kit can use it.
|
|
452
453
|
const intent = signalsKit
|
|
453
|
-
? classifyIntent(
|
|
454
|
+
? classifyIntent(
|
|
455
|
+
control,
|
|
456
|
+
pathname,
|
|
457
|
+
this.checkoutIntentSelectors()
|
|
458
|
+
)
|
|
454
459
|
: undefined;
|
|
455
460
|
kind = intent ? intent.kind : undefined;
|
|
456
461
|
source = intent ? intent.source : undefined;
|
|
@@ -490,7 +495,11 @@ export class ButtonTracker {
|
|
|
490
495
|
kind = 'commit';
|
|
491
496
|
source = 'submit';
|
|
492
497
|
} else if (control) {
|
|
493
|
-
const intent = classifyIntent(
|
|
498
|
+
const intent = classifyIntent(
|
|
499
|
+
control,
|
|
500
|
+
pathname,
|
|
501
|
+
this.checkoutIntentSelectors()
|
|
502
|
+
);
|
|
494
503
|
kind = intent ? intent.kind : undefined;
|
|
495
504
|
source = intent ? intent.source : undefined;
|
|
496
505
|
adds = intent ? intent.adds : undefined;
|
|
@@ -662,6 +671,13 @@ export class ButtonTracker {
|
|
|
662
671
|
);
|
|
663
672
|
}
|
|
664
673
|
|
|
674
|
+
private checkoutIntentSelectors(): ICheckoutIntentSelectors | undefined {
|
|
675
|
+
const roktManager = this.mpInstance._RoktManager;
|
|
676
|
+
return roktManager
|
|
677
|
+
? roktManager.getCheckoutIntentSelectors()
|
|
678
|
+
: undefined;
|
|
679
|
+
}
|
|
680
|
+
|
|
665
681
|
private linkClicksReachKit(): boolean {
|
|
666
682
|
const roktManager = this.mpInstance._RoktManager;
|
|
667
683
|
return !!roktManager && roktManager.areAutoLinkClicksForwarded();
|