Skip to content
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

Next.js quick start guide for manual setup #12663

Merged
merged 17 commits into from
Feb 28, 2025

Conversation

inventarSarah
Copy link
Collaborator

DESCRIBE YOUR PR

Rework the Next.js Manual Setup page into a quick start guide for manual setup.

Issue: #12486

This PR draft contains an early, WIP version of the quick start guide. Please focus your review on the structure and content of the page and ignore grammar, style, etc. for now, if possible :)

IS YOUR CHANGE URGENT?

Help us prioritize incoming PRs by letting us know when the change needs to go live.

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

SLA

  • Teamwork makes the dream work, so please add a reviewer to your PRs.
  • Please give the docs team up to 1 week to review your PR unless you've added an urgent due date to it.
    Thanks in advance for your help!

PRE-MERGE CHECKLIST

Make sure you've checked the following before merging your changes:

  • 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

EXTRA RESOURCES

Copy link

vercel bot commented Feb 11, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
develop-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 4:27pm
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 26, 2025 4:27pm
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview Feb 26, 2025 4:27pm

Copy link

codecov bot commented Feb 11, 2025

Bundle Report

Changes will decrease total bundle size by 15 bytes (-0.0%) ⬇️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 10.2MB -9 bytes (-0.0%) ⬇️
sentry-docs-client-array-push 9.39MB -6 bytes (-0.0%) ⬇️

Affected Assets, Files, and Routes:

view changes for bundle: sentry-docs-server-cjs

Assets Changed:

Asset Name Size Change Total Size Change (%)
1729.js -3 bytes 1.46MB -0.0%
../instrumentation.js -3 bytes 791.26kB -0.0%
9523.js -3 bytes 767.46kB -0.0%
view changes for bundle: sentry-docs-client-array-push

Assets Changed:

Asset Name Size Change Total Size Change (%)
static/chunks/pages/_app-*.js -3 bytes 868.04kB -0.0%
static/chunks/4028-*.js -3 bytes 393.29kB -0.0%
server/middleware-*.js 5.55kB 6.55kB 555.3% ⚠️
server/middleware-*.js -5.55kB 1.0kB -84.74%
static/M_VWWfvjSeuM9MXS106f1/_buildManifest.js (New) 578 bytes 578 bytes 100.0% 🚀
static/M_VWWfvjSeuM9MXS106f1/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/ZOv-*.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️
static/ZOv-*.js (Deleted) -578 bytes 0 bytes -100.0% 🗑️


## Disable the Sentry SDK Debug Logger to Save Bundle Size
- Instrument Next.js server actions
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm curious why the first two options here don't provide links; is this content that's in development?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

yes, this is content that is currently on this page, but we want to move it to other pages. This will be done before this site goes live, and then we can link properly.

Copy link
Member

Choose a reason for hiding this comment

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

@lforst wdyt about moving the server action stuff to another page (probably the new API page)?

Copy link
Contributor

@coolguyzone coolguyzone left a comment

Choose a reason for hiding this comment

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

Looks good! Much clearer 🤠

@inventarSarah
Copy link
Collaborator Author

Looks good! Much clearer 🤠

Thanks, @coolguyzone, for your feedback
There is still a lot of feedback to come, and the page will change a lot -> as soon as everything is ready, I will ping you again for another/the final review 🙏

Copy link
Member

@lforst lforst left a comment

Choose a reason for hiding this comment

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

Thanks for doing this! I love the Step 1, 2, 3, ... - it's much more a story than previously where it was a random assortment of options.

The stuff I brought up is pretty important I feel like. Happy to discuss.

---

If you can't (or prefer not to) run the [automatic setup](/platforms/javascript/guides/nextjs/#install), you can follow the instructions below to configure your application.
Copy link
Member

Choose a reason for hiding this comment

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

I have the somewhat strong opinion we should keep this line. Doing the setup manually is a mistake 95% of the time and I would like to use every opportunity we get to direct people back to the automatic setup.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Good point! I added this info back at the top in an info alert

Comment on lines 105 to 108
// Route browser requests to Sentry through a Next.js rewrite to circumvent ad-blockers.
// This can increase your server load as well as your hosting bill.
// Note: Check that the configured route will not match with your Next.js middleware, otherwise reporting of client-side errors will fail.
tunnelRoute: "/monitoring",
Copy link
Member

Choose a reason for hiding this comment

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

I have a bad feeling about putting tunnelRoute here. It's a foot gun in combination with middlewares and the comment here is too untechnical. I'd think about moving it into its own step maybe?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

If tunneling is something we need to explain in more detail, it makes sense to deal with it in a separate section.
So I've added ## Step 5: Avoid Ad Blockers With Tunneling (Optional) -- please check if this looks okay to you content-wise

Comment on lines 296 to 299
<Alert type="info" title="Note">
You can also add Error components for the Pages Router, which you can learn
more about here (LINK!).
</Alert>
Copy link
Member

Choose a reason for hiding this comment

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

Pages router is still too ubiquitous for us to "hide away" that section.

Copy link
Member

Choose a reason for hiding this comment

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

So let's either add an expandable or just inline the content again here

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I added the section about Pages Router back in.

However, we don't have that in the installation wizard(?) or the wizard guide.
Does it make sense to add this as an optional step to the wizard guide?

(I also just realized that we didn't include the “global-error.jsx” in the list of things the wizard changes/creates in the user application. So I need to add this)

Copy link
Member

Choose a reason for hiding this comment

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

We definitely have it in the CLI wizard but not the getting started docs it seems like. We should probably add it. Thinking about it some more about it, I less and less like it that we include in the docs what the CLI wizard did or will do. The CLI wizard should be self-explanatory.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

That's why we put it in an expandable, so anybody who doesn't care about that can ignore it, and anybody else can have a look. I think it is a thoughtful service to users to offer this list

Do I need a custom next.js error page in my project before I run the wizard to have it add captureUnderscoreErrorException? I didn't do that, and maybe that's why I can't find that in my project.

Copy link
Member

Choose a reason for hiding this comment

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

Looking at the code the wizard should either create an _error page automatically, or instruct you to add relevant code if you already the file.

@@ -307,386 +319,200 @@ import * as Sentry from "@sentry/nextjs";
export const onRequestError = Sentry.captureRequestError;
```

If you need additional logic within the `onRequestError` hook, call `captureRequestError` with all arguments passed to `onRequestError`:
Copy link
Member

Choose a reason for hiding this comment

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

I would like to keep this because we have no other location where this is documented and people will be clueless what to do in case they already have an onRequestError hook for some reason.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Is this also relevant for installation wizard users?

Copy link
Member

Choose a reason for hiding this comment

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

Potentially yes. However, my goal with my comment was to have this instruction ✨somewhere✨, at least so that Kapa or google can show it if people ask questions about it.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@chargome will this go into the API page?

Copy link
Member

Choose a reason for hiding this comment

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

@inventarSarah we still don't know as the api page still needs more clarification – so let's keep it here for now

Comment on lines 428 to 384
// Specify the organization and project to upload source maps to
org: "___ORG_SLUG___",
project: "___PROJECT_SLUG___",

Copy link
Member

Choose a reason for hiding this comment

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

Would not remove, project is necessary, and org too with old auth tokens.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

added this back in


Set the `disableLogger` option to `true` to strip the Sentry SDK debug logger out of your client bundles, saving bundle size.
Please note that this will effectively override and disable the `debug` option in your `Sentry.init()` calls.
<Expandable permalink={false} title="Did you experience any issues with this guide?">
Copy link
Member

Choose a reason for hiding this comment

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

I know kinda off topic but this sounds way too self-conscious

Suggested change
<Expandable permalink={false} title="Did you experience any issues with this guide?">
<Expandable permalink={false} title="Are you having problems setting up the SDK?">

Comment on lines +494 to +496
1. Open the [**Issues**](https://sentry.io/orgredirect/organizations/:orgslug/issues) page and select an error from the issues list to view the full details and context of this error. For an interactive UI walkthrough, click [here](/product/sentry-basics/integrate-frontend/generate-first-error/#ui-walkthrough).
2. Open the [**Traces**](https://sentry.io/orgredirect/organizations/:orgslug/traces) page and select a trace to reveal more information about each span, its duration, and any errors. For an interactive UI walkthrough, click [here](/product/sentry-basics/distributed-tracing/generate-first-error/#ui-walkthrough).
3. Open the [**Replays**](https://sentry.io/orgredirect/organizations/:orgslug/replays) page and select an entry from the list to get a detailed view where you can replay the interaction and get more information to help you troubleshoot.
Copy link
Member

Choose a reason for hiding this comment

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

Love this

Comment on lines 486 to 490
<Alert level="warning" title="Important">

```javascript {tabTitle:ESM} {filename:next.config.mjs}
export default withSentryConfig(nextConfig, {
autoInstrumentMiddleware: false,
});
```

```javascript {tabTitle:CJS} {filename:next.config.js}
module.exports = withSentryConfig(nextConfig, {
autoInstrumentMiddleware: false,
});
```
Errors triggered from within your browser's developer tools (like the browser console) are sandboxed, so they will not trigger Sentry's error monitoring.

### Instrumentation of Vercel Cron Jobs
</Alert>
Copy link
Member

@lforst lforst Feb 12, 2025

Choose a reason for hiding this comment

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

I'd probably move this (devtools warning) into the "Verify > Issues" section

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

moved it! 👍

Comment on lines 9 to 10
- A Sentry [account](https://sentry.io/signup/) and [project](https://docs.sentry.io/product/projects/)
- Your application up and running
Copy link
Member

Choose a reason for hiding this comment

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

l: since we're gonna use this in a lot of places we could move it into an <Include ...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

👍 let me create a separate PR for this (it probably also makes sense to already use this Include in the wizard guide)

Comment on lines 296 to 299
<Alert type="info" title="Note">
You can also add Error components for the Pages Router, which you can learn
more about here (LINK!).
</Alert>
Copy link
Member

Choose a reason for hiding this comment

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

So let's either add an expandable or just inline the content again here


<Alert title={<>Complications when using <code>tunnelRoute</code> with Next.js Middleware</>}>
<Expandable level="warning" title="Are you developing with Turbopack?">
Copy link
Member

Choose a reason for hiding this comment

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

l: maybe also move this one into an Include, so we don't forget to update this once there are turbopack changes


## Disable the Sentry SDK Debug Logger to Save Bundle Size
- Instrument Next.js server actions
Copy link
Member

Choose a reason for hiding this comment

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

@lforst wdyt about moving the server action stuff to another page (probably the new API page)?

@inventarSarah
Copy link
Collaborator Author

Hey @lforst, @chargome @coolguyzone
I've updated this page: I've already incorporated the feedback from the first round. In addition, I have optimized the content for the quick start guide format.
It would be great if you could review it again!

Note: We will only merge this after we've made sure that no content is lost (see #12487 ). This could mean that we need to temporarily add content back into this guide until we have created a suitable place for it.

Thank you!

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.

This looks really good! So the only thing left is to clarify the api page and move (link) some content around right?

@@ -307,386 +319,200 @@ import * as Sentry from "@sentry/nextjs";
export const onRequestError = Sentry.captureRequestError;
```

If you need additional logic within the `onRequestError` hook, call `captureRequestError` with all arguments passed to `onRequestError`:
Copy link
Member

Choose a reason for hiding this comment

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

@inventarSarah we still don't know as the api page still needs more clarification – so let's keep it here for now

@inventarSarah
Copy link
Collaborator Author

So the only thing left is to clarify the api page and move (link) some content around right?

@chargome yes, exactly. I've updated the list content to move here: #12487

---

If you can't (or prefer not to) run the [automatic setup](/platforms/javascript/guides/nextjs/#install), you can follow the instructions below to configure your application.
<Alert type="info">
For the fastest setup, we recommend using the [wizard
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it make sense to also have this note include why one might choose manual setup? e.g. "Manual installation allows the greatest level of customization, for the fastest setup . . ."

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ideally, the user should take the same steps in this guide as the Installation Wizard. This means that the result is the same, and the user has no advantage or disadvantage if they prefer one guide to the other.
If this guide should have more content than the wizard guide at some point, then it makes sense to include the addition you suggested.

Copy link
Contributor

@coolguyzone coolguyzone left a comment

Choose a reason for hiding this comment

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

Looks great!!

@inventarSarah inventarSarah merged commit c341c76 into master Feb 28, 2025
11 checks passed
@inventarSarah inventarSarah deleted the smi/quick-start/nextjs-manual branch February 28, 2025 10:19
limbonaut pushed a commit that referenced this pull request Feb 28, 2025
* commit first rough draft of page for a first review of structure
* fix title typo
* feedback updates
* pr feedback
* add tunneling alert
* pr feedback
* shorten and edit guide content
* replace content with includes
* formatting fixes
* add back content that we can't move somewhere else atm
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.

4 participants