@mparticle/web-sdk 2.67.0 → 2.69.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/dist/mparticle.common.js +85 -46
- package/dist/mparticle.esm.js +85 -46
- package/dist/mparticle.js +240 -21
- package/dist/types/src/ecommerce.d.ts +1 -1
- package/dist/types/src/identity-utils.d.ts +4 -0
- package/dist/types/src/public-types.d.ts +1 -1
- package/dist/types/src/reporting/deprecatedMethodLogger.d.ts +8 -0
- package/dist/types/src/reporting/types.d.ts +1 -0
- package/dist/types/src/sdkRuntimeModels.d.ts +16 -7
- package/dist/types/src/stub/mparticle.stub.d.ts +1 -0
- package/dist/types/src/types.d.ts +47 -2
- package/package.json +2 -2
- package/src/consent.ts +8 -2
- package/src/ecommerce.js +28 -0
- package/src/events.js +7 -0
- package/src/identity-utils.ts +46 -4
- package/src/identity.js +89 -34
- package/src/mp-instance.ts +60 -29
- package/src/mparticle-instance-manager.ts +2 -1
- package/src/public-types.ts +2 -0
- package/src/reporting/deprecatedMethodLogger.ts +19 -0
- package/src/reporting/types.ts +1 -0
- package/src/sdkRuntimeModels.ts +15 -5
- package/src/sessionManager.ts +12 -6
- package/src/stub/mparticle.stub.js +1 -0
- package/src/types.ts +79 -0
|
@@ -53,8 +53,31 @@ export declare const ProductActionType: {
|
|
|
53
53
|
Refund: 8;
|
|
54
54
|
AddToWishlist: 9;
|
|
55
55
|
RemoveFromWishlist: 10;
|
|
56
|
+
ViewCart: 11;
|
|
57
|
+
AddShippingInfo: 12;
|
|
58
|
+
AddPaymentInfo: 13;
|
|
59
|
+
PaymentMethodSelected: 14;
|
|
60
|
+
PaymentAttempted: 15;
|
|
61
|
+
PaymentSucceeded: 16;
|
|
62
|
+
PaymentFailed: 17;
|
|
63
|
+
RefundInitiated: 18;
|
|
64
|
+
isRoktCommerceType: (id: number) => boolean;
|
|
56
65
|
getName: (id: number) => string;
|
|
57
|
-
getExpansionName: (id: number) => "add_to_cart" | "remove_from_cart" | "checkout" | "checkout_option" | "click" | "view_detail" | "purchase" | "refund" | "add_to_wishlist" | "remove_from_wishlist" | "unknown";
|
|
66
|
+
getExpansionName: (id: number) => "add_to_cart" | "remove_from_cart" | "checkout" | "checkout_option" | "click" | "view_detail" | "purchase" | "refund" | "add_to_wishlist" | "remove_from_wishlist" | "view_cart" | "add_shipping_info" | "add_payment_info" | "payment_method_selected" | "payment_attempted" | "payment_succeeded" | "payment_failed" | "refund_initiated" | "unknown";
|
|
67
|
+
};
|
|
68
|
+
export type RoktEventName = 'sign_up' | 'subscribe' | 'start_trial' | 'generate_lead' | 'search' | 'upsell' | 'earn_virtual_currency' | 'dwell_time' | 'hover' | 'scroll' | 'click_to_expand' | (string & {});
|
|
69
|
+
export declare const RoktEvents: {
|
|
70
|
+
SignUp: "sign_up";
|
|
71
|
+
Subscribe: "subscribe";
|
|
72
|
+
StartTrial: "start_trial";
|
|
73
|
+
GenerateLead: "generate_lead";
|
|
74
|
+
Search: "search";
|
|
75
|
+
Upsell: "upsell";
|
|
76
|
+
EarnVirtualCurrency: "earn_virtual_currency";
|
|
77
|
+
DwellTime: "dwell_time";
|
|
78
|
+
Hover: "hover";
|
|
79
|
+
Scroll: "scroll";
|
|
80
|
+
ClickToExpand: "click_to_expand";
|
|
58
81
|
};
|
|
59
82
|
export declare const PromotionActionType: {
|
|
60
83
|
Unknown: 0;
|
|
@@ -139,8 +162,17 @@ declare const _default: {
|
|
|
139
162
|
Refund: 8;
|
|
140
163
|
AddToWishlist: 9;
|
|
141
164
|
RemoveFromWishlist: 10;
|
|
165
|
+
ViewCart: 11;
|
|
166
|
+
AddShippingInfo: 12;
|
|
167
|
+
AddPaymentInfo: 13;
|
|
168
|
+
PaymentMethodSelected: 14;
|
|
169
|
+
PaymentAttempted: 15;
|
|
170
|
+
PaymentSucceeded: 16;
|
|
171
|
+
PaymentFailed: 17;
|
|
172
|
+
RefundInitiated: 18;
|
|
173
|
+
isRoktCommerceType: (id: number) => boolean;
|
|
142
174
|
getName: (id: number) => string;
|
|
143
|
-
getExpansionName: (id: number) => "add_to_cart" | "remove_from_cart" | "checkout" | "checkout_option" | "click" | "view_detail" | "purchase" | "refund" | "add_to_wishlist" | "remove_from_wishlist" | "unknown";
|
|
175
|
+
getExpansionName: (id: number) => "add_to_cart" | "remove_from_cart" | "checkout" | "checkout_option" | "click" | "view_detail" | "purchase" | "refund" | "add_to_wishlist" | "remove_from_wishlist" | "view_cart" | "add_shipping_info" | "add_payment_info" | "payment_method_selected" | "payment_attempted" | "payment_succeeded" | "payment_failed" | "refund_initiated" | "unknown";
|
|
144
176
|
};
|
|
145
177
|
readonly PromotionActionType: {
|
|
146
178
|
Unknown: 0;
|
|
@@ -149,6 +181,19 @@ declare const _default: {
|
|
|
149
181
|
getName: (id: number) => string;
|
|
150
182
|
getExpansionName: (id: number) => string;
|
|
151
183
|
};
|
|
184
|
+
readonly RoktEvents: {
|
|
185
|
+
SignUp: "sign_up";
|
|
186
|
+
Subscribe: "subscribe";
|
|
187
|
+
StartTrial: "start_trial";
|
|
188
|
+
GenerateLead: "generate_lead";
|
|
189
|
+
Search: "search";
|
|
190
|
+
Upsell: "upsell";
|
|
191
|
+
EarnVirtualCurrency: "earn_virtual_currency";
|
|
192
|
+
DwellTime: "dwell_time";
|
|
193
|
+
Hover: "hover";
|
|
194
|
+
Scroll: "scroll";
|
|
195
|
+
ClickToExpand: "click_to_expand";
|
|
196
|
+
};
|
|
152
197
|
readonly Environment: {
|
|
153
198
|
readonly Development: "development";
|
|
154
199
|
readonly Production: "production";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mparticle/web-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.69.0",
|
|
4
4
|
"description": "mParticle core SDK for web applications",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"keywords": [
|
|
@@ -118,7 +118,7 @@
|
|
|
118
118
|
"@types/jest": "^29.5.1",
|
|
119
119
|
"@types/jest-expect-message": "^1.1.0",
|
|
120
120
|
"@types/mocha": "^9.0.0",
|
|
121
|
-
"@types/mparticle__web-sdk": "^2.
|
|
121
|
+
"@types/mparticle__web-sdk": "^2.66.0",
|
|
122
122
|
"@types/node": "^20.1.0",
|
|
123
123
|
"babel-preset-minify": "^0.5.1",
|
|
124
124
|
"browser-sync": "^2.26.3",
|
package/src/consent.ts
CHANGED
|
@@ -9,6 +9,7 @@ import KitFilterHelper from './kitFilterHelper';
|
|
|
9
9
|
import Constants from './constants';
|
|
10
10
|
import { IMParticleUser } from './identity-user-interfaces';
|
|
11
11
|
import { IMParticleWebSDKInstance } from './mp-instance';
|
|
12
|
+
import { logDeprecatedMethodUsage } from './reporting/deprecatedMethodLogger';
|
|
12
13
|
|
|
13
14
|
const { CCPAPurpose } = Constants;
|
|
14
15
|
|
|
@@ -505,8 +506,13 @@ export default function Consent(this: IConsent, mpInstance: IMParticleWebSDKInst
|
|
|
505
506
|
|
|
506
507
|
// TODO: Can we remove this? It is deprecated.
|
|
507
508
|
function removeCCPAState(this: ConsentState) {
|
|
508
|
-
|
|
509
|
-
|
|
509
|
+
logDeprecatedMethodUsage(
|
|
510
|
+
{
|
|
511
|
+
methodName: 'Consent.removeCCPAState',
|
|
512
|
+
warningMessage: 'removeCCPAState is deprecated and will be removed in a future release; use removeCCPAConsentState instead',
|
|
513
|
+
},
|
|
514
|
+
mpInstance.Logger,
|
|
515
|
+
mpInstance._LoggingDispatcher
|
|
510
516
|
);
|
|
511
517
|
// @ts-ignore
|
|
512
518
|
return removeCCPAConsentState();
|
package/src/ecommerce.js
CHANGED
|
@@ -69,6 +69,22 @@ export default function Ecommerce(mpInstance) {
|
|
|
69
69
|
return 'RemoveFromWishlist';
|
|
70
70
|
case Types.ProductActionType.ViewDetail:
|
|
71
71
|
return 'ViewDetail';
|
|
72
|
+
case Types.ProductActionType.ViewCart:
|
|
73
|
+
return 'ViewCart';
|
|
74
|
+
case Types.ProductActionType.AddShippingInfo:
|
|
75
|
+
return 'AddShippingInfo';
|
|
76
|
+
case Types.ProductActionType.AddPaymentInfo:
|
|
77
|
+
return 'AddPaymentInfo';
|
|
78
|
+
case Types.ProductActionType.PaymentMethodSelected:
|
|
79
|
+
return 'PaymentMethodSelected';
|
|
80
|
+
case Types.ProductActionType.PaymentAttempted:
|
|
81
|
+
return 'PaymentAttempted';
|
|
82
|
+
case Types.ProductActionType.PaymentSucceeded:
|
|
83
|
+
return 'PaymentSucceeded';
|
|
84
|
+
case Types.ProductActionType.PaymentFailed:
|
|
85
|
+
return 'PaymentFailed';
|
|
86
|
+
case Types.ProductActionType.RefundInitiated:
|
|
87
|
+
return 'RefundInitiated';
|
|
72
88
|
case Types.ProductActionType.Unknown:
|
|
73
89
|
default:
|
|
74
90
|
return 'Unknown';
|
|
@@ -113,6 +129,18 @@ export default function Ecommerce(mpInstance) {
|
|
|
113
129
|
|
|
114
130
|
case Types.ProductActionType.ViewDetail:
|
|
115
131
|
return Types.CommerceEventType.ProductViewDetail;
|
|
132
|
+
|
|
133
|
+
// Rokt Brain commerce-adjacent types map to Unknown on server
|
|
134
|
+
case Types.ProductActionType.ViewCart:
|
|
135
|
+
case Types.ProductActionType.AddShippingInfo:
|
|
136
|
+
case Types.ProductActionType.AddPaymentInfo:
|
|
137
|
+
case Types.ProductActionType.PaymentMethodSelected:
|
|
138
|
+
case Types.ProductActionType.PaymentAttempted:
|
|
139
|
+
case Types.ProductActionType.PaymentSucceeded:
|
|
140
|
+
case Types.ProductActionType.PaymentFailed:
|
|
141
|
+
case Types.ProductActionType.RefundInitiated:
|
|
142
|
+
return Types.EventType.Unknown;
|
|
143
|
+
|
|
116
144
|
default:
|
|
117
145
|
mpInstance.Logger.error(
|
|
118
146
|
'Could not convert product action type ' +
|
package/src/events.js
CHANGED
|
@@ -174,6 +174,13 @@ export default function Events(mpInstance) {
|
|
|
174
174
|
ProductList: productList,
|
|
175
175
|
};
|
|
176
176
|
|
|
177
|
+
if (Types.ProductActionType.isRoktCommerceType(productActionType)) {
|
|
178
|
+
event.CustomFlags = event.CustomFlags || {};
|
|
179
|
+
event.CustomFlags[
|
|
180
|
+
'Rokt.CommerceEventType'
|
|
181
|
+
] = Types.ProductActionType.getExpansionName(productActionType);
|
|
182
|
+
}
|
|
183
|
+
|
|
177
184
|
if (mpInstance._Helpers.isObject(transactionAttributes)) {
|
|
178
185
|
mpInstance._Ecommerce.convertTransactionAttributesToProductAction(
|
|
179
186
|
transactionAttributes,
|
package/src/identity-utils.ts
CHANGED
|
@@ -289,6 +289,48 @@ const getExpireTimestamp = (maxAge: number = ONE_DAY_IN_SECONDS): number =>
|
|
|
289
289
|
const parseIdentityResponse = (responseText: string): IdentityResultBody =>
|
|
290
290
|
responseText ? JSON.parse(responseText) : ({} as IdentityResultBody);
|
|
291
291
|
|
|
292
|
+
type Sha256IdentityAlias = 'email_sha256' | 'mobile_sha256';
|
|
293
|
+
|
|
294
|
+
const SHA256_IDENTITY_ALIASES: Readonly<
|
|
295
|
+
Record<Sha256IdentityAlias, keyof UserIdentities>
|
|
296
|
+
> = {
|
|
297
|
+
email_sha256: 'other',
|
|
298
|
+
mobile_sha256: 'other2',
|
|
299
|
+
};
|
|
300
|
+
|
|
301
|
+
type UserIdentitiesWithAliases = UserIdentities &
|
|
302
|
+
Partial<Record<Sha256IdentityAlias, string | null>>;
|
|
303
|
+
|
|
304
|
+
export const normalizeUserIdentityKeys = (
|
|
305
|
+
userIdentities: UserIdentitiesWithAliases
|
|
306
|
+
): UserIdentities => {
|
|
307
|
+
const normalized: UserIdentitiesWithAliases = { ...userIdentities };
|
|
308
|
+
(Object.keys(SHA256_IDENTITY_ALIASES) as Sha256IdentityAlias[]).forEach(
|
|
309
|
+
(alias) => {
|
|
310
|
+
if (alias in normalized) {
|
|
311
|
+
const value = normalized[alias];
|
|
312
|
+
delete normalized[alias];
|
|
313
|
+
normalized[SHA256_IDENTITY_ALIASES[alias]] = value;
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
);
|
|
317
|
+
return normalized;
|
|
318
|
+
};
|
|
319
|
+
|
|
320
|
+
// Compare two identity objects by key and value, independent of
|
|
321
|
+
// object key insertion order. The two sides come from different sources
|
|
322
|
+
// (numeric IdentityType iteration vs. partner-provided / alias-normalized
|
|
323
|
+
// order)
|
|
324
|
+
const identitiesEqual = (
|
|
325
|
+
a?: UserIdentities,
|
|
326
|
+
b?: UserIdentities
|
|
327
|
+
): boolean => {
|
|
328
|
+
const aKeys = Object.keys(a ?? {});
|
|
329
|
+
const bKeys = Object.keys(b ?? {});
|
|
330
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
331
|
+
return aKeys.every((key) => a[key] === b[key]);
|
|
332
|
+
};
|
|
333
|
+
|
|
292
334
|
export const hasIdentityRequestChanged = (
|
|
293
335
|
currentUser: IMParticleUser,
|
|
294
336
|
newIdentityRequest: IdentityApiData
|
|
@@ -300,11 +342,11 @@ export const hasIdentityRequestChanged = (
|
|
|
300
342
|
const currentUserIdentities =
|
|
301
343
|
currentUser.getUserIdentities().userIdentities;
|
|
302
344
|
|
|
303
|
-
const newIdentities =
|
|
304
|
-
|
|
305
|
-
return (
|
|
306
|
-
JSON.stringify(currentUserIdentities) !== JSON.stringify(newIdentities)
|
|
345
|
+
const newIdentities = normalizeUserIdentityKeys(
|
|
346
|
+
newIdentityRequest.userIdentities
|
|
307
347
|
);
|
|
348
|
+
|
|
349
|
+
return !identitiesEqual(currentUserIdentities, newIdentities);
|
|
308
350
|
};
|
|
309
351
|
|
|
310
352
|
/**
|
package/src/identity.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
cacheOrClearIdCache,
|
|
5
5
|
createKnownIdentities,
|
|
6
6
|
executeSearchRequest,
|
|
7
|
+
normalizeUserIdentityKeys,
|
|
7
8
|
tryCacheIdentity,
|
|
8
9
|
} from './identity-utils';
|
|
9
10
|
import AudienceManager from './audienceManager';
|
|
@@ -19,6 +20,7 @@ import {
|
|
|
19
20
|
} from './utils';
|
|
20
21
|
import { hasMPIDAndUserLoginChanged, hasMPIDChanged } from './user-utils';
|
|
21
22
|
import { processReadyQueue } from './pre-init-utils';
|
|
23
|
+
import { logDeprecatedMethodUsage } from './reporting/deprecatedMethodLogger';
|
|
22
24
|
|
|
23
25
|
export default function Identity(mpInstance) {
|
|
24
26
|
const { getFeatureFlag, extend } = mpInstance._Helpers;
|
|
@@ -35,11 +37,21 @@ export default function Identity(mpInstance) {
|
|
|
35
37
|
);
|
|
36
38
|
|
|
37
39
|
// First, remove any falsy identity values and warn about them
|
|
38
|
-
const
|
|
40
|
+
const removedFalsyIdentityData = mpInstance._Helpers.Validators.removeFalsyIdentityValues(
|
|
39
41
|
identityApiData,
|
|
40
42
|
mpInstance.Logger
|
|
41
43
|
);
|
|
42
44
|
|
|
45
|
+
// Normalize convenience aliases (email_sha256 → other, mobile_sha256 → other2)
|
|
46
|
+
const cleanedIdentityApiData = removedFalsyIdentityData?.userIdentities
|
|
47
|
+
? {
|
|
48
|
+
...removedFalsyIdentityData,
|
|
49
|
+
userIdentities: normalizeUserIdentityKeys(
|
|
50
|
+
removedFalsyIdentityData.userIdentities
|
|
51
|
+
),
|
|
52
|
+
}
|
|
53
|
+
: removedFalsyIdentityData;
|
|
54
|
+
|
|
43
55
|
var identityValidationResult = mpInstance._Helpers.Validators.validateIdentities(
|
|
44
56
|
cleanedIdentityApiData,
|
|
45
57
|
method
|
|
@@ -1241,8 +1253,14 @@ export default function Identity(mpInstance) {
|
|
|
1241
1253
|
* @return a cart object
|
|
1242
1254
|
*/
|
|
1243
1255
|
getCart: function() {
|
|
1244
|
-
|
|
1245
|
-
|
|
1256
|
+
logDeprecatedMethodUsage(
|
|
1257
|
+
{
|
|
1258
|
+
methodName: 'Identity.getCurrentUser().getCart()',
|
|
1259
|
+
warningMessage:
|
|
1260
|
+
'Deprecated function Identity.getCurrentUser().getCart() will be removed in future releases',
|
|
1261
|
+
},
|
|
1262
|
+
mpInstance.Logger,
|
|
1263
|
+
mpInstance._LoggingDispatcher
|
|
1246
1264
|
);
|
|
1247
1265
|
return self.mParticleUserCart();
|
|
1248
1266
|
},
|
|
@@ -1323,13 +1341,18 @@ export default function Identity(mpInstance) {
|
|
|
1323
1341
|
* @deprecated
|
|
1324
1342
|
*/
|
|
1325
1343
|
add: function() {
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
'Identity.getCurrentUser().getCart().add()',
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1344
|
+
logDeprecatedMethodUsage(
|
|
1345
|
+
{
|
|
1346
|
+
methodName: 'Identity.getCurrentUser().getCart().add()',
|
|
1347
|
+
warningMessage: generateDeprecationMessage(
|
|
1348
|
+
'Identity.getCurrentUser().getCart().add()',
|
|
1349
|
+
true,
|
|
1350
|
+
'eCommerce.logProductAction()',
|
|
1351
|
+
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
|
|
1352
|
+
),
|
|
1353
|
+
},
|
|
1354
|
+
mpInstance.Logger,
|
|
1355
|
+
mpInstance._LoggingDispatcher
|
|
1333
1356
|
);
|
|
1334
1357
|
},
|
|
1335
1358
|
/**
|
|
@@ -1338,13 +1361,19 @@ export default function Identity(mpInstance) {
|
|
|
1338
1361
|
* @deprecated
|
|
1339
1362
|
*/
|
|
1340
1363
|
remove: function() {
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1364
|
+
logDeprecatedMethodUsage(
|
|
1365
|
+
{
|
|
1366
|
+
methodName:
|
|
1367
|
+
'Identity.getCurrentUser().getCart().remove()',
|
|
1368
|
+
warningMessage: generateDeprecationMessage(
|
|
1369
|
+
'Identity.getCurrentUser().getCart().remove()',
|
|
1370
|
+
true,
|
|
1371
|
+
'eCommerce.logProductAction()',
|
|
1372
|
+
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
|
|
1373
|
+
),
|
|
1374
|
+
},
|
|
1375
|
+
mpInstance.Logger,
|
|
1376
|
+
mpInstance._LoggingDispatcher
|
|
1348
1377
|
);
|
|
1349
1378
|
},
|
|
1350
1379
|
/**
|
|
@@ -1353,13 +1382,19 @@ export default function Identity(mpInstance) {
|
|
|
1353
1382
|
* @deprecated
|
|
1354
1383
|
*/
|
|
1355
1384
|
clear: function() {
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1385
|
+
logDeprecatedMethodUsage(
|
|
1386
|
+
{
|
|
1387
|
+
methodName:
|
|
1388
|
+
'Identity.getCurrentUser().getCart().clear()',
|
|
1389
|
+
warningMessage: generateDeprecationMessage(
|
|
1390
|
+
'Identity.getCurrentUser().getCart().clear()',
|
|
1391
|
+
true,
|
|
1392
|
+
'',
|
|
1393
|
+
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
|
|
1394
|
+
),
|
|
1395
|
+
},
|
|
1396
|
+
mpInstance.Logger,
|
|
1397
|
+
mpInstance._LoggingDispatcher
|
|
1363
1398
|
);
|
|
1364
1399
|
},
|
|
1365
1400
|
/**
|
|
@@ -1369,13 +1404,19 @@ export default function Identity(mpInstance) {
|
|
|
1369
1404
|
* @deprecated
|
|
1370
1405
|
*/
|
|
1371
1406
|
getCartProducts: function() {
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1407
|
+
logDeprecatedMethodUsage(
|
|
1408
|
+
{
|
|
1409
|
+
methodName:
|
|
1410
|
+
'Identity.getCurrentUser().getCart().getCartProducts()',
|
|
1411
|
+
warningMessage: generateDeprecationMessage(
|
|
1412
|
+
'Identity.getCurrentUser().getCart().getCartProducts()',
|
|
1413
|
+
true,
|
|
1414
|
+
'eCommerce.logProductAction()',
|
|
1415
|
+
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
|
|
1416
|
+
),
|
|
1417
|
+
},
|
|
1418
|
+
mpInstance.Logger,
|
|
1419
|
+
mpInstance._LoggingDispatcher
|
|
1379
1420
|
);
|
|
1380
1421
|
return [];
|
|
1381
1422
|
},
|
|
@@ -1529,7 +1570,8 @@ export default function Identity(mpInstance) {
|
|
|
1529
1570
|
prevUser,
|
|
1530
1571
|
newUser,
|
|
1531
1572
|
identityApiData,
|
|
1532
|
-
mpInstance.Logger
|
|
1573
|
+
mpInstance.Logger,
|
|
1574
|
+
mpInstance._LoggingDispatcher
|
|
1533
1575
|
);
|
|
1534
1576
|
|
|
1535
1577
|
const persistence = mpInstance._Persistence.getPersistence();
|
|
@@ -1764,14 +1806,27 @@ export default function Identity(mpInstance) {
|
|
|
1764
1806
|
}
|
|
1765
1807
|
|
|
1766
1808
|
// https://go.mparticle.com/work/SQDSDKS-6359
|
|
1767
|
-
function tryOnUserAlias(
|
|
1809
|
+
function tryOnUserAlias(
|
|
1810
|
+
previousUser,
|
|
1811
|
+
newUser,
|
|
1812
|
+
identityApiData,
|
|
1813
|
+
logger,
|
|
1814
|
+
loggingDispatcher
|
|
1815
|
+
) {
|
|
1768
1816
|
if (
|
|
1769
1817
|
identityApiData &&
|
|
1770
1818
|
identityApiData.onUserAlias &&
|
|
1771
1819
|
isFunction(identityApiData.onUserAlias)
|
|
1772
1820
|
) {
|
|
1773
1821
|
try {
|
|
1774
|
-
|
|
1822
|
+
logDeprecatedMethodUsage(
|
|
1823
|
+
{
|
|
1824
|
+
methodName: 'onUserAlias',
|
|
1825
|
+
warningMessage: generateDeprecationMessage('onUserAlias'),
|
|
1826
|
+
},
|
|
1827
|
+
logger,
|
|
1828
|
+
loggingDispatcher
|
|
1829
|
+
);
|
|
1775
1830
|
identityApiData.onUserAlias(previousUser, newUser);
|
|
1776
1831
|
} catch (e) {
|
|
1777
1832
|
logger.error(
|
package/src/mp-instance.ts
CHANGED
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
// Uses portions of code from jQuery
|
|
17
17
|
// jQuery v1.10.2 | (c) 2005, 2013 jQuery Foundation, Inc. | jquery.org/license
|
|
18
18
|
|
|
19
|
-
import { EventType, IdentityType, CommerceEventType, PromotionActionType, ProductActionType, MessageType } from './types';
|
|
19
|
+
import { EventType, IdentityType, CommerceEventType, PromotionActionType, ProductActionType, MessageType, RoktEvents } from './types';
|
|
20
20
|
import Constants from './constants';
|
|
21
21
|
import APIClient, { IAPIClient } from './apiClient';
|
|
22
22
|
import Helpers from './helpers';
|
|
@@ -55,6 +55,7 @@ import CookieConsentManager, { ICookieConsentManager } from './cookieConsentMana
|
|
|
55
55
|
import { ErrorReportingDispatcher } from './reporting/errorReportingDispatcher';
|
|
56
56
|
import { LoggingDispatcher } from './reporting/loggingDispatcher';
|
|
57
57
|
import { IErrorReportingService, ILoggingService } from './reporting/types';
|
|
58
|
+
import { logDeprecatedMethodUsage } from './reporting/deprecatedMethodLogger';
|
|
58
59
|
|
|
59
60
|
export interface IErrorLogMessage {
|
|
60
61
|
message?: string;
|
|
@@ -187,6 +188,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
187
188
|
this.CommerceEventType = CommerceEventType;
|
|
188
189
|
this.PromotionType = PromotionActionType;
|
|
189
190
|
this.ProductActionType = ProductActionType;
|
|
191
|
+
this.RoktEvents = RoktEvents;
|
|
190
192
|
|
|
191
193
|
|
|
192
194
|
this._Identity = new Identity(this);
|
|
@@ -772,13 +774,18 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
772
774
|
* @deprecated
|
|
773
775
|
*/
|
|
774
776
|
add: function(product, logEventBoolean) {
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
'eCommerce.Cart.add()',
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
777
|
+
logDeprecatedMethodUsage(
|
|
778
|
+
{
|
|
779
|
+
methodName: 'mPInstance.eCommerce.Cart.add()',
|
|
780
|
+
warningMessage: generateDeprecationMessage(
|
|
781
|
+
'eCommerce.Cart.add()',
|
|
782
|
+
true,
|
|
783
|
+
'eCommerce.logProductAction()',
|
|
784
|
+
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
|
|
785
|
+
),
|
|
786
|
+
},
|
|
787
|
+
self.Logger,
|
|
788
|
+
self._LoggingDispatcher
|
|
782
789
|
);
|
|
783
790
|
},
|
|
784
791
|
/**
|
|
@@ -789,13 +796,18 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
789
796
|
* @deprecated
|
|
790
797
|
*/
|
|
791
798
|
remove: function(product, logEventBoolean) {
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
'eCommerce.Cart.remove()',
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
+
logDeprecatedMethodUsage(
|
|
800
|
+
{
|
|
801
|
+
methodName: 'mPInstance.eCommerce.Cart.remove()',
|
|
802
|
+
warningMessage: generateDeprecationMessage(
|
|
803
|
+
'eCommerce.Cart.remove()',
|
|
804
|
+
true,
|
|
805
|
+
'eCommerce.logProductAction()',
|
|
806
|
+
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
|
|
807
|
+
),
|
|
808
|
+
},
|
|
809
|
+
self.Logger,
|
|
810
|
+
self._LoggingDispatcher
|
|
799
811
|
);
|
|
800
812
|
},
|
|
801
813
|
/**
|
|
@@ -804,13 +816,18 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
804
816
|
* @deprecated
|
|
805
817
|
*/
|
|
806
818
|
clear: function() {
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
'eCommerce.Cart.clear()',
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
819
|
+
logDeprecatedMethodUsage(
|
|
820
|
+
{
|
|
821
|
+
methodName: 'mPInstance.eCommerce.Cart.clear()',
|
|
822
|
+
warningMessage: generateDeprecationMessage(
|
|
823
|
+
'eCommerce.Cart.clear()',
|
|
824
|
+
true,
|
|
825
|
+
'',
|
|
826
|
+
'https://docs.mparticle.com/developers/sdk/web/commerce-tracking'
|
|
827
|
+
),
|
|
828
|
+
},
|
|
829
|
+
self.Logger,
|
|
830
|
+
self._LoggingDispatcher
|
|
814
831
|
);
|
|
815
832
|
},
|
|
816
833
|
},
|
|
@@ -940,8 +957,13 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
940
957
|
* @deprecated
|
|
941
958
|
*/
|
|
942
959
|
logCheckout: function(step, option, attrs, customFlags) {
|
|
943
|
-
|
|
944
|
-
|
|
960
|
+
logDeprecatedMethodUsage(
|
|
961
|
+
{
|
|
962
|
+
methodName: 'mParticle.logCheckout',
|
|
963
|
+
warningMessage: 'mParticle.logCheckout is deprecated, please use mParticle.logProductAction instead',
|
|
964
|
+
},
|
|
965
|
+
self.Logger,
|
|
966
|
+
self._LoggingDispatcher
|
|
945
967
|
);
|
|
946
968
|
|
|
947
969
|
if (!self._Store.isInitialized) {
|
|
@@ -1020,8 +1042,13 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
1020
1042
|
attrs,
|
|
1021
1043
|
customFlags
|
|
1022
1044
|
) {
|
|
1023
|
-
|
|
1024
|
-
|
|
1045
|
+
logDeprecatedMethodUsage(
|
|
1046
|
+
{
|
|
1047
|
+
methodName: 'mParticle.logPurchase',
|
|
1048
|
+
warningMessage: 'mParticle.logPurchase is deprecated, please use mParticle.logProductAction instead',
|
|
1049
|
+
},
|
|
1050
|
+
self.Logger,
|
|
1051
|
+
self._LoggingDispatcher
|
|
1025
1052
|
);
|
|
1026
1053
|
if (!self._Store.isInitialized) {
|
|
1027
1054
|
self.ready(function() {
|
|
@@ -1132,8 +1159,13 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
1132
1159
|
attrs,
|
|
1133
1160
|
customFlags
|
|
1134
1161
|
) {
|
|
1135
|
-
|
|
1136
|
-
|
|
1162
|
+
logDeprecatedMethodUsage(
|
|
1163
|
+
{
|
|
1164
|
+
methodName: 'mParticle.logRefund',
|
|
1165
|
+
warningMessage: 'mParticle.logRefund is deprecated, please use mParticle.logProductAction instead',
|
|
1166
|
+
},
|
|
1167
|
+
self.Logger,
|
|
1168
|
+
self._LoggingDispatcher
|
|
1137
1169
|
);
|
|
1138
1170
|
if (!self._Store.isInitialized) {
|
|
1139
1171
|
self.ready(function() {
|
|
@@ -1741,4 +1773,3 @@ function queueIfNotInitialized(func, self) {
|
|
|
1741
1773
|
});
|
|
1742
1774
|
return true;
|
|
1743
1775
|
}
|
|
1744
|
-
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Polyfill from './polyfill';
|
|
2
|
-
import { CommerceEventType, EventType, IdentityType, PerformanceMarkType, ProductActionType, PromotionActionType } from './types';
|
|
2
|
+
import { CommerceEventType, EventType, IdentityType, PerformanceMarkType, ProductActionType, PromotionActionType, RoktEvents } from './types';
|
|
3
3
|
import Constants from './constants';
|
|
4
4
|
import mParticleInstance, { IMParticleWebSDKInstance } from './mp-instance.js';
|
|
5
5
|
import _BatchValidator from './mockBatchCreator';
|
|
@@ -36,6 +36,7 @@ function mParticleInstanceManager(this: IMParticleInstanceManager) {
|
|
|
36
36
|
this.CommerceEventType = CommerceEventType;
|
|
37
37
|
this.PromotionType = PromotionActionType;
|
|
38
38
|
this.ProductActionType = ProductActionType;
|
|
39
|
+
this.RoktEvents = RoktEvents;
|
|
39
40
|
|
|
40
41
|
this.MPSideloadedKit = MPSideloadedKit;
|
|
41
42
|
|
package/src/public-types.ts
CHANGED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { ErrorCodes, ILoggingService } from './types';
|
|
2
|
+
import { SDKLoggerApi } from '../sdkRuntimeModels';
|
|
3
|
+
|
|
4
|
+
interface DeprecatedMethodUsage {
|
|
5
|
+
methodName: string;
|
|
6
|
+
warningMessage: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function logDeprecatedMethodUsage(
|
|
10
|
+
usage: DeprecatedMethodUsage,
|
|
11
|
+
logger: Pick<SDKLoggerApi, 'warning'>,
|
|
12
|
+
loggingDispatcher: ILoggingService | undefined
|
|
13
|
+
): void {
|
|
14
|
+
logger.warning(usage.warningMessage);
|
|
15
|
+
loggingDispatcher?.log({
|
|
16
|
+
message: usage.methodName,
|
|
17
|
+
code: ErrorCodes.MP_DEPRECATED_METHOD_USAGE,
|
|
18
|
+
});
|
|
19
|
+
}
|
package/src/reporting/types.ts
CHANGED
|
@@ -6,6 +6,7 @@ export const ErrorCodes = {
|
|
|
6
6
|
IDENTITY_REQUEST: 'IDENTITY_REQUEST',
|
|
7
7
|
IDENTITY_MISMATCH: 'IDENTITY_MISMATCH',
|
|
8
8
|
ROKT_KIT_ATTACHED: 'ROKT_KIT_ATTACHED',
|
|
9
|
+
MP_DEPRECATED_METHOD_USAGE: 'MP_DEPRECATED_METHOD_USAGE',
|
|
9
10
|
} as const;
|
|
10
11
|
|
|
11
12
|
export type ErrorCodes = valueof<typeof ErrorCodes>;
|