Skip to content

Commit 3a2d92a

Browse files
fix(analytics): missing 'data' attribute exclusion (#95219)
1 parent e3c4bfb commit 3a2d92a

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/sentry/analytics/event.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,13 @@ def from_instance(cls, instance: Any, **kwargs: Any) -> Self:
113113
**{
114114
f.name: kwargs.get(f.name, getattr(instance, f.name, None))
115115
for f in fields(cls)
116-
if f.name not in ("type", "uuid_", "datetime_")
116+
if f.name
117+
not in (
118+
"type",
119+
"uuid_",
120+
"datetime_",
121+
"data", # TODO: remove this data field once migrated
122+
)
117123
}
118124
)
119125

tests/sentry/analytics/test_event.py

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,29 @@ def test_simple(self, mock_uuid1):
5353
"uuid": b"AAEC",
5454
}
5555

56+
@patch("sentry.analytics.event.uuid1")
57+
def test_simple_from_instance(self, mock_uuid1):
58+
mock_uuid1.return_value = self.get_mock_uuid()
59+
60+
result = ExampleEvent.from_instance(
61+
None,
62+
id="1",
63+
map={"key": "value"},
64+
optional=False,
65+
)
66+
result.datetime_ = datetime(2001, 4, 18, tzinfo=timezone.utc)
67+
68+
assert result.serialize() == {
69+
"data": {
70+
"id": 1,
71+
"map": {"key": "value"},
72+
"optional": False,
73+
},
74+
"type": "example",
75+
"timestamp": 987552000,
76+
"uuid": b"AAEC",
77+
}
78+
5679
@patch("sentry.analytics.event.uuid1")
5780
def test_simple_old_style(self, mock_uuid1):
5881
mock_uuid1.return_value = self.get_mock_uuid()

0 commit comments

Comments
 (0)