Skip to content

Commit d8f8e1b

Browse files
Merge branch 'baseline_semver' into SDKS_8273_reuse_matchers_debug_logs
2 parents 1f338ca + a1856db commit d8f8e1b

File tree

10 files changed

+22
-15
lines changed

10 files changed

+22
-15
lines changed

CHANGES.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
1.14.0 (April XX, 2024)
2-
- Added support for Semver matchers.
3-
- Updated impression label to 'unsupported matcher type' when the matcher type is not supported by the SDK.
2+
- Added support for targeting rules based on semantic versions (https://semver.org/).
3+
- Added special impression label "targeting rule type unsupported by sdk" when the matcher type is not supported by the SDK, which returns 'control' treatment.
44
- Updated Split API client to include the flags spec version query parameter for the `splitChanges` and `auth` endpoints.
55

66
1.13.1 (January 10, 2024)

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@splitsoftware/splitio-commons",
3-
"version": "1.13.2-rc.7",
3+
"version": "1.13.2-rc.9",
44
"description": "Split JavaScript SDK common components",
55
"main": "cjs/index.js",
66
"module": "esm/index.js",

src/evaluator/parser/__tests__/invalidMatcher.spec.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ test('PARSER / handle invalid matcher as control', async function () {
2929
let evaluation = await evaluator('aaaaa', 31);
3030

3131
expect(evaluation.treatment).toBe('control'); // return control when invalid matcher
32-
expect(evaluation.label).toBe('unsupported matcher type'); // track invalid as unsupported matcher type
32+
expect(evaluation.label).toBe('targeting rule type unsupported by sdk'); // track invalid as targeting rule type unsupported by sdk
3333
});
3434

3535
test('PARSER / handle invalid matcher as control (complex example)', async function () {
@@ -128,7 +128,7 @@ test('PARSER / handle invalid matcher as control (complex example)', async funct
128128

129129
for (let ev of [ev1, ev2, ev3]) {
130130
expect(ev.treatment).toBe('control'); // return control when invalid matcher
131-
expect(ev.label).toBe('unsupported matcher type'); // track invalid as unsupported matcher type
131+
expect(ev.label).toBe('targeting rule type unsupported by sdk'); // track invalid as targeting rule type unsupported by sdk
132132
}
133133
});
134134

@@ -254,6 +254,6 @@ test('PARSER / handle invalid matcher as control (complex example mixing invalid
254254

255255
for (let ev of [ev1, ev2, ev3]) {
256256
expect(ev.treatment).toBe('control'); // return control when invalid matcher
257-
expect(ev.label).toBe('unsupported matcher type'); // track invalid as unsupported matcher type
257+
expect(ev.label).toBe('targeting rule type unsupported by sdk'); // track invalid as targeting rule type unsupported by sdk
258258
}
259259
});

src/logger/messages/error.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as c from '../constants';
22

33
export const codesError: [number, string][] = [
44
// evaluator
5-
[c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules or unsupported matcher type found'],
5+
[c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules or unsupported targeting rule type found'],
66
[c.ENGINE_MATCHER_ERROR, c.LOG_PREFIX_ENGINE_MATCHER + '[%s] %s'],
77
// SDK
88
[c.ERROR_LOGLEVEL_INVALID, 'logger: Invalid Log Level - No changes to the logs will be applied.'],

src/services/__tests__/splitApi.spec.ts

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import { ISettings } from '../../types';
44
import { settingsSplitApi } from '../../utils/settingsValidation/__tests__/settings.mocks';
55

66
const settingsWithRuntime = { ...settingsSplitApi, runtime: { ip: 'ip', hostname: 'hostname' } } as ISettings;
7+
const settingsWithSets = { ...settingsSplitApi, validateFilters: true, sync: { __splitFiltersValidation: { queryString: '&testFlagQueryString'}}} as ISettings;
78

89
const telemetryTrackerMock = { trackHttp: jest.fn(() => () => { }) };
910

@@ -19,7 +20,7 @@ function assertHeaders(settings: ISettings, headers: Record<string, string>) {
1920

2021
describe('splitApi', () => {
2122

22-
test.each([settingsSplitApi, settingsWithRuntime])('performs requests with expected headers', (settings) => {
23+
test.each([settingsSplitApi, settingsWithRuntime, settingsWithSets])('performs requests with expected headers', (settings) => {
2324

2425
const fetchMock = jest.fn(() => Promise.resolve({ ok: true }));
2526
const splitApi = splitApiFactory(settings, { getFetch: () => fetchMock }, telemetryTrackerMock);
@@ -42,7 +43,7 @@ describe('splitApi', () => {
4243
splitApi.fetchSplitChanges(-1, false, 100);
4344
[url, { headers }] = fetchMock.mock.calls[3];
4445
assertHeaders(settings, headers);
45-
expect(url).toBe('sdk/splitChanges?s=1.1&since=-1&till=100');
46+
expect(url).toBe(expecteFlagsUrl(-1, 100, settings.validateFilters || false, settings));
4647

4748
splitApi.postEventsBulk('fake-body');
4849
assertHeaders(settings, fetchMock.mock.calls[4][1].headers);
@@ -63,6 +64,12 @@ describe('splitApi', () => {
6364

6465
telemetryTrackerMock.trackHttp.mockClear();
6566
fetchMock.mockClear();
67+
68+
69+
function expecteFlagsUrl(since: number, till: number, usesFilter: boolean, settings: ISettings) {
70+
const filterQueryString = settings.sync.__splitFiltersValidation && settings.sync.__splitFiltersValidation.queryString;
71+
return `sdk/splitChanges?s=1.1&since=${since}${usesFilter ? filterQueryString : ''}${till ? '&till=' + till : ''}`;
72+
}
6673
});
6774

6875
test('rejects requests if fetch Api is not provided', (done) => {

src/services/splitApi.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ export function splitApiFactory(
5353
},
5454

5555
fetchSplitChanges(since: number, noCache?: boolean, till?: number) {
56-
const url = `${urls.sdk}/splitChanges?s=${FLAGS_SPEC}&since=${since}${till ? '&till=' + till : ''}${filterQueryString || ''}`;
56+
const url = `${urls.sdk}/splitChanges?s=${FLAGS_SPEC}&since=${since}${filterQueryString || ''}${till ? '&till=' + till : ''}`;
5757
return splitHttpClient(url, noCache ? noCacheHeaderOptions : undefined, telemetryTracker.trackHttp(SPLITS))
5858
.catch((err) => {
5959
if (err.statusCode === 414) settings.log.error(ERROR_TOO_MANY_SETS);

src/storages/inLocalStorage/SplitsCacheInLocal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,7 +146,7 @@ export class SplitsCacheInLocal extends AbstractSplitsCacheSync {
146146

147147
// when using a new split query, we must update it at the store
148148
if (this.updateNewFilter) {
149-
this.log.info(LOG_PREFIX + 'SDK key or feature flag filter criteria was modified. Updating cache');
149+
this.log.info(LOG_PREFIX + 'SDK key, flags filter criteria or flags spec version was modified. Updating cache');
150150
const storageHashKey = this.keys.buildHashKey();
151151
try {
152152
localStorage.setItem(storageHashKey, this.storageHash);

src/storages/pluggable/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ export function PluggableStorage(options: PluggableStorageOptions): IStorageAsyn
9696
return wrapper.get(keys.buildHashKey()).then((hash) => {
9797
const currentHash = getStorageHash(settings);
9898
if (hash !== currentHash) {
99-
log.info(LOG_PREFIX + 'Storage HASH has changed (SDK key or feature flag filter criteria was modified). Clearing cache');
99+
log.info(LOG_PREFIX + 'Storage HASH has changed (SDK key, flags filter criteria or flags spec version was modified). Clearing cache');
100100
return wrapper.getKeysByPrefix(`${keys.prefix}.`).then(storageKeys => {
101101
return Promise.all(storageKeys.map(storageKey => wrapper.del(storageKey)));
102102
}).then(() => wrapper.set(keys.buildHashKey(), currentHash));

src/utils/labels/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@ export const SDK_NOT_READY = 'not ready';
55
export const EXCEPTION = 'exception';
66
export const SPLIT_ARCHIVED = 'archived';
77
export const NOT_IN_SPLIT = 'not in split';
8-
export const UNSUPPORTED_MATCHER_TYPE = 'unsupported matcher type';
8+
export const UNSUPPORTED_MATCHER_TYPE = 'targeting rule type unsupported by sdk';

0 commit comments

Comments
 (0)