diff --git a/src/sentry/analytics/events/relocation_created.py b/src/sentry/analytics/events/relocation_created.py index 70ffd032b495b5..1706b70dca7468 100644 --- a/src/sentry/analytics/events/relocation_created.py +++ b/src/sentry/analytics/events/relocation_created.py @@ -1,14 +1,11 @@ from sentry import analytics +@analytics.eventclass("relocation.created") class RelocationCreatedEvent(analytics.Event): - type = "relocation.created" - - attributes = ( - analytics.Attribute("creator_id"), - analytics.Attribute("owner_id"), - analytics.Attribute("uuid"), - ) + creator_id: str + owner_id: str + uuid: str analytics.register(RelocationCreatedEvent) diff --git a/src/sentry/analytics/events/relocation_forked.py b/src/sentry/analytics/events/relocation_forked.py index 477c401086f888..10742bf4a35855 100644 --- a/src/sentry/analytics/events/relocation_forked.py +++ b/src/sentry/analytics/events/relocation_forked.py @@ -1,17 +1,14 @@ from sentry import analytics +@analytics.eventclass("relocation.forked") class RelocationForkedEvent(analytics.Event): - type = "relocation.forked" - - attributes = ( - analytics.Attribute("creator_id"), - analytics.Attribute("owner_id"), - analytics.Attribute("uuid"), - analytics.Attribute("from_org_slug"), - analytics.Attribute("requesting_region_name"), - analytics.Attribute("replying_region_name"), - ) + creator_id: str + owner_id: str + uuid: str + from_org_slug: str + requesting_region_name: str + replying_region_name: str analytics.register(RelocationForkedEvent) diff --git a/src/sentry/analytics/events/user_signup.py b/src/sentry/analytics/events/user_signup.py index 52cb62b07f3160..11535e9bc06acc 100644 --- a/src/sentry/analytics/events/user_signup.py +++ b/src/sentry/analytics/events/user_signup.py @@ -1,15 +1,12 @@ from sentry import analytics +@analytics.eventclass("user.signup") class UserSignUpEvent(analytics.Event): - type = "user.signup" - - attributes = ( - analytics.Attribute("user_id"), - analytics.Attribute("source"), - analytics.Attribute("provider", required=False), - analytics.Attribute("referrer", required=False), - ) + user_id: str + source: str + provider: str | None = None + referrer: str | None = None class RelocationUserSignUpEvent(UserSignUpEvent): diff --git a/src/sentry/api/endpoints/organization_fork.py b/src/sentry/api/endpoints/organization_fork.py index bce9523fabce28..3bf518a71df57c 100644 --- a/src/sentry/api/endpoints/organization_fork.py +++ b/src/sentry/api/endpoints/organization_fork.py @@ -8,6 +8,7 @@ from sentry_sdk import capture_exception from sentry import analytics +from sentry.analytics.events.relocation_forked import RelocationForkedEvent from sentry.api.api_owners import ApiOwner from sentry.api.api_publish_status import ApiPublishStatus from sentry.api.base import Endpoint, region_silo_endpoint @@ -168,13 +169,14 @@ def post(self, request: Request, organization_id_or_slug) -> Response: try: analytics.record( - "relocation.forked", - creator_id=request.user.id, - owner_id=owner.id, - uuid=str(new_relocation.uuid), - from_org_slug=org_mapping.slug, - requesting_region_name=requesting_region_name, - replying_region_name=replying_region_name, + RelocationForkedEvent( + creator_id=request.user.id, + owner_id=owner.id, + uuid=str(new_relocation.uuid), + from_org_slug=org_mapping.slug, + requesting_region_name=requesting_region_name, + replying_region_name=replying_region_name, + ) ) except Exception as e: capture_exception(e) diff --git a/src/sentry/receivers/experiments.py b/src/sentry/receivers/experiments.py index 9682372ea3e446..7491cbd2d20802 100644 --- a/src/sentry/receivers/experiments.py +++ b/src/sentry/receivers/experiments.py @@ -1,4 +1,5 @@ from sentry import analytics +from sentry.analytics.events.user_signup import UserSignUpEvent from sentry.signals import join_request_created, join_request_link_viewed, user_signup @@ -20,9 +21,10 @@ def record_join_request_link_viewed(organization, **kwargs): @user_signup.connect(weak=False) def record_user_signup(user, source, **kwargs): analytics.record( - "user.signup", - user_id=user.id, - source=source, - provider=kwargs.get("provider"), - referrer=kwargs.get("referrer"), + UserSignUpEvent( + user_id=user.id, + source=source, + provider=kwargs.get("provider"), + referrer=kwargs.get("referrer"), + ) ) diff --git a/src/sentry/relocation/api/endpoints/index.py b/src/sentry/relocation/api/endpoints/index.py index a3c0940b4f3028..0a5f0fb10397b6 100644 --- a/src/sentry/relocation/api/endpoints/index.py +++ b/src/sentry/relocation/api/endpoints/index.py @@ -13,6 +13,7 @@ from sentry_sdk import capture_exception from sentry import analytics, options +from sentry.analytics.events.relocation_created import RelocationCreatedEvent from sentry.api.api_owners import ApiOwner from sentry.api.api_publish_status import ApiPublishStatus from sentry.api.base import Endpoint, region_silo_endpoint @@ -298,10 +299,11 @@ def post(self, request: Request) -> Response: uploading_start.apply_async(args=[str(relocation.uuid), None, None]) try: analytics.record( - "relocation.created", - creator_id=request.user.id, - owner_id=owner.id, - uuid=str(relocation.uuid), + RelocationCreatedEvent( + creator_id=request.user.id, + owner_id=owner.id, + uuid=str(relocation.uuid), + ) ) except Exception as e: capture_exception(e) diff --git a/src/sentry/relocation/api/endpoints/retry.py b/src/sentry/relocation/api/endpoints/retry.py index b467fc3bee0c48..dad61e67d2bbb4 100644 --- a/src/sentry/relocation/api/endpoints/retry.py +++ b/src/sentry/relocation/api/endpoints/retry.py @@ -8,6 +8,7 @@ from sentry_sdk import capture_exception from sentry import analytics +from sentry.analytics.events.relocation_created import RelocationCreatedEvent from sentry.api.api_owners import ApiOwner from sentry.api.api_publish_status import ApiPublishStatus from sentry.api.base import Endpoint, region_silo_endpoint @@ -134,10 +135,11 @@ def post(self, request: Request, relocation_uuid: str) -> Response: uploading_start.delay(new_relocation.uuid, None, None) try: analytics.record( - "relocation.created", - creator_id=request.user.id, - owner_id=owner.id, - uuid=str(new_relocation.uuid), + RelocationCreatedEvent( + creator_id=request.user.id, + owner_id=owner.id, + uuid=str(new_relocation.uuid), + ) ) except Exception as e: capture_exception(e)