@mparticle/web-sdk 2.61.0 → 2.63.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 +7 -6
- package/dist/mparticle.esm.js +7 -6
- package/dist/mparticle.js +131 -102
- 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 +27 -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 +15 -2
- package/src/batchUploader.ts +13 -0
- package/src/forwarders.interfaces.ts +42 -0
- package/src/forwarders.js +28 -1
- package/src/internal-types.ts +66 -0
- package/src/public-types.ts +84 -0
- package/src/roktManager.ts +25 -13
|
@@ -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 {};
|
|
@@ -0,0 +1,319 @@
|
|
|
1
|
+
import * as EventsApi from '@mparticle/event-models';
|
|
2
|
+
import { DataPlanVersion } from '@mparticle/data-planning-models';
|
|
3
|
+
import { MPConfiguration, MPID, SDKEventOptions, SDKEventAttrs, Callback } from '@mparticle/web-sdk';
|
|
4
|
+
import { IntegrationAttribute, IntegrationAttributes, IStore, WrapperSDKTypes } from './store';
|
|
5
|
+
import Validators from './validators';
|
|
6
|
+
import { Dictionary, valueof } from './utils';
|
|
7
|
+
import { IKitConfigs } from './configAPIClient';
|
|
8
|
+
import { SDKConsentApi, SDKConsentState } from './consent';
|
|
9
|
+
import MPSideloadedKit from './sideloadedKit';
|
|
10
|
+
import { ISessionManager } from './sessionManager';
|
|
11
|
+
import { ConfiguredKit, MPForwarder, UnregisteredKit } from './forwarders.interfaces';
|
|
12
|
+
import { SDKIdentityApi, IAliasCallback } from './identity.interfaces';
|
|
13
|
+
import { ISDKUserAttributeChangeData, ISDKUserIdentityChanges, IMParticleUser, ISDKUserIdentity, IdentityCallback, ISDKUserAttributes } from './identity-user-interfaces';
|
|
14
|
+
import { CommerceEventType, EventType, IdentityType, ProductActionType, PromotionActionType } from './types';
|
|
15
|
+
import { IPixelConfiguration } from './cookieSyncManager';
|
|
16
|
+
import _BatchValidator from './mockBatchCreator';
|
|
17
|
+
import { SDKECommerceAPI } from './ecommerce.interfaces';
|
|
18
|
+
import { IErrorLogMessage, IMParticleWebSDKInstance, IntegrationDelays } from './mp-instance';
|
|
19
|
+
import Constants from './constants';
|
|
20
|
+
import RoktManager, { IRoktLauncherOptions } from './roktManager';
|
|
21
|
+
import { IConsoleLogger } from './logger';
|
|
22
|
+
import { ErrorCodes, IErrorReportingService, ILoggingService } from './reporting/types';
|
|
23
|
+
export type SDKEventCustomFlags = Dictionary<any>;
|
|
24
|
+
export interface SDKEvent {
|
|
25
|
+
DeviceId: string;
|
|
26
|
+
IsFirstRun: boolean;
|
|
27
|
+
EventName: string;
|
|
28
|
+
EventCategory: number;
|
|
29
|
+
UserAttributes?: ISDKUserAttributes;
|
|
30
|
+
UserIdentities?: ISDKUserIdentity[];
|
|
31
|
+
SourceMessageId: string;
|
|
32
|
+
MPID: string;
|
|
33
|
+
EventAttributes?: {
|
|
34
|
+
[key: string]: string;
|
|
35
|
+
};
|
|
36
|
+
SDKVersion: string;
|
|
37
|
+
SessionId: string;
|
|
38
|
+
SessionStartDate: number;
|
|
39
|
+
SessionLength?: number;
|
|
40
|
+
currentSessionMPIDs?: string[];
|
|
41
|
+
Timestamp: number;
|
|
42
|
+
EventDataType: number;
|
|
43
|
+
Debug: boolean;
|
|
44
|
+
Location?: SDKGeoLocation;
|
|
45
|
+
OptOut?: boolean;
|
|
46
|
+
CustomFlags?: SDKEventCustomFlags;
|
|
47
|
+
AppVersion?: string;
|
|
48
|
+
AppName?: string;
|
|
49
|
+
Package?: string;
|
|
50
|
+
ConsentState?: SDKConsentState;
|
|
51
|
+
IntegrationAttributes?: IntegrationAttributes;
|
|
52
|
+
ProductAction?: SDKProductAction;
|
|
53
|
+
PromotionAction?: SDKPromotionAction;
|
|
54
|
+
ProductImpressions?: SDKProductImpression[];
|
|
55
|
+
ShoppingCart?: SDKShoppingCart;
|
|
56
|
+
UserIdentityChanges?: ISDKUserIdentityChanges;
|
|
57
|
+
UserAttributeChanges?: ISDKUserAttributeChangeData;
|
|
58
|
+
CurrencyCode: string;
|
|
59
|
+
DataPlan?: SDKDataPlan;
|
|
60
|
+
LaunchReferral?: string;
|
|
61
|
+
ExpandedEventCount: number;
|
|
62
|
+
ActiveTimeOnSite: number;
|
|
63
|
+
IsBackgroundAST?: boolean;
|
|
64
|
+
AlreadySentToForwarders?: boolean;
|
|
65
|
+
}
|
|
66
|
+
export interface SDKGeoLocation {
|
|
67
|
+
lat: number | string;
|
|
68
|
+
lng: number | string;
|
|
69
|
+
}
|
|
70
|
+
export interface SDKDataPlan {
|
|
71
|
+
PlanVersion?: number | null;
|
|
72
|
+
PlanId?: string | null;
|
|
73
|
+
}
|
|
74
|
+
export interface SDKShoppingCart {
|
|
75
|
+
ProductList?: SDKProduct[];
|
|
76
|
+
}
|
|
77
|
+
export interface SDKPromotionAction {
|
|
78
|
+
PromotionActionType: string;
|
|
79
|
+
PromotionList?: SDKPromotion[];
|
|
80
|
+
}
|
|
81
|
+
export interface SDKPromotion {
|
|
82
|
+
Id?: string;
|
|
83
|
+
Name?: string;
|
|
84
|
+
Creative?: string;
|
|
85
|
+
Position?: string;
|
|
86
|
+
}
|
|
87
|
+
export interface SDKImpression {
|
|
88
|
+
Name: string;
|
|
89
|
+
Product: SDKProduct;
|
|
90
|
+
}
|
|
91
|
+
export interface SDKProductImpression {
|
|
92
|
+
ProductImpressionList?: string;
|
|
93
|
+
ProductList?: SDKProduct[];
|
|
94
|
+
}
|
|
95
|
+
export declare enum SDKProductActionType {
|
|
96
|
+
Unknown = 0,
|
|
97
|
+
AddToCart = 1,
|
|
98
|
+
RemoveFromCart = 2,
|
|
99
|
+
Checkout = 3,
|
|
100
|
+
CheckoutOption = 4,
|
|
101
|
+
Click = 5,
|
|
102
|
+
ViewDetail = 6,
|
|
103
|
+
Purchase = 7,
|
|
104
|
+
Refund = 8,
|
|
105
|
+
AddToWishlist = 9,
|
|
106
|
+
RemoveFromWishlist = 10
|
|
107
|
+
}
|
|
108
|
+
export interface SDKProductAction {
|
|
109
|
+
ProductActionType: SDKProductActionType;
|
|
110
|
+
CheckoutStep?: number;
|
|
111
|
+
CheckoutOptions?: string;
|
|
112
|
+
ProductList?: SDKProduct[];
|
|
113
|
+
TransactionId?: string;
|
|
114
|
+
Affiliation?: string;
|
|
115
|
+
CouponCode?: string;
|
|
116
|
+
TotalAmount?: number;
|
|
117
|
+
ShippingAmount?: number;
|
|
118
|
+
TaxAmount?: number;
|
|
119
|
+
}
|
|
120
|
+
export interface SDKProduct {
|
|
121
|
+
Sku?: string;
|
|
122
|
+
Name?: string;
|
|
123
|
+
Price?: number;
|
|
124
|
+
Quantity?: number;
|
|
125
|
+
Brand?: string;
|
|
126
|
+
Variant?: string;
|
|
127
|
+
Category?: string;
|
|
128
|
+
Position?: number;
|
|
129
|
+
CouponCode?: string;
|
|
130
|
+
TotalAmount?: number;
|
|
131
|
+
Attributes?: Record<string, unknown> | null;
|
|
132
|
+
}
|
|
133
|
+
export interface MParticleWebSDK {
|
|
134
|
+
addForwarder(forwarder: UnregisteredKit): void;
|
|
135
|
+
IdentityType: typeof IdentityType;
|
|
136
|
+
CommerceEventType: typeof CommerceEventType;
|
|
137
|
+
EventType: typeof EventType;
|
|
138
|
+
PromotionType: typeof PromotionActionType;
|
|
139
|
+
ProductActionType: typeof ProductActionType;
|
|
140
|
+
Identity: SDKIdentityApi;
|
|
141
|
+
Logger: SDKLoggerApi;
|
|
142
|
+
Consent: SDKConsentApi;
|
|
143
|
+
_resetForTests(MPConfig?: SDKInitConfig, keepPersistence?: boolean, instance?: IMParticleWebSDKInstance): void;
|
|
144
|
+
configurePixel(config: IPixelConfiguration): void;
|
|
145
|
+
endSession(): void;
|
|
146
|
+
init(apiKey: string, config: SDKInitConfig, instanceName?: string): void;
|
|
147
|
+
_getActiveForwarders(): ConfiguredKit[];
|
|
148
|
+
_getIntegrationDelays(): IntegrationDelays;
|
|
149
|
+
_setIntegrationDelay(module: number, shouldDelayIntegration: boolean): void;
|
|
150
|
+
_setWrapperSDKInfo(name: WrapperSDKTypes, version: string): void;
|
|
151
|
+
getAppName(): string;
|
|
152
|
+
getAppVersion(): string;
|
|
153
|
+
getDeviceId(): string;
|
|
154
|
+
setDeviceId(deviceId: string): void;
|
|
155
|
+
getEnvironment(): valueof<typeof Constants.Environment>;
|
|
156
|
+
setSessionAttribute(key: string, value: string): void;
|
|
157
|
+
getVersion(): string;
|
|
158
|
+
upload(): void;
|
|
159
|
+
setLogLevel(logLevel: LogLevelType): void;
|
|
160
|
+
setPosition(lat: number | string, lng: number | string): void;
|
|
161
|
+
startNewSession(): void;
|
|
162
|
+
logEvent(eventName: string, eventType?: valueof<typeof EventType>, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
|
|
163
|
+
logBaseEvent(event: BaseEvent, eventOptions?: SDKEventOptions): void;
|
|
164
|
+
logError(error: IErrorLogMessage, attrs?: SDKEventAttrs): void;
|
|
165
|
+
logLink(selector: string, eventName: string, eventType: valueof<typeof EventType>, eventInfo: SDKEventAttrs): void;
|
|
166
|
+
logForm(selector: string, eventName: string, eventType: valueof<typeof EventType>, eventInfo: SDKEventAttrs): void;
|
|
167
|
+
logPageView(eventName?: string, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
|
|
168
|
+
setOptOut(isOptingOut: boolean): void;
|
|
169
|
+
eCommerce: SDKECommerceAPI;
|
|
170
|
+
isInitialized(): boolean;
|
|
171
|
+
ready(f: Function): void;
|
|
172
|
+
reset(instance?: IMParticleWebSDKInstance): void;
|
|
173
|
+
setAppName(name: string): void;
|
|
174
|
+
setAppVersion(version: string): void;
|
|
175
|
+
setOptOut(isOptingOut: boolean): void;
|
|
176
|
+
startTrackingLocation(callback?: Callback): void;
|
|
177
|
+
stopTrackingLocation(): void;
|
|
178
|
+
generateHash(value: string): string;
|
|
179
|
+
setIntegrationAttribute(integrationModuleId: number, attrs: IntegrationAttribute): void;
|
|
180
|
+
getIntegrationAttributes(integrationModuleId: number): IntegrationAttribute;
|
|
181
|
+
captureTiming(metricName: string): void;
|
|
182
|
+
_registerErrorReportingService(service: IErrorReportingService): void;
|
|
183
|
+
_registerLoggingService(service: ILoggingService): void;
|
|
184
|
+
}
|
|
185
|
+
export interface IMParticleInstanceManager extends MParticleWebSDK {
|
|
186
|
+
_BatchValidator: _BatchValidator;
|
|
187
|
+
_instances: Dictionary<IMParticleWebSDKInstance>;
|
|
188
|
+
_isTestEnv?: boolean;
|
|
189
|
+
config: SDKInitConfig;
|
|
190
|
+
isIOS?: boolean;
|
|
191
|
+
MPSideloadedKit: typeof MPSideloadedKit;
|
|
192
|
+
Rokt: RoktManager;
|
|
193
|
+
sessionManager: Pick<ISessionManager, 'getSession'>;
|
|
194
|
+
Store: IStore;
|
|
195
|
+
getInstance(instanceName?: string): IMParticleWebSDKInstance;
|
|
196
|
+
}
|
|
197
|
+
export type BooleanStringLowerCase = 'false' | 'true';
|
|
198
|
+
export type BooleanStringTitleCase = 'False' | 'True';
|
|
199
|
+
export type LogLevelType = (typeof LogLevelType)[keyof typeof LogLevelType];
|
|
200
|
+
export declare const LogLevelType: {
|
|
201
|
+
readonly None: "none";
|
|
202
|
+
readonly Verbose: "verbose";
|
|
203
|
+
readonly Warning: "warning";
|
|
204
|
+
readonly Error: "error";
|
|
205
|
+
};
|
|
206
|
+
export interface SDKInitConfig extends Omit<MPConfiguration, 'dataPlan' | 'logLevel'> {
|
|
207
|
+
dataPlan?: DataPlanConfig | KitBlockerDataPlan;
|
|
208
|
+
logLevel?: LogLevelType;
|
|
209
|
+
kitConfigs?: IKitConfigs[];
|
|
210
|
+
kits?: Dictionary<UnregisteredKit>;
|
|
211
|
+
sideloadedKits?: MPForwarder[];
|
|
212
|
+
dataPlanOptions?: KitBlockerOptions;
|
|
213
|
+
flags?: Dictionary;
|
|
214
|
+
pixelConfigs?: IPixelConfiguration[];
|
|
215
|
+
aliasMaxWindow?: number;
|
|
216
|
+
deviceId?: string;
|
|
217
|
+
forceHttps?: boolean;
|
|
218
|
+
aliasUrl?: string;
|
|
219
|
+
configUrl?: string;
|
|
220
|
+
identityUrl?: string;
|
|
221
|
+
integrationDelayTimeout?: number;
|
|
222
|
+
isIOS?: boolean;
|
|
223
|
+
maxProducts?: number;
|
|
224
|
+
requestConfig?: boolean;
|
|
225
|
+
sessionTimeout?: number;
|
|
226
|
+
useNativeSdk?: boolean;
|
|
227
|
+
useCookieStorage?: boolean;
|
|
228
|
+
v1SecureServiceUrl?: string;
|
|
229
|
+
v2SecureServiceUrl?: string;
|
|
230
|
+
v3SecureServiceUrl?: string;
|
|
231
|
+
domain?: string;
|
|
232
|
+
workspaceToken?: string;
|
|
233
|
+
isDevelopmentMode?: boolean;
|
|
234
|
+
identityCallback?: IdentityCallback;
|
|
235
|
+
launcherOptions?: IRoktLauncherOptions;
|
|
236
|
+
isLoggingEnabled?: boolean;
|
|
237
|
+
rq?: Function[] | any[];
|
|
238
|
+
logger?: IConsoleLogger;
|
|
239
|
+
}
|
|
240
|
+
export interface DataPlanConfig {
|
|
241
|
+
planId?: string;
|
|
242
|
+
planVersion?: number;
|
|
243
|
+
document?: DataPlanResult;
|
|
244
|
+
}
|
|
245
|
+
export interface SDKHelpersApi {
|
|
246
|
+
canLog?(): boolean;
|
|
247
|
+
createMainStorageName?(workspaceToken: string): string;
|
|
248
|
+
createServiceUrl(url: string, devToken?: string): string;
|
|
249
|
+
createXHR?(cb: () => void): XMLHttpRequest;
|
|
250
|
+
extend?(...args: any[]): any;
|
|
251
|
+
findKeyInObject?(obj: any, key: string): string;
|
|
252
|
+
parseNumber?(value: string | number): number;
|
|
253
|
+
generateUniqueId(): any;
|
|
254
|
+
generateHash?(value: string): string;
|
|
255
|
+
getFeatureFlag?(feature: string): boolean | string;
|
|
256
|
+
invokeAliasCallback(aliasCallback: IAliasCallback, number: number, errorMessage: string): void;
|
|
257
|
+
isDelayedByIntegration?(delayedIntegrations: Dictionary<boolean>, timeoutStart: number, now: number): boolean;
|
|
258
|
+
isEventType?(type: valueof<typeof EventType>): boolean;
|
|
259
|
+
isObject?(item: any): any;
|
|
260
|
+
invokeCallback?(callback: IdentityCallback, code: number, body: string, mParticleUser?: IMParticleUser, previousMpid?: MPID): void;
|
|
261
|
+
sanitizeAttributes?(attrs: SDKEventAttrs, name: string): Dictionary<string> | null;
|
|
262
|
+
Validators: typeof Validators;
|
|
263
|
+
}
|
|
264
|
+
export interface SDKLoggerApi {
|
|
265
|
+
error(msg: string, code?: ErrorCodes): void;
|
|
266
|
+
verbose(msg: string): void;
|
|
267
|
+
warning(msg: string): void;
|
|
268
|
+
isVerbose(): boolean;
|
|
269
|
+
setLogLevel(logLevel: LogLevelType): void;
|
|
270
|
+
}
|
|
271
|
+
export interface SDKStoreApi {
|
|
272
|
+
isEnabled: boolean;
|
|
273
|
+
isFirstRun: boolean;
|
|
274
|
+
devToken: string;
|
|
275
|
+
SDKConfig: SDKConfigApi;
|
|
276
|
+
sessionId?: string;
|
|
277
|
+
deviceId?: string;
|
|
278
|
+
}
|
|
279
|
+
export interface SDKConfigApi {
|
|
280
|
+
v3SecureServiceUrl?: string;
|
|
281
|
+
isDevelopmentMode: boolean;
|
|
282
|
+
appVersion?: string;
|
|
283
|
+
onCreateBatch(batch: EventsApi.Batch): EventsApi.Batch;
|
|
284
|
+
}
|
|
285
|
+
export interface BaseEvent {
|
|
286
|
+
messageType: number;
|
|
287
|
+
name?: string;
|
|
288
|
+
eventType?: number;
|
|
289
|
+
data?: SDKEventAttrs;
|
|
290
|
+
customFlags?: {
|
|
291
|
+
[key: string]: string;
|
|
292
|
+
};
|
|
293
|
+
toEventAPIObject?(): SDKEvent;
|
|
294
|
+
sourceMessageId?: string;
|
|
295
|
+
userAttributeChanges?: ISDKUserAttributeChangeData;
|
|
296
|
+
userIdentityChanges?: ISDKUserIdentityChanges;
|
|
297
|
+
}
|
|
298
|
+
export interface KitBlockerOptions {
|
|
299
|
+
dataPlanVersion: DataPlanVersion;
|
|
300
|
+
blockUserAttributes: boolean;
|
|
301
|
+
blockEventAttributes: boolean;
|
|
302
|
+
blockEvents: boolean;
|
|
303
|
+
blockUserIdentities: boolean;
|
|
304
|
+
}
|
|
305
|
+
export interface KitBlockerDataPlan {
|
|
306
|
+
document: DataPlanResult;
|
|
307
|
+
}
|
|
308
|
+
export interface DataPlanResult {
|
|
309
|
+
dtpn?: {
|
|
310
|
+
vers: DataPlanVersion;
|
|
311
|
+
blok: {
|
|
312
|
+
ev: boolean;
|
|
313
|
+
ea: boolean;
|
|
314
|
+
ua: boolean;
|
|
315
|
+
id: boolean;
|
|
316
|
+
};
|
|
317
|
+
};
|
|
318
|
+
error_message?: string;
|
|
319
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { SDKEvent, SDKGeoLocation, SDKProduct, SDKPromotion, SDKProductActionType } from './sdkRuntimeModels';
|
|
2
|
+
import * as EventsApi from '@mparticle/event-models';
|
|
3
|
+
import { SDKConsentState, SDKGDPRConsentState, SDKCCPAConsentState } from './consent';
|
|
4
|
+
import { Dictionary } from './utils';
|
|
5
|
+
import { ISDKUserIdentity } from './identity-user-interfaces';
|
|
6
|
+
import { SDKIdentityTypeEnum } from './identity.interfaces';
|
|
7
|
+
import { IMParticleWebSDKInstance } from './mp-instance';
|
|
8
|
+
type PartnerIdentities = Dictionary<string>;
|
|
9
|
+
interface Batch extends EventsApi.Batch {
|
|
10
|
+
partner_identities?: PartnerIdentities;
|
|
11
|
+
}
|
|
12
|
+
export declare function convertEvents(mpid: string, sdkEvents: SDKEvent[], mpInstance: IMParticleWebSDKInstance): Batch | null;
|
|
13
|
+
export declare function convertConsentState(sdkConsentState?: SDKConsentState): EventsApi.ConsentState | null;
|
|
14
|
+
export declare function convertGdprConsentState(sdkGdprConsentState: SDKGDPRConsentState): {
|
|
15
|
+
[key: string]: EventsApi.GDPRConsentState | null;
|
|
16
|
+
};
|
|
17
|
+
export declare function convertCcpaConsentState(sdkCcpaConsentState: SDKCCPAConsentState): {
|
|
18
|
+
data_sale_opt_out: EventsApi.CCPAConsentState;
|
|
19
|
+
};
|
|
20
|
+
export declare function convertUserIdentities(sdkUserIdentities?: ISDKUserIdentity[]): EventsApi.BatchUserIdentities | null;
|
|
21
|
+
export declare function convertEvent(sdkEvent: SDKEvent): EventsApi.BaseEvent | null;
|
|
22
|
+
export declare function convertProductActionType(actionType: SDKProductActionType): EventsApi.ProductActionActionEnum;
|
|
23
|
+
export declare function convertProductAction(sdkEvent: SDKEvent): EventsApi.ProductAction | null;
|
|
24
|
+
export declare function convertProducts(sdkProducts: SDKProduct[]): EventsApi.Product[] | null;
|
|
25
|
+
export declare function convertPromotionAction(sdkEvent: SDKEvent): EventsApi.PromotionAction | null;
|
|
26
|
+
export declare function convertPromotions(sdkPromotions: SDKPromotion[]): EventsApi.Promotion[] | null;
|
|
27
|
+
export declare function convertImpressions(sdkEvent: SDKEvent): EventsApi.ProductImpression[] | null;
|
|
28
|
+
export declare function convertShoppingCart(sdkEvent: SDKEvent): EventsApi.ShoppingCart | null;
|
|
29
|
+
export declare function convertCommerceEvent(sdkEvent: SDKEvent): EventsApi.CommerceEvent;
|
|
30
|
+
export declare function convertCrashReportEvent(sdkEvent: SDKEvent): EventsApi.CrashReportEvent;
|
|
31
|
+
export declare function convertAST(sdkEvent: SDKEvent): EventsApi.ApplicationStateTransitionEvent;
|
|
32
|
+
export declare function convertSessionEndEvent(sdkEvent: SDKEvent): EventsApi.SessionEndEvent;
|
|
33
|
+
export declare function convertSessionStartEvent(sdkEvent: SDKEvent): EventsApi.SessionStartEvent;
|
|
34
|
+
export declare function convertPageViewEvent(sdkEvent: SDKEvent): EventsApi.ScreenViewEvent;
|
|
35
|
+
export declare function convertOptOutEvent(sdkEvent: SDKEvent): EventsApi.OptOutEvent;
|
|
36
|
+
export declare function convertCustomEvent(sdkEvent: SDKEvent): EventsApi.CustomEvent;
|
|
37
|
+
export declare function convertSdkEventType(sdkEventType: number): EventsApi.CustomEventDataCustomEventTypeEnum | EventsApi.CommerceEventDataCustomEventTypeEnum;
|
|
38
|
+
export declare function convertBaseEventData(sdkEvent: SDKEvent): EventsApi.CommonEventData;
|
|
39
|
+
export declare function convertSDKLocation(sdkEventLocation: SDKGeoLocation): EventsApi.GeoLocation;
|
|
40
|
+
export declare function convertUserAttributeChangeEvent(sdkEvent: SDKEvent): EventsApi.UserAttributeChangeEvent | null;
|
|
41
|
+
export declare function convertUserIdentityChangeEvent(sdkEvent: SDKEvent): EventsApi.UserIdentityChangeEvent | null;
|
|
42
|
+
export declare function convertUserIdentityTypeToServerIdentityType(identityType: SDKIdentityTypeEnum): EventsApi.IdentityType;
|
|
43
|
+
export {};
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { BaseEvent, SDKEvent, SDKGeoLocation } from './sdkRuntimeModels';
|
|
2
|
+
import { Dictionary } from './utils';
|
|
3
|
+
import { ServerSettings } from './store';
|
|
4
|
+
import { MPID } from '@mparticle/web-sdk';
|
|
5
|
+
import { IConsentStateV2DTO, SDKConsentState } from './consent';
|
|
6
|
+
import { IMParticleUser, ISDKUserIdentity } from './identity-user-interfaces';
|
|
7
|
+
import { IMParticleWebSDKInstance } from './mp-instance';
|
|
8
|
+
export interface IServerV2DTO {
|
|
9
|
+
id: string | number;
|
|
10
|
+
nm: string | number;
|
|
11
|
+
pr: number;
|
|
12
|
+
qt: number;
|
|
13
|
+
br: string | number;
|
|
14
|
+
va: string | number;
|
|
15
|
+
ca: string | number;
|
|
16
|
+
ps: number;
|
|
17
|
+
cc: string | number;
|
|
18
|
+
attrs: Record<string, string> | null;
|
|
19
|
+
dp_id?: string;
|
|
20
|
+
dp_v?: number;
|
|
21
|
+
n?: string;
|
|
22
|
+
et?: number;
|
|
23
|
+
ua?: Dictionary<string | string[]>;
|
|
24
|
+
ui?: ISDKUserIdentity[];
|
|
25
|
+
ia?: Dictionary<Dictionary<string>>;
|
|
26
|
+
str?: ServerSettings;
|
|
27
|
+
sdk?: string;
|
|
28
|
+
sid?: string;
|
|
29
|
+
sl?: number;
|
|
30
|
+
ssd?: number;
|
|
31
|
+
dt?: number;
|
|
32
|
+
dbg?: boolean;
|
|
33
|
+
ct?: number;
|
|
34
|
+
lc?: SDKGeoLocation;
|
|
35
|
+
o?: boolean;
|
|
36
|
+
eec?: number;
|
|
37
|
+
av?: string;
|
|
38
|
+
cgid?: string;
|
|
39
|
+
das?: string;
|
|
40
|
+
mpid?: MPID;
|
|
41
|
+
smpids?: MPID[];
|
|
42
|
+
con?: IConsentStateV2DTO;
|
|
43
|
+
fr?: boolean;
|
|
44
|
+
iu?: boolean;
|
|
45
|
+
at?: number;
|
|
46
|
+
lr?: string;
|
|
47
|
+
flags?: Dictionary<string[]>;
|
|
48
|
+
cu?: string;
|
|
49
|
+
sc?: {
|
|
50
|
+
pl: IProductV2DTO[];
|
|
51
|
+
};
|
|
52
|
+
pd?: {
|
|
53
|
+
an: number;
|
|
54
|
+
cs: number;
|
|
55
|
+
co: string;
|
|
56
|
+
pl: IProductV2DTO[];
|
|
57
|
+
ta: string;
|
|
58
|
+
ti: string;
|
|
59
|
+
tcc: string;
|
|
60
|
+
tr: number;
|
|
61
|
+
ts: number;
|
|
62
|
+
tt: number;
|
|
63
|
+
};
|
|
64
|
+
pm?: {
|
|
65
|
+
an: string;
|
|
66
|
+
pl: IPromotionV2DTO[];
|
|
67
|
+
};
|
|
68
|
+
pi?: IProductImpressionV2DTO[];
|
|
69
|
+
pet?: number;
|
|
70
|
+
}
|
|
71
|
+
export interface IProductV2DTO {
|
|
72
|
+
id: string | number;
|
|
73
|
+
nm: string | number;
|
|
74
|
+
pr: number;
|
|
75
|
+
qt: number;
|
|
76
|
+
br: string | number;
|
|
77
|
+
va: string | number;
|
|
78
|
+
ca: string | number;
|
|
79
|
+
ps: number;
|
|
80
|
+
cc: string | number;
|
|
81
|
+
tpa: number;
|
|
82
|
+
attrs: Dictionary<string> | null;
|
|
83
|
+
}
|
|
84
|
+
export interface IPromotionV2DTO {
|
|
85
|
+
id: string | number;
|
|
86
|
+
nm: string | number;
|
|
87
|
+
ps: string | number;
|
|
88
|
+
cr: string;
|
|
89
|
+
}
|
|
90
|
+
export interface IProductImpressionV2DTO {
|
|
91
|
+
pil: string;
|
|
92
|
+
pl: IProductV2DTO[];
|
|
93
|
+
}
|
|
94
|
+
export interface IUploadObject extends SDKEvent {
|
|
95
|
+
ClientGeneratedId: string;
|
|
96
|
+
Store: ServerSettings;
|
|
97
|
+
ExpandedEventCount: number;
|
|
98
|
+
ProfileMessageType: number;
|
|
99
|
+
}
|
|
100
|
+
export interface IServerModel {
|
|
101
|
+
convertEventToV2DTO: (event: IUploadObject) => IServerV2DTO;
|
|
102
|
+
createEventObject: (event: BaseEvent, user?: IMParticleUser) => SDKEvent;
|
|
103
|
+
convertToConsentStateV2DTO: (state: SDKConsentState) => IConsentStateV2DTO;
|
|
104
|
+
}
|
|
105
|
+
export default function ServerModel(this: IServerModel, mpInstance: IMParticleWebSDKInstance): void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { IMParticleWebSDKInstance } from './mp-instance';
|
|
2
|
+
export interface ISessionManager {
|
|
3
|
+
initialize: () => void;
|
|
4
|
+
getSessionId: () => string;
|
|
5
|
+
startNewSession: () => void;
|
|
6
|
+
endSession: (override?: boolean) => void;
|
|
7
|
+
setSessionTimer: () => void;
|
|
8
|
+
resetSessionTimer: () => void;
|
|
9
|
+
clearSessionTimeout: () => void;
|
|
10
|
+
startNewSessionIfNeeded: () => void;
|
|
11
|
+
/**
|
|
12
|
+
* @deprecated
|
|
13
|
+
*/
|
|
14
|
+
getSession: () => string;
|
|
15
|
+
}
|
|
16
|
+
export default function SessionManager(this: ISessionManager, mpInstance: IMParticleWebSDKInstance): void;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import { IKitFilterSettings } from './configAPIClient';
|
|
2
|
+
import { UnregisteredKit } from './forwarders.interfaces';
|
|
3
|
+
import { EventType, IdentityType } from './types';
|
|
4
|
+
import { valueof } from './utils';
|
|
5
|
+
export interface IMPSideloadedKit {
|
|
6
|
+
kitInstance: UnregisteredKit;
|
|
7
|
+
filterDictionary: IKitFilterSettings;
|
|
8
|
+
addEventTypeFilter(eventType: valueof<typeof EventType>): void;
|
|
9
|
+
addEventNameFilter(eventType: valueof<typeof EventType>, eventName: string): void;
|
|
10
|
+
addEventAttributeFilter(eventType: valueof<typeof EventType>, eventName: string, customAttributeKey: string): void;
|
|
11
|
+
addScreenNameFilter(screenName: string): void;
|
|
12
|
+
addScreenAttributeFilter(screenName: string, screenAttribute: string): void;
|
|
13
|
+
addUserIdentityFilter(userIdentity: typeof IdentityType): void;
|
|
14
|
+
addUserAttributeFilter(userAttributeKey: string): void;
|
|
15
|
+
}
|
|
16
|
+
export interface IMPSideloadedKitConstructor {
|
|
17
|
+
new (unregisteredKitInstance: UnregisteredKit): IMPSideloadedKit;
|
|
18
|
+
}
|
|
19
|
+
export default class MPSideloadedKit implements IMPSideloadedKit {
|
|
20
|
+
kitInstance: UnregisteredKit;
|
|
21
|
+
filterDictionary: IKitFilterSettings;
|
|
22
|
+
constructor(unregisteredKitInstance: UnregisteredKit);
|
|
23
|
+
addEventTypeFilter(eventType: valueof<typeof EventType>): void;
|
|
24
|
+
addEventNameFilter(eventType: valueof<typeof EventType>, eventName: string): void;
|
|
25
|
+
addEventAttributeFilter(eventType: valueof<typeof EventType>, eventName: string, customAttributeKey: string): void;
|
|
26
|
+
addScreenNameFilter(screenName: string): void;
|
|
27
|
+
addScreenAttributeFilter(screenName: string, screenAttribute: string): void;
|
|
28
|
+
addUserIdentityFilter(userIdentity: typeof IdentityType): void;
|
|
29
|
+
addUserAttributeFilter(userAttributeKey: string): void;
|
|
30
|
+
}
|