Skip to content

Commit b9f150f

Browse files
committed
Add getter for all active override keys
1 parent d64a2d1 commit b9f150f

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
@@ -198,6 +198,16 @@ export default class EppoClient {
198198
this.overridesStore = undefined;
199199
}
200200

201+
// Returns a mapping of flag key to variation key for all active overrides
202+
getOverrideVariationKeys(): Record<string, string> {
203+
return Object.fromEntries(
204+
Object.entries(this.overridesStore?.entries() ?? {}).map(([flagKey, value]) => [
205+
flagKey,
206+
value.key,
207+
]),
208+
);
209+
}
210+
201211
async fetchFlagConfigurations() {
202212
if (!this.configurationRequestParameters) {
203213
throw new Error(

0 commit comments

Comments
 (0)