Skip to content

Commit bfd89d1

Browse files
authored
feat: Evaluation Details (#97)
* feat: New "Details" assignment functions * code review changes
1 parent 5daa34b commit bfd89d1

21 files changed

+1255
-275
lines changed

.vscode/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"eslint.format.enable": true,
33
"editor.codeActionsOnSave": {
4-
"source.fixAll.eslint": true
4+
"source.fixAll.eslint": "explicit"
55
}
66
}

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@eppo/js-client-sdk-common",
3-
"version": "3.6.0",
3+
"version": "4.0.0",
44
"description": "Eppo SDK for client-side JavaScript applications (base for both web and react native)",
55
"main": "dist/index.js",
66
"files": [

src/assignment-logger.spec.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import { IAssignmentEvent } from './assignment-logger';
2+
import { AllocationEvaluationCode } from './flag-evaluation-details-builder';
23

34
describe('IAssignmentEvent', () => {
45
it('should allow adding arbitrary fields', () => {
@@ -11,6 +12,25 @@ describe('IAssignmentEvent', () => {
1112
timestamp: new Date().toISOString(),
1213
subjectAttributes: { age: 25, country: 'USA' },
1314
holdoutKey: 'holdout_key_123',
15+
evaluationDetails: {
16+
environmentName: 'Test',
17+
variationKey: 'variationKey',
18+
variationValue: 'variation_123',
19+
banditKey: null,
20+
banditAction: null,
21+
flagEvaluationCode: 'MATCH',
22+
flagEvaluationDescription: '',
23+
configFetchedAt: new Date().toISOString(),
24+
configPublishedAt: new Date().toISOString(),
25+
matchedRule: null,
26+
matchedAllocation: {
27+
key: 'allocation_123',
28+
allocationEvaluationCode: AllocationEvaluationCode.MATCH,
29+
orderPosition: 1,
30+
},
31+
unmatchedAllocations: [],
32+
unevaluatedAllocations: [],
33+
},
1434
};
1535

1636
expect(event.holdoutKey).toBe('holdout_key_123');

src/assignment-logger.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { IFlagEvaluationDetails } from './flag-evaluation-details-builder';
2+
13
export enum HoldoutVariationEnum {
24
STATUS_QUO = 'status_quo',
35
ALL_SHIPPED = 'all_shipped_variants',
@@ -46,6 +48,11 @@ export interface IAssignmentEvent {
4648
[propName: string]: unknown;
4749

4850
metaData?: Record<string, unknown>;
51+
52+
/**
53+
* The flag evaluation details
54+
*/
55+
evaluationDetails: IFlagEvaluationDetails;
4956
}
5057

5158
/**

src/bandit-logger.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { IFlagEvaluationDetails } from './flag-evaluation-details-builder';
12
import { Attributes } from './types';
23

34
export interface IBanditEvent {
@@ -14,6 +15,7 @@ export interface IBanditEvent {
1415
actionNumericAttributes: Attributes;
1516
actionCategoricalAttributes: Attributes;
1617
metaData?: Record<string, unknown>;
18+
evaluationDetails: IFlagEvaluationDetails;
1719
}
1820

1921
export interface IBanditLogger {

src/cache/lru-cache.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
*/
1414
export class LRUCache implements Map<string, string> {
1515
private readonly cache = new Map<string, string>();
16+
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
17+
// @ts-ignore
1618
[Symbol.toStringTag]: string;
1719

1820
constructor(private readonly capacity: number) {}

0 commit comments

Comments
 (0)