@mparticle/web-sdk 2.32.2 → 2.32.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/mparticle.common.js +34 -63
- package/dist/mparticle.esm.js +34 -63
- package/dist/mparticle.js +490 -501
- package/package.json +1 -1
- package/src/apiClient.ts +4 -1
- package/src/batchUploader.ts +26 -20
- package/src/constants.ts +8 -0
- package/src/ecommerce.interfaces.ts +201 -0
- package/src/ecommerce.js +9 -0
- package/src/events.interfaces.ts +83 -0
- package/src/events.js +3 -0
- package/src/forwarders.interfaces.ts +0 -3
- package/src/identity-user-interfaces.ts +9 -9
- package/src/identity.js +2 -3
- package/src/identityApiClient.ts +123 -56
- package/src/integrationCapture.ts +7 -5
- package/src/kitFilterHelper.ts +6 -7
- package/src/mp-instance.js +3 -3
- package/src/sdkRuntimeModels.ts +32 -14
- package/src/sdkToEventsApiConverter.ts +1 -1
- package/src/serverModel.ts +1 -1
- package/src/sideloadedKit.ts +12 -11
- package/src/types.ts +404 -0
- package/src/utils.ts +1 -1
- package/src/type-utils.ts +0 -66
- package/src/types.interfaces.ts +0 -56
- package/src/types.js +0 -338
package/package.json
CHANGED
package/src/apiClient.ts
CHANGED
|
@@ -135,7 +135,10 @@ export default function APIClient(
|
|
|
135
135
|
this.queueEventForBatchUpload(event);
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
-
|
|
138
|
+
// https://go.mparticle.com/work/SQDSDKS-6935
|
|
139
|
+
// While Event Name is 'usually' a string, there are some cases where it is a number
|
|
140
|
+
// in that it could be a type of MessageType Enum
|
|
141
|
+
if (event.EventName as unknown as number !== Types.MessageType.AppStateTransition) {
|
|
139
142
|
if (kitBlocker && kitBlocker.kitBlockingEnabled) {
|
|
140
143
|
event = kitBlocker.createBlockedEvent(event);
|
|
141
144
|
}
|
package/src/batchUploader.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { Batch } from '@mparticle/event-models';
|
|
|
2
2
|
import Constants from './constants';
|
|
3
3
|
import { SDKEvent, MParticleWebSDK, SDKLoggerApi } from './sdkRuntimeModels';
|
|
4
4
|
import { convertEvents } from './sdkToEventsApiConverter';
|
|
5
|
-
import
|
|
5
|
+
import { MessageType } from './types';
|
|
6
6
|
import { getRampNumber, isEmpty } from './utils';
|
|
7
7
|
import { SessionStorageVault, LocalStorageVault } from './vault';
|
|
8
8
|
import {
|
|
@@ -167,29 +167,35 @@ export class BatchUploader {
|
|
|
167
167
|
* @param event event that should be queued
|
|
168
168
|
*/
|
|
169
169
|
public queueEvent(event: SDKEvent): void {
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
this.eventVault.store(this.eventsQueuedForProcessing);
|
|
174
|
-
}
|
|
175
|
-
this.mpInstance.Logger.verbose(
|
|
176
|
-
`Queuing event: ${JSON.stringify(event)}`
|
|
177
|
-
);
|
|
178
|
-
this.mpInstance.Logger.verbose(
|
|
179
|
-
`Queued event count: ${this.eventsQueuedForProcessing.length}`
|
|
180
|
-
);
|
|
170
|
+
if (isEmpty(event)) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
181
173
|
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
174
|
+
const { verbose } = this.mpInstance.Logger;
|
|
175
|
+
|
|
176
|
+
this.eventsQueuedForProcessing.push(event);
|
|
177
|
+
if (this.offlineStorageEnabled && this.eventVault) {
|
|
178
|
+
this.eventVault.store(this.eventsQueuedForProcessing);
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
verbose(`Queuing event: ${JSON.stringify(event)}`);
|
|
182
|
+
verbose(`Queued event count: ${this.eventsQueuedForProcessing.length}`);
|
|
183
|
+
|
|
184
|
+
if (this.shouldTriggerImmediateUpload(event.EventDataType)) {
|
|
185
|
+
this.prepareAndUpload(false, false);
|
|
190
186
|
}
|
|
191
187
|
}
|
|
192
188
|
|
|
189
|
+
// https://go.mparticle.com/work/SQDSDKS-3720
|
|
190
|
+
private shouldTriggerImmediateUpload (eventDataType: number): boolean {
|
|
191
|
+
const priorityEvents = [
|
|
192
|
+
MessageType.Commerce,
|
|
193
|
+
MessageType.UserIdentityChange,
|
|
194
|
+
] as const;
|
|
195
|
+
|
|
196
|
+
return !this.batchingEnabled || priorityEvents.includes(eventDataType as typeof priorityEvents[number]);
|
|
197
|
+
};
|
|
198
|
+
|
|
193
199
|
/**
|
|
194
200
|
* This implements crucial logic to:
|
|
195
201
|
* - bucket pending events by MPID, and then by Session, and upload individual batches for each bucket.
|
package/src/constants.ts
CHANGED
|
@@ -184,6 +184,11 @@ const Constants = {
|
|
|
184
184
|
Login: 'login',
|
|
185
185
|
Identify: 'identify',
|
|
186
186
|
},
|
|
187
|
+
|
|
188
|
+
Environment: {
|
|
189
|
+
Development: 'development',
|
|
190
|
+
Production: 'production',
|
|
191
|
+
},
|
|
187
192
|
} as const;
|
|
188
193
|
|
|
189
194
|
export default Constants;
|
|
@@ -196,4 +201,7 @@ export const MILLIS_IN_ONE_SEC = 1000;
|
|
|
196
201
|
export const HTTP_OK = 200 as const;
|
|
197
202
|
export const HTTP_ACCEPTED = 202 as const;
|
|
198
203
|
export const HTTP_BAD_REQUEST = 400 as const;
|
|
204
|
+
export const HTTP_UNAUTHORIZED = 401 as const;
|
|
199
205
|
export const HTTP_FORBIDDEN = 403 as const;
|
|
206
|
+
export const HTTP_NOT_FOUND = 404 as const;
|
|
207
|
+
export const HTTP_SERVER_ERROR = 500 as const;
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
import {
|
|
2
|
+
ProductAction,
|
|
3
|
+
Product,
|
|
4
|
+
Promotion,
|
|
5
|
+
CommerceEvent,
|
|
6
|
+
} from '@mparticle/event-models';
|
|
7
|
+
import {
|
|
8
|
+
SDKEventAttrs,
|
|
9
|
+
SDKEventOptions,
|
|
10
|
+
TransactionAttributes,
|
|
11
|
+
} from '@mparticle/web-sdk';
|
|
12
|
+
import { valueof } from './utils';
|
|
13
|
+
import {
|
|
14
|
+
ProductActionType,
|
|
15
|
+
PromotionActionType,
|
|
16
|
+
CommerceEventType,
|
|
17
|
+
EventType,
|
|
18
|
+
} from './types';
|
|
19
|
+
import {
|
|
20
|
+
SDKEvent,
|
|
21
|
+
SDKEventCustomFlags,
|
|
22
|
+
SDKImpression,
|
|
23
|
+
SDKProduct,
|
|
24
|
+
SDKProductImpression,
|
|
25
|
+
SDKPromotion,
|
|
26
|
+
} from './sdkRuntimeModels';
|
|
27
|
+
|
|
28
|
+
interface IECommerceShared {
|
|
29
|
+
createProduct(
|
|
30
|
+
name: string,
|
|
31
|
+
sku: string | number,
|
|
32
|
+
price: string | number,
|
|
33
|
+
quantity?: string | number,
|
|
34
|
+
variant?: string,
|
|
35
|
+
category?: string,
|
|
36
|
+
brand?: string,
|
|
37
|
+
position?: number,
|
|
38
|
+
couponCode?: string,
|
|
39
|
+
attributes?: SDKEventAttrs
|
|
40
|
+
): SDKProduct | null;
|
|
41
|
+
createImpression(name: string, product: Product): SDKImpression | null;
|
|
42
|
+
createPromotion(
|
|
43
|
+
id: string | number,
|
|
44
|
+
creative?: string,
|
|
45
|
+
name?: string,
|
|
46
|
+
position?: number
|
|
47
|
+
): SDKPromotion | null;
|
|
48
|
+
createTransactionAttributes(
|
|
49
|
+
id: string | number,
|
|
50
|
+
affiliation?: string,
|
|
51
|
+
couponCode?: string,
|
|
52
|
+
revenue?: string | number,
|
|
53
|
+
shipping?: string | number,
|
|
54
|
+
tax?: number
|
|
55
|
+
): TransactionAttributes | null;
|
|
56
|
+
expandCommerceEvent(event: CommerceEvent): SDKEvent[] | null;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface SDKCart {
|
|
60
|
+
add(product: SDKProduct | SDKProduct[], logEvent?: boolean): void;
|
|
61
|
+
remove(product: SDKProduct | SDKProduct[], logEvent?: boolean): void;
|
|
62
|
+
clear(): void;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
// Used for the public `eCommerce` namespace
|
|
66
|
+
export interface SDKECommerceAPI extends IECommerceShared {
|
|
67
|
+
logCheckout(
|
|
68
|
+
step: number,
|
|
69
|
+
option?: string,
|
|
70
|
+
attrs?: SDKEventAttrs,
|
|
71
|
+
customFlags?: SDKEventCustomFlags
|
|
72
|
+
): void;
|
|
73
|
+
logImpression(
|
|
74
|
+
impression: SDKProductImpression,
|
|
75
|
+
attrs?: SDKEventAttrs,
|
|
76
|
+
customFlags?: SDKEventCustomFlags,
|
|
77
|
+
eventOptions?: SDKEventOptions
|
|
78
|
+
): void;
|
|
79
|
+
logProductAction(
|
|
80
|
+
productActionType: valueof<typeof ProductActionType>,
|
|
81
|
+
product: SDKProduct | SDKProduct[],
|
|
82
|
+
attrs?: SDKEventAttrs,
|
|
83
|
+
customFlags?: SDKEventCustomFlags,
|
|
84
|
+
transactionAttributes?: TransactionAttributes,
|
|
85
|
+
eventOptions?: SDKEventOptions
|
|
86
|
+
): void;
|
|
87
|
+
logPromotion(
|
|
88
|
+
type: valueof<typeof PromotionActionType>,
|
|
89
|
+
promotion: SDKPromotion,
|
|
90
|
+
attrs?: SDKEventAttrs,
|
|
91
|
+
customFlags?: SDKEventCustomFlags,
|
|
92
|
+
eventOptions?: SDKEventOptions
|
|
93
|
+
): void;
|
|
94
|
+
setCurrencyCode(code: string): void;
|
|
95
|
+
|
|
96
|
+
/*
|
|
97
|
+
* @deprecated
|
|
98
|
+
*/
|
|
99
|
+
Cart: SDKCart;
|
|
100
|
+
|
|
101
|
+
/*
|
|
102
|
+
* @deprecated
|
|
103
|
+
*/
|
|
104
|
+
logPurchase(
|
|
105
|
+
transactionAttributes: TransactionAttributes,
|
|
106
|
+
product: SDKProduct | SDKProduct[],
|
|
107
|
+
clearCart?: boolean,
|
|
108
|
+
attrs?: SDKEventAttrs,
|
|
109
|
+
customFlags?: SDKEventCustomFlags
|
|
110
|
+
): void;
|
|
111
|
+
|
|
112
|
+
/*
|
|
113
|
+
* @deprecated
|
|
114
|
+
*/
|
|
115
|
+
logRefund(
|
|
116
|
+
transactionAttributes: TransactionAttributes,
|
|
117
|
+
product: SDKProduct | SDKProduct[],
|
|
118
|
+
clearCart?: boolean,
|
|
119
|
+
attrs?: SDKEventAttrs,
|
|
120
|
+
customFlags?: SDKEventCustomFlags
|
|
121
|
+
): void;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
interface ExtractedActionAttributes {
|
|
125
|
+
Affiliation?: string;
|
|
126
|
+
'Coupon Code'?: string;
|
|
127
|
+
'Total Amount'?: number;
|
|
128
|
+
'Shipping Amount'?: number;
|
|
129
|
+
'Tax Amount'?: number;
|
|
130
|
+
'Checkout Option'?: string;
|
|
131
|
+
'Checkout Step'?: number;
|
|
132
|
+
'Transaction ID'?: string;
|
|
133
|
+
}
|
|
134
|
+
interface ExtractedProductAttributes {
|
|
135
|
+
'Coupon Code'?: string;
|
|
136
|
+
Brand?: string;
|
|
137
|
+
Category?: string;
|
|
138
|
+
Name?: string;
|
|
139
|
+
Id?: string;
|
|
140
|
+
'Item Price'?: number;
|
|
141
|
+
Quantity?: number;
|
|
142
|
+
Position?: number;
|
|
143
|
+
Variant?: string;
|
|
144
|
+
'Total Product Amount': number;
|
|
145
|
+
}
|
|
146
|
+
interface ExtractedPromotionAttributes {
|
|
147
|
+
Id?: string;
|
|
148
|
+
Creative?: string;
|
|
149
|
+
Name?: string;
|
|
150
|
+
Position?: number;
|
|
151
|
+
}
|
|
152
|
+
interface ExtractedTransactionId {
|
|
153
|
+
'Transaction ID'?: string;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// Used for the private `_Ecommerce` namespace
|
|
157
|
+
export interface IECommerce extends IECommerceShared {
|
|
158
|
+
buildProductList(event: SDKEvent, product: Product | Product[]): Product[];
|
|
159
|
+
convertProductActionToEventType(
|
|
160
|
+
productActionType: valueof<typeof ProductActionType>
|
|
161
|
+
): // https://go.mparticle.com/work/SQDSDKS-4801
|
|
162
|
+
typeof CommerceEventType | typeof EventType | null;
|
|
163
|
+
convertPromotionActionToEventType(
|
|
164
|
+
promotionActionType: valueof<typeof PromotionActionType>
|
|
165
|
+
): typeof CommerceEventType | null;
|
|
166
|
+
convertTransactionAttributesToProductAction(
|
|
167
|
+
transactionAttributes: TransactionAttributes,
|
|
168
|
+
productAction: ProductAction
|
|
169
|
+
): void;
|
|
170
|
+
createCommerceEventObject(
|
|
171
|
+
customFlags: SDKEventCustomFlags,
|
|
172
|
+
options?: SDKEventOptions
|
|
173
|
+
): SDKEvent | null;
|
|
174
|
+
expandProductAction(commerceEvent: CommerceEvent): SDKEvent[];
|
|
175
|
+
expandProductImpression(commerceEvent: CommerceEvent): SDKEvent[];
|
|
176
|
+
expandPromotionAction(commerceEvent: CommerceEvent): SDKEvent[];
|
|
177
|
+
extractActionAttributes(
|
|
178
|
+
attributes: ExtractedActionAttributes,
|
|
179
|
+
productAction: ProductAction
|
|
180
|
+
): void;
|
|
181
|
+
extractProductAttributes(
|
|
182
|
+
attributes: ExtractedProductAttributes,
|
|
183
|
+
product: Product
|
|
184
|
+
): void;
|
|
185
|
+
extractPromotionAttributes(
|
|
186
|
+
attributes: ExtractedPromotionAttributes,
|
|
187
|
+
promotion: Promotion
|
|
188
|
+
): void;
|
|
189
|
+
extractTransactionId(
|
|
190
|
+
attributes: ExtractedTransactionId,
|
|
191
|
+
productAction: ProductAction
|
|
192
|
+
): void;
|
|
193
|
+
generateExpandedEcommerceName(eventName: string, plusOne: boolean): string;
|
|
194
|
+
getProductActionEventName(
|
|
195
|
+
productActionType: valueof<typeof ProductActionType>
|
|
196
|
+
): string;
|
|
197
|
+
getPromotionActionEventName(
|
|
198
|
+
promotionActionType: valueof<typeof PromotionActionType>
|
|
199
|
+
): string;
|
|
200
|
+
sanitizeAmount(amount: string | number, category: string): number;
|
|
201
|
+
}
|
package/src/ecommerce.js
CHANGED
|
@@ -5,6 +5,8 @@ var Messages = Constants.Messages;
|
|
|
5
5
|
|
|
6
6
|
export default function Ecommerce(mpInstance) {
|
|
7
7
|
var self = this;
|
|
8
|
+
|
|
9
|
+
// https://go.mparticle.com/work/SQDSDKS-4801
|
|
8
10
|
this.convertTransactionAttributesToProductAction = function(
|
|
9
11
|
transactionAttributes,
|
|
10
12
|
productAction
|
|
@@ -103,8 +105,11 @@ export default function Ecommerce(mpInstance) {
|
|
|
103
105
|
return Types.CommerceEventType.ProductRemoveFromCart;
|
|
104
106
|
case Types.ProductActionType.RemoveFromWishlist:
|
|
105
107
|
return Types.CommerceEventType.ProductRemoveFromWishlist;
|
|
108
|
+
|
|
109
|
+
// https://go.mparticle.com/work/SQDSDKS-4801
|
|
106
110
|
case Types.ProductActionType.Unknown:
|
|
107
111
|
return Types.EventType.Unknown;
|
|
112
|
+
|
|
108
113
|
case Types.ProductActionType.ViewDetail:
|
|
109
114
|
return Types.CommerceEventType.ProductViewDetail;
|
|
110
115
|
default:
|
|
@@ -139,6 +144,7 @@ export default function Ecommerce(mpInstance) {
|
|
|
139
144
|
);
|
|
140
145
|
};
|
|
141
146
|
|
|
147
|
+
// https://go.mparticle.com/work/SQDSDKS-4801
|
|
142
148
|
this.extractProductAttributes = function(attributes, product) {
|
|
143
149
|
if (product.CouponCode) {
|
|
144
150
|
attributes['Coupon Code'] = product.CouponCode;
|
|
@@ -170,12 +176,14 @@ export default function Ecommerce(mpInstance) {
|
|
|
170
176
|
attributes['Total Product Amount'] = product.TotalAmount || 0;
|
|
171
177
|
};
|
|
172
178
|
|
|
179
|
+
// https://go.mparticle.com/work/SQDSDKS-4801
|
|
173
180
|
this.extractTransactionId = function(attributes, productAction) {
|
|
174
181
|
if (productAction.TransactionId) {
|
|
175
182
|
attributes['Transaction Id'] = productAction.TransactionId;
|
|
176
183
|
}
|
|
177
184
|
};
|
|
178
185
|
|
|
186
|
+
// https://go.mparticle.com/work/SQDSDKS-4801
|
|
179
187
|
this.extractActionAttributes = function(attributes, productAction) {
|
|
180
188
|
self.extractTransactionId(attributes, productAction);
|
|
181
189
|
|
|
@@ -208,6 +216,7 @@ export default function Ecommerce(mpInstance) {
|
|
|
208
216
|
}
|
|
209
217
|
};
|
|
210
218
|
|
|
219
|
+
// https://go.mparticle.com/work/SQDSDKS-4801
|
|
211
220
|
this.extractPromotionAttributes = function(attributes, promotion) {
|
|
212
221
|
if (promotion.Id) {
|
|
213
222
|
attributes['Id'] = promotion.Id;
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Callback,
|
|
3
|
+
SDKEventAttrs,
|
|
4
|
+
SDKEventOptions,
|
|
5
|
+
TransactionAttributes,
|
|
6
|
+
} from '@mparticle/web-sdk';
|
|
7
|
+
import {
|
|
8
|
+
BaseEvent,
|
|
9
|
+
SDKEvent,
|
|
10
|
+
SDKEventCustomFlags,
|
|
11
|
+
SDKProduct,
|
|
12
|
+
SDKProductImpression,
|
|
13
|
+
SDKPromotion,
|
|
14
|
+
} from './sdkRuntimeModels';
|
|
15
|
+
import { valueof } from './utils';
|
|
16
|
+
import { EventType, ProductActionType, PromotionActionType } from './types';
|
|
17
|
+
|
|
18
|
+
// Supports wrapping event handlers functions that will ideally return a specific type
|
|
19
|
+
type EventHandlerFunction<T> = (element: HTMLLinkElement | HTMLFormElement) => T;
|
|
20
|
+
|
|
21
|
+
export interface IEvents {
|
|
22
|
+
addEventHandler(
|
|
23
|
+
domEvent: string,
|
|
24
|
+
selector: string | Node,
|
|
25
|
+
eventName: EventHandlerFunction<string> | string,
|
|
26
|
+
data: EventHandlerFunction<SDKEventAttrs> | SDKEventAttrs,
|
|
27
|
+
eventType: valueof<typeof EventType>
|
|
28
|
+
): void;
|
|
29
|
+
logAST(): void;
|
|
30
|
+
logCheckoutEvent(
|
|
31
|
+
step: number,
|
|
32
|
+
|
|
33
|
+
// User options specified during the checkout process
|
|
34
|
+
// e.g., FedEx, DHL, UPS for delivery options;
|
|
35
|
+
// Visa, MasterCard, AmEx for payment options.
|
|
36
|
+
option?: string,
|
|
37
|
+
|
|
38
|
+
attrs?: SDKEventAttrs,
|
|
39
|
+
customFlags?: SDKEventCustomFlags
|
|
40
|
+
): void;
|
|
41
|
+
logCommerceEvent(
|
|
42
|
+
commerceEvent: SDKEvent,
|
|
43
|
+
attrs?: SDKEventAttrs,
|
|
44
|
+
options?: SDKEventOptions
|
|
45
|
+
): void;
|
|
46
|
+
logEvent(event: BaseEvent, eventOptions?: SDKEventOptions): void;
|
|
47
|
+
logImpressionEvent(
|
|
48
|
+
impression: SDKProductImpression,
|
|
49
|
+
attrs?: SDKEventAttrs,
|
|
50
|
+
customFlags?: SDKEventCustomFlags,
|
|
51
|
+
eventOptions?: SDKEventOptions
|
|
52
|
+
);
|
|
53
|
+
logOptOut(): void;
|
|
54
|
+
logProductActionEvent(
|
|
55
|
+
productActionType: valueof<typeof ProductActionType>,
|
|
56
|
+
product: SDKProduct,
|
|
57
|
+
attrs?: SDKEventAttrs,
|
|
58
|
+
customFlags?: SDKEventCustomFlags,
|
|
59
|
+
transactionAttributes?: TransactionAttributes,
|
|
60
|
+
eventOptions?: SDKEventOptions
|
|
61
|
+
): void;
|
|
62
|
+
logPromotionEvent(
|
|
63
|
+
promotionType: valueof<typeof PromotionActionType>,
|
|
64
|
+
promotion: SDKPromotion,
|
|
65
|
+
attrs?: SDKEventAttrs,
|
|
66
|
+
customFlags?: SDKEventCustomFlags,
|
|
67
|
+
eventOptions?: SDKEventOptions
|
|
68
|
+
): void;
|
|
69
|
+
logPurchaseEvent(
|
|
70
|
+
transactionAttributes: TransactionAttributes,
|
|
71
|
+
product: SDKProduct,
|
|
72
|
+
attrs?: SDKEventAttrs,
|
|
73
|
+
customFlags?: SDKEventCustomFlags
|
|
74
|
+
): void;
|
|
75
|
+
logRefundEvent(
|
|
76
|
+
transactionAttributes: TransactionAttributes,
|
|
77
|
+
product: SDKProduct,
|
|
78
|
+
attrs?: SDKEventAttrs,
|
|
79
|
+
customFlags?: SDKEventCustomFlags
|
|
80
|
+
): void;
|
|
81
|
+
startTracking(callback: Callback): void;
|
|
82
|
+
stopTracking(): void;
|
|
83
|
+
}
|
package/src/events.js
CHANGED
|
@@ -438,10 +438,13 @@ export default function Events(mpInstance) {
|
|
|
438
438
|
element = elements[i];
|
|
439
439
|
|
|
440
440
|
if (element.addEventListener) {
|
|
441
|
+
// Modern browsers
|
|
441
442
|
element.addEventListener(domEvent, handler, false);
|
|
442
443
|
} else if (element.attachEvent) {
|
|
444
|
+
// IE < 9
|
|
443
445
|
element.attachEvent('on' + domEvent, handler);
|
|
444
446
|
} else {
|
|
447
|
+
// All other browsers
|
|
445
448
|
element['on' + domEvent] = handler;
|
|
446
449
|
}
|
|
447
450
|
}
|
|
@@ -63,9 +63,6 @@ export interface ConfiguredKit
|
|
|
63
63
|
setOptOut(isOptingOut: boolean): string | KitMappedMethodFailure;
|
|
64
64
|
removeUserAttribute(key: string): string;
|
|
65
65
|
setUserAttribute(key: string, value: string): string;
|
|
66
|
-
|
|
67
|
-
// TODO: Convert type to enum during Identity migration
|
|
68
|
-
// https://go.mparticle.com/work/SQDSDKS-5218
|
|
69
66
|
setUserIdentity(id: UserIdentityId, type: UserIdentityType): void;
|
|
70
67
|
|
|
71
68
|
// TODO: https://go.mparticle.com/work/SQDSDKS-5156
|
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
import { AllUserAttributes, MPID, Product, User } from '@mparticle/web-sdk';
|
|
2
2
|
import { SDKIdentityTypeEnum } from './identity.interfaces';
|
|
3
|
-
import { MessageType } from './types
|
|
4
|
-
import { BaseEvent } from './sdkRuntimeModels';
|
|
3
|
+
import { MessageType } from './types';
|
|
4
|
+
import { BaseEvent, SDKProduct } from './sdkRuntimeModels';
|
|
5
5
|
import Constants from './constants';
|
|
6
6
|
const { HTTPCodes } = Constants;
|
|
7
7
|
|
|
8
8
|
// Cart is Deprecated and private to mParticle user in @mparticle/web-sdk
|
|
9
9
|
// but we need to expose it here for type safety in some of our tests
|
|
10
|
-
interface
|
|
10
|
+
interface ICart {
|
|
11
11
|
/**
|
|
12
12
|
* @deprecated Cart persistence in mParticle has been deprecated. Please use mParticle.eCommerce.logProductAction(mParticle.ProductActionType.AddToCart, [products])
|
|
13
13
|
*/
|
|
14
|
-
add: (product:
|
|
14
|
+
add: (product: SDKProduct, logEventBoolean?: boolean) => void;
|
|
15
15
|
/**
|
|
16
16
|
* @deprecated Cart persistence in mParticle has been deprecated. Please use mParticle.eCommerce.logProductAction(mParticle.ProductActionType.RemoveFromCart, [products])
|
|
17
17
|
*/
|
|
18
|
-
remove: (product:
|
|
18
|
+
remove: (product: SDKProduct, logEventBoolean?: boolean) => void;
|
|
19
19
|
/**
|
|
20
20
|
* @deprecated Cart persistence in mParticle has been deprecated.
|
|
21
21
|
*/
|
|
@@ -23,7 +23,7 @@ interface Cart {
|
|
|
23
23
|
/**
|
|
24
24
|
* @deprecated Cart Products have been deprecated
|
|
25
25
|
*/
|
|
26
|
-
getCartProducts: () =>
|
|
26
|
+
getCartProducts: () => SDKProduct[];
|
|
27
27
|
}
|
|
28
28
|
|
|
29
29
|
// https://go.mparticle.com/work/SQDSDKS-5033
|
|
@@ -36,7 +36,7 @@ export interface IMParticleUser extends User {
|
|
|
36
36
|
/*
|
|
37
37
|
* @deprecated
|
|
38
38
|
*/
|
|
39
|
-
getCart():
|
|
39
|
+
getCart(): ICart;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export interface ISDKUserIdentity {
|
|
@@ -58,7 +58,7 @@ export interface ISDKUserIdentityChangeData {
|
|
|
58
58
|
}
|
|
59
59
|
|
|
60
60
|
export interface IUserIdentityChangeEvent extends BaseEvent {
|
|
61
|
-
messageType: MessageType.UserIdentityChange;
|
|
61
|
+
messageType: typeof MessageType.UserIdentityChange;
|
|
62
62
|
userIdentityChanges: ISDKUserIdentityChanges;
|
|
63
63
|
}
|
|
64
64
|
|
|
@@ -75,7 +75,7 @@ export interface ISDKUserAttributeChangeData {
|
|
|
75
75
|
}
|
|
76
76
|
|
|
77
77
|
export interface IUserAttributeChangeEvent extends BaseEvent {
|
|
78
|
-
messageType: MessageType.UserAttributeChange;
|
|
78
|
+
messageType: typeof MessageType.UserAttributeChange;
|
|
79
79
|
userAttributeChanges: ISDKUserAttributeChangeData;
|
|
80
80
|
}
|
|
81
81
|
|
package/src/identity.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import Constants, { HTTP_OK } from './constants';
|
|
2
|
-
import Types from './types';
|
|
2
|
+
import Types, { IdentityType } from './types';
|
|
3
3
|
import {
|
|
4
4
|
cacheOrClearIdCache,
|
|
5
5
|
createKnownIdentities,
|
|
@@ -17,7 +17,6 @@ import {
|
|
|
17
17
|
isObject,
|
|
18
18
|
} from './utils';
|
|
19
19
|
import { hasMPIDAndUserLoginChanged, hasMPIDChanged } from './user-utils';
|
|
20
|
-
import { getNewIdentitiesByName } from './type-utils';
|
|
21
20
|
import { processReadyQueue } from './pre-init-utils';
|
|
22
21
|
|
|
23
22
|
export default function Identity(mpInstance) {
|
|
@@ -1619,7 +1618,7 @@ export default function Identity(mpInstance) {
|
|
|
1619
1618
|
self.setForwarderCallbacks(newUser, method);
|
|
1620
1619
|
}
|
|
1621
1620
|
|
|
1622
|
-
const newIdentitiesByName = getNewIdentitiesByName(
|
|
1621
|
+
const newIdentitiesByName = IdentityType.getNewIdentitiesByName(
|
|
1623
1622
|
newIdentitiesByType
|
|
1624
1623
|
);
|
|
1625
1624
|
|