Skip to content

feat(api): Use region-specific URLs in API doc curl examples#17779

Open
mwarkentin wants to merge 5 commits into
masterfrom
michaelwarkentin/inc-2335-improve-api-docs-with-region-specific-endpoint-examples
Open

feat(api): Use region-specific URLs in API doc curl examples#17779
mwarkentin wants to merge 5 commits into
masterfrom
michaelwarkentin/inc-2335-improve-api-docs-with-region-specific-endpoint-examples

Conversation

@mwarkentin
Copy link
Copy Markdown
Member

DESCRIBE YOUR PR

API doc pages (e.g. /api/explore/query-explore-events-in-table-format/) currently render curl examples with https://sentry.io/api/0/... as the base URL. This ignores the OpenAPI spec's servers field which defines region-specific URLs (https://{region}.sentry.io).

This PR:

  • Reads the global servers field from the OpenAPI spec instead of hardcoding sentry.io. Per-operation server overrides are still respected first, then the global servers block, then https://sentry.io as a safety fallback.
  • Adds a region picker (US | DE tabs) above the curl code block on every API endpoint page, so users can switch between https://us.sentry.io/api/0/... and https://de.sentry.io/api/0/....
  • Auto-detects the region for logged-in users by reading their project's API_URL from CodeContext, pre-selecting the correct tab.

This steers customers (especially those on the DE region) toward the correct regional endpoint, avoiding cross-Atlantic RPCs.

Refs INC-2335

IS YOUR CHANGE URGENT?

  • Urgent deadline (GA date, etc.)
  • Other deadline
  • None: Not urgent, can wait up to 1 week+

PRE-MERGE CHECKLIST

  • Checked Vercel preview for correctness, including links
  • PR was reviewed and approved by any necessary SMEs (subject matter experts)
  • PR was reviewed and approved by a member of the Sentry docs team

Made with Cursor

Read the global `servers` field from the OpenAPI spec instead of
hardcoding `sentry.io` as the base URL for curl examples. The spec
defines `https://{region}.sentry.io` with region enum (us, de), so
curl examples now render as `https://us.sentry.io/api/0/...` with a
region picker (US | DE tabs) above the code block.

For logged-in users, the region is auto-detected from their
CodeContext project data so the correct regional endpoint is
pre-selected.

Refs INC-2335
Co-Authored-By: Claude <noreply@anthropic.com>

Co-authored-by: Cursor <cursoragent@cursor.com>
@linear-code
Copy link
Copy Markdown

linear-code Bot commented May 15, 2026

INC-2335

@vercel
Copy link
Copy Markdown

vercel Bot commented May 15, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
develop-docs Ready Ready Preview, Comment May 15, 2026 9:14pm
sentry-docs Ready Ready Preview, Comment May 15, 2026 9:14pm

Request Review

Comment thread src/components/apiExamples/apiExamples.tsx Fixed
Satisfy CodeQL js/regex/missing-regexp-anchor by requiring a `/`
after `.sentry.io` so the pattern cannot match lookalike domains.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
mwarkentin and others added 2 commits May 15, 2026 16:20
Fixes react-hooks/exhaustive-deps lint error where the fallback
empty array created a new reference on every render.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Copy link
Copy Markdown
Contributor

@cursor cursor Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit b2ecd86. Configure here.

Comment thread src/components/apiExamples/apiExamples.tsx
Read sharedKeywordSelection to resolve the user's currently selected
project instead of always reading PROJECT[0]. This ensures the region
tab matches when users switch between projects in different regions.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
@sergical
Copy link
Copy Markdown
Member

CleanShot 2026-05-19 at 11 11 20@2x

Just thinking out loud, would it make more sense to have it be 2 separate code tabs in the snippet vs additional tabs above? @mwarkentin

@mwarkentin
Copy link
Copy Markdown
Member Author

@sergical do you mean tabs where we have "bash"? Or underneath that?

@sergical
Copy link
Copy Markdown
Member

@sergical do you mean tabs where we have "bash"? Or underneath that?

yeah where it says Bash. I am not sure if we can create those programmatically but feels like something that can be done?

And then the UX will be more close to for example
CleanShot 2026-05-19 at 16 19 36@2x

@mwarkentin
Copy link
Copy Markdown
Member Author

mwarkentin commented May 19, 2026

@sergical seems like that would get a bit weird - would we have a us and de tab for each language that we support? Seems like a different "level" of hierarchy compared to language.

Edit: Note that this will get worse as new localities are added in the future.

@sergical
Copy link
Copy Markdown
Member

@sergical seems like that would get a bit weird - would we have a us and de tab for each language that we support? Seems like a different "level" of hierarchy compared to language.

Edit: Note that this will get worse as new localities are added in the future.

I was thinking since it's for api docs, there isn't anything language specific and it's just curl commands with different urls.

maybe the right approach is on API routes to have a region dropdown where on SDK pages we have the SDK dropdown?

Sorry, im just trying to figure out a way to have existing patterns serve the need. since most of the time a user looking at docs will only care about 1 config for the region vs each code block example, thoughts?
CleanShot 2026-05-19 at 16 27 48@2x
CleanShot 2026-05-19 at 16 27 44@2x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants