Skip to content

ref(analytics): Transform analytics events for TET-837 #95216

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
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 4 additions & 7 deletions src/sentry/analytics/events/relocation_created.py
Original file line number Diff line number Diff line change
@@ -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)
17 changes: 7 additions & 10 deletions src/sentry/analytics/events/relocation_forked.py
Original file line number Diff line number Diff line change
@@ -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)
13 changes: 5 additions & 8 deletions src/sentry/analytics/events/user_signup.py
Original file line number Diff line number Diff line change
@@ -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):
Expand Down
16 changes: 9 additions & 7 deletions src/sentry/api/endpoints/organization_fork.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
12 changes: 7 additions & 5 deletions src/sentry/receivers/experiments.py
Original file line number Diff line number Diff line change
@@ -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


Expand All @@ -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"),
)
)
10 changes: 6 additions & 4 deletions src/sentry/relocation/api/endpoints/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
10 changes: 6 additions & 4 deletions src/sentry/relocation/api/endpoints/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
Loading