From 3438b1f1ae276c6a7117c1a88c38ff9be9bd7ba3 Mon Sep 17 00:00:00 2001 From: Ryan Albrecht Date: Fri, 4 Oct 2024 10:01:35 -0700 Subject: [PATCH] chore: Add session-replay-rage-click-issue-creation flagpole guard --- src/sentry/features/temporary.py | 4 ++++ src/sentry/replays/usecases/ingest/dom_index.py | 10 +++++++++- .../sentry/replays/unit/test_ingest_dom_index.py | 16 ++++++++++------ 3 files changed, 23 insertions(+), 7 deletions(-) diff --git a/src/sentry/features/temporary.py b/src/sentry/features/temporary.py index c3f0e6f7d211f3..96602912d32ffe 100644 --- a/src/sentry/features/temporary.py +++ b/src/sentry/features/temporary.py @@ -393,6 +393,10 @@ def register_temporary_features(manager: FeatureManager): manager.add("organizations:session-replay-enable-canvas", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True) # Enable canvas replaying manager.add("organizations:session-replay-enable-canvas-replayer", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True) + + # Enable Hydration Error Issue Creation In Recording Consumer + manager.add("organizations:session-replay-hydration-error-issue-creation", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True) + # Enable linking from 'new issue' email notifs to the issue replay list manager.add("organizations:session-replay-issue-emails", OrganizationFeature, FeatureHandlerStrategy.INTERNAL, api_expose=False) # Enable queries to materialized view from replay index endpoint diff --git a/src/sentry/replays/usecases/ingest/dom_index.py b/src/sentry/replays/usecases/ingest/dom_index.py index 99d35cdf5deef5..a9dd00ffa0fef3 100644 --- a/src/sentry/replays/usecases/ingest/dom_index.py +++ b/src/sentry/replays/usecases/ingest/dom_index.py @@ -8,6 +8,7 @@ from hashlib import md5 from typing import Any, Literal, TypedDict +from sentry import features from sentry.conf.types.kafka_definition import Topic from sentry.models.project import Project from sentry.replays.usecases.ingest.issue_creation import ( @@ -301,7 +302,14 @@ def _should_report_hydration_error_issue(project: Project) -> bool: """ Checks the project option, controlled by a project owner. """ - return project.get_option("sentry:replay_hydration_error_issues") + + # Killswitch + has_feature = features.has( + "organizations:session-replay-rage-click-issue-creation", + project.organization, + ) + + return has_feature and project.get_option("sentry:replay_hydration_error_issues") def _should_report_rage_click_issue(project: Project) -> bool: diff --git a/tests/sentry/replays/unit/test_ingest_dom_index.py b/tests/sentry/replays/unit/test_ingest_dom_index.py index 34eaa548fafb32..d22a7206a3077c 100644 --- a/tests/sentry/replays/unit/test_ingest_dom_index.py +++ b/tests/sentry/replays/unit/test_ingest_dom_index.py @@ -17,6 +17,7 @@ log_canvas_size, parse_replay_actions, ) +from sentry.testutils.helpers.features import Feature from sentry.testutils.pytest.fixtures import django_db_all from sentry.utils import json @@ -384,8 +385,9 @@ def test_parse_replay_dead_click_actions(patch_rage_click_issue_with_replay_even }, ] - default_project.update_option("sentry:replay_rage_click_issues", True) - replay_actions = parse_replay_actions(default_project, "1", 30, events, mock_replay_event()) + with Feature({"organizations:session-replay-rage-click-issue-creation": True}): + default_project.update_option("sentry:replay_rage_click_issues", True) + replay_actions = parse_replay_actions(default_project, "1", 30, events, mock_replay_event()) assert patch_rage_click_issue_with_replay_event.call_count == 2 assert replay_actions is not None assert replay_actions["type"] == "replay_event" @@ -537,8 +539,9 @@ def test_rage_click_issue_creation_no_component_name( }, ] - default_project.update_option("sentry:replay_rage_click_issues", True) - parse_replay_actions(default_project, "1", 30, events, mock_replay_event()) + with Feature({"organizations:session-replay-rage-click-issue-creation": True}): + default_project.update_option("sentry:replay_rage_click_issues", True) + parse_replay_actions(default_project, "1", 30, events, mock_replay_event()) # test that 2 rage click issues are still created assert patch_rage_click_issue_with_replay_event.call_count == 2 @@ -939,8 +942,9 @@ def test_parse_replay_rage_clicks_with_replay_event( }, ] - default_project.update_option("sentry:replay_rage_click_issues", True) - replay_actions = parse_replay_actions(default_project, "1", 30, events, mock_replay_event()) + with Feature({"organizations:session-replay-rage-click-issue-creation": True}): + default_project.update_option("sentry:replay_rage_click_issues", True) + replay_actions = parse_replay_actions(default_project, "1", 30, events, mock_replay_event()) assert patch_rage_click_issue_with_replay_event.call_count == 2 assert replay_actions is not None assert replay_actions["type"] == "replay_event"