Skip to content

Commit 4d46ac0

Browse files
Merge pull request #294 from splitio/unsupported_matcher_type
Add new `unsupported matcher type` label
2 parents fda5c5f + 6341356 commit 4d46ac0

File tree

9 files changed

+16
-13
lines changed

9 files changed

+16
-13
lines changed

CHANGES.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
1.14.0 (April XX, 2024)
2+
- Updated impression label to 'unsupported matcher type' when the matcher type is not supported by the SDK.
3+
14
1.13.1 (January 10, 2024)
25
- Updated client `destroy` method to release SDK key immediately and avoid unexpected warning logs when a factory is created with the same SDK key after the previous one was destroyed.
36

src/evaluator/combiners/ifelseif.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ export function ifElseIfCombinerContext(log: ILogger, predicates: IEvaluator[]):
1414

1515
return {
1616
treatment: CONTROL,
17-
label: LabelsConstants.EXCEPTION
17+
label: LabelsConstants.UNSUPPORTED_MATCHER_TYPE
1818
};
1919
}
2020

@@ -50,7 +50,7 @@ export function ifElseIfCombinerContext(log: ILogger, predicates: IEvaluator[]):
5050
}
5151

5252
// if there is none predicates, then there was an error in parsing phase
53-
if (!Array.isArray(predicates) || Array.isArray(predicates) && predicates.length === 0) {
53+
if (!Array.isArray(predicates) || predicates.length === 0) {
5454
return unexpectedInputHandler;
5555
} else {
5656
return ifElseIfCombiner;

src/evaluator/matchers/matcherTypes.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
export const matcherTypes: Record<string, number> = {
2-
UNDEFINED: 0,
2+
UNDEFINED: 0, // Value for unsupported or invalid matchers
33
ALL_KEYS: 1,
44
IN_SEGMENT: 2,
55
WHITELIST: 3,

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('exception'); // track invalid as an exception
32+
expect(evaluation.label).toBe('unsupported matcher type'); // track invalid as unsupported matcher type
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('exception'); // track invalid as an exception
131+
expect(ev.label).toBe('unsupported matcher type'); // track invalid as unsupported matcher type
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('exception'); // track invalid as an exception
257+
expect(ev.label).toBe('unsupported matcher type'); // track invalid as unsupported matcher type
258258
}
259259
});

src/evaluator/parser/index.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,7 @@ export function parser(log: ILogger, conditions: ISplitCondition[], storage: ISt
4444
};
4545
});
4646

47-
// if matcher's factory can't instanciate the matchers, the expressions array
48-
// will be empty
47+
// if matcher's factory can't instantiate the matchers, the expressions array will be empty
4948
if (expressions.length === 0) {
5049
// reset any data collected during parsing
5150
predicates = [];

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 found'],
5+
[c.ERROR_ENGINE_COMBINER_IFELSEIF, c.LOG_PREFIX_ENGINE_COMBINER + 'Invalid feature flag, no valid rules or unsupported matcher type found'],
66
// SDK
77
[c.ERROR_LOGLEVEL_INVALID, 'logger: Invalid Log Level - No changes to the logs will be applied.'],
88
[c.ERROR_CLIENT_CANNOT_GET_READY, 'The SDK will not get ready. Reason: %s'],

src/types.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ interface INodeBasicSettings extends ISharedSettings {
353353
IPAddressesEnabled?: boolean
354354
},
355355
/**
356-
* Defines which kind of storage we should instanciate.
356+
* Defines which kind of storage we should instantiate.
357357
* @property {Object} storage
358358
*/
359359
storage?: (params: any) => any,
@@ -918,7 +918,7 @@ export namespace SplitIO {
918918
*/
919919
features?: MockedFeaturesMap,
920920
/**
921-
* Defines which kind of storage we should instanciate.
921+
* Defines which kind of storage we should instantiate.
922922
* @property {Object} storage
923923
*/
924924
storage?: (params: IStorageFactoryParams) => IStorageSync | IStorageAsync,
@@ -944,7 +944,7 @@ export namespace SplitIO {
944944
*/
945945
urls?: UrlSettings,
946946
/**
947-
* Defines which kind of storage we should instanciate.
947+
* Defines which kind of storage we should instantiate.
948948
* @property {Object} storage
949949
*/
950950
storage?: (params: IStorageFactoryParams) => IStorageSync,

src/utils/labels/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +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';

src/utils/settingsValidation/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ export const base = {
6161
telemetry: 'https://telemetry.split.io/api',
6262
},
6363

64-
// Defines which kind of storage we should instanciate.
64+
// Defines which kind of storage we should instantiate.
6565
storage: undefined,
6666

6767
// Defines if the logs are enabled, SDK wide.

0 commit comments

Comments
 (0)