Skip to content

Commit 5efd6ca

Browse files
fix: Revise sandbox setting
1 parent c2d25af commit 5efd6ca

3 files changed

Lines changed: 21 additions & 20 deletions

File tree

src/mp-instance.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ import { IECommerce } from './ecommerce.interfaces';
4949
import { INativeSdkHelpers } from './nativeSdkHelpers.interfaces';
5050
import { IPersistence } from './persistence.interfaces';
5151
import ForegroundTimer from './foregroundTimeTracker';
52-
import RoktManager, { IRoktManagerOptions, IRoktOptions } from './roktManager';
52+
import RoktManager, { IRoktOptions } from './roktManager';
5353
import filteredMparticleUser from './filteredMparticleUser';
5454

5555
export interface IErrorLogMessage {
@@ -1404,9 +1404,7 @@ function completeSDKInitialization(apiKey, config, mpInstance) {
14041404
mpInstance
14051405
);
14061406
const roktOptions: IRoktOptions = {
1407-
managerOptions: {
1408-
sandbox: config.isDevelopmentMode,
1409-
},
1407+
sandbox: config?.isDevelopmentMode,
14101408
launcherOptions: config?.launcherOptions,
14111409
};
14121410
// https://go.mparticle.com/work/SQDSDKS-7339

src/roktManager.ts

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,11 @@ export interface IRoktKit {
5656
}
5757

5858
export interface IRoktOptions {
59-
managerOptions?: IRoktManagerOptions;
59+
sandbox?: boolean;
6060
launcherOptions?: IRoktLauncherOptions;
6161
}
6262

6363
export type IRoktLauncherOptions = Dictionary<any>;
64-
export type IRoktManagerOptions = {
65-
sandbox?: boolean;
66-
};
6764

6865
// The purpose of this class is to create a link between the Core mParticle SDK and the
6966
// Rokt Web SDK via a Web Kit.
@@ -124,11 +121,11 @@ export default class RoktManager {
124121
// It is set here and passed in to the createLauncher method in the Rokt Kit
125122
// This is not to be confused for the `sandbox` flag in the selectPlacements attributes
126123
// as that is independent of this setting, though they share the same name.
127-
this.sandbox = options?.managerOptions?.sandbox;
124+
const sandbox = options?.sandbox || false;
128125

129126
// Launcher options are set here for the kit to pick up and pass through
130127
// to the Rokt Launcher.
131-
this.launcherOptions = options?.launcherOptions;
128+
this.launcherOptions = { sandbox, ...options?.launcherOptions };
132129
}
133130

134131
public attachKit(kit: IRoktKit): void {

test/jest/roktManager.spec.ts

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -217,17 +217,17 @@ describe('RoktManager', () => {
217217
});
218218
});
219219

220-
it('should initialize the manager with sandbox from options', () => {
220+
it('should initialize the manager with sandbox from options as launcherOptions', () => {
221221
roktManager.init(
222222
{} as IKitConfigs,
223223
undefined,
224224
mockMPInstance.Identity,
225225
undefined,
226226
{
227-
managerOptions: { sandbox: true },
227+
sandbox: true,
228228
}
229229
);
230-
expect(roktManager['sandbox']).toBe(true);
230+
expect(roktManager['launcherOptions']).toEqual({ sandbox: true });
231231
});
232232

233233
it('should initialize the manager with placement attributes mapping from a config', () => {
@@ -281,26 +281,32 @@ describe('RoktManager', () => {
281281
mockMPInstance.Identity,
282282
mockMPInstance.Logger,
283283
{
284-
managerOptions: { sandbox: true },
285284
launcherOptions
286285
}
287286
);
288287

289-
expect(roktManager['launcherOptions']).toEqual(launcherOptions);
288+
const expectedOptions = {
289+
sandbox: false,
290+
...launcherOptions
291+
};
292+
293+
expect(roktManager['launcherOptions']).toEqual(expectedOptions);
290294
});
291295

292-
it('should initialize the manager with launcher options as undefined when not provided', () => {
296+
it('should initialize the manager with default launcher options not provided', () => {
293297
roktManager.init(
294298
{} as IKitConfigs,
295299
undefined,
296300
mockMPInstance.Identity,
297301
mockMPInstance.Logger,
298-
{
299-
managerOptions: { sandbox: true }
300-
}
302+
undefined,
301303
);
302304

303-
expect(roktManager['launcherOptions']).toEqual(undefined);
305+
const expectedOptions = {
306+
sandbox: false,
307+
};
308+
309+
expect(roktManager['launcherOptions']).toEqual(expectedOptions);
304310
});
305311
});
306312

0 commit comments

Comments
 (0)