@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,76 @@
|
|
|
1
|
+
import { IAPIClient } from './apiClient';
|
|
2
|
+
import { ICookieSyncManager } from './cookieSyncManager';
|
|
3
|
+
import { ISessionManager } from './sessionManager';
|
|
4
|
+
import { IStore } from './store';
|
|
5
|
+
import { IServerModel } from './serverModel';
|
|
6
|
+
import ForwardingStatsUploader from './forwardingStatsUploader';
|
|
7
|
+
import { IConsent } from './consent';
|
|
8
|
+
import IdentityAPIClient from './identityApiClient';
|
|
9
|
+
import IntegrationCapture from './integrationCapture';
|
|
10
|
+
import { IPreInit } from './pre-init-utils';
|
|
11
|
+
import { MParticleWebSDK, SDKHelpersApi } from './sdkRuntimeModels';
|
|
12
|
+
import { Dictionary } from '@mparticle/web-sdk';
|
|
13
|
+
import { IIdentity } from './identity.interfaces';
|
|
14
|
+
import { IEvents } from './events.interfaces';
|
|
15
|
+
import { IECommerce } from './ecommerce.interfaces';
|
|
16
|
+
import { INativeSdkHelpers } from './nativeSdkHelpers.interfaces';
|
|
17
|
+
import { IPersistence } from './persistence.interfaces';
|
|
18
|
+
import ForegroundTimer from './foregroundTimeTracker';
|
|
19
|
+
import RoktManager from './roktManager';
|
|
20
|
+
import { ICookieConsentManager } from './cookieConsentManager';
|
|
21
|
+
import { ErrorReportingDispatcher } from './reporting/errorReportingDispatcher';
|
|
22
|
+
import { LoggingDispatcher } from './reporting/loggingDispatcher';
|
|
23
|
+
export interface IErrorLogMessage {
|
|
24
|
+
message?: string;
|
|
25
|
+
name?: string;
|
|
26
|
+
stack?: string;
|
|
27
|
+
}
|
|
28
|
+
export interface IErrorLogMessageMinified {
|
|
29
|
+
m?: string;
|
|
30
|
+
s?: string;
|
|
31
|
+
t?: string;
|
|
32
|
+
}
|
|
33
|
+
export type IntegrationDelays = Dictionary<boolean>;
|
|
34
|
+
export interface IMParticleWebSDKInstance extends MParticleWebSDK {
|
|
35
|
+
_APIClient: IAPIClient;
|
|
36
|
+
_Consent: IConsent;
|
|
37
|
+
_CookieSyncManager: ICookieSyncManager;
|
|
38
|
+
_Ecommerce: IECommerce;
|
|
39
|
+
_Events: IEvents;
|
|
40
|
+
_Forwarders: any;
|
|
41
|
+
_ForwardingStatsUploader: ForwardingStatsUploader;
|
|
42
|
+
_Helpers: SDKHelpersApi;
|
|
43
|
+
_Identity: IIdentity;
|
|
44
|
+
_IdentityAPIClient: typeof IdentityAPIClient;
|
|
45
|
+
_IntegrationCapture: IntegrationCapture;
|
|
46
|
+
_NativeSdkHelpers: INativeSdkHelpers;
|
|
47
|
+
_Persistence: IPersistence;
|
|
48
|
+
_CookieConsentManager: ICookieConsentManager;
|
|
49
|
+
_ErrorReportingDispatcher: ErrorReportingDispatcher;
|
|
50
|
+
_LoggingDispatcher: LoggingDispatcher;
|
|
51
|
+
_RoktManager: RoktManager;
|
|
52
|
+
_SessionManager: ISessionManager;
|
|
53
|
+
_ServerModel: IServerModel;
|
|
54
|
+
_Store: IStore;
|
|
55
|
+
_instanceName: string;
|
|
56
|
+
_preInit: IPreInit;
|
|
57
|
+
_timeOnSiteTimer: ForegroundTimer;
|
|
58
|
+
setLauncherInstanceGuid: () => void;
|
|
59
|
+
getLauncherInstanceGuid: () => string;
|
|
60
|
+
captureTiming(metricName: string): any;
|
|
61
|
+
processQueueOnIdentityFailure?: () => void;
|
|
62
|
+
processQueueOnNoFunctional?: () => void;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* <p>All of the following methods can be called on the primary mParticle class. In version 2.10.0, we introduced <a href="https://docs.mparticle.com/developers/sdk/web/multiple-instances/">multiple instances</a>. If you are using multiple instances (self hosted environments only), you should call these methods on each instance.</p>
|
|
66
|
+
* <p>In current versions of mParticle, if your site has one instance, that instance name is 'default_instance'. Any methods called on mParticle on a site with one instance will be mapped to the `default_instance`.</p>
|
|
67
|
+
* <p>This is for simplicity and backwards compatibility. For example, calling mParticle.logPageView() automatically maps to mParticle.getInstance('default_instance').logPageView().</p>
|
|
68
|
+
* <p>If you have multiple instances, instances must first be initialized and then a method can be called on that instance. For example:</p>
|
|
69
|
+
* <code>
|
|
70
|
+
* mParticle.init('apiKey', config, 'another_instance');
|
|
71
|
+
* mParticle.getInstance('another_instance').logPageView();
|
|
72
|
+
* </code>
|
|
73
|
+
*
|
|
74
|
+
* @class mParticle & mParticleInstance
|
|
75
|
+
*/
|
|
76
|
+
export default function mParticleInstance(this: IMParticleWebSDKInstance, instanceName: string): void;
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export default function NativeSdkHelpers(mpInstance: any): void;
|
|
2
|
+
export default class NativeSdkHelpers {
|
|
3
|
+
constructor(mpInstance: any);
|
|
4
|
+
initializeSessionAttributes: (apiKey: any) => void;
|
|
5
|
+
isBridgeV2Available: (bridgeName: any) => boolean;
|
|
6
|
+
isWebviewEnabled: (requiredWebviewBridgeName: any, minWebviewBridgeVersion: any) => any;
|
|
7
|
+
isBridgeV1Available: () => boolean;
|
|
8
|
+
sendToNative: (path: any, value: any) => void;
|
|
9
|
+
sendViaBridgeV1: (path: any, value: any) => void;
|
|
10
|
+
sendViaIframeToIOS: (path: any, value: any) => void;
|
|
11
|
+
sendViaBridgeV2: (path: any, value: any, requiredWebviewBridgeName: any) => void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export interface INativeSdkHelpers {
|
|
2
|
+
initializeSessionAttributes: (apiKey: string) => void;
|
|
3
|
+
isBridgeV2Available: (bridgeName: string) => boolean;
|
|
4
|
+
isWebviewEnabled: (requiredWebviewBridgeName: string, minWebviewBridgeVersion: number) => boolean;
|
|
5
|
+
isBridgeV1Available: () => boolean;
|
|
6
|
+
sendToNative: (path: string, value?: string) => void;
|
|
7
|
+
sendViaBridgeV1: (path: string, value: string) => void;
|
|
8
|
+
sendViaIframeToIOS: (path: string, value: string) => void;
|
|
9
|
+
sendViaBridgeV2: (path: string, value: string, requiredWebviewBridgeName: boolean) => void;
|
|
10
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
export default function _Persistence(mpInstance: any): void;
|
|
2
|
+
export default class _Persistence {
|
|
3
|
+
constructor(mpInstance: any);
|
|
4
|
+
useLocalStorage: () => any;
|
|
5
|
+
initializeStorage: () => void;
|
|
6
|
+
update: () => void;
|
|
7
|
+
storeDataInMemory: (obj: any, currentMPID: any) => void;
|
|
8
|
+
determineLocalStorageAvailability: (storage: any) => any;
|
|
9
|
+
setLocalStorage: () => void;
|
|
10
|
+
getLocalStorage: () => {};
|
|
11
|
+
expireCookies: (cookieName: any) => void;
|
|
12
|
+
getCookie: () => any;
|
|
13
|
+
setCookie: () => void;
|
|
14
|
+
reduceAndEncodePersistence: (persistence: any, expires: any, domain: any, maxCookieSize: any) => string;
|
|
15
|
+
findPrevCookiesBasedOnUI: (identityApiData: any) => void;
|
|
16
|
+
encodePersistence: (persistence: any) => string;
|
|
17
|
+
decodePersistence: (persistence: any) => string;
|
|
18
|
+
getCookieDomain: () => any;
|
|
19
|
+
getDomain: (doc: any, locationHostname: any) => any;
|
|
20
|
+
saveUserCookieSyncDatesToPersistence: (mpid: any, csd: any) => void;
|
|
21
|
+
swapCurrentUser: (previousMPID: any, currentMPID: any, currentSessionMPIDs: any) => void;
|
|
22
|
+
savePersistence: (persistence: any) => void;
|
|
23
|
+
getPersistence: () => any;
|
|
24
|
+
getFirstSeenTime: (mpid: any) => any;
|
|
25
|
+
/**
|
|
26
|
+
* set the "first seen" time for a user. the time will only be set once for a given
|
|
27
|
+
* mpid after which subsequent calls will be ignored
|
|
28
|
+
*/
|
|
29
|
+
setFirstSeenTime: (mpid: any, time: any) => void;
|
|
30
|
+
/**
|
|
31
|
+
* returns the "last seen" time for a user. If the mpid represents the current user, the
|
|
32
|
+
* return value will always be the current time, otherwise it will be to stored "last seen"
|
|
33
|
+
* time
|
|
34
|
+
*/
|
|
35
|
+
getLastSeenTime: (mpid: any) => any;
|
|
36
|
+
setLastSeenTime: (mpid: any, time: any) => void;
|
|
37
|
+
getDeviceId: () => any;
|
|
38
|
+
setDeviceId: (guid: any) => void;
|
|
39
|
+
resetPersistence: () => void;
|
|
40
|
+
forwardingStatsBatches: {
|
|
41
|
+
uploadsTable: {};
|
|
42
|
+
forwardingStatsEventQueue: any[];
|
|
43
|
+
};
|
|
44
|
+
}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { Context } from '@mparticle/event-models';
|
|
2
|
+
import { IdentityApiData, MPID, Product, UserIdentities } from '@mparticle/web-sdk';
|
|
3
|
+
import { IForwardingStatsData } from './apiClient';
|
|
4
|
+
import { IntegrationAttributes, ServerSettings, SessionAttributes, LocalSessionAttributes } from './store';
|
|
5
|
+
import { Dictionary } from './utils';
|
|
6
|
+
import { IMinifiedConsentJSONObject } from './consent';
|
|
7
|
+
import { UserAttributes } from './identity-user-interfaces';
|
|
8
|
+
import { CookieSyncDates } from './cookieSyncManager';
|
|
9
|
+
export type UploadsTable = Dictionary<any>;
|
|
10
|
+
export interface iForwardingStatsBatches {
|
|
11
|
+
uploadsTable: UploadsTable;
|
|
12
|
+
forwardingStatsEventQueue: IForwardingStatsData[];
|
|
13
|
+
}
|
|
14
|
+
export interface IGlobalStoreV2MinifiedKeys {
|
|
15
|
+
sid: string;
|
|
16
|
+
ie: boolean;
|
|
17
|
+
sa: SessionAttributes;
|
|
18
|
+
lsa?: LocalSessionAttributes;
|
|
19
|
+
ss: ServerSettings;
|
|
20
|
+
dt: string;
|
|
21
|
+
av: string;
|
|
22
|
+
cgid: string;
|
|
23
|
+
das: string;
|
|
24
|
+
ia: IntegrationAttributes;
|
|
25
|
+
c: Context;
|
|
26
|
+
csm: MPID[];
|
|
27
|
+
les: number;
|
|
28
|
+
ssd: number;
|
|
29
|
+
}
|
|
30
|
+
export interface IPersistenceMinified extends Dictionary {
|
|
31
|
+
cu: MPID;
|
|
32
|
+
gs: IGlobalStoreV2MinifiedKeys;
|
|
33
|
+
l: boolean;
|
|
34
|
+
}
|
|
35
|
+
export interface IUserPersistenceMinified extends Dictionary {
|
|
36
|
+
csd: CookieSyncDates;
|
|
37
|
+
con: IMinifiedConsentJSONObject;
|
|
38
|
+
ui: UserIdentities;
|
|
39
|
+
ua: UserAttributes;
|
|
40
|
+
cp: Product[];
|
|
41
|
+
fst: number;
|
|
42
|
+
lst: number;
|
|
43
|
+
}
|
|
44
|
+
export interface IPersistence {
|
|
45
|
+
useLocalStorage(): boolean;
|
|
46
|
+
initializeStorage(): void;
|
|
47
|
+
update(): void;
|
|
48
|
+
storeDataInMemory(obj: IPersistenceMinified, currentMPID: MPID): void;
|
|
49
|
+
determineLocalStorageAvailability(storage: Storage): boolean;
|
|
50
|
+
setLocalStorage(): void;
|
|
51
|
+
getLocalStorage(): IPersistenceMinified | null;
|
|
52
|
+
expireCookies(cookieName: string): void;
|
|
53
|
+
getCookie(): IPersistenceMinified | null;
|
|
54
|
+
setCookie(): void;
|
|
55
|
+
reduceAndEncodePersistence(persistence: IPersistenceMinified, expires: string, domain: string, maxCookieSize: number): string;
|
|
56
|
+
findPrevCookiesBasedOnUI(identityApiData: IdentityApiData): void;
|
|
57
|
+
encodePersistence(persistence: IPersistenceMinified): string;
|
|
58
|
+
decodePersistence(persistenceString: string): string;
|
|
59
|
+
getCookieDomain(): string;
|
|
60
|
+
getDomain(doc: string, locationHostname: string): string;
|
|
61
|
+
saveUserCookieSyncDatesToPersistence(mpid: MPID, csd: CookieSyncDates): void;
|
|
62
|
+
savePersistence(persistance: IPersistenceMinified): void;
|
|
63
|
+
getPersistence(): IPersistenceMinified;
|
|
64
|
+
getFirstSeenTime(mpid: MPID): string | null;
|
|
65
|
+
setFirstSeenTime(mpid: MPID, time: number): void;
|
|
66
|
+
getLastSeenTime(mpid: MPID): number | null;
|
|
67
|
+
setLastSeenTime(mpid: MPID, time: number): void;
|
|
68
|
+
getDeviceId(): string;
|
|
69
|
+
setDeviceId(guid: string): void;
|
|
70
|
+
resetPersistence(): void;
|
|
71
|
+
swapCurrentUser(previousMPID: MPID, currentMPID: MPID, currentSessionMPIDs?: MPID[]): void;
|
|
72
|
+
forwardingStatsBatches: iForwardingStatsBatches;
|
|
73
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
declare namespace _default {
|
|
2
|
+
export function forEach(callback: any, thisArg: any, ...args: any[]): void;
|
|
3
|
+
export function map(callback: any, thisArg: any, ...args: any[]): any[];
|
|
4
|
+
export function filter(fun: any, ...args: any[]): any[];
|
|
5
|
+
export function isArray(arg: any): boolean;
|
|
6
|
+
export { Base64 };
|
|
7
|
+
}
|
|
8
|
+
export default _default;
|
|
9
|
+
declare namespace Base64 {
|
|
10
|
+
let _keyStr: string;
|
|
11
|
+
function encode(input: any): string;
|
|
12
|
+
function _encode(input: any): string;
|
|
13
|
+
function decode(input: any): string;
|
|
14
|
+
function _decode(input: any): string;
|
|
15
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { IPixelConfiguration } from './cookieSyncManager';
|
|
2
|
+
import { MPForwarder } from './forwarders.interfaces';
|
|
3
|
+
import { IntegrationDelays } from './mp-instance';
|
|
4
|
+
export interface IPreInit {
|
|
5
|
+
readyQueue: Function[] | any[];
|
|
6
|
+
integrationDelays: IntegrationDelays;
|
|
7
|
+
forwarderConstructors: MPForwarder[];
|
|
8
|
+
pixelConfigurations?: IPixelConfiguration[];
|
|
9
|
+
isDevelopmentMode?: boolean;
|
|
10
|
+
}
|
|
11
|
+
export declare const processReadyQueue: (readyQueue: any) => Function[];
|
|
@@ -0,0 +1,23 @@
|
|
|
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
|
+
export type { Batch, } from '@mparticle/event-models';
|
|
16
|
+
export type { EventType, CommerceEventType, IdentityType, ProductActionType, PromotionActionType, MessageType, } from './types';
|
|
17
|
+
export type { SDKInitConfig, DataPlanConfig, BaseEvent, SDKEventCustomFlags, LogLevelType, MParticleWebSDK, } from './sdkRuntimeModels';
|
|
18
|
+
export type { IMParticleUser, IdentityCallback, IdentityResult, IdentityResultBody, IdentityModifyResultBody, ISDKUserIdentity, ISDKUserAttributes, } from './identity-user-interfaces';
|
|
19
|
+
export type { SDKIdentityApi, IAliasRequest, IAliasCallback, IAliasResult, SDKIdentityTypeEnum, } from './identity.interfaces';
|
|
20
|
+
export type { SDKECommerceAPI, SDKCart, } from './ecommerce.interfaces';
|
|
21
|
+
export type { SDKProduct, SDKPromotion, SDKImpression, SDKProductImpression, } from './sdkRuntimeModels';
|
|
22
|
+
export type { SDKConsentApi, SDKConsentState, SDKConsentStateData, SDKGDPRConsentState, SDKCCPAConsentState, } from './consent';
|
|
23
|
+
export type { Dictionary, valueof } from './utils';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SDKLoggerApi } from '../sdkRuntimeModels';
|
|
2
|
+
import { IErrorReportingService, ISDKError } from './types';
|
|
3
|
+
export declare class ErrorReportingDispatcher implements IErrorReportingService {
|
|
4
|
+
private readonly services;
|
|
5
|
+
logger?: SDKLoggerApi;
|
|
6
|
+
register(service: IErrorReportingService): void;
|
|
7
|
+
report(error: ISDKError): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { SDKLoggerApi } from '../sdkRuntimeModels';
|
|
2
|
+
import { ILoggingService, ISDKLogEntry } from './types';
|
|
3
|
+
export declare class LoggingDispatcher implements ILoggingService {
|
|
4
|
+
private readonly services;
|
|
5
|
+
logger?: SDKLoggerApi;
|
|
6
|
+
register(service: ILoggingService): void;
|
|
7
|
+
log(entry: ISDKLogEntry): void;
|
|
8
|
+
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { valueof } from '../utils';
|
|
2
|
+
export declare const ErrorCodes: {
|
|
3
|
+
readonly UNKNOWN_ERROR: "UNKNOWN_ERROR";
|
|
4
|
+
readonly UNHANDLED_EXCEPTION: "UNHANDLED_EXCEPTION";
|
|
5
|
+
readonly IDENTITY_REQUEST: "IDENTITY_REQUEST";
|
|
6
|
+
readonly IDENTITY_MISMATCH: "IDENTITY_MISMATCH";
|
|
7
|
+
readonly ROKT_KIT_ATTACHED: "ROKT_KIT_ATTACHED";
|
|
8
|
+
};
|
|
9
|
+
export type ErrorCodes = valueof<typeof ErrorCodes>;
|
|
10
|
+
export declare const WSDKErrorSeverity: {
|
|
11
|
+
readonly ERROR: "ERROR";
|
|
12
|
+
readonly INFO: "INFO";
|
|
13
|
+
readonly WARNING: "WARNING";
|
|
14
|
+
};
|
|
15
|
+
export type WSDKErrorSeverity = (typeof WSDKErrorSeverity)[keyof typeof WSDKErrorSeverity];
|
|
16
|
+
/** Structured error object for reporting. */
|
|
17
|
+
export interface ISDKError {
|
|
18
|
+
message: string;
|
|
19
|
+
code?: ErrorCodes;
|
|
20
|
+
severity: WSDKErrorSeverity;
|
|
21
|
+
stackTrace?: string;
|
|
22
|
+
additionalInformation?: Record<string, string>;
|
|
23
|
+
}
|
|
24
|
+
/** Structured log entry for informational logging. */
|
|
25
|
+
export interface ISDKLogEntry {
|
|
26
|
+
message: string;
|
|
27
|
+
code?: ErrorCodes;
|
|
28
|
+
additionalInformation?: Record<string, string>;
|
|
29
|
+
}
|
|
30
|
+
/** Contract for error/warning reporting services. */
|
|
31
|
+
export interface IErrorReportingService {
|
|
32
|
+
report(error: ISDKError): void;
|
|
33
|
+
}
|
|
34
|
+
/** Contract for informational logging services. */
|
|
35
|
+
export interface ILoggingService {
|
|
36
|
+
log(entry: ISDKLogEntry): void;
|
|
37
|
+
}
|
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
import { IKitConfigs } from "./configAPIClient";
|
|
2
|
+
import { UserAttributeFilters } from "./forwarders.interfaces";
|
|
3
|
+
import { IMParticleUser } from "./identity-user-interfaces";
|
|
4
|
+
import { Dictionary, AttributeValue } from "./utils";
|
|
5
|
+
import { SDKIdentityApi } from "./identity.interfaces";
|
|
6
|
+
import { SDKLoggerApi } from "./sdkRuntimeModels";
|
|
7
|
+
import { IStore, LocalSessionAttributes } from "./store";
|
|
8
|
+
import { IErrorReportingService, ILoggingService } from "./reporting/types";
|
|
9
|
+
export type RoktAttributeValueArray = Array<string | number | boolean>;
|
|
10
|
+
export type RoktAttributeValueType = string | number | boolean | undefined | null;
|
|
11
|
+
export type RoktAttributeValue = RoktAttributeValueType | RoktAttributeValueArray;
|
|
12
|
+
export type RoktAttributes = Record<string, RoktAttributeValue>;
|
|
13
|
+
export interface IRoktPartnerExtensionData<T> {
|
|
14
|
+
[extensionName: string]: T;
|
|
15
|
+
}
|
|
16
|
+
export interface IRoktSelectPlacementsOptions {
|
|
17
|
+
attributes: RoktAttributes;
|
|
18
|
+
identifier?: string;
|
|
19
|
+
}
|
|
20
|
+
interface IRoktPlacement {
|
|
21
|
+
}
|
|
22
|
+
export interface IRoktSelection {
|
|
23
|
+
close: () => void;
|
|
24
|
+
getPlacements: () => Promise<IRoktPlacement[]>;
|
|
25
|
+
}
|
|
26
|
+
export interface IRoktLauncher {
|
|
27
|
+
selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise<IRoktSelection>;
|
|
28
|
+
hashAttributes: (attributes: RoktAttributes) => Promise<Record<string, string>>;
|
|
29
|
+
use: <T>(name: string) => Promise<T>;
|
|
30
|
+
}
|
|
31
|
+
export interface IRoktMessage {
|
|
32
|
+
messageId: string;
|
|
33
|
+
methodName: string;
|
|
34
|
+
payload: any;
|
|
35
|
+
resolve?: Function;
|
|
36
|
+
reject?: Function;
|
|
37
|
+
}
|
|
38
|
+
export interface RoktKitFilterSettings {
|
|
39
|
+
userAttributeFilters?: UserAttributeFilters;
|
|
40
|
+
filterUserAttributes?: (userAttributes: Dictionary<string>, filterList: number[]) => Dictionary<string>;
|
|
41
|
+
filteredUser?: IMParticleUser | null;
|
|
42
|
+
}
|
|
43
|
+
export interface IRoktKitSettings {
|
|
44
|
+
accountId?: string;
|
|
45
|
+
placementAttributesMapping?: string;
|
|
46
|
+
hashedEmailUserIdentityType?: string;
|
|
47
|
+
}
|
|
48
|
+
export interface IRoktKit {
|
|
49
|
+
filters: RoktKitFilterSettings;
|
|
50
|
+
filteredUser: IMParticleUser | null;
|
|
51
|
+
launcher: IRoktLauncher | null;
|
|
52
|
+
userAttributes: Dictionary<string>;
|
|
53
|
+
hashAttributes: (attributes: RoktAttributes) => Promise<RoktAttributes>;
|
|
54
|
+
selectPlacements: (options: IRoktSelectPlacementsOptions) => Promise<IRoktSelection>;
|
|
55
|
+
setExtensionData<T>(extensionData: IRoktPartnerExtensionData<T>): void;
|
|
56
|
+
use: <T>(name: string) => Promise<T>;
|
|
57
|
+
launcherOptions?: Dictionary<any>;
|
|
58
|
+
settings?: IRoktKitSettings;
|
|
59
|
+
integrationName?: string;
|
|
60
|
+
}
|
|
61
|
+
export interface IRoktOptions {
|
|
62
|
+
sandbox?: boolean;
|
|
63
|
+
launcherOptions?: IRoktLauncherOptions;
|
|
64
|
+
domain?: string;
|
|
65
|
+
}
|
|
66
|
+
export type IRoktLauncherOptions = Dictionary<any>;
|
|
67
|
+
export default class RoktManager {
|
|
68
|
+
kit: IRoktKit;
|
|
69
|
+
filters: RoktKitFilterSettings;
|
|
70
|
+
private currentUser;
|
|
71
|
+
private messageQueue;
|
|
72
|
+
private sandbox;
|
|
73
|
+
private placementAttributesMapping;
|
|
74
|
+
private identityService;
|
|
75
|
+
private store;
|
|
76
|
+
private launcherOptions?;
|
|
77
|
+
private logger;
|
|
78
|
+
private errorReporter;
|
|
79
|
+
private loggingService;
|
|
80
|
+
private domain?;
|
|
81
|
+
private mappedEmailShaIdentityType?;
|
|
82
|
+
private captureTiming?;
|
|
83
|
+
private onReadyCallback;
|
|
84
|
+
private initialized;
|
|
85
|
+
/**
|
|
86
|
+
* Sets a callback to be invoked when RoktManager becomes ready
|
|
87
|
+
*/
|
|
88
|
+
setOnReadyCallback(callback: () => void): void;
|
|
89
|
+
/**
|
|
90
|
+
* Initializes the RoktManager with configuration settings and user data.
|
|
91
|
+
*
|
|
92
|
+
* @param {IKitConfigs} roktConfig - Configuration object containing user attribute filters and settings
|
|
93
|
+
* @param {IMParticleUser} filteredUser - User object with filtered attributes
|
|
94
|
+
* @param {SDKIdentityApi} identityService - The mParticle Identity instance
|
|
95
|
+
* @param {SDKLoggerApi} logger - The mParticle Logger instance
|
|
96
|
+
* @param {IRoktOptions} options - Options for the RoktManager
|
|
97
|
+
* @param {Function} captureTiming - Function to capture performance timing marks
|
|
98
|
+
* @param {IErrorReportingService} errorReporter - Dispatcher for error/warning reporting
|
|
99
|
+
* @param {ILoggingService} loggingService - Dispatcher for informational logging
|
|
100
|
+
*
|
|
101
|
+
* @throws Logs error to console if placementAttributesMapping parsing fails
|
|
102
|
+
*/
|
|
103
|
+
init(roktConfig: IKitConfigs, filteredUser: IMParticleUser, identityService: SDKIdentityApi, store: IStore, logger?: SDKLoggerApi, options?: IRoktOptions, captureTiming?: (metricsName: string) => void, errorReporter?: IErrorReportingService, loggingService?: ILoggingService): void;
|
|
104
|
+
get isInitialized(): boolean;
|
|
105
|
+
attachKit(kit: IRoktKit): void;
|
|
106
|
+
/**
|
|
107
|
+
* Renders ads based on the options provided
|
|
108
|
+
*
|
|
109
|
+
* @param {IRoktSelectPlacementsOptions} options - The options for selecting placements, including attributes and optional identifier
|
|
110
|
+
* @returns {Promise<IRoktSelection>} A promise that resolves to the selection
|
|
111
|
+
*
|
|
112
|
+
* @example
|
|
113
|
+
* // Correct usage with await
|
|
114
|
+
* await window.mParticle.Rokt.selectPlacements({
|
|
115
|
+
* attributes: {
|
|
116
|
+
* email: 'user@example.com',
|
|
117
|
+
* customAttr: 'value'
|
|
118
|
+
* }
|
|
119
|
+
* });
|
|
120
|
+
*/
|
|
121
|
+
selectPlacements(options: IRoktSelectPlacementsOptions): Promise<IRoktSelection>;
|
|
122
|
+
/**
|
|
123
|
+
* Hashes attributes and returns both original and hashed versions
|
|
124
|
+
* with Rokt-compatible key names (like emailsha256, mobilesha256)
|
|
125
|
+
*
|
|
126
|
+
*
|
|
127
|
+
* @param {RoktAttributes} attributes - Attributes to hash
|
|
128
|
+
* @returns {Promise<RoktAttributes>} Object with both original and hashed attributes
|
|
129
|
+
*
|
|
130
|
+
*/
|
|
131
|
+
hashAttributes(attributes: RoktAttributes): Promise<RoktAttributes>;
|
|
132
|
+
setExtensionData<T>(extensionData: IRoktPartnerExtensionData<T>): void;
|
|
133
|
+
use<T>(name: string): Promise<T>;
|
|
134
|
+
/**
|
|
135
|
+
* Hashes an attribute using SHA-256
|
|
136
|
+
*
|
|
137
|
+
* @param {string | number | boolean | undefined | null} attribute - The value to hash
|
|
138
|
+
* @returns {Promise<string | undefined | null>} SHA-256 hashed value or undefined/null
|
|
139
|
+
*
|
|
140
|
+
*/
|
|
141
|
+
hashSha256(attribute: RoktAttributeValueType): Promise<string | undefined | null>;
|
|
142
|
+
getLocalSessionAttributes(): LocalSessionAttributes;
|
|
143
|
+
setLocalSessionAttribute(key: string, value: AttributeValue): void;
|
|
144
|
+
isReady(): boolean;
|
|
145
|
+
private setUserAttributes;
|
|
146
|
+
private mapPlacementAttributes;
|
|
147
|
+
onIdentityComplete(): void;
|
|
148
|
+
processMessageQueue(): void;
|
|
149
|
+
private queueMessage;
|
|
150
|
+
private deferredCall;
|
|
151
|
+
/**
|
|
152
|
+
* Hashes a string input using SHA-256 and returns the hex digest
|
|
153
|
+
* Uses the Web Crypto API for secure hashing
|
|
154
|
+
*
|
|
155
|
+
* @param {string} input - The string to hash
|
|
156
|
+
* @returns {Promise<string>} The SHA-256 hash as a hexadecimal string
|
|
157
|
+
*/
|
|
158
|
+
private sha256Hex;
|
|
159
|
+
/**
|
|
160
|
+
* Converts an ArrayBuffer to a hexadecimal string representation
|
|
161
|
+
* Each byte is converted to a 2-character hex string with leading zeros
|
|
162
|
+
*
|
|
163
|
+
* @param {ArrayBuffer} buffer - The buffer to convert
|
|
164
|
+
* @returns {string} The hexadecimal string representation
|
|
165
|
+
*/
|
|
166
|
+
private arrayBufferToHex;
|
|
167
|
+
/**
|
|
168
|
+
* Checks if an identity value has changed by comparing current and new values
|
|
169
|
+
*
|
|
170
|
+
* @param {string | undefined} currentValue - The current identity value
|
|
171
|
+
* @param {string | undefined} newValue - The new identity value to compare against
|
|
172
|
+
* @returns {boolean} True if the identity has changed (new value exists and differs from current), false otherwise
|
|
173
|
+
*/
|
|
174
|
+
private hasIdentityChanged;
|
|
175
|
+
}
|
|
176
|
+
export {};
|