Skip to content

ref(analytics): Transform analytics events for TET-829 #95209

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 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
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
13 changes: 5 additions & 8 deletions src/sentry/analytics/events/codeowners_updated.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
from sentry import analytics


@analytics.eventclass("codeowners.updated")
class CodeownersUpdated(analytics.Event):
type = "codeowners.updated"

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


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


@analytics.eventclass("first_feedback.sent")
class FirstFeedbackSentEvent(analytics.Event):
type = "first_feedback.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(FirstFeedbackSentEvent)
11 changes: 4 additions & 7 deletions src/sentry/analytics/events/first_flag_sent.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from sentry import analytics


@analytics.eventclass("first_flag.sent")
class FirstFlagSentEvent(analytics.Event):
type = "first_flag.sent"

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


analytics.register(FirstFlagSentEvent)
11 changes: 4 additions & 7 deletions src/sentry/analytics/events/first_release_tag_sent.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,11 @@
from sentry import analytics


@analytics.eventclass("first_release_tag.sent")
class FirstReleaseTagSentEvent(analytics.Event):
type = "first_release_tag.sent"

attributes = (
analytics.Attribute("user_id"),
analytics.Attribute("organization_id"),
analytics.Attribute("project_id"),
)
user_id: str
organization_id: str
project_id: str


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


@analytics.eventclass("first_replay.sent")
class FirstReplaySentEvent(analytics.Event):
type = "first_replay.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(FirstReplaySentEvent)
15 changes: 6 additions & 9 deletions src/sentry/analytics/events/integration_serverless_setup.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
from sentry import analytics


@analytics.eventclass("integrations.serverless_setup")
class IntegrationServerlessSetup(analytics.Event):
type = "integrations.serverless_setup"

attributes = (
analytics.Attribute("user_id"),
analytics.Attribute("organization_id"),
analytics.Attribute("integration"),
analytics.Attribute("success_count"),
analytics.Attribute("failure_count"),
)
user_id: str
organization_id: str
integration: str
success_count: str
failure_count: str


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


@analytics.eventclass("open_pr_comment.created")
class OpenPRCommentCreatedEvent(analytics.Event):
type = "open_pr_comment.created"

attributes = (
analytics.Attribute("comment_id"),
analytics.Attribute("org_id"),
analytics.Attribute("pr_id"),
analytics.Attribute("language"),
)
comment_id: str
org_id: str
pr_id: str
language: str


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


@analytics.eventclass("project_issue.searched")
class ProjectIssueSearchEvent(analytics.Event):
type = "project_issue.searched"

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


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


@analytics.eventclass("second_platform.added")
class SecondPlatformAddedEvent(analytics.Event):
type = "second_platform.added"

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


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


@analytics.eventclass("weekly_report.sent")
class WeeklyReportSent(analytics.Event):
type = "weekly_report.sent"

attributes = (
analytics.Attribute("organization_id"),
analytics.Attribute("user_id"),
analytics.Attribute("notification_uuid"),
analytics.Attribute("user_project_count", type=int),
)
organization_id: str
user_id: str
notification_uuid: str
user_project_count: int


analytics.register(WeeklyReportSent)
64 changes: 26 additions & 38 deletions src/sentry/api/analytics.py
Original file line number Diff line number Diff line change
@@ -1,54 +1,42 @@
from sentry import analytics


@analytics.eventclass("organization_saved_search.created")
class OrganizationSavedSearchCreatedEvent(analytics.Event):
type = "organization_saved_search.created"

attributes = (
analytics.Attribute("org_id"),
analytics.Attribute("search_type"),
analytics.Attribute("query"),
)
org_id: str
search_type: str
query: str


@analytics.eventclass("organization_saved_search.deleted")
class OrganizationSavedSearchDeletedEvent(analytics.Event):
type = "organization_saved_search.deleted"

attributes = (
analytics.Attribute("org_id"),
analytics.Attribute("search_type"),
analytics.Attribute("query"),
)
org_id: str
search_type: str
query: str


@analytics.eventclass("group_similar_issues_embeddings.count")
class GroupSimilarIssuesEmbeddingsCountEvent(analytics.Event):
type = "group_similar_issues_embeddings.count"

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


@analytics.eventclass("devtoolbar.api_request")
class DevToolbarApiRequestEvent(analytics.Event):
type = "devtoolbar.api_request"

attributes = (
analytics.Attribute("view_name"),
analytics.Attribute("route"),
analytics.Attribute("query_string", required=False),
analytics.Attribute("origin", required=False),
analytics.Attribute("method"),
analytics.Attribute("status_code", type=int),
analytics.Attribute("organization_id", type=int, required=False),
analytics.Attribute("organization_slug", required=False),
analytics.Attribute("project_id", type=int, required=False),
analytics.Attribute("project_slug", required=False),
analytics.Attribute("user_id", type=int, required=False),
)
view_name: str
route: str
query_string: str | None = None
origin: str | None = None
method: str
status_code: int
organization_id: int | None = None
organization_slug: str | None = None
project_id: int | None = None
project_slug: str | None = None
user_id: int | None = None


analytics.register(OrganizationSavedSearchCreatedEvent)
Expand Down
12 changes: 7 additions & 5 deletions src/sentry/api/endpoints/codeowners/details.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
from rest_framework.response import Response

from sentry import analytics
from sentry.analytics.events.codeowners_updated import CodeownersUpdated
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 @@ -80,11 +81,12 @@ def put(self, request: Request, project: Project, codeowners: ProjectCodeOwners)

user_id = getattr(request.user, "id", None) or None
analytics.record(
"codeowners.updated",
user_id=user_id,
organization_id=project.organization_id,
project_id=project.id,
codeowners_id=updated_codeowners.id,
CodeownersUpdated(
user_id=user_id,
organization_id=project.organization_id,
project_id=project.id,
codeowners_id=updated_codeowners.id,
)
)
self.track_response_code("update", status.HTTP_200_OK)
return Response(
Expand Down
10 changes: 6 additions & 4 deletions src/sentry/api/endpoints/organization_search_details.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
from sentry.api.analytics import OrganizationSavedSearchDeletedEvent
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 @@ -103,9 +104,10 @@ def delete(self, request: Request, organization: Organization, search: SavedSear
"""
search.delete()
analytics.record(
"organization_saved_search.deleted",
search_type=SearchType(search.type).name,
org_id=organization.id,
query=search.query,
OrganizationSavedSearchDeletedEvent(
search_type=SearchType(search.type).name,
org_id=organization.id,
query=search.query,
)
)
return Response(status=204)
Loading
Loading