Skip to content

Commit 2702342

Browse files
authored
fix: Use clientSideAvailability instead of clientSide for filtering client side flags. (#270)
1 parent fa9e45b commit 2702342

File tree

3 files changed

+8
-10
lines changed

3 files changed

+8
-10
lines changed

packages/shared/akamai-edgeworker-sdk/src/__tests__/testData.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@
9797
"variations": [true, false],
9898
"clientSideAvailability": {
9999
"usingMobileKey": true,
100-
"usingEnvironmentId": true
100+
"usingEnvironmentId": false
101101
},
102102
"clientSide": false,
103103
"salt": "aef830243d6640d0a973be89988e008d",

packages/shared/sdk-server/__tests__/LDClient.allFlags.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -108,28 +108,28 @@ describe('given an LDClient with test data', () => {
108108
on: false,
109109
offVariation: 0,
110110
variations: ['a'],
111-
clientSide: false,
112111
});
113112
td.usePreconfiguredFlag({
114113
key: 'server-side-2',
115114
on: false,
116115
offVariation: 0,
117116
variations: ['b'],
118-
clientSide: false,
117+
// Absence and false should be equivalent, so we add a false one here.
118+
clientSideAvailability: { usingEnvironmentId: false },
119119
});
120120
td.usePreconfiguredFlag({
121121
key: 'client-side-1',
122122
on: false,
123123
offVariation: 0,
124124
variations: ['value1'],
125-
clientSide: true,
125+
clientSideAvailability: { usingEnvironmentId: true },
126126
});
127127
td.usePreconfiguredFlag({
128128
key: 'client-side-2',
129129
on: false,
130130
offVariation: 0,
131131
variations: ['value2'],
132-
clientSide: true,
132+
clientSideAvailability: { usingEnvironmentId: true },
133133
});
134134
const state = await client.allFlagsState(defaultUser, { clientSideOnly: true });
135135
expect(state.valid).toEqual(true);
@@ -241,28 +241,26 @@ describe('given an LDClient with test data', () => {
241241
on: false,
242242
offVariation: 0,
243243
variations: ['a'],
244-
clientSide: false,
245244
});
246245
td.usePreconfiguredFlag({
247246
key: 'server-side-2',
248247
on: false,
249248
offVariation: 0,
250249
variations: ['b'],
251-
clientSide: false,
252250
});
253251
td.usePreconfiguredFlag({
254252
key: 'client-side-1',
255253
on: false,
256254
offVariation: 0,
257255
variations: ['value1'],
258-
clientSide: true,
256+
clientSideAvailability: { usingEnvironmentId: true },
259257
});
260258
td.usePreconfiguredFlag({
261259
key: 'client-side-2',
262260
on: false,
263261
offVariation: 0,
264262
variations: ['value2'],
265-
clientSide: true,
263+
clientSideAvailability: { usingEnvironmentId: true },
266264
});
267265
client.allFlagsState(defaultUser, { clientSideOnly: true }, (err, state) => {
268266
expect(state.valid).toEqual(true);

packages/shared/sdk-server/src/LDClientImpl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ export default class LDClientImpl implements LDClient {
301301
Object.values(allFlags),
302302
(storeItem, iterCb) => {
303303
const flag = storeItem as Flag;
304-
if (clientOnly && !flag.clientSide) {
304+
if (clientOnly && !flag.clientSideAvailability?.usingEnvironmentId) {
305305
iterCb(true);
306306
return;
307307
}

0 commit comments

Comments
 (0)