@mparticle/web-sdk 2.68.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 +47 -44
- package/dist/mparticle.esm.js +47 -44
- package/dist/mparticle.js +168 -18
- package/dist/types/src/ecommerce.d.ts +1 -1
- 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 +11 -2
- package/dist/types/src/stub/mparticle.stub.d.ts +1 -0
- package/dist/types/src/types.d.ts +47 -2
- package/package.json +1 -1
- package/src/consent.ts +8 -2
- package/src/ecommerce.js +28 -0
- package/src/events.js +7 -0
- package/src/identity.js +77 -33
- 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 +10 -0
- package/src/sessionManager.ts +12 -6
- package/src/stub/mparticle.stub.js +1 -0
- package/src/types.ts +75 -0
package/src/identity.js
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
} from './utils';
|
|
21
21
|
import { hasMPIDAndUserLoginChanged, hasMPIDChanged } from './user-utils';
|
|
22
22
|
import { processReadyQueue } from './pre-init-utils';
|
|
23
|
+
import { logDeprecatedMethodUsage } from './reporting/deprecatedMethodLogger';
|
|
23
24
|
|
|
24
25
|
export default function Identity(mpInstance) {
|
|
25
26
|
const { getFeatureFlag, extend } = mpInstance._Helpers;
|
|
@@ -1252,8 +1253,14 @@ export default function Identity(mpInstance) {
|
|
|
1252
1253
|
* @return a cart object
|
|
1253
1254
|
*/
|
|
1254
1255
|
getCart: function() {
|
|
1255
|
-
|
|
1256
|
-
|
|
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
|
|
1257
1264
|
);
|
|
1258
1265
|
return self.mParticleUserCart();
|
|
1259
1266
|
},
|
|
@@ -1334,13 +1341,18 @@ export default function Identity(mpInstance) {
|
|
|
1334
1341
|
* @deprecated
|
|
1335
1342
|
*/
|
|
1336
1343
|
add: function() {
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
'Identity.getCurrentUser().getCart().add()',
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
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
|
|
1344
1356
|
);
|
|
1345
1357
|
},
|
|
1346
1358
|
/**
|
|
@@ -1349,13 +1361,19 @@ export default function Identity(mpInstance) {
|
|
|
1349
1361
|
* @deprecated
|
|
1350
1362
|
*/
|
|
1351
1363
|
remove: function() {
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
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
|
|
1359
1377
|
);
|
|
1360
1378
|
},
|
|
1361
1379
|
/**
|
|
@@ -1364,13 +1382,19 @@ export default function Identity(mpInstance) {
|
|
|
1364
1382
|
* @deprecated
|
|
1365
1383
|
*/
|
|
1366
1384
|
clear: function() {
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
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
|
|
1374
1398
|
);
|
|
1375
1399
|
},
|
|
1376
1400
|
/**
|
|
@@ -1380,13 +1404,19 @@ export default function Identity(mpInstance) {
|
|
|
1380
1404
|
* @deprecated
|
|
1381
1405
|
*/
|
|
1382
1406
|
getCartProducts: function() {
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
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
|
|
1390
1420
|
);
|
|
1391
1421
|
return [];
|
|
1392
1422
|
},
|
|
@@ -1540,7 +1570,8 @@ export default function Identity(mpInstance) {
|
|
|
1540
1570
|
prevUser,
|
|
1541
1571
|
newUser,
|
|
1542
1572
|
identityApiData,
|
|
1543
|
-
mpInstance.Logger
|
|
1573
|
+
mpInstance.Logger,
|
|
1574
|
+
mpInstance._LoggingDispatcher
|
|
1544
1575
|
);
|
|
1545
1576
|
|
|
1546
1577
|
const persistence = mpInstance._Persistence.getPersistence();
|
|
@@ -1775,14 +1806,27 @@ export default function Identity(mpInstance) {
|
|
|
1775
1806
|
}
|
|
1776
1807
|
|
|
1777
1808
|
// https://go.mparticle.com/work/SQDSDKS-6359
|
|
1778
|
-
function tryOnUserAlias(
|
|
1809
|
+
function tryOnUserAlias(
|
|
1810
|
+
previousUser,
|
|
1811
|
+
newUser,
|
|
1812
|
+
identityApiData,
|
|
1813
|
+
logger,
|
|
1814
|
+
loggingDispatcher
|
|
1815
|
+
) {
|
|
1779
1816
|
if (
|
|
1780
1817
|
identityApiData &&
|
|
1781
1818
|
identityApiData.onUserAlias &&
|
|
1782
1819
|
isFunction(identityApiData.onUserAlias)
|
|
1783
1820
|
) {
|
|
1784
1821
|
try {
|
|
1785
|
-
|
|
1822
|
+
logDeprecatedMethodUsage(
|
|
1823
|
+
{
|
|
1824
|
+
methodName: 'onUserAlias',
|
|
1825
|
+
warningMessage: generateDeprecationMessage('onUserAlias'),
|
|
1826
|
+
},
|
|
1827
|
+
logger,
|
|
1828
|
+
loggingDispatcher
|
|
1829
|
+
);
|
|
1786
1830
|
identityApiData.onUserAlias(previousUser, newUser);
|
|
1787
1831
|
} catch (e) {
|
|
1788
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>;
|
package/src/sdkRuntimeModels.ts
CHANGED
|
@@ -39,6 +39,7 @@ import {
|
|
|
39
39
|
IdentityType,
|
|
40
40
|
ProductActionType,
|
|
41
41
|
PromotionActionType,
|
|
42
|
+
RoktEvents,
|
|
42
43
|
} from './types';
|
|
43
44
|
import { IPixelConfiguration } from './cookieSyncManager';
|
|
44
45
|
import _BatchValidator from './mockBatchCreator';
|
|
@@ -145,6 +146,14 @@ export enum SDKProductActionType {
|
|
|
145
146
|
Refund = 8,
|
|
146
147
|
AddToWishlist = 9,
|
|
147
148
|
RemoveFromWishlist = 10,
|
|
149
|
+
ViewCart = 11,
|
|
150
|
+
AddShippingInfo = 12,
|
|
151
|
+
AddPaymentInfo = 13,
|
|
152
|
+
PaymentMethodSelected = 14,
|
|
153
|
+
PaymentAttempted = 15,
|
|
154
|
+
PaymentSucceeded = 16,
|
|
155
|
+
PaymentFailed = 17,
|
|
156
|
+
RefundInitiated = 18,
|
|
148
157
|
}
|
|
149
158
|
|
|
150
159
|
export interface SDKProductAction {
|
|
@@ -184,6 +193,7 @@ export interface MParticleWebSDK {
|
|
|
184
193
|
EventType: typeof EventType;
|
|
185
194
|
PromotionType: typeof PromotionActionType;
|
|
186
195
|
ProductActionType: typeof ProductActionType;
|
|
196
|
+
RoktEvents: typeof RoktEvents;
|
|
187
197
|
Identity: SDKIdentityApi;
|
|
188
198
|
Logger: SDKLoggerApi;
|
|
189
199
|
Consent: SDKConsentApi;
|
package/src/sessionManager.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { generateDeprecationMessage } from './utils';
|
|
|
6
6
|
import { IMParticleUser } from './identity-user-interfaces';
|
|
7
7
|
import { IMParticleWebSDKInstance } from './mp-instance';
|
|
8
8
|
import { hasIdentityRequestChanged, hasExplicitIdentifier } from './identity-utils';
|
|
9
|
+
import { logDeprecatedMethodUsage } from './reporting/deprecatedMethodLogger';
|
|
9
10
|
|
|
10
11
|
const { Messages } = Constants;
|
|
11
12
|
|
|
@@ -67,12 +68,17 @@ export default function SessionManager(
|
|
|
67
68
|
};
|
|
68
69
|
|
|
69
70
|
this.getSession = function (): string {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
'SessionManager.getSession()',
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
logDeprecatedMethodUsage(
|
|
72
|
+
{
|
|
73
|
+
methodName: 'SessionManager.getSession()',
|
|
74
|
+
warningMessage: generateDeprecationMessage(
|
|
75
|
+
'SessionManager.getSession()',
|
|
76
|
+
false,
|
|
77
|
+
'SessionManager.getSessionId()'
|
|
78
|
+
),
|
|
79
|
+
},
|
|
80
|
+
mpInstance.Logger,
|
|
81
|
+
mpInstance._LoggingDispatcher
|
|
76
82
|
);
|
|
77
83
|
return this.getSessionId();
|
|
78
84
|
};
|
package/src/types.ts
CHANGED
|
@@ -302,6 +302,20 @@ export const ProductActionType = {
|
|
|
302
302
|
AddToWishlist: 9 as const,
|
|
303
303
|
RemoveFromWishlist: 10 as const,
|
|
304
304
|
|
|
305
|
+
// Rokt Brain commerce-adjacent types
|
|
306
|
+
ViewCart: 11 as const,
|
|
307
|
+
AddShippingInfo: 12 as const,
|
|
308
|
+
AddPaymentInfo: 13 as const,
|
|
309
|
+
PaymentMethodSelected: 14 as const,
|
|
310
|
+
PaymentAttempted: 15 as const,
|
|
311
|
+
PaymentSucceeded: 16 as const,
|
|
312
|
+
PaymentFailed: 17 as const,
|
|
313
|
+
RefundInitiated: 18 as const,
|
|
314
|
+
|
|
315
|
+
isRoktCommerceType: (id: number): boolean => {
|
|
316
|
+
return id >= ProductActionType.ViewCart && id <= ProductActionType.RefundInitiated;
|
|
317
|
+
},
|
|
318
|
+
|
|
305
319
|
getName: (id: number): string => {
|
|
306
320
|
switch (id) {
|
|
307
321
|
case ProductActionType.AddToCart:
|
|
@@ -324,6 +338,22 @@ export const ProductActionType = {
|
|
|
324
338
|
return 'Add to Wishlist';
|
|
325
339
|
case ProductActionType.RemoveFromWishlist:
|
|
326
340
|
return 'Remove from Wishlist';
|
|
341
|
+
case ProductActionType.ViewCart:
|
|
342
|
+
return 'View Cart';
|
|
343
|
+
case ProductActionType.AddShippingInfo:
|
|
344
|
+
return 'Add Shipping Info';
|
|
345
|
+
case ProductActionType.AddPaymentInfo:
|
|
346
|
+
return 'Add Payment Info';
|
|
347
|
+
case ProductActionType.PaymentMethodSelected:
|
|
348
|
+
return 'Payment Method Selected';
|
|
349
|
+
case ProductActionType.PaymentAttempted:
|
|
350
|
+
return 'Payment Attempted';
|
|
351
|
+
case ProductActionType.PaymentSucceeded:
|
|
352
|
+
return 'Payment Succeeded';
|
|
353
|
+
case ProductActionType.PaymentFailed:
|
|
354
|
+
return 'Payment Failed';
|
|
355
|
+
case ProductActionType.RefundInitiated:
|
|
356
|
+
return 'Refund Initiated';
|
|
327
357
|
default:
|
|
328
358
|
return 'Unknown';
|
|
329
359
|
}
|
|
@@ -352,12 +382,56 @@ export const ProductActionType = {
|
|
|
352
382
|
return 'add_to_wishlist';
|
|
353
383
|
case ProductActionType.RemoveFromWishlist:
|
|
354
384
|
return 'remove_from_wishlist';
|
|
385
|
+
case ProductActionType.ViewCart:
|
|
386
|
+
return 'view_cart';
|
|
387
|
+
case ProductActionType.AddShippingInfo:
|
|
388
|
+
return 'add_shipping_info';
|
|
389
|
+
case ProductActionType.AddPaymentInfo:
|
|
390
|
+
return 'add_payment_info';
|
|
391
|
+
case ProductActionType.PaymentMethodSelected:
|
|
392
|
+
return 'payment_method_selected';
|
|
393
|
+
case ProductActionType.PaymentAttempted:
|
|
394
|
+
return 'payment_attempted';
|
|
395
|
+
case ProductActionType.PaymentSucceeded:
|
|
396
|
+
return 'payment_succeeded';
|
|
397
|
+
case ProductActionType.PaymentFailed:
|
|
398
|
+
return 'payment_failed';
|
|
399
|
+
case ProductActionType.RefundInitiated:
|
|
400
|
+
return 'refund_initiated';
|
|
355
401
|
default:
|
|
356
402
|
return 'unknown';
|
|
357
403
|
}
|
|
358
404
|
},
|
|
359
405
|
};
|
|
360
406
|
|
|
407
|
+
export type RoktEventName =
|
|
408
|
+
| 'sign_up'
|
|
409
|
+
| 'subscribe'
|
|
410
|
+
| 'start_trial'
|
|
411
|
+
| 'generate_lead'
|
|
412
|
+
| 'search'
|
|
413
|
+
| 'upsell'
|
|
414
|
+
| 'earn_virtual_currency'
|
|
415
|
+
| 'dwell_time'
|
|
416
|
+
| 'hover'
|
|
417
|
+
| 'scroll'
|
|
418
|
+
| 'click_to_expand'
|
|
419
|
+
| (string & {});
|
|
420
|
+
|
|
421
|
+
export const RoktEvents = {
|
|
422
|
+
SignUp: 'sign_up' as const,
|
|
423
|
+
Subscribe: 'subscribe' as const,
|
|
424
|
+
StartTrial: 'start_trial' as const,
|
|
425
|
+
GenerateLead: 'generate_lead' as const,
|
|
426
|
+
Search: 'search' as const,
|
|
427
|
+
Upsell: 'upsell' as const,
|
|
428
|
+
EarnVirtualCurrency: 'earn_virtual_currency' as const,
|
|
429
|
+
DwellTime: 'dwell_time' as const,
|
|
430
|
+
Hover: 'hover' as const,
|
|
431
|
+
Scroll: 'scroll' as const,
|
|
432
|
+
ClickToExpand: 'click_to_expand' as const,
|
|
433
|
+
};
|
|
434
|
+
|
|
361
435
|
export const PromotionActionType = {
|
|
362
436
|
Unknown: 0 as const,
|
|
363
437
|
PromotionView: 1 as const,
|
|
@@ -544,5 +618,6 @@ export default {
|
|
|
544
618
|
ApplicationTransitionType,
|
|
545
619
|
ProductActionType,
|
|
546
620
|
PromotionActionType,
|
|
621
|
+
RoktEvents,
|
|
547
622
|
Environment: Constants.Environment,
|
|
548
623
|
} as const;
|