Skip to content

Commit 020bd82

Browse files
committed
refactor: better naming for tracking events for inmemory provider
Signed-off-by: Danju Visvanathan <danju.visvanathan@gmail.com>
1 parent 802f169 commit 020bd82

File tree

2 files changed

+6
-10
lines changed

2 files changed

+6
-10
lines changed

openfeature/provider/in_memory_provider.py

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class InMemoryMetadata(Metadata):
2525
@dataclass
2626
class InMemoryTrackingEvent():
2727
value: float | None = None
28-
data: dict[str, typing.Any] = field(default_factory=dict)
28+
details: dict[str, typing.Any] = field(default_factory=dict)
2929
eval_context_attributes: dict[str, typing.Any] = field(default_factory=dict)
3030

3131

@@ -193,16 +193,12 @@ async def _resolve_async(
193193
return self._resolve(flag_key, default_value, evaluation_context)
194194

195195
def track(self, tracking_event_name: str, evaluation_context: EvaluationContext | None = None, tracking_event_details: TrackingEventDetails | None = None) -> None:
196-
value, data, eval_context_attributes = None, None, None
197-
if tracking_event_details is not None:
198-
value = tracking_event_details.value
199-
data = tracking_event_details.attributes
200-
201-
if evaluation_context is not None:
202-
eval_context_attributes = evaluation_context.attributes
196+
value = tracking_event_details.value if tracking_event_details is not None else None
197+
details = tracking_event_details.attributes if tracking_event_details is not None else {}
198+
eval_context_attributes = evaluation_context.attributes if evaluation_context is not None else None
203199

204200
self._tracking_events[tracking_event_name] = InMemoryTrackingEvent(
205201
value=value,
206-
data=data,
202+
details=details,
207203
eval_context_attributes=eval_context_attributes,
208204
)

tests/provider/test_in_memory_provider.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,4 +205,4 @@ async def test_should_track_event():
205205
{"Key": InMemoryFlag("hundred", {"zero": 0, "hundred": 100})}
206206
)
207207
provider.track(tracking_event_name="test", evaluation_context=EvaluationContext(attributes={"key": "value"}), tracking_event_details=TrackingEventDetails(value=1, attributes={"key": "value"}))
208-
assert provider._tracking_events == {"test": InMemoryTrackingEvent(value=1, data={"key": "value"}, context_attributes={"key": "value"})}
208+
assert provider._tracking_events == {"test": InMemoryTrackingEvent(value=1, details={"key": "value"}, eval_context_attributes={"key": "value"})}

0 commit comments

Comments
 (0)