Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 10 additions & 4 deletions packages/node/src/remote/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,14 +118,20 @@ export class RemoteEvaluationClient {
flagKeys: options?.flagKeys,
timeoutMillis: timeoutMillis,
};
if (options?.tracksAssignment) {
getVariantsOptions.trackingOption = options?.tracksAssignment
if (
options?.tracksAssignment !== undefined &&
options?.tracksAssignment !== null
) {
getVariantsOptions.trackingOption = options.tracksAssignment
? 'track'
: 'no-track';
}
if (options?.tracksExposure) {
if (
options?.tracksExposure !== undefined &&
options?.tracksExposure !== null
) {
(getVariantsOptions as any).exposureTrackingOption =
options?.tracksExposure ? 'track' : 'no-track';
options.tracksExposure ? 'track' : 'no-track';
}
const results = await this.evaluationApi.getVariants(
userContext,
Expand Down
20 changes: 20 additions & 0 deletions packages/node/test/remote/client.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,26 @@ describe('ExperimentClient.fetch', () => {
}),
);
});

test('ExperimentClient.fetch, v2 tracksAssignment false and tracksExposure false', async () => {
const client = new RemoteEvaluationClient(API_KEY, {});
const getVariantsSpy = jest.spyOn(
(client as any).evaluationApi,
'getVariants',
);
const variants = await client.fetchV2(testUser, {
tracksAssignment: false,
tracksExposure: false,
});
expect(variants['sdk-ci-test'].key).toEqual('on');
expect(getVariantsSpy).toHaveBeenCalledWith(
expect.objectContaining(testUser),
expect.objectContaining({
trackingOption: 'no-track',
exposureTrackingOption: 'no-track',
Comment on lines +122 to +123
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We already have tests for truthy cases.

}),
);
});
});

describe('ExperimentClient.fetch, retry with different response codes', () => {
Expand Down
Loading