Skip to content

ref(analytics): Transform analytics events for TET-830 #95210

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
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
from sentry import analytics


@analytics.eventclass("alert_rule_ui_component_webhook.sent")
class AlertRuleUiComponentWebhookSentEvent(analytics.Event):
type = "alert_rule_ui_component_webhook.sent"

attributes = (
# organization_id refers to the organization that installed the sentryapp
analytics.Attribute("organization_id"),
analytics.Attribute("sentry_app_id"),
analytics.Attribute("event"),
)
# organization_id refers to the organization that installed the sentryapp
organization_id: str
sentry_app_id: str
event: str


analytics.register(AlertRuleUiComponentWebhookSentEvent)
27 changes: 12 additions & 15 deletions src/sentry/analytics/events/alert_sent.py
Original file line number Diff line number Diff line change
@@ -1,22 +1,19 @@
from sentry import analytics


@analytics.eventclass("alert.sent")
class AlertSentEvent(analytics.Event):
type = "alert.sent"

attributes = (
analytics.Attribute("organization_id"),
analytics.Attribute("project_id"),
# The id of the Alert or AlertRule
analytics.Attribute("alert_id"),
# "issue_alert" or "metric_alert"
analytics.Attribute("alert_type"),
# Slack, msteams, email, etc.
analytics.Attribute("provider"),
# User_id if sent via email, channel id if sent via slack, etc.
analytics.Attribute("external_id", type=str, required=False),
analytics.Attribute("notification_uuid", required=False),
)
organization_id: str
project_id: str
# The id of the Alert or AlertRule
alert_id: str
# "issue_alert" or "metric_alert"
alert_type: str
# Slack, msteams, email, etc.
provider: str
# User_id if sent via email, channel id if sent via slack, etc.
external_id: str | None = None
notification_uuid: str | None = None


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


@analytics.eventclass("checkin_processing_error.stored")
class CheckinProcessingErrorStored(analytics.Event):
type = "checkin_processing_error.stored"

attributes = (
analytics.Attribute("organization_id"),
analytics.Attribute("project_id"),
analytics.Attribute("monitor_slug"),
analytics.Attribute("error_types", type=list),
)
organization_id: str
project_id: str
monitor_slug: str
error_types: list


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


@analytics.eventclass("codeowners.created")
class CodeownersCreated(analytics.Event):
type = "codeowners.created"

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(CodeownersCreated)
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_cron_checkin_sent.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,12 @@
from sentry import analytics


@analytics.eventclass("first_cron_checkin.sent")
class FirstCronCheckinSent(analytics.Event):
type = "first_cron_checkin.sent"

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


analytics.register(FirstCronCheckinSent)
15 changes: 6 additions & 9 deletions src/sentry/analytics/events/first_insight_span_sent.py
Original file line number Diff line number Diff line change
@@ -1,16 +1,13 @@
from sentry import analytics


@analytics.eventclass("first_insight_span.sent")
class FirstInsightSpanSentEvent(analytics.Event):
type = "first_insight_span.sent"

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


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


@analytics.eventclass("first_transaction.sent")
class FirstTransactionSentEvent(analytics.Event):
type = "first_transaction.sent"

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


analytics.register(FirstTransactionSentEvent)
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
from sentry import analytics


@analytics.eventclass("integrations.failed_to_fetch_commit_context_all_frames")
class IntegrationsFailedToFetchCommitContextAllFrames(analytics.Event):
type = "integrations.failed_to_fetch_commit_context_all_frames"

attributes = (
analytics.Attribute("organization_id"),
analytics.Attribute("project_id"),
analytics.Attribute("group_id"),
analytics.Attribute("event_id"),
analytics.Attribute("num_frames", type=int),
analytics.Attribute("num_successfully_mapped_frames", type=int),
analytics.Attribute("reason"),
)
organization_id: str
project_id: str
group_id: str
event_id: str
num_frames: int
num_successfully_mapped_frames: int
reason: str


@analytics.eventclass("integrations.successfully_fetched_commit_context_all_frames")
class IntegrationsSuccessfullyFetchedCommitContextAllFrames(analytics.Event):
type = "integrations.successfully_fetched_commit_context_all_frames"

attributes = (
analytics.Attribute("organization_id"),
analytics.Attribute("project_id"),
analytics.Attribute("group_id"),
analytics.Attribute("event_id"),
analytics.Attribute("num_frames", type=int),
analytics.Attribute("num_unique_commits", type=int),
analytics.Attribute("num_unique_commit_authors", type=int),
analytics.Attribute("num_successfully_mapped_frames", type=int),
analytics.Attribute("selected_frame_index", type=int),
analytics.Attribute("selected_provider", type=str),
analytics.Attribute("selected_code_mapping_id"),
)
organization_id: str
project_id: str
group_id: str
event_id: str
num_frames: int
num_unique_commits: int
num_unique_commit_authors: int
num_successfully_mapped_frames: int
selected_frame_index: int
selected_provider: str
selected_code_mapping_id: str


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


@analytics.eventclass("member.invited")
class MemberInvitedEvent(analytics.Event):
type = "member.invited"

attributes = (
analytics.Attribute("inviter_user_id"),
analytics.Attribute("invited_member_id"),
analytics.Attribute("organization_id"),
analytics.Attribute("referrer", required=False),
)
inviter_user_id: str
invited_member_id: str
organization_id: str
referrer: str | None = None


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


@analytics.eventclass("onboarding_continuation.sent")
class OnboardingContinuationSent(analytics.Event):
type = "onboarding_continuation.sent"

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


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


@analytics.eventclass("project.transferred")
class ProjectTransferredEvent(analytics.Event):
type = "project.transferred"

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


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


@analytics.eventclass("release.get_previous_commits")
class ReleaseGetPreviousCommitsEvent(analytics.Event):
type = "release.get_previous_commits"

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


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


@analytics.eventclass("release.set_commits_local")
class ReleaseSetCommitsLocalEvent(analytics.Event):
type = "release.set_commits_local"

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


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


@analytics.eventclass("webhook.repository_created")
class WebHookRepositoryCreatedEvent(analytics.Event):
type = "webhook.repository_created"

attributes = (
analytics.Attribute("organization_id"),
analytics.Attribute("repository_id"),
analytics.Attribute("integration"),
)
organization_id: str
repository_id: str
integration: str


analytics.register(WebHookRepositoryCreatedEvent)
12 changes: 7 additions & 5 deletions src/sentry/api/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
from sentry_sdk import Scope

from sentry import analytics, options, tsdb
from sentry.analytics.events.release_set_commits import ReleaseSetCommitsLocalEvent
from sentry.api.api_owners import ApiOwner
from sentry.api.api_publish_status import ApiPublishStatus
from sentry.api.exceptions import StaffRequired, SuperuserRequired
Expand Down Expand Up @@ -648,11 +649,12 @@ def _parse_resolution(self, value: str) -> int:
class ReleaseAnalyticsMixin:
def track_set_commits_local(self, request: Request, organization_id=None, project_ids=None):
analytics.record(
"release.set_commits_local",
user_id=request.user.id if request.user and request.user.id else None,
organization_id=organization_id,
project_ids=project_ids,
user_agent=request.META.get("HTTP_USER_AGENT", ""),
ReleaseSetCommitsLocalEvent(
user_id=request.user.id if request.user and request.user.id else None,
organization_id=organization_id,
project_ids=project_ids,
user_agent=request.META.get("HTTP_USER_AGENT", ""),
)
)


Expand Down
Loading
Loading