Skip to content

Commit

Permalink
Add 'track' property in ImpressionDTO and 'trackImpressions' property…
Browse files Browse the repository at this point in the history
… in ISplit
  • Loading branch information
EmilianoSanchez committed Dec 6, 2024
1 parent 5014820 commit e6d46fd
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
3 changes: 2 additions & 1 deletion src/dtos/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,8 @@ export interface ISplit {
configurations?: {
[treatmentName: string]: string
},
sets?: string[]
sets?: string[],
trackImpressions?: boolean
}

// Split definition used in offline mode
Expand Down
2 changes: 2 additions & 0 deletions src/evaluator/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,12 +156,14 @@ function getEvaluation(
return evaluation.then(result => {
result.changeNumber = split.getChangeNumber();
result.config = splitJSON.configurations && splitJSON.configurations[result.treatment] || null;
result.track = splitJSON.trackImpressions;

return result;
});
} else {
evaluation.changeNumber = split.getChangeNumber(); // Always sync and optional
evaluation.config = splitJSON.configurations && splitJSON.configurations[evaluation.treatment] || null;
evaluation.track = splitJSON.trackImpressions;
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/evaluator/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ export interface IEvaluation {
config?: string | null
}

export type IEvaluationResult = IEvaluation & { treatment: string }
export type IEvaluationResult = IEvaluation & { treatment: string; track?: boolean }

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

Expand Down
5 changes: 3 additions & 2 deletions src/sdkClient/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
const matchingKey = getMatching(key);
const bucketingKey = getBucketing(key);

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

if (validateSplitExistence(log, readinessManager, featureFlagName, label, invokingMethodName)) {
Expand All @@ -145,7 +145,8 @@ export function clientFactory(params: ISdkFactoryContext): SplitIO.IClient | Spl
time: Date.now(),
bucketingKey,
label,
changeNumber: changeNumber as number
changeNumber: changeNumber as number,
track
});
}

Expand Down
1 change: 1 addition & 0 deletions types/splitio.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -811,6 +811,7 @@ declare namespace SplitIO {
label: string;
changeNumber: number;
pt?: number;
track?: boolean;
}
/**
* Object with information about an impression. It contains the generated impression DTO as well as
Expand Down

0 comments on commit e6d46fd

Please sign in to comment.