Skip to content

Commit 287ab98

Browse files
committed
feat(api): Add integration endpoint to project key serializer
1 parent 9bda99e commit 287ab98

File tree

4 files changed

+25
-0
lines changed

4 files changed

+25
-0
lines changed

src/sentry/api/serializers/models/project_key.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class DSN(TypedDict):
2828
crons: str
2929
cdn: str
3030
playstation: str
31+
integration: str
3132
otlp_traces: str
3233
otlp_logs: str
3334

@@ -98,6 +99,7 @@ def serialize(
9899
"crons": obj.crons_endpoint,
99100
"cdn": obj.js_sdk_loader_cdn_url,
100101
"playstation": obj.playstation_endpoint,
102+
"integration": obj.integration_endpoint,
101103
"otlp_traces": obj.otlp_traces_endpoint,
102104
"otlp_logs": obj.otlp_logs_endpoint,
103105
},

src/sentry/apidocs/examples/project_examples.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"security": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/security/?sentry_key=a785682ddda719b7a8a4011110d75598",
1919
"minidump": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/minidump/?sentry_key=a785682ddda719b7a8a4011110d75598",
2020
"playstation": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/playstation/?sentry_key=a785682ddda719b7a8a4011110d75598",
21+
"integration": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/integration/",
2122
"otlp_traces": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/integration/otlp/v1/traces",
2223
"otlp_logs": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/integration/otlp/v1/logs",
2324
"nel": "https://o4504765715316736.ingest.sentry.io/api/4505281256090153/nel/?sentry_key=a785682ddda719b7a8a4011110d75598",

src/sentry/models/projectkey.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,11 @@ def playstation_endpoint(self):
265265

266266
return f"{endpoint}/api/{self.project_id}/playstation/?sentry_key={self.public_key}"
267267

268+
def integration_endpoint(self):
269+
endpoint = self.get_endpoint()
270+
271+
return f"{endpoint}/api/{self.project_id}/integration/"
272+
268273
@property
269274
def otlp_traces_endpoint(self):
270275
endpoint = self.get_endpoint()

tests/sentry/core/endpoints/test_project_keys.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,22 @@ def test_playstation_dsn(self) -> None:
4040
assert response.status_code == 200
4141
assert response.data[0]["dsn"]["playstation"] == key.playstation_endpoint
4242

43+
def test_integration_endpoint(self) -> None:
44+
project = self.create_project()
45+
key = ProjectKey.objects.get_or_create(project=project)[0]
46+
self.login_as(user=self.user)
47+
url = reverse(
48+
"sentry-api-0-project-keys",
49+
kwargs={
50+
"organization_id_or_slug": project.organization.slug,
51+
"project_id_or_slug": project.slug,
52+
},
53+
)
54+
response = self.client.get(url)
55+
assert response.status_code == 200
56+
assert response.data[0]["dsn"]["integration"] == key.integration_endpoint
57+
assert "integration/" in response.data[0]["dsn"]["integration"]
58+
4359
def test_otlp_traces_endpoint(self) -> None:
4460
project = self.create_project()
4561
key = ProjectKey.objects.get_or_create(project=project)[0]
@@ -54,6 +70,7 @@ def test_otlp_traces_endpoint(self) -> None:
5470
response = self.client.get(url)
5571
assert response.status_code == 200
5672
assert response.data[0]["dsn"]["otlp_traces"] == key.otlp_traces_endpoint
73+
assert "integration/otlp/v1/traces" in response.data[0]["dsn"]["otlp_traces"]
5774

5875
def test_otlp_logs_endpoint(self) -> None:
5976
project = self.create_project()

0 commit comments

Comments
 (0)