Skip to content

Commit e721f3b

Browse files
committed
feat: Always inline contexts for feature events (#351)
1 parent 0b131c0 commit e721f3b

File tree

3 files changed

+8
-19
lines changed

3 files changed

+8
-19
lines changed

contract-tests/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ app.get('/', (req, res) => {
3131
'migrations',
3232
'event-sampling',
3333
'strongly-typed',
34-
'polling-gzip'
34+
'polling-gzip',
35+
'inline-context',
3536
],
3637
});
3738
});

packages/shared/common/__tests__/internal/events/EventProcessor.test.ts

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,11 @@ function makeFeatureEvent(
7373
variation,
7474
value,
7575
default: def,
76-
...(debug
77-
? {
78-
context: {
79-
key: 'userKey',
80-
name: 'Red',
81-
kind: 'user',
82-
},
83-
}
84-
: {
85-
contextKeys: {
86-
user: 'userKey',
87-
},
88-
}),
76+
context: {
77+
key: 'userKey',
78+
name: 'Red',
79+
kind: 'user',
80+
},
8981
};
9082
}
9183

packages/shared/common/src/internal/events/EventProcessor.ts

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,6 +270,7 @@ export default class EventProcessor implements LDEventProcessor {
270270
const out: FeatureOutputEvent = {
271271
kind: debug ? 'debug' : 'feature',
272272
creationDate: event.creationDate,
273+
context: this.contextFilter.filter(event.context),
273274
key: event.key,
274275
value: event.value,
275276
default: event.default,
@@ -289,11 +290,6 @@ export default class EventProcessor implements LDEventProcessor {
289290
if (event.reason) {
290291
out.reason = event.reason;
291292
}
292-
if (debug) {
293-
out.context = this.contextFilter.filter(event.context);
294-
} else {
295-
out.contextKeys = event.context.kindsAndKeys;
296-
}
297293
return out;
298294
}
299295
case 'index': // Intentional fallthrough.

0 commit comments

Comments
 (0)