Skip to content

Commit

Permalink
feat: Always inline contexts for feature events (#351)
Browse files Browse the repository at this point in the history
  • Loading branch information
keelerm84 committed Mar 13, 2024
1 parent 0b131c0 commit e721f3b
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 19 deletions.
3 changes: 2 additions & 1 deletion contract-tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ app.get('/', (req, res) => {
'migrations',
'event-sampling',
'strongly-typed',
'polling-gzip'
'polling-gzip',
'inline-context',
],
});
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,19 +73,11 @@ function makeFeatureEvent(
variation,
value,
default: def,
...(debug
? {
context: {
key: 'userKey',
name: 'Red',
kind: 'user',
},
}
: {
contextKeys: {
user: 'userKey',
},
}),
context: {
key: 'userKey',
name: 'Red',
kind: 'user',
},
};
}

Expand Down
6 changes: 1 addition & 5 deletions packages/shared/common/src/internal/events/EventProcessor.ts
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,7 @@ export default class EventProcessor implements LDEventProcessor {
const out: FeatureOutputEvent = {
kind: debug ? 'debug' : 'feature',
creationDate: event.creationDate,
context: this.contextFilter.filter(event.context),
key: event.key,
value: event.value,
default: event.default,
Expand All @@ -289,11 +290,6 @@ export default class EventProcessor implements LDEventProcessor {
if (event.reason) {
out.reason = event.reason;
}
if (debug) {
out.context = this.contextFilter.filter(event.context);
} else {
out.contextKeys = event.context.kindsAndKeys;
}
return out;
}
case 'index': // Intentional fallthrough.
Expand Down

0 comments on commit e721f3b

Please sign in to comment.