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 authored Feb 6, 2024
1 parent 2c6add5 commit 381f008
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 18 deletions.
1 change: 1 addition & 0 deletions contract-tests/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ app.get('/', (req, res) => {
'migrations',
'event-sampling',
'strongly-typed',
'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 @@ -261,6 +261,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 @@ -280,11 +281,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 381f008

Please sign in to comment.