Skip to content

Commit 74ac2e6

Browse files
Merge branch 'refactor-evaluator-to-support-no-target' into configs-sdk-client
2 parents 6a6febd + c396555 commit 74ac2e6

3 files changed

Lines changed: 9 additions & 12 deletions

File tree

src/logger/constants.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@ export const ENGINE_DEFAULT = 41;
3232

3333
export const CLIENT_READY_FROM_CACHE = 100;
3434
export const CLIENT_READY = 101;
35-
export const IMPRESSION = 102;
3635
export const IMPRESSION_QUEUEING = 103;
3736
export const NEW_SHARED_CLIENT = 104;
3837
export const NEW_FACTORY = 105;

src/logger/messages/info.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ export const codesInfo: [number, string][] = codesWarn.concat([
88
[c.CLIENT_READY_FROM_CACHE, READY_MSG + ' from cache'],
99
[c.CLIENT_READY, READY_MSG],
1010
// SDK
11-
[c.IMPRESSION, c.LOG_PREFIX_IMPRESSIONS_TRACKER +'Feature flag: %s. Key: %s. Evaluation: %s. Label: %s'],
12-
[c.IMPRESSION_QUEUEING, c.LOG_PREFIX_IMPRESSIONS_TRACKER +'Queueing corresponding impression.'],
11+
[c.IMPRESSION_QUEUEING, c.LOG_PREFIX_IMPRESSIONS_TRACKER +'Queueing corresponding impression. Feature flag: %s. Key: %s. Evaluation: %s. Label: %s'],
1312
[c.NEW_SHARED_CLIENT, 'New shared client instance created.'],
1413
[c.NEW_FACTORY, 'New Split SDK instance created. %s'],
1514
[c.EVENTS_TRACKER_SUCCESS, c.LOG_PREFIX_EVENTS_TRACKER + 'Successfully queued %s'],

src/sdkClient/client.ts

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { SDK_NOT_READY } from '../utils/labels';
77
import { CONTROL, TREATMENT, TREATMENTS, TREATMENT_WITH_CONFIG, TREATMENTS_WITH_CONFIG, TRACK, TREATMENTS_WITH_CONFIG_BY_FLAGSETS, TREATMENTS_BY_FLAGSETS, TREATMENTS_BY_FLAGSET, TREATMENTS_WITH_CONFIG_BY_FLAGSET, GET_TREATMENTS_WITH_CONFIG, GET_TREATMENTS_BY_FLAG_SETS, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SETS, GET_TREATMENTS_BY_FLAG_SET, GET_TREATMENTS_WITH_CONFIG_BY_FLAG_SET, GET_TREATMENT_WITH_CONFIG, GET_TREATMENT, GET_TREATMENTS, TRACK_FN_LABEL } from '../utils/constants';
88
import { IEvaluation, IEvaluationResult } from '../evaluator/types';
99
import SplitIO from '../../types/splitio';
10-
import { IMPRESSION, IMPRESSION_QUEUEING } from '../logger/constants';
10+
import { IMPRESSION_QUEUEING } from '../logger/constants';
1111
import { ISdkFactoryContext } from '../sdkFactory/types';
1212
import { isConsumerMode } from '../utils/settingsValidation/mode';
1313
import { Method } from '../sync/submitters/types';
@@ -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, featureFlagName: string, attributes?: SplitIO.Attributes, options?: SplitIO.EvaluationOptions, withConfig = false, methodName = GET_TREATMENT) {
42+
function getTreatment(key: SplitIO.SplitKey | undefined, 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,15 +134,12 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
134134
function processEvaluation(
135135
evaluation: IEvaluationResult,
136136
featureFlagName: string,
137-
key: SplitIO.SplitKey,
137+
key: SplitIO.SplitKey | undefined,
138138
properties: string | undefined,
139139
withConfig: boolean,
140140
invokingMethodName: string,
141141
queue: ImpressionDecorated[]
142142
): SplitIO.Treatment | Pick<IEvaluation, 'treatment' | 'config'> {
143-
const matchingKey = getMatching(key);
144-
const bucketingKey = getBucketing(key);
145-
146143
const { changeNumber, impressionsDisabled } = evaluation;
147144
let { treatment, label, config = null } = evaluation;
148145

@@ -153,10 +150,12 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
153150
config = fallbackTreatment.config;
154151
}
155152

156-
log.info(IMPRESSION, [featureFlagName, matchingKey, treatment, label]);
153+
// If no target/key, no impression is tracked
154+
if (validateSplitExistence(log, readinessManager, featureFlagName, label, invokingMethodName) && key) {
155+
const matchingKey = getMatching(key);
156+
const bucketingKey = getBucketing(key);
157157

158-
if (validateSplitExistence(log, readinessManager, featureFlagName, label, invokingMethodName)) {
159-
log.info(IMPRESSION_QUEUEING);
158+
log.info(IMPRESSION_QUEUEING, [featureFlagName, matchingKey, treatment, label]);
160159
queue.push({
161160
imp: {
162161
feature: featureFlagName,

0 commit comments

Comments
 (0)