@mparticle/web-sdk 2.45.0 → 2.47.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 +46 -37
- package/dist/mparticle.esm.js +46 -37
- package/dist/mparticle.js +174 -48
- package/package.json +1 -1
- package/src/batchUploader.ts +7 -2
- package/src/constants.ts +25 -0
- package/src/integrationCapture.ts +61 -28
- package/src/mp-instance.ts +24 -11
- package/src/persistence.js +14 -1
- package/src/roktManager.ts +6 -3
- package/src/sdkToEventsApiConverter.ts +8 -5
- package/src/serverModel.ts +9 -5
- package/src/store.ts +29 -12
- package/src/vault.ts +16 -0
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { SDKEventCustomFlags } from './sdkRuntimeModels';
|
|
2
|
+
import Constants from './constants';
|
|
2
3
|
import { IntegrationAttributes } from './store';
|
|
3
4
|
import {
|
|
4
5
|
Dictionary,
|
|
@@ -73,7 +74,7 @@ interface IntegrationIdMapping {
|
|
|
73
74
|
[key: string]: IntegrationMappingItem;
|
|
74
75
|
}
|
|
75
76
|
|
|
76
|
-
const
|
|
77
|
+
const integrationMappingExternal: IntegrationIdMapping = {
|
|
77
78
|
// Facebook / Meta
|
|
78
79
|
fbclid: {
|
|
79
80
|
mappedKey: 'Facebook.ClickId',
|
|
@@ -103,6 +104,25 @@ const integrationMapping: IntegrationIdMapping = {
|
|
|
103
104
|
output: IntegrationOutputs.CUSTOM_FLAGS,
|
|
104
105
|
},
|
|
105
106
|
|
|
107
|
+
// TIKTOK
|
|
108
|
+
ttclid: {
|
|
109
|
+
mappedKey: 'TikTok.Callback',
|
|
110
|
+
output: IntegrationOutputs.CUSTOM_FLAGS,
|
|
111
|
+
},
|
|
112
|
+
_ttp: {
|
|
113
|
+
mappedKey: 'tiktok_cookie_id',
|
|
114
|
+
output: IntegrationOutputs.PARTNER_IDENTITIES,
|
|
115
|
+
},
|
|
116
|
+
|
|
117
|
+
// Snapchat
|
|
118
|
+
// https://businesshelp.snapchat.com/s/article/troubleshooting-click-id?language=en_US
|
|
119
|
+
ScCid: {
|
|
120
|
+
mappedKey: 'SnapchatConversions.ClickId',
|
|
121
|
+
output: IntegrationOutputs.CUSTOM_FLAGS,
|
|
122
|
+
},
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
const integrationMappingRokt: IntegrationIdMapping = {
|
|
106
126
|
// Rokt
|
|
107
127
|
// https://docs.rokt.com/developers/integration-guides/web/advanced/rokt-id-tag/
|
|
108
128
|
// https://go.mparticle.com/work/SQDSDKS-7167
|
|
@@ -121,23 +141,6 @@ const integrationMapping: IntegrationIdMapping = {
|
|
|
121
141
|
output: IntegrationOutputs.INTEGRATION_ATTRIBUTES,
|
|
122
142
|
moduleId: 1277,
|
|
123
143
|
},
|
|
124
|
-
|
|
125
|
-
// TIKTOK
|
|
126
|
-
ttclid: {
|
|
127
|
-
mappedKey: 'TikTok.Callback',
|
|
128
|
-
output: IntegrationOutputs.CUSTOM_FLAGS,
|
|
129
|
-
},
|
|
130
|
-
_ttp: {
|
|
131
|
-
mappedKey: 'tiktok_cookie_id',
|
|
132
|
-
output: IntegrationOutputs.PARTNER_IDENTITIES,
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
// Snapchat
|
|
136
|
-
// https://businesshelp.snapchat.com/s/article/troubleshooting-click-id?language=en_US
|
|
137
|
-
ScCid: {
|
|
138
|
-
mappedKey: 'SnapchatConversions.ClickId',
|
|
139
|
-
output: IntegrationOutputs.CUSTOM_FLAGS,
|
|
140
|
-
},
|
|
141
144
|
};
|
|
142
145
|
|
|
143
146
|
export default class IntegrationCapture {
|
|
@@ -146,9 +149,11 @@ export default class IntegrationCapture {
|
|
|
146
149
|
public readonly filteredPartnerIdentityMappings: IntegrationIdMapping;
|
|
147
150
|
public readonly filteredCustomFlagMappings: IntegrationIdMapping;
|
|
148
151
|
public readonly filteredIntegrationAttributeMappings: IntegrationIdMapping;
|
|
152
|
+
public captureMode?: valueof<typeof Constants.CaptureIntegrationSpecificIdsV2Modes>;
|
|
149
153
|
|
|
150
|
-
constructor() {
|
|
154
|
+
constructor(captureMode: valueof<typeof Constants.CaptureIntegrationSpecificIdsV2Modes>) {
|
|
151
155
|
this.initialTimestamp = Date.now();
|
|
156
|
+
this.captureMode = captureMode;
|
|
152
157
|
|
|
153
158
|
// Cache filtered mappings for faster access
|
|
154
159
|
this.filteredPartnerIdentityMappings = this.filterMappings(IntegrationOutputs.PARTNER_IDENTITIES);
|
|
@@ -205,7 +210,8 @@ export default class IntegrationCapture {
|
|
|
205
210
|
* Captures cookies based on the integration ID mapping.
|
|
206
211
|
*/
|
|
207
212
|
public captureCookies(): Dictionary<string> {
|
|
208
|
-
const
|
|
213
|
+
const integrationKeys = this.getAllowedKeysForMode();
|
|
214
|
+
const cookies = getCookies(integrationKeys);
|
|
209
215
|
return this.applyProcessors(cookies, getHref(), this.initialTimestamp);
|
|
210
216
|
}
|
|
211
217
|
|
|
@@ -221,8 +227,9 @@ export default class IntegrationCapture {
|
|
|
221
227
|
* Captures local storage based on the integration ID mapping.
|
|
222
228
|
*/
|
|
223
229
|
public captureLocalStorage(): Dictionary<string> {
|
|
230
|
+
const integrationKeys = this.getAllowedKeysForMode();
|
|
224
231
|
let localStorageItems: Dictionary<string> = {};
|
|
225
|
-
for (const key
|
|
232
|
+
for (const key of integrationKeys) {
|
|
226
233
|
const localStorageItem = localStorage.getItem(key);
|
|
227
234
|
if (localStorageItem) {
|
|
228
235
|
localStorageItems[key] = localStorageItem;
|
|
@@ -237,7 +244,8 @@ export default class IntegrationCapture {
|
|
|
237
244
|
* @returns {Dictionary<string>} The query parameters.
|
|
238
245
|
*/
|
|
239
246
|
public getQueryParams(): Dictionary<string> {
|
|
240
|
-
|
|
247
|
+
const integrationKeys = this.getAllowedKeysForMode();
|
|
248
|
+
return queryStringParser(getHref(), integrationKeys);
|
|
241
249
|
}
|
|
242
250
|
|
|
243
251
|
/**
|
|
@@ -316,15 +324,15 @@ export default class IntegrationCapture {
|
|
|
316
324
|
timestamp?: number
|
|
317
325
|
): Dictionary<string> {
|
|
318
326
|
const processedClickIds: Dictionary<string> = {};
|
|
319
|
-
|
|
327
|
+
const integrationKeys = this.getActiveIntegrationMapping();
|
|
328
|
+
|
|
320
329
|
for (const key in clickIds) {
|
|
321
330
|
if (clickIds.hasOwnProperty(key)) {
|
|
322
331
|
const value = clickIds[key];
|
|
323
|
-
const processor =
|
|
332
|
+
const processor = integrationKeys[key]?.processor;
|
|
324
333
|
processedClickIds[key] = processor ? processor(value, url, timestamp) : value;
|
|
325
334
|
}
|
|
326
335
|
}
|
|
327
|
-
|
|
328
336
|
return processedClickIds;
|
|
329
337
|
}
|
|
330
338
|
|
|
@@ -332,11 +340,36 @@ export default class IntegrationCapture {
|
|
|
332
340
|
outputType: valueof<typeof IntegrationOutputs>
|
|
333
341
|
): IntegrationIdMapping {
|
|
334
342
|
const filteredMappings: IntegrationIdMapping = {};
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
343
|
+
const integrationKeys = this.getActiveIntegrationMapping();
|
|
344
|
+
for (const key in integrationKeys) {
|
|
345
|
+
if (integrationKeys[key].output === outputType) {
|
|
346
|
+
filteredMappings[key] = integrationKeys[key];
|
|
338
347
|
}
|
|
339
348
|
}
|
|
340
349
|
return filteredMappings;
|
|
341
350
|
}
|
|
351
|
+
|
|
352
|
+
/**
|
|
353
|
+
* Returns the allowed keys to capture based on the current mode.
|
|
354
|
+
* For RoktOnly, limit capture to Rokt keys; for All, capture all mapped keys.
|
|
355
|
+
*/
|
|
356
|
+
private getAllowedKeysForMode(): string[] {
|
|
357
|
+
return Object.keys(this.getActiveIntegrationMapping());
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* Selects the active integration mapping for the current captureMode.
|
|
362
|
+
* - 'roktonly': only Rokt IDs are considered
|
|
363
|
+
* - 'all': both External and Rokt IDs are considered
|
|
364
|
+
* - else: returns an empty mapping and nothing will be captured
|
|
365
|
+
*/
|
|
366
|
+
private getActiveIntegrationMapping(): IntegrationIdMapping {
|
|
367
|
+
if (this.captureMode === Constants.CaptureIntegrationSpecificIdsV2Modes.RoktOnly) {
|
|
368
|
+
return integrationMappingRokt;
|
|
369
|
+
}
|
|
370
|
+
if (this.captureMode === Constants.CaptureIntegrationSpecificIdsV2Modes.All) {
|
|
371
|
+
return { ...integrationMappingExternal, ...integrationMappingRokt };
|
|
372
|
+
}
|
|
373
|
+
return {};
|
|
374
|
+
}
|
|
342
375
|
}
|
package/src/mp-instance.ts
CHANGED
|
@@ -36,8 +36,8 @@ import Consent, { IConsent } from './consent';
|
|
|
36
36
|
import KitBlocker from './kitBlocking';
|
|
37
37
|
import ConfigAPIClient, { IKitConfigs } from './configAPIClient';
|
|
38
38
|
import IdentityAPIClient from './identityApiClient';
|
|
39
|
-
import { isFunction, parseConfig } from './utils';
|
|
40
|
-
import { LocalStorageVault } from './vault';
|
|
39
|
+
import { isFunction, parseConfig, valueof } from './utils';
|
|
40
|
+
import { DisabledVault, LocalStorageVault } from './vault';
|
|
41
41
|
import { removeExpiredIdentityCacheDates } from './identity-utils';
|
|
42
42
|
import IntegrationCapture from './integrationCapture';
|
|
43
43
|
import { IPreInit, processReadyQueue } from './pre-init-utils';
|
|
@@ -91,8 +91,8 @@ export interface IMParticleWebSDKInstance extends MParticleWebSDK {
|
|
|
91
91
|
_timeOnSiteTimer: ForegroundTimer;
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
const { Messages, HTTPCodes, FeatureFlags } = Constants;
|
|
95
|
-
const { ReportBatching, CaptureIntegrationSpecificIds } = FeatureFlags;
|
|
94
|
+
const { Messages, HTTPCodes, FeatureFlags, CaptureIntegrationSpecificIdsV2Modes } = Constants;
|
|
95
|
+
const { ReportBatching, CaptureIntegrationSpecificIds, CaptureIntegrationSpecificIdsV2 } = FeatureFlags;
|
|
96
96
|
const { StartingInitialization } = Messages.InformationMessages;
|
|
97
97
|
|
|
98
98
|
/**
|
|
@@ -128,7 +128,6 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
128
128
|
integrationDelays: {},
|
|
129
129
|
forwarderConstructors: [],
|
|
130
130
|
};
|
|
131
|
-
this._IntegrationCapture = new IntegrationCapture();
|
|
132
131
|
this._RoktManager = new RoktManager();
|
|
133
132
|
|
|
134
133
|
// required for forwarders once they reference the mparticle instance
|
|
@@ -1354,6 +1353,7 @@ export default function mParticleInstance(this: IMParticleWebSDKInstance, instan
|
|
|
1354
1353
|
// Some (server) config settings need to be returned before they are set on SDKConfig in a self hosted environment
|
|
1355
1354
|
function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
1356
1355
|
const kitBlocker = createKitBlocker(config, mpInstance);
|
|
1356
|
+
const { getFeatureFlag } = mpInstance._Helpers;
|
|
1357
1357
|
|
|
1358
1358
|
mpInstance._APIClient = new APIClient(mpInstance, kitBlocker);
|
|
1359
1359
|
mpInstance._Forwarders = new Forwarders(mpInstance, kitBlocker);
|
|
@@ -1386,11 +1386,22 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
|
|
|
1386
1386
|
? { userIdentities: currentUserIdentities }
|
|
1387
1387
|
: mpInstance._Store.SDKConfig.identifyRequest;
|
|
1388
1388
|
|
|
1389
|
-
if (
|
|
1389
|
+
if (getFeatureFlag(ReportBatching)) {
|
|
1390
1390
|
mpInstance._ForwardingStatsUploader.startForwardingStatsTimer();
|
|
1391
1391
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1392
|
+
// https://go.mparticle.com/work/SQDSDKS-7639
|
|
1393
|
+
const integrationSpecificIds = getFeatureFlag(CaptureIntegrationSpecificIds) as boolean;
|
|
1394
|
+
const integrationSpecificIdsV2 = getFeatureFlag(CaptureIntegrationSpecificIdsV2) as string;
|
|
1395
|
+
|
|
1396
|
+
const isIntegrationCaptureEnabled = (integrationSpecificIdsV2 && integrationSpecificIdsV2 !== CaptureIntegrationSpecificIdsV2Modes.None) || integrationSpecificIds === true;
|
|
1397
|
+
if (isIntegrationCaptureEnabled) {
|
|
1398
|
+
let captureMode: valueof<typeof CaptureIntegrationSpecificIdsV2Modes> | undefined;
|
|
1399
|
+
if (integrationSpecificIds || integrationSpecificIdsV2 === CaptureIntegrationSpecificIdsV2Modes.All) {
|
|
1400
|
+
captureMode = 'all';
|
|
1401
|
+
} else if (integrationSpecificIdsV2 === CaptureIntegrationSpecificIdsV2Modes.RoktOnly) {
|
|
1402
|
+
captureMode = 'roktonly';
|
|
1403
|
+
}
|
|
1404
|
+
mpInstance._IntegrationCapture = new IntegrationCapture(captureMode);
|
|
1394
1405
|
mpInstance._IntegrationCapture.capture();
|
|
1395
1406
|
}
|
|
1396
1407
|
|
|
@@ -1523,9 +1534,11 @@ function createKitBlocker(config, mpInstance) {
|
|
|
1523
1534
|
}
|
|
1524
1535
|
|
|
1525
1536
|
function createIdentityCache(mpInstance) {
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1537
|
+
const cacheKey = `${mpInstance._Store.storageName}-id-cache`;
|
|
1538
|
+
if (mpInstance._Store.getPrivacyFlag('IdentityCache')) {
|
|
1539
|
+
return new DisabledVault(cacheKey, { logger: mpInstance.Logger });
|
|
1540
|
+
}
|
|
1541
|
+
return new LocalStorageVault(cacheKey, { logger: mpInstance.Logger });
|
|
1529
1542
|
}
|
|
1530
1543
|
|
|
1531
1544
|
function runPreConfigFetchInitialization(mpInstance, apiKey, config) {
|
package/src/persistence.js
CHANGED
|
@@ -35,6 +35,10 @@ export default function _Persistence(mpInstance) {
|
|
|
35
35
|
mpInstance._Store.isFirstRun = false;
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
|
|
39
|
+
return;
|
|
40
|
+
}
|
|
41
|
+
|
|
38
42
|
// https://go.mparticle.com/work/SQDSDKS-6045
|
|
39
43
|
if (!mpInstance._Store.isLocalStorageAvailable) {
|
|
40
44
|
mpInstance._Store.SDKConfig.useCookieStorage = true;
|
|
@@ -142,7 +146,10 @@ export default function _Persistence(mpInstance) {
|
|
|
142
146
|
};
|
|
143
147
|
|
|
144
148
|
this.update = function() {
|
|
145
|
-
if (
|
|
149
|
+
if (
|
|
150
|
+
!mpInstance._Store.webviewBridgeEnabled &&
|
|
151
|
+
!mpInstance._Store.getPrivacyFlag('SDKState')
|
|
152
|
+
) {
|
|
146
153
|
if (mpInstance._Store.SDKConfig.useCookieStorage) {
|
|
147
154
|
self.setCookie();
|
|
148
155
|
}
|
|
@@ -962,6 +969,9 @@ export default function _Persistence(mpInstance) {
|
|
|
962
969
|
|
|
963
970
|
// https://go.mparticle.com/work/SQDSDKS-6021
|
|
964
971
|
this.savePersistence = function(persistence) {
|
|
972
|
+
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
|
|
973
|
+
return;
|
|
974
|
+
}
|
|
965
975
|
var encodedPersistence = self.encodePersistence(
|
|
966
976
|
JSON.stringify(persistence)
|
|
967
977
|
),
|
|
@@ -1006,6 +1016,9 @@ export default function _Persistence(mpInstance) {
|
|
|
1006
1016
|
};
|
|
1007
1017
|
|
|
1008
1018
|
this.getPersistence = function() {
|
|
1019
|
+
if (mpInstance._Store.getPrivacyFlag('SDKState')) {
|
|
1020
|
+
return null;
|
|
1021
|
+
}
|
|
1009
1022
|
var persistence = this.useLocalStorage()
|
|
1010
1023
|
? this.getLocalStorage()
|
|
1011
1024
|
: this.getCookie();
|
package/src/roktManager.ts
CHANGED
|
@@ -319,15 +319,15 @@ export default class RoktManager {
|
|
|
319
319
|
this.logger?.verbose(`RoktManager: Processing ${this.messageQueue.size} queued messages`);
|
|
320
320
|
|
|
321
321
|
this.messageQueue.forEach((message) => {
|
|
322
|
-
if(!(message.methodName in this
|
|
323
|
-
this.logger?.error(`RoktManager: Method ${message.methodName} not found
|
|
322
|
+
if(!(message.methodName in this) || !isFunction(this[message.methodName])) {
|
|
323
|
+
this.logger?.error(`RoktManager: Method ${message.methodName} not found`);
|
|
324
324
|
return;
|
|
325
325
|
}
|
|
326
326
|
|
|
327
327
|
this.logger?.verbose(`RoktManager: Processing queued message: ${message.methodName} with payload: ${JSON.stringify(message.payload)}`);
|
|
328
328
|
|
|
329
329
|
try {
|
|
330
|
-
const result = (this
|
|
330
|
+
const result = (this[message.methodName] as Function)(message.payload);
|
|
331
331
|
this.completePendingPromise(message.messageId, result);
|
|
332
332
|
} catch (error) {
|
|
333
333
|
const errorMessage = error instanceof Error ? error.message : String(error);
|
|
@@ -335,6 +335,9 @@ export default class RoktManager {
|
|
|
335
335
|
this.completePendingPromise(message.messageId, Promise.reject(error));
|
|
336
336
|
}
|
|
337
337
|
});
|
|
338
|
+
|
|
339
|
+
// Clear the queue after processing all messages
|
|
340
|
+
this.messageQueue.clear();
|
|
338
341
|
}
|
|
339
342
|
|
|
340
343
|
private queueMessage(message: IRoktMessage): void {
|
|
@@ -18,11 +18,10 @@ import { SDKIdentityTypeEnum } from './identity.interfaces';
|
|
|
18
18
|
import Constants from './constants';
|
|
19
19
|
import { IMParticleWebSDKInstance } from './mp-instance';
|
|
20
20
|
|
|
21
|
-
const {
|
|
22
|
-
FeatureFlags
|
|
23
|
-
} = Constants;
|
|
21
|
+
const { FeatureFlags } = Constants;
|
|
24
22
|
const {
|
|
25
|
-
CaptureIntegrationSpecificIds
|
|
23
|
+
CaptureIntegrationSpecificIds,
|
|
24
|
+
CaptureIntegrationSpecificIdsV2,
|
|
26
25
|
} = FeatureFlags;
|
|
27
26
|
|
|
28
27
|
type PartnerIdentities = Dictionary<string>;
|
|
@@ -127,8 +126,12 @@ export function convertEvents(
|
|
|
127
126
|
},
|
|
128
127
|
};
|
|
129
128
|
}
|
|
129
|
+
// https://go.mparticle.com/work/SQDSDKS-7639
|
|
130
|
+
const integrationSpecificIds = getFeatureFlag && Boolean(getFeatureFlag(CaptureIntegrationSpecificIds));
|
|
131
|
+
const integrationSpecificIdsV2 = getFeatureFlag && (getFeatureFlag(CaptureIntegrationSpecificIdsV2) as string);
|
|
132
|
+
|
|
133
|
+
const isIntegrationCaptureEnabled = (integrationSpecificIdsV2 && integrationSpecificIdsV2 !== Constants.CaptureIntegrationSpecificIdsV2Modes.None) || integrationSpecificIds === true;
|
|
130
134
|
|
|
131
|
-
const isIntegrationCaptureEnabled: boolean = getFeatureFlag && Boolean(getFeatureFlag(CaptureIntegrationSpecificIds));
|
|
132
135
|
if (isIntegrationCaptureEnabled) {
|
|
133
136
|
const capturedPartnerIdentities: PartnerIdentities = _IntegrationCapture?.getClickIdsAsPartnerIdentities();
|
|
134
137
|
if (!isEmpty(capturedPartnerIdentities)) {
|
package/src/serverModel.ts
CHANGED
|
@@ -276,18 +276,22 @@ export default function ServerModel(
|
|
|
276
276
|
let customFlags: SDKEventCustomFlags = {...event.customFlags};
|
|
277
277
|
let integrationAttributes: IntegrationAttributes = mpInstance._Store.integrationAttributes;
|
|
278
278
|
|
|
279
|
+
const { getFeatureFlag } = mpInstance._Helpers;
|
|
279
280
|
// https://go.mparticle.com/work/SQDSDKS-5053
|
|
280
|
-
|
|
281
|
-
|
|
281
|
+
// https://go.mparticle.com/work/SQDSDKS-7639
|
|
282
|
+
const integrationSpecificIds = getFeatureFlag && (getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIds) as boolean);
|
|
283
|
+
const integrationSpecificIdsV2 = getFeatureFlag && ((getFeatureFlag(Constants.FeatureFlags.CaptureIntegrationSpecificIdsV2) as string) || '');
|
|
284
|
+
const isIntegrationCaptureEnabled = (integrationSpecificIdsV2 && integrationSpecificIdsV2 !== Constants.CaptureIntegrationSpecificIdsV2Modes.None) || integrationSpecificIds === true;
|
|
285
|
+
if (isIntegrationCaptureEnabled) {
|
|
282
286
|
// Attempt to recapture click IDs in case a third party integration
|
|
283
287
|
// has added or updated new click IDs since the last event was sent.
|
|
284
288
|
mpInstance._IntegrationCapture.capture();
|
|
285
289
|
const transformedClickIDs = mpInstance._IntegrationCapture.getClickIdsAsCustomFlags();
|
|
286
|
-
customFlags = {...transformedClickIDs, ...customFlags};
|
|
287
|
-
|
|
290
|
+
customFlags = { ...transformedClickIDs, ...customFlags };
|
|
288
291
|
const transformedIntegrationAttributes = mpInstance._IntegrationCapture.getClickIdsAsIntegrationAttributes();
|
|
289
|
-
integrationAttributes = {...transformedIntegrationAttributes, ...integrationAttributes};
|
|
292
|
+
integrationAttributes = { ...transformedIntegrationAttributes, ...integrationAttributes };
|
|
290
293
|
}
|
|
294
|
+
|
|
291
295
|
|
|
292
296
|
if (event.hasOwnProperty('toEventAPIObject')) {
|
|
293
297
|
eventObject = event.toEventAPIObject();
|
package/src/store.ts
CHANGED
|
@@ -8,7 +8,7 @@ import {
|
|
|
8
8
|
UserIdentities,
|
|
9
9
|
} from '@mparticle/web-sdk';
|
|
10
10
|
import { IKitConfigs } from './configAPIClient';
|
|
11
|
-
import Constants from './constants';
|
|
11
|
+
import Constants, { PrivacyControl, StoragePrivacyMap, StorageTypes } from './constants';
|
|
12
12
|
import {
|
|
13
13
|
DataPlanResult,
|
|
14
14
|
KitBlockerOptions,
|
|
@@ -145,6 +145,7 @@ export interface IFeatureFlags {
|
|
|
145
145
|
directURLRouting?: boolean;
|
|
146
146
|
cacheIdentity?: boolean;
|
|
147
147
|
captureIntegrationSpecificIds?: boolean;
|
|
148
|
+
captureIntegrationSpecificIdsV2?: string;
|
|
148
149
|
astBackgroundEvents?: boolean;
|
|
149
150
|
}
|
|
150
151
|
|
|
@@ -215,6 +216,7 @@ export interface IStore {
|
|
|
215
216
|
setNoFunctional?(noFunctional: boolean): void;
|
|
216
217
|
getNoTargeting?(): boolean;
|
|
217
218
|
setNoTargeting?(noTargeting: boolean): void;
|
|
219
|
+
getPrivacyFlag?(storageType: StorageTypes): boolean;
|
|
218
220
|
|
|
219
221
|
getDeviceId?(): string;
|
|
220
222
|
setDeviceId?(deviceId: string): void;
|
|
@@ -607,6 +609,17 @@ export default function Store(
|
|
|
607
609
|
this.noTargeting = noTargeting;
|
|
608
610
|
};
|
|
609
611
|
|
|
612
|
+
this.getPrivacyFlag = (storageType: StorageTypes): boolean => {
|
|
613
|
+
const privacyControl: PrivacyControl = StoragePrivacyMap[storageType];
|
|
614
|
+
if (privacyControl === 'functional') {
|
|
615
|
+
return this.getNoFunctional();
|
|
616
|
+
}
|
|
617
|
+
if (privacyControl === 'targeting') {
|
|
618
|
+
return this.getNoTargeting();
|
|
619
|
+
}
|
|
620
|
+
return false;
|
|
621
|
+
};
|
|
622
|
+
|
|
610
623
|
this.getDeviceId = () => this.deviceId;
|
|
611
624
|
this.setDeviceId = (deviceId: string) => {
|
|
612
625
|
this.deviceId = deviceId;
|
|
@@ -727,9 +740,21 @@ export default function Store(
|
|
|
727
740
|
this.SDKConfig[baseUrlKeys] = baseUrls[baseUrlKeys];
|
|
728
741
|
}
|
|
729
742
|
|
|
743
|
+
const { noFunctional, noTargeting } = config?.launcherOptions ?? {};
|
|
744
|
+
|
|
745
|
+
if (noFunctional != null) {
|
|
746
|
+
this.setNoFunctional(noFunctional);
|
|
747
|
+
}
|
|
748
|
+
|
|
749
|
+
if (noTargeting != null) {
|
|
750
|
+
this.setNoTargeting(noTargeting);
|
|
751
|
+
}
|
|
752
|
+
|
|
730
753
|
if (workspaceToken) {
|
|
731
754
|
this.SDKConfig.workspaceToken = workspaceToken;
|
|
732
|
-
|
|
755
|
+
if (!this.getPrivacyFlag('TimeOnSite')) {
|
|
756
|
+
mpInstance._timeOnSiteTimer = new ForegroundTimer(workspaceToken);
|
|
757
|
+
}
|
|
733
758
|
} else {
|
|
734
759
|
mpInstance.Logger.warning(
|
|
735
760
|
'You should have a workspaceToken on your config object for security purposes.'
|
|
@@ -739,15 +764,6 @@ export default function Store(
|
|
|
739
764
|
this.storageName = createMainStorageName(workspaceToken);
|
|
740
765
|
this.prodStorageName = createProductStorageName(workspaceToken);
|
|
741
766
|
|
|
742
|
-
// Extract privacy flags directly from config into Store
|
|
743
|
-
if (config.hasOwnProperty('noFunctional')) {
|
|
744
|
-
this.setNoFunctional(config.noFunctional);
|
|
745
|
-
}
|
|
746
|
-
|
|
747
|
-
if (config.hasOwnProperty('noTargeting')) {
|
|
748
|
-
this.setNoTargeting(config.noTargeting);
|
|
749
|
-
}
|
|
750
|
-
|
|
751
767
|
this.SDKConfig.requiredWebviewBridgeName =
|
|
752
768
|
requiredWebviewBridgeName || workspaceToken;
|
|
753
769
|
|
|
@@ -771,6 +787,7 @@ export function processFlags(config: SDKInitConfig): IFeatureFlags {
|
|
|
771
787
|
CacheIdentity,
|
|
772
788
|
AudienceAPI,
|
|
773
789
|
CaptureIntegrationSpecificIds,
|
|
790
|
+
CaptureIntegrationSpecificIdsV2,
|
|
774
791
|
AstBackgroundEvents
|
|
775
792
|
} = Constants.FeatureFlags;
|
|
776
793
|
|
|
@@ -790,8 +807,8 @@ export function processFlags(config: SDKInitConfig): IFeatureFlags {
|
|
|
790
807
|
flags[CacheIdentity] = config.flags[CacheIdentity] === 'True';
|
|
791
808
|
flags[AudienceAPI] = config.flags[AudienceAPI] === 'True';
|
|
792
809
|
flags[CaptureIntegrationSpecificIds] = config.flags[CaptureIntegrationSpecificIds] === 'True';
|
|
810
|
+
flags[CaptureIntegrationSpecificIdsV2] = (config.flags[CaptureIntegrationSpecificIdsV2] || 'none');
|
|
793
811
|
flags[AstBackgroundEvents] = config.flags[AstBackgroundEvents] === 'True';
|
|
794
|
-
|
|
795
812
|
return flags;
|
|
796
813
|
}
|
|
797
814
|
|
package/src/vault.ts
CHANGED
|
@@ -102,4 +102,20 @@ export class SessionStorageVault<StorableItem> extends BaseVault<StorableItem> {
|
|
|
102
102
|
constructor(storageKey: string, options?: IVaultOptions) {
|
|
103
103
|
super(storageKey, window.sessionStorage, options);
|
|
104
104
|
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// DisabledVault is used when persistence is disabled by privacy flags.
|
|
108
|
+
export class DisabledVault<StorableItem> extends BaseVault<StorableItem> {
|
|
109
|
+
constructor(storageKey: string, options?: IVaultOptions) {
|
|
110
|
+
super(storageKey, window.localStorage, options);
|
|
111
|
+
this.contents = null;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
public store(_item: StorableItem): void {
|
|
115
|
+
this.contents = null;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
public retrieve(): StorableItem | null {
|
|
119
|
+
return this.contents;
|
|
120
|
+
}
|
|
105
121
|
}
|