@mparticle/web-sdk 2.60.1 → 2.62.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 +22 -22
- package/dist/mparticle.esm.js +22 -22
- package/dist/mparticle.js +118 -173
- package/dist/types/src/apiClient.d.ts +34 -0
- package/dist/types/src/audience.d.ts +4 -0
- package/dist/types/src/audienceManager.d.ts +19 -0
- package/dist/types/src/batchUploader.d.ts +72 -0
- package/dist/types/src/configAPIClient.d.ts +68 -0
- package/dist/types/src/consent.d.ts +71 -0
- package/dist/types/src/constants.d.ts +201 -0
- package/dist/types/src/cookieConsentManager.d.ts +50 -0
- package/dist/types/src/cookieSyncManager.d.ts +34 -0
- package/dist/types/src/ecommerce.d.ts +52 -0
- package/dist/types/src/ecommerce.interfaces.d.ts +78 -0
- package/dist/types/src/events.d.ts +17 -0
- package/dist/types/src/events.interfaces.d.ts +21 -0
- package/dist/types/src/filteredMparticleUser.d.ts +8 -0
- package/dist/types/src/foregroundTimeTracker.d.ts +21 -0
- package/dist/types/src/forwarders.d.ts +26 -0
- package/dist/types/src/forwarders.interfaces.d.ts +59 -0
- package/dist/types/src/forwardingStatsUploader.d.ts +5 -0
- package/dist/types/src/helpers.d.ts +54 -0
- package/dist/types/src/identity-user-interfaces.d.ts +106 -0
- package/dist/types/src/identity-utils.d.ts +36 -0
- package/dist/types/src/identity.interfaces.d.ts +117 -0
- package/dist/types/src/identityApiClient.d.ts +14 -0
- package/dist/types/src/integrationCapture.d.ts +83 -0
- package/dist/types/src/internal-types.d.ts +20 -0
- package/dist/types/src/kitBlocking.d.ts +116 -0
- package/dist/types/src/kitFilterHelper.d.ts +15 -0
- package/dist/types/src/logger.d.ts +18 -0
- package/dist/types/src/mockBatchCreator.d.ts +7 -0
- package/dist/types/src/mp-instance.d.ts +76 -0
- package/dist/types/src/mparticle-instance-manager.d.ts +2 -0
- package/dist/types/src/nativeSdkHelpers.d.ts +12 -0
- package/dist/types/src/nativeSdkHelpers.interfaces.d.ts +10 -0
- package/dist/types/src/persistence.d.ts +44 -0
- package/dist/types/src/persistence.interfaces.d.ts +73 -0
- package/dist/types/src/polyfill.d.ts +15 -0
- package/dist/types/src/pre-init-utils.d.ts +11 -0
- package/dist/types/src/public-types.d.ts +23 -0
- package/dist/types/src/reporting/errorReportingDispatcher.d.ts +8 -0
- package/dist/types/src/reporting/loggingDispatcher.d.ts +8 -0
- package/dist/types/src/reporting/types.d.ts +37 -0
- package/dist/types/src/roktManager.d.ts +176 -0
- package/dist/types/src/sdkRuntimeModels.d.ts +319 -0
- package/dist/types/src/sdkToEventsApiConverter.d.ts +43 -0
- package/dist/types/src/serverModel.d.ts +105 -0
- package/dist/types/src/sessionManager.d.ts +16 -0
- package/dist/types/src/sideloadedKit.d.ts +30 -0
- package/dist/types/src/store.d.ts +157 -0
- package/dist/types/src/stub/mparticle.stub.d.ts +182 -0
- package/dist/types/src/types.d.ts +154 -0
- package/dist/types/src/uploaders.d.ts +21 -0
- package/dist/types/src/user-utils.d.ts +5 -0
- package/dist/types/src/utils.d.ts +82 -0
- package/dist/types/src/validators.d.ts +18 -0
- package/dist/types/src/vault.d.ts +41 -0
- package/package.json +16 -3
- package/src/apiClient.ts +1 -1
- package/src/constants.ts +0 -4
- package/src/forwarders.interfaces.ts +42 -0
- package/src/identityApiClient.ts +9 -6
- package/src/internal-types.ts +66 -0
- package/src/logger.ts +3 -12
- package/src/mp-instance.ts +28 -15
- package/src/mparticle-instance-manager.ts +6 -0
- package/src/public-types.ts +84 -0
- package/src/reporting/errorReportingDispatcher.ts +21 -0
- package/src/reporting/loggingDispatcher.ts +21 -0
- package/src/reporting/types.ts +45 -0
- package/src/roktManager.ts +32 -6
- package/src/sdkRuntimeModels.ts +3 -1
- package/src/serverModel.ts +1 -1
- package/src/store.ts +1 -3
- package/src/logging/reportingLogger.ts +0 -192
- package/src/logging/types.ts +0 -32
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Internal types for @mparticle/web-sdk
|
|
3
|
+
*
|
|
4
|
+
* These types are shared between mParticle and Rokt SDKs but are NOT part of
|
|
5
|
+
* the public API. They may change without notice between minor versions.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import type { IKitFilterSettings, IRoktKit, SDKProduct } from '@mparticle/web-sdk/internal';
|
|
9
|
+
*
|
|
10
|
+
* This entry point re-exports all public types so that internal consumers
|
|
11
|
+
* only need a single import path.
|
|
12
|
+
*
|
|
13
|
+
* Customers should NOT import from this path.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// Re-export all public types so internal consumers have a single import path
|
|
17
|
+
export * from './public-types';
|
|
18
|
+
|
|
19
|
+
export type {
|
|
20
|
+
KitInterface,
|
|
21
|
+
} from './forwarders.interfaces';
|
|
22
|
+
|
|
23
|
+
// Rokt integration types
|
|
24
|
+
export type {
|
|
25
|
+
RoktAttributeValue,
|
|
26
|
+
RoktAttributeValueType,
|
|
27
|
+
RoktAttributeValueArray,
|
|
28
|
+
RoktAttributes,
|
|
29
|
+
IRoktPartnerExtensionData,
|
|
30
|
+
IRoktSelectPlacementsOptions,
|
|
31
|
+
IRoktSelection,
|
|
32
|
+
IRoktLauncher,
|
|
33
|
+
IRoktMessage,
|
|
34
|
+
RoktKitFilterSettings,
|
|
35
|
+
IRoktKitSettings,
|
|
36
|
+
IRoktKit,
|
|
37
|
+
IRoktOptions,
|
|
38
|
+
IRoktLauncherOptions,
|
|
39
|
+
} from './roktManager';
|
|
40
|
+
|
|
41
|
+
// Reporting / Error types (type-only to avoid runtime mismatch with entry point)
|
|
42
|
+
export type {
|
|
43
|
+
ErrorCodes,
|
|
44
|
+
WSDKErrorSeverity,
|
|
45
|
+
} from './reporting/types';
|
|
46
|
+
|
|
47
|
+
export type {
|
|
48
|
+
ISDKError,
|
|
49
|
+
ISDKLogEntry,
|
|
50
|
+
IErrorReportingService,
|
|
51
|
+
ILoggingService,
|
|
52
|
+
} from './reporting/types';
|
|
53
|
+
|
|
54
|
+
// SDK internals shared between kits
|
|
55
|
+
export type {
|
|
56
|
+
SDKEvent,
|
|
57
|
+
SDKProductAction,
|
|
58
|
+
SDKProductActionType,
|
|
59
|
+
SDKPromotionAction,
|
|
60
|
+
SDKShoppingCart,
|
|
61
|
+
SDKGeoLocation,
|
|
62
|
+
SDKDataPlan,
|
|
63
|
+
SDKLoggerApi,
|
|
64
|
+
SDKConfigApi,
|
|
65
|
+
IMParticleInstanceManager,
|
|
66
|
+
} from './sdkRuntimeModels';
|
package/src/logger.ts
CHANGED
|
@@ -1,6 +1,4 @@
|
|
|
1
1
|
import { LogLevelType, SDKInitConfig, SDKLoggerApi } from './sdkRuntimeModels';
|
|
2
|
-
import { ReportingLogger } from './logging/reportingLogger';
|
|
3
|
-
import { ErrorCodes } from './logging/types';
|
|
4
2
|
|
|
5
3
|
export type ILoggerConfig = Pick<SDKInitConfig, 'logLevel' | 'logger'>;
|
|
6
4
|
export type IConsoleLogger = Partial<Pick<SDKLoggerApi, 'error' | 'warning' | 'verbose'>>;
|
|
@@ -8,18 +6,14 @@ export type IConsoleLogger = Partial<Pick<SDKLoggerApi, 'error' | 'warning' | 'v
|
|
|
8
6
|
export class Logger {
|
|
9
7
|
private logLevel: LogLevelType;
|
|
10
8
|
private logger: IConsoleLogger;
|
|
11
|
-
private reportingLogger: ReportingLogger;
|
|
12
9
|
|
|
13
|
-
constructor(config: ILoggerConfig
|
|
14
|
-
reportingLogger?: ReportingLogger,
|
|
15
|
-
) {
|
|
10
|
+
constructor(config: ILoggerConfig) {
|
|
16
11
|
this.logLevel = config.logLevel ?? LogLevelType.Warning;
|
|
17
12
|
this.logger = config.logger ?? new ConsoleLogger();
|
|
18
|
-
this.reportingLogger = reportingLogger;
|
|
19
13
|
}
|
|
20
14
|
|
|
21
15
|
public verbose(msg: string): void {
|
|
22
|
-
if(this.logLevel === LogLevelType.None)
|
|
16
|
+
if(this.logLevel === LogLevelType.None)
|
|
23
17
|
return;
|
|
24
18
|
|
|
25
19
|
if (this.logger.verbose && this.logLevel === LogLevelType.Verbose) {
|
|
@@ -37,15 +31,12 @@ export class Logger {
|
|
|
37
31
|
}
|
|
38
32
|
}
|
|
39
33
|
|
|
40
|
-
public error(msg: string
|
|
34
|
+
public error(msg: string): void {
|
|
41
35
|
if(this.logLevel === LogLevelType.None)
|
|
42
36
|
return;
|
|
43
37
|
|
|
44
38
|
if (this.logger.error) {
|
|
45
39
|
this.logger.error(msg);
|
|
46
|
-
if (codeForReporting) {
|
|
47
|
-
this.reportingLogger?.error(msg, codeForReporting);
|
|
48
|
-
}
|
|
49
40
|
}
|
|
50
41
|
}
|
|
51
42
|
|
package/src/mp-instance.ts
CHANGED
|
@@ -52,7 +52,9 @@ import ForegroundTimer from './foregroundTimeTracker';
|
|
|
52
52
|
import RoktManager, { IRoktOptions } from './roktManager';
|
|
53
53
|
import filteredMparticleUser from './filteredMparticleUser';
|
|
54
54
|
import CookieConsentManager, { ICookieConsentManager } from './cookieConsentManager';
|
|
55
|
-
import {
|
|
55
|
+
import { ErrorReportingDispatcher } from './reporting/errorReportingDispatcher';
|
|
56
|
+
import { LoggingDispatcher } from './reporting/loggingDispatcher';
|
|
57
|
+
import { IErrorReportingService, ILoggingService } from './reporting/types';
|
|
56
58
|
|
|
57
59
|
export interface IErrorLogMessage {
|
|
58
60
|
message?: string;
|
|
@@ -85,7 +87,8 @@ export interface IMParticleWebSDKInstance extends MParticleWebSDK {
|
|
|
85
87
|
_NativeSdkHelpers: INativeSdkHelpers;
|
|
86
88
|
_Persistence: IPersistence;
|
|
87
89
|
_CookieConsentManager: ICookieConsentManager;
|
|
88
|
-
|
|
90
|
+
_ErrorReportingDispatcher: ErrorReportingDispatcher;
|
|
91
|
+
_LoggingDispatcher: LoggingDispatcher;
|
|
89
92
|
_RoktManager: RoktManager;
|
|
90
93
|
_SessionManager: ISessionManager;
|
|
91
94
|
_ServerModel: IServerModel;
|
|
@@ -138,6 +141,9 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
138
141
|
forwarderConstructors: [],
|
|
139
142
|
};
|
|
140
143
|
|
|
144
|
+
this._ErrorReportingDispatcher = new ErrorReportingDispatcher();
|
|
145
|
+
this._LoggingDispatcher = new LoggingDispatcher();
|
|
146
|
+
|
|
141
147
|
this._RoktManager = new RoktManager();
|
|
142
148
|
|
|
143
149
|
this._RoktManager.setOnReadyCallback(() => {
|
|
@@ -266,14 +272,16 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
266
272
|
}
|
|
267
273
|
};
|
|
268
274
|
|
|
269
|
-
this._resetForTests = function(config, keepPersistence, instance
|
|
275
|
+
this._resetForTests = function(config, keepPersistence, instance) {
|
|
270
276
|
if (instance._Store) {
|
|
271
277
|
delete instance._Store;
|
|
272
278
|
}
|
|
273
|
-
instance.
|
|
279
|
+
instance._ErrorReportingDispatcher = new ErrorReportingDispatcher();
|
|
280
|
+
instance._LoggingDispatcher = new LoggingDispatcher();
|
|
281
|
+
instance.Logger = new Logger(config);
|
|
282
|
+
instance._ErrorReportingDispatcher.logger = instance.Logger;
|
|
283
|
+
instance._LoggingDispatcher.logger = instance.Logger;
|
|
274
284
|
instance._Store = new Store(config, instance);
|
|
275
|
-
// Update ReportingLogger with the new Store reference to avoid stale data
|
|
276
|
-
reportingLogger?.setStore(instance._Store);
|
|
277
285
|
instance._Store.isLocalStorageAvailable = instance._Persistence.determineLocalStorageAvailability(
|
|
278
286
|
window.localStorage
|
|
279
287
|
);
|
|
@@ -1406,6 +1414,14 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
1406
1414
|
}
|
|
1407
1415
|
};
|
|
1408
1416
|
|
|
1417
|
+
this._registerErrorReportingService = function(service: IErrorReportingService) {
|
|
1418
|
+
self._ErrorReportingDispatcher.register(service);
|
|
1419
|
+
};
|
|
1420
|
+
|
|
1421
|
+
this._registerLoggingService = function(service: ILoggingService) {
|
|
1422
|
+
self._LoggingDispatcher.register(service);
|
|
1423
|
+
};
|
|
1424
|
+
|
|
1409
1425
|
const launcherInstanceGuidKey = Constants.Rokt.LauncherInstanceGuidKey;
|
|
1410
1426
|
this.setLauncherInstanceGuid = function() {
|
|
1411
1427
|
if (!window[launcherInstanceGuidKey]
|
|
@@ -1504,7 +1520,9 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
|
1504
1520
|
mpInstance._Store,
|
|
1505
1521
|
mpInstance.Logger,
|
|
1506
1522
|
roktOptions,
|
|
1507
|
-
mpInstance.captureTiming
|
|
1523
|
+
mpInstance.captureTiming,
|
|
1524
|
+
mpInstance._ErrorReportingDispatcher,
|
|
1525
|
+
mpInstance._LoggingDispatcher
|
|
1508
1526
|
);
|
|
1509
1527
|
}
|
|
1510
1528
|
|
|
@@ -1626,16 +1644,11 @@ function createIdentityCache(mpInstance) {
|
|
|
1626
1644
|
}
|
|
1627
1645
|
|
|
1628
1646
|
function runPreConfigFetchInitialization(mpInstance, apiKey, config) {
|
|
1629
|
-
mpInstance.
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
undefined,
|
|
1633
|
-
mpInstance.getLauncherInstanceGuid(),
|
|
1634
|
-
);
|
|
1635
|
-
mpInstance.Logger = new Logger(config, mpInstance._ReportingLogger);
|
|
1647
|
+
mpInstance.Logger = new Logger(config);
|
|
1648
|
+
mpInstance._ErrorReportingDispatcher.logger = mpInstance.Logger;
|
|
1649
|
+
mpInstance._LoggingDispatcher.logger = mpInstance.Logger;
|
|
1636
1650
|
mpInstance._Store = new Store(config, mpInstance, apiKey);
|
|
1637
1651
|
window.mParticle.Store = mpInstance._Store;
|
|
1638
|
-
mpInstance._ReportingLogger.setStore(mpInstance._Store);
|
|
1639
1652
|
mpInstance.Logger.verbose(StartingInitialization);
|
|
1640
1653
|
|
|
1641
1654
|
// Initialize CookieConsentManager with privacy flags from launcherOptions
|
|
@@ -487,6 +487,12 @@ function mParticleInstanceManager(this: IMParticleInstanceManager) {
|
|
|
487
487
|
this._setWrapperSDKInfo = function(name, version) {
|
|
488
488
|
self.getInstance()._setWrapperSDKInfo(name, version);
|
|
489
489
|
};
|
|
490
|
+
this._registerErrorReportingService = function(service) {
|
|
491
|
+
self.getInstance()._registerErrorReportingService(service);
|
|
492
|
+
};
|
|
493
|
+
this._registerLoggingService = function(service) {
|
|
494
|
+
self.getInstance()._registerLoggingService(service);
|
|
495
|
+
};
|
|
490
496
|
}
|
|
491
497
|
|
|
492
498
|
const mParticleManager = new mParticleInstanceManager();
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Public types for @mparticle/web-sdk
|
|
3
|
+
*
|
|
4
|
+
* These types are part of the stable public API and are safe for customers
|
|
5
|
+
* to import. Only add types here that are intended for external consumption.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* import type { SDKInitConfig, EventType } from '@mparticle/web-sdk';
|
|
9
|
+
*
|
|
10
|
+
* Note: Types from @types/mparticle__web-sdk (e.g., MPConfiguration, MPID,
|
|
11
|
+
* ConsentState) are NOT re-exported here to avoid circular references.
|
|
12
|
+
* Consumers get those automatically via DefinitelyTyped until they are
|
|
13
|
+
* natively defined in this SDK and the DT package is deprecated.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
// Re-export types from @mparticle/event-models
|
|
17
|
+
// Consumers should not need to install @mparticle/event-models directly
|
|
18
|
+
export type {
|
|
19
|
+
Batch,
|
|
20
|
+
} from '@mparticle/event-models';
|
|
21
|
+
|
|
22
|
+
// Enums / Constants (type-only to avoid runtime mismatch with entry point)
|
|
23
|
+
export type {
|
|
24
|
+
EventType,
|
|
25
|
+
CommerceEventType,
|
|
26
|
+
IdentityType,
|
|
27
|
+
ProductActionType,
|
|
28
|
+
PromotionActionType,
|
|
29
|
+
MessageType,
|
|
30
|
+
} from './types';
|
|
31
|
+
|
|
32
|
+
// Configuration
|
|
33
|
+
export type {
|
|
34
|
+
SDKInitConfig,
|
|
35
|
+
DataPlanConfig,
|
|
36
|
+
BaseEvent,
|
|
37
|
+
SDKEventCustomFlags,
|
|
38
|
+
LogLevelType,
|
|
39
|
+
MParticleWebSDK,
|
|
40
|
+
} from './sdkRuntimeModels';
|
|
41
|
+
|
|
42
|
+
// User & Identity
|
|
43
|
+
export type {
|
|
44
|
+
IMParticleUser,
|
|
45
|
+
IdentityCallback,
|
|
46
|
+
IdentityResult,
|
|
47
|
+
IdentityResultBody,
|
|
48
|
+
IdentityModifyResultBody,
|
|
49
|
+
ISDKUserIdentity,
|
|
50
|
+
ISDKUserAttributes,
|
|
51
|
+
} from './identity-user-interfaces';
|
|
52
|
+
|
|
53
|
+
export type {
|
|
54
|
+
SDKIdentityApi,
|
|
55
|
+
IAliasRequest,
|
|
56
|
+
IAliasCallback,
|
|
57
|
+
IAliasResult,
|
|
58
|
+
SDKIdentityTypeEnum,
|
|
59
|
+
} from './identity.interfaces';
|
|
60
|
+
|
|
61
|
+
// eCommerce
|
|
62
|
+
export type {
|
|
63
|
+
SDKECommerceAPI,
|
|
64
|
+
SDKCart,
|
|
65
|
+
} from './ecommerce.interfaces';
|
|
66
|
+
|
|
67
|
+
export type {
|
|
68
|
+
SDKProduct,
|
|
69
|
+
SDKPromotion,
|
|
70
|
+
SDKImpression,
|
|
71
|
+
SDKProductImpression,
|
|
72
|
+
} from './sdkRuntimeModels';
|
|
73
|
+
|
|
74
|
+
// Consent
|
|
75
|
+
export type {
|
|
76
|
+
SDKConsentApi,
|
|
77
|
+
SDKConsentState,
|
|
78
|
+
SDKConsentStateData,
|
|
79
|
+
SDKGDPRConsentState,
|
|
80
|
+
SDKCCPAConsentState,
|
|
81
|
+
} from './consent';
|
|
82
|
+
|
|
83
|
+
// Utilities
|
|
84
|
+
export type { Dictionary, valueof } from './utils';
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SDKLoggerApi } from '../sdkRuntimeModels';
|
|
2
|
+
import { IErrorReportingService, ISDKError } from './types';
|
|
3
|
+
|
|
4
|
+
export class ErrorReportingDispatcher implements IErrorReportingService {
|
|
5
|
+
private readonly services: IErrorReportingService[] = [];
|
|
6
|
+
public logger?: SDKLoggerApi;
|
|
7
|
+
|
|
8
|
+
public register(service: IErrorReportingService): void {
|
|
9
|
+
this.services.push(service);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public report(error: ISDKError): void {
|
|
13
|
+
this.services.forEach(s => {
|
|
14
|
+
try {
|
|
15
|
+
s.report(error);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
this.logger?.error('Error in ErrorReportingService: ' + e);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { SDKLoggerApi } from '../sdkRuntimeModels';
|
|
2
|
+
import { ILoggingService, ISDKLogEntry } from './types';
|
|
3
|
+
|
|
4
|
+
export class LoggingDispatcher implements ILoggingService {
|
|
5
|
+
private readonly services: ILoggingService[] = [];
|
|
6
|
+
public logger?: SDKLoggerApi;
|
|
7
|
+
|
|
8
|
+
public register(service: ILoggingService): void {
|
|
9
|
+
this.services.push(service);
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
public log(entry: ISDKLogEntry): void {
|
|
13
|
+
this.services.forEach(s => {
|
|
14
|
+
try {
|
|
15
|
+
s.log(entry);
|
|
16
|
+
} catch (e) {
|
|
17
|
+
this.logger?.error('Error in LoggingService: ' + e);
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { valueof } from '../utils';
|
|
2
|
+
|
|
3
|
+
export const ErrorCodes = {
|
|
4
|
+
UNKNOWN_ERROR: 'UNKNOWN_ERROR',
|
|
5
|
+
UNHANDLED_EXCEPTION: 'UNHANDLED_EXCEPTION',
|
|
6
|
+
IDENTITY_REQUEST: 'IDENTITY_REQUEST',
|
|
7
|
+
IDENTITY_MISMATCH: 'IDENTITY_MISMATCH',
|
|
8
|
+
ROKT_KIT_ATTACHED: 'ROKT_KIT_ATTACHED',
|
|
9
|
+
} as const;
|
|
10
|
+
|
|
11
|
+
export type ErrorCodes = valueof<typeof ErrorCodes>;
|
|
12
|
+
|
|
13
|
+
export const WSDKErrorSeverity = {
|
|
14
|
+
ERROR: 'ERROR',
|
|
15
|
+
INFO: 'INFO',
|
|
16
|
+
WARNING: 'WARNING',
|
|
17
|
+
} as const;
|
|
18
|
+
|
|
19
|
+
export type WSDKErrorSeverity = (typeof WSDKErrorSeverity)[keyof typeof WSDKErrorSeverity];
|
|
20
|
+
|
|
21
|
+
/** Structured error object for reporting. */
|
|
22
|
+
export interface ISDKError {
|
|
23
|
+
message: string;
|
|
24
|
+
code?: ErrorCodes;
|
|
25
|
+
severity: WSDKErrorSeverity;
|
|
26
|
+
stackTrace?: string;
|
|
27
|
+
additionalInformation?: Record<string, string>;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Structured log entry for informational logging. */
|
|
31
|
+
export interface ISDKLogEntry {
|
|
32
|
+
message: string;
|
|
33
|
+
code?: ErrorCodes;
|
|
34
|
+
additionalInformation?: Record<string, string>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
/** Contract for error/warning reporting services. */
|
|
38
|
+
export interface IErrorReportingService {
|
|
39
|
+
report(error: ISDKError): void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Contract for informational logging services. */
|
|
43
|
+
export interface ILoggingService {
|
|
44
|
+
log(entry: ISDKLogEntry): void;
|
|
45
|
+
}
|
package/src/roktManager.ts
CHANGED
|
@@ -16,6 +16,7 @@ import { SDKLoggerApi } from "./sdkRuntimeModels";
|
|
|
16
16
|
import { IStore, LocalSessionAttributes } from "./store";
|
|
17
17
|
import { UserIdentities } from "@mparticle/web-sdk";
|
|
18
18
|
import { IdentityType, PerformanceMarkType } from "./types";
|
|
19
|
+
import { ErrorCodes, IErrorReportingService, ILoggingService, WSDKErrorSeverity } from "./reporting/types";
|
|
19
20
|
|
|
20
21
|
// https://docs.rokt.com/developers/integration-guides/web/library/attributes
|
|
21
22
|
export type RoktAttributeValueArray = Array<string | number | boolean>;
|
|
@@ -108,6 +109,8 @@ export default class RoktManager {
|
|
|
108
109
|
private store: IStore;
|
|
109
110
|
private launcherOptions?: IRoktLauncherOptions;
|
|
110
111
|
private logger: SDKLoggerApi;
|
|
112
|
+
private errorReporter: IErrorReportingService;
|
|
113
|
+
private loggingService: ILoggingService;
|
|
111
114
|
private domain?: string;
|
|
112
115
|
private mappedEmailShaIdentityType?: string | null;
|
|
113
116
|
private captureTiming?: (metricsName: string) => void;
|
|
@@ -130,17 +133,21 @@ export default class RoktManager {
|
|
|
130
133
|
* @param {SDKLoggerApi} logger - The mParticle Logger instance
|
|
131
134
|
* @param {IRoktOptions} options - Options for the RoktManager
|
|
132
135
|
* @param {Function} captureTiming - Function to capture performance timing marks
|
|
133
|
-
*
|
|
136
|
+
* @param {IErrorReportingService} errorReporter - Dispatcher for error/warning reporting
|
|
137
|
+
* @param {ILoggingService} loggingService - Dispatcher for informational logging
|
|
138
|
+
*
|
|
134
139
|
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
135
140
|
*/
|
|
136
141
|
public init(
|
|
137
|
-
roktConfig: IKitConfigs,
|
|
138
|
-
filteredUser: IMParticleUser,
|
|
142
|
+
roktConfig: IKitConfigs,
|
|
143
|
+
filteredUser: IMParticleUser,
|
|
139
144
|
identityService: SDKIdentityApi,
|
|
140
145
|
store: IStore,
|
|
141
146
|
logger?: SDKLoggerApi,
|
|
142
147
|
options?: IRoktOptions,
|
|
143
|
-
captureTiming?: (metricsName: string) => void
|
|
148
|
+
captureTiming?: (metricsName: string) => void,
|
|
149
|
+
errorReporter?: IErrorReportingService,
|
|
150
|
+
loggingService?: ILoggingService
|
|
144
151
|
): void {
|
|
145
152
|
const { userAttributeFilters, settings } = roktConfig || {};
|
|
146
153
|
const { placementAttributesMapping, hashedEmailUserIdentityType } = settings || {};
|
|
@@ -149,6 +156,8 @@ export default class RoktManager {
|
|
|
149
156
|
this.identityService = identityService;
|
|
150
157
|
this.store = store;
|
|
151
158
|
this.logger = logger;
|
|
159
|
+
this.errorReporter = errorReporter;
|
|
160
|
+
this.loggingService = loggingService;
|
|
152
161
|
this.captureTiming = captureTiming;
|
|
153
162
|
|
|
154
163
|
this.captureTiming?.(PerformanceMarkType.JointSdkRoktKitInit);
|
|
@@ -199,6 +208,11 @@ export default class RoktManager {
|
|
|
199
208
|
this.store?.setIntegrationName(kit.integrationName);
|
|
200
209
|
}
|
|
201
210
|
|
|
211
|
+
this.loggingService?.log({
|
|
212
|
+
message: 'RoktManager: Kit attached, Rokt is ready',
|
|
213
|
+
code: ErrorCodes.ROKT_KIT_ATTACHED,
|
|
214
|
+
});
|
|
215
|
+
|
|
202
216
|
this.processMessageQueue();
|
|
203
217
|
|
|
204
218
|
try {
|
|
@@ -269,13 +283,25 @@ export default class RoktManager {
|
|
|
269
283
|
if (emailChanged) {
|
|
270
284
|
newIdentities.email = newEmail;
|
|
271
285
|
if (newEmail) {
|
|
272
|
-
|
|
286
|
+
const msg = 'Email mismatch detected. Current email differs from email passed to selectPlacements call. Proceeding to call identify with email from selectPlacements call. Please verify your implementation.';
|
|
287
|
+
this.logger.warning(msg);
|
|
288
|
+
this.errorReporter?.report({
|
|
289
|
+
message: msg,
|
|
290
|
+
code: ErrorCodes.IDENTITY_MISMATCH,
|
|
291
|
+
severity: WSDKErrorSeverity.WARNING,
|
|
292
|
+
});
|
|
273
293
|
}
|
|
274
294
|
}
|
|
275
295
|
|
|
276
296
|
if (hashedEmailChanged) {
|
|
277
297
|
newIdentities[this.mappedEmailShaIdentityType] = newHashedEmail;
|
|
278
|
-
|
|
298
|
+
const msg = 'emailsha256 mismatch detected. Current mParticle hashedEmail differs from hashedEmail passed to selectPlacements call. Proceeding to call identify with hashedEmail from selectPlacements call. Please verify your implementation.';
|
|
299
|
+
this.logger.warning(msg);
|
|
300
|
+
this.errorReporter?.report({
|
|
301
|
+
message: msg,
|
|
302
|
+
code: ErrorCodes.IDENTITY_MISMATCH,
|
|
303
|
+
severity: WSDKErrorSeverity.WARNING,
|
|
304
|
+
});
|
|
279
305
|
}
|
|
280
306
|
|
|
281
307
|
if (!isEmpty(newIdentities)) {
|
package/src/sdkRuntimeModels.ts
CHANGED
|
@@ -51,7 +51,7 @@ import {
|
|
|
51
51
|
import Constants from './constants';
|
|
52
52
|
import RoktManager, { IRoktLauncherOptions } from './roktManager';
|
|
53
53
|
import { IConsoleLogger } from './logger';
|
|
54
|
-
import { ErrorCodes } from './
|
|
54
|
+
import { ErrorCodes, IErrorReportingService, ILoggingService } from './reporting/types';
|
|
55
55
|
|
|
56
56
|
// TODO: Resolve this with version in @mparticle/web-sdk
|
|
57
57
|
export type SDKEventCustomFlags = Dictionary<any>;
|
|
@@ -260,6 +260,8 @@ export interface MParticleWebSDK {
|
|
|
260
260
|
): void;
|
|
261
261
|
getIntegrationAttributes(integrationModuleId: number): IntegrationAttribute;
|
|
262
262
|
captureTiming(metricName: string): void;
|
|
263
|
+
_registerErrorReportingService(service: IErrorReportingService): void;
|
|
264
|
+
_registerLoggingService(service: ILoggingService): void;
|
|
263
265
|
}
|
|
264
266
|
|
|
265
267
|
// https://go.mparticle.com/work/SQDSDKS-4805
|
package/src/serverModel.ts
CHANGED
|
@@ -302,7 +302,7 @@ export default function ServerModel(
|
|
|
302
302
|
// events do not have names, but are denoted by their `event_type`
|
|
303
303
|
EventName:
|
|
304
304
|
event.name ||
|
|
305
|
-
(
|
|
305
|
+
String(event.messageType),
|
|
306
306
|
EventCategory: event.eventType,
|
|
307
307
|
EventAttributes: mpInstance._Helpers.sanitizeAttributes(
|
|
308
308
|
event.data,
|
package/src/store.ts
CHANGED
|
@@ -96,8 +96,6 @@ export interface SDKConfig {
|
|
|
96
96
|
webviewBridgeName?: string;
|
|
97
97
|
workspaceToken?: string;
|
|
98
98
|
requiredWebviewBridgeName?: string;
|
|
99
|
-
loggingUrl?: string;
|
|
100
|
-
errorUrl?: string;
|
|
101
99
|
isLoggingEnabled?: boolean;
|
|
102
100
|
}
|
|
103
101
|
|
|
@@ -862,7 +860,7 @@ function processDirectBaseUrls(
|
|
|
862
860
|
for (let baseUrlKey in defaultBaseUrls) {
|
|
863
861
|
// Any custom endpoints passed to mpConfig will take priority over direct
|
|
864
862
|
// mapping to the silo. The most common use case is a customer provided CNAME.
|
|
865
|
-
if (baseUrlKey === 'configUrl'
|
|
863
|
+
if (baseUrlKey === 'configUrl') {
|
|
866
864
|
directBaseUrls[baseUrlKey] =
|
|
867
865
|
config[baseUrlKey] || defaultBaseUrls[baseUrlKey];
|
|
868
866
|
continue;
|