-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
ref(analytics): Transform analytics events for TET-830 #95210
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
- Transform event classes to use @analytics.eventclass decorator - Transform analytics.record calls to use event class instances - Update imports as needed Closes TET-830
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Incorrect Type for Project IDs List
The project_ids
field in ReleaseGetPreviousCommitsEvent
and ReleaseSetCommitsLocalEvent
is incorrectly typed as str
. It is consistently used to pass a list of project IDs, such as [project.id for project in release.projects.all()]
in src/sentry/issues/endpoints/organization_release_previous_commits.py
. This type mismatch should be corrected to list[int]
.
src/sentry/analytics/events/release_get_previous_commits.py#L7-L8
organization_id: str | |
project_ids: str |
src/sentry/analytics/events/release_set_commits.py#L7-L8
sentry/src/sentry/analytics/events/release_set_commits.py
Lines 7 to 8 in 9b0ac3d
organization_id: str | |
project_ids: str |
Bug: Type Mismatch in Alert Event IDs
The AlertSentEvent
class defines organization_id
, project_id
, and alert_id
as str
. However, the AlertSentEvent
is instantiated with integer IDs (e.g., event.organization.id
, event.project_id
, rule.id
) for these fields. Specifically, alert_id
receives an integer or an empty string. This type mismatch could cause runtime errors or unexpected analytics behavior.
src/sentry/rules/actions/integrations/base.py#L124-L133
sentry/src/sentry/rules/actions/integrations/base.py
Lines 124 to 133 in 9b0ac3d
analytics.record( | |
AlertSentEvent( | |
provider=self.provider, | |
alert_id=rule.id if rule else "", | |
alert_type="issue_alert", | |
organization_id=event.organization.id, | |
project_id=event.project_id, | |
external_id=external_id, | |
notification_uuid=notification_uuid if notification_uuid else "", | |
) |
src/sentry/analytics/events/alert_sent.py#L5-L16
sentry/src/sentry/analytics/events/alert_sent.py
Lines 5 to 16 in 9b0ac3d
class AlertSentEvent(analytics.Event): | |
organization_id: str | |
project_id: str | |
# The id of the Alert or AlertRule | |
alert_id: str | |
# "issue_alert" or "metric_alert" | |
alert_type: str | |
# Slack, msteams, email, etc. | |
provider: str | |
# User_id if sent via email, channel id if sent via slack, etc. | |
external_id: str | None = None | |
notification_uuid: str | None = None |
Was this report helpful? Give feedback by reacting with 👍 or 👎
❌ 40 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
Closes TET-830