Skip to content

Commit 12ee171

Browse files
Merge branch 'sdk-configs-baseline' into refactor-evaluator-to-support-no-target
2 parents bd199f0 + b992a20 commit 12ee171

File tree

8 files changed

+19
-19
lines changed

8 files changed

+19
-19
lines changed

CHANGES.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
2.12.0 (February 24, 2026)
2-
- Added support for ioredis v5.
2+
- Added support for ioredis v5 (Related to issue https://github.com/splitio/javascript-commons/issues/471).
33

44
2.11.0 (January 28, 2026)
55
- Added functionality to provide metadata alongside SDK update and READY events. Read more in our docs.

src/evaluator/Engine.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,9 @@ export function engineParser(log: ILogger, split: ISplit, storage: IStorageSync
2929

3030
return {
3131

32-
getTreatment(key: SplitIO.SplitKey | undefined, attributes: SplitIO.Attributes | undefined, splitEvaluator: ISplitEvaluator): MaybeThenable<IEvaluationResult> {
32+
getTreatment(key: SplitIO.SplitKey, attributes: SplitIO.Attributes | undefined, splitEvaluator: ISplitEvaluator): MaybeThenable<IEvaluationResult> {
33+
34+
const parsedKey = keyParser(key);
3335

3436
function evaluate(prerequisitesMet: boolean) {
3537
if (!prerequisitesMet) {
@@ -40,7 +42,7 @@ export function engineParser(log: ILogger, split: ISplit, storage: IStorageSync
4042
};
4143
}
4244

43-
const evaluation = evaluator(key ? keyParser(key) : undefined, seed, trafficAllocation, trafficAllocationSeed, attributes, splitEvaluator) as MaybeThenable<IEvaluation>;
45+
const evaluation = evaluator(parsedKey, seed, trafficAllocation, trafficAllocationSeed, attributes, splitEvaluator) as MaybeThenable<IEvaluation>;
4446

4547
return thenable(evaluation) ?
4648
evaluation.then(result => evaluationResult(result, defaultTreatment)) :

src/evaluator/combiners/ifelseif.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ export function ifElseIfCombinerContext(log: ILogger, predicates: IEvaluator[]):
3333
return undefined;
3434
}
3535

36-
function ifElseIfCombiner(key?: SplitIO.SplitKeyObject, seed?: number, trafficAllocation?: number, trafficAllocationSeed?: number, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator) {
36+
function ifElseIfCombiner(key: SplitIO.SplitKeyObject, seed?: number, trafficAllocation?: number, trafficAllocationSeed?: number, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator) {
3737
// In Async environments we are going to have async predicates. There is none way to know
3838
// before hand so we need to evaluate all the predicates, verify for thenables, and finally,
3939
// define how to return the treatment (wrap result into a Promise or not).

src/evaluator/condition/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ function match(log: ILogger, matchingResult: boolean, bucketingKey: string | und
2424
// Condition factory
2525
export function conditionContext(log: ILogger, matcherEvaluator: (key: SplitIO.SplitKeyObject, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator) => MaybeThenable<boolean>, treatments?: { getTreatmentFor: (x: number) => string }, label?: string, conditionType?: 'ROLLOUT' | 'WHITELIST'): IEvaluator {
2626

27-
return function conditionEvaluator(key?: SplitIO.SplitKeyObject, seed?: number, trafficAllocation?: number, trafficAllocationSeed?: number, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator) {
27+
return function conditionEvaluator(key: SplitIO.SplitKeyObject, seed?: number, trafficAllocation?: number, trafficAllocationSeed?: number, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator) {
2828

2929
// Whitelisting has more priority than traffic allocation, so we don't apply this filtering to those conditions.
30-
if (!key || (conditionType === 'ROLLOUT' && !shouldApplyRollout(trafficAllocation!, key.bucketingKey, trafficAllocationSeed!))) {
30+
if (conditionType === 'ROLLOUT' && !shouldApplyRollout(trafficAllocation!, key.bucketingKey, trafficAllocationSeed!)) {
3131
return {
3232
treatment: undefined, // treatment value is assigned later
3333
label: NOT_IN_SPLIT

src/evaluator/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@ function treatmentsException(splitNames: string[]) {
2424
return evaluations;
2525
}
2626

27-
// @TODO: test cases with no key
2827
export function evaluateFeature(
2928
log: ILogger,
30-
key: SplitIO.SplitKey | undefined,
29+
key: SplitIO.SplitKey,
3130
splitName: string,
3231
attributes: SplitIO.Attributes | undefined,
3332
storage: IStorageSync | IStorageAsync,
@@ -140,7 +139,7 @@ export function evaluateFeaturesByFlagSets(
140139

141140
function getEvaluation(
142141
log: ILogger,
143-
key: SplitIO.SplitKey | undefined,
142+
key: SplitIO.SplitKey,
144143
splitJSON: ISplit | null,
145144
attributes: SplitIO.Attributes | undefined,
146145
storage: IStorageSync | IStorageAsync,

src/evaluator/matchers/prerequisites.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { IDependencyMatcherValue, ISplitEvaluator } from '../types';
66

77
export function prerequisitesMatcherContext(prerequisites: ISplit['prerequisites'], storage: IStorageSync | IStorageAsync, log: ILogger) {
88

9-
return function prerequisitesMatcher({ key, attributes }: Partial<IDependencyMatcherValue>, splitEvaluator: ISplitEvaluator): MaybeThenable<boolean> {
9+
return function prerequisitesMatcher({ key, attributes }: IDependencyMatcherValue, splitEvaluator: ISplitEvaluator): MaybeThenable<boolean> {
1010

1111
prerequisites = prerequisites == null ? [] : prerequisites;
1212

src/evaluator/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,8 @@ export interface IEvaluation {
2727

2828
export type IEvaluationResult = IEvaluation & { treatment: string; impressionsDisabled?: boolean }
2929

30-
export type ISplitEvaluator = (log: ILogger, key: SplitIO.SplitKey | undefined, splitName: string, attributes: SplitIO.Attributes | undefined, storage: IStorageSync | IStorageAsync) => MaybeThenable<IEvaluation>
30+
export type ISplitEvaluator = (log: ILogger, key: SplitIO.SplitKey, splitName: string, attributes: SplitIO.Attributes | undefined, storage: IStorageSync | IStorageAsync) => MaybeThenable<IEvaluation>
3131

32-
export type IEvaluator = (key?: SplitIO.SplitKeyObject, seed?: number, trafficAllocation?: number, trafficAllocationSeed?: number, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator) => MaybeThenable<IEvaluation | boolean | undefined>
32+
export type IEvaluator = (key: SplitIO.SplitKeyObject, seed?: number, trafficAllocation?: number, trafficAllocationSeed?: number, attributes?: SplitIO.Attributes, splitEvaluator?: ISplitEvaluator) => MaybeThenable<IEvaluation | boolean | undefined>
3333

3434
export type IMatcher = (value: string | number | boolean | string[] | IDependencyMatcherValue, splitEvaluator?: ISplitEvaluator) => MaybeThenable<boolean>

src/sdkClient/client.ts

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
3939
const { log, mode } = settings;
4040
const isAsync = isConsumerMode(mode);
4141

42-
function getTreatment(key: SplitIO.SplitKey | undefined, featureFlagName: string, attributes?: SplitIO.Attributes, options?: SplitIO.EvaluationOptions, withConfig = false, methodName = GET_TREATMENT) {
42+
function getTreatment(key: SplitIO.SplitKey, featureFlagName: string, attributes?: SplitIO.Attributes, options?: SplitIO.EvaluationOptions, withConfig = false, methodName = GET_TREATMENT) {
4343
const stopTelemetryTracker = telemetryTracker.trackEval(withConfig ? TREATMENT_WITH_CONFIG : TREATMENT);
4444

4545
const wrapUp = (evaluationResult: IEvaluationResult) => {
@@ -134,12 +134,15 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
134134
function processEvaluation(
135135
evaluation: IEvaluationResult,
136136
featureFlagName: string,
137-
key: SplitIO.SplitKey | undefined,
137+
key: SplitIO.SplitKey,
138138
properties: string | undefined,
139139
withConfig: boolean,
140140
invokingMethodName: string,
141141
queue: ImpressionDecorated[]
142142
): SplitIO.Treatment | SplitIO.TreatmentWithConfig {
143+
const matchingKey = getMatching(key);
144+
const bucketingKey = getBucketing(key);
145+
143146
const { changeNumber, impressionsDisabled } = evaluation;
144147
let { treatment, label, config = null } = evaluation;
145148

@@ -150,11 +153,7 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
150153
config = fallbackTreatment.config;
151154
}
152155

153-
// If no target/key, no impression is tracked
154-
if (key && validateSplitExistence(log, readinessManager, featureFlagName, label, invokingMethodName)) {
155-
const matchingKey = getMatching(key);
156-
const bucketingKey = getBucketing(key);
157-
156+
if (validateSplitExistence(log, readinessManager, featureFlagName, label, invokingMethodName)) {
158157
log.info(IMPRESSION_QUEUEING, [featureFlagName, matchingKey, treatment, label]);
159158
queue.push({
160159
imp: {

0 commit comments

Comments
 (0)