@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.
Files changed (77) hide show
  1. package/dist/mparticle.common.js +22 -22
  2. package/dist/mparticle.esm.js +22 -22
  3. package/dist/mparticle.js +118 -173
  4. package/dist/types/src/apiClient.d.ts +34 -0
  5. package/dist/types/src/audience.d.ts +4 -0
  6. package/dist/types/src/audienceManager.d.ts +19 -0
  7. package/dist/types/src/batchUploader.d.ts +72 -0
  8. package/dist/types/src/configAPIClient.d.ts +68 -0
  9. package/dist/types/src/consent.d.ts +71 -0
  10. package/dist/types/src/constants.d.ts +201 -0
  11. package/dist/types/src/cookieConsentManager.d.ts +50 -0
  12. package/dist/types/src/cookieSyncManager.d.ts +34 -0
  13. package/dist/types/src/ecommerce.d.ts +52 -0
  14. package/dist/types/src/ecommerce.interfaces.d.ts +78 -0
  15. package/dist/types/src/events.d.ts +17 -0
  16. package/dist/types/src/events.interfaces.d.ts +21 -0
  17. package/dist/types/src/filteredMparticleUser.d.ts +8 -0
  18. package/dist/types/src/foregroundTimeTracker.d.ts +21 -0
  19. package/dist/types/src/forwarders.d.ts +26 -0
  20. package/dist/types/src/forwarders.interfaces.d.ts +59 -0
  21. package/dist/types/src/forwardingStatsUploader.d.ts +5 -0
  22. package/dist/types/src/helpers.d.ts +54 -0
  23. package/dist/types/src/identity-user-interfaces.d.ts +106 -0
  24. package/dist/types/src/identity-utils.d.ts +36 -0
  25. package/dist/types/src/identity.interfaces.d.ts +117 -0
  26. package/dist/types/src/identityApiClient.d.ts +14 -0
  27. package/dist/types/src/integrationCapture.d.ts +83 -0
  28. package/dist/types/src/internal-types.d.ts +20 -0
  29. package/dist/types/src/kitBlocking.d.ts +116 -0
  30. package/dist/types/src/kitFilterHelper.d.ts +15 -0
  31. package/dist/types/src/logger.d.ts +18 -0
  32. package/dist/types/src/mockBatchCreator.d.ts +7 -0
  33. package/dist/types/src/mp-instance.d.ts +76 -0
  34. package/dist/types/src/mparticle-instance-manager.d.ts +2 -0
  35. package/dist/types/src/nativeSdkHelpers.d.ts +12 -0
  36. package/dist/types/src/nativeSdkHelpers.interfaces.d.ts +10 -0
  37. package/dist/types/src/persistence.d.ts +44 -0
  38. package/dist/types/src/persistence.interfaces.d.ts +73 -0
  39. package/dist/types/src/polyfill.d.ts +15 -0
  40. package/dist/types/src/pre-init-utils.d.ts +11 -0
  41. package/dist/types/src/public-types.d.ts +23 -0
  42. package/dist/types/src/reporting/errorReportingDispatcher.d.ts +8 -0
  43. package/dist/types/src/reporting/loggingDispatcher.d.ts +8 -0
  44. package/dist/types/src/reporting/types.d.ts +37 -0
  45. package/dist/types/src/roktManager.d.ts +176 -0
  46. package/dist/types/src/sdkRuntimeModels.d.ts +319 -0
  47. package/dist/types/src/sdkToEventsApiConverter.d.ts +43 -0
  48. package/dist/types/src/serverModel.d.ts +105 -0
  49. package/dist/types/src/sessionManager.d.ts +16 -0
  50. package/dist/types/src/sideloadedKit.d.ts +30 -0
  51. package/dist/types/src/store.d.ts +157 -0
  52. package/dist/types/src/stub/mparticle.stub.d.ts +182 -0
  53. package/dist/types/src/types.d.ts +154 -0
  54. package/dist/types/src/uploaders.d.ts +21 -0
  55. package/dist/types/src/user-utils.d.ts +5 -0
  56. package/dist/types/src/utils.d.ts +82 -0
  57. package/dist/types/src/validators.d.ts +18 -0
  58. package/dist/types/src/vault.d.ts +41 -0
  59. package/package.json +16 -3
  60. package/src/apiClient.ts +1 -1
  61. package/src/constants.ts +0 -4
  62. package/src/forwarders.interfaces.ts +42 -0
  63. package/src/identityApiClient.ts +9 -6
  64. package/src/internal-types.ts +66 -0
  65. package/src/logger.ts +3 -12
  66. package/src/mp-instance.ts +28 -15
  67. package/src/mparticle-instance-manager.ts +6 -0
  68. package/src/public-types.ts +84 -0
  69. package/src/reporting/errorReportingDispatcher.ts +21 -0
  70. package/src/reporting/loggingDispatcher.ts +21 -0
  71. package/src/reporting/types.ts +45 -0
  72. package/src/roktManager.ts +32 -6
  73. package/src/sdkRuntimeModels.ts +3 -1
  74. package/src/serverModel.ts +1 -1
  75. package/src/store.ts +1 -3
  76. package/src/logging/reportingLogger.ts +0 -192
  77. package/src/logging/types.ts +0 -32
