Skip to content

Commit e190f43

Browse files
authored
fix(hybridcloud) Add org slug route for prompts-activity (#63122)
This endpoint is region scoped as all the current prompts are organization bound. Having an organization_slug path will allow us to do regional routing. I've also added the slug-less path to the US pinned route list. Once this is merged, I'll update the UI code to use the new route. Refs HC-1066
1 parent 00c7a6e commit e190f43

File tree

6 files changed

+19
-9
lines changed

6 files changed

+19
-9
lines changed

src/sentry/api/endpoints/prompts_activity.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class PromptsActivityEndpoint(Endpoint):
4242
}
4343
permission_classes = (IsAuthenticated,)
4444

45-
def get(self, request: Request) -> Response:
45+
def get(self, request: Request, **kwargs) -> Response:
4646
"""Return feature prompt status if dismissed or in snoozed period"""
4747

4848
features = request.GET.getlist("feature")
@@ -71,7 +71,7 @@ def get(self, request: Request) -> Response:
7171
else:
7272
return Response({"features": featuredata})
7373

74-
def put(self, request: Request):
74+
def put(self, request: Request, **kwargs):
7575
serializer = PromptsActivitySerializer(data=request.data)
7676
if not serializer.is_valid():
7777
return Response(serializer.errors, status=400)

src/sentry/api/urls.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,6 +2006,11 @@
20062006
OrganizationUnsubscribeIssue.as_view(),
20072007
name="sentry-api-0-organization-unsubscribe-issue",
20082008
),
2009+
re_path(
2010+
r"^(?P<organization_slug>[^/]+)/prompts-activity/$",
2011+
PromptsActivityEndpoint.as_view(),
2012+
name="sentry-api-0-organization-prompts-activity",
2013+
),
20092014
]
20102015

20112016
PROJECT_URLS: list[URLPattern | URLResolver] = [

src/sentry/apidocs/api_ownership_allowlist_dont_modify.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,7 @@
275275
"/extensions/slack/action/",
276276
"/api/0/organizations/{organization_slug}/discover/saved/{query_id}/visit/",
277277
"/api/0/prompts-activity/",
278+
"/api/0/organizations/{organization_slug}/prompts-activity/",
278279
"/api/0/teams/{organization_slug}/{team_slug}/avatar/",
279280
"/api/0/organizations/{organization_slug}/api-keys/{api_key_id}/",
280281
"/api/0/projects/{organization_slug}/{project_slug}/releases/completion/",

src/sentry/apidocs/api_publish_status_allowlist_dont_modify.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,7 @@
681681
"/api/0/api-authorizations/": {"GET", "DELETE"},
682682
"/api/0/api-tokens/": {"DELETE", "GET", "POST"},
683683
"/api/0/prompts-activity/": {"GET", "PUT"},
684+
"/api/0/organizations/{organization_slug}/prompts-activity/": {"GET", "PUT"},
684685
"/api/0/authenticators/": {"GET"},
685686
"/api/0/accept-transfer/": {"GET", "POST"},
686687
"/api/0/accept-invite/{organization_slug}/{member_id}/{token}/": {"GET", "POST"},

src/sentry/conf/server.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3965,6 +3965,7 @@ def build_cdc_postgres_init_db_volume(settings: Any) -> dict[str, dict[str, str]
39653965
# These paths have organization scoped aliases
39663966
"sentry-api-0-builtin-symbol-sources",
39673967
"sentry-api-0-grouping-configs",
3968+
"sentry-api-0-prompts-activity",
39683969
# Legacy monitor endpoints
39693970
"sentry-api-0-monitor-ingest-check-in-index",
39703971
# These paths are used by relay which is implicitly region scoped

tests/sentry/api/endpoints/test_prompts_activity.py

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,11 @@ def setUp(self):
88
super().setUp()
99
self.login_as(user=self.user)
1010
self.org = self.create_organization(owner=self.user, name="baz")
11-
# self.project = self.create_project(
12-
# organization=self.org,
13-
# # teams=[self.team],
14-
# # name='Bengal-Elephant-Giraffe-Tree-House',
15-
# )
16-
1711
self.team = self.create_team(organization=self.org, name="Mariachi Band")
1812
self.project = self.create_project(
1913
organization=self.org, teams=[self.team], name="Bengal-Elephant-Giraffe-Tree-House"
2014
)
21-
self.path = reverse("sentry-api-0-prompts-activity")
15+
self.path = reverse("sentry-api-0-organization-prompts-activity", args=[self.org.slug])
2216

2317
def test_invalid_feature(self):
2418
# Invalid feature prompt name
@@ -95,6 +89,10 @@ def test_dismiss(self):
9589
assert "data" in resp.data
9690
assert "dismissed_ts" in resp.data["data"]
9791

92+
def test_dismiss_legacy_path(self):
93+
self.path = reverse("sentry-api-0-prompts-activity")
94+
self.test_dismiss()
95+
9896
def test_snooze(self):
9997
data = {
10098
"organization_id": self.org.id,
@@ -121,6 +119,10 @@ def test_snooze(self):
121119
assert "data" in resp.data
122120
assert "snoozed_ts" in resp.data["data"]
123121

122+
def test_snooze_legacy_path(self):
123+
self.path = reverse("sentry-api-0-prompts-activity")
124+
self.test_snooze()
125+
124126
def test_batched(self):
125127
data = {
126128
"organization_id": self.org.id,

0 commit comments

Comments
 (0)