Skip to content
Merged
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
14 changes: 14 additions & 0 deletions src/sentry/analytics/events/relocation_created.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
from sentry import analytics


class RelocationCreatedEvent(analytics.Event):
type = "relocation.created"

attributes = (
analytics.Attribute("creator_id"),
analytics.Attribute("owner_id"),
analytics.Attribute("uuid"),
)


analytics.register(RelocationCreatedEvent)
16 changes: 16 additions & 0 deletions src/sentry/analytics/events/relocation_organization_imported.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from sentry import analytics


class RelocationOrganizationImportedEvent(analytics.Event):
type = "relocation.organization_imported"

attributes = (
analytics.Attribute("organization_id"),
analytics.Attribute("relocation_uuid"),
analytics.Attribute("owner_id"),
analytics.Attribute("name"),
analytics.Attribute("slug"),
)


analytics.register(RelocationOrganizationImportedEvent)
5 changes: 5 additions & 0 deletions src/sentry/analytics/events/user_signup.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,9 @@ class UserSignUpEvent(analytics.Event):
)


class RelocationUserSignUpEvent(UserSignUpEvent):
type = "relocation.user_signup"


analytics.register(UserSignUpEvent)
analytics.register(RelocationUserSignUpEvent)
8 changes: 7 additions & 1 deletion src/sentry/api/endpoints/relocations/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from rest_framework.request import Request
from rest_framework.response import Response

from sentry import options
from sentry import analytics, options
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 @@ -269,4 +269,10 @@ def post(self, request: Request) -> Response:
)

uploading_complete.delay(relocation.uuid)
analytics.record(
Comment thread
hubertdeng123 marked this conversation as resolved.
"relocation.created",
creator_id=request.user.id,
owner_id=owner.id,
uuid=str(relocation.uuid),
)
return Response(serialize(relocation), status=status.HTTP_201_CREATED)
7 changes: 7 additions & 0 deletions src/sentry/api/endpoints/relocations/retry.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from rest_framework.request import Request
from rest_framework.response import Response

from sentry import analytics
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 @@ -118,4 +119,10 @@ def post(self, request: Request, relocation_uuid: str) -> Response:
)

uploading_complete.delay(new_relocation.uuid)
analytics.record(
"relocation.created",
creator_id=request.user.id,
owner_id=owner.id,
uuid=str(new_relocation.uuid),
)
return Response(serialize(new_relocation), status=status.HTTP_201_CREATED)
15 changes: 14 additions & 1 deletion src/sentry/tasks/relocation.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
from django.db import router, transaction
from google.cloud.devtools.cloudbuild_v1 import Build
from google.cloud.devtools.cloudbuild_v1 import CloudBuildClient as CloudBuildClient
from sentry_sdk import capture_exception

from sentry import analytics
from sentry.api.serializers.rest_framework.base import camel_to_snake_case, convert_dict_key_case
from sentry.backup.dependencies import NormalizedModelName, get_model
from sentry.backup.exports import export_in_config_scope, export_in_user_scope
Expand Down Expand Up @@ -1085,14 +1087,25 @@ def postprocessing(uuid: str) -> None:
user_id=relocation.owner_id,
role="owner",
)

# Last, but certainly not least: trigger signals, so that interested subscribers in eg:
# getsentry can do whatever postprocessing they need to. If even a single one fails, we fail
# the entire task.
for _, result in relocated.send_robust(sender=postprocessing, relocation_uuid=uuid):
if isinstance(result, Exception):
raise result

for org in imported_orgs:
try:
analytics.record(
"relocation.organization_imported",
organization_id=org.id,
relocation_uuid=str(relocation.uuid),
slug=org.slug,
owner_id=relocation.owner_id,
)
except Exception as e:
capture_exception(e)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the capture bit here, good idea.


notifying_users.apply_async(args=[uuid])


Expand Down
Loading