Skip to content

Commit b5a13ee

Browse files
authored
feat(agents-insights): Add prefersAgentsInsightsModule user option (#93802)
1 parent 633f26d commit b5a13ee

File tree

4 files changed

+33
-0
lines changed

4 files changed

+33
-0
lines changed

src/sentry/users/api/endpoints/user_details.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ class UserOptionsSerializer(serializers.Serializer[UserOption]):
8282
prefersNextjsInsightsOverview = serializers.BooleanField(required=False)
8383
prefersStackedNavigation = serializers.BooleanField(required=False)
8484
prefersChonkUI = serializers.BooleanField(required=False)
85+
prefersAgentsInsightsModule = serializers.BooleanField(required=False)
8586

8687
quickStartDisplay = serializers.JSONField(
8788
required=False,
@@ -260,6 +261,7 @@ def put(self, request: Request, user: User) -> Response:
260261
"prefersStackedNavigation": "prefers_stacked_navigation",
261262
"prefersNextjsInsightsOverview": "prefers_nextjs_insights_overview",
262263
"prefersChonkUI": "prefers_chonk_ui",
264+
"prefersAgentsInsightsModule": "prefers_agents_insights_module",
263265
"quickStartDisplay": "quick_start_display",
264266
}
265267

src/sentry/users/api/serializers/user.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@ class _UserOptions(TypedDict):
6969
prefersStackedNavigation: bool | None
7070
prefersChonkUI: bool
7171
quickStartDisplay: dict[str, int]
72+
prefersAgentsInsightsModule: bool
7273

7374

7475
class UserSerializerResponseOptional(TypedDict, total=False):
@@ -208,6 +209,7 @@ def serialize(
208209
"prefersStackedNavigation": options.get("prefers_stacked_navigation"),
209210
"prefersChonkUI": options.get("prefers_chonk_ui", False),
210211
"quickStartDisplay": options.get("quick_start_display") or {},
212+
"prefersAgentsInsightsModule": options.get("prefers_agents_insights_module", True),
211213
}
212214

213215
d["flags"] = {"newsletter_consent_prompt": bool(obj.flags.newsletter_consent_prompt)}

src/sentry/users/models/user_option.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,8 @@ class UserOption(Model):
169169
- Whether the user prefers the new stacked navigation experience (boolean)
170170
- prefers_nextjs_insights_overview
171171
- Whether the user prefers the new NextJS insights overview experience (boolean)
172+
- prefers_agents_insights_module
173+
- Whether the user prefers the new Agents insights module experience (boolean)
172174
- prefers_chonk_ui
173175
- Whether the user prefers the new Chonk UI experience (boolean)
174176
- quick_start_display

tests/sentry/users/api/endpoints/test_user_details.py

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ def test_simple(self):
123123
"prefersStackedNavigation": True,
124124
"prefersChonkUI": True,
125125
"quickStartDisplay": {self.organization.id: 1},
126+
"prefersAgentsInsightsModule": True,
126127
},
127128
)
128129

@@ -153,6 +154,7 @@ def test_simple(self):
153154
)
154155

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

157159
def test_saving_changes_value(self):
158160
"""
@@ -299,6 +301,31 @@ def test_saving_quick_start_display_option(self):
299301
status_code=400,
300302
)
301303

304+
def test_saving_agents_insights_module_option(self):
305+
self.get_success_response(
306+
"me",
307+
options={"prefersAgentsInsightsModule": True},
308+
)
309+
assert (
310+
UserOption.objects.get_value(user=self.user, key="prefers_agents_insights_module")
311+
is True
312+
)
313+
314+
self.get_success_response(
315+
"me",
316+
options={"prefersAgentsInsightsModule": False},
317+
)
318+
assert (
319+
UserOption.objects.get_value(user=self.user, key="prefers_agents_insights_module")
320+
is False
321+
)
322+
323+
def test_default_agents_insights_module_option_is_true(self):
324+
resp = self.get_success_response(
325+
"me",
326+
)
327+
assert resp.data["options"]["prefersAgentsInsightsModule"] is True
328+
302329

303330
@control_silo_test
304331
class UserDetailsSuperuserUpdateTest(UserDetailsTest):

0 commit comments

Comments
 (0)