@mparticle/web-sdk 2.56.0 → 2.58.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 +39 -39
- package/dist/mparticle.esm.js +39 -39
- package/dist/mparticle.js +292 -62
- package/package.json +1 -1
- package/src/constants.ts +4 -0
- package/src/identityApiClient.ts +24 -11
- package/src/logger.ts +14 -5
- package/src/logging/reportingLogger.ts +192 -0
- package/src/logging/types.ts +32 -0
- package/src/mp-instance.ts +58 -11
- package/src/roktManager.ts +38 -6
- package/src/sdkRuntimeModels.ts +46 -17
- package/src/store.ts +31 -10
- package/src/types.ts +1 -0
- package/src/uploaders.ts +1 -0
package/src/sdkRuntimeModels.ts
CHANGED
|
@@ -7,18 +7,24 @@ import {
|
|
|
7
7
|
SDKEventAttrs,
|
|
8
8
|
Callback,
|
|
9
9
|
} from '@mparticle/web-sdk';
|
|
10
|
-
import {
|
|
10
|
+
import {
|
|
11
|
+
IntegrationAttribute,
|
|
12
|
+
IntegrationAttributes,
|
|
13
|
+
IStore,
|
|
14
|
+
WrapperSDKTypes,
|
|
15
|
+
} from './store';
|
|
11
16
|
import Validators from './validators';
|
|
12
17
|
import { Dictionary, valueof } from './utils';
|
|
13
18
|
import { IKitConfigs } from './configAPIClient';
|
|
14
19
|
import { SDKConsentApi, SDKConsentState } from './consent';
|
|
15
20
|
import MPSideloadedKit from './sideloadedKit';
|
|
16
21
|
import { ISessionManager } from './sessionManager';
|
|
17
|
-
import { ConfiguredKit, MPForwarder, UnregisteredKit } from './forwarders.interfaces';
|
|
18
22
|
import {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
23
|
+
ConfiguredKit,
|
|
24
|
+
MPForwarder,
|
|
25
|
+
UnregisteredKit,
|
|
26
|
+
} from './forwarders.interfaces';
|
|
27
|
+
import { SDKIdentityApi, IAliasCallback } from './identity.interfaces';
|
|
22
28
|
import {
|
|
23
29
|
ISDKUserAttributeChangeData,
|
|
24
30
|
ISDKUserIdentityChanges,
|
|
@@ -36,11 +42,16 @@ import {
|
|
|
36
42
|
} from './types';
|
|
37
43
|
import { IPixelConfiguration } from './cookieSyncManager';
|
|
38
44
|
import _BatchValidator from './mockBatchCreator';
|
|
39
|
-
import {
|
|
40
|
-
import {
|
|
45
|
+
import { SDKECommerceAPI } from './ecommerce.interfaces';
|
|
46
|
+
import {
|
|
47
|
+
IErrorLogMessage,
|
|
48
|
+
IMParticleWebSDKInstance,
|
|
49
|
+
IntegrationDelays,
|
|
50
|
+
} from './mp-instance';
|
|
41
51
|
import Constants from './constants';
|
|
42
52
|
import RoktManager, { IRoktLauncherOptions } from './roktManager';
|
|
43
53
|
import { IConsoleLogger } from './logger';
|
|
54
|
+
import { ErrorCodes } from './logging/types';
|
|
44
55
|
|
|
45
56
|
// TODO: Resolve this with version in @mparticle/web-sdk
|
|
46
57
|
export type SDKEventCustomFlags = Dictionary<any>;
|
|
@@ -178,7 +189,7 @@ export interface MParticleWebSDK {
|
|
|
178
189
|
_resetForTests(
|
|
179
190
|
MPConfig?: SDKInitConfig,
|
|
180
191
|
keepPersistence?: boolean,
|
|
181
|
-
instance?: IMParticleWebSDKInstance
|
|
192
|
+
instance?: IMParticleWebSDKInstance
|
|
182
193
|
): void;
|
|
183
194
|
configurePixel(config: IPixelConfiguration): void;
|
|
184
195
|
endSession(): void;
|
|
@@ -207,9 +218,24 @@ export interface MParticleWebSDK {
|
|
|
207
218
|
): void;
|
|
208
219
|
logBaseEvent(event: BaseEvent, eventOptions?: SDKEventOptions): void;
|
|
209
220
|
logError(error: IErrorLogMessage, attrs?: SDKEventAttrs): void;
|
|
210
|
-
logLink(
|
|
211
|
-
|
|
212
|
-
|
|
221
|
+
logLink(
|
|
222
|
+
selector: string,
|
|
223
|
+
eventName: string,
|
|
224
|
+
eventType: valueof<typeof EventType>,
|
|
225
|
+
eventInfo: SDKEventAttrs
|
|
226
|
+
): void;
|
|
227
|
+
logForm(
|
|
228
|
+
selector: string,
|
|
229
|
+
eventName: string,
|
|
230
|
+
eventType: valueof<typeof EventType>,
|
|
231
|
+
eventInfo: SDKEventAttrs
|
|
232
|
+
): void;
|
|
233
|
+
logPageView(
|
|
234
|
+
eventName?: string,
|
|
235
|
+
attrs?: SDKEventAttrs,
|
|
236
|
+
customFlags?: SDKEventCustomFlags,
|
|
237
|
+
eventOptions?: SDKEventOptions
|
|
238
|
+
): void;
|
|
213
239
|
setOptOut(isOptingOut: boolean): void;
|
|
214
240
|
eCommerce: SDKECommerceAPI;
|
|
215
241
|
isInitialized(): boolean;
|
|
@@ -227,7 +253,10 @@ export interface MParticleWebSDK {
|
|
|
227
253
|
|
|
228
254
|
stopTrackingLocation(): void;
|
|
229
255
|
generateHash(value: string): string;
|
|
230
|
-
setIntegrationAttribute(
|
|
256
|
+
setIntegrationAttribute(
|
|
257
|
+
integrationModuleId: number,
|
|
258
|
+
attrs: IntegrationAttribute
|
|
259
|
+
): void;
|
|
231
260
|
getIntegrationAttributes(integrationModuleId: number): IntegrationAttribute;
|
|
232
261
|
captureTiming(metricName: string): void;
|
|
233
262
|
}
|
|
@@ -248,14 +277,13 @@ export interface IMParticleInstanceManager extends MParticleWebSDK {
|
|
|
248
277
|
MPSideloadedKit: typeof MPSideloadedKit;
|
|
249
278
|
Rokt: RoktManager;
|
|
250
279
|
// https://go.mparticle.com/work/SQDSDKS-7060
|
|
251
|
-
sessionManager: Pick<ISessionManager, 'getSession'>;
|
|
280
|
+
sessionManager: Pick<ISessionManager, 'getSession'>;
|
|
252
281
|
Store: IStore;
|
|
253
282
|
|
|
254
283
|
// Public Methods
|
|
255
284
|
getInstance(instanceName?: string): IMParticleWebSDKInstance;
|
|
256
285
|
}
|
|
257
286
|
|
|
258
|
-
|
|
259
287
|
// Used in cases where server requires booleans as strings
|
|
260
288
|
export type BooleanStringLowerCase = 'false' | 'true';
|
|
261
289
|
export type BooleanStringTitleCase = 'False' | 'True';
|
|
@@ -311,6 +339,7 @@ export interface SDKInitConfig
|
|
|
311
339
|
identityCallback?: IdentityCallback;
|
|
312
340
|
|
|
313
341
|
launcherOptions?: IRoktLauncherOptions;
|
|
342
|
+
isLoggingEnabled?: boolean;
|
|
314
343
|
|
|
315
344
|
rq?: Function[] | any[];
|
|
316
345
|
logger?: IConsoleLogger;
|
|
@@ -361,9 +390,9 @@ export interface SDKHelpersApi {
|
|
|
361
390
|
}
|
|
362
391
|
|
|
363
392
|
export interface SDKLoggerApi {
|
|
364
|
-
error(
|
|
365
|
-
verbose(
|
|
366
|
-
warning(
|
|
393
|
+
error(msg: string, code?: ErrorCodes): void;
|
|
394
|
+
verbose(msg: string): void;
|
|
395
|
+
warning(msg: string): void;
|
|
367
396
|
setLogLevel(logLevel: LogLevelType): void;
|
|
368
397
|
}
|
|
369
398
|
|
package/src/store.ts
CHANGED
|
@@ -96,6 +96,9 @@ export interface SDKConfig {
|
|
|
96
96
|
webviewBridgeName?: string;
|
|
97
97
|
workspaceToken?: string;
|
|
98
98
|
requiredWebviewBridgeName?: string;
|
|
99
|
+
loggingUrl?: string;
|
|
100
|
+
errorUrl?: string;
|
|
101
|
+
isLoggingEnabled?: boolean;
|
|
99
102
|
}
|
|
100
103
|
|
|
101
104
|
function createSDKConfig(config: SDKInitConfig): SDKConfig {
|
|
@@ -120,6 +123,9 @@ function createSDKConfig(config: SDKInitConfig): SDKConfig {
|
|
|
120
123
|
sdkConfig[prop] = Constants.DefaultBaseUrls[prop];
|
|
121
124
|
}
|
|
122
125
|
|
|
126
|
+
// Always initialize flags to at least an empty object to prevent undefined access
|
|
127
|
+
sdkConfig.flags = sdkConfig.flags || {};
|
|
128
|
+
|
|
123
129
|
return sdkConfig;
|
|
124
130
|
}
|
|
125
131
|
|
|
@@ -182,6 +188,7 @@ export interface IStore {
|
|
|
182
188
|
context: Context | null;
|
|
183
189
|
configurationLoaded: boolean;
|
|
184
190
|
identityCallInFlight: boolean;
|
|
191
|
+
identityCallFailed: boolean;
|
|
185
192
|
identifyRequestCount: number;
|
|
186
193
|
SDKConfig: Partial<SDKConfig>;
|
|
187
194
|
nonCurrentUserMPIDs: Record<MPID, Dictionary>;
|
|
@@ -201,6 +208,8 @@ export interface IStore {
|
|
|
201
208
|
integrationDelayTimeoutStart: number; // UNIX Timestamp
|
|
202
209
|
webviewBridgeEnabled?: boolean;
|
|
203
210
|
wrapperSDKInfo: WrapperSDKInfo;
|
|
211
|
+
roktAccountId: string | null;
|
|
212
|
+
integrationName: string | null;
|
|
204
213
|
|
|
205
214
|
persistenceData?: IPersistenceMinified;
|
|
206
215
|
|
|
@@ -222,6 +231,10 @@ export interface IStore {
|
|
|
222
231
|
setUserAttributes?(mpid: MPID, attributes: UserAttributes): void;
|
|
223
232
|
getUserIdentities?(mpid: MPID): UserIdentities;
|
|
224
233
|
setUserIdentities?(mpid: MPID, userIdentities: UserIdentities): void;
|
|
234
|
+
getRoktAccountId?(): string;
|
|
235
|
+
setRoktAccountId?(accountId: string): void;
|
|
236
|
+
getIntegrationName?(): string;
|
|
237
|
+
setIntegrationName?(integrationName: string): void;
|
|
225
238
|
|
|
226
239
|
addMpidToSessionHistory?(mpid: MPID, previousMpid?: MPID): void;
|
|
227
240
|
hasInvalidIdentifyRequest?: () => boolean;
|
|
@@ -267,6 +280,7 @@ export default function Store(
|
|
|
267
280
|
context: null,
|
|
268
281
|
configurationLoaded: false,
|
|
269
282
|
identityCallInFlight: false,
|
|
283
|
+
identityCallFailed: false,
|
|
270
284
|
identifyRequestCount: 0,
|
|
271
285
|
SDKConfig: {},
|
|
272
286
|
nonCurrentUserMPIDs: {},
|
|
@@ -287,6 +301,8 @@ export default function Store(
|
|
|
287
301
|
version: null,
|
|
288
302
|
isInfoSet: false,
|
|
289
303
|
},
|
|
304
|
+
roktAccountId: null,
|
|
305
|
+
integrationName: null,
|
|
290
306
|
|
|
291
307
|
// Placeholder for in-memory persistence model
|
|
292
308
|
persistenceData: {
|
|
@@ -309,10 +325,6 @@ export default function Store(
|
|
|
309
325
|
this.SDKConfig.flags = {};
|
|
310
326
|
}
|
|
311
327
|
|
|
312
|
-
// We process the initial config that is passed via the SDK init
|
|
313
|
-
// and then we will reprocess the config within the processConfig
|
|
314
|
-
// function when the config is updated from the server
|
|
315
|
-
// https://go.mparticle.com/work/SQDSDKS-6317
|
|
316
328
|
this.SDKConfig.flags = processFlags(config);
|
|
317
329
|
|
|
318
330
|
if (config.deviceId) {
|
|
@@ -336,10 +348,6 @@ export default function Store(
|
|
|
336
348
|
this.SDKConfig[baseUrlKeys] = baseUrls[baseUrlKeys];
|
|
337
349
|
}
|
|
338
350
|
|
|
339
|
-
if (config.hasOwnProperty('logLevel')) {
|
|
340
|
-
this.SDKConfig.logLevel = config.logLevel;
|
|
341
|
-
}
|
|
342
|
-
|
|
343
351
|
this.SDKConfig.useNativeSdk = !!config.useNativeSdk;
|
|
344
352
|
|
|
345
353
|
this.SDKConfig.kits = config.kits || {};
|
|
@@ -665,6 +673,16 @@ export default function Store(
|
|
|
665
673
|
this.setUserIdentities = (mpid: MPID, userIdentities: UserIdentities) => {
|
|
666
674
|
this._setPersistence(mpid, 'ui', userIdentities);
|
|
667
675
|
};
|
|
676
|
+
|
|
677
|
+
this.getRoktAccountId = () => this.roktAccountId;
|
|
678
|
+
this.setRoktAccountId = (accountId: string) => {
|
|
679
|
+
this.roktAccountId = accountId;
|
|
680
|
+
};
|
|
681
|
+
|
|
682
|
+
this.getIntegrationName = () => this.integrationName;
|
|
683
|
+
this.setIntegrationName = (integrationName: string) => {
|
|
684
|
+
this.integrationName = integrationName;
|
|
685
|
+
};
|
|
668
686
|
|
|
669
687
|
this.addMpidToSessionHistory = (mpid: MPID, previousMPID?: MPID): void => {
|
|
670
688
|
const indexOfMPID = this.currentSessionMPIDs.indexOf(mpid);
|
|
@@ -697,7 +715,10 @@ export default function Store(
|
|
|
697
715
|
// We should reprocess the flags and baseUrls in case they have changed when we request an updated config
|
|
698
716
|
// such as if the SDK is being self-hosted and the flags are different on the server config
|
|
699
717
|
// https://go.mparticle.com/work/SQDSDKS-6317
|
|
700
|
-
|
|
718
|
+
// Only update flags if the config actually has flags (don't overwrite with empty object)
|
|
719
|
+
if (config.flags) {
|
|
720
|
+
this.SDKConfig.flags = processFlags(config);
|
|
721
|
+
}
|
|
701
722
|
|
|
702
723
|
const baseUrls: Dictionary<string> = processBaseUrls(
|
|
703
724
|
config,
|
|
@@ -840,7 +861,7 @@ function processDirectBaseUrls(
|
|
|
840
861
|
for (let baseUrlKey in defaultBaseUrls) {
|
|
841
862
|
// Any custom endpoints passed to mpConfig will take priority over direct
|
|
842
863
|
// mapping to the silo. The most common use case is a customer provided CNAME.
|
|
843
|
-
if (baseUrlKey === 'configUrl') {
|
|
864
|
+
if (baseUrlKey === 'configUrl' || baseUrlKey === 'loggingUrl' || baseUrlKey === 'errorUrl') {
|
|
844
865
|
directBaseUrls[baseUrlKey] =
|
|
845
866
|
config[baseUrlKey] || defaultBaseUrls[baseUrlKey];
|
|
846
867
|
continue;
|
package/src/types.ts
CHANGED
|
@@ -394,6 +394,7 @@ export const ApplicationTransitionType = {
|
|
|
394
394
|
export const PerformanceMarkType = {
|
|
395
395
|
SdkStart: 'mp:sdkStart' as const,
|
|
396
396
|
JointSdkSelectPlacements: 'mp:jointSdkSelectPlacements' as const,
|
|
397
|
+
JointSdkRoktKitInit: 'mp:jointSdkRoktKitInit' as const,
|
|
397
398
|
}
|
|
398
399
|
|
|
399
400
|
export default {
|