@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.
@@ -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 {
@@ -161,9 +170,9 @@ export interface SDKProductAction {
161
170
  }
162
171
 
163
172
  export interface SDKProduct {
164
- Sku?: string;
165
- Name?: string;
166
- Price?: number;
173
+ Sku: string;
174
+ Name: string;
175
+ Price: number;
167
176
  Quantity?: number;
168
177
  Brand?: string;
169
178
  Variant?: string;
@@ -173,7 +182,7 @@ export interface SDKProduct {
173
182
  TotalAmount?: number;
174
183
 
175
184
  // https://go.mparticle.com/work/SQDSDKS-4801
176
- Attributes?: Record<string, unknown> | null;
185
+ Attributes?: Record<string, unknown>;
177
186
  }
178
187
 
179
188
  // https://go.mparticle.com/work/SQDSDKS-6949
@@ -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;
@@ -306,7 +316,7 @@ export const LogLevelType = {
306
316
  // Currently, this extends MPConfiguration in @types/mparticle__web-sdk
307
317
  // and the two will be merged in once the Store module is refactored
308
318
  export interface SDKInitConfig
309
- extends Omit<MPConfiguration, 'dataPlan' | 'logLevel'> {
319
+ extends Omit<MPConfiguration, 'dataPlan' | 'logLevel' | 'identityCallback'> {
310
320
  dataPlan?: DataPlanConfig | KitBlockerDataPlan; // TODO: These should be eventually split into two different attributes
311
321
  logLevel?: LogLevelType;
312
322
 
@@ -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
- mpInstance.Logger.warning(
71
- generateDeprecationMessage(
72
- 'SessionManager.getSession()',
73
- false,
74
- 'SessionManager.getSessionId()'
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
  };
@@ -28,6 +28,7 @@ let mParticle = {
28
28
  IdentityType: {},
29
29
  ProductActionType: {},
30
30
  PromotionType: {},
31
+ RoktEvents: {},
31
32
  eCommerce: {
32
33
  createImpression: returnImpression,
33
34
  createProduct: returnProduct,
package/src/types.ts CHANGED
@@ -205,6 +205,10 @@ export const IdentityType = {
205
205
  return IdentityType.PhoneNumber2;
206
206
  case 'phone_number_3':
207
207
  return IdentityType.PhoneNumber3;
208
+ case 'email_sha256':
209
+ return IdentityType.Other;
210
+ case 'mobile_sha256':
211
+ return IdentityType.Other2;
208
212
  default:
209
213
  return false;
210
214
  }
@@ -298,6 +302,20 @@ export const ProductActionType = {
298
302
  AddToWishlist: 9 as const,
299
303
  RemoveFromWishlist: 10 as const,
300
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
+
301
319
  getName: (id: number): string => {
302
320
  switch (id) {
303
321
  case ProductActionType.AddToCart:
@@ -320,6 +338,22 @@ export const ProductActionType = {
320
338
  return 'Add to Wishlist';
321
339
  case ProductActionType.RemoveFromWishlist:
322
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';
323
357
  default:
324
358
  return 'Unknown';
325
359
  }
@@ -348,12 +382,56 @@ export const ProductActionType = {
348
382
  return 'add_to_wishlist';
349
383
  case ProductActionType.RemoveFromWishlist:
350
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';
351
401
  default:
352
402
  return 'unknown';
353
403
  }
354
404
  },
355
405
  };
356
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
+
357
435
  export const PromotionActionType = {
358
436
  Unknown: 0 as const,
359
437
  PromotionView: 1 as const,
@@ -540,5 +618,6 @@ export default {
540
618
  ApplicationTransitionType,
541
619
  ProductActionType,
542
620
  PromotionActionType,
621
+ RoktEvents,
543
622
  Environment: Constants.Environment,
544
623
  } as const;