@mparticle/web-sdk 2.18.2 → 2.18.3

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.
@@ -1,15 +1,51 @@
1
1
  import Constants from './constants';
2
2
  import Types from './types';
3
3
  import { BatchUploader } from './batchUploader';
4
+ import {
5
+ MParticleUser,
6
+ MParticleWebSDK,
7
+ MPForwarder,
8
+ SDKEvent,
9
+ } from './sdkRuntimeModels';
10
+ import KitBlocker from './kitBlocking';
11
+ import { Dictionary } from './utils';
12
+ import { IUploadObject } from './serverModel';
4
13
 
5
- var Messages = Constants.Messages;
14
+ const Messages = Constants.Messages;
6
15
 
7
- export default function APIClient(mpInstance, kitBlocker) {
16
+ export type ForwardingStatsData = Dictionary<any>;
17
+
18
+ export interface IAPIClient {
19
+ uploader: BatchUploader | null;
20
+ queueEventForBatchUpload: (event: SDKEvent) => void;
21
+ shouldEnableBatching: () => boolean;
22
+ processQueuedEvents: () => void;
23
+ appendUserInfoToEvents: (user: MParticleUser, events: SDKEvent[]) => void;
24
+ sendEventToServer: (event: SDKEvent, _options?: Dictionary<any>) => void;
25
+ sendSingleEventToServer: (event: SDKEvent) => void;
26
+ sendBatchForwardingStatsToServer: (
27
+ forwardingStatsData: ForwardingStatsData,
28
+ xhr: XMLHttpRequest
29
+ ) => void;
30
+ sendSingleForwardingStatsToServer: (
31
+ forwardingStatsData: ForwardingStatsData
32
+ ) => void;
33
+ prepareForwardingStats: (
34
+ forwarder: MPForwarder,
35
+ event: IUploadObject
36
+ ) => void;
37
+ }
38
+
39
+ export default function APIClient(
40
+ this: IAPIClient,
41
+ mpInstance: MParticleWebSDK,
42
+ kitBlocker: KitBlocker
43
+ ) {
8
44
  this.uploader = null;
9
- var self = this;
10
- this.queueEventForBatchUpload = function(event) {
45
+ const self = this;
46
+ this.queueEventForBatchUpload = function(event: SDKEvent) {
11
47
  if (!this.uploader) {
12
- var millis = mpInstance._Helpers.getFeatureFlag(
48
+ const millis = mpInstance._Helpers.getFeatureFlag(
13
49
  Constants.FeatureFlags.EventBatchingIntervalMillis
14
50
  );
15
51
  this.uploader = new BatchUploader(mpInstance, millis);
@@ -22,7 +58,7 @@ export default function APIClient(mpInstance, kitBlocker) {
22
58
  this.shouldEnableBatching = function() {
23
59
  // Returns a string of a number that must be parsed
24
60
  // Invalid strings will be parsed to NaN which is falsey
25
- var eventsV3Percentage = parseInt(
61
+ const eventsV3Percentage = parseInt(
26
62
  mpInstance._Helpers.getFeatureFlag(Constants.FeatureFlags.EventsV3),
27
63
  10
28
64
  );
@@ -31,20 +67,20 @@ export default function APIClient(mpInstance, kitBlocker) {
31
67
  return false;
32
68
  }
33
69
 
34
- var rampNumber = mpInstance._Helpers.getRampNumber(
70
+ const rampNumber = mpInstance._Helpers.getRampNumber(
35
71
  mpInstance._Store.deviceId
36
72
  );
37
73
  return eventsV3Percentage >= rampNumber;
38
74
  };
39
75
 
40
76
  this.processQueuedEvents = function() {
41
- var mpid,
77
+ let mpid,
42
78
  currentUser = mpInstance.Identity.getCurrentUser();
43
79
  if (currentUser) {
44
80
  mpid = currentUser.getMPID();
45
81
  }
46
82
  if (mpInstance._Store.eventQueue.length && mpid) {
47
- var localQueueCopy = mpInstance._Store.eventQueue;
83
+ const localQueueCopy = mpInstance._Store.eventQueue;
48
84
  mpInstance._Store.eventQueue = [];
49
85
  this.appendUserInfoToEvents(currentUser, localQueueCopy);
50
86
  localQueueCopy.forEach(function(event) {
@@ -62,10 +98,10 @@ export default function APIClient(mpInstance, kitBlocker) {
62
98
  };
63
99
 
64
100
  this.sendEventToServer = function(event, _options) {
65
- var defaultOptions = {
101
+ const defaultOptions = {
66
102
  shouldUploadEvent: true,
67
103
  };
68
- var options = mpInstance._Helpers.extend(defaultOptions, _options);
104
+ const options = mpInstance._Helpers.extend(defaultOptions, _options);
69
105
 
70
106
  if (mpInstance._Store.webviewBridgeEnabled) {
71
107
  mpInstance._NativeSdkHelpers.sendToNative(
@@ -75,7 +111,7 @@ export default function APIClient(mpInstance, kitBlocker) {
75
111
  return;
76
112
  }
77
113
 
78
- var mpid,
114
+ let mpid,
79
115
  currentUser = mpInstance.Identity.getCurrentUser();
80
116
  if (currentUser) {
81
117
  mpid = currentUser.getMPID();
@@ -126,7 +162,7 @@ export default function APIClient(mpInstance, kitBlocker) {
126
162
  if (event.EventDataType === Types.MessageType.Media) {
127
163
  return;
128
164
  }
129
- var xhr,
165
+ let xhr,
130
166
  xhrCallback = function() {
131
167
  if (xhr.readyState === 4) {
132
168
  mpInstance.Logger.verbose(
@@ -153,7 +189,9 @@ export default function APIClient(mpInstance, kitBlocker) {
153
189
  );
154
190
  xhr.send(
155
191
  JSON.stringify(
156
- mpInstance._ServerModel.convertEventToDTO(event)
192
+ mpInstance._ServerModel.convertEventToDTO(
193
+ event as IUploadObject
194
+ )
157
195
  )
158
196
  );
159
197
  } catch (e) {
@@ -165,7 +203,8 @@ export default function APIClient(mpInstance, kitBlocker) {
165
203
  };
166
204
 
167
205
  this.sendBatchForwardingStatsToServer = function(forwardingStatsData, xhr) {
168
- var url, data;
206
+ let url;
207
+ let data;
169
208
  try {
170
209
  url = mpInstance._Helpers.createServiceUrl(
171
210
  mpInstance._Store.SDKConfig.v2SecureServiceUrl,
@@ -188,9 +227,10 @@ export default function APIClient(mpInstance, kitBlocker) {
188
227
  };
189
228
 
190
229
  this.sendSingleForwardingStatsToServer = function(forwardingStatsData) {
191
- var url, data;
230
+ let url;
231
+ let data;
192
232
  try {
193
- var xhrCallback = function() {
233
+ const xhrCallback = function() {
194
234
  if (xhr.readyState === 4) {
195
235
  if (xhr.status === 202) {
196
236
  mpInstance.Logger.verbose(
@@ -201,7 +241,7 @@ export default function APIClient(mpInstance, kitBlocker) {
201
241
  }
202
242
  }
203
243
  };
204
- var xhr = mpInstance._Helpers.createXHR(xhrCallback);
244
+ const xhr = mpInstance._Helpers.createXHR(xhrCallback);
205
245
  url = mpInstance._Helpers.createServiceUrl(
206
246
  mpInstance._Store.SDKConfig.v1SecureServiceUrl,
207
247
  mpInstance._Store.devToken
@@ -220,8 +260,8 @@ export default function APIClient(mpInstance, kitBlocker) {
220
260
  };
221
261
 
222
262
  this.prepareForwardingStats = function(forwarder, event) {
223
- var forwardingStatsData,
224
- queue = mpInstance._Forwarders.getForwarderStatsQueue();
263
+ let forwardingStatsData;
264
+ const queue = mpInstance._Forwarders.getForwarderStatsQueue();
225
265
 
226
266
  if (forwarder && forwarder.isVisible) {
227
267
  forwardingStatsData = {
@@ -0,0 +1,89 @@
1
+ // TODO: Migrate this to Consent.ts when that is created
2
+ import { ConsentState, PrivacyConsentState } from '@mparticle/web-sdk';
3
+
4
+ export interface IGDPRConsentObject {
5
+ purpose: string;
6
+ }
7
+
8
+ export interface ICCPAConsentObject {
9
+ purpose: string;
10
+ }
11
+
12
+ export interface IConsentJSONObject {
13
+ gdpr?: Partial<IGDPRConsentObject>;
14
+ ccpa?: Partial<ICCPAConsentObject>;
15
+ }
16
+
17
+ interface ICreatePrivacyConsentFunction {
18
+ (
19
+ consented: boolean,
20
+ timestamp?: number,
21
+ consentDocument?: string,
22
+ location?: string,
23
+ hardwareId?: string
24
+ ): PrivacyConsentState | null;
25
+ }
26
+
27
+ // TODO: Refactor this with Consent Namespace in @types/mparticle-web-sdk
28
+ // https://go.mparticle.com/work/SQDSDKS-5009
29
+ export interface SDKConsentApi {
30
+ createGDPRConsent: ICreatePrivacyConsentFunction;
31
+ createCCPAConsent: ICreatePrivacyConsentFunction;
32
+ createConsentState: (consentState?: ConsentState) => ConsentState;
33
+ ConsentSerialization: IConsentSerialization;
34
+ createPrivacyConsent: ICreatePrivacyConsentFunction;
35
+ }
36
+
37
+ export interface IConsentSerialization {
38
+ toMinifiedJsonObject: (state: ConsentState) => IConsentJSONObject;
39
+ fromMinifiedJsonObject: (json: IConsentJSONObject) => ConsentState;
40
+ }
41
+
42
+ // TODO: Resolve discrepency between ConsentState and SDKConsentState
43
+ // https://go.mparticle.com/work/SQDSDKS-5009
44
+ export interface SDKConsentState
45
+ extends Omit<ConsentState, 'getGDPRConsentState' | 'getCCPAConsentState'> {
46
+ getGDPRConsentState(): SDKGDPRConsentState;
47
+ getCCPAConsentState(): SDKCCPAConsentState;
48
+ }
49
+
50
+ export interface SDKGDPRConsentState {
51
+ [key: string]: SDKConsentStateData;
52
+ }
53
+
54
+ // TODO: Resolve discrepency between ConsentState and SDKConsentState
55
+ // https://go.mparticle.com/work/SQDSDKS-5009
56
+ // Specifically PrivacyConsentState, GDPRConsentState and CCPAConsentState
57
+ // Treat all attributes as required, but we had to override this
58
+ // to be optional for a bugfix:
59
+ // https://github.com/mParticle/mparticle-web-sdk/commit/3b11ead79f25b417737442a4fabd6435750f46b8
60
+ export interface SDKConsentStateData {
61
+ Consented: boolean;
62
+ Timestamp?: number;
63
+ ConsentDocument?: string;
64
+ Location?: string;
65
+ HardwareId?: string;
66
+ }
67
+
68
+ export interface SDKCCPAConsentState extends SDKConsentStateData {}
69
+
70
+ export interface IPrivacyV2DTO {
71
+ c: boolean; // Consented
72
+ ts: number; // Timestamp
73
+ d: string; // Document
74
+ l: string; // Location
75
+ h: string; // HardwareID
76
+ }
77
+
78
+ export interface IGDPRConsentStateDTO {
79
+ [key: string]: IPrivacyV2DTO;
80
+ }
81
+
82
+ export interface ICCPAConsentStateDTO {
83
+ data_sale_opt_out: IPrivacyV2DTO;
84
+ }
85
+
86
+ export interface IConsentStateDTO {
87
+ gdpr?: IGDPRConsentStateDTO;
88
+ ccpa?: ICCPAConsentStateDTO;
89
+ }
@@ -7,15 +7,15 @@ import * as EventsApi from '@mparticle/event-models';
7
7
 
8
8
  const mockFunction = function () {
9
9
  return null;
10
- }
10
+ };
11
11
  export default class _BatchValidator {
12
12
  private getMPInstance() {
13
13
  return {
14
14
  // Certain Helper, Store, and Identity properties need to be mocked to be used in the `returnBatch` method
15
15
  _Helpers: {
16
- sanitizeAttributes: window.mParticle.getInstance()._Helpers
17
- .sanitizeAttributes,
18
- generateUniqueId: function() {
16
+ sanitizeAttributes:
17
+ window.mParticle.getInstance()._Helpers.sanitizeAttributes,
18
+ generateUniqueId: function () {
19
19
  return 'mockId';
20
20
  },
21
21
  extend: window.mParticle.getInstance()._Helpers.extend,
@@ -28,6 +28,11 @@ export default class _BatchValidator {
28
28
  _resetForTests: mockFunction,
29
29
  _APIClient: null,
30
30
  _Consent: null,
31
+ _Forwarders: null,
32
+ _NativeSdkHelpers: null,
33
+ _Persistence: null,
34
+ _preInit: null,
35
+ Consent: null,
31
36
  _ServerModel: null,
32
37
  _SessionManager: null,
33
38
  _Store: {
@@ -1,12 +1,12 @@
1
1
  import * as EventsApi from '@mparticle/event-models';
2
- import { Batch } from '@mparticle/event-models';
3
- import { DataPlanVersion, DataPlan } from '@mparticle/data-planning-models';
2
+ import { DataPlanVersion } from '@mparticle/data-planning-models';
4
3
  import { MPConfiguration, IdentityApiData } from '@mparticle/web-sdk';
5
- import { IStore, SDKConfig } from './store';
4
+ import { IStore } from './store';
6
5
  import Validators from './validators';
7
6
  import { Dictionary } from './utils';
8
7
  import { IServerModel } from './serverModel';
9
8
  import { IKitConfigs } from './configAPIClient';
9
+ import { SDKConsentApi, SDKConsentState } from './consent.interfaces';
10
10
 
11
11
  // TODO: Resolve this with version in @mparticle/web-sdk
12
12
  export type SDKEventCustomFlags = Dictionary<any>;
@@ -131,12 +131,17 @@ export interface MParticleWebSDK {
131
131
  Logger: SDKLoggerApi;
132
132
  _APIClient: any; // TODO: Set up API Client
133
133
  _Store: IStore;
134
+ _Forwarders: any;
134
135
  _Helpers: SDKHelpersApi;
135
136
  config: SDKInitConfig;
136
137
  _ServerModel: IServerModel;
137
138
  _SessionManager: any; // TODO: Set up Session Manager
138
- _Consent: any; // TODO: Set up Consent SDK
139
- _resetForTests(MPConfig?: SDKConfig): void;
139
+ _Consent: SDKConsentApi;
140
+ Consent: SDKConsentApi;
141
+ _NativeSdkHelpers: any; // TODO: Set up API
142
+ _Persistence: any; // TODO: Set up Persistence API
143
+ _preInit: any; // TODO: Set up API
144
+ _resetForTests(MPConfig?: SDKInitConfig): void;
140
145
  init(apiKey: string, config: SDKInitConfig, instanceName?: string): void;
141
146
  getAppName(): string;
142
147
  getAppVersion(): string;
@@ -220,12 +225,19 @@ export interface SDKIdentityApi {
220
225
  export interface SDKHelpersApi {
221
226
  createServiceUrl(arg0: string, arg1: string): void;
222
227
  createXHR?(cb: () => void): XMLHttpRequest;
223
- extend(...args: any[]);
224
- parseNumber(value: string | number): number;
228
+ extend?(...args: any[]);
229
+ parseNumber?(value: string | number): number;
225
230
  generateUniqueId();
226
- isObject(item: any);
231
+ getFeatureFlag?(feature: string); // TODO: Feature Constants should be converted to enum
232
+ getRampNumber?(deviceId: string): number;
233
+ isDelayedByIntegration?(
234
+ delayedIntegrations: Dictionary<boolean>,
235
+ timeoutStart: number,
236
+ now: number
237
+ ): boolean;
238
+ isObject?(item: any);
227
239
  returnConvertedBoolean(data: string | boolean | number): boolean;
228
- sanitizeAttributes(
240
+ sanitizeAttributes?(
229
241
  attrs: Dictionary<string>,
230
242
  name: string
231
243
  ): Dictionary<string> | null;
@@ -254,6 +266,9 @@ export interface SDKConfigApi {
254
266
  appVersion?: string;
255
267
  onCreateBatch(batch: EventsApi.Batch): EventsApi.Batch;
256
268
  }
269
+
270
+ // FIXME: Resolve with User in @types/mparticle-web-sdk
271
+ // https://go.mparticle.com/work/SQDSDKS-5033
257
272
  export interface MParticleUser {
258
273
  getMPID(): string;
259
274
  getConsentState(): any; // FIXME:
@@ -261,25 +276,6 @@ export interface MParticleUser {
261
276
  getUserIdentities(): IdentityApiData; // FIXME: Is this correct?
262
277
  }
263
278
 
264
- export interface SDKConsentState {
265
- getGDPRConsentState(): SDKGDPRConsentState;
266
- getCCPAConsentState(): SDKCCPAConsentState;
267
- }
268
-
269
- export interface SDKGDPRConsentState {
270
- [key: string]: SDKConsentStateData;
271
- }
272
-
273
- export interface SDKConsentStateData {
274
- Consented: boolean;
275
- Timestamp?: number;
276
- ConsentDocument?: string;
277
- Location?: string;
278
- HardwareId?: string;
279
- }
280
-
281
- export interface SDKCCPAConsentState extends SDKConsentStateData {}
282
-
283
279
  export interface SDKUserIdentityChangeData {
284
280
  New: Identity;
285
281
  Old: Identity;
@@ -1,9 +1,6 @@
1
1
  import {
2
2
  SDKEvent,
3
- SDKConsentState,
4
- SDKGDPRConsentState,
5
3
  SDKGeoLocation,
6
- SDKCCPAConsentState,
7
4
  SDKProduct,
8
5
  SDKPromotion,
9
6
  SDKUserIdentity,
@@ -12,7 +9,13 @@ import {
12
9
  SDKIdentityTypeEnum,
13
10
  } from './sdkRuntimeModels';
14
11
  import * as EventsApi from '@mparticle/event-models';
12
+ import {
13
+ SDKConsentState,
14
+ SDKGDPRConsentState,
15
+ SDKCCPAConsentState,
16
+ } from './consent.interfaces';
15
17
  import Types from './types';
18
+ import { isEmpty } from './utils';
16
19
 
17
20
  export function convertEvents(
18
21
  mpid: string,
@@ -26,6 +29,8 @@ export function convertEvents(
26
29
  return null;
27
30
  }
28
31
 
32
+ const user = mpInstance.Identity.getCurrentUser();
33
+
29
34
  const uploadEvents: EventsApi.BaseEvent[] = [];
30
35
  let lastEvent: SDKEvent = null;
31
36
  for (const sdkEvent of sdkEvents) {
@@ -42,6 +47,15 @@ export function convertEvents(
42
47
  return null;
43
48
  }
44
49
 
50
+ let currentConsentState: SDKConsentState = null;
51
+
52
+ // Add the consent state from either the Last Event or the user
53
+ if (!isEmpty(lastEvent.ConsentState)) {
54
+ currentConsentState = lastEvent.ConsentState;
55
+ } else if (!isEmpty(user)) {
56
+ currentConsentState = user.getConsentState();
57
+ }
58
+
45
59
  const upload: EventsApi.Batch = {
46
60
  source_request_id: mpInstance._Helpers.generateUniqueId(),
47
61
  mpid,
@@ -64,7 +78,7 @@ export function convertEvents(
64
78
  },
65
79
  user_attributes: lastEvent.UserAttributes,
66
80
  user_identities: convertUserIdentities(lastEvent.UserIdentities),
67
- consent_state: convertConsentState(lastEvent.ConsentState),
81
+ consent_state: convertConsentState(currentConsentState),
68
82
  integration_attributes: lastEvent.IntegrationAttributes,
69
83
  };
70
84
 
@@ -82,7 +96,7 @@ export function convertEvents(
82
96
  export function convertConsentState(
83
97
  sdkConsentState?: SDKConsentState
84
98
  ): EventsApi.ConsentState | null {
85
- if (!sdkConsentState) {
99
+ if (isEmpty(sdkConsentState)) {
86
100
  return null;
87
101
  }
88
102
  const consentState: EventsApi.ConsentState = {
@@ -327,7 +341,8 @@ export function convertPromotionAction(
327
341
  return null;
328
342
  }
329
343
  const promotionAction: EventsApi.PromotionAction = {
330
- action: sdkEvent.PromotionAction.PromotionActionType as EventsApi.PromotionActionActionEnum,
344
+ action: sdkEvent.PromotionAction
345
+ .PromotionActionType as EventsApi.PromotionActionActionEnum,
331
346
  promotions: convertPromotions(sdkEvent.PromotionAction.PromotionList),
332
347
  };
333
348
  return promotionAction;
@@ -388,9 +403,8 @@ export function convertShoppingCart(
388
403
  export function convertCommerceEvent(
389
404
  sdkEvent: SDKEvent
390
405
  ): EventsApi.CommerceEvent {
391
- const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
392
- sdkEvent
393
- );
406
+ const commonEventData: EventsApi.CommonEventData =
407
+ convertBaseEventData(sdkEvent);
394
408
  let commerceEventData: EventsApi.CommerceEventData = {
395
409
  custom_flags: sdkEvent.CustomFlags,
396
410
  product_action: convertProductAction(sdkEvent),
@@ -409,9 +423,8 @@ export function convertCommerceEvent(
409
423
  export function convertCrashReportEvent(
410
424
  sdkEvent: SDKEvent
411
425
  ): EventsApi.CrashReportEvent {
412
- const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
413
- sdkEvent
414
- );
426
+ const commonEventData: EventsApi.CommonEventData =
427
+ convertBaseEventData(sdkEvent);
415
428
  let crashReportEventData: EventsApi.CrashReportEventData = {
416
429
  message: sdkEvent.EventName,
417
430
  };
@@ -425,9 +438,8 @@ export function convertCrashReportEvent(
425
438
  export function convertAST(
426
439
  sdkEvent: SDKEvent
427
440
  ): EventsApi.ApplicationStateTransitionEvent {
428
- const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
429
- sdkEvent
430
- );
441
+ const commonEventData: EventsApi.CommonEventData =
442
+ convertBaseEventData(sdkEvent);
431
443
  let astEventData: EventsApi.ApplicationStateTransitionEventData = {
432
444
  application_transition_type:
433
445
  EventsApi
@@ -447,9 +459,8 @@ export function convertAST(
447
459
  export function convertSessionEndEvent(
448
460
  sdkEvent: SDKEvent
449
461
  ): EventsApi.SessionEndEvent {
450
- const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
451
- sdkEvent
452
- );
462
+ const commonEventData: EventsApi.CommonEventData =
463
+ convertBaseEventData(sdkEvent);
453
464
  let sessionEndEventData: EventsApi.SessionEndEventData = {
454
465
  session_duration_ms: sdkEvent.SessionLength,
455
466
  //note: External Events DTO does not support the session mpids array as of this time.
@@ -465,9 +476,8 @@ export function convertSessionEndEvent(
465
476
  export function convertSessionStartEvent(
466
477
  sdkEvent: SDKEvent
467
478
  ): EventsApi.SessionStartEvent {
468
- const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
469
- sdkEvent
470
- );
479
+ const commonEventData: EventsApi.CommonEventData =
480
+ convertBaseEventData(sdkEvent);
471
481
  let sessionStartEventData: EventsApi.SessionStartEventData = {};
472
482
  sessionStartEventData = Object.assign(
473
483
  sessionStartEventData,
@@ -482,9 +492,8 @@ export function convertSessionStartEvent(
482
492
  export function convertPageViewEvent(
483
493
  sdkEvent: SDKEvent
484
494
  ): EventsApi.ScreenViewEvent {
485
- const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
486
- sdkEvent
487
- );
495
+ const commonEventData: EventsApi.CommonEventData =
496
+ convertBaseEventData(sdkEvent);
488
497
  let screenViewEventData: EventsApi.ScreenViewEventData = {
489
498
  custom_flags: sdkEvent.CustomFlags,
490
499
  screen_name: sdkEvent.EventName,
@@ -497,9 +506,8 @@ export function convertPageViewEvent(
497
506
  }
498
507
 
499
508
  export function convertOptOutEvent(sdkEvent: SDKEvent): EventsApi.OptOutEvent {
500
- const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
501
- sdkEvent
502
- );
509
+ const commonEventData: EventsApi.CommonEventData =
510
+ convertBaseEventData(sdkEvent);
503
511
  let optOutEventData: EventsApi.OptOutEventData = {
504
512
  is_opted_out: sdkEvent.OptOut,
505
513
  };
@@ -511,9 +519,8 @@ export function convertOptOutEvent(sdkEvent: SDKEvent): EventsApi.OptOutEvent {
511
519
  }
512
520
 
513
521
  export function convertCustomEvent(sdkEvent: SDKEvent): EventsApi.CustomEvent {
514
- const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
515
- sdkEvent
516
- );
522
+ const commonEventData: EventsApi.CommonEventData =
523
+ convertBaseEventData(sdkEvent);
517
524
  let customEventData: EventsApi.CustomEventData = {
518
525
  custom_event_type: convertSdkEventType(
519
526
  sdkEvent.EventCategory
@@ -596,7 +603,7 @@ export function convertBaseEventData(
596
603
  session_start_unixtime_ms: sdkEvent.SessionStartDate,
597
604
  custom_attributes: sdkEvent.EventAttributes,
598
605
  location: convertSDKLocation(sdkEvent.Location),
599
- source_message_id: sdkEvent.SourceMessageId
606
+ source_message_id: sdkEvent.SourceMessageId,
600
607
  };
601
608
 
602
609
  return commonEventData;
@@ -617,9 +624,8 @@ export function convertSDKLocation(
617
624
  export function convertUserAttributeChangeEvent(
618
625
  sdkEvent: SDKEvent
619
626
  ): EventsApi.UserAttributeChangeEvent | null {
620
- const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
621
- sdkEvent
622
- );
627
+ const commonEventData: EventsApi.CommonEventData =
628
+ convertBaseEventData(sdkEvent);
623
629
  let userAttributeChangeEvent: EventsApi.UserAttributeChangeEventData = {
624
630
  user_attribute_name: sdkEvent.UserAttributeChanges.UserAttributeName,
625
631
  new: sdkEvent.UserAttributeChanges.New,
@@ -642,9 +648,8 @@ export function convertUserAttributeChangeEvent(
642
648
  export function convertUserIdentityChangeEvent(
643
649
  sdkEvent: SDKEvent
644
650
  ): EventsApi.UserIdentityChangeEvent | null {
645
- const commonEventData: EventsApi.CommonEventData = convertBaseEventData(
646
- sdkEvent
647
- );
651
+ const commonEventData: EventsApi.CommonEventData =
652
+ convertBaseEventData(sdkEvent);
648
653
 
649
654
  let userIdentityChangeEvent: EventsApi.UserIdentityChangeEventData = {
650
655
  new: {
@@ -683,48 +688,48 @@ export function convertUserIdentityTypeToServerIdentityType(
683
688
  ): EventsApi.IdentityType {
684
689
  switch (identityType) {
685
690
  case SDKIdentityTypeEnum.other:
686
- return EventsApi.IdentityTypeEnum.other
691
+ return EventsApi.IdentityTypeEnum.other;
687
692
  case SDKIdentityTypeEnum.customerId:
688
- return EventsApi.IdentityTypeEnum.customerId
693
+ return EventsApi.IdentityTypeEnum.customerId;
689
694
  case SDKIdentityTypeEnum.facebook:
690
- return EventsApi.IdentityTypeEnum.facebook
695
+ return EventsApi.IdentityTypeEnum.facebook;
691
696
  case SDKIdentityTypeEnum.twitter:
692
- return EventsApi.IdentityTypeEnum.twitter
697
+ return EventsApi.IdentityTypeEnum.twitter;
693
698
  case SDKIdentityTypeEnum.google:
694
- return EventsApi.IdentityTypeEnum.google
699
+ return EventsApi.IdentityTypeEnum.google;
695
700
  case SDKIdentityTypeEnum.microsoft:
696
- return EventsApi.IdentityTypeEnum.microsoft
701
+ return EventsApi.IdentityTypeEnum.microsoft;
697
702
  case SDKIdentityTypeEnum.yahoo:
698
- return EventsApi.IdentityTypeEnum.yahoo
703
+ return EventsApi.IdentityTypeEnum.yahoo;
699
704
  case SDKIdentityTypeEnum.email:
700
- return EventsApi.IdentityTypeEnum.email
705
+ return EventsApi.IdentityTypeEnum.email;
701
706
  case SDKIdentityTypeEnum.alias:
702
- return EventsApi.IdentityTypeEnum.alias
707
+ return EventsApi.IdentityTypeEnum.alias;
703
708
  case SDKIdentityTypeEnum.facebookCustomAudienceId:
704
- return EventsApi.IdentityTypeEnum.facebookCustomAudienceId
709
+ return EventsApi.IdentityTypeEnum.facebookCustomAudienceId;
705
710
  case SDKIdentityTypeEnum.otherId2:
706
- return EventsApi.IdentityTypeEnum.otherId2
711
+ return EventsApi.IdentityTypeEnum.otherId2;
707
712
  case SDKIdentityTypeEnum.otherId3:
708
- return EventsApi.IdentityTypeEnum.otherId3
713
+ return EventsApi.IdentityTypeEnum.otherId3;
709
714
  case SDKIdentityTypeEnum.otherId4:
710
- return EventsApi.IdentityTypeEnum.otherId4
715
+ return EventsApi.IdentityTypeEnum.otherId4;
711
716
  case SDKIdentityTypeEnum.otherId5:
712
- return EventsApi.IdentityTypeEnum.otherId5
717
+ return EventsApi.IdentityTypeEnum.otherId5;
713
718
  case SDKIdentityTypeEnum.otherId6:
714
- return EventsApi.IdentityTypeEnum.otherId6
719
+ return EventsApi.IdentityTypeEnum.otherId6;
715
720
  case SDKIdentityTypeEnum.otherId7:
716
- return EventsApi.IdentityTypeEnum.otherId7
721
+ return EventsApi.IdentityTypeEnum.otherId7;
717
722
  case SDKIdentityTypeEnum.otherId8:
718
- return EventsApi.IdentityTypeEnum.otherId8
723
+ return EventsApi.IdentityTypeEnum.otherId8;
719
724
  case SDKIdentityTypeEnum.otherId9:
720
- return EventsApi.IdentityTypeEnum.otherId9
725
+ return EventsApi.IdentityTypeEnum.otherId9;
721
726
  case SDKIdentityTypeEnum.otherId10:
722
- return EventsApi.IdentityTypeEnum.otherId10
727
+ return EventsApi.IdentityTypeEnum.otherId10;
723
728
  case SDKIdentityTypeEnum.mobileNumber:
724
- return EventsApi.IdentityTypeEnum.mobileNumber
729
+ return EventsApi.IdentityTypeEnum.mobileNumber;
725
730
  case SDKIdentityTypeEnum.phoneNumber2:
726
- return EventsApi.IdentityTypeEnum.phoneNumber2
731
+ return EventsApi.IdentityTypeEnum.phoneNumber2;
727
732
  case SDKIdentityTypeEnum.phoneNumber3:
728
- return EventsApi.IdentityTypeEnum.phoneNumber3
733
+ return EventsApi.IdentityTypeEnum.phoneNumber3;
729
734
  }
730
735
  }