@mparticle/web-sdk 2.79.3 → 2.80.1

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 (39) hide show
  1. package/dist/mparticle.common.js +220 -574
  2. package/dist/mparticle.esm.js +220 -574
  3. package/dist/mparticle.js +1489 -1793
  4. package/dist/types/src/configAPIClient.d.ts +1 -0
  5. package/dist/types/src/ecommerce.d.ts +3 -53
  6. package/dist/types/src/ecommerce.interfaces.d.ts +11 -12
  7. package/dist/types/src/events.interfaces.d.ts +1 -1
  8. package/dist/types/src/forwarders.d.ts +4 -26
  9. package/dist/types/src/forwarders.interfaces.d.ts +41 -10
  10. package/dist/types/src/identity-utils.d.ts +3 -3
  11. package/dist/types/src/identity.d.ts +3 -0
  12. package/dist/types/src/identity.interfaces.d.ts +45 -11
  13. package/dist/types/src/identityApiClient.d.ts +5 -4
  14. package/dist/types/src/mp-instance.d.ts +2 -2
  15. package/dist/types/src/pageViewTracker.d.ts +12 -5
  16. package/dist/types/src/persistence.d.ts +3 -44
  17. package/dist/types/src/persistence.interfaces.d.ts +12 -13
  18. package/dist/types/src/sdkRuntimeModels.d.ts +3 -2
  19. package/dist/types/src/store.d.ts +5 -3
  20. package/package.json +1 -1
  21. package/src/configAPIClient.ts +1 -0
  22. package/src/ecommerce.interfaces.ts +12 -21
  23. package/src/{ecommerce.js → ecommerce.ts} +144 -73
  24. package/src/events.interfaces.ts +1 -1
  25. package/src/events.ts +10 -2
  26. package/src/forwarders.interfaces.ts +73 -10
  27. package/src/{forwarders.js → forwarders.ts} +214 -176
  28. package/src/helpers.ts +7 -3
  29. package/src/identity-utils.ts +2 -2
  30. package/src/identity.interfaces.ts +58 -14
  31. package/src/{identity.js → identity.ts} +237 -192
  32. package/src/identityApiClient.ts +9 -9
  33. package/src/mp-instance.ts +2 -2
  34. package/src/pageViewTracker.ts +176 -42
  35. package/src/persistence.interfaces.ts +12 -13
  36. package/src/persistence.ts +1210 -0
  37. package/src/sdkRuntimeModels.ts +3 -1
  38. package/src/store.ts +5 -3
  39. package/src/persistence.js +0 -985
@@ -7,6 +7,7 @@ export interface IKitConfigs extends IKitFilterSettings {
7
7
  suffix?: string;
8
8
  moduleId: number;
9
9
  isDebug: boolean;
10
+ isSandbox?: boolean;
10
11
  isVisible: boolean;
11
12
  isDebugString: BooleanStringLowerCase;
12
13
  hasDebugString: BooleanStringLowerCase;
@@ -1,53 +1,3 @@
1
- export default function Ecommerce(mpInstance: any): void;
2
- export default class Ecommerce {
3
- constructor(mpInstance: any);
4
- convertTransactionAttributesToProductAction: (transactionAttributes: any, productAction: any) => void;
5
- calculateProductActionTotalAmount: (productAction: any) => any;
6
- getProductActionEventName: (productActionType: any) => "AddToCart" | "AddToWishlist" | "Checkout" | "CheckoutOption" | "Click" | "Purchase" | "Refund" | "RemoveFromCart" | "RemoveFromWishlist" | "ViewDetail" | "ViewCart" | "AddShippingInfo" | "AddPaymentInfo" | "PaymentMethodSelected" | "PaymentAttempted" | "PaymentSucceeded" | "PaymentFailed" | "RefundInitiated" | "Unknown";
7
- getPromotionActionEventName: (promotionActionType: any) => "Unknown" | "PromotionClick" | "PromotionView";
8
- convertProductActionToEventType: (productActionType: any) => 0 | 20 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 21;
9
- convertPromotionActionToEventType: (promotionActionType: any) => 18 | 19;
10
- generateExpandedEcommerceName: (eventName: any, plusOne: any) => string;
11
- extractProductAttributes: (attributes: any, product: any) => void;
12
- extractTransactionId: (attributes: any, productAction: any) => void;
13
- extractActionAttributes: (attributes: any, productAction: any) => void;
14
- extractPromotionAttributes: (attributes: any, promotion: any) => void;
15
- buildProductList: (event: any, product: any) => any;
16
- createProduct: (name: any, sku: any, price: any, quantity: any, variant: any, category: any, brand: any, position: any, couponCode: any, attributes: any) => {
17
- Name: string;
18
- Sku: any;
19
- Price: any;
20
- Quantity: any;
21
- Brand: any;
22
- Variant: any;
23
- Category: any;
24
- Position: any;
25
- CouponCode: any;
26
- TotalAmount: number;
27
- Attributes: any;
28
- };
29
- createPromotion: (id: any, creative: any, name: any, position: any) => {
30
- Id: any;
31
- Creative: any;
32
- Name: any;
33
- Position: any;
34
- };
35
- createImpression: (name: any, product: any) => {
36
- Name: string;
37
- Product: any;
38
- };
39
- createTransactionAttributes: (id: any, affiliation: any, couponCode: any, revenue: any, shipping: any, tax: any) => {
40
- Id: any;
41
- Affiliation: any;
42
- CouponCode: any;
43
- Revenue: any;
44
- Shipping: any;
45
- Tax: any;
46
- };
47
- expandProductImpression: (commerceEvent: any) => any[];
48
- expandCommerceEvent: (event: any) => any[];
49
- expandPromotionAction: (commerceEvent: any) => any[];
50
- expandProductAction: (commerceEvent: any) => any[];
51
- createCommerceEventObject: (customFlags: any, options: any) => any;
52
- sanitizeAmount: (amount: any, category: any) => any;
53
- }
1
+ import { IMParticleWebSDKInstance } from './mp-instance';
2
+ import { IECommerce } from './ecommerce.interfaces';
3
+ export default function Ecommerce(this: IECommerce, mpInstance: IMParticleWebSDKInstance): void;
@@ -1,14 +1,13 @@
1
- import { ProductAction, Product, Promotion, CommerceEvent } from '@mparticle/event-models';
2
1
  import { SDKEventAttrs, SDKEventOptions, TransactionAttributes } from '@mparticle/web-sdk';
3
2
  import { valueof } from './utils';
4
3
  import { ProductActionType, PromotionActionType } from './types';
5
4
  import { SDKEvent, SDKEventCustomFlags, SDKImpression, SDKProduct, SDKProductAction, SDKPromotion } from './sdkRuntimeModels';
6
5
  interface IECommerceShared {
7
6
  createProduct(name: string, sku: string | number, price: string | number, quantity?: string | number, variant?: string, category?: string, brand?: string, position?: number, couponCode?: string, attributes?: SDKEventAttrs): SDKProduct | null;
8
- createImpression(name: string, product: Product): SDKImpression | null;
7
+ createImpression(name: string, product: SDKProduct): SDKImpression | null;
9
8
  createPromotion(id: string | number, creative?: string, name?: string, position?: number): SDKPromotion | null;
10
9
  createTransactionAttributes(id: string | number, affiliation?: string, couponCode?: string, revenue?: string | number, shipping?: string | number, tax?: number): TransactionAttributes | null;
11
- expandCommerceEvent(event: CommerceEvent): SDKEvent[] | null;
10
+ expandCommerceEvent(event: SDKEvent): SDKEvent[] | null;
12
11
  }
13
12
  export interface SDKCart {
14
13
  add(product: SDKProduct | SDKProduct[], logEvent?: boolean): void;
@@ -19,7 +18,7 @@ export interface SDKECommerceAPI extends IECommerceShared {
19
18
  logCheckout(step: number, option?: string, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags): void;
20
19
  logImpression(impression: SDKImpression | SDKImpression[], attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
21
20
  logProductAction(productActionType: valueof<typeof ProductActionType>, product: SDKProduct | SDKProduct[], attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, transactionAttributes?: TransactionAttributes, eventOptions?: SDKEventOptions): void;
22
- logPromotion(type: valueof<typeof PromotionActionType>, promotion: SDKPromotion, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
21
+ logPromotion(type: valueof<typeof PromotionActionType>, promotion: SDKPromotion | SDKPromotion[], attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
23
22
  setCurrencyCode(code: string): void;
24
23
  Cart: SDKCart;
25
24
  logPurchase(transactionAttributes: TransactionAttributes, product: SDKProduct | SDKProduct[], clearCart?: boolean, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags): void;
@@ -64,14 +63,14 @@ export interface IECommerce extends IECommerceShared {
64
63
  calculateProductActionTotalAmount(productAction: SDKProductAction): SDKProductAction;
65
64
  convertTransactionAttributesToProductAction(transactionAttributes: TransactionAttributes, productAction: SDKProductAction): void;
66
65
  createCommerceEventObject(customFlags: SDKEventCustomFlags, options?: SDKEventOptions): SDKEvent | null;
67
- expandProductAction(commerceEvent: CommerceEvent): SDKEvent[];
68
- expandProductImpression(commerceEvent: CommerceEvent): SDKEvent[];
69
- expandPromotionAction(commerceEvent: CommerceEvent): SDKEvent[];
70
- extractActionAttributes(attributes: ExtractedActionAttributes, productAction: ProductAction): void;
71
- extractProductAttributes(attributes: ExtractedProductAttributes, product: Product): void;
72
- extractPromotionAttributes(attributes: ExtractedPromotionAttributes, promotion: Promotion): void;
73
- extractTransactionId(attributes: ExtractedTransactionId, productAction: ProductAction): void;
74
- generateExpandedEcommerceName(eventName: string, plusOne: boolean): string;
66
+ expandProductAction(commerceEvent: SDKEvent): SDKEvent[];
67
+ expandProductImpression(commerceEvent: SDKEvent): SDKEvent[];
68
+ expandPromotionAction(commerceEvent: SDKEvent): SDKEvent[];
69
+ extractActionAttributes(attributes: ExtractedActionAttributes, productAction: SDKProductAction): void;
70
+ extractProductAttributes(attributes: ExtractedProductAttributes, product: SDKProduct): void;
71
+ extractPromotionAttributes(attributes: ExtractedPromotionAttributes, promotion: SDKPromotion): void;
72
+ extractTransactionId(attributes: ExtractedTransactionId, productAction: SDKProductAction): void;
73
+ generateExpandedEcommerceName(eventName: string, plusOne?: boolean): string;
75
74
  getProductActionEventName(productActionType: valueof<typeof ProductActionType>): string;
76
75
  getPromotionActionEventName(promotionActionType: valueof<typeof PromotionActionType>): string;
77
76
  sanitizeAmount(amount: string | number, category: string): number;
@@ -13,7 +13,7 @@ export interface IEvents {
13
13
  logOptOut(): void;
14
14
  logPageView(): void;
15
15
  logProductActionEvent(productActionType: valueof<typeof ProductActionType>, product: SDKProduct | SDKProduct[], attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, transactionAttributes?: TransactionAttributes, eventOptions?: SDKEventOptions): void;
16
- logPromotionEvent(promotionType: valueof<typeof PromotionActionType>, promotion: SDKPromotion, attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
16
+ logPromotionEvent(promotionType: valueof<typeof PromotionActionType>, promotion: SDKPromotion | SDKPromotion[], attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags, eventOptions?: SDKEventOptions): void;
17
17
  logPurchaseEvent(transactionAttributes: TransactionAttributes, product: SDKProduct | SDKProduct[], attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags): void;
18
18
  logRefundEvent(transactionAttributes: TransactionAttributes, product: SDKProduct | SDKProduct[], attrs?: SDKEventAttrs, customFlags?: SDKEventCustomFlags): void;
19
19
  startTracking(callback: Callback): void;
@@ -1,26 +1,4 @@
1
- export default function Forwarders(mpInstance: any, kitBlocker: any): void;
2
- export default class Forwarders {
3
- constructor(mpInstance: any, kitBlocker: any);
4
- forwarderStatsUploader: any;
5
- initForwarders: (userIdentities: any, forwardingStatsCallback: any) => void;
6
- isEnabledForUserAttributes: (filterObject: any, user: any) => boolean;
7
- isEnabledForUnknownUser: (excludeAnonymousUserBoolean: any, user: any) => boolean;
8
- applyToForwarders: (functionName: any, functionArgs: any) => void;
9
- sendEventToForwarders: (event: any) => void;
10
- handleForwarderUserAttributes: (functionNameKey: any, key: any, value: any) => void;
11
- setForwarderUserIdentities: (userIdentities: any) => void;
12
- setForwarderOnUserIdentified: (user: any) => void;
13
- setForwarderOnIdentityComplete: (user: any, identityMethod: any) => void;
14
- getForwarderStatsQueue: () => any;
15
- setForwarderStatsQueue: (queue: any) => void;
16
- processForwarders: (config: any, forwardingStatsCallback: any) => void;
17
- processUIEnabledKits: (config: any) => void;
18
- returnKitConstructors: () => {};
19
- configureUIEnabledKit: (configuration: any, kits: any) => void;
20
- processSideloadedKits: (mpConfig: any) => void;
21
- configureSideloadedKit: (kitConstructor: any) => void;
22
- returnConfiguredKit: (forwarder: any, config?: {}) => any;
23
- configurePixel: (settings: any) => void;
24
- processPixelConfigs: (config: any) => void;
25
- sendSingleForwardingStatsToServer: (forwardingStatsData: any) => Promise<void>;
26
- }
1
+ import { IMParticleWebSDKInstance } from './mp-instance';
2
+ import KitBlocker from './kitBlocking';
3
+ import { IForwarders } from './forwarders.interfaces';
4
+ export default function Forwarders(this: IForwarders, mpInstance: IMParticleWebSDKInstance, kitBlocker: KitBlocker): void;
@@ -1,9 +1,13 @@
1
- import { SDKEvent, SDKEventCustomFlags } from './sdkRuntimeModels';
1
+ import { SDKEvent, SDKEventCustomFlags, SDKInitConfig, SDKLoggerApi } from './sdkRuntimeModels';
2
2
  import { Dictionary } from './utils';
3
- import { IKitConfigs, IKitFilterSettings } from './configAPIClient';
4
- import { IdentityApiData, IdentityType } from '@mparticle/web-sdk';
3
+ import { IKitConfigs, IKitFilterSettings, IFilteringUserAttributeValue } from './configAPIClient';
4
+ import { IdentityApiData, IdentityType, UserIdentities } from '@mparticle/web-sdk';
5
5
  import { Batch } from '@mparticle/event-models';
6
+ import { IForwardingStatsData } from './apiClient';
7
+ import { AsyncUploader } from './uploaders';
8
+ import { IPixelConfiguration } from './cookieSyncManager';
6
9
  import { IMParticleUser, ISDKUserIdentity, UserAttributes } from './identity-user-interfaces';
10
+ import type { IFilteredMparticleUser } from './filteredMparticleUser';
7
11
  export type MPForwarder = Dictionary;
8
12
  export interface UnregisteredKit {
9
13
  constructor: () => void;
@@ -22,19 +26,22 @@ export interface KitRegistrationConfig {
22
26
  export interface ConfiguredKit extends Omit<IKitConfigs, 'isDebugString' | 'hasDebugString'> {
23
27
  common: Dictionary<unknown>;
24
28
  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;
29
+ init(settings: Dictionary<unknown>, service: forwardingStatsCallback, testMode: boolean, trackerId: string | null, userAttributes: UserAttributes, userIdentities: ISDKUserIdentity[], appVersion: string, appName: string, customFlags: SDKEventCustomFlags, clientId: string): string;
30
+ onIdentifyComplete(user: IFilteredMparticleUser, filteredIdentityRequest: IdentityApiData): string;
31
+ onLoginComplete(user: IFilteredMparticleUser, filteredIdentityRequest: IdentityApiData): string;
32
+ onLogoutComplete(user: IFilteredMparticleUser, filteredIdentityRequest: IdentityApiData): string;
33
+ onModifyComplete(user: IFilteredMparticleUser, filteredIdentityRequest: IdentityApiData): string;
34
+ onUserIdentified(user: IFilteredMparticleUser): string;
31
35
  process(event: SDKEvent): string;
32
36
  setOptOut(isOptingOut: boolean): string;
33
37
  removeUserAttribute(key: string): string;
34
38
  setUserAttribute(key: string, value: string): string;
35
- setUserIdentity(id: UserIdentityId, type: UserIdentityType): void;
39
+ setUserIdentity(id: UserIdentityId, type: UserIdentityType): string | void;
40
+ logOut?(evt: SDKEvent): void;
36
41
  isSandbox: boolean;
37
42
  hasSandbox: boolean;
43
+ initialized?: boolean;
44
+ logger?: SDKLoggerApi;
38
45
  }
39
46
  export interface KitInterface {
40
47
  id: number;
@@ -57,3 +64,27 @@ export type UserIdentityType = number;
57
64
  export type UserAttributeFilters = number[];
58
65
  export type UserIdentityFilters = typeof IdentityType[];
59
66
  export type forwardingStatsCallback = (forwarder: ConfiguredKit, event: SDKEvent) => void;
67
+ export interface IForwarders {
68
+ forwarderStatsUploader: AsyncUploader;
69
+ initForwarders(userIdentities: UserIdentities, forwardingStatsCallback: forwardingStatsCallback): void;
70
+ isEnabledForUserAttributes(filterObject: Partial<IFilteringUserAttributeValue>, user: IMParticleUser): boolean;
71
+ isEnabledForUnknownUser(excludeAnonymousUserBoolean: boolean, user: IMParticleUser): boolean;
72
+ applyToForwarders(functionName: string, functionArgs: unknown): void;
73
+ sendEventToForwarders(event: SDKEvent): void;
74
+ handleForwarderUserAttributes(functionNameKey: string, key: string, value: string): void;
75
+ setForwarderUserIdentities(userIdentities: UserIdentities): void;
76
+ setForwarderOnUserIdentified(user: IMParticleUser): void;
77
+ setForwarderOnIdentityComplete(user: IMParticleUser, identityMethod: string): void;
78
+ getForwarderStatsQueue(): IForwardingStatsData[];
79
+ setForwarderStatsQueue(queue: IForwardingStatsData[]): void;
80
+ processForwarders(config: SDKInitConfig, forwardingStatsCallback: forwardingStatsCallback): void;
81
+ processUIEnabledKits(config: SDKInitConfig): void;
82
+ returnKitConstructors(): Dictionary<RegisteredKit>;
83
+ configureUIEnabledKit(configuration: IKitConfigs, kits: Dictionary<RegisteredKit>): void;
84
+ processSideloadedKits(mpConfig: SDKInitConfig): void;
85
+ configureSideloadedKit(kitConstructor: RegisteredKit): void;
86
+ returnConfiguredKit(forwarder: RegisteredKit, config?: Partial<IKitConfigs>): ConfiguredKit;
87
+ configurePixel(settings: IPixelConfiguration): void;
88
+ processPixelConfigs(config: SDKInitConfig): void;
89
+ sendSingleForwardingStatsToServer(forwardingStatsData: IForwardingStatsData): Promise<void>;
90
+ }
@@ -1,14 +1,14 @@
1
1
  import { Dictionary, Environment } from './utils';
2
2
  import { BaseVault } from './vault';
3
- import { IdentityApiData, UserIdentities, IdentityCallback } from '@mparticle/web-sdk';
3
+ import { IdentityApiData, UserIdentities } from '@mparticle/web-sdk';
4
4
  import { IdentityAPIMethod } from './identity.interfaces';
5
- import { IIdentityResponse, IMParticleUser } from './identity-user-interfaces';
5
+ import { IdentityCallback, IIdentityResponse, IMParticleUser } from './identity-user-interfaces';
6
6
  import { IStore } from './store';
7
7
  import type { IMParticleWebSDKInstance } from './mp-instance';
8
8
  import { IIdentitySearchRequestBody, IdentitySearchCallback } from './identity/search';
9
9
  export declare const CACHE_HEADER: "x-mp-max-age";
10
10
  export type IdentityCache = BaseVault<Dictionary<ICachedIdentityCall>>;
11
- export type IParseCachedIdentityResponse = (cachedIdentity: IIdentityResponse, mpid: string, callback: IdentityCallback, identityApiData: IdentityApiData, identityMethod: string, knownIdentities: IKnownIdentities, fromCachedIdentity: boolean) => void;
11
+ export type IParseCachedIdentityResponse = (cachedIdentity: IIdentityResponse, mpid: string, callback: IdentityCallback, identityApiData: IdentityApiData, identityMethod: IdentityAPIMethod, knownIdentities: IKnownIdentities, fromCachedIdentity: boolean) => void;
12
12
  export interface IKnownIdentities extends UserIdentities {
13
13
  device_application_stamp?: string;
14
14
  }
@@ -0,0 +1,3 @@
1
+ import { IIdentity } from './identity.interfaces';
2
+ import { IMParticleWebSDKInstance } from './mp-instance';
3
+ export default function Identity(this: IIdentity, mpInstance: IMParticleWebSDKInstance): void;
@@ -6,7 +6,7 @@ import { Dictionary, Environment, valueof } from './utils';
6
6
  import Constants from './constants';
7
7
  import { IdentityCallback, IUserAttributeChangeEvent, IUserIdentityChangeEvent, IMParticleUser, mParticleUserCart, IIdentityResponse } from './identity-user-interfaces';
8
8
  import { IdentitySearchCallback } from './identity/search';
9
- declare const platform: "web", sdkVendor: "mparticle", sdkVersion: string, HTTPCodes: {
9
+ declare const HTTPCodes: {
10
10
  readonly noHttpCoverage: -1;
11
11
  readonly activeIdentityRequest: -2;
12
12
  readonly activeSession: -3;
@@ -18,6 +18,7 @@ declare const platform: "web", sdkVendor: "mparticle", sdkVersion: string, HTTPC
18
18
  export type IdentityPreProcessResult = {
19
19
  valid: boolean;
20
20
  error?: string;
21
+ cleanedIdentities?: IdentityApiData;
21
22
  };
22
23
  export type IdentityAPIMethod = valueof<typeof Constants.IdentityMethods>;
23
24
  export declare enum SDKIdentityTypeEnum {
@@ -46,14 +47,14 @@ export declare enum SDKIdentityTypeEnum {
46
47
  }
47
48
  export interface IIdentityAPIRequestData {
48
49
  client_sdk: {
49
- platform: typeof platform;
50
- sdk_vendor: typeof sdkVendor;
51
- sdk_version: typeof sdkVersion;
50
+ platform: string;
51
+ sdk_vendor: string;
52
+ sdk_version: string;
52
53
  };
53
54
  context: string | null;
54
55
  environment: Environment;
55
56
  request_id: string;
56
- request_timestamp_unixtime_ms: number;
57
+ request_timestamp_ms: number;
57
58
  previous_mpid: MPID | null;
58
59
  known_identities: IKnownIdentities;
59
60
  }
@@ -69,9 +70,13 @@ export interface IIdentityRequest {
69
70
  combineUserIdentities(previousUIByName: UserIdentities, newUIByName: UserIdentities): UserIdentities;
70
71
  createIdentityRequest(identityApiData: IdentityApiData, platform: string, sdkVendor: string, sdkVersion: string, deviceId: string, context: string | null, mpid: MPID): IIdentityAPIRequestData;
71
72
  createModifyIdentityRequest(currentUserIdentities: UserIdentities, newUserIdentities: UserIdentities, platform: string, sdkVendor: string, sdkVersion: string, context: string | null): IIdentityAPIModifyRequestData;
72
- createIdentityChanges(previousIdentities: UserIdentities, newIdentitie: UserIdentities): IIdentityAPIIdentityChangeData;
73
+ createIdentityChanges(previousIdentities: UserIdentities, newIdentities: UserIdentities): IIdentityAPIIdentityChangeData[];
73
74
  preProcessIdentityRequest(identityApiData: IdentityApiData, callback: IdentityCallback, method: IdentityAPIMethod): IdentityPreProcessResult;
75
+ createAliasNetworkRequest(aliasRequest: IAliasRequest): IAliasNetworkRequest;
76
+ convertAliasToNative(aliasRequest: IAliasRequest): IAliasNativeRequest;
77
+ convertToNative(identityApiData: IdentityApiData): IIdentityNativeRequest | undefined;
74
78
  }
79
+ export type UserAttributeChangeValue = string | string[] | null;
75
80
  export type AliasRequestScope = 'device' | 'mpid';
76
81
  export interface IAliasRequest {
77
82
  destinationMpid: MPID;
@@ -80,6 +85,33 @@ export interface IAliasRequest {
80
85
  endTime: number;
81
86
  scope?: AliasRequestScope;
82
87
  }
88
+ export interface IAliasNetworkRequest {
89
+ request_id: string;
90
+ request_type: 'alias';
91
+ environment: Environment;
92
+ api_key: string;
93
+ data: {
94
+ destination_mpid: MPID;
95
+ source_mpid: MPID;
96
+ start_unixtime_ms: number;
97
+ end_unixtime_ms: number;
98
+ scope?: AliasRequestScope;
99
+ device_application_stamp: string;
100
+ };
101
+ }
102
+ export interface IAliasNativeRequest {
103
+ DestinationMpid: MPID;
104
+ SourceMpid: MPID;
105
+ StartUnixtimeMs: number;
106
+ EndUnixtimeMs: number;
107
+ Scope?: AliasRequestScope;
108
+ }
109
+ export interface IIdentityNativeRequest {
110
+ UserIdentities: Array<{
111
+ Type: number;
112
+ Identity: string;
113
+ }>;
114
+ }
83
115
  export interface IAliasCallback {
84
116
  (result: IAliasResult): void;
85
117
  }
@@ -96,7 +128,7 @@ export interface SDKIdentityApi {
96
128
  getCurrentUser?(): IMParticleUser;
97
129
  getUser?(mpid: string): IMParticleUser;
98
130
  getUsers?(): IMParticleUser[];
99
- aliasUsers?(aliasRequest?: IAliasRequest, callback?: IdentityCallback): void;
131
+ aliasUsers?(aliasRequest?: IAliasRequest, callback?: IAliasCallback): void;
100
132
  createAliasRequest?(sourceUser: IMParticleUser, destinationUser: IMParticleUser, scope?: AliasRequestScope): IAliasRequest;
101
133
  /**
102
134
  * Sends a request to mParticle's IDSync `/v1/search` endpoint to look up
@@ -140,12 +172,14 @@ export interface IIdentity {
140
172
  idCache: BaseVault<Dictionary<ICachedIdentityCall>>;
141
173
  IdentityAPI: SDKIdentityApi;
142
174
  IdentityRequest: IIdentityRequest;
143
- mParticleUser(mpid: MPID, IsLoggedIn: boolean): IMParticleUser;
144
- createUserAttributeChange(key: string, newValue: string, previousUserAttributeValue: string, isNewAttribute: boolean, deleted: boolean, user: IMParticleUser): IUserAttributeChangeEvent;
175
+ mParticleUser(mpid?: MPID, IsLoggedIn?: boolean): IMParticleUser;
176
+ createUserAttributeChange(key: string, newValue: UserAttributeChangeValue, previousUserAttributeValue: UserAttributeChangeValue, isNewAttribute: boolean, deleted: boolean, user: IMParticleUser): IUserAttributeChangeEvent;
145
177
  createUserIdentityChange(identityType: SDKIdentityTypeEnum, newIdentity: string, oldIdentity: string, newCreatedThisBatch: boolean, userInMemory: IMParticleUser): IUserIdentityChangeEvent;
146
- parseIdentityResponse(identityResponse: IIdentityResponse, previousMPID: MPID, callback: IdentityCallback, identityApiData: IdentityApiData, method: IdentityAPIMethod, knownIdentities: UserIdentities, parsingCachedResponse: boolean): void;
147
- sendUserAttributeChangeEvent(attributeKey: string, newUserAttributeValue: string, previousUserAttributeValue: string, isNewAttribute: boolean, deleted: boolean, user: IMParticleUser): void;
178
+ parseIdentityResponse(identityResponse: IIdentityResponse, previousMPID: MPID, callback: IdentityCallback, identityApiData: IdentityApiData, method: IdentityAPIMethod, knownIdentities: IKnownIdentities, parsingCachedResponse: boolean): void;
179
+ sendUserAttributeChangeEvent(attributeKey: string, newUserAttributeValue: UserAttributeChangeValue, previousUserAttributeValue: UserAttributeChangeValue, isNewAttribute: boolean, deleted: boolean, user: IMParticleUser): void;
148
180
  sendUserIdentityChangeEvent(newUserIdentities: UserIdentities, method: IdentityAPIMethod, mpid: MPID, prevUserIdentities: UserIdentities): void;
181
+ reinitForwardersOnUserChange(prevUser: IMParticleUser, newUser: IMParticleUser): void;
182
+ setForwarderCallbacks(user: IMParticleUser, method: IdentityAPIMethod): void;
149
183
  /**
150
184
  * @deprecated
151
185
  */
@@ -1,10 +1,11 @@
1
- import { IAliasCallback, IAliasRequest, IdentityAPIMethod, IIdentity, IIdentityAPIRequestData } from './identity.interfaces';
2
- import { IdentityApiData, MPID, UserIdentities } from '@mparticle/web-sdk';
1
+ import { IKnownIdentities } from './identity-utils';
2
+ import { IAliasCallback, IAliasNetworkRequest, IdentityAPIMethod, IIdentity, IIdentityAPIRequestData, IIdentityAPIModifyRequestData } from './identity.interfaces';
3
+ import { IdentityApiData, MPID } from '@mparticle/web-sdk';
3
4
  import { IdentityCallback, IdentityResultBody, IIdentityResponse } from './identity-user-interfaces';
4
5
  import { IMParticleWebSDKInstance } from './mp-instance';
5
6
  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>;
7
+ sendAliasRequest: (aliasRequest: IAliasNetworkRequest, aliasCallback: IAliasCallback) => Promise<void>;
8
+ sendIdentityRequest: (identityApiRequest: IIdentityAPIRequestData | IIdentityAPIModifyRequestData, method: IdentityAPIMethod, callback: IdentityCallback, originalIdentityApiData: IdentityApiData, parseIdentityResponse: IIdentity['parseIdentityResponse'], mpid: MPID, knownIdentities?: IKnownIdentities) => Promise<void>;
8
9
  getUploadUrl: (method: IdentityAPIMethod, mpid: MPID) => string;
9
10
  getIdentityResponseFromFetch: (response: Response, responseBody: IdentityResultBody) => IIdentityResponse;
10
11
  getIdentityResponseFromXHR: (response: XMLHttpRequest) => IIdentityResponse;
@@ -5,7 +5,7 @@ import { IStore } from './store';
5
5
  import { IServerModel } from './serverModel';
6
6
  import { IForwardingStatsUploader } from './forwardingStatsUploader';
7
7
  import { IConsent } from './consent';
8
- import IdentityAPIClient from './identityApiClient';
8
+ import { IIdentityApiClient } from './identityApiClient';
9
9
  import IntegrationCapture from './integrationCapture';
10
10
  import { IPreInit } from './pre-init-utils';
11
11
  import { MParticleWebSDK, SDKHelpersApi } from './sdkRuntimeModels';
@@ -42,7 +42,7 @@ export interface IMParticleWebSDKInstance extends MParticleWebSDK {
42
42
  _ForwardingStatsUploader: IForwardingStatsUploader;
43
43
  _Helpers: SDKHelpersApi;
44
44
  _Identity: IIdentity;
45
- _IdentityAPIClient: typeof IdentityAPIClient;
45
+ _IdentityAPIClient: IIdentityApiClient;
46
46
  _IntegrationCapture: IntegrationCapture;
47
47
  _NativeSdkHelpers: INativeSdkHelpers;
48
48
  _PageViewTracker?: PageViewTracker;
@@ -1,16 +1,23 @@
1
1
  import { IMParticleWebSDKInstance } from './mp-instance';
2
2
  import { BaseEvent } from './sdkRuntimeModels';
3
+ import { Dictionary } from './utils';
3
4
  type HistoryMethodName = 'pushState' | 'replaceState';
4
5
  type NavigationSource = HistoryMethodName | 'popstate';
5
6
  export declare const WIN_APV_KEY = "__mpApv__";
6
- interface IPageViewData {
7
+ export declare const ALLOWED_QUERY_PARAMS: string[];
8
+ interface IPageSnapshot {
9
+ path: string;
10
+ params: Dictionary<string>;
11
+ }
12
+ interface IPageViewData extends IPageSnapshot {
7
13
  hostname: string;
8
14
  title: string;
9
- path: string;
10
15
  }
11
- export declare const isNewPage: (lastPath: string | null, candidatePath: string) => boolean;
16
+ export declare const allowedQueryParams: (href: string) => Dictionary<string>;
17
+ export declare const pageKey: (page: IPageSnapshot) => string;
18
+ export declare const isNewPage: (lastKey: string | null, candidateKey: string) => boolean;
12
19
  export declare const supportsHistoryTracking: (win: Window | null) => boolean;
13
- export declare const buildPageViewEvent: (data: IPageViewData) => BaseEvent;
20
+ export declare const buildPageViewEvent: ({ params, hostname, title, path, }: IPageViewData) => BaseEvent;
14
21
  export declare const getActiveTracker: () => PageViewTracker | undefined;
15
22
  export declare const hasInitialPageViewFired: () => boolean;
16
23
  export declare const markInitialPageViewFired: () => void;
@@ -18,7 +25,7 @@ export declare const resetPageViewTracking: () => void;
18
25
  export declare const patchHistory: (onNavigate: (source: NavigationSource) => void, log: (message: string) => void) => (() => void) | null;
19
26
  export declare class PageViewTracker {
20
27
  private readonly mpInstance;
21
- private lastPath;
28
+ private lastPage;
22
29
  private active;
23
30
  private pendingNavigations;
24
31
  private undoHistoryPatch;
@@ -1,44 +1,3 @@
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
- }
1
+ import { IMParticleWebSDKInstance } from './mp-instance';
2
+ import { IPersistence } from './persistence.interfaces';
3
+ export default function _Persistence(this: IPersistence, mpInstance: IMParticleWebSDKInstance): void;
@@ -1,4 +1,3 @@
1
- import { Context } from '@mparticle/event-models';
2
1
  import { IdentityApiData, MPID, Product, UserIdentities } from '@mparticle/web-sdk';
3
2
  import { IForwardingStatsData } from './apiClient';
4
3
  import { IntegrationAttributes, ServerSettings, SessionAttributes, LocalSessionAttributes } from './store';
@@ -22,7 +21,7 @@ export interface IGlobalStoreV2MinifiedKeys {
22
21
  cgid: string;
23
22
  das: string;
24
23
  ia: IntegrationAttributes;
25
- c: Context;
24
+ c: string | null;
26
25
  csm: MPID[];
27
26
  les: number;
28
27
  ssd: number;
@@ -30,7 +29,7 @@ export interface IGlobalStoreV2MinifiedKeys {
30
29
  export interface IPersistenceMinified extends Dictionary {
31
30
  cu: MPID;
32
31
  gs: IGlobalStoreV2MinifiedKeys;
33
- l: boolean;
32
+ l: boolean | 0 | 1;
34
33
  }
35
34
  export interface IUserPersistenceMinified extends Dictionary {
36
35
  csd: CookieSyncDates;
@@ -45,8 +44,8 @@ export interface IPersistence {
45
44
  useLocalStorage(): boolean;
46
45
  initializeStorage(): void;
47
46
  update(): void;
48
- storeDataInMemory(obj: IPersistenceMinified, currentMPID: MPID): void;
49
- determineLocalStorageAvailability(storage: Storage): boolean;
47
+ storeDataInMemory(obj: IPersistenceMinified, currentMPID?: MPID): void;
48
+ determineLocalStorageAvailability(storage?: Storage): boolean;
50
49
  setLocalStorage(): void;
51
50
  getLocalStorage(): IPersistenceMinified | null;
52
51
  expireCookies(cookieName: string): void;
@@ -54,17 +53,17 @@ export interface IPersistence {
54
53
  setCookie(): void;
55
54
  reduceAndEncodePersistence(persistence: IPersistenceMinified, expires: string, domain: string, maxCookieSize: number): string;
56
55
  findPrevCookiesBasedOnUI(identityApiData: IdentityApiData): void;
57
- encodePersistence(persistence: IPersistenceMinified): string;
58
- decodePersistence(persistenceString: string): string;
56
+ encodePersistence(persistence: string): string;
57
+ decodePersistence(persistenceString: string | null): string | void;
59
58
  getCookieDomain(): string;
60
- getDomain(doc: string, locationHostname: string): string;
59
+ getDomain(doc: Document, locationHostname: string): string;
61
60
  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;
61
+ savePersistence(persistence: IPersistenceMinified): void;
62
+ getPersistence(): IPersistenceMinified | null;
63
+ getFirstSeenTime(mpid: MPID): number | null;
64
+ setFirstSeenTime(mpid: MPID, time?: number): void;
66
65
  getLastSeenTime(mpid: MPID): number | null;
67
- setLastSeenTime(mpid: MPID, time: number): void;
66
+ setLastSeenTime(mpid: MPID, time?: number): void;
68
67
  getDeviceId(): string;
69
68
  setDeviceId(guid: string): void;
70
69
  resetPersistence(): void;
@@ -1,6 +1,6 @@
1
1
  import * as EventsApi from '@mparticle/event-models';
2
2
  import { DataPlanVersion } from '@mparticle/data-planning-models';
3
- import { MPConfiguration, MPID, SDKEventOptions, SDKEventAttrs, Callback } from '@mparticle/web-sdk';
3
+ import { MPConfiguration, MPID, SDKEventOptions, SDKEventAttrs, Callback, UserIdentities } from '@mparticle/web-sdk';
4
4
  import { IntegrationAttribute, IntegrationAttributes, IStore, WrapperSDKTypes } from './store';
5
5
  import Validators from './validators';
6
6
  import { Dictionary, valueof } from './utils';
@@ -197,6 +197,7 @@ export interface IMParticleInstanceManager extends MParticleWebSDK {
197
197
  _BatchValidator: _BatchValidator;
198
198
  _instances: Dictionary<IMParticleWebSDKInstance>;
199
199
  _isTestEnv?: boolean;
200
+ _forceNoLocalStorage?: boolean;
200
201
  config: SDKInitConfig;
201
202
  isIOS?: boolean;
202
203
  MPSideloadedKit: typeof MPSideloadedKit;
@@ -271,7 +272,7 @@ export interface SDKHelpersApi {
271
272
  converted?(s: string): string;
272
273
  filterUserIdentitiesForForwarders(userIdentities: Dictionary, filterList: number[]): Dictionary;
273
274
  filterUserAttributes(userAttributes: Dictionary, filterList: number[]): Dictionary;
274
- filterUserIdentities?(userIdentitiesObject: Dictionary<string>, filterList: number[]): ISDKUserIdentity[];
275
+ filterUserIdentities?(userIdentitiesObject: UserIdentities | Dictionary<string>, filterList: number[]): ISDKUserIdentity[];
275
276
  invokeAliasCallback(aliasCallback: IAliasCallback, number: number, errorMessage?: string): void;
276
277
  isDelayedByIntegration?(delayedIntegrations: Dictionary<boolean>, timeoutStart: number, now: number): boolean;
277
278
  isEventType?(type: valueof<typeof EventType>): boolean;
@@ -1,4 +1,4 @@
1
- import { Batch, Context } from '@mparticle/event-models';
1
+ import { Batch } from '@mparticle/event-models';
2
2
  import { MPID, IdentifyRequest, SDKEventCustomFlags, ConsentState, UserIdentities } from '@mparticle/web-sdk';
3
3
  import { IKitConfigs } from './configAPIClient';
4
4
  import { DataPlanResult, KitBlockerOptions, LogLevelType, SDKDataPlan, SDKEvent, SDKGeoLocation, SDKInitConfig, SDKProduct } from './sdkRuntimeModels';
@@ -29,6 +29,7 @@ export interface SDKConfig {
29
29
  kits: Dictionary<UnregisteredKit>;
30
30
  logLevel?: LogLevelType;
31
31
  cookieDomain?: string;
32
+ cookieExpiration?: number;
32
33
  maxCookieSize?: number | undefined;
33
34
  minWebviewBridgeVersion: 1 | 2 | undefined;
34
35
  identifyRequest: IdentifyRequest;
@@ -83,6 +84,7 @@ export interface IFeatureFlags {
83
84
  export interface IStore {
84
85
  isEnabled: boolean;
85
86
  isInitialized: boolean;
87
+ mpid: MPID;
86
88
  sessionAttributes: SessionAttributes;
87
89
  localSessionAttributes: LocalSessionAttributes;
88
90
  currentSessionMPIDs: MPID[];
@@ -102,7 +104,7 @@ export interface IStore {
102
104
  eventQueue: SDKEvent[];
103
105
  currencyCode: string | null;
104
106
  globalTimer: number | null;
105
- context: Context | null;
107
+ context: string | null;
106
108
  configurationLoaded: boolean;
107
109
  identityCallInFlight: boolean;
108
110
  identityCallFailed: boolean;
@@ -120,7 +122,7 @@ export interface IStore {
120
122
  activeForwarders: ConfiguredKit[];
121
123
  kits: Dictionary<MPForwarder>;
122
124
  sideloadedKits: MPForwarder[];
123
- configuredForwarders: MPForwarder[];
125
+ configuredForwarders: ConfiguredKit[];
124
126
  pixelConfigurations: IPixelConfiguration[];
125
127
  integrationDelayTimeoutStart: number;
126
128
  webviewBridgeEnabled?: boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-sdk",
3
- "version": "2.79.3",
3
+ "version": "2.80.1",
4
4
  "description": "mParticle core SDK for web applications",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -20,6 +20,7 @@ export interface IKitConfigs extends IKitFilterSettings {
20
20
  suffix?: string;
21
21
  moduleId: number;
22
22
  isDebug: boolean;
23
+ isSandbox?: boolean;
23
24
  isVisible: boolean;
24
25
  isDebugString: BooleanStringLowerCase;
25
26
  hasDebugString: BooleanStringLowerCase;