Skip to content

Commit ecfd56c

Browse files
authoredMar 13, 2025··
feat: Inline context for custom and migration op events (#327)
1 parent b71fd61 commit ecfd56c

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed
 

‎contract-tests/service.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ def status():
7373
'optional-event-gzip',
7474
'event-sampling',
7575
'polling-gzip',
76-
'inline-context',
76+
'inline-context-all',
7777
'anonymous-redaction',
7878
'evaluation-hooks',
7979
'omit-anonymous-contexts',

‎ldclient/impl/events/event_processor.py

+8-2
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,13 @@ def make_output_event(self, e: Any):
8282
elif isinstance(e, IndexEvent):
8383
return {'kind': 'index', 'creationDate': e.timestamp, 'context': self._process_context(e.context, False)}
8484
elif isinstance(e, EventInputCustom):
85-
out = {'kind': 'custom', 'creationDate': e.timestamp, 'key': e.key, 'contextKeys': self._context_keys(e.context)}
85+
out = {
86+
'kind': 'custom',
87+
'creationDate': e.timestamp,
88+
'key': e.key,
89+
'context': self._process_context(e.context, True)
90+
}
91+
8692
if e.data is not None:
8793
out['data'] = e.data
8894
if e.metric_value is not None:
@@ -93,7 +99,7 @@ def make_output_event(self, e: Any):
9399
'kind': 'migration_op',
94100
'creationDate': e.timestamp,
95101
'operation': e.operation.value,
96-
'contextKeys': self._context_keys(e.context),
102+
'context': self._process_context(e.context, True),
97103
'evaluation': {'key': e.key, 'value': e.detail.value},
98104
}
99105

‎ldclient/testing/impl/events/test_event_processor.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -798,7 +798,7 @@ def check_feature_event(data, source: EventInputEvaluation, context_json: Option
798798
def check_migration_op_event(data, source: MigrationOpEvent):
799799
assert data['kind'] == 'migration_op'
800800
assert data['creationDate'] == source.timestamp
801-
assert data['contextKeys'] == make_context_keys(source.context)
801+
assert data['context'] == source.context.to_dict()
802802
assert data['evaluation']['key'] == source.key
803803
assert data['evaluation']['value'] == source.detail.value
804804

@@ -861,7 +861,7 @@ def check_custom_event(data, source: EventInputCustom):
861861
assert data['creationDate'] == source.timestamp
862862
assert data['key'] == source.key
863863
assert data['data'] == source.data
864-
assert data['contextKeys'] == make_context_keys(source.context)
864+
assert data['context'] == source.context.to_dict()
865865
assert data.get('metricValue') == source.metric_value
866866

867867

0 commit comments

Comments
 (0)
Please sign in to comment.