@@ -0,0 +1,59 @@
1
+ import { SDKEvent, SDKEventCustomFlags } from './sdkRuntimeModels';
2
+ import { Dictionary } from './utils';
3
+ import { IKitConfigs, IKitFilterSettings } from './configAPIClient';
4
+ import { IdentityApiData, IdentityType } from '@mparticle/web-sdk';
5
+ import { Batch } from '@mparticle/event-models';
6
+ import { IMParticleUser, ISDKUserIdentity, UserAttributes } from './identity-user-interfaces';
7
+ export type MPForwarder = Dictionary;
8
+ export interface UnregisteredKit {
9
+ constructor: () => void;
10
+ register(config: KitRegistrationConfig): void;
11
+ name: string;
12
+ moduleId?: number;
13
+ suffix?: string;
14
+ }
15
+ export interface RegisteredKit {
16
+ constructor: () => void;
17
+ filters?: IKitFilterSettings;
18
+ }
19
+ export interface KitRegistrationConfig {
20
+ kits: Dictionary<RegisteredKit>;
21
+ }
22
+ export interface ConfiguredKit extends Omit<IKitConfigs, 'isDebugString' | 'hasDebugString'> {
23
+ common: Dictionary<unknown>;
24
+ id: number;
25
+ init(settings: Dictionary<unknown>, service: forwardingStatsCallback, testMode: boolean, trackerId: string | null, userAttributes: UserAttributes, userIdentities: ISDKUserIdentity, appVersion: string, appName: string, customFlags: SDKEventCustomFlags, clientId: string): string;
26
+ onIdentifyComplete(user: IMParticleUser, filteredIdentityRequest: IdentityApiData): string;
27
+ onLoginComplete(user: IMParticleUser, filteredIdentityRequest: IdentityApiData): string;
28
+ onLogoutComplete(user: IMParticleUser, filteredIdentityRequest: IdentityApiData): string;
29
+ onModifyComplete(user: IMParticleUser, filteredIdentityRequest: IdentityApiData): string;
30
+ onUserIdentified(user: IMParticleUser): string;
31
+ process(event: SDKEvent): string;
32
+ setOptOut(isOptingOut: boolean): string;
33
+ removeUserAttribute(key: string): string;
34
+ setUserAttribute(key: string, value: string): string;
35
+ setUserIdentity(id: UserIdentityId, type: UserIdentityType): void;
36
+ isSandbox: boolean;
37
+ hasSandbox: boolean;
38
+ }
39
+ export interface KitInterface {
40
+ id: number;
41
+ name: string;
42
+ init(settings: Dictionary<unknown>, service: forwardingStatsCallback, testMode?: boolean, trackerId?: string | null, userAttributes?: UserAttributes, userIdentities?: ISDKUserIdentity, appVersion?: string, appName?: string, customFlags?: SDKEventCustomFlags, clientId?: string): string;
43
+ onIdentifyComplete?(user: IMParticleUser, filteredIdentityRequest: IdentityApiData): string;
44
+ onLoginComplete?(user: IMParticleUser, filteredIdentityRequest: IdentityApiData): string;
45
+ onLogoutComplete?(user: IMParticleUser, filteredIdentityRequest: IdentityApiData): string;
46
+ onModifyComplete?(user: IMParticleUser, filteredIdentityRequest: IdentityApiData): string;
47
+ onUserIdentified?(user: IMParticleUser): string;
48
+ process?(event: SDKEvent): string;
49
+ processBatch?(batch: Batch): string;
50
+ setOptOut?(isOptingOut: boolean): string;
51
+ removeUserAttribute?(key: string): string;
52
+ setUserAttribute?(key: string, value: string): string;
53
+ setUserIdentity?(id: UserIdentityId, type: UserIdentityType): void;
54
+ }
55
+ export type UserIdentityId = string;
56
+ export type UserIdentityType = number;
57
+ export type UserAttributeFilters = number[];
58
+ export type UserIdentityFilters = typeof IdentityType[];
59
+ export type forwardingStatsCallback = (forwarder: ConfiguredKit, event: SDKEvent) => void;
@@ -0,0 +1,5 @@
1
+ export default function forwardingStatsUploader(mpInstance: any): void;
2
+ export default class forwardingStatsUploader {
3
+ constructor(mpInstance: any);
4
+ startForwardingStatsTimer: () => void;
5
+ }
@@ -0,0 +1,54 @@
1
+ export default function Helpers(mpInstance: any): void;
2
+ export default class Helpers {
3
+ constructor(mpInstance: any);
4
+ canLog: () => boolean;
5
+ getFeatureFlag: (feature: any) => any;
6
+ invokeCallback: (callback: any, code: any, body: any, mParticleUser: any, previousMpid: any) => void;
7
+ invokeAliasCallback: (callback: any, code: any, message: any) => void;
8
+ extend: (...args: any[]) => any;
9
+ createServiceUrl: (secureServiceUrl: any, devToken: any) => string;
10
+ createXHR: (cb: any) => any;
11
+ filterUserIdentities: (userIdentitiesObject: any, filterList: any) => {
12
+ Type: any;
13
+ Identity: any;
14
+ }[];
15
+ filterUserIdentitiesForForwarders: (userIdentities: utils.Dictionary<string>, filterList: number[]) => utils.Dictionary<string>;
16
+ filterUserAttributes: (userAttributes: utils.Dictionary<string>, filterList: number[]) => utils.Dictionary<string>;
17
+ isEventType: (type: any) => boolean;
18
+ sanitizeAttributes: (attrs: any, name: any) => {};
19
+ isDelayedByIntegration: (delayedIntegrations: any, timeoutStart: any, now: any) => boolean;
20
+ createMainStorageName: (workspaceToken: any) => string;
21
+ converted: (s: string) => string;
22
+ findKeyInObject: (obj: any, key: string) => string;
23
+ parseNumber: (value: string | number) => number;
24
+ inArray: (items: any[], name: any) => boolean;
25
+ isObject: (value: any) => boolean;
26
+ decoded: (s: string) => string;
27
+ parseStringOrNumber: (value: string | number) => string | number;
28
+ generateHash: typeof utils.generateHash;
29
+ generateUniqueId: (a?: string) => string;
30
+ Validators: {
31
+ isNumber: (value: any) => boolean;
32
+ isFunction: (fn: any) => boolean;
33
+ isStringOrNumber: (value: any) => boolean;
34
+ isValidAttributeValue: (value: any) => boolean;
35
+ isValidKeyValue: (key: any) => boolean;
36
+ removeFalsyIdentityValues: (identityApiData: import("@mparticle/web-sdk").IdentityApiData, logger: any) => import("@mparticle/web-sdk").IdentityApiData;
37
+ validateIdentities: (identityApiData: import("@mparticle/web-sdk").IdentityApiData, method?: import("./identity.interfaces").IdentityAPIMethod) => {
38
+ valid: boolean;
39
+ error?: utils.valueof<{
40
+ readonly ModifyIdentityRequestUserIdentitiesPresent: "identityRequests to modify require userIdentities to be present. Request not sent to server. Please fix and try again";
41
+ readonly IdentityRequesetInvalidKey: "There is an invalid key on your identityRequest object. It can only contain a `userIdentities` object and a `onUserAlias` function. Request not sent to server. Please fix and try again.";
42
+ readonly OnUserAliasType: "The onUserAlias value must be a function.";
43
+ readonly UserIdentities: "The userIdentities key must be an object with keys of identityTypes and values of strings. Request not sent to server. Please fix and try again.";
44
+ readonly UserIdentitiesInvalidKey: "There is an invalid identity key on your `userIdentities` object within the identityRequest. Request not sent to server. Please fix and try again.";
45
+ readonly UserIdentitiesInvalidValues: "All user identity values must be strings or null. Request not sent to server. Please fix and try again.";
46
+ readonly AliasMissingMpid: "Alias Request must contain both a destinationMpid and a sourceMpid";
47
+ readonly AliasNonUniqueMpid: "Alias Request's destinationMpid and sourceMpid must be unique";
48
+ readonly AliasMissingTime: "Alias Request must have both a startTime and an endTime";
49
+ readonly AliasStartBeforeEndTime: "Alias Request's endTime must be later than its startTime";
50
+ }>;
51
+ };
52
+ };
53
+ }
54
+ import * as utils from './utils';
@@ -0,0 +1,106 @@
1
+ import { AllUserAttributes, MPID, User } from '@mparticle/web-sdk';
2
+ import { SDKIdentityTypeEnum } from './identity.interfaces';
3
+ import { MessageType } from './types';
4
+ import { BaseEvent, SDKProduct } from './sdkRuntimeModels';
5
+ declare const HTTPCodes: {
6
+ readonly noHttpCoverage: -1;
7
+ readonly activeIdentityRequest: -2;
8
+ readonly activeSession: -3;
9
+ readonly validationIssue: -4;
10
+ readonly nativeIdentityRequest: -5;
11
+ readonly loggingDisabledOrMissingAPIKey: -6;
12
+ readonly tooManyRequests: 429;
13
+ };
14
+ interface ICart {
15
+ /**
16
+ * @deprecated Cart persistence in mParticle has been deprecated. Please use mParticle.eCommerce.logProductAction(mParticle.ProductActionType.AddToCart, [products])
17
+ */
18
+ add: (product: SDKProduct, logEventBoolean?: boolean) => void;
19
+ /**
20
+ * @deprecated Cart persistence in mParticle has been deprecated. Please use mParticle.eCommerce.logProductAction(mParticle.ProductActionType.RemoveFromCart, [products])
21
+ */
22
+ remove: (product: SDKProduct, logEventBoolean?: boolean) => void;
23
+ /**
24
+ * @deprecated Cart persistence in mParticle has been deprecated.
25
+ */
26
+ clear: () => void;
27
+ /**
28
+ * @deprecated Cart Products have been deprecated
29
+ */
30
+ getCartProducts: () => SDKProduct[];
31
+ }
32
+ export interface IMParticleUser extends User {
33
+ getAllUserAttributes(): any;
34
+ setUserTag(tagName: string, value?: any): void;
35
+ setUserAttribute(key: string, value: any): void;
36
+ getUserAudiences?(callback?: IdentityCallback): void;
37
+ getCart(): ICart;
38
+ }
39
+ export interface ISDKUserIdentity {
40
+ Identity: string;
41
+ Type: number;
42
+ }
43
+ export interface ISDKUserIdentityChanges {
44
+ New: ISDKUserIdentityChangeData;
45
+ Old: ISDKUserIdentityChangeData;
46
+ }
47
+ export interface ISDKUserIdentityChangeData {
48
+ IdentityType: SDKIdentityTypeEnum;
49
+ Identity: string;
50
+ CreatedThisBatch: boolean;
51
+ Timestamp?: number;
52
+ }
53
+ export interface IUserIdentityChangeEvent extends BaseEvent {
54
+ messageType: typeof MessageType.UserIdentityChange;
55
+ userIdentityChanges: ISDKUserIdentityChanges;
56
+ }
57
+ export interface ISDKUserAttributes {
58
+ [key: string]: string | string[] | null;
59
+ }
60
+ export interface ISDKUserAttributeChangeData {
61
+ UserAttributeName: string;
62
+ New: string;
63
+ Old: string;
64
+ Deleted: boolean;
65
+ IsNewAttribute: boolean;
66
+ }
67
+ export interface IUserAttributeChangeEvent extends BaseEvent {
68
+ messageType: typeof MessageType.UserAttributeChange;
69
+ userAttributeChanges: ISDKUserAttributeChangeData;
70
+ }
71
+ export interface IdentityCallback {
72
+ (result: IdentityResult): void;
73
+ }
74
+ export interface IIdentityResponse {
75
+ responseText: IdentityResultBody;
76
+ status: number;
77
+ cacheMaxAge?: number;
78
+ expireTimestamp?: number;
79
+ }
80
+ export interface IdentityResult {
81
+ httpCode: typeof HTTPCodes;
82
+ getPreviousUser(): User;
83
+ getUser(): User;
84
+ body: IdentityResultBody | IdentityModifyResultBody;
85
+ }
86
+ export interface IdentityResultBody {
87
+ context: string | null;
88
+ is_ephemeral: boolean;
89
+ is_logged_in: boolean;
90
+ matched_identities: Record<string, unknown>;
91
+ mpid?: MPID;
92
+ }
93
+ export interface IdentityModifyResultBody {
94
+ change_results?: {
95
+ identity_type: SDKIdentityTypeEnum;
96
+ modified_mpid: MPID;
97
+ };
98
+ }
99
+ export interface mParticleUserCart {
100
+ add(): void;
101
+ remove(): void;
102
+ clear(): void;
103
+ getCartProducts(): SDKProduct[];
104
+ }
105
+ export type UserAttributes = AllUserAttributes;
106
+ export {};
@@ -0,0 +1,36 @@
1
+ import { Dictionary } from './utils';
2
+ import { BaseVault } from './vault';
3
+ import { IdentityApiData, UserIdentities, IdentityCallback } from '@mparticle/web-sdk';
4
+ import { IdentityAPIMethod } from './identity.interfaces';
5
+ import { IIdentityResponse, IMParticleUser } from './identity-user-interfaces';
6
+ import { IStore } from './store';
7
+ export declare const CACHE_HEADER: "x-mp-max-age";
8
+ export type IdentityCache = BaseVault<Dictionary<ICachedIdentityCall>>;
9
+ export type IParseCachedIdentityResponse = (cachedIdentity: IIdentityResponse, mpid: string, callback: IdentityCallback, identityApiData: IdentityApiData, identityMethod: string, knownIdentities: IKnownIdentities, fromCachedIdentity: boolean) => void;
10
+ export interface IKnownIdentities extends UserIdentities {
11
+ device_application_stamp?: string;
12
+ }
13
+ export interface ICachedIdentityCall {
14
+ responseText: string;
15
+ status: number;
16
+ expireTimestamp: number;
17
+ }
18
+ export declare const cacheOrClearIdCache: (method: string, knownIdentities: IKnownIdentities, idCache: BaseVault<Dictionary<ICachedIdentityCall>>, identityResponse: IIdentityResponse, parsingCachedResponse: boolean) => void;
19
+ export declare const cacheIdentityRequest: (method: IdentityAPIMethod, identities: IKnownIdentities, expireTimestamp: number, idCache: IdentityCache, identityResponse: IIdentityResponse) => void;
20
+ export declare const concatenateIdentities: (method: IdentityAPIMethod, userIdentities: IKnownIdentities) => string;
21
+ export declare const hasValidCachedIdentity: (method: IdentityAPIMethod, proposedUserIdentities: IKnownIdentities, idCache?: IdentityCache) => boolean;
22
+ export declare const getCachedIdentity: (method: IdentityAPIMethod, proposedUserIdentities: IKnownIdentities, idCache: IdentityCache) => IIdentityResponse | null;
23
+ export declare const createKnownIdentities: (identityApiData: IdentityApiData, deviceId: string) => IKnownIdentities;
24
+ export declare const removeExpiredIdentityCacheDates: (idCache: BaseVault<Dictionary<ICachedIdentityCall>>) => void;
25
+ export declare const tryCacheIdentity: (knownIdentities: IKnownIdentities, idCache: IdentityCache, parseIdentityResponse: IParseCachedIdentityResponse, mpid: string, callback: IdentityCallback, identityApiData: IdentityApiData, identityMethod: IdentityAPIMethod) => boolean;
26
+ export declare const hasIdentityRequestChanged: (currentUser: IMParticleUser, newIdentityRequest: IdentityApiData) => boolean;
27
+ /**
28
+ * Checks if deviceId or other user identifiers (like email) were explicitly provided
29
+ * by the partner via config.deviceId or config.identifyRequest.userIdentities.
30
+ * When noFunctional is true, then cookies are blocked, so the partner must explicitly
31
+ * pass deviceId or other identifiers to prevent new users from being created on each page load.
32
+ *
33
+ * @param store - The SDK store (provides SDKConfig.deviceId and SDKConfig.identifyRequest.userIdentities)
34
+ * @returns true if deviceId or other identifiers were explicitly provided in config, false otherwise
35
+ */
36
+ export declare const hasExplicitIdentifier: (store: IStore | undefined | null) => boolean;
@@ -0,0 +1,117 @@
1
+ import { IdentityApiData, MPID, UserIdentities } from '@mparticle/web-sdk';
2
+ import AudienceManager from './audienceManager';
3
+ import { ICachedIdentityCall, IKnownIdentities } from './identity-utils';
4
+ import { BaseVault } from './vault';
5
+ import { Dictionary, Environment, valueof } from './utils';
6
+ import Constants from './constants';
7
+ import { IdentityCallback, IUserAttributeChangeEvent, IUserIdentityChangeEvent, IMParticleUser, mParticleUserCart, IIdentityResponse } from './identity-user-interfaces';
8
+ declare const platform: "web", sdkVendor: "mparticle", sdkVersion: string, HTTPCodes: {
9
+ readonly noHttpCoverage: -1;
10
+ readonly activeIdentityRequest: -2;
11
+ readonly activeSession: -3;
12
+ readonly validationIssue: -4;
13
+ readonly nativeIdentityRequest: -5;
14
+ readonly loggingDisabledOrMissingAPIKey: -6;
15
+ readonly tooManyRequests: 429;
16
+ };
17
+ export type IdentityPreProcessResult = {
18
+ valid: boolean;
19
+ error?: string;
20
+ };
21
+ export type IdentityAPIMethod = valueof<typeof Constants.IdentityMethods>;
22
+ export declare enum SDKIdentityTypeEnum {
23
+ other = "other",
24
+ customerId = "customerid",
25
+ facebook = "facebook",
26
+ twitter = "twitter",
27
+ google = "google",
28
+ microsoft = "microsoft",
29
+ yahoo = "yahoo",
30
+ email = "email",
31
+ alias = "alias",
32
+ facebookCustomAudienceId = "facebookcustomaudienceid",
33
+ otherId2 = "other2",
34
+ otherId3 = "other3",
35
+ otherId4 = "other4",
36
+ otherId5 = "other5",
37
+ otherId6 = "other6",
38
+ otherId7 = "other7",
39
+ otherId8 = "other8",
40
+ otherId9 = "other9",
41
+ otherId10 = "other10",
42
+ mobileNumber = "mobile_number",
43
+ phoneNumber2 = "phone_number_2",
44
+ phoneNumber3 = "phone_number_3"
45
+ }
46
+ export interface IIdentityAPIRequestData {
47
+ client_sdk: {
48
+ platform: typeof platform;
49
+ sdk_vendor: typeof sdkVendor;
50
+ sdk_version: typeof sdkVersion;
51
+ };
52
+ context: string | null;
53
+ environment: Environment;
54
+ request_id: string;
55
+ request_timestamp_unixtime_ms: number;
56
+ previous_mpid: MPID | null;
57
+ known_identities: IKnownIdentities;
58
+ }
59
+ export interface IIdentityAPIModifyRequestData extends Omit<IIdentityAPIRequestData, 'known_identities' | 'previous_mpid'> {
60
+ identity_changes: IIdentityAPIIdentityChangeData[];
61
+ }
62
+ export interface IIdentityAPIIdentityChangeData {
63
+ identity_type: SDKIdentityTypeEnum;
64
+ old_value: string;
65
+ new_value: string;
66
+ }
67
+ export interface IIdentityRequest {
68
+ combineUserIdentities(previousUIByName: UserIdentities, newUIByName: UserIdentities): UserIdentities;
69
+ createIdentityRequest(identityApiData: IdentityApiData, platform: string, sdkVendor: string, sdkVersion: string, deviceId: string, context: string | null, mpid: MPID): IIdentityAPIRequestData;
70
+ createModifyIdentityRequest(currentUserIdentities: UserIdentities, newUserIdentities: UserIdentities, platform: string, sdkVendor: string, sdkVersion: string, context: string | null): IIdentityAPIModifyRequestData;
71
+ createIdentityChanges(previousIdentities: UserIdentities, newIdentitie: UserIdentities): IIdentityAPIIdentityChangeData;
72
+ preProcessIdentityRequest(identityApiData: IdentityApiData, callback: IdentityCallback, method: IdentityAPIMethod): IdentityPreProcessResult;
73
+ }
74
+ export type AliasRequestScope = 'device' | 'mpid';
75
+ export interface IAliasRequest {
76
+ destinationMpid: MPID;
77
+ sourceMpid: MPID;
78
+ startTime: number;
79
+ endTime: number;
80
+ scope?: AliasRequestScope;
81
+ }
82
+ export interface IAliasCallback {
83
+ (result: IAliasResult): void;
84
+ }
85
+ export interface IAliasResult {
86
+ httpCode: number;
87
+ message: string;
88
+ }
89
+ export interface SDKIdentityApi {
90
+ HTTPCodes: typeof HTTPCodes;
91
+ identify?(identityApiData?: IdentityApiData, callback?: IdentityCallback): void;
92
+ login?(identityApiData?: IdentityApiData, callback?: IdentityCallback): void;
93
+ logout?(identityApiData?: IdentityApiData, callback?: IdentityCallback): void;
94
+ modify?(identityApiData?: IdentityApiData, callback?: IdentityCallback): void;
95
+ getCurrentUser?(): IMParticleUser;
96
+ getUser?(mpid: string): IMParticleUser;
97
+ getUsers?(): IMParticleUser[];
98
+ aliasUsers?(aliasRequest?: IAliasRequest, callback?: IdentityCallback): void;
99
+ createAliasRequest?(sourceUser: IMParticleUser, destinationUser: IMParticleUser, scope?: AliasRequestScope): IAliasRequest;
100
+ }
101
+ export interface IIdentity {
102
+ audienceManager: AudienceManager;
103
+ idCache: BaseVault<Dictionary<ICachedIdentityCall>>;
104
+ IdentityAPI: SDKIdentityApi;
105
+ IdentityRequest: IIdentityRequest;
106
+ mParticleUser(mpid: MPID, IsLoggedIn: boolean): IMParticleUser;
107
+ createUserAttributeChange(key: string, newValue: string, previousUserAttributeValue: string, isNewAttribute: boolean, deleted: boolean, user: IMParticleUser): IUserAttributeChangeEvent;
108
+ createUserIdentityChange(identityType: SDKIdentityTypeEnum, newIdentity: string, oldIdentity: string, newCreatedThisBatch: boolean, userInMemory: IMParticleUser): IUserIdentityChangeEvent;
109
+ parseIdentityResponse(identityResponse: IIdentityResponse, previousMPID: MPID, callback: IdentityCallback, identityApiData: IdentityApiData, method: IdentityAPIMethod, knownIdentities: UserIdentities, parsingCachedResponse: boolean): void;
110
+ sendUserAttributeChangeEvent(attributeKey: string, newUserAttributeValue: string, previousUserAttributeValue: string, isNewAttribute: boolean, deleted: boolean, user: IMParticleUser): void;
111
+ sendUserIdentityChangeEvent(newUserIdentities: UserIdentities, method: IdentityAPIMethod, mpid: MPID, prevUserIdentities: UserIdentities): void;
112
+ /**
113
+ * @deprecated
114
+ */
115
+ mParticleUserCart(): mParticleUserCart;
116
+ }
117
+ export {};
@@ -0,0 +1,14 @@
1
+ import { IAliasCallback, IAliasRequest, IdentityAPIMethod, IIdentity, IIdentityAPIRequestData } from './identity.interfaces';
2
+ import { IdentityApiData, MPID, UserIdentities } from '@mparticle/web-sdk';
3
+ import { IdentityCallback, IdentityResultBody, IIdentityResponse } from './identity-user-interfaces';
4
+ import { IMParticleWebSDKInstance } from './mp-instance';
5
+ export interface IIdentityApiClient {
6
+ sendAliasRequest: (aliasRequest: IAliasRequest, aliasCallback: IAliasCallback) => Promise<void>;
7
+ sendIdentityRequest: (identityApiRequest: IIdentityAPIRequestData, method: IdentityAPIMethod, callback: IdentityCallback, originalIdentityApiData: IdentityApiData, parseIdentityResponse: IIdentity['parseIdentityResponse'], mpid: MPID, knownIdentities: UserIdentities) => Promise<void>;
8
+ getUploadUrl: (method: IdentityAPIMethod, mpid: MPID) => string;
9
+ getIdentityResponseFromFetch: (response: Response, responseBody: IdentityResultBody) => IIdentityResponse;
10
+ getIdentityResponseFromXHR: (response: XMLHttpRequest) => IIdentityResponse;
11
+ }
12
+ export interface IAliasResponseBody {
13
+ }
14
+ export default function IdentityAPIClient(this: IIdentityApiClient, mpInstance: IMParticleWebSDKInstance): void;
@@ -0,0 +1,83 @@
1
+ import { SDKEventCustomFlags } from './sdkRuntimeModels';
2
+ import Constants from './constants';
3
+ import { IntegrationAttributes } from './store';
4
+ import { Dictionary, valueof } from './utils';
5
+ export interface IntegrationCaptureProcessorFunction {
6
+ (clickId: string, url: string, timestamp?: number): string;
7
+ }
8
+ export declare const facebookClickIdProcessor: IntegrationCaptureProcessorFunction;
9
+ declare const IntegrationOutputs: {
10
+ readonly CUSTOM_FLAGS: "custom_flags";
11
+ readonly PARTNER_IDENTITIES: "partner_identities";
12
+ readonly INTEGRATION_ATTRIBUTES: "integration_attributes";
13
+ };
14
+ interface IntegrationMappingItem {
15
+ mappedKey: string;
16
+ output: valueof<typeof IntegrationOutputs>;
17
+ processor?: IntegrationCaptureProcessorFunction;
18
+ moduleId?: number;
19
+ }
20
+ interface IntegrationIdMapping {
21
+ [key: string]: IntegrationMappingItem;
22
+ }
23
+ export default class IntegrationCapture {
24
+ clickIds: Dictionary<string>;
25
+ readonly initialTimestamp: number;
26
+ readonly filteredPartnerIdentityMappings: IntegrationIdMapping;
27
+ readonly filteredCustomFlagMappings: IntegrationIdMapping;
28
+ readonly filteredIntegrationAttributeMappings: IntegrationIdMapping;
29
+ captureMode?: valueof<typeof Constants.CaptureIntegrationSpecificIdsV2Modes>;
30
+ constructor(captureMode: valueof<typeof Constants.CaptureIntegrationSpecificIdsV2Modes>);
31
+ /**
32
+ * Captures Integration Ids from cookies and query params and stores them in clickIds object
33
+ */
34
+ capture(): void;
35
+ /**
36
+ * Captures cookies based on the integration ID mapping.
37
+ */
38
+ captureCookies(): Dictionary<string>;
39
+ /**
40
+ * Captures query parameters based on the integration ID mapping.
41
+ */
42
+ captureQueryParams(): Dictionary<string>;
43
+ /**
44
+ * Captures local storage based on the integration ID mapping.
45
+ */
46
+ captureLocalStorage(): Dictionary<string>;
47
+ /**
48
+ * Gets the query parameters based on the integration ID mapping.
49
+ * @returns {Dictionary<string>} The query parameters.
50
+ */
51
+ getQueryParams(): Dictionary<string>;
52
+ /**
53
+ * Converts captured click IDs to custom flags for SDK events.
54
+ * @returns {SDKEventCustomFlags} The custom flags.
55
+ */
56
+ getClickIdsAsCustomFlags(): SDKEventCustomFlags;
57
+ /**
58
+ * Returns only the `partner_identities` mapped integration output.
59
+ * @returns {Dictionary<string>} The partner identities.
60
+ */
61
+ getClickIdsAsPartnerIdentities(): Dictionary<string>;
62
+ /**
63
+ * Returns only the `integration_attributes` mapped integration output.
64
+ * @returns {IntegrationAttributes} The integration attributes.
65
+ */
66
+ getClickIdsAsIntegrationAttributes(): IntegrationAttributes;
67
+ private getClickIds;
68
+ private applyProcessors;
69
+ private filterMappings;
70
+ /**
71
+ * Returns the allowed keys to capture based on the current mode.
72
+ * For RoktOnly, limit capture to Rokt keys; for All, capture all mapped keys.
73
+ */
74
+ private getAllowedKeysForMode;
75
+ /**
76
+ * Selects the active integration mapping for the current captureMode.
77
+ * - 'roktonly': only Rokt IDs are considered
78
+ * - 'all': both External and Rokt IDs are considered
79
+ * - else: returns an empty mapping and nothing will be captured
80
+ */
81
+ private getActiveIntegrationMapping;
82
+ }
83
+ export {};
@@ -0,0 +1,20 @@
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
+ export * from './public-types';
16
+ export type { KitInterface, } from './forwarders.interfaces';
17
+ export type { RoktAttributeValue, RoktAttributeValueType, RoktAttributeValueArray, RoktAttributes, IRoktPartnerExtensionData, IRoktSelectPlacementsOptions, IRoktSelection, IRoktLauncher, IRoktMessage, RoktKitFilterSettings, IRoktKitSettings, IRoktKit, IRoktOptions, IRoktLauncherOptions, } from './roktManager';
18
+ export type { ErrorCodes, WSDKErrorSeverity, } from './reporting/types';
19
+ export type { ISDKError, ISDKLogEntry, IErrorReportingService, ILoggingService, } from './reporting/types';
20
+ export type { SDKEvent, SDKProductAction, SDKProductActionType, SDKPromotionAction, SDKShoppingCart, SDKGeoLocation, SDKDataPlan, SDKLoggerApi, SDKConfigApi, IMParticleInstanceManager, } from './sdkRuntimeModels';
@@ -0,0 +1,116 @@
1
+ import { SDKEvent, KitBlockerDataPlan } from './sdkRuntimeModels';
2
+ import { BaseEvent } from '@mparticle/event-models';
3
+ import { DataPlanPoint } from '@mparticle/data-planning-models';
4
+ import { IMParticleWebSDKInstance } from './mp-instance';
5
+ export default class KitBlocker {
6
+ dataPlanMatchLookups: {
7
+ [key: string]: {};
8
+ };
9
+ blockEvents: boolean;
10
+ blockEventAttributes: boolean;
11
+ blockUserAttributes: boolean;
12
+ blockUserIdentities: boolean;
13
+ kitBlockingEnabled: boolean;
14
+ mpInstance: IMParticleWebSDKInstance;
15
+ constructor(dataPlan: KitBlockerDataPlan, mpInstance: IMParticleWebSDKInstance);
16
+ addToMatchLookups(point: DataPlanPoint): void;
17
+ generateMatchKey(match: any): string | null;
18
+ generateProductAttributeMatchKey(match: any): string | null;
19
+ getPlannedProperties(type: any, validator: any): boolean | {
20
+ [key: string]: true;
21
+ } | null;
22
+ getProductProperties(type: any, validator: any): boolean | {
23
+ [key: string]: true;
24
+ } | null;
25
+ getMatchKey(eventToMatch: BaseEvent): string | null;
26
+ getProductAttributeMatchKey(eventToMatch: BaseEvent): string | null;
27
+ createBlockedEvent(event: SDKEvent): SDKEvent;
28
+ transformEventAndEventAttributes(event: SDKEvent): SDKEvent;
29
+ transformProductAttributes(event: SDKEvent): SDKEvent;
30
+ transformUserAttributes(event: SDKEvent): {
31
+ DeviceId: string;
32
+ IsFirstRun: boolean;
33
+ EventName: string;
34
+ EventCategory: number;
35
+ UserAttributes?: import("./identity-user-interfaces").ISDKUserAttributes;
36
+ UserIdentities?: import("./identity-user-interfaces").ISDKUserIdentity[];
37
+ SourceMessageId: string;
38
+ MPID: string;
39
+ EventAttributes?: {
40
+ [key: string]: string;
41
+ };
42
+ SDKVersion: string;
43
+ SessionId: string;
44
+ SessionStartDate: number;
45
+ SessionLength?: number;
46
+ currentSessionMPIDs?: string[];
47
+ Timestamp: number;
48
+ EventDataType: number;
49
+ Debug: boolean;
50
+ Location?: import("./sdkRuntimeModels").SDKGeoLocation;
51
+ OptOut?: boolean;
52
+ CustomFlags?: import("./sdkRuntimeModels").SDKEventCustomFlags;
53
+ AppVersion?: string;
54
+ AppName?: string;
55
+ Package?: string;
56
+ ConsentState?: import("./consent").SDKConsentState;
57
+ IntegrationAttributes?: import("./store").IntegrationAttributes;
58
+ ProductAction?: import("./sdkRuntimeModels").SDKProductAction;
59
+ PromotionAction?: import("./sdkRuntimeModels").SDKPromotionAction;
60
+ ProductImpressions?: import("./sdkRuntimeModels").SDKProductImpression[];
61
+ ShoppingCart?: import("./sdkRuntimeModels").SDKShoppingCart;
62
+ UserIdentityChanges?: import("./identity-user-interfaces").ISDKUserIdentityChanges;
63
+ UserAttributeChanges?: import("./identity-user-interfaces").ISDKUserAttributeChangeData;
64
+ CurrencyCode: string;
65
+ DataPlan?: import("./sdkRuntimeModels").SDKDataPlan;
66
+ LaunchReferral?: string;
67
+ ExpandedEventCount: number;
68
+ ActiveTimeOnSite: number;
69
+ IsBackgroundAST?: boolean;
70
+ AlreadySentToForwarders?: boolean;
71
+ };
72
+ isAttributeKeyBlocked(key: string): boolean;
73
+ isIdentityBlocked(key: string): boolean;
74
+ transformUserIdentities(event: SDKEvent): {
75
+ DeviceId: string;
76
+ IsFirstRun: boolean;
77
+ EventName: string;
78
+ EventCategory: number;
79
+ UserAttributes?: import("./identity-user-interfaces").ISDKUserAttributes;
80
+ UserIdentities?: import("./identity-user-interfaces").ISDKUserIdentity[];
81
+ SourceMessageId: string;
82
+ MPID: string;
83
+ EventAttributes?: {
84
+ [key: string]: string;
85
+ };
86
+ SDKVersion: string;
87
+ SessionId: string;
88
+ SessionStartDate: number;
89
+ SessionLength?: number;
90
+ currentSessionMPIDs?: string[];
91
+ Timestamp: number;
92
+ EventDataType: number;
93
+ Debug: boolean;
94
+ Location?: import("./sdkRuntimeModels").SDKGeoLocation;
95
+ OptOut?: boolean;
96
+ CustomFlags?: import("./sdkRuntimeModels").SDKEventCustomFlags;
97
+ AppVersion?: string;
98
+ AppName?: string;
99
+ Package?: string;
100
+ ConsentState?: import("./consent").SDKConsentState;
101
+ IntegrationAttributes?: import("./store").IntegrationAttributes;
102
+ ProductAction?: import("./sdkRuntimeModels").SDKProductAction;
103
+ PromotionAction?: import("./sdkRuntimeModels").SDKPromotionAction;
104
+ ProductImpressions?: import("./sdkRuntimeModels").SDKProductImpression[];
105
+ ShoppingCart?: import("./sdkRuntimeModels").SDKShoppingCart;
106
+ UserIdentityChanges?: import("./identity-user-interfaces").ISDKUserIdentityChanges;
107
+ UserAttributeChanges?: import("./identity-user-interfaces").ISDKUserAttributeChangeData;
108
+ CurrencyCode: string;
109
+ DataPlan?: import("./sdkRuntimeModels").SDKDataPlan;
110
+ LaunchReferral?: string;
111
+ ExpandedEventCount: number;
112
+ ActiveTimeOnSite: number;
113
+ IsBackgroundAST?: boolean;
114
+ AlreadySentToForwarders?: boolean;
115
+ };
116
+ }
@@ -0,0 +1,15 @@
1
+ import { Dictionary, valueof } from "./utils";
2
+ import { EventType, IdentityType } from "./types";
3
+ export default class KitFilterHelper {
4
+ static hashEventType(eventType: valueof<typeof EventType>): number;
5
+ static hashEventName(eventName: string, eventType: valueof<typeof EventType>): number;
6
+ static hashEventAttributeKey(eventType: valueof<typeof EventType>, eventName: string, customAttributeName: string): number;
7
+ static hashUserAttribute(userAttributeKey: string): number;
8
+ static hashUserIdentity(userIdentity: typeof IdentityType): typeof IdentityType;
9
+ static hashConsentPurpose(prefix: string, purpose: string): number;
10
+ static hashAttributeConditionalForwarding(attribute: string): string;
11
+ static hashConsentPurposeConditionalForwarding(prefix: string, purpose: string): string;
12
+ static readonly filterUserAttributes: (userAttributes: Dictionary<string>, filterList: number[]) => Dictionary<string>;
13
+ static readonly filterUserIdentities: (userIdentities: Dictionary<string>, filterList: number[]) => Dictionary<string>;
14
+ static readonly isFilteredUserAttribute: (userAttributeKey: string, filterList: number[]) => boolean;
15
+ }
@@ -0,0 +1,18 @@
1
+ import { LogLevelType, SDKInitConfig, SDKLoggerApi } from './sdkRuntimeModels';
2
+ export type ILoggerConfig = Pick<SDKInitConfig, 'logLevel' | 'logger'>;
3
+ export type IConsoleLogger = Partial<Pick<SDKLoggerApi, 'error' | 'warning' | 'verbose'>>;
4
+ export declare class Logger {
5
+ private logLevel;
6
+ private logger;
7
+ constructor(config: ILoggerConfig);
8
+ verbose(msg: string): void;
9
+ warning(msg: string): void;
10
+ error(msg: string): void;
11
+ isVerbose(): boolean;
12
+ setLogLevel(newLogLevel: LogLevelType): void;
13
+ }
14
+ export declare class ConsoleLogger implements IConsoleLogger {
15
+ verbose(msg: string): void;
16
+ error(msg: string): void;
17
+ warning(msg: string): void;
18
+ }
@@ -0,0 +1,7 @@
1
+ import { BaseEvent } from './sdkRuntimeModels';
2
+ import { Batch } from '@mparticle/event-models';
3
+ export default class _BatchValidator {
4
+ private getMPInstance;
5
+ private createSDKEventFunction;
6
+ returnBatch(events: BaseEvent | BaseEvent[]): Batch | null;
7
+ }