Skip to content

ref(analytics): Transform analytics events for TET-838 #95217

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
9 changes: 3 additions & 6 deletions src/sentry/analytics/events/eventuser_endpoint_request.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
from sentry import analytics


@analytics.eventclass("eventuser_endpoint.request")
class EventUserEndpointRequest(analytics.Event):
type = "eventuser_endpoint.request"

attributes = (
analytics.Attribute("endpoint", required=True),
analytics.Attribute("project_id", required=False),
)
endpoint: str
project_id: str | None = None


analytics.register(EventUserEndpointRequest)
13 changes: 5 additions & 8 deletions src/sentry/analytics/events/first_profile_sent.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
from sentry import analytics


@analytics.eventclass("first_profile.sent")
class FirstProfileSentEvent(analytics.Event):
type = "first_profile.sent"

attributes = (
analytics.Attribute("organization_id"),
analytics.Attribute("project_id"),
analytics.Attribute("platform", required=False),
analytics.Attribute("user_id", required=False),
)
organization_id: str
project_id: str
platform: str | None = None
user_id: str | None = None


analytics.register(FirstProfileSentEvent)
8 changes: 5 additions & 3 deletions src/sentry/api/endpoints/group_tagkey_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from rest_framework.response import Response

from sentry import analytics, tagstore
from sentry.analytics.events.eventuser_endpoint_request import EventUserEndpointRequest
from sentry.api.api_owners import ApiOwner
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.api.base import region_silo_endpoint
Expand Down Expand Up @@ -68,9 +69,10 @@ def get(self, request: Request, group, key) -> Response:
List a Tag's Values
"""
analytics.record(
"eventuser_endpoint.request",
project_id=group.project_id,
endpoint="sentry.api.endpoints.group_tagkey_values.get",
EventUserEndpointRequest(
project_id=group.project_id,
endpoint="sentry.api.endpoints.group_tagkey_values.get",
)
)
lookup_key = tagstore.backend.prefix_reserved_key(key)

Expand Down
8 changes: 5 additions & 3 deletions src/sentry/api/endpoints/project_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from rest_framework.response import Response

from sentry import analytics
from sentry.analytics.events.eventuser_endpoint_request import EventUserEndpointRequest
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.api.base import region_silo_endpoint
from sentry.api.bases.project import ProjectAndStaffPermission, ProjectEndpoint
Expand Down Expand Up @@ -41,9 +42,10 @@ def get(self, request: Request, project) -> Response:
For example, ``query=email:foo@example.com``
"""
analytics.record(
"eventuser_endpoint.request",
project_id=project.id,
endpoint="sentry.api.endpoints.project_users.get",
EventUserEndpointRequest(
project_id=project.id,
endpoint="sentry.api.endpoints.project_users.get",
)
)
field, identifier = None, None
if request.GET.get("query"):
Expand Down
12 changes: 7 additions & 5 deletions src/sentry/receivers/onboarding.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from django.db.models import F

from sentry import analytics
from sentry.analytics.events.first_profile_sent import FirstProfileSentEvent
from sentry.integrations.base import IntegrationDomain, get_integration_types
from sentry.integrations.services.integration import RpcIntegration, integration_service
from sentry.models.organization import Organization
Expand Down Expand Up @@ -182,11 +183,12 @@ def record_first_transaction(project, event, **kwargs):
@first_profile_received.connect(weak=False, dispatch_uid="onboarding.record_first_profile")
def record_first_profile(project, **kwargs):
analytics.record(
"first_profile.sent",
user_id=get_owner_id(project),
organization_id=project.organization_id,
project_id=project.id,
platform=project.platform,
FirstProfileSentEvent(
user_id=get_owner_id(project),
organization_id=project.organization_id,
project_id=project.id,
platform=project.platform,
)
)


Expand Down
8 changes: 5 additions & 3 deletions src/sentry/tasks/unmerge.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
from django.db.models.base import Model

from sentry import analytics, eventstore, features, similarity, tsdb
from sentry.analytics.events.eventuser_endpoint_request import EventUserEndpointRequest
from sentry.constants import DEFAULT_LOGGER_NAME, LOG_LEVELS_MAP
from sentry.culprit import generate_culprit
from sentry.eventstore.models import BaseEvent
Expand Down Expand Up @@ -380,9 +381,10 @@ def repair_group_release_data(caches, project, events):

def get_event_user_from_interface(value, project):
analytics.record(
"eventuser_endpoint.request",
project_id=project.id,
endpoint="sentry.tasks.unmerge.get_event_user_from_interface",
EventUserEndpointRequest(
project_id=project.id,
endpoint="sentry.tasks.unmerge.get_event_user_from_interface",
)
)
return EventUser(
user_ident=value.get("id"),
Expand Down
Loading