GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — fix(nextjs): Support automatic instrumentation for app directory with custom page extensions by ziyadkhalil · Pull Request #12858 · getsentry/sentry-javascript

Conversation

@ziyadkhalil

@ziyadkhalil ziyadkhalil commented Jul 10, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Contributor

This PR updates the regex and logic for detecting middleware, route handler, and server component files to support custom page extensions, such as middleware.custom.ts and route.custom.ts.

Changes Made

  • Modified the isRouteHandler function to use a regex that matches custom page extensions for route handler files.
  • Modified the isMiddlewareResource function to use a regex that matches custom page extensions for middleware files.
  • Modified the isServerComponent function to use a regex that matches custom page extensions for server component files.
  • modified hasGlobalErrorFile flag to account for custom page extensions

Testing

  • Verified the updated regex matches route handlers and middleware files with standard and custom extensions.
  • Added new cases for server loaders tests to cover route handler files
  • Updated and passed all test cases.
  • Added a duplicate e2e nextjs project with page extensions enabled and it passes all tests e2e(nextjs): add nextjs app dir project with page extensions #12864

Checklist

  • Modified isRouteHandler function.
  • Modified isMiddlewareResource function.
  • Modified isServerComponent function.
  • Modified hasGlobalErrorFile flag.
  • Manual and automated testing completed.
  • e2e tests e2e(nextjs): add nextjs app dir project with page extensions #12864

Please review and provide feedback. Thank you!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

HagerDakroury reacted with hooray emoji HagerDakroury reacted with heart emoji millar and HagerDakroury reacted with rocket emoji
All reactions
  • 🎉 1 reaction
  • ❤️ 1 reaction
  • 🚀 2 reactions
@ziyadkhalil ziyadkhalil changed the title fix(nextjs): Support automatic instrumentation for route handlers and… fix(nextjs): Support automatic instrumentation for route handlers and middleware with custom page extensions Jul 10, 2024
AbhiPrasad
AbhiPrasad reviewed Jul 10, 2024
View reviewed changes

@AbhiPrasad AbhiPrasad left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

@ziyadkhalil thanks for the PR! Could you update an e2e test to validate this? https://github.com/getsentry/sentry-javascript/tree/develop/dev-packages/e2e-tests

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
ziyadkhalil added a commit to ziyadkhalil/sentry-javascript that referenced this pull request Jul 10, 2024
@ziyadkhalil
fix(nextjs): Support automatic instrumentation for route handlers and…
295e85b
… middleware with page extensions (getsentry#12858)
@ziyadkhalil
ziyadkhalil force-pushed the ziyad/fix-route-handlers-instrumentation branch from 317caa7 to 295e85b Compare July 10, 2024 18:44
@ziyadkhalil

ziyadkhalil commented Jul 10, 2024

Copy link
Copy Markdown
Contributor Author

@ziyadkhalil thanks for the PR! Could you update an e2e test to validate this? https://github.com/getsentry/sentry-javascript/tree/develop/dev-packages/e2e-tests

@AbhiPrasad Sure! I'm not sure which test to update tho as to test this change we have to set the pageExtension option in next.config.js.
Should I add a new nextjs project under test applications with the page extension option set in next.config.js and have the same tests as nextjs-app-dir?

Thank you for the quick feedback!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@AbhiPrasad

AbhiPrasad commented Jul 10, 2024

Copy link
Copy Markdown
Contributor

Sure! I'm not sure which test to update tho as to test this change we have to set the pageExtension option in next.config.js

Good question. I'll let the other sdk maintainers chime in here for this as I have no strong opinions

ziyadkhalil reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ziyadkhalil
ziyadkhalil force-pushed the ziyad/fix-route-handlers-instrumentation branch from 295e85b to 432ecb0 Compare July 10, 2024 21:53
ziyadkhalil added a commit to ziyadkhalil/sentry-javascript that referenced this pull request Jul 10, 2024
@ziyadkhalil
fix(nextjs): Support automatic instrumentation for route handlers and…
432ecb0
… middleware with page extensions (getsentry#12858)
@ziyadkhalil
fix(nextjs): Support automatic instrumentation for app directory with…
bb20466
… page extensions (getsentry#12858)
@ziyadkhalil
ziyadkhalil force-pushed the ziyad/fix-route-handlers-instrumentation branch from 432ecb0 to bb20466 Compare July 10, 2024 22:48
@ziyadkhalil ziyadkhalil changed the title fix(nextjs): Support automatic instrumentation for route handlers and middleware with custom page extensions fix(nextjs): Support automatic instrumentation for app directory with custom page extensions Jul 10, 2024
@ziyadkhalil ziyadkhalil mentioned this pull request Jul 10, 2024
e2e(nextjs): add nextjs app dir project with page extensions #12864
Closed
@ziyadkhalil

ziyadkhalil commented Jul 10, 2024

Copy link
Copy Markdown
Contributor Author

@AbhiPrasad Great! I created another PR #12864 with the suggested solution and it was a great idea that made me notice that page extensions feature is not working for server components as well.
I updated this PR to enable instrumentation for server components as well.
It passes all the e2e tests in the other PR #12864

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@ziyadkhalil
ziyadkhalil requested a review from AbhiPrasad July 10, 2024 23:15
@lforst
lforst self-requested a review July 11, 2024 07:22
Luca Forstner
fix
8ad089a
lforst
lforst approved these changes Jul 11, 2024
View reviewed changes

@lforst lforst left a comment

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

Thank you!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

ziyadkhalil reacted with thumbs up emoji
All reactions
  • 👍 1 reaction
lforst
lforst reviewed Jul 11, 2024
View reviewed changes
Comment thread packages/nextjs/test/config/loaders.test.ts
Comment on lines -174 to -175
resourcePath: '/Users/Maisey/projects/squirrelChasingSimulator/src/app/nested/page.ts', // ts is not a valid file ending for pages in the app dir
expectedWrappingTargetKind: undefined,

@lforst lforst Jul 11, 2024

Copy link
Copy Markdown
Contributor

There was a problem hiding this comment.

Choose a reason for hiding this comment

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

I checked and this is actually not true. It's just very uncommon because usually you have jsx in your pages.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@lforst

lforst commented Jul 11, 2024

Copy link
Copy Markdown
Contributor

I am gonna merge this so that this is off your plate @ziyadkhalil. I will add tests as a follow-up.

ziyadkhalil reacted with thumbs up emoji
All reactions
  • 👍 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@lforst
lforst merged commit 1be3b4a into getsentry:develop Jul 11, 2024
@ziyadkhalil ziyadkhalil mentioned this pull request Jul 16, 2024
meta: Update CHANGELOG for 8.18.0 #12932
Merged
@ziyadkhalil
ziyadkhalil deleted the ziyad/fix-route-handlers-instrumentation branch July 17, 2024 09:47
@ziyadkhalil
ziyadkhalil restored the ziyad/fix-route-handlers-instrumentation branch July 17, 2024 09:47
@angeloreale angeloreale mentioned this pull request Aug 6, 2024
[Snyk] Upgrade @sentry/nextjs from 8.17.0 to 8.18.0 dupipcom/hypnos#18
Closed
@q1blue q1blue mentioned this pull request Aug 6, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.18.0 https-quantumblockchainai-atlassian-net/ossinsight#799
Open
@wkylin wkylin mentioned this pull request Aug 7, 2024
[Snyk] Upgrade @sentry/react from 8.15.0 to 8.18.0 wkylin/pro-react-admin#371
Merged
This was referenced Aug 7, 2024
[Snyk] Upgrade @sentry/nextjs from 8.17.0 to 8.18.0 dupipcom/hypnos#23
Closed
[Snyk] Upgrade @sentry/nextjs from 8.17.0 to 8.19.0 dupipcom/hypnos#29
Closed
This was referenced Aug 9, 2024
[Snyk] Upgrade @sentry/react from 7.118.0 to 8.19.0 Stanislav1975/win11React#4
Open
[Snyk] Upgrade @sentry/node from 6.17.4 to 8.19.0 Stanislav1975/shields#596
Open
@q1blue q1blue mentioned this pull request Aug 9, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.19.0 https-quantumblockchainai-atlassian-net/ossinsight#802
Open
@FengShangWuQi FengShangWuQi mentioned this pull request Aug 11, 2024
[Snyk] Upgrade @sentry/gatsby from 7.20.0 to 8.19.0 FengShangWuQi/fengshangwuqi.github.io#1914
Closed
@angeloreale angeloreale mentioned this pull request Aug 15, 2024
[Snyk] Upgrade @sentry/nextjs from 8.17.0 to 8.20.0 dupipcom/hypnos#30
Merged
@q1blue q1blue mentioned this pull request Aug 16, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.20.0 https-quantumblockchainai-atlassian-net/ossinsight#807
Open
@wkylin wkylin mentioned this pull request Aug 19, 2024
[Snyk] Upgrade @sentry/react from 8.18.0 to 8.20.0 wkylin/pro-react-admin#383
Closed
This was referenced Aug 22, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.21.0 https-quantumblockchainai-atlassian-net/ossinsight#814
Open
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.22.0 https-quantumblockchainai-atlassian-net/ossinsight#816
Open
@FengShangWuQi FengShangWuQi mentioned this pull request Aug 25, 2024
[Snyk] Upgrade @sentry/gatsby from 7.20.0 to 8.22.0 FengShangWuQi/fengshangwuqi.github.io#1916
Closed
@q1blue q1blue mentioned this pull request Aug 27, 2024
[Snyk] Upgrade @sentry/react from 7.16.0 to 8.23.0 https-quantumblockchainai-atlassian-net/ossinsight#820
Open
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@AbhiPrasad AbhiPrasad Awaiting requested review from AbhiPrasad
1 more reviewer
@lforst lforst lforst approved these changes
Reviewers whose approvals may not affect merge requirements

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

Uh oh!

There was an error while loading. Please reload this page.

3 participants

@ziyadkhalil @AbhiPrasad @lforst
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.