Skip to content

feat(astro): Parametrize routes on client-side #17133

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 7 commits into from
Jul 24, 2025
Merged

Conversation

s1gr1d
Copy link
Member

@s1gr1d s1gr1d commented Jul 23, 2025

Route Parametrization for Server Requests in Astro.

The route is stored in a meta tag so the client can receive the parametrized information.

Last part of this issue and closes #16686

@s1gr1d s1gr1d requested review from Lms24 and andreiborza July 23, 2025 14:14
cursor[bot]

This comment was marked as outdated.

cursor[bot]

This comment was marked as outdated.

Copy link
Contributor

github-actions bot commented Jul 23, 2025

size-limit report 📦

Path Size % Change Change
@sentry/browser 23.75 kB - -
@sentry/browser - with treeshaking flags 22.33 kB - -
@sentry/browser (incl. Tracing) 39.6 kB - -
@sentry/browser (incl. Tracing, Replay) 77.77 kB - -
@sentry/browser (incl. Tracing, Replay) - with treeshaking flags 67.58 kB - -
@sentry/browser (incl. Tracing, Replay with Canvas) 82.47 kB - -
@sentry/browser (incl. Tracing, Replay, Feedback) 94.57 kB - -
@sentry/browser (incl. Feedback) 40.44 kB - -
@sentry/browser (incl. sendFeedback) 28.42 kB - -
@sentry/browser (incl. FeedbackAsync) 33.33 kB - -
@sentry/react 25.49 kB - -
@sentry/react (incl. Tracing) 41.58 kB - -
@sentry/vue 28.18 kB - -
@sentry/vue (incl. Tracing) 41.4 kB - -
@sentry/svelte 23.77 kB - -
CDN Bundle 25.16 kB - -
CDN Bundle (incl. Tracing) 39.4 kB - -
CDN Bundle (incl. Tracing, Replay) 75.4 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) 80.88 kB - -
CDN Bundle - uncompressed 73.42 kB - -
CDN Bundle (incl. Tracing) - uncompressed 116.83 kB - -
CDN Bundle (incl. Tracing, Replay) - uncompressed 230.97 kB - -
CDN Bundle (incl. Tracing, Replay, Feedback) - uncompressed 243.78 kB - -
@sentry/nextjs (client) 43.61 kB - -
@sentry/sveltekit (client) 40.03 kB - -
@sentry/node-core 47.23 kB -0.01% -1 B 🔽
@sentry/node 143.89 kB - -
@sentry/node - without tracing 91.31 kB - -
@sentry/aws-serverless 102.75 kB -0.01% -1 B 🔽

View base workflow run

Copy link
Member

@Lms24 Lms24 left a comment

Choose a reason for hiding this comment

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

Nice!

const routeNameFromMetaTags = getMetaContent('sentry-route-name');

if (routeNameFromMetaTags) {
const decodedRouteName = decodeURIComponent(routeNameFromMetaTags);
Copy link
Member

Choose a reason for hiding this comment

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

l: can we try/catch the decoding? Chances are low that it fails but we had similar issues (#16251) before.

Copy link
Member

@chargome chargome left a comment

Choose a reason for hiding this comment

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

Nice! Did you double check that e.g. catch-all/[...path] and catch-all/static in the same app get parameterized correctly?

DEBUG_BUILD && debug.log(`[Tracing] Using route name from Sentry HTML meta-tag: ${decodedRouteName}`);

pageLoadSpan.updateName(decodedRouteName);
pageLoadSpan.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_SOURCE, 'route' as TransactionSource);
Copy link
Member

Choose a reason for hiding this comment

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

We could also update the sentry.origin here to reflect that this is coming from the custom browser instrumentation.

@s1gr1d
Copy link
Member Author

s1gr1d commented Jul 24, 2025

Did you double check that e.g. catch-all/[...path] and catch-all/static in the same app get parameterized correctly?

Yes, there is an E2E test for that in astro-5 but I'll reflect the same test to astro-4.

@s1gr1d s1gr1d merged commit f807802 into develop Jul 24, 2025
142 of 143 checks passed
@s1gr1d s1gr1d deleted the sig/astro-client-param branch July 24, 2025 09:31
s1gr1d added a commit that referenced this pull request Jul 24, 2025
Route Parametrization for Server Requests in Astro. 

The route is stored in a meta tag so the client can receive the
parametrized information.

Last part of this issue and closes
#16686
s1gr1d added a commit that referenced this pull request Jul 24, 2025
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.

Implement parametrized routes for Astro
3 participants