-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
ref(analytics): Transform analytics events for TET-833 #95213
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-833
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: Undefined Provider Argument in IssueResolvedEvent
The IssueResolvedEvent
is instantiated with a provider
argument that is not defined in its class, causing a TypeError
. This prevents the issue.resolved
analytics event from being recorded with the provider
information, which was previously captured.
src/sentry/integrations/tasks/sync_status_inbound.py#L296-L307
sentry/src/sentry/integrations/tasks/sync_status_inbound.py
Lines 296 to 307 in 7b6199a
analytics.record( | |
IssueResolvedEvent( | |
project_id=group.project.id, | |
default_user_id="Sentry Jira", | |
organization_id=organization_id, | |
group_id=group.id, | |
resolution_type="with_third_party_app", | |
provider=provider.key, | |
issue_type=group.issue_type.slug, | |
issue_category=group.issue_category.name.lower(), | |
) | |
) |
Bug: Missing `user_id` Field Causes Event Recording Error
The IntegrationIssueCommentsSyncedEvent
class in src/sentry/integrations/analytics.py
lacks a user_id
field. Despite this, user_id
is passed to its constructor in analytics.record()
calls within src/sentry/integrations/tasks/create_comment.py
and src/sentry/integrations/tasks/update_comment.py
. This mismatch results in a TypeError
when the event is recorded, as user_id
is an unexpected argument.
src/sentry/integrations/analytics.py#L53-L58
sentry/src/sentry/integrations/analytics.py
Lines 53 to 58 in 7b6199a
@analytics.eventclass("integration.issue.comments.synced") | |
class IntegrationIssueCommentsSyncedEvent(analytics.Event): | |
provider: str | |
id: str | |
organization_id: str |
src/sentry/integrations/tasks/create_comment.py#L71-L77
sentry/src/sentry/integrations/tasks/create_comment.py
Lines 71 to 77 in 7b6199a
analytics.record( | |
IntegrationIssueCommentsSyncedEvent( | |
provider=installation.model.provider, | |
id=installation.model.id, | |
organization_id=external_issue.organization_id, | |
user_id=user_id, | |
) |
src/sentry/integrations/tasks/update_comment.py#L71-L77
sentry/src/sentry/integrations/tasks/update_comment.py
Lines 71 to 77 in 7b6199a
analytics.record( | |
IntegrationIssueCommentsSyncedEvent( | |
provider=installation.model.provider, | |
id=installation.model.id, | |
organization_id=external_issue.organization_id, | |
user_id=user_id, | |
) |
Bug: Type Mismatch in Analytics Event Fields
Type mismatch: Analytics event classes, such as IssueResolvedEvent
and GroupOwnerAssignment
, declare organization_id
, project_id
, and group_id
fields as str
types. However, integer database IDs are being passed to these fields at various call sites, which can lead to runtime type errors or incorrect analytics data.
src/sentry/receivers/features.py#L241-L250
sentry/src/sentry/receivers/features.py
Lines 241 to 250 in 7b6199a
IssueResolvedEvent( | |
user_id=user_id, | |
project_id=project.id, | |
default_user_id=default_user_id, | |
organization_id=organization_id, | |
group_id=group.id, | |
resolution_type=resolution_type, | |
issue_type=group.issue_type.slug, | |
issue_category=group.issue_category.name.lower(), | |
) |
src/sentry/analytics/events/groupowner_assignment.py#L5-L8
sentry/src/sentry/analytics/events/groupowner_assignment.py
Lines 5 to 8 in 7b6199a
class GroupOwnerAssignment(analytics.Event): | |
organization_id: str | |
project_id: str | |
group_id: str |
Was this report helpful? Give feedback by reacting with 👍 or 👎
❌ 20 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-833