Skip to content

Commit a9780be

Browse files
yfrancisgreghuels
authored andcommitted
Add getter for all active override keys
1 parent 4979b7d commit a9780be

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

src/client/eppo-client.spec.ts

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,5 +1148,23 @@ describe('EppoClient E2E test', () => {
11481148
const normalAssignment = client.getStringAssignment(flagKey, 'subject-10', {}, 'default');
11491149
expect(normalAssignment).toBe(variationA.value);
11501150
});
1151+
1152+
it('returns a mapping of flag key to variation key for all active overrides', () => {
1153+
overrideStore.setEntries({
1154+
[flagKey]: {
1155+
key: 'override-variation',
1156+
value: 'override-value',
1157+
},
1158+
'other-flag': {
1159+
key: 'other-variation',
1160+
value: 'other-value',
1161+
},
1162+
});
1163+
1164+
expect(client.getOverrideVariationKeys()).toEqual({
1165+
[flagKey]: 'override-variation',
1166+
'other-flag': 'other-variation',
1167+
});
1168+
});
11511169
});
11521170
});

src/client/eppo-client.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,16 @@ export default class EppoClient {
213213
this.overridesStore = undefined;
214214
}
215215

216+
// Returns a mapping of flag key to variation key for all active overrides
217+
getOverrideVariationKeys(): Record<string, string> {
218+
return Object.fromEntries(
219+
Object.entries(this.overridesStore?.entries() ?? {}).map(([flagKey, value]) => [
220+
flagKey,
221+
value.key,
222+
]),
223+
);
224+
}
225+
216226
async fetchFlagConfigurations() {
217227
if (!this.configurationRequestParameters) {
218228
throw new Error(

0 commit comments

Comments
 (0)