@mparticle/web-sdk 3.13.0 → 3.15.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.
- package/dist/mparticle.common.js +66 -67
- package/dist/mparticle.esm.js +66 -67
- package/dist/mparticle.js +2459 -2469
- package/dist/types/src/integrationCapture.d.ts +1 -0
- package/package.json +1 -1
- package/src/batchUploader.ts +2 -4
- package/src/integrationCapture.ts +20 -0
- package/src/kitBlocking.ts +7 -3
- package/src/mp-instance.ts +4 -6
- package/src/persistence.ts +18 -29
- package/src/sdkToEventsApiConverter.ts +2 -13
- package/src/serverModel.ts +2 -4
|
@@ -20,6 +20,7 @@ interface IntegrationMappingItem {
|
|
|
20
20
|
interface IntegrationIdMapping {
|
|
21
21
|
[key: string]: IntegrationMappingItem;
|
|
22
22
|
}
|
|
23
|
+
export declare function isIntegrationCaptureEnabled(getFeatureFlag: (feature: string) => unknown): boolean;
|
|
23
24
|
export default class IntegrationCapture {
|
|
24
25
|
clickIds: Dictionary<string>;
|
|
25
26
|
readonly initialTimestamp: number;
|
package/package.json
CHANGED
package/src/batchUploader.ts
CHANGED
|
@@ -15,6 +15,7 @@ import { IMParticleUser } from './identity-user-interfaces';
|
|
|
15
15
|
import { IMParticleWebSDKInstance } from './mp-instance';
|
|
16
16
|
import { appendUserInfo } from './user-utils';
|
|
17
17
|
import { IntegrationAttributes } from './store';
|
|
18
|
+
import { isIntegrationCaptureEnabled } from './integrationCapture';
|
|
18
19
|
/**
|
|
19
20
|
* BatchUploader contains all the logic to store/retrieve events and batches
|
|
20
21
|
* to/from persistence, and upload batches to mParticle.
|
|
@@ -205,12 +206,9 @@ export class BatchUploader {
|
|
|
205
206
|
|
|
206
207
|
let customFlags: SDKEventCustomFlags = {...event.CustomFlags};
|
|
207
208
|
let integrationAttributes: IntegrationAttributes = _Store.integrationAttributes;
|
|
208
|
-
const integrationSpecificIds = getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIds) as boolean;
|
|
209
|
-
const integrationSpecificIdsV2 = getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIdsV2) as string || '';
|
|
210
|
-
const isIntegrationCaptureEnabled = (integrationSpecificIdsV2 && integrationSpecificIdsV2 !== Constants.CaptureIntegrationSpecificIdsV2Modes.None) || integrationSpecificIds === true;
|
|
211
209
|
|
|
212
210
|
// https://go.mparticle.com/work/SQDSDKS-5053
|
|
213
|
-
if (isIntegrationCaptureEnabled) {
|
|
211
|
+
if (isIntegrationCaptureEnabled(getFeatureFlag)) {
|
|
214
212
|
|
|
215
213
|
// Attempt to recapture click IDs in case a third party integration
|
|
216
214
|
// has added or updated new click IDs since the last event was sent.
|
|
@@ -160,6 +160,26 @@ const integrationMappingRokt: IntegrationIdMapping = {
|
|
|
160
160
|
},
|
|
161
161
|
};
|
|
162
162
|
|
|
163
|
+
export function isIntegrationCaptureEnabled(
|
|
164
|
+
getFeatureFlag: (feature: string) => unknown
|
|
165
|
+
): boolean {
|
|
166
|
+
if (!getFeatureFlag) {
|
|
167
|
+
return false;
|
|
168
|
+
}
|
|
169
|
+
const integrationSpecificIds = getFeatureFlag(
|
|
170
|
+
Constants.FeatureFlags.CaptureIntegrationSpecificIds
|
|
171
|
+
);
|
|
172
|
+
const integrationSpecificIdsV2 = getFeatureFlag(
|
|
173
|
+
Constants.FeatureFlags.CaptureIntegrationSpecificIdsV2
|
|
174
|
+
);
|
|
175
|
+
return (
|
|
176
|
+
(!!integrationSpecificIdsV2 &&
|
|
177
|
+
integrationSpecificIdsV2 !==
|
|
178
|
+
Constants.CaptureIntegrationSpecificIdsV2Modes.None) ||
|
|
179
|
+
integrationSpecificIds === true
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
|
|
163
183
|
export default class IntegrationCapture {
|
|
164
184
|
public clickIds: Dictionary<string>;
|
|
165
185
|
public readonly initialTimestamp: number;
|
package/src/kitBlocking.ts
CHANGED
|
@@ -390,10 +390,14 @@ export default class KitBlocker {
|
|
|
390
390
|
return clonedEvent;
|
|
391
391
|
}
|
|
392
392
|
if (matchedEvent) {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
393
|
+
if (clonedEvent.EventAttributes) {
|
|
394
|
+
const plannedEventAttributes = {};
|
|
395
|
+
for (const key of Object.keys(clonedEvent.EventAttributes)) {
|
|
396
|
+
if (matchedEvent[key] === true) {
|
|
397
|
+
plannedEventAttributes[key] = clonedEvent.EventAttributes[key];
|
|
398
|
+
}
|
|
396
399
|
}
|
|
400
|
+
clonedEvent.EventAttributes = plannedEventAttributes;
|
|
397
401
|
}
|
|
398
402
|
return clonedEvent;
|
|
399
403
|
} else {
|
package/src/mp-instance.ts
CHANGED
|
@@ -42,7 +42,7 @@ import IdentityAPIClient, { IIdentityApiClient } from './identityApiClient';
|
|
|
42
42
|
import { isFunction, parseConfig, valueof, generateDeprecationMessage, extend } from './utils';
|
|
43
43
|
import { DisabledVault, LocalStorageVault } from './vault';
|
|
44
44
|
import { removeExpiredIdentityCacheDates, hasExplicitIdentifier } from './identity-utils';
|
|
45
|
-
import IntegrationCapture from './integrationCapture';
|
|
45
|
+
import IntegrationCapture, { isIntegrationCaptureEnabled } from './integrationCapture';
|
|
46
46
|
import { IPreInit, processReadyQueue } from './pre-init-utils';
|
|
47
47
|
import { BaseEvent, MParticleWebSDK, SDKHelpersApi } from './sdkRuntimeModels';
|
|
48
48
|
import { Dictionary, SDKEventAttrs } from '@mparticle/web-sdk';
|
|
@@ -1389,11 +1389,9 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
|
1389
1389
|
mpInstance._ForwardingStatsUploader.startForwardingStatsTimer();
|
|
1390
1390
|
}
|
|
1391
1391
|
// https://go.mparticle.com/work/SQDSDKS-7639
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
const isIntegrationCaptureEnabled = (integrationSpecificIdsV2 && integrationSpecificIdsV2 !== CaptureIntegrationSpecificIdsV2Modes.None) || integrationSpecificIds === true;
|
|
1396
|
-
if (isIntegrationCaptureEnabled) {
|
|
1392
|
+
if (isIntegrationCaptureEnabled(getFeatureFlag)) {
|
|
1393
|
+
const integrationSpecificIds = getFeatureFlag(CaptureIntegrationSpecificIds) as boolean;
|
|
1394
|
+
const integrationSpecificIdsV2 = getFeatureFlag(CaptureIntegrationSpecificIdsV2) as string;
|
|
1397
1395
|
let captureMode: valueof<typeof CaptureIntegrationSpecificIdsV2Modes> | undefined;
|
|
1398
1396
|
if (integrationSpecificIds || integrationSpecificIdsV2 === CaptureIntegrationSpecificIdsV2Modes.All) {
|
|
1399
1397
|
captureMode = 'all';
|
package/src/persistence.ts
CHANGED
|
@@ -362,36 +362,28 @@ export default function _Persistence(
|
|
|
362
362
|
return data;
|
|
363
363
|
}
|
|
364
364
|
|
|
365
|
-
|
|
366
|
-
|
|
365
|
+
function parsePersistenceRecord(
|
|
366
|
+
raw: string | null
|
|
367
|
+
): IPersistenceMinified | null {
|
|
368
|
+
const decoded = self.decodePersistence(raw);
|
|
369
|
+
if (!decoded) {
|
|
367
370
|
return null;
|
|
368
371
|
}
|
|
372
|
+
const record = JSON.parse(decoded);
|
|
373
|
+
return mpInstance._Helpers.isObject(record) &&
|
|
374
|
+
Object.keys(record).length
|
|
375
|
+
? (record as IPersistenceMinified)
|
|
376
|
+
: null;
|
|
377
|
+
}
|
|
369
378
|
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
window.localStorage.getItem(key)
|
|
373
|
-
);
|
|
374
|
-
|
|
375
|
-
if (!decodedPersistence) {
|
|
379
|
+
this.getLocalStorage = function(): IPersistenceMinified | null {
|
|
380
|
+
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
376
381
|
return null;
|
|
377
382
|
}
|
|
378
383
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
)
|
|
382
|
-
const obj: IPersistenceMinified = {} as IPersistenceMinified;
|
|
383
|
-
|
|
384
|
-
for (const key in parsedPersistence) {
|
|
385
|
-
if (parsedPersistence.hasOwnProperty(key)) {
|
|
386
|
-
obj[key] = parsedPersistence[key];
|
|
387
|
-
}
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
if (Object.keys(obj).length) {
|
|
391
|
-
return obj;
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
return null;
|
|
384
|
+
return parsePersistenceRecord(
|
|
385
|
+
window.localStorage.getItem(mpInstance._Store.storageName)
|
|
386
|
+
);
|
|
395
387
|
};
|
|
396
388
|
|
|
397
389
|
this.expireCookies = function(cookieName: string): void {
|
|
@@ -443,14 +435,11 @@ export default function _Persistence(
|
|
|
443
435
|
}
|
|
444
436
|
|
|
445
437
|
if (key && key === name) {
|
|
446
|
-
const
|
|
438
|
+
const persistence = parsePersistenceRecord(
|
|
447
439
|
(mpInstance._Helpers as Dictionary).converted(cookie)
|
|
448
440
|
);
|
|
449
|
-
const persistence = decodedPersistence
|
|
450
|
-
? JSON.parse(decodedPersistence)
|
|
451
|
-
: null;
|
|
452
441
|
|
|
453
|
-
if (
|
|
442
|
+
if (persistence) {
|
|
454
443
|
mpInstance.Logger.verbose(
|
|
455
444
|
Messages.InformationMessages.CookieFound
|
|
456
445
|
);
|
|
@@ -15,14 +15,8 @@ import Types, { getEventCategoryFromCustomEventType } from './types';
|
|
|
15
15
|
import { Dictionary, isEmpty } from './utils';
|
|
16
16
|
import { ISDKUserIdentity } from './identity-user-interfaces';
|
|
17
17
|
import { SDKIdentityTypeEnum } from './identity.interfaces';
|
|
18
|
-
import Constants from './constants';
|
|
19
18
|
import { IMParticleWebSDKInstance } from './mp-instance';
|
|
20
|
-
|
|
21
|
-
const { FeatureFlags } = Constants;
|
|
22
|
-
const {
|
|
23
|
-
CaptureIntegrationSpecificIds,
|
|
24
|
-
CaptureIntegrationSpecificIdsV2,
|
|
25
|
-
} = FeatureFlags;
|
|
19
|
+
import { isIntegrationCaptureEnabled } from './integrationCapture';
|
|
26
20
|
|
|
27
21
|
type PartnerIdentities = Dictionary<string>;
|
|
28
22
|
|
|
@@ -127,12 +121,7 @@ export function convertEvents(
|
|
|
127
121
|
};
|
|
128
122
|
}
|
|
129
123
|
// https://go.mparticle.com/work/SQDSDKS-7639
|
|
130
|
-
|
|
131
|
-
const integrationSpecificIdsV2 = getFeatureFlag && (getFeatureFlag(CaptureIntegrationSpecificIdsV2) as string);
|
|
132
|
-
|
|
133
|
-
const isIntegrationCaptureEnabled = (integrationSpecificIdsV2 && integrationSpecificIdsV2 !== Constants.CaptureIntegrationSpecificIdsV2Modes.None) || integrationSpecificIds === true;
|
|
134
|
-
|
|
135
|
-
if (isIntegrationCaptureEnabled) {
|
|
124
|
+
if (isIntegrationCaptureEnabled(getFeatureFlag)) {
|
|
136
125
|
_IntegrationCapture?.capture();
|
|
137
126
|
const capturedPartnerIdentities: PartnerIdentities = _IntegrationCapture?.getClickIdsAsPartnerIdentities();
|
|
138
127
|
if (!isEmpty(capturedPartnerIdentities)) {
|
package/src/serverModel.ts
CHANGED
|
@@ -30,6 +30,7 @@ import {
|
|
|
30
30
|
import { IMParticleUser, ISDKUserIdentity } from './identity-user-interfaces';
|
|
31
31
|
import { IMParticleWebSDKInstance } from './mp-instance';
|
|
32
32
|
import { appendUserInfo } from './user-utils';
|
|
33
|
+
import { isIntegrationCaptureEnabled } from './integrationCapture';
|
|
33
34
|
|
|
34
35
|
const MessageType = Types.MessageType;
|
|
35
36
|
const ApplicationTransitionType = Types.ApplicationTransitionType;
|
|
@@ -281,10 +282,7 @@ export default function ServerModel(
|
|
|
281
282
|
const { getFeatureFlag } = mpInstance._Helpers;
|
|
282
283
|
// https://go.mparticle.com/work/SQDSDKS-5053
|
|
283
284
|
// https://go.mparticle.com/work/SQDSDKS-7639
|
|
284
|
-
|
|
285
|
-
const integrationSpecificIdsV2 = getFeatureFlag && ((getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIdsV2) as string) || '');
|
|
286
|
-
const isIntegrationCaptureEnabled = (integrationSpecificIdsV2 && integrationSpecificIdsV2 !== Constants.CaptureIntegrationSpecificIdsV2Modes.None) || integrationSpecificIds === true;
|
|
287
|
-
if (isIntegrationCaptureEnabled) {
|
|
285
|
+
if (isIntegrationCaptureEnabled(getFeatureFlag)) {
|
|
288
286
|
// Attempt to recapture click IDs in case a third party integration
|
|
289
287
|
// has added or updated new click IDs since the last event was sent.
|
|
290
288
|
mpInstance._IntegrationCapture.capture();
|