@mparticle/web-sdk 2.26.2 → 2.26.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 +53 -74
- package/dist/mparticle.esm.js +53 -74
- package/dist/mparticle.js +764 -804
- package/package.json +1 -1
- package/src/identity.js +218 -158
- package/src/identityApiClient.js +0 -2
- package/src/persistence.interfaces.ts +2 -1
- package/src/persistence.js +0 -17
- package/src/sdkRuntimeModels.ts +6 -12
- package/src/serverModel.ts +0 -4
- package/src/store.ts +0 -18
- package/src/types.js +44 -3
- package/src/utils.ts +0 -4
- package/src/type-utils.ts +0 -66
- package/src/user-utils.ts +0 -12
package/src/sdkRuntimeModels.ts
CHANGED
|
@@ -26,10 +26,7 @@ export interface SDKEvent {
|
|
|
26
26
|
IsFirstRun: boolean;
|
|
27
27
|
EventName: string;
|
|
28
28
|
EventCategory: number;
|
|
29
|
-
|
|
30
|
-
// https://go.mparticle.com/work/SQDSDKS-5196
|
|
31
29
|
UserAttributes?: { [key: string]: string | string[] | null };
|
|
32
|
-
|
|
33
30
|
UserIdentities?: SDKUserIdentity[];
|
|
34
31
|
SourceMessageId: string;
|
|
35
32
|
MPID: string;
|
|
@@ -307,16 +304,13 @@ export interface SDKConfigApi {
|
|
|
307
304
|
onCreateBatch(batch: EventsApi.Batch): EventsApi.Batch;
|
|
308
305
|
}
|
|
309
306
|
|
|
310
|
-
//
|
|
307
|
+
// FIXME: Resolve with User in @types/mparticle-web-sdk
|
|
308
|
+
// https://go.mparticle.com/work/SQDSDKS-5033
|
|
311
309
|
export interface MParticleUser {
|
|
312
|
-
getMPID
|
|
313
|
-
getConsentState
|
|
314
|
-
|
|
315
|
-
//
|
|
316
|
-
getAllUserAttributes?(): any;
|
|
317
|
-
|
|
318
|
-
getUserIdentities?(): IdentityApiData;
|
|
319
|
-
isLoggedIn?(): boolean;
|
|
310
|
+
getMPID(): string;
|
|
311
|
+
getConsentState(): SDKConsentState;
|
|
312
|
+
getAllUserAttributes(): any; // FIXME;
|
|
313
|
+
getUserIdentities(): IdentityApiData; // FIXME: Is this correct?
|
|
320
314
|
}
|
|
321
315
|
|
|
322
316
|
export interface SDKUserIdentityChangeData {
|
package/src/serverModel.ts
CHANGED
|
@@ -27,7 +27,6 @@ import {
|
|
|
27
27
|
IPrivacyV2DTO,
|
|
28
28
|
SDKConsentState,
|
|
29
29
|
} from './consent';
|
|
30
|
-
import { UserAttributes } from './persistence.interfaces';
|
|
31
30
|
|
|
32
31
|
const MessageType = Types.MessageType;
|
|
33
32
|
const ApplicationTransitionType = Types.ApplicationTransitionType;
|
|
@@ -48,10 +47,7 @@ export interface IServerV2DTO {
|
|
|
48
47
|
dp_v?: number;
|
|
49
48
|
n?: string;
|
|
50
49
|
et?: number;
|
|
51
|
-
|
|
52
|
-
// https://go.mparticle.com/work/SQDSDKS-5196
|
|
53
50
|
ua?: Dictionary<string | string[]>;
|
|
54
|
-
|
|
55
51
|
ui?: SDKUserIdentity[];
|
|
56
52
|
ia?: Dictionary<Dictionary<string>>;
|
|
57
53
|
str?: ServerSettings;
|
package/src/store.ts
CHANGED
|
@@ -26,7 +26,6 @@ import {
|
|
|
26
26
|
isEmpty,
|
|
27
27
|
isNumber,
|
|
28
28
|
isObject,
|
|
29
|
-
moveElementToEnd,
|
|
30
29
|
parseNumber,
|
|
31
30
|
returnConvertedBoolean,
|
|
32
31
|
} from './utils';
|
|
@@ -186,7 +185,6 @@ export interface IStore {
|
|
|
186
185
|
getLastSeenTime?(mpid: MPID): number;
|
|
187
186
|
setLastSeenTime?(mpid: MPID, time?: number): void;
|
|
188
187
|
|
|
189
|
-
addMpidToSessionHistory?(mpid: MPID, previousMpid?: MPID): void;
|
|
190
188
|
hasInvalidIdentifyRequest?: () => boolean;
|
|
191
189
|
nullifySession?: () => void;
|
|
192
190
|
processConfig(config: SDKInitConfig): void;
|
|
@@ -495,22 +493,6 @@ export default function Store(
|
|
|
495
493
|
mpInstance._Persistence.update();
|
|
496
494
|
};
|
|
497
495
|
|
|
498
|
-
this.addMpidToSessionHistory = (mpid: MPID, previousMPID?: MPID): void => {
|
|
499
|
-
const indexOfMPID = this.currentSessionMPIDs.indexOf(mpid);
|
|
500
|
-
|
|
501
|
-
if (mpid && previousMPID !== mpid && indexOfMPID < 0) {
|
|
502
|
-
this.currentSessionMPIDs.push(mpid);
|
|
503
|
-
return;
|
|
504
|
-
}
|
|
505
|
-
|
|
506
|
-
if (indexOfMPID >= 0) {
|
|
507
|
-
this.currentSessionMPIDs = moveElementToEnd(
|
|
508
|
-
this.currentSessionMPIDs,
|
|
509
|
-
indexOfMPID
|
|
510
|
-
);
|
|
511
|
-
}
|
|
512
|
-
};
|
|
513
|
-
|
|
514
496
|
this.getFirstSeenTime = (mpid: MPID) => {
|
|
515
497
|
if (!mpid) {
|
|
516
498
|
return null;
|
package/src/types.js
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { getIdentityName } from './type-utils';
|
|
2
|
-
|
|
3
1
|
var MessageType = {
|
|
4
2
|
SessionStart: 1,
|
|
5
3
|
SessionEnd: 2,
|
|
@@ -211,7 +209,50 @@ IdentityType.getIdentityType = function(identityName) {
|
|
|
211
209
|
};
|
|
212
210
|
|
|
213
211
|
IdentityType.getIdentityName = function(identityType) {
|
|
214
|
-
|
|
212
|
+
switch (identityType) {
|
|
213
|
+
case IdentityType.Other:
|
|
214
|
+
return 'other';
|
|
215
|
+
case IdentityType.CustomerId:
|
|
216
|
+
return 'customerid';
|
|
217
|
+
case IdentityType.Facebook:
|
|
218
|
+
return 'facebook';
|
|
219
|
+
case IdentityType.Twitter:
|
|
220
|
+
return 'twitter';
|
|
221
|
+
case IdentityType.Google:
|
|
222
|
+
return 'google';
|
|
223
|
+
case IdentityType.Microsoft:
|
|
224
|
+
return 'microsoft';
|
|
225
|
+
case IdentityType.Yahoo:
|
|
226
|
+
return 'yahoo';
|
|
227
|
+
case IdentityType.Email:
|
|
228
|
+
return 'email';
|
|
229
|
+
case IdentityType.FacebookCustomAudienceId:
|
|
230
|
+
return 'facebookcustomaudienceid';
|
|
231
|
+
case IdentityType.Other2:
|
|
232
|
+
return 'other2';
|
|
233
|
+
case IdentityType.Other3:
|
|
234
|
+
return 'other3';
|
|
235
|
+
case IdentityType.Other4:
|
|
236
|
+
return 'other4';
|
|
237
|
+
case IdentityType.Other5:
|
|
238
|
+
return 'other5';
|
|
239
|
+
case IdentityType.Other6:
|
|
240
|
+
return 'other6';
|
|
241
|
+
case IdentityType.Other7:
|
|
242
|
+
return 'other7';
|
|
243
|
+
case IdentityType.Other8:
|
|
244
|
+
return 'other8';
|
|
245
|
+
case IdentityType.Other9:
|
|
246
|
+
return 'other9';
|
|
247
|
+
case IdentityType.Other10:
|
|
248
|
+
return 'other10';
|
|
249
|
+
case IdentityType.MobileNumber:
|
|
250
|
+
return 'mobile_number';
|
|
251
|
+
case IdentityType.PhoneNumber2:
|
|
252
|
+
return 'phone_number_2';
|
|
253
|
+
case IdentityType.PhoneNumber3:
|
|
254
|
+
return 'phone_number_3';
|
|
255
|
+
}
|
|
215
256
|
};
|
|
216
257
|
|
|
217
258
|
var ProductActionType = {
|
package/src/utils.ts
CHANGED
|
@@ -227,9 +227,6 @@ const mergeObjects = <T extends object>(...objects: T[]): T => {
|
|
|
227
227
|
return Object.assign({}, ...objects);
|
|
228
228
|
};
|
|
229
229
|
|
|
230
|
-
const moveElementToEnd = <T>(array: T[], index: number): T[] =>
|
|
231
|
-
array.slice(0, index).concat(array.slice(index + 1), array[index]);
|
|
232
|
-
|
|
233
230
|
export {
|
|
234
231
|
createCookieString,
|
|
235
232
|
revertCookieString,
|
|
@@ -259,5 +256,4 @@ export {
|
|
|
259
256
|
isEmpty,
|
|
260
257
|
isValidCustomFlagProperty,
|
|
261
258
|
mergeObjects,
|
|
262
|
-
moveElementToEnd,
|
|
263
259
|
};
|
package/src/type-utils.ts
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { IdentityType } from './types.interfaces';
|
|
2
|
-
import { parseNumber } from './utils';
|
|
3
|
-
|
|
4
|
-
export interface IIdentitiesByType {
|
|
5
|
-
[key: number]: string;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export function getNewIdentitiesByName(newIdentitiesByType: IIdentitiesByType) {
|
|
9
|
-
const newIdentitiesByName = {};
|
|
10
|
-
|
|
11
|
-
for (var key in newIdentitiesByType) {
|
|
12
|
-
const identityNameKey = getIdentityName(parseNumber(key));
|
|
13
|
-
newIdentitiesByName[identityNameKey] = newIdentitiesByType[key];
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
return newIdentitiesByName;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export function getIdentityName(identityType: IdentityType): string | null {
|
|
20
|
-
switch (identityType) {
|
|
21
|
-
case IdentityType.Other:
|
|
22
|
-
return 'other';
|
|
23
|
-
case IdentityType.CustomerId:
|
|
24
|
-
return 'customerid';
|
|
25
|
-
case IdentityType.Facebook:
|
|
26
|
-
return 'facebook';
|
|
27
|
-
case IdentityType.Twitter:
|
|
28
|
-
return 'twitter';
|
|
29
|
-
case IdentityType.Google:
|
|
30
|
-
return 'google';
|
|
31
|
-
case IdentityType.Microsoft:
|
|
32
|
-
return 'microsoft';
|
|
33
|
-
case IdentityType.Yahoo:
|
|
34
|
-
return 'yahoo';
|
|
35
|
-
case IdentityType.Email:
|
|
36
|
-
return 'email';
|
|
37
|
-
case IdentityType.FacebookCustomAudienceId:
|
|
38
|
-
return 'facebookcustomaudienceid';
|
|
39
|
-
case IdentityType.Other2:
|
|
40
|
-
return 'other2';
|
|
41
|
-
case IdentityType.Other3:
|
|
42
|
-
return 'other3';
|
|
43
|
-
case IdentityType.Other4:
|
|
44
|
-
return 'other4';
|
|
45
|
-
case IdentityType.Other5:
|
|
46
|
-
return 'other5';
|
|
47
|
-
case IdentityType.Other6:
|
|
48
|
-
return 'other6';
|
|
49
|
-
case IdentityType.Other7:
|
|
50
|
-
return 'other7';
|
|
51
|
-
case IdentityType.Other8:
|
|
52
|
-
return 'other8';
|
|
53
|
-
case IdentityType.Other9:
|
|
54
|
-
return 'other9';
|
|
55
|
-
case IdentityType.Other10:
|
|
56
|
-
return 'other10';
|
|
57
|
-
case IdentityType.MobileNumber:
|
|
58
|
-
return 'mobile_number';
|
|
59
|
-
case IdentityType.PhoneNumber2:
|
|
60
|
-
return 'phone_number_2';
|
|
61
|
-
case IdentityType.PhoneNumber3:
|
|
62
|
-
return 'phone_number_3';
|
|
63
|
-
default:
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
}
|
package/src/user-utils.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { MParticleUser } from './sdkRuntimeModels';
|
|
2
|
-
|
|
3
|
-
export function didUserChange(
|
|
4
|
-
previousUser: MParticleUser,
|
|
5
|
-
newUser: MParticleUser
|
|
6
|
-
): boolean {
|
|
7
|
-
return (
|
|
8
|
-
!previousUser ||
|
|
9
|
-
newUser.getMPID() !== previousUser.getMPID() ||
|
|
10
|
-
previousUser.isLoggedIn() !== newUser.isLoggedIn()
|
|
11
|
-
);
|
|
12
|
-
}
|