@mparticle/web-sdk 2.32.3 → 2.32.4

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.
@@ -3,22 +3,19 @@ import { DataPlanVersion } from '@mparticle/data-planning-models';
3
3
  import {
4
4
  MPConfiguration,
5
5
  MPID,
6
- IdentityApiData,
7
6
  SDKEventOptions,
8
7
  SDKEventAttrs,
8
+ Callback,
9
9
  } from '@mparticle/web-sdk';
10
- import { IStore } from './store';
10
+ import { IntegrationAttribute, IntegrationAttributes, IStore, WrapperSDKTypes } from './store';
11
11
  import Validators from './validators';
12
12
  import { Dictionary, valueof } from './utils';
13
- import { IServerModel } from './serverModel';
14
13
  import { IKitConfigs } from './configAPIClient';
15
14
  import { SDKConsentApi, SDKConsentState } from './consent';
16
- import { IPersistence } from './persistence.interfaces';
17
- import { IMPSideloadedKit } from './sideloadedKit';
15
+ import MPSideloadedKit from './sideloadedKit';
18
16
  import { ISessionManager } from './sessionManager';
19
17
  import { Kit, MPForwarder } from './forwarders.interfaces';
20
18
  import {
21
- IIdentity,
22
19
  SDKIdentityApi,
23
20
  IAliasCallback,
24
21
  } from './identity.interfaces';
@@ -34,13 +31,14 @@ import {
34
31
  CommerceEventType,
35
32
  EventType,
36
33
  IdentityType,
34
+ ProductActionType,
37
35
  PromotionActionType,
38
36
  } from './types';
39
- import IntegrationCapture from './integrationCapture';
40
- import { INativeSdkHelpers } from './nativeSdkHelpers.interfaces';
41
- import { ICookieSyncManager, IPixelConfiguration } from './cookieSyncManager';
42
- import { IEvents } from './events.interfaces';
43
- import { IECommerce, SDKECommerceAPI } from './ecommerce.interfaces';
37
+ import { IPixelConfiguration } from './cookieSyncManager';
38
+ import _BatchValidator from './mockBatchCreator';
39
+ import { SDKECommerceAPI } from './ecommerce.interfaces';
40
+ import { IErrorLogMessage, IMParticleWebSDKInstance, IntegrationDelays } from './mp-instance';
41
+ import Constants from './constants';
44
42
 
45
43
  // TODO: Resolve this with version in @mparticle/web-sdk
46
44
  export type SDKEventCustomFlags = Dictionary<any>;
@@ -70,7 +68,7 @@ export interface SDKEvent {
70
68
  AppName?: string;
71
69
  Package?: string;
72
70
  ConsentState?: SDKConsentState;
73
- IntegrationAttributes?: { [key: string]: { [key: string]: string } };
71
+ IntegrationAttributes?: IntegrationAttributes;
74
72
  ProductAction?: SDKProductAction;
75
73
  PromotionAction?: SDKPromotionAction;
76
74
  ProductImpressions?: SDKProductImpression[];
@@ -161,51 +159,36 @@ export interface SDKProduct {
161
159
  Attributes?: Record<string, unknown> | null;
162
160
  }
163
161
 
162
+ // https://go.mparticle.com/work/SQDSDKS-6949
164
163
  export interface MParticleWebSDK {
165
164
  addForwarder(mockForwarder: MPForwarder): void;
166
- _IntegrationCapture: IntegrationCapture;
167
165
  IdentityType: valueof<typeof IdentityType>;
168
166
  CommerceEventType: valueof<typeof CommerceEventType>;
169
167
  EventType: valueof<typeof EventType>;
170
168
  PromotionType: valueof<typeof PromotionActionType>;
171
- _Identity: IIdentity;
172
169
  Identity: SDKIdentityApi;
173
170
  Logger: SDKLoggerApi;
174
- MPSideloadedKit: IMPSideloadedKit;
175
- _APIClient: any; // TODO: Set up API Client
176
- _CookieSyncManager: ICookieSyncManager;
177
- _Store: IStore;
178
- _Forwarders: any;
179
- _Helpers: SDKHelpersApi;
180
- _Events: IEvents;
181
- _Ecommerce: IECommerce;
182
- config: SDKInitConfig;
183
- _ServerModel: IServerModel;
184
- _SessionManager: ISessionManager;
185
- _Consent: SDKConsentApi;
186
171
  Consent: SDKConsentApi;
187
- _NativeSdkHelpers: INativeSdkHelpers;
188
- _Persistence: IPersistence;
189
- _preInit: any; // TODO: Set up API
190
- _instances?: Dictionary<MParticleWebSDK>;
191
- _isTestEnv?: boolean;
192
172
  _resetForTests(
193
173
  MPConfig?: SDKInitConfig,
194
174
  keepPersistence?: boolean,
195
- instance?: MParticleWebSDK
175
+ instance?: IMParticleWebSDKInstance,
196
176
  ): void;
177
+ configurePixel(config: IPixelConfiguration): void;
197
178
  endSession(): void;
198
- identifyRequest: IdentityApiData;
199
179
  init(apiKey: string, config: SDKInitConfig, instanceName?: string): void;
200
180
  _getActiveForwarders(): MPForwarder[];
181
+ _getIntegrationDelays(): IntegrationDelays;
182
+ _setIntegrationDelay(module: number, shouldDelayIntegration: boolean): void;
183
+ _setWrapperSDKInfo(name: WrapperSDKTypes, version: string): void;
201
184
  getAppName(): string;
202
185
  getAppVersion(): string;
203
186
  getDeviceId(): string;
204
187
  setDeviceId(deviceId: string): void;
188
+ getEnvironment(): valueof<typeof Constants.Environment>;
205
189
  setSessionAttribute(key: string, value: string): void;
206
- getInstance(instanceName?: string): MParticleWebSDK; // https://go.mparticle.com/work/SQDSDKS-4804
207
- ServerModel();
208
- upload();
190
+ getVersion(): string;
191
+ upload(): void;
209
192
  setLogLevel(logLevel: LogLevelType): void;
210
193
  setPosition(lat: number | string, lng: number | string): void;
211
194
  startNewSession(): void;
@@ -217,14 +200,52 @@ export interface MParticleWebSDK {
217
200
  eventOptions?: SDKEventOptions
218
201
  ): void;
219
202
  logBaseEvent(event: BaseEvent, eventOptions?: SDKEventOptions): void;
203
+ logError(error: IErrorLogMessage, attrs?: SDKEventAttrs): void;
204
+ logLink(selector: string, eventName: string, eventType: valueof<typeof EventType>, eventInfo: SDKEventAttrs): void;
205
+ logForm(selector: string, eventName: string, eventType: valueof<typeof EventType>, eventInfo: SDKEventAttrs): void;
206
+ logPageView(eventName: string, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
207
+ setOptOut(isOptingOut: boolean): void;
220
208
  eCommerce: SDKECommerceAPI;
221
- logLevel: string;
222
- ProductActionType: SDKProductActionType;
209
+ isInitialized(): boolean;
210
+ ProductActionType: valueof<typeof ProductActionType>;
211
+ ready(f: Function): void;
212
+ reset(instance: IMParticleWebSDKInstance): void;
213
+ setAppName(name: string): void;
214
+ setAppVersion(version: string): void;
215
+ setOptOut(isOptingOut: boolean): void;
216
+
217
+ // https://go.mparticle.com/work/SQDSDKS-7063
218
+ startTrackingLocation(callback?: Callback): void;
219
+
220
+ stopTrackingLocation(): void;
223
221
  generateHash(value: string): string;
222
+ setIntegrationAttribute(integrationModuleId: number, attrs: IntegrationAttribute): void;
223
+ getIntegrationAttributes(integrationModuleId: number): IntegrationAttribute;
224
+ }
225
+
226
+ // https://go.mparticle.com/work/SQDSDKS-4805
227
+
228
+ // https://go.mparticle.com/work/SQDSDKS-6949
229
+ export interface IMParticleInstanceManager extends MParticleWebSDK {
230
+ // https://go.mparticle.com/work/SQDSDKS-5053
231
+ // Private Properties
232
+ _BatchValidator: _BatchValidator;
233
+ _instances: Dictionary<IMParticleWebSDKInstance>;
234
+ _isTestEnv?: boolean;
235
+
236
+ // Public Properties
237
+ config: SDKInitConfig;
224
238
  isIOS?: boolean;
225
- sessionManager: Pick<ISessionManager, 'getSession'>; // https://go.mparticle.com/work/SQDSDKS-6949
239
+ MPSideloadedKit: typeof MPSideloadedKit;
240
+ // https://go.mparticle.com/work/SQDSDKS-7060
241
+ sessionManager: Pick<ISessionManager, 'getSession'>;
242
+ Store: IStore;
243
+
244
+ // Public Methods
245
+ getInstance(instanceName?: string): IMParticleWebSDKInstance;
226
246
  }
227
247
 
248
+
228
249
  // Used in cases where server requires booleans as strings
229
250
  export type BooleanStringLowerCase = 'false' | 'true';
230
251
  export type BooleanStringTitleCase = 'False' | 'True';
@@ -271,6 +292,8 @@ export interface SDKInitConfig
271
292
 
272
293
  // https://go.mparticle.com/work/SQDSDKS-6460
273
294
  identityCallback?: IdentityCallback;
295
+
296
+ rq?: Function[] | any[];
274
297
  }
275
298
 
276
299
  export interface DataPlanConfig {
@@ -286,6 +309,7 @@ export interface SDKHelpersApi {
286
309
  createServiceUrl(url: string, devToken?: string): string;
287
310
  createXHR?(cb: () => void): XMLHttpRequest;
288
311
  extend?(...args: any[]);
312
+ findKeyInObject?(obj: any, key: string): string;
289
313
  parseNumber?(value: string | number): number;
290
314
  generateUniqueId();
291
315
  generateHash?(value: string): string;
@@ -311,7 +335,7 @@ export interface SDKHelpersApi {
311
335
  previousMpid?: MPID
312
336
  ): void;
313
337
  sanitizeAttributes?(
314
- attrs: Dictionary<string>,
338
+ attrs: SDKEventAttrs,
315
339
  name: string
316
340
  ): Dictionary<string> | null;
317
341
  Validators: typeof Validators;
@@ -321,6 +345,7 @@ export interface SDKLoggerApi {
321
345
  error(arg0: string): void;
322
346
  verbose(arg0: string): void;
323
347
  warning(arg0: string): void;
348
+ setLogLevel(logLevel: LogLevelType): void;
324
349
  }
325
350
 
326
351
  // TODO: Merge this with IStore in store.ts
@@ -344,7 +369,7 @@ export interface BaseEvent {
344
369
  messageType: number;
345
370
  name?: string;
346
371
  eventType?: number;
347
- data?: { [key: string]: string };
372
+ data?: SDKEventAttrs;
348
373
  customFlags?: { [key: string]: string };
349
374
  toEventAPIObject?(): SDKEvent;
350
375
  sourceMessageId?: string;
@@ -4,7 +4,6 @@ import {
4
4
  SDKProduct,
5
5
  SDKPromotion,
6
6
  SDKProductActionType,
7
- MParticleWebSDK,
8
7
  } from './sdkRuntimeModels';
9
8
  import * as EventsApi from '@mparticle/event-models';
10
9
  import {
@@ -17,6 +16,7 @@ import { Dictionary, isEmpty } from './utils';
17
16
  import { ISDKUserIdentity } from './identity-user-interfaces';
18
17
  import { SDKIdentityTypeEnum } from './identity.interfaces';
19
18
  import Constants from './constants';
19
+ import { IMParticleWebSDKInstance } from './mp-instance';
20
20
 
21
21
  const {
22
22
  FeatureFlags
@@ -35,7 +35,7 @@ interface Batch extends EventsApi.Batch {
35
35
  export function convertEvents(
36
36
  mpid: string,
37
37
  sdkEvents: SDKEvent[],
38
- mpInstance: MParticleWebSDK
38
+ mpInstance: IMParticleWebSDKInstance
39
39
  ): Batch | null {
40
40
  if (!mpid) {
41
41
  return null;
@@ -6,7 +6,6 @@ import Types from './types';
6
6
  import Constants from './constants';
7
7
  import {
8
8
  BaseEvent,
9
- MParticleWebSDK,
10
9
  SDKEvent,
11
10
  SDKEventCustomFlags,
12
11
  SDKGeoLocation,
@@ -27,6 +26,7 @@ import {
27
26
  SDKConsentState,
28
27
  } from './consent';
29
28
  import { IMParticleUser, ISDKUserIdentity } from './identity-user-interfaces';
29
+ import { IMParticleWebSDKInstance } from './mp-instance';
30
30
 
31
31
  const MessageType = Types.MessageType;
32
32
  const ApplicationTransitionType = Types.ApplicationTransitionType;
@@ -110,7 +110,7 @@ export interface IProductV2DTO {
110
110
  ps: number;
111
111
  cc: string | number;
112
112
  tpa: number;
113
- attrs: Record<string, unknown> | undefined;
113
+ attrs: Dictionary<string> | null;
114
114
  }
115
115
 
116
116
  export interface IPromotionV2DTO {
@@ -181,7 +181,7 @@ function convertProductToV2DTO(product: SDKProduct): IProductV2DTO {
181
181
  ps: parseNumber(product.Position),
182
182
  cc: parseStringOrNumber(product.CouponCode),
183
183
  tpa: parseNumber(product.TotalAmount),
184
- attrs: product.Attributes,
184
+ attrs: product.Attributes as Dictionary<string> | null,
185
185
  };
186
186
  }
187
187
 
@@ -197,7 +197,7 @@ function convertProductListToV2DTO(productList: SDKProduct[]): IProductV2DTO[] {
197
197
 
198
198
  export default function ServerModel(
199
199
  this: IServerModel,
200
- mpInstance: MParticleWebSDK
200
+ mpInstance: IMParticleWebSDKInstance
201
201
  ) {
202
202
  var self = this;
203
203
 
@@ -1,10 +1,10 @@
1
1
  import { MPID } from '@mparticle/web-sdk';
2
2
  import Constants from './constants';
3
3
  import { IPersistenceMinified } from './persistence.interfaces';
4
- import { MParticleWebSDK } from './sdkRuntimeModels';
5
4
  import Types from './types';
6
5
  import { generateDeprecationMessage } from './utils';
7
6
  import { IMParticleUser } from './identity-user-interfaces';
7
+ import { IMParticleWebSDKInstance } from './mp-instance';
8
8
 
9
9
  const { Messages } = Constants;
10
10
 
@@ -26,7 +26,7 @@ export interface ISessionManager {
26
26
 
27
27
  export default function SessionManager(
28
28
  this: ISessionManager,
29
- mpInstance: MParticleWebSDK
29
+ mpInstance: IMParticleWebSDKInstance
30
30
  ) {
31
31
  const self = this;
32
32
 
package/src/store.ts CHANGED
@@ -13,7 +13,6 @@ import {
13
13
  DataPlanResult,
14
14
  KitBlockerOptions,
15
15
  LogLevelType,
16
- MParticleWebSDK,
17
16
  SDKDataPlan,
18
17
  SDKEvent,
19
18
  SDKGeoLocation,
@@ -38,6 +37,7 @@ import {
38
37
  IPersistenceMinified,
39
38
  } from './persistence.interfaces';
40
39
  import { CookieSyncDates, IPixelConfiguration } from './cookieSyncManager';
40
+ import { IMParticleWebSDKInstance } from './mp-instance';
41
41
 
42
42
  // This represents the runtime configuration of the SDK AFTER
43
43
  // initialization has been complete and all settings and
@@ -121,10 +121,10 @@ function createSDKConfig(config: SDKInitConfig): SDKConfig {
121
121
  // to TypeScript
122
122
  export type ServerSettings = Dictionary;
123
123
  export type SessionAttributes = Dictionary;
124
- export type IntegrationAttributes = Dictionary<Dictionary<string>>;
125
-
126
- type WrapperSDKTypes = 'flutter' | 'none';
127
- interface WrapperSDKInfo {
124
+ export type IntegrationAttribute = Dictionary<string>;
125
+ export type IntegrationAttributes = Dictionary<IntegrationAttribute>;
126
+ export type WrapperSDKTypes = 'flutter' | 'none';
127
+ export interface WrapperSDKInfo {
128
128
  name: WrapperSDKTypes;
129
129
  version: string | null;
130
130
  isInfoSet: boolean;
@@ -142,6 +142,7 @@ export interface IFeatureFlags {
142
142
  // Temporary Interface until Store can be refactored as a class
143
143
  export interface IStore {
144
144
  isEnabled: boolean;
145
+ isInitialized: boolean;
145
146
  sessionAttributes: SessionAttributes;
146
147
  currentSessionMPIDs: MPID[];
147
148
  consentState: SDKConsentState | null;
@@ -213,7 +214,7 @@ export interface IStore {
213
214
  export default function Store(
214
215
  this: IStore,
215
216
  config: SDKInitConfig,
216
- mpInstance: MParticleWebSDK,
217
+ mpInstance: IMParticleWebSDKInstance,
217
218
  apiKey?: string
218
219
  ) {
219
220
  const {
package/src/uploaders.ts CHANGED
@@ -75,9 +75,11 @@ export class XHRUploader extends AsyncUploader {
75
75
 
76
76
  xhr.open(method, url);
77
77
 
78
- Object.entries(headers).forEach(([key, value]) => {
79
- xhr.setRequestHeader(key, value);
80
- });
78
+ for (const key in headers) {
79
+ if (headers.hasOwnProperty(key)) {
80
+ xhr.setRequestHeader(key, headers[key]);
81
+ }
82
+ }
81
83
 
82
84
  xhr.send(data);
83
85
  });