Skip to content

feat(agents-insights): Add prefersAgentsInsightsModule user option #93802

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

Merged
merged 3 commits into from
Jun 20, 2025
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
2 changes: 2 additions & 0 deletions src/sentry/users/api/endpoints/user_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class UserOptionsSerializer(serializers.Serializer[UserOption]):
prefersNextjsInsightsOverview = serializers.BooleanField(required=False)
prefersStackedNavigation = serializers.BooleanField(required=False)
prefersChonkUI = serializers.BooleanField(required=False)
prefersAgentsInsightsModule = serializers.BooleanField(required=False)

quickStartDisplay = serializers.JSONField(
required=False,
Expand Down Expand Up @@ -260,6 +261,7 @@ def put(self, request: Request, user: User) -> Response:
"prefersStackedNavigation": "prefers_stacked_navigation",
"prefersNextjsInsightsOverview": "prefers_nextjs_insights_overview",
"prefersChonkUI": "prefers_chonk_ui",
"prefersAgentsInsightsModule": "prefers_agents_insights_module",
"quickStartDisplay": "quick_start_display",
}

Expand Down
2 changes: 2 additions & 0 deletions src/sentry/users/api/serializers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ class _UserOptions(TypedDict):
prefersStackedNavigation: bool | None
prefersChonkUI: bool
quickStartDisplay: dict[str, int]
prefersAgentsInsightsModule: bool


class UserSerializerResponseOptional(TypedDict, total=False):
Expand Down Expand Up @@ -208,6 +209,7 @@ def serialize(
"prefersStackedNavigation": options.get("prefers_stacked_navigation"),
"prefersChonkUI": options.get("prefers_chonk_ui", False),
"quickStartDisplay": options.get("quick_start_display") or {},
"prefersAgentsInsightsModule": options.get("prefers_agents_insights_module", True),
}

d["flags"] = {"newsletter_consent_prompt": bool(obj.flags.newsletter_consent_prompt)}
Expand Down
2 changes: 2 additions & 0 deletions src/sentry/users/models/user_option.py
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ class UserOption(Model):
- Whether the user prefers the new stacked navigation experience (boolean)
- prefers_nextjs_insights_overview
- Whether the user prefers the new NextJS insights overview experience (boolean)
- prefers_agents_insights_module
- Whether the user prefers the new Agents insights module experience (boolean)
- prefers_chonk_ui
- Whether the user prefers the new Chonk UI experience (boolean)
- quick_start_display
Expand Down
27 changes: 27 additions & 0 deletions tests/sentry/users/api/endpoints/test_user_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ def test_simple(self):
"prefersStackedNavigation": True,
"prefersChonkUI": True,
"quickStartDisplay": {self.organization.id: 1},
"prefersAgentsInsightsModule": True,
},
)

Expand Down Expand Up @@ -153,6 +154,7 @@ def test_simple(self):
)

assert not UserOption.objects.get_value(user=self.user, key="extra")
assert UserOption.objects.get_value(user=self.user, key="prefers_agents_insights_module")

def test_saving_changes_value(self):
"""
Expand Down Expand Up @@ -299,6 +301,31 @@ def test_saving_quick_start_display_option(self):
status_code=400,
)

def test_saving_agents_insights_module_option(self):
self.get_success_response(
"me",
options={"prefersAgentsInsightsModule": True},
)
assert (
UserOption.objects.get_value(user=self.user, key="prefers_agents_insights_module")
is True
)

self.get_success_response(
"me",
options={"prefersAgentsInsightsModule": False},
)
assert (
UserOption.objects.get_value(user=self.user, key="prefers_agents_insights_module")
is False
)

def test_default_agents_insights_module_option_is_true(self):
resp = self.get_success_response(
"me",
)
assert resp.data["options"]["prefersAgentsInsightsModule"] is True


@control_silo_test
class UserDetailsSuperuserUpdateTest(UserDetailsTest):
Expand Down
Loading