-
-
Notifications
You must be signed in to change notification settings - Fork 4.4k
ref(analytics): Transform analytics events for TET-832 #95212
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-832
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: Event Parameter Mismatch Causes Error
The analytics.record
calls in create_comment.py
and update_comment.py
incorrectly pass a user_id
parameter to IntegrationIssueCommentsSyncedEvent
. This event class does not define a user_id
field (only provider
, id
, and organization_id
), which causes a TypeError
when the event is instantiated. The previous analytics.record
method would have ignored this extra parameter.
src/sentry/integrations/tasks/create_comment.py#L70-L78
sentry/src/sentry/integrations/tasks/create_comment.py
Lines 70 to 78 in 19176fb
note.save() | |
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#L70-L78
sentry/src/sentry/integrations/tasks/update_comment.py
Lines 70 to 78 in 19176fb
installation.update_comment(external_issue.key, user_id, note) | |
analytics.record( | |
IntegrationIssueCommentsSyncedEvent( | |
provider=installation.model.provider, | |
id=installation.model.id, | |
organization_id=external_issue.organization_id, | |
user_id=user_id, | |
) | |
) |
Bug: Discord Integration Status Type Error
Type mismatch in the DiscordIntegrationStatus
event: the status
field is defined as str
but receives a Mapping[str, object]
, which can cause runtime errors.
src/sentry/integrations/discord/webhooks/message_component.py#L244-L251
sentry/src/sentry/integrations/discord/webhooks/message_component.py
Lines 244 to 251 in 19176fb
if self.group: | |
analytics.record( | |
DiscordIntegrationStatus( | |
organization_id=self.group.organization.id, | |
user_id=self.user.id, | |
status=data, | |
) | |
) |
src/sentry/integrations/discord/analytics.py#L42-L47
sentry/src/sentry/integrations/discord/analytics.py
Lines 42 to 47 in 19176fb
@analytics.eventclass("integrations.discord.status") | |
class DiscordIntegrationStatus(analytics.Event): | |
organization_id: str | |
user_id: str | |
status: str |
Bug: Undefined Parameter Causes Runtime Error
The GroupSimilarIssuesEmbeddingsCountEvent
is instantiated with a hash
parameter (hash=latest_event.get_primary_hash()
) that is not defined in its class definition in src/sentry/api/analytics.py
. This will cause a runtime error.
src/sentry/issues/endpoints/group_similar_issues_embeddings.py#L126-L142
sentry/src/sentry/issues/endpoints/group_similar_issues_embeddings.py
Lines 126 to 142 in 19176fb
analytics.record( | |
GroupSimilarIssuesEmbeddingsCountEvent( | |
organization_id=group.organization.id, | |
project_id=group.project.id, | |
group_id=group.id, | |
hash=latest_event.get_primary_hash(), | |
count_over_threshold=len( | |
[ | |
result.stacktrace_distance | |
for result in results | |
if result.stacktrace_distance <= 0.01 | |
] | |
), | |
user_id=request.user.id, | |
) | |
) |
Was this report helpful? Give feedback by reacting with 👍 or 👎
❌ 17695 Tests Failed:
View the top 3 failed test(s) by shortest run time
To view more test analytics, go to the Test Analytics Dashboard |
DiscordIntegrationStatus( | ||
organization_id=self.group.organization.id, | ||
user_id=self.user.id, | ||
status=data, |
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.
is this right? status should be a string right, but data is a dict?
Closes TET-832