Skip to content

Commit e6d46fd

Browse files
Add 'track' property in ImpressionDTO and 'trackImpressions' property in ISplit
1 parent 5014820 commit e6d46fd

File tree

5 files changed

+9
-4
lines changed

5 files changed

+9
-4
lines changed

src/dtos/types.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,8 @@ export interface ISplit {
208208
configurations?: {
209209
[treatmentName: string]: string
210210
},
211-
sets?: string[]
211+
sets?: string[],
212+
trackImpressions?: boolean
212213
}
213214

214215
// Split definition used in offline mode

src/evaluator/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -156,12 +156,14 @@ function getEvaluation(
156156
return evaluation.then(result => {
157157
result.changeNumber = split.getChangeNumber();
158158
result.config = splitJSON.configurations && splitJSON.configurations[result.treatment] || null;
159+
result.track = splitJSON.trackImpressions;
159160

160161
return result;
161162
});
162163
} else {
163164
evaluation.changeNumber = split.getChangeNumber(); // Always sync and optional
164165
evaluation.config = splitJSON.configurations && splitJSON.configurations[evaluation.treatment] || null;
166+
evaluation.track = splitJSON.trackImpressions;
165167
}
166168
}
167169

src/evaluator/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ export interface IEvaluation {
2525
config?: string | null
2626
}
2727

28-
export type IEvaluationResult = IEvaluation & { treatment: string }
28+
export type IEvaluationResult = IEvaluation & { treatment: string; track?: boolean }
2929

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

src/sdkClient/client.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
133133
const matchingKey = getMatching(key);
134134
const bucketingKey = getBucketing(key);
135135

136-
const { treatment, label, changeNumber, config = null } = evaluation;
136+
const { treatment, label, changeNumber, config = null, track } = evaluation;
137137
log.info(IMPRESSION, [featureFlagName, matchingKey, treatment, label]);
138138

139139
if (validateSplitExistence(log, readinessManager, featureFlagName, label, invokingMethodName)) {
@@ -145,7 +145,8 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
145145
time: Date.now(),
146146
bucketingKey,
147147
label,
148-
changeNumber: changeNumber as number
148+
changeNumber: changeNumber as number,
149+
track
149150
});
150151
}
151152

types/splitio.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -811,6 +811,7 @@ declare namespace SplitIO {
811811
label: string;
812812
changeNumber: number;
813813
pt?: number;
814+
track?: boolean;
814815
}
815816
/**
816817
* Object with information about an impression. It contains the generated impression DTO as well as

0 commit comments

Comments
 (0)