Skip to content

Commit fdf899c

Browse files
Merge branch 'priscila/ref/quick-start/clean-up-deprecated-code' into priscila/ref/quick-start/rename-variables
2 parents b8f68a1 + 234021b commit fdf899c

File tree

5 files changed

+5
-118
lines changed

5 files changed

+5
-118
lines changed

src/sentry/event_manager.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
from sentry.plugins.base import plugins
104104
from sentry.quotas.base import index_data_category
105105
from sentry.receivers.features import record_event_processed
106-
from sentry.receivers.onboarding import record_release_received, record_user_context_received
106+
from sentry.receivers.onboarding import record_release_received
107107
from sentry.reprocessing2 import is_reprocessed_event
108108
from sentry.seer.signed_seer_api import make_signed_seer_api_request
109109
from sentry.signals import (
@@ -2538,7 +2538,6 @@ def _record_transaction_info(jobs: Sequence[Job], projects: ProjectsMapping) ->
25382538
# instead of sending a signal. we should consider potentially
25392539
# deleting these
25402540
record_event_processed(project, event)
2541-
record_user_context_received(project, event)
25422541
record_release_received(project, event)
25432542
except Exception:
25442543
sentry_sdk.capture_exception()

src/sentry/models/organizationonboardingtask.py

+1-7
Original file line numberDiff line numberDiff line change
@@ -20,18 +20,16 @@
2020
from sentry.db.models.manager.base import BaseManager
2121

2222

23+
# NOTE: There are gaps in the numberation because a few tasks were removed, e.g. in the PR https://github.com/getsentry/sentry/pull/83360
2324
class OnboardingTask:
2425
FIRST_PROJECT = 1
2526
FIRST_EVENT = 2
2627
INVITE_MEMBER = 3
2728
SECOND_PLATFORM = 4
28-
USER_CONTEXT = 5
2929
RELEASE_TRACKING = 6
3030
SOURCEMAPS = 7
31-
USER_REPORTS = 8
3231
ALERT_RULE = 10
3332
FIRST_TRANSACTION = 11
34-
METRIC_ALERT = 12
3533
SESSION_REPLAY = 14
3634
REAL_TIME_NOTIFICATIONS = 15
3735
LINK_SENTRY_TO_SOURCE_CODE = 16
@@ -122,12 +120,8 @@ class OrganizationOnboardingTask(AbstractOnboardingTask):
122120
(OnboardingTask.SECOND_PLATFORM, "setup_second_platform"),
123121
(OnboardingTask.RELEASE_TRACKING, "setup_release_tracking"),
124122
(OnboardingTask.SOURCEMAPS, "setup_sourcemaps"),
125-
# TODO(Telemety Experience): Check if we can remove this from the frontend
126-
(OnboardingTask.USER_REPORTS, "setup_user_reports"),
127123
(OnboardingTask.ALERT_RULE, "setup_alert_rules"),
128124
(OnboardingTask.FIRST_TRANSACTION, "setup_transactions"),
129-
# TODO(Telemety Experience): Check if we can remove this from the frontend
130-
(OnboardingTask.METRIC_ALERT, "setup_metric_alert_rules"),
131125
(OnboardingTask.SESSION_REPLAY, "setup_session_replay"),
132126
(OnboardingTask.REAL_TIME_NOTIFICATIONS, "setup_real_time_notifications"),
133127
(OnboardingTask.LINK_SENTRY_TO_SOURCE_CODE, "link_sentry_to_source_code"),

src/sentry/receivers/onboarding.py

+3-78
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@
1818
)
1919
from sentry.models.project import Project
2020
from sentry.onboarding_tasks import try_mark_onboarding_complete
21-
from sentry.plugins.bases.issue import IssueTrackingPlugin
22-
from sentry.plugins.bases.issue2 import IssueTrackingPlugin2
2321
from sentry.signals import (
2422
alert_rule_created,
2523
cron_monitor_created,
@@ -480,44 +478,6 @@ def record_release_received(project, event, **kwargs):
480478
transaction_processed.connect(record_release_received, weak=False)
481479

482480

483-
def record_user_context_received(project, event, **kwargs):
484-
user_context = event.data.get("user")
485-
if not user_context:
486-
return
487-
# checking to see if only ip address is being sent (our js library does this automatically)
488-
# testing for this in test_no_user_tracking_for_ip_address_only
489-
# list(d.keys()) pattern is to make this python3 safe
490-
elif list(user_context.keys()) != ["ip_address"]:
491-
success = OrganizationOnboardingTask.objects.record(
492-
organization_id=project.organization_id,
493-
task=OnboardingTask.USER_CONTEXT,
494-
status=OnboardingTaskStatus.COMPLETE,
495-
project_id=project.id,
496-
)
497-
if success:
498-
organization = Organization.objects.get_from_cache(id=project.organization_id)
499-
try:
500-
owner: RpcUser = organization.get_default_owner()
501-
except IndexError:
502-
logger.warning(
503-
"Cannot record user context received for organization (%s) due to missing owners",
504-
project.organization_id,
505-
)
506-
return
507-
508-
analytics.record(
509-
"first_user_context.sent",
510-
user_id=owner.id,
511-
organization_id=project.organization_id,
512-
project_id=project.id,
513-
)
514-
515-
try_mark_onboarding_complete(project.organization_id, owner)
516-
517-
518-
event_processed.connect(record_user_context_received, weak=False)
519-
520-
521481
@first_event_with_minified_stack_trace_received.connect(weak=False)
522482
def record_event_with_first_minified_stack_trace_for_project(project, event, **kwargs):
523483
organization = Organization.objects.get_from_cache(id=project.organization_id)
@@ -553,9 +513,6 @@ def record_event_with_first_minified_stack_trace_for_project(project, event, **k
553513
)
554514

555515

556-
transaction_processed.connect(record_user_context_received, weak=False)
557-
558-
559516
@event_processed.connect(weak=False)
560517
def record_sourcemaps_received(project, event, **kwargs):
561518
if not has_sourcemap(event):
@@ -626,23 +583,6 @@ def record_sourcemaps_received_for_project(project, event, **kwargs):
626583

627584
@plugin_enabled.connect(weak=False)
628585
def record_plugin_enabled(plugin, project, user, **kwargs):
629-
if isinstance(plugin, IssueTrackingPlugin) or isinstance(plugin, IssueTrackingPlugin2):
630-
task = OnboardingTask.ISSUE_TRACKER
631-
status = OnboardingTaskStatus.PENDING
632-
else:
633-
return
634-
635-
success = OrganizationOnboardingTask.objects.record(
636-
organization_id=project.organization_id,
637-
task=task,
638-
status=status,
639-
user_id=user.id if user else None,
640-
project_id=project.id,
641-
data={"plugin": plugin.slug},
642-
)
643-
if success:
644-
try_mark_onboarding_complete(project.organization_id, user)
645-
646586
analytics.record(
647587
"plugin.enabled",
648588
user_id=user.id if user else None,
@@ -654,10 +594,11 @@ def record_plugin_enabled(plugin, project, user, **kwargs):
654594

655595
@alert_rule_created.connect(weak=False)
656596
def record_alert_rule_created(user, project: Project, rule_type: str, **kwargs):
657-
task = OnboardingTask.METRIC_ALERT if rule_type == "metric" else OnboardingTask.ALERT_RULE
597+
if rule_type == "metric":
598+
return
658599
rows_affected, created = OrganizationOnboardingTask.objects.create_or_update(
659600
organization_id=project.organization_id,
660-
task=task,
601+
task=OnboardingTask.ALERT_RULE,
661602
values={
662603
"status": OnboardingTaskStatus.COMPLETE,
663604
"user_id": user.id if user else None,
@@ -672,22 +613,6 @@ def record_alert_rule_created(user, project: Project, rule_type: str, **kwargs):
672613

673614
@issue_tracker_used.connect(weak=False)
674615
def record_issue_tracker_used(plugin, project, user, **kwargs):
675-
rows_affected, created = OrganizationOnboardingTask.objects.create_or_update(
676-
organization_id=project.organization_id,
677-
task=OnboardingTask.ISSUE_TRACKER,
678-
status=OnboardingTaskStatus.PENDING,
679-
values={
680-
"status": OnboardingTaskStatus.COMPLETE,
681-
"user_id": user.id,
682-
"project_id": project.id,
683-
"date_completed": django_timezone.now(),
684-
"data": {"plugin": plugin.slug},
685-
},
686-
)
687-
688-
if rows_affected or created:
689-
try_mark_onboarding_complete(project.organization_id, user)
690-
691616
if user and user.is_authenticated:
692617
user_id = default_user_id = user.id
693618
else:

tests/sentry/event_manager/test_event_manager.py

-1
Original file line numberDiff line numberDiff line change
@@ -1578,7 +1578,6 @@ def test_transaction_sampler_and_receive(self) -> None:
15781578
manager.save(self.project.id)
15791579

15801580
@patch("sentry.event_manager.record_event_processed")
1581-
@patch("sentry.event_manager.record_user_context_received")
15821581
@patch("sentry.event_manager.record_release_received")
15831582
@patch("sentry.ingest.transaction_clusterer.datasource.redis._record_sample")
15841583
def test_transaction_sampler_and_receive_mock_called(

tests/sentry/receivers/test_onboarding.py

-30
Original file line numberDiff line numberDiff line change
@@ -14,18 +14,15 @@
1414
from sentry.models.project import Project
1515
from sentry.models.rule import Rule
1616
from sentry.organizations.services.organization import organization_service
17-
from sentry.plugins.bases.issue import IssueTrackingPlugin
1817
from sentry.signals import (
1918
alert_rule_created,
2019
event_processed,
2120
first_event_received,
2221
first_replay_received,
2322
first_transaction_received,
2423
integration_added,
25-
issue_tracker_used,
2624
member_invited,
2725
member_joined,
28-
plugin_enabled,
2926
project_created,
3027
transaction_processed,
3128
)
@@ -274,33 +271,6 @@ def test_member_joined(self):
274271
)
275272
assert task.data["invited_member_id"] == om.id
276273

277-
def test_issue_tracker_onboarding(self):
278-
plugin_enabled.send(
279-
plugin=IssueTrackingPlugin(),
280-
project=self.project,
281-
user=self.user,
282-
sender=type(IssueTrackingPlugin),
283-
)
284-
task = OrganizationOnboardingTask.objects.get(
285-
organization=self.organization,
286-
task=OnboardingTask.ISSUE_TRACKER,
287-
status=OnboardingTaskStatus.PENDING,
288-
)
289-
assert task is not None
290-
291-
issue_tracker_used.send(
292-
plugin=IssueTrackingPlugin(),
293-
project=self.project,
294-
user=self.user,
295-
sender=type(IssueTrackingPlugin),
296-
)
297-
task = OrganizationOnboardingTask.objects.get(
298-
organization=self.organization,
299-
task=OnboardingTask.ISSUE_TRACKER,
300-
status=OnboardingTaskStatus.COMPLETE,
301-
)
302-
assert task is not None
303-
304274
def test_alert_added(self):
305275
alert_rule_created.send(
306276
rule_id=Rule(id=1).id,

0 commit comments

Comments
 (0)