Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 7 additions & 1 deletion src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,8 @@ export interface ISettings {
splitFilters: SplitIO.SplitFilter[],
impressionsMode: SplitIO.ImpressionsMode,
__splitFiltersValidation: ISplitFiltersValidation,
localhostMode?: SplitIO.LocalhostFactory
localhostMode?: SplitIO.LocalhostFactory,
singleSync: boolean
},
readonly runtime: {
ip: string | false
Expand Down Expand Up @@ -214,6 +215,11 @@ interface ISharedSettings {
* @default 'OPTIMIZED'
*/
impressionsMode?: SplitIO.ImpressionsMode,
/**
* single Sync enables.
* @property {boolean} singleSync
*/
singleSync: boolean
}
}
/**
Expand Down
21 changes: 21 additions & 0 deletions src/utils/settingsValidation/__tests__/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ describe('settingsValidation', () => {
telemetry: 'https://telemetry.split.io/api',
});
expect(settings.sync.impressionsMode).toBe(OPTIMIZED);
expect(settings.sync.singleSync).toBe(false);
});

test('override with default impressionMode if provided one is invalid', () => {
Expand Down Expand Up @@ -163,6 +164,26 @@ describe('settingsValidation', () => {
expect(settingsWithStreamingEnabled.streamingEnabled).toBe(true); // If streamingEnabled is not provided, it will be true.
});

test('singleSync should be overwritable and false by default', () => {
const settingsWithSingleSyncDisabled = settingsValidation({
core: {
authorizationKey: 'dummy token',
}
}, minimalSettingsParams);
const settingsWithSingleSyncEnabled = settingsValidation({
core: {
authorizationKey: 'dummy token'
},
sync: {
singleSync: true
}
}, minimalSettingsParams);

expect(settingsWithSingleSyncDisabled.sync.singleSync).toBe(false); // If singleSync is not provided, it will be true.
expect(settingsWithSingleSyncEnabled.sync.singleSync).toBe(true); // When creating a setting instance, it will have the provided value for singleSync

});

const storageMock = () => { };
const integrationsMock = [() => { }];

Expand Down
3 changes: 2 additions & 1 deletion src/utils/settingsValidation/__tests__/settings.mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,8 @@ export const fullSettings: ISettings = {
validFilters: [],
queryString: null,
groupedFilters: { byName: [], byPrefix: [] }
}
},
singleSync: false
},
version: 'jest',
runtime: {
Expand Down
8 changes: 7 additions & 1 deletion src/utils/settingsValidation/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,8 @@ export const base = {
splitFilters: undefined,
// impressions collection mode
impressionsMode: OPTIMIZED,
localhostMode: undefined
localhostMode: undefined,
singleSync: false

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add validation, similar to streamingEnabled

},

// Logger
Expand Down Expand Up @@ -191,6 +192,11 @@ export function settingsValidation(config: unknown, validationParams: ISettingsV
scheduler.pushRetryBackoffBase = fromSecondsToMillis(scheduler.pushRetryBackoffBase);
}

// validate singleSync
if (withDefaults.sync.singleSync !== true) { // @ts-ignore, modify readonly prop
withDefaults.sync.singleSync = false;
}

// validate the `splitFilters` settings and parse splits query
const splitFiltersValidation = validateSplitFilters(log, withDefaults.sync.splitFilters, withDefaults.mode);
withDefaults.sync.splitFilters = splitFiltersValidation.validFilters;
Expand Down