Skip to content

ref(analytics): Transform analytics events for TET-825 #95205

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 14 commits 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-825

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

Closes TET-825
@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

codecov bot commented Jul 10, 2025

❌ 3 Tests Failed:

Tests completed Failed Passed Skipped
27178 3 27175 240
View the top 3 failed test(s) by shortest run time
tests.sentry.utils.test_eventuser.EventUserTestCase::test_for_projects_query_filter_id
Stack Traces | 4.45s run time
#x1B[1m#x1B[.../sentry/utils/test_eventuser.py#x1B[0m:73: in test_for_projects_query_filter_id
    mock_record.assert_has_calls(
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1.../x64/lib/python3.13/unittest/mock.py#x1B[0m:1014: in assert_has_calls
    raise AssertionError(
#x1B[1m#x1B[31mE   AssertionError: Calls not found.#x1B[0m
#x1B[1m#x1B[31mE   Expected: [call('eventuser_snuba.query', project_ids=[4556387027255298], query="MATCH (events)\nSELECT project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email, max(timestamp) AS `latest_timestamp`\nBY project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email\nWHERE project_id IN array(4556387027255298) AND timestamp < toDateTime('2025-07-09T14:10:00') AND timestamp >= toDateTime('2025-07-09T12:10:00') AND user_id IN array('2')\nORDER BY latest_timestamp DESC\nLIMIT 1\nOFFSET 0", query_try=0, count_rows_returned=1, count_rows_filtered=0, query_time_ms=0),#x1B[0m
#x1B[1m#x1B[31mE    call('eventuser_snuba.for_projects', project_ids=[4556387027255298], total_tries=1, total_rows_returned=1, total_time_ms=0)]#x1B[0m
#x1B[1m#x1B[31mE     Actual: [call(EventUserSnubaQuery(uuid_=UUID('c0aa09ca-5d9d-11f0-9a04-7c1e523e95a5'), datetime_=datetime.datetime(2025, 7, 9, 14, 10, tzinfo=datetime.timezone.utc), project_ids=[4556387027255298], query="MATCH (events)\nSELECT project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email, max(timestamp) AS `latest_timestamp`\nBY project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email\nWHERE project_id IN array(4556387027255298) AND timestamp < toDateTime('2025-07-09T14:10:00') AND timestamp >= toDateTime('2025-07-09T12:10:00') AND user_id IN array('2')\nORDER BY latest_timestamp DESC\nLIMIT 1\nOFFSET 0", query_try=0, count_rows_returned=1, count_rows_filtered=0, query_time_ms=0)),#x1B[0m
#x1B[1m#x1B[31mE    call(EventUserSnubaForProjects(uuid_=UUID('c0aa09cb-5d9d-11f0-812d-7c1e523e95a5'), datetime_=datetime.datetime(2025, 7, 9, 14, 10, tzinfo=datetime.timezone.utc), project_ids=[4556387027255298], total_tries=1, total_rows_returned=1, total_time_ms=0))]#x1B[0m
tests.sentry.utils.test_eventuser.EventUserTestCase::test_for_projects_multiple_query
Stack Traces | 9.94s run time
#x1B[1m#x1B[.../sentry/utils/test_eventuser.py#x1B[0m:364: in test_for_projects_multiple_query
    mock_record.assert_has_calls(
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1.../x64/lib/python3.13/unittest/mock.py#x1B[0m:1014: in assert_has_calls
    raise AssertionError(
#x1B[1m#x1B[31mE   AssertionError: Calls not found.#x1B[0m
#x1B[1m#x1B[31mE   Expected: [call('eventuser_snuba.query', project_ids=[4556387027255298], query="MATCH (events)\nSELECT project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email, max(timestamp) AS `latest_timestamp`\nBY project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email\nWHERE project_id IN array(4556387027255298) AND timestamp < toDateTime('2025-07-09T14:10:00') AND timestamp >= toDateTime('2025-07-09T12:10:00') AND user_name IN array('test', 'test2')\nORDER BY latest_timestamp DESC\nLIMIT 5\nOFFSET 0", query_try=0, count_rows_returned=5, count_rows_filtered=4, query_time_ms=0),#x1B[0m
#x1B[1m#x1B[31mE    call('eventuser_snuba.query', project_ids=[4556387027255298], query="MATCH (events)\nSELECT project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email, max(timestamp) AS `latest_timestamp`\nBY project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email\nWHERE project_id IN array(4556387027255298) AND timestamp < toDateTime('2025-07-09T14:10:00') AND timestamp >= toDateTime('2025-07-09T12:10:00') AND user_name IN array('test', 'test2')\nORDER BY latest_timestamp DESC\nLIMIT 5\nOFFSET 5", query_try=1, count_rows_returned=4, count_rows_filtered=3, query_time_ms=0),#x1B[0m
#x1B[1m#x1B[31mE    call('eventuser_snuba.for_projects', project_ids=[4556387027255298], total_tries=2, total_rows_returned=2, total_time_ms=0)]#x1B[0m
#x1B[1m#x1B[31mE     Actual: [call(EventUserSnubaQuery(uuid_=UUID('b7074304-5d9d-11f0-80ab-7ced8d56d800'), datetime_=datetime.datetime(2025, 7, 9, 14, 10, tzinfo=datetime.timezone.utc), project_ids=[4556387027255298], query="MATCH (events)\nSELECT project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email, max(timestamp) AS `latest_timestamp`\nBY project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email\nWHERE project_id IN array(4556387027255298) AND timestamp < toDateTime('2025-07-09T14:10:00') AND timestamp >= toDateTime('2025-07-09T12:10:00') AND user_name IN array('test', 'test2')\nORDER BY latest_timestamp DESC\nLIMIT 5\nOFFSET 0", query_try=0, count_rows_returned=5, count_rows_filtered=4, query_time_ms=0)),#x1B[0m
#x1B[1m#x1B[31mE    call(EventUserSnubaQuery(uuid_=UUID('b7074305-5d9d-11f0-845c-7ced8d56d800'), datetime_=datetime.datetime(2025, 7, 9, 14, 10, tzinfo=datetime.timezone.utc), project_ids=[4556387027255298], query="MATCH (events)\nSELECT project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email, max(timestamp) AS `latest_timestamp`\nBY project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email\nWHERE project_id IN array(4556387027255298) AND timestamp < toDateTime('2025-07-09T14:10:00') AND timestamp >= toDateTime('2025-07-09T12:10:00') AND user_name IN array('test', 'test2')\nORDER BY latest_timestamp DESC\nLIMIT 5\nOFFSET 5", query_try=1, count_rows_returned=4, count_rows_filtered=3, query_time_ms=0)),#x1B[0m
#x1B[1m#x1B[31mE    call(EventUserSnubaForProjects(uuid_=UUID('b7074306-5d9d-11f0-8d70-7ced8d56d800'), datetime_=datetime.datetime(2025, 7, 9, 14, 10, tzinfo=datetime.timezone.utc), project_ids=[4556387027255298], total_tries=2, total_rows_returned=2, total_time_ms=0))]#x1B[0m
tests.sentry.utils.test_eventuser.EventUserTestCase::test_for_projects_query_with_multiple_eventuser_entries_different_ips_query_by_username
Stack Traces | 15.2s run time
#x1B[1m#x1B[.../sentry/utils/test_eventuser.py#x1B[0m:284: in test_for_projects_query_with_multiple_eventuser_entries_different_ips_query_by_username
    mock_record.assert_has_calls(
#x1B[1m#x1B[.../hostedtoolcache/Python/3.13.1.../x64/lib/python3.13/unittest/mock.py#x1B[0m:1014: in assert_has_calls
    raise AssertionError(
#x1B[1m#x1B[31mE   AssertionError: Calls not found.#x1B[0m
#x1B[1m#x1B[31mE   Expected: [call('eventuser_snuba.query', project_ids=[4556387027255298], query="MATCH (events)\nSELECT project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email, max(timestamp) AS `latest_timestamp`\nBY project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email\nWHERE project_id IN array(4556387027255298) AND timestamp < toDateTime('2025-07-09T14:10:00') AND timestamp >= toDateTime('2025-07-09T12:10:00') AND user_name IN array('nisanthan', 'minion')\nORDER BY latest_timestamp DESC", query_try=0, count_rows_returned=21, count_rows_filtered=19, query_time_ms=0),#x1B[0m
#x1B[1m#x1B[31mE    call('eventuser_snuba.for_projects', project_ids=[4556387027255298], total_tries=1, total_rows_returned=2, total_time_ms=0)]#x1B[0m
#x1B[1m#x1B[31mE     Actual: [call(EventUserSnubaQuery(uuid_=UUID('bfcc5390-5d9d-11f0-a910-7c1e527ba117'), datetime_=datetime.datetime(2025, 7, 9, 14, 10, tzinfo=datetime.timezone.utc), project_ids=[4556387027255298], query="MATCH (events)\nSELECT project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email, max(timestamp) AS `latest_timestamp`\nBY project_id, ip_address_v6, ip_address_v4, user_id, user_name, user_email\nWHERE project_id IN array(4556387027255298) AND timestamp < toDateTime('2025-07-09T14:10:00') AND timestamp >= toDateTime('2025-07-09T12:10:00') AND user_name IN array('nisanthan', 'minion')\nORDER BY latest_timestamp DESC", query_try=0, count_rows_returned=21, count_rows_filtered=19, query_time_ms=0)),#x1B[0m
#x1B[1m#x1B[31mE    call(EventUserSnubaForProjects(uuid_=UUID('bfcc5391-5d9d-11f0-959b-7c1e527ba117'), datetime_=datetime.datetime(2025, 7, 9, 14, 10, tzinfo=datetime.timezone.utc), project_ids=[4556387027255298], total_tries=1, total_rows_returned=2, total_time_ms=0))]#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.

ArthurKnaus and others added 6 commits July 10, 2025 12:11
Not sure why the same logic returns a different result now that is not
in a hook anymore. However, the color ended up being white after moving
this to the theme and this PR fixes it.
Move the `OnboardingStep` type out of the `Step` component file as the
type is also used in other components and a general building block of
our docs structure.
Move `TabbedCodeSnippet` from `step.tsx` into
`onboardingCodeSnippet.tsx` since it is just a utility wrapper for it
and also is used in a multitude of places that do not use the `Step`
component.

- closes [TET-841: Move general onboarding doc types out of step
component
file](https://linear.app/getsentry/issue/TET-841/move-general-onboarding-doc-types-out-of-step-component-file)
The arcade for the profiling onboarding got blocked by our CSP.
This PR streamlines the embed URL to use the same format as the other
arcades.
@constantinius constantinius requested review from a team as code owners July 10, 2025 10:11
@github-actions github-actions bot added the Scope: Frontend Automatically applied to PRs that change frontend components label Jul 10, 2025
Copy link
Contributor

🚨 Warning: This pull request contains Frontend and Backend changes!

It's discouraged to make changes to Sentry's Frontend and Backend in a single pull request. The Frontend and Backend are not atomically deployed. If the changes are interdependent of each other, they must be separated into two pull requests and be made forward or backwards compatible, such that the Backend or Frontend can be safely deployed independently.

Have questions? Please ask in the #discuss-dev-infra channel.

cursor[bot]

This comment was marked as outdated.

Comment on lines +7 to +8
project_id: str
event_id: str
Copy link
Member

Choose a reason for hiding this comment

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

Shouldn't these be ints?

Comment on lines +7 to +8
actor_id: str | None = None
id: str
Copy link
Member

Choose a reason for hiding this comment

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

Same as above - are these ints or str?

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: Database ID Typing Inconsistency

Several ID fields in EmailNotificationSent (organization_id, project_id, actor_id, user_id, group_id, id, alert_id) and NotificationSettingsUpdated (actor_id, id) are incorrectly typed as str (or str | None for actor_id). These database IDs should be int (or int | None), consistent with Sentry's typical ID patterns and other analytics events. This type mismatch can cause type checking failures, compatibility issues, and runtime errors when integer values are passed.

src/sentry/analytics/events/notifications_settings_updated.py#L6-L8

target_type: str
actor_id: str | None = None
id: str

src/sentry/mail/analytics.py#L6-L16

class EmailNotificationSent(analytics.Event):
organization_id: str
project_id: str | None = None
category: str
actor_id: str | None = None
user_id: str | None = None
group_id: str | None = None
id: str
actor_type: str
notification_uuid: str
alert_id: str | None = None

Fix in CursorFix in Web


Bug: String Type Mismatch for Integer ID Fields

The project_id and event_id fields in GroupingParameterizationExperiment are typed as str but should be int. As database IDs, these are consistently integers in Sentry. This type mismatch can lead to runtime errors or compatibility issues when these analytics events are used with integer ID values.

src/sentry/analytics/events/grouping_parameterization_experiment.py#L6-L8

experiment_name: str
project_id: str
event_id: str

Fix in CursorFix in Web


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

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 Scope: Frontend Automatically applied to PRs that change frontend components
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants