Skip to content

ref(analytics): Transform analytics events for TET-826 #95206

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

constantinius
Copy link
Contributor

  • Transform event classes to use @analytics.eventclass decorator
  • Transform analytics.record calls to use event class instances
  • Update imports as needed

Closes TET-826

- Transform event classes to use @analytics.eventclass decorator
- Transform analytics.record calls to use event class instances
- Update imports as needed

Closes TET-826
@constantinius constantinius requested a review from a team as a code owner July 10, 2025 09:12
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Jul 10, 2025
Copy link

@cursor cursor bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: API Event Attributes Mismatch Integer IDs

The organization_id, project_id, and user_id (where applicable) attributes in the PreprodArtifactApi event classes are incorrectly typed as str. These attributes receive integer Django model IDs (e.g., project.organization_id, project.id, request.user.id), causing type checking errors and potential runtime issues.

src/sentry/preprod/analytics.py#L5-L20

class PreprodArtifactApiAssembleEvent(analytics.Event):
organization_id: str
project_id: str
user_id: str | None = None
@analytics.eventclass("preprod_artifact.api.update")
class PreprodArtifactApiUpdateEvent(analytics.Event):
organization_id: str
project_id: str
@analytics.eventclass("preprod_artifact.api.assemble_generic")
class PreprodArtifactApiAssembleGenericEvent(analytics.Event):
organization_id: str
project_id: str

Fix in CursorFix in Web


Was this report helpful? Give feedback by reacting with 👍 or 👎

Copy link

codecov bot commented Jul 10, 2025

❌ 2 Tests Failed:

Tests completed Failed Passed Skipped
27177 2 27175 240
View the top 2 failed test(s) by shortest run time
tests.sentry.preprod.api.endpoints.test_project_preprod_artifact_assemble_generic.ProjectPreprodArtifactAssembleGenericEndpointTest::test_assemble_size_analysis_success
Stack Traces | 2.18s run time
#x1B[1m#x1B[.../api/endpoints/test_project_preprod_artifact_assemble_generic.py#x1B[0m:80: in test_assemble_size_analysis_success
    mock_analytics.assert_called_once_with(
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1....../x64/lib/python3.13/unittest/mock.py#x1B[0m:989: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1....../x64/lib/python3.13/unittest/mock.py#x1B[0m:977: in assert_called_with
    raise AssertionError(_error_message()) from cause
#x1B[1m#x1B[31mE   AssertionError: expected call not found.#x1B[0m
#x1B[1m#x1B[31mE   Expected: record('preprod_artifact.api.assemble_generic', organization_id=4556391552057344, project_id=4556391552057346)#x1B[0m
#x1B[1m#x1B[31mE     Actual: record(PreprodArtifactApiAssembleGenericEvent(uuid_=UUID('26c60012-5d6f-11f0-b894-7c1e529650e3'), datetime_=datetime.datetime(2025, 7, 10, 9, 20, 43, 486117, tzinfo=datetime.timezone.utc), organization_id='4556391552057344', project_id='4556391552057346'))#x1B[0m
tests.sentry.preprod.api.endpoints.test_project_preprod_artifact_assemble_generic.ProjectPreprodArtifactAssembleGenericEndpointTest::test_assemble_installable_app_success
Stack Traces | 2.3s run time
#x1B[1m#x1B[.../api/endpoints/test_project_preprod_artifact_assemble_generic.py#x1B[0m:107: in test_assemble_installable_app_success
    mock_analytics.assert_called_once_with(
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1....../x64/lib/python3.13/unittest/mock.py#x1B[0m:989: in assert_called_once_with
    return self.assert_called_with(*args, **kwargs)
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1....../x64/lib/python3.13/unittest/mock.py#x1B[0m:977: in assert_called_with
    raise AssertionError(_error_message()) from cause
#x1B[1m#x1B[31mE   AssertionError: expected call not found.#x1B[0m
#x1B[1m#x1B[31mE   Expected: record('preprod_artifact.api.assemble_generic', organization_id=4556391553892352, project_id=4556391553892354)#x1B[0m
#x1B[1m#x1B[31mE     Actual: record(PreprodArtifactApiAssembleGenericEvent(uuid_=UUID('37691abc-5d6f-11f0-b894-7c1e52caa639'), datetime_=datetime.datetime(2025, 7, 10, 9, 21, 11, 656030, tzinfo=datetime.timezone.utc), organization_id='4556391553892352', project_id='4556391553892354'))#x1B[0m

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scope: Backend Automatically applied to PRs that change backend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant