Skip to content

Commit 9b0ac3d

Browse files
committed
ref(analytics): Transform analytics events for TET-830
- Transform event classes to use @analytics.eventclass decorator - Transform analytics.record calls to use event class instances - Update imports as needed Closes TET-830
1 parent 986ceec commit 9b0ac3d

33 files changed

+281
-273
lines changed
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
from sentry import analytics
22

33

4+
@analytics.eventclass("alert_rule_ui_component_webhook.sent")
45
class AlertRuleUiComponentWebhookSentEvent(analytics.Event):
5-
type = "alert_rule_ui_component_webhook.sent"
6-
7-
attributes = (
8-
# organization_id refers to the organization that installed the sentryapp
9-
analytics.Attribute("organization_id"),
10-
analytics.Attribute("sentry_app_id"),
11-
analytics.Attribute("event"),
12-
)
6+
# organization_id refers to the organization that installed the sentryapp
7+
organization_id: str
8+
sentry_app_id: str
9+
event: str
1310

1411

1512
analytics.register(AlertRuleUiComponentWebhookSentEvent)
Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,19 @@
11
from sentry import analytics
22

33

4+
@analytics.eventclass("alert.sent")
45
class AlertSentEvent(analytics.Event):
5-
type = "alert.sent"
6-
7-
attributes = (
8-
analytics.Attribute("organization_id"),
9-
analytics.Attribute("project_id"),
10-
# The id of the Alert or AlertRule
11-
analytics.Attribute("alert_id"),
12-
# "issue_alert" or "metric_alert"
13-
analytics.Attribute("alert_type"),
14-
# Slack, msteams, email, etc.
15-
analytics.Attribute("provider"),
16-
# User_id if sent via email, channel id if sent via slack, etc.
17-
analytics.Attribute("external_id", type=str, required=False),
18-
analytics.Attribute("notification_uuid", required=False),
19-
)
6+
organization_id: str
7+
project_id: str
8+
# The id of the Alert or AlertRule
9+
alert_id: str
10+
# "issue_alert" or "metric_alert"
11+
alert_type: str
12+
# Slack, msteams, email, etc.
13+
provider: str
14+
# User_id if sent via email, channel id if sent via slack, etc.
15+
external_id: str | None = None
16+
notification_uuid: str | None = None
2017

2118

2219
analytics.register(AlertSentEvent)
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
from sentry import analytics
22

33

4+
@analytics.eventclass("checkin_processing_error.stored")
45
class CheckinProcessingErrorStored(analytics.Event):
5-
type = "checkin_processing_error.stored"
6-
7-
attributes = (
8-
analytics.Attribute("organization_id"),
9-
analytics.Attribute("project_id"),
10-
analytics.Attribute("monitor_slug"),
11-
analytics.Attribute("error_types", type=list),
12-
)
6+
organization_id: str
7+
project_id: str
8+
monitor_slug: str
9+
error_types: list
1310

1411

1512
analytics.register(CheckinProcessingErrorStored)
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
from sentry import analytics
22

33

4+
@analytics.eventclass("codeowners.created")
45
class CodeownersCreated(analytics.Event):
5-
type = "codeowners.created"
6-
7-
attributes = (
8-
analytics.Attribute("user_id", required=False),
9-
analytics.Attribute("organization_id"),
10-
analytics.Attribute("project_id"),
11-
analytics.Attribute("codeowners_id"),
12-
)
6+
user_id: str | None = None
7+
organization_id: str
8+
project_id: str
9+
codeowners_id: str
1310

1411

1512
analytics.register(CodeownersCreated)
Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
from sentry import analytics
22

33

4+
@analytics.eventclass("eventuser_endpoint.request")
45
class EventUserEndpointRequest(analytics.Event):
5-
type = "eventuser_endpoint.request"
6-
7-
attributes = (
8-
analytics.Attribute("endpoint", required=True),
9-
analytics.Attribute("project_id", required=False),
10-
)
6+
endpoint: str
7+
project_id: str | None = None
118

129

1310
analytics.register(EventUserEndpointRequest)
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
from sentry import analytics
22

33

4+
@analytics.eventclass("first_cron_checkin.sent")
45
class FirstCronCheckinSent(analytics.Event):
5-
type = "first_cron_checkin.sent"
6-
7-
attributes = (
8-
analytics.Attribute("organization_id"),
9-
analytics.Attribute("project_id"),
10-
analytics.Attribute("monitor_id"),
11-
analytics.Attribute("user_id", required=False),
12-
)
6+
organization_id: str
7+
project_id: str
8+
monitor_id: str
9+
user_id: str | None = None
1310

1411

1512
analytics.register(FirstCronCheckinSent)
Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,13 @@
11
from sentry import analytics
22

33

4+
@analytics.eventclass("first_insight_span.sent")
45
class FirstInsightSpanSentEvent(analytics.Event):
5-
type = "first_insight_span.sent"
6-
7-
attributes = (
8-
analytics.Attribute("organization_id"),
9-
analytics.Attribute("user_id"),
10-
analytics.Attribute("project_id"),
11-
analytics.Attribute("module"),
12-
analytics.Attribute("platform", required=False),
13-
)
6+
organization_id: str
7+
user_id: str
8+
project_id: str
9+
module: str
10+
platform: str | None = None
1411

1512

1613
analytics.register(FirstInsightSpanSentEvent)
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
from sentry import analytics
22

33

4+
@analytics.eventclass("first_transaction.sent")
45
class FirstTransactionSentEvent(analytics.Event):
5-
type = "first_transaction.sent"
6-
7-
attributes = (
8-
analytics.Attribute("organization_id"),
9-
analytics.Attribute("project_id"),
10-
analytics.Attribute("platform", required=False),
11-
analytics.Attribute("default_user_id", required=False),
12-
)
6+
organization_id: str
7+
project_id: str
8+
platform: str | None = None
9+
default_user_id: str | None = None
1310

1411

1512
analytics.register(FirstTransactionSentEvent)

src/sentry/analytics/events/integration_commit_context_all_frames.py

Lines changed: 20 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,30 @@
11
from sentry import analytics
22

33

4+
@analytics.eventclass("integrations.failed_to_fetch_commit_context_all_frames")
45
class IntegrationsFailedToFetchCommitContextAllFrames(analytics.Event):
5-
type = "integrations.failed_to_fetch_commit_context_all_frames"
6-
7-
attributes = (
8-
analytics.Attribute("organization_id"),
9-
analytics.Attribute("project_id"),
10-
analytics.Attribute("group_id"),
11-
analytics.Attribute("event_id"),
12-
analytics.Attribute("num_frames", type=int),
13-
analytics.Attribute("num_successfully_mapped_frames", type=int),
14-
analytics.Attribute("reason"),
15-
)
6+
organization_id: str
7+
project_id: str
8+
group_id: str
9+
event_id: str
10+
num_frames: int
11+
num_successfully_mapped_frames: int
12+
reason: str
1613

1714

15+
@analytics.eventclass("integrations.successfully_fetched_commit_context_all_frames")
1816
class IntegrationsSuccessfullyFetchedCommitContextAllFrames(analytics.Event):
19-
type = "integrations.successfully_fetched_commit_context_all_frames"
20-
21-
attributes = (
22-
analytics.Attribute("organization_id"),
23-
analytics.Attribute("project_id"),
24-
analytics.Attribute("group_id"),
25-
analytics.Attribute("event_id"),
26-
analytics.Attribute("num_frames", type=int),
27-
analytics.Attribute("num_unique_commits", type=int),
28-
analytics.Attribute("num_unique_commit_authors", type=int),
29-
analytics.Attribute("num_successfully_mapped_frames", type=int),
30-
analytics.Attribute("selected_frame_index", type=int),
31-
analytics.Attribute("selected_provider", type=str),
32-
analytics.Attribute("selected_code_mapping_id"),
33-
)
17+
organization_id: str
18+
project_id: str
19+
group_id: str
20+
event_id: str
21+
num_frames: int
22+
num_unique_commits: int
23+
num_unique_commit_authors: int
24+
num_successfully_mapped_frames: int
25+
selected_frame_index: int
26+
selected_provider: str
27+
selected_code_mapping_id: str
3428

3529

3630
analytics.register(IntegrationsSuccessfullyFetchedCommitContextAllFrames)
Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
from sentry import analytics
22

33

4+
@analytics.eventclass("member.invited")
45
class MemberInvitedEvent(analytics.Event):
5-
type = "member.invited"
6-
7-
attributes = (
8-
analytics.Attribute("inviter_user_id"),
9-
analytics.Attribute("invited_member_id"),
10-
analytics.Attribute("organization_id"),
11-
analytics.Attribute("referrer", required=False),
12-
)
6+
inviter_user_id: str
7+
invited_member_id: str
8+
organization_id: str
9+
referrer: str | None = None
1310

1411

1512
analytics.register(MemberInvitedEvent)

0 commit comments

Comments
 (0)