Skip to content

Commit 688c5ce

Browse files
committed
fix: source privacy flags from launcherOptions
1 parent eba8f11 commit 688c5ce

5 files changed

Lines changed: 16 additions & 26 deletions

File tree

src/store.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -740,13 +740,13 @@ export default function Store(
740740
this.SDKConfig[baseUrlKeys] = baseUrls[baseUrlKeys];
741741
}
742742

743-
// Extract privacy flags directly from config into Store BEFORE initializing timers
744-
if (config.hasOwnProperty('noFunctional')) {
745-
this.setNoFunctional(config.noFunctional);
743+
// Extract privacy flags exclusively from launcherOptions
744+
const launcherOptions = config.launcherOptions;
745+
if (launcherOptions && launcherOptions.hasOwnProperty('noFunctional')) {
746+
this.setNoFunctional(launcherOptions.noFunctional);
746747
}
747-
748-
if (config.hasOwnProperty('noTargeting')) {
749-
this.setNoTargeting(config.noTargeting);
748+
if (launcherOptions && launcherOptions.hasOwnProperty('noTargeting')) {
749+
this.setNoTargeting(launcherOptions.noTargeting);
750750
}
751751

752752
if (workspaceToken) {

test/jest/foregroundTimeTracker.spec.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -541,13 +541,13 @@ describe('ForegroundTimeTracker', () => {
541541
});
542542

543543
it('should NOT track time on site when noTargeting is true', () => {
544-
store.processConfig({ workspaceToken, noTargeting: true } as SDKInitConfig);
544+
store.processConfig({ workspaceToken, launcherOptions: { noTargeting: true } } as SDKInitConfig);
545545
expect(mockMPInstance._timeOnSiteTimer).toBeUndefined();
546546
expect(localStorage.getItem(tosKey)).toBeNull();
547547
});
548548

549549
it('should track time on site when noTargeting is false', () => {
550-
store.processConfig({ workspaceToken, noTargeting: false } as SDKInitConfig);
550+
store.processConfig({ workspaceToken, launcherOptions: { noTargeting: false } } as SDKInitConfig);
551551
expect(mockMPInstance._timeOnSiteTimer).toBeDefined();
552552
jest.advanceTimersByTime(1000);
553553
mockMPInstance._timeOnSiteTimer.getTimeInForeground();

test/jest/store.flags.spec.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -46,39 +46,30 @@ describe('Store privacy flags', () => {
4646

4747
it('should set noFunctional as true and noTargeting as true from config', () => {
4848
const cfg: SDKInitConfig = {
49-
noFunctional: true,
50-
noTargeting: true,
49+
launcherOptions: { noFunctional: true, noTargeting: true },
5150
flags: {},
5251
} as any;
53-
5452
store.processConfig(cfg);
55-
5653
expect(store.getNoFunctional()).toBe(true);
5754
expect(store.getNoTargeting()).toBe(true);
5855
});
5956

6057
it('should set noFunctional as true and noTargeting as false from config', () => {
6158
const cfg: SDKInitConfig = {
62-
noFunctional: true,
63-
noTargeting: false,
59+
launcherOptions: { noFunctional: true, noTargeting: false },
6460
flags: {},
6561
} as any;
66-
6762
store.processConfig(cfg);
68-
6963
expect(store.getNoFunctional()).toBe(true);
7064
expect(store.getNoTargeting()).toBe(false);
7165
});
7266

7367
it('should set noFunctional as false and noTargeting as true from config', () => {
7468
const cfg: SDKInitConfig = {
75-
noFunctional: false,
76-
noTargeting: true,
69+
launcherOptions: { noFunctional: false, noTargeting: true },
7770
flags: {},
7871
} as any;
79-
8072
store.processConfig(cfg);
81-
8273
expect(store.getNoFunctional()).toBe(false);
8374
expect(store.getNoTargeting()).toBe(true);
8475
});

test/src/tests-batchUploader.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1744,7 +1744,7 @@ describe('batch uploader', () => {
17441744
offlineStorage: '100',
17451745
...enableBatchingConfigFlags,
17461746
};
1747-
window.mParticle.config.noFunctional = true;
1747+
window.mParticle.config.launcherOptions = { noFunctional: true };
17481748
window.mParticle.init(apiKey, window.mParticle.config);
17491749
await waitForCondition(hasIdentifyReturned);
17501750
const mpInstance = window.mParticle.getInstance();
@@ -1758,7 +1758,7 @@ describe('batch uploader', () => {
17581758
offlineStorage: '100',
17591759
...enableBatchingConfigFlags,
17601760
};
1761-
window.mParticle.config.noFunctional = false;
1761+
window.mParticle.config.launcherOptions = { noFunctional: false };
17621762
window.mParticle.init(apiKey, window.mParticle.config);
17631763
await waitForCondition(hasIdentifyReturned);
17641764
const mpInstance = window.mParticle.getInstance();
@@ -1783,7 +1783,7 @@ describe('batch uploader', () => {
17831783
offlineStorage: '100',
17841784
...enableBatchingConfigFlags,
17851785
};
1786-
window.mParticle.config.noFunctional = true;
1786+
window.mParticle.config.launcherOptions = { noFunctional: true };
17871787
window.mParticle.init(apiKey, window.mParticle.config);
17881788
await waitForCondition(hasIdentifyReturned);
17891789
const mpInstance = window.mParticle.getInstance();
@@ -1798,7 +1798,7 @@ describe('batch uploader', () => {
17981798
offlineStorage: '100',
17991799
...enableBatchingConfigFlags,
18001800
};
1801-
window.mParticle.config.noFunctional = false;
1801+
window.mParticle.config.launcherOptions = { noFunctional: false };
18021802
window.mParticle.init(apiKey, window.mParticle.config);
18031803
await waitForCondition(hasIdentifyReturned);
18041804
const mpInstance = window.mParticle.getInstance();

test/src/tests-store.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1817,8 +1817,7 @@ describe('Store', () => {
18171817
it('should set noFunctional and noTargeting from init config', () => {
18181818
window.mParticle._resetForTests(MPConfig);
18191819
window.mParticle.config = window.mParticle.config || {};
1820-
window.mParticle.config.noFunctional = true;
1821-
window.mParticle.config.noTargeting = true;
1820+
window.mParticle.config.launcherOptions = { noFunctional: true, noTargeting: true };
18221821

18231822
window.mParticle.init(apiKey, window.mParticle.config);
18241823

0 commit comments

Comments
 (0)