@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,182 @@
1
+ export default mParticle;
2
+ declare namespace mParticle {
3
+ export { voidFunction as endSession };
4
+ export { returnString as getAppName };
5
+ export { returnString as getAppVersion };
6
+ export { returnString as getDeviceId };
7
+ export { returnString as getEnvironment };
8
+ export { returnString as getVersion };
9
+ export { voidFunction as init };
10
+ export { voidFunction as logError };
11
+ export { voidFunction as logEvent };
12
+ export { voidFunction as logForm };
13
+ export { voidFunction as logLink };
14
+ export { voidFunction as logPageView };
15
+ export { voidFunction as ready };
16
+ export { voidFunction as reset };
17
+ export { voidFunction as _resetForTests };
18
+ export { voidFunction as setAppName };
19
+ export { voidFunction as setAppVersion };
20
+ export { voidFunction as setLogLevel };
21
+ export { voidFunction as setOptOut };
22
+ export { voidFunction as setPosition };
23
+ export { voidFunction as setSessionAttribute };
24
+ export { voidFunction as startNewSession };
25
+ export { voidFunction as startTrackingLocation };
26
+ export { voidFunction as stopTrackingLocation };
27
+ export let CommerceEventType: {};
28
+ export let EventType: {};
29
+ export let IdentityType: {};
30
+ export let ProductActionType: {};
31
+ export let PromotionType: {};
32
+ export namespace eCommerce {
33
+ export { returnImpression as createImpression };
34
+ export { returnProduct as createProduct };
35
+ export { returnPromotion as createPromotion };
36
+ export { returnTransactionAttributes as createTransactionAttributes };
37
+ export { voidFunction as logCheckout };
38
+ export { voidFunction as logImpression };
39
+ export { voidFunction as logProductAction };
40
+ export { voidFunction as logPromotion };
41
+ export { voidFunction as logPurchase };
42
+ export { voidFunction as logRefund };
43
+ export { voidFunction as setCurrencyCode };
44
+ export let Cart: any;
45
+ }
46
+ export namespace Consent {
47
+ export { createConsentState };
48
+ export { returnGDPRConsent as createGDPRConsent };
49
+ }
50
+ export namespace Identity {
51
+ export { voidFunction as aliasUsers };
52
+ export { createAliasRequest };
53
+ export { returnUser as getCurrentUser };
54
+ export { returnUser as getUser };
55
+ export { returnUsers as getUsers };
56
+ export { voidFunction as identify };
57
+ export { voidFunction as login };
58
+ export { voidFunction as logout };
59
+ export { voidFunction as modify };
60
+ }
61
+ }
62
+ declare function voidFunction(): void;
63
+ declare function returnString(): string;
64
+ declare function returnImpression(): {
65
+ Name: string;
66
+ Product: {
67
+ Name: string;
68
+ Sku: string;
69
+ Price: number;
70
+ Quantity: number;
71
+ Brand: string;
72
+ Variant: string;
73
+ Category: string;
74
+ Position: string;
75
+ CouponCode: string;
76
+ TotalAmount: number;
77
+ Attributes: {};
78
+ };
79
+ };
80
+ declare function returnProduct(): {
81
+ Name: string;
82
+ Sku: string;
83
+ Price: number;
84
+ Quantity: number;
85
+ Brand: string;
86
+ Variant: string;
87
+ Category: string;
88
+ Position: string;
89
+ CouponCode: string;
90
+ TotalAmount: number;
91
+ Attributes: {};
92
+ };
93
+ declare function returnPromotion(): {
94
+ Id: string;
95
+ Creative: string;
96
+ Name: string;
97
+ Position: number;
98
+ };
99
+ declare function returnTransactionAttributes(): {
100
+ Id: string;
101
+ Affiliation: string;
102
+ CouponCode: string;
103
+ Revenue: number;
104
+ Shipping: string;
105
+ Tax: number;
106
+ };
107
+ declare function createConsentState(): {
108
+ addGDPRConsentState: typeof returnThis;
109
+ setGDPRConsentState: typeof returnThis;
110
+ getGDPRConsentState: typeof returnGDPRConsent;
111
+ removeGDPRConsentState: typeof returnThis;
112
+ };
113
+ declare function returnGDPRConsent(): {
114
+ ConsentDocument: string;
115
+ Consented: boolean;
116
+ HardwareId: string;
117
+ Location: string;
118
+ Timestamp: number;
119
+ };
120
+ declare function createAliasRequest(): {
121
+ sourceMpid: string;
122
+ destinationMpid: string;
123
+ startTime: number;
124
+ endTime: number;
125
+ scope: string;
126
+ };
127
+ declare function returnUser(): {
128
+ getUserIdentities: () => {
129
+ userIdentities: {};
130
+ };
131
+ getMPID: typeof returnString;
132
+ setUserTag: typeof voidFunction;
133
+ removeUserTag: typeof voidFunction;
134
+ setUserAttribute: typeof voidFunction;
135
+ setUserAttributes: typeof voidFunction;
136
+ removeUserAttribute: typeof voidFunction;
137
+ setUserAttributeList: typeof voidFunction;
138
+ removeAllUserAttributes: typeof voidFunction;
139
+ getUserAttributesLists: typeof returnObject;
140
+ getAllUserAttributes: typeof returnObject;
141
+ getCart: typeof Cart;
142
+ getConsentState: typeof createConsentState;
143
+ setConsentState: typeof voidFunction;
144
+ };
145
+ declare function returnUsers(): {
146
+ getUserIdentities: () => {
147
+ userIdentities: {};
148
+ };
149
+ getMPID: typeof returnString;
150
+ setUserTag: typeof voidFunction;
151
+ removeUserTag: typeof voidFunction;
152
+ setUserAttribute: typeof voidFunction;
153
+ setUserAttributes: typeof voidFunction;
154
+ removeUserAttribute: typeof voidFunction;
155
+ setUserAttributeList: typeof voidFunction;
156
+ removeAllUserAttributes: typeof voidFunction;
157
+ getUserAttributesLists: typeof returnObject;
158
+ getAllUserAttributes: typeof returnObject;
159
+ getCart: typeof Cart;
160
+ getConsentState: typeof createConsentState;
161
+ setConsentState: typeof voidFunction;
162
+ }[];
163
+ declare function returnThis(): any;
164
+ declare function returnObject(): {};
165
+ declare function Cart_1(): {
166
+ add: typeof voidFunction;
167
+ clear: typeof voidFunction;
168
+ remove: typeof voidFunction;
169
+ getCartProducts: () => {
170
+ Name: string;
171
+ Sku: string;
172
+ Price: number;
173
+ Quantity: number;
174
+ Brand: string;
175
+ Variant: string;
176
+ Category: string;
177
+ Position: string;
178
+ CouponCode: string;
179
+ TotalAmount: number;
180
+ Attributes: {};
181
+ }[];
182
+ };
@@ -0,0 +1,154 @@
1
+ export declare const MessageType: {
2
+ SessionStart: 1;
3
+ SessionEnd: 2;
4
+ PageView: 3;
5
+ PageEvent: 4;
6
+ CrashReport: 5;
7
+ OptOut: 6;
8
+ AppStateTransition: 10;
9
+ Profile: 14;
10
+ Commerce: 16;
11
+ Media: 20;
12
+ UserAttributeChange: 17;
13
+ UserIdentityChange: 18;
14
+ };
15
+ export declare const EventType: {
16
+ Unknown: 0;
17
+ Navigation: 1;
18
+ Location: 2;
19
+ Search: 3;
20
+ Transaction: 4;
21
+ UserContent: 5;
22
+ UserPreference: 6;
23
+ Social: 7;
24
+ Other: 8;
25
+ Media: 9;
26
+ getName(id: number): string;
27
+ };
28
+ export declare const CommerceEventType: {
29
+ ProductAddToCart: 10;
30
+ ProductRemoveFromCart: 11;
31
+ ProductCheckout: 12;
32
+ ProductCheckoutOption: 13;
33
+ ProductClick: 14;
34
+ ProductViewDetail: 15;
35
+ ProductPurchase: 16;
36
+ ProductRefund: 17;
37
+ PromotionView: 18;
38
+ PromotionClick: 19;
39
+ ProductAddToWishlist: 20;
40
+ ProductRemoveFromWishlist: 21;
41
+ ProductImpression: 22;
42
+ };
43
+ export declare const IdentityType: any;
44
+ export declare const ProductActionType: {
45
+ Unknown: 0;
46
+ AddToCart: 1;
47
+ RemoveFromCart: 2;
48
+ Checkout: 3;
49
+ CheckoutOption: 4;
50
+ Click: 5;
51
+ ViewDetail: 6;
52
+ Purchase: 7;
53
+ Refund: 8;
54
+ AddToWishlist: 9;
55
+ RemoveFromWishlist: 10;
56
+ getName: (id: number) => string;
57
+ getExpansionName: (id: number) => "add_to_cart" | "remove_from_cart" | "checkout" | "checkout_option" | "click" | "view_detail" | "purchase" | "refund" | "add_to_wishlist" | "remove_from_wishlist" | "unknown";
58
+ };
59
+ export declare const PromotionActionType: {
60
+ Unknown: 0;
61
+ PromotionView: 1;
62
+ PromotionClick: 2;
63
+ getName: (id: number) => string;
64
+ getExpansionName: (id: number) => string;
65
+ };
66
+ export declare const ProfileMessageType: {
67
+ Logout: 3;
68
+ };
69
+ export declare const ApplicationTransitionType: {
70
+ AppInit: 1;
71
+ };
72
+ export declare const PerformanceMarkType: {
73
+ SdkStart: "mp:sdkStart";
74
+ JointSdkSelectPlacements: "mp:jointSdkSelectPlacements";
75
+ JointSdkRoktKitInit: "mp:jointSdkRoktKitInit";
76
+ };
77
+ declare const _default: {
78
+ readonly MessageType: {
79
+ SessionStart: 1;
80
+ SessionEnd: 2;
81
+ PageView: 3;
82
+ PageEvent: 4;
83
+ CrashReport: 5;
84
+ OptOut: 6;
85
+ AppStateTransition: 10;
86
+ Profile: 14;
87
+ Commerce: 16;
88
+ Media: 20;
89
+ UserAttributeChange: 17;
90
+ UserIdentityChange: 18;
91
+ };
92
+ readonly EventType: {
93
+ Unknown: 0;
94
+ Navigation: 1;
95
+ Location: 2;
96
+ Search: 3;
97
+ Transaction: 4;
98
+ UserContent: 5;
99
+ UserPreference: 6;
100
+ Social: 7;
101
+ Other: 8;
102
+ Media: 9;
103
+ getName(id: number): string;
104
+ };
105
+ readonly CommerceEventType: {
106
+ ProductAddToCart: 10;
107
+ ProductRemoveFromCart: 11;
108
+ ProductCheckout: 12;
109
+ ProductCheckoutOption: 13;
110
+ ProductClick: 14;
111
+ ProductViewDetail: 15;
112
+ ProductPurchase: 16;
113
+ ProductRefund: 17;
114
+ PromotionView: 18;
115
+ PromotionClick: 19;
116
+ ProductAddToWishlist: 20;
117
+ ProductRemoveFromWishlist: 21;
118
+ ProductImpression: 22;
119
+ };
120
+ readonly IdentityType: any;
121
+ readonly ProfileMessageType: {
122
+ Logout: 3;
123
+ };
124
+ readonly ApplicationTransitionType: {
125
+ AppInit: 1;
126
+ };
127
+ readonly ProductActionType: {
128
+ Unknown: 0;
129
+ AddToCart: 1;
130
+ RemoveFromCart: 2;
131
+ Checkout: 3;
132
+ CheckoutOption: 4;
133
+ Click: 5;
134
+ ViewDetail: 6;
135
+ Purchase: 7;
136
+ Refund: 8;
137
+ AddToWishlist: 9;
138
+ RemoveFromWishlist: 10;
139
+ getName: (id: number) => string;
140
+ getExpansionName: (id: number) => "add_to_cart" | "remove_from_cart" | "checkout" | "checkout_option" | "click" | "view_detail" | "purchase" | "refund" | "add_to_wishlist" | "remove_from_wishlist" | "unknown";
141
+ };
142
+ readonly PromotionActionType: {
143
+ Unknown: 0;
144
+ PromotionView: 1;
145
+ PromotionClick: 2;
146
+ getName: (id: number) => string;
147
+ getExpansionName: (id: number) => string;
148
+ };
149
+ readonly Environment: {
150
+ readonly Development: "development";
151
+ readonly Production: "production";
152
+ };
153
+ };
154
+ export default _default;
@@ -0,0 +1,21 @@
1
+ export interface IFetchPayload {
2
+ method: string;
3
+ headers: {
4
+ Accept: string;
5
+ 'Content-Type'?: string;
6
+ 'rokt-account-id'?: string;
7
+ };
8
+ body?: string;
9
+ }
10
+ export declare abstract class AsyncUploader {
11
+ url: string;
12
+ abstract upload(fetchPayload: IFetchPayload, url?: string): Promise<Response>;
13
+ constructor(url: string);
14
+ }
15
+ export declare class FetchUploader extends AsyncUploader {
16
+ upload(fetchPayload: IFetchPayload, _url?: string): Promise<Response>;
17
+ }
18
+ export declare class XHRUploader extends AsyncUploader {
19
+ upload(fetchPayload: IFetchPayload): Promise<Response>;
20
+ private makeRequest;
21
+ }
@@ -0,0 +1,5 @@
1
+ import { IMParticleUser, IdentityResultBody } from './identity-user-interfaces';
2
+ import { SDKEvent } from './sdkRuntimeModels';
3
+ export declare function hasMPIDAndUserLoginChanged(previousUser: IMParticleUser, newUser: IMParticleUser): boolean;
4
+ export declare function hasMPIDChanged(prevUser: IMParticleUser, identityApiResult: IdentityResultBody): boolean;
5
+ export declare function appendUserInfo(user: IMParticleUser, event: SDKEvent): void;
@@ -0,0 +1,82 @@
1
+ import { MPID } from '@mparticle/web-sdk';
2
+ import Constants from './constants';
3
+ import { SDKInitConfig } from './sdkRuntimeModels';
4
+ import { IKitConfigs } from './configAPIClient';
5
+ type valueof<T> = T[keyof T];
6
+ type AttributeValue = string | number | boolean | null | undefined;
7
+ export type Dictionary<V = any> = Record<string, V>;
8
+ export type Environment = valueof<typeof Constants.Environment>;
9
+ declare const createCookieString: (value: string) => string;
10
+ declare const revertCookieString: (value: string) => string;
11
+ declare const inArray: (items: any[], name: any) => boolean;
12
+ declare const findKeyInObject: (obj: any, key: string) => string;
13
+ declare const generateDeprecationMessage: (methodName: string, isDeprecated?: boolean, alternateMethod?: string, docsUrl?: string) => string;
14
+ declare function generateHash(name: string): number;
15
+ declare const generateUniqueId: (a?: string) => string;
16
+ /**
17
+ * Returns a value between 1-100 inclusive.
18
+ */
19
+ declare const getRampNumber: (value?: string) => number;
20
+ declare const isObject: (value: any) => boolean;
21
+ declare const parseNumber: (value: string | number) => number;
22
+ declare const parseSettingsString: (settingsString: string) => Dictionary<string>[];
23
+ declare const parseStringOrNumber: (value: string | number) => string | number | null;
24
+ declare const replaceCommasWithPipes: (value: string) => string;
25
+ declare const replacePipesWithCommas: (value: string) => string;
26
+ declare const replaceApostrophesWithQuotes: (value: string) => string;
27
+ declare const replaceQuotesWithApostrophes: (value: string) => string;
28
+ declare const replaceMPID: (value: string, mpid: MPID) => string;
29
+ declare const replaceAmpWithAmpersand: (value: string) => string;
30
+ declare const createCookieSyncUrl: (mpid: MPID, pixelUrl: string, redirectUrl?: string, domain?: string) => string;
31
+ declare const returnConvertedBoolean: (data: string | boolean | number) => boolean;
32
+ declare const decoded: (s: string) => string;
33
+ declare const converted: (s: string) => string;
34
+ declare const isString: (value: any) => boolean;
35
+ declare const isNumber: (value: any) => boolean;
36
+ declare const isFunction: (fn: any) => boolean;
37
+ declare const isValidAttributeValue: (value: any) => boolean;
38
+ declare const isValidCustomFlagProperty: (value: any) => boolean;
39
+ declare const toDataPlanSlug: (value: any) => string;
40
+ declare const isDataPlanSlug: (str: string) => boolean;
41
+ declare const isStringOrNumber: (value: any) => boolean;
42
+ declare const isEmpty: (value: Dictionary<any> | string | null | undefined) => boolean;
43
+ declare const mergeObjects: <T extends object>(...objects: T[]) => T;
44
+ declare const moveElementToEnd: <T>(array: T[], index: number) => T[];
45
+ declare const queryStringParser: (url: string, keys?: string[]) => Dictionary<string>;
46
+ declare const getCookies: (keys?: string[]) => Dictionary<string>;
47
+ declare const getHref: () => string;
48
+ declare const filterDictionaryWithHash: <T>(dictionary: Dictionary<T>, filterList: any[], hashFn: (key: string) => any) => Dictionary<T>;
49
+ declare const parseConfig: (config: SDKInitConfig, moduleName: string, moduleId: number) => IKitConfigs | null;
50
+ /**
51
+ * Obfuscates an object by replacing all primitive values with their type names,
52
+ * while preserving the structure of nested objects and arrays.
53
+ * This is useful for logging data structures without exposing PII.
54
+ *
55
+ * @param value - The value to obfuscate
56
+ * @returns The obfuscated value with types instead of actual values
57
+ *
58
+ * @example
59
+ * obfuscateData({ email: 'user@email.com', age: 30 })
60
+ * // Returns: { email: 'string', age: 'number' }
61
+ *
62
+ * obfuscateData({ tags: ['premium', 'verified'] })
63
+ * // Returns: { tags: ['string', 'string'] }
64
+ */
65
+ declare const obfuscateData: (value: any) => any;
66
+ /**
67
+ * For verbose logging: returns raw data when isDevelopmentMode is true, else obfuscated data.
68
+ * Used when logging payloads so PII is not exposed in production.
69
+ *
70
+ * @param data - The value to log
71
+ * @param isDevelopmentMode - When true, returns data unchanged, when false or undefined, returns obfuscated data
72
+ * @returns Raw data when isDevelopmentMode is true, otherwise obfuscated structure
73
+ *
74
+ * @example
75
+ * obfuscateDevData({ email: 'user@email.com' }, true)
76
+ * // Returns: { email: 'user@email.com' }
77
+ *
78
+ * obfuscateDevData({ email: 'user@email.com' }, false)
79
+ * // Returns: { email: 'string' }
80
+ */
81
+ declare const obfuscateDevData: (data: any, isDevelopmentMode?: boolean) => any;
82
+ export { createCookieString, revertCookieString, createCookieSyncUrl, valueof, AttributeValue, converted, decoded, obfuscateDevData, filterDictionaryWithHash, findKeyInObject, generateDeprecationMessage, generateHash, generateUniqueId, getRampNumber, inArray, isObject, isStringOrNumber, obfuscateData, parseConfig, parseNumber, parseSettingsString, parseStringOrNumber, replaceCommasWithPipes, replacePipesWithCommas, replaceApostrophesWithQuotes, replaceQuotesWithApostrophes, returnConvertedBoolean, toDataPlanSlug, isString, isNumber, isFunction, isDataPlanSlug, isEmpty, isValidAttributeValue, isValidCustomFlagProperty, mergeObjects, moveElementToEnd, queryStringParser, getCookies, getHref, replaceMPID, replaceAmpWithAmpersand, };
@@ -0,0 +1,18 @@
1
+ import { valueof } from './utils';
2
+ import Constants from './constants';
3
+ import { IdentityApiData } from '@mparticle/web-sdk';
4
+ import { IdentityAPIMethod } from './identity.interfaces';
5
+ type ValidationIdentitiesReturn = {
6
+ valid: boolean;
7
+ error?: valueof<typeof Constants.Messages.ValidationMessages>;
8
+ };
9
+ declare const Validators: {
10
+ isNumber: (value: any) => boolean;
11
+ isFunction: (fn: any) => boolean;
12
+ isStringOrNumber: (value: any) => boolean;
13
+ isValidAttributeValue: (value: any) => boolean;
14
+ isValidKeyValue: (key: any) => boolean;
15
+ removeFalsyIdentityValues: (identityApiData: IdentityApiData, logger: any) => IdentityApiData;
16
+ validateIdentities: (identityApiData: IdentityApiData, method?: IdentityAPIMethod) => ValidationIdentitiesReturn;
17
+ };
18
+ export default Validators;
@@ -0,0 +1,41 @@
1
+ export declare abstract class BaseVault<StorableItem> {
2
+ contents: StorableItem;
3
+ protected readonly _storageKey: string;
4
+ protected storageObject: Storage;
5
+ /**
6
+ *
7
+ * @param {string} storageKey the local storage key string
8
+ * @param {Storage} storageObject Web API Storage object that is being used
9
+ */
10
+ constructor(storageKey: string, storageObject: Storage);
11
+ /**
12
+ * Stores a StorableItem to Storage
13
+ * @method store
14
+ * @param item {StorableItem}
15
+ */
16
+ store(item: StorableItem): void;
17
+ /**
18
+ * Retrieve StorableItem from Storage
19
+ * @method retrieve
20
+ * @returns {StorableItem}
21
+ */
22
+ retrieve(): StorableItem | null;
23
+ /**
24
+ * Removes all persisted data from Storage based on this vault's `key`
25
+ * Will remove storage key from Storage as well
26
+ * @method purge
27
+ */
28
+ purge(): void;
29
+ }
30
+ export declare class LocalStorageVault<StorableItem> extends BaseVault<StorableItem> {
31
+ constructor(storageKey: string);
32
+ }
33
+ export declare class SessionStorageVault<StorableItem> extends BaseVault<StorableItem> {
34
+ constructor(storageKey: string);
35
+ }
36
+ export declare class DisabledVault<StorableItem> extends BaseVault<StorableItem> {
37
+ constructor(storageKey: string);
38
+ store(_item: StorableItem): void;
39
+ retrieve(): StorableItem | null;
40
+ purge(): void;
41
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mparticle/web-sdk",
3
- "version": "2.60.1",
3
+ "version": "2.62.0",
4
4
  "description": "mParticle core SDK for web applications",
5
5
  "license": "Apache-2.0",
6
6
  "keywords": [
@@ -12,6 +12,7 @@
12
12
  "dist/mparticle.common.js",
13
13
  "dist/mparticle.esm.js",
14
14
  "dist/mparticle.js",
15
+ "dist/types/",
15
16
  "src/"
16
17
  ],
17
18
  "publishConfig": {
@@ -21,9 +22,18 @@
21
22
  },
22
23
  "main": "dist/mparticle.common.js",
23
24
  "module": "dist/mparticle.esm.js",
25
+ "types": "dist/types/src/public-types.d.ts",
26
+ "typesVersions": {
27
+ "*": {
28
+ "internal": [
29
+ "dist/types/src/internal-types.d.ts"
30
+ ]
31
+ }
32
+ },
24
33
  "repository": "https://github.com/mParticle/mparticle-web-sdk",
25
34
  "scripts": {
26
- "build": "cross-env ENVIRONMENT=prod BUILDALL=true rollup --config rollup.config.js",
35
+ "build": "cross-env ENVIRONMENT=prod BUILDALL=true rollup --config rollup.config.js && npm run build:types",
36
+ "build:types": "rm -rf dist/types && (tsc -p tsconfig.types.json || true) && test -f dist/types/src/public-types.d.ts && test -f dist/types/src/internal-types.d.ts",
27
37
  "build:cbt": "rollup --config test/cross-browser-testing/rollup.CBT.config.js",
28
38
  "build:dev": "cross-env ENVIRONMENT=dev BUILD=iife rollup --config rollup.config.js",
29
39
  "build:iife": "cross-env ENVIRONMENT=prod BUILD=iife rollup --config rollup.config.js",
@@ -65,7 +75,7 @@
65
75
  "test:karma:rollup:cjs": "cross-env BUNDLER=rollup karma start test/integrations/cjs/karma.rollup.config.js",
66
76
  "test:karma:webpack:module": "cross-env BUNDLER=webpack karma start test/integrations/module/karma.webpack.config.js",
67
77
  "test:karma:rollup:module": "cross-env BUNDLER=rollup karma start test/integrations/module/karma.rollup.config.js",
68
- "test:jest": "npm run build && jest --config jest.config.js",
78
+ "test:jest": "jest --config jest.config.js",
69
79
  "test:jest:watch": "jest --config jest.config.js --watch",
70
80
  "watch": "cross-env ENVIRONMENT=dev BUILD=iife rollup --config rollup.config.js -w",
71
81
  "watch:all": "cross-env ENVIRONMENT=prod BUILDALL=true rollup --config rollup.config.js -w",
@@ -148,6 +158,9 @@
148
158
  "webpack": "^5.36.2",
149
159
  "webpack-cli": "^5.0.2"
150
160
  },
161
+ "peerDependencies": {
162
+ "@mparticle/event-models": "^1.1.9"
163
+ },
151
164
  "dependencies": {
152
165
  "@babel/runtime": "^7.23.2"
153
166
  }
package/src/apiClient.ts CHANGED
@@ -176,7 +176,7 @@ export default function APIClient(
176
176
  // https://go.mparticle.com/work/SQDSDKS-6935
177
177
  // While Event Name is 'usually' a string, there are some cases where it is a number
178
178
  // in that it could be a type of MessageType Enum
179
- if (event.EventName as unknown as number !== Types.MessageType.AppStateTransition) {
179
+ if (event.EventName !== String(Types.MessageType.AppStateTransition)) {
180
180
  if (kitBlocker && kitBlocker.kitBlockingEnabled) {
181
181
  event = kitBlocker.createBlockedEvent(event);
182
182
  }
package/src/constants.ts CHANGED
@@ -139,8 +139,6 @@ const Constants = {
139
139
  identityUrl: 'identity.mparticle.com/v1/',
140
140
  aliasUrl: 'jssdks.mparticle.com/v1/identity/',
141
141
  userAudienceUrl: 'nativesdks.mparticle.com/v1/',
142
- loggingUrl: 'apps.rokt-api.com/v1/log',
143
- errorUrl: 'apps.rokt-api.com/v1/errors',
144
142
  },
145
143
  // These are the paths that are used to construct the CNAME urls
146
144
  CNAMEUrlPaths: {
@@ -150,8 +148,6 @@ const Constants = {
150
148
  configUrl: '/tags/JS/v2/',
151
149
  identityUrl: '/identity/v1/',
152
150
  aliasUrl: '/webevents/v1/identity/',
153
- loggingUrl: '/v1/log',
154
- errorUrl: '/v1/errors',
155
151
  },
156
152
  Base64CookieKeys: {
157
153
  csm: 1,
@@ -2,6 +2,8 @@ import { SDKEvent, SDKEventCustomFlags } from './sdkRuntimeModels';
2
2
  import { Dictionary } from './utils';
3
3
  import { IKitConfigs, IKitFilterSettings } from './configAPIClient';
4
4
  import { IdentityApiData, IdentityType } from '@mparticle/web-sdk';
5
+ import { Batch } from '@mparticle/event-models';
6
+
5
7
  import {
6
8
  IMParticleUser,
7
9
  ISDKUserIdentity,
@@ -89,6 +91,46 @@ export interface ConfiguredKit
89
91
  hasSandbox: boolean;
90
92
  }
91
93
 
94
+ export interface KitInterface {
95
+ id: number;
96
+ name: string;
97
+ init(
98
+ settings: Dictionary<unknown>,
99
+ service: forwardingStatsCallback,
100
+ testMode?: boolean,
101
+ trackerId?: string | null,
102
+ userAttributes?: UserAttributes,
103
+ userIdentities?: ISDKUserIdentity,
104
+ appVersion?: string,
105
+ appName?: string,
106
+ customFlags?: SDKEventCustomFlags,
107
+ clientId?: string
108
+ ): string;
109
+ onIdentifyComplete?(
110
+ user: IMParticleUser,
111
+ filteredIdentityRequest: IdentityApiData
112
+ ): string;
113
+ onLoginComplete?(
114
+ user: IMParticleUser,
115
+ filteredIdentityRequest: IdentityApiData
116
+ ): string;
117
+ onLogoutComplete?(
118
+ user: IMParticleUser,
119
+ filteredIdentityRequest: IdentityApiData
120
+ ): string;
121
+ onModifyComplete?(
122
+ user: IMParticleUser,
123
+ filteredIdentityRequest: IdentityApiData
124
+ ): string;
125
+ onUserIdentified?(user: IMParticleUser): string;
126
+ process?(event: SDKEvent): string;
127
+ processBatch?(batch: Batch): string;
128
+ setOptOut?(isOptingOut: boolean): string;
129
+ removeUserAttribute?(key: string): string;
130
+ setUserAttribute?(key: string, value: string): string;
131
+ setUserIdentity?(id: UserIdentityId, type: UserIdentityType): void;
132
+ }
133
+
92
134
  export type UserIdentityId = string;
93
135
  export type UserIdentityType = number;
94
136
  export type UserAttributeFilters = number[];
@@ -25,7 +25,7 @@ import {
25
25
  IIdentityResponse,
26
26
  } from './identity-user-interfaces';
27
27
  import { IMParticleWebSDKInstance } from './mp-instance';
28
- import { ErrorCodes } from './logging/types';
28
+ import { ErrorCodes, WSDKErrorSeverity } from './reporting/types';
29
29
 
30
30
  const { HTTPCodes, Messages, IdentityMethods } = Constants;
31
31
 
@@ -201,7 +201,7 @@ export default function IdentityAPIClient(
201
201
  }
202
202
 
203
203
  const { invokeCallback } = mpInstance._Helpers;
204
- const { Logger } = mpInstance;
204
+ const { Logger, _ErrorReportingDispatcher: errorReporter } = mpInstance;
205
205
  Logger.verbose(Messages.InformationMessages.SendIdentityBegin);
206
206
  if (!identityApiRequest) {
207
207
  Logger.error(Messages.ErrorMessages.APIRequestEmpty);
@@ -339,10 +339,13 @@ export default function IdentityAPIClient(
339
339
  }
340
340
 
341
341
  const errorMessage = (err as Error).message || err.toString();
342
- Logger.error(
343
- 'Error sending identity request to servers' + ' - ' + errorMessage,
344
- ErrorCodes.IDENTITY_REQUEST
345
- );
342
+ const msg = 'Error sending identity request to servers' + ' - ' + errorMessage;
343
+ Logger.error(msg);
344
+ errorReporter?.report({
345
+ message: msg,
346
+ code: ErrorCodes.IDENTITY_REQUEST,
347
+ severity: WSDKErrorSeverity.ERROR,
348
+ });
346
349
 
347
350
  mpInstance.processQueueOnIdentityFailure?.();
348
351
  invokeCallback(callback, HTTPCodes.noHttpCoverage, errorMessage);