Skip to content
Merged
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
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@eppo/js-client-sdk-common",
"version": "4.13.0",
"version": "4.13.1",
"description": "Common library for Eppo JavaScript SDKs (web, react native, and node)",
"main": "dist/index.js",
"files": [
Expand Down
11 changes: 11 additions & 0 deletions src/client/eppo-client.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ describe('EppoClient E2E test', () => {
const mockFlag: Flag = {
key: flagKey,
enabled: true,
entityId: 123,
variationType: VariationType.STRING,
variations: { a: variationA, b: variationB },
allocations: [
Expand Down Expand Up @@ -195,6 +196,16 @@ describe('EppoClient E2E test', () => {
client.setAssignmentLogger(mockLogger);
expect(td.explain(mockLogger.logAssignment).callCount).toEqual(MAX_EVENT_QUEUE_SIZE);
});

it('should log assignment event with entityId', () => {
const mockLogger = td.object<IAssignmentLogger>();
const client = new EppoClient({ flagConfigurationStore: storage });
client.setAssignmentLogger(mockLogger);
client.getStringAssignment(flagKey, 'subject-to-be-logged', {}, 'default-value');
expect(td.explain(mockLogger.logAssignment).callCount).toEqual(1);
const loggedAssignmentEvent = td.explain(mockLogger.logAssignment).calls[0].args[0];
expect(loggedAssignmentEvent.entityId).toEqual(123);
});
});

describe('check type match', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/client/eppo-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1287,7 +1287,7 @@ export default class EppoClient {
});
}

private maybeLogAssignment(result: FlagEvaluation & { entityId?: number }) {
private maybeLogAssignment(result: FlagEvaluation) {
const {
flagKey,
format,
Expand Down
1 change: 1 addition & 0 deletions src/client/eppo-precomputed-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,7 @@ export default class EppoPrecomputedClient {
allocationKey: precomputedFlag.allocationKey ?? '',
extraLogging: precomputedFlag.extraLogging ?? {},
doLog: precomputedFlag.doLog,
entityId: null,
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this something that needs to be returned from the assignments endpoint so that the precomputed client has it available as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

In order to support automated event logging for the precomputed mode, yes we'll have to pass that down as well.

};

try {
Expand Down
4 changes: 4 additions & 0 deletions src/evaluator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ export interface FlagEvaluationWithoutDetails {
extraLogging: Record<string, string>;
// whether to log assignment event
doLog: boolean;
entityId: number | null;
}

export interface FlagEvaluation extends FlagEvaluationWithoutDetails {
Expand Down Expand Up @@ -122,6 +123,7 @@ export class Evaluator {
extraLogging: split.extraLogging ?? {},
doLog: allocation.doLog,
flagEvaluationDetails,
entityId: flag.entityId ?? null,
Copy link
Contributor

Choose a reason for hiding this comment

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

🤦🏽

};
}
}
Expand Down Expand Up @@ -227,6 +229,7 @@ export function noneResult(
extraLogging: {},
doLog: false,
flagEvaluationDetails,
entityId: null,
};
}

Expand Down Expand Up @@ -288,5 +291,6 @@ export function overrideResult(
format: '',
allocationKey: overrideAllocationKey,
extraLogging: {},
entityId: null,
};
}
Loading