Skip to content

docs(js): Review and update Nest.js Quick Start guide #13497

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 12 commits into from
May 20, 2025

Conversation

inventarSarah
Copy link
Collaborator

@inventarSarah inventarSarah commented Apr 24, 2025

DESCRIBE YOUR PR

The Nest.js quick start guide already looked great -> I added and removed some content to be more consistent with our other guides.

I tried to streamline the CommonJS section, as we already have the details on this page (I added a link to the page). Plus, the content seemed too detailed for a Quick Start guide IMO.
Naturally, if you say the info I removed is vital for the QS guide, we can add it back in.

Additionally, I expanded the "Verify Your Setup" section so the example provided is like our Node.js one.

Closes: #13498

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 Apr 24, 2025

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

Name Status Preview Comments Updated (UTC)
sentry-docs ✅ Ready (Inspect) Visit Preview 💬 Add feedback May 15, 2025 0:26am
2 Skipped Deployments
Name Status Preview Comments Updated (UTC)
changelog ⬜️ Ignored (Inspect) Visit Preview May 15, 2025 0:26am
develop-docs ⬜️ Ignored (Inspect) Visit Preview May 15, 2025 0:26am

@@ -33,28 +33,15 @@ import { AppService } from "./app.service";
export class AppModule {}
```

If you're using a global catch-all exception filter (which is either a filter registered with `app.useGlobalFilters()` or a filter registered in your app module providers annotated with a `@Catch()` decorator without arguments), add a `@SentryExceptionCaptured()` decorator to the filter's `catch()` method.
This decorator will report all unexpected errors that are received by your global error filter to Sentry:
By default, only unhandled exceptions that are not caught by an error filter are reported to Sentry. Additionally, `HttpException`s (including [derivatives](https://docs.nestjs.com/exception-filters#built-in-http-exceptions)) are not captured automatically as they mostly act as control flow vehicles.
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Here we start with the Error Capturing topic.
I was wondering if it would make sense to not have this in "Apply Instrumentation to Your App" and instead put it in a dedicated section, "Step x: Capture Nest.js Errors" -> similar to how we have it for React .

But then this only seems to be documented for CJS - I was wondering why we don't have this documented for ESM? Or is this not needed/possible?

I don't see this as part of this PR -- we can address in a future issue/PR.

Copy link
Member

Choose a reason for hiding this comment

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

I was wondering if it would make sense to not have this in "Apply Instrumentation to Your App" and instead put it in a dedicated section, "Step x: Capture Nest.js Errors"

This sounds reasonable to me!

But then this only seems to be documented for CJS - I was wondering why we don't have this documented for ESM? Or is this not needed/possible?

I think this should be the same for CJS and ESM. Or IOW, the filters require should be applied in the same way regardless of ESM/CJS

I don't see this as part of this PR -- we can address in a future issue/PR.

that also sounds reasonable :D

@inventarSarah inventarSarah marked this pull request as ready for review April 24, 2025 10:18
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.

This looks good but I think we need to sort out some things:

  1. h: we can't include nestjs specific code and instructions in the shared commonjs page
  2. m: we should avoid linking to commonJS for the exception filter explanation (or IOW think about where we put this and then link there if applicable)

1 we need to solve in this PR, 2 we can also address in a follow-up.

Copy link
Member

@Lms24 Lms24 Apr 25, 2025

Choose a reason for hiding this comment

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

For NestJS-CommmonJS specifically, I don't think we should show ESM/CJS tabs here because later on we instruct users to import "./instrument". Since Nest ships with TS, we can simply let users create an instrument.ts file. (cc @chargome - let me know if I'm missing something or this sounds unreasonable to you)

image

I'm realizing that this is a common guide for various node platforms but it's quite confusing for NestJS I'd argue. So maybe it makes sense to create a Nest-specific version of it 🤔 In general, for the common guide, I don't think we should even show the ESM tab on the CommonJS installation page :)

also please see my other comment about nestjs-specific code in this page

Copy link
Member

Choose a reason for hiding this comment

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

Yeah sounds reasonable to just use a ts file here 👍

}
}
```
For more precise control over error reporting in global catch-all exception filters, specific exception filters, or microservices, check out our [CommonJS installation documentation](/platforms/javascript/guides/nestjs/install/commonjs/).
Copy link
Member

Choose a reason for hiding this comment

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

m: I don't think we should link to the CJS guide for this. Either we find a place for it here, or we do something like we have in Angular or React where we explain the intricacies of the filters in a "NestJS Features -> Exception Filters" page. wdyt?

Copy link

codecov bot commented Apr 28, 2025

Bundle Report

Changes will increase total bundle size by 240 bytes (0.0%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
sentry-docs-server-cjs 11.2MB 246 bytes (0.0%) ⬆️
sentry-docs-client-array-push 9.51MB -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.75MB -0.0%
../instrumentation.js -3 bytes 1.08MB -0.0%
9523.js -3 bytes 1.05MB -0.0%
../app/[[...path]]/page.js.nft.json 85 bytes 396.51kB 0.02%
../app/platform-redirect/page.js.nft.json 85 bytes 396.43kB 0.02%
../app/sitemap.xml/route.js.nft.json 85 bytes 394.4kB 0.02%
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.7kB -0.0%
static/chunks/8165-*.js -3 bytes 410.1kB -0.0%
static/A6KS4ZhyNgqH41R14Mfav/_buildManifest.js (New) 578 bytes 578 bytes 100.0% 🚀
static/A6KS4ZhyNgqH41R14Mfav/_ssgManifest.js (New) 77 bytes 77 bytes 100.0% 🚀
static/XNLYCqEJQahnoiFGvzySl/_buildManifest.js (Deleted) -578 bytes 0 bytes -100.0% 🗑️
static/XNLYCqEJQahnoiFGvzySl/_ssgManifest.js (Deleted) -77 bytes 0 bytes -100.0% 🗑️

@inventarSarah
Copy link
Collaborator Author

Thanks @Lms24 !

  1. h: we can't include nestjs specific code and instructions in the shared commonjs page
  2. m: we should avoid linking to commonJS for the exception filter explanation (or IOW think about where we put this and then link there if applicable)

I restored the previous content of the commonjs and getting-started-use/nestjs pages. So, now the Nest.js specific info shouldn't surface on other platforms anymore -- lmk if I missed something 🙏 (I think this is the most complex structure I've worked with so far :D)

This way, we can keep this PR focused and small and tackle other issues in a new PR. -> I already created an issue here #13525
Please review and comment if you have any suggestions.

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.

Thanks for making the changes and for creating the follow-up issue.

Co-authored-by: Lukas Stracke <lukas.stracke@sentry.io>
@inventarSarah
Copy link
Collaborator Author

New updates in this PR, @chargome @Lms24

  • guide no longer inherits content from getting-started-node
  • updated code snippets to Typescript (remove ESM tabs)
  • created new step "Capturing Nest.js Errors" and moved content about exception filters there
  • created a new include file for the exception filter content so I could use it in the quick start guide and the CommonJS page -> once the CommonJS page is updated, we can use the content from the include file directly in the QS guide and delete the include file
  • removed "ESM" subsection in "Configure"


To make sure Sentry captures all your app's errors, configure error handling based on how your application manages exceptions:

### Using a Global Catch-All Exception Filter
Copy link
Member

Choose a reason for hiding this comment

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

This I would rather name something like "using a custom global filter" – and update the section below accordingly

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Updated the subheading to

Using a Custom Global Filter
and
Not Using a Custom Global Filter

@@ -14,9 +16,9 @@ async function bootstrap() {
bootstrap();
```

Afterwards, add the `SentryModule` as a root module to your main module:
Afterward, add the `SentryModule` as a root module to your main module:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Afterward, add the `SentryModule` as a root module to your main module:
Afterwards, add the `SentryModule` as a root module to your main module:

I think? 😅

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Both forms are correct, although the variant with “s” is used in British English and the one without in American English 👍

@inventarSarah inventarSarah requested a review from Lms24 May 7, 2025 06:42
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.

@inventarSarah just realized that we have the global error filter sections now twice in the guide!

@inventarSarah
Copy link
Collaborator Author

@inventarSarah just realized that we have the global error filter sections now twice in the guide!

Fixed -> things got crazy with the includes!

Quick Start guide and CommonJS installation method page (which used the same includes) look okay to me now

@chargome
Copy link
Member

seems to be stuck, can you re-trigger a deployment?

@inventarSarah
Copy link
Collaborator Author

seems to be stuck, can you re-trigger a deployment?
@chargome now everything has worked out

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.

All good from my end, will let @chargome give the final approval :)

@inventarSarah inventarSarah merged commit 2c6b6a3 into master May 20, 2025
13 checks passed
@inventarSarah inventarSarah deleted the smi/quick-start/review-nestjs branch May 20, 2025 09:08
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.

Review and update Nest.js Quick Start Guide
3 participants