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

docs(nestjs): Update nestjs documentation to refer to new sdk #10514

Merged
merged 14 commits into from
Jun 27, 2024
Merged
13 changes: 9 additions & 4 deletions docs/platforms/javascript/guides/nestjs/index.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,19 @@
---
title: Nest.js
description: "Learn about using Sentry with Nest.js."
sdk: sentry.javascript.node
fallbackGuide: javascript.node
sdk: sentry.javascript.nestjs
fallbackGuide: javascript.nestjs
categories:
- server
---

<PlatformContent includePath="getting-started-primer" />

This guide explains how to set up Sentry in your Nest.js application.

<Note>This guide is for version 8.0.0 and up of `@sentry/nestjs`.</Note>

<Note>
This SDK is considered **experimental and in an alpha state**. It may experience breaking changes. Please reach out on
[GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose) if you have any feedback or concerns.
</Note>

lizokm marked this conversation as resolved.
Show resolved Hide resolved
<PlatformContent includePath="getting-started-node" />
8 changes: 4 additions & 4 deletions docs/platforms/javascript/guides/nestjs/profiling/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,16 @@ If you're adopting Profiling in a high-throughput environment, we recommend test
<Note>

Node profiling is available starting in `@sentry/profiling-node` version `0.3.0`.
You have to have the `@sentry/node` (minimum version `7.44.1`) package installed.
You have to have the `@sentry/nestjs` package installed.

</Note>

```bash {tabTitle:npm}
npm install --save @sentry/node @sentry/profiling-node
npm install --save @sentry/nestjs @sentry/profiling-node
```

```bash {tabTitle:Yarn}
yarn add @sentry/node @sentry/profiling-node
yarn add @sentry/nestjs @sentry/profiling-node
```

## Enabling Profiling
Expand All @@ -36,7 +36,7 @@ To enable profiling, import `@sentry/profiling-node`, add `ProfilingIntegration`
<SignInNote />

```javascript
const Sentry = require("@sentry/node");
const Sentry = require("@sentry/nestjs");
const { nodeProfilingIntegration } = require("@sentry/profiling-node");

Sentry.init({
Expand Down
43 changes: 43 additions & 0 deletions platform-includes/getting-started-config/javascript.nestjs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
```javascript {tabTitle:CommonJS} {filename: instrument.js} {"onboardingOptions": {"performance": "11-14", "profiling": "2, 7-10, 15-18"}}
const Sentry = require("@sentry/nestjs");
const { nodeProfilingIntegration } = require("@sentry/profiling-node");

// Ensure to call this before requiring any other modules!
Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [
// Add our Profiling integration
nodeProfilingIntegration(),
],

// Add Tracing by setting tracesSampleRate
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// Set sampling rate for profiling
// This is relative to tracesSampleRate
profilesSampleRate: 1.0,
});
```

```javascript {tabTitle:ESM} {filename: instrument.mjs} {"onboardingOptions": {"performance": "11-14", "profiling": "2, 7-10, 15-18"}}
import * as Sentry from "@sentry/nestjs";
import { nodeProfilingIntegration } from '@sentry/profiling-node';

// Ensure to call this before importing any other modules!
Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [
// Add our Profiling integration
nodeProfilingIntegration(),
],

// Add Tracing by setting tracesSampleRate
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// Set sampling rate for profiling
// This is relative to tracesSampleRate
profilesSampleRate: 1.0,
});
```
23 changes: 23 additions & 0 deletions platform-includes/getting-started-install/javascript.nestjs.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
<OnboardingOption optionId="profiling" hideForThisOption>

```bash {tabTitle:npm}
npm install --save @sentry/nestjs
```

```bash {tabTitle:Yarn}
yarn add @sentry/nestjs
```

</OnboardingOption>

<OnboardingOption optionId="profiling">

```bash {tabTitle:npm}
npm install --save @sentry/nestjs @sentry/profiling-node
```

```bash {tabTitle:Yarn}
yarn add @sentry/nestjs @sentry/profiling-node
```

</OnboardingOption>
8 changes: 6 additions & 2 deletions platform-includes/getting-started-node/javascript.mdx
Original file line number Diff line number Diff line change
@@ -1,22 +1,26 @@
Don't already have an account and Sentry project established? Head over to [sentry.io](https://sentry.io/signup/), then return to this page.

<Note>This guide is for version 8.0.0 and up of `@sentry/node`.</Note>
<PlatformSection notSupported={["javascript.nestjs"]}>
<Note>This guide is for version 8.0.0 and up of `@sentry/node`.</Note>
</PlatformSection>

nicohrubec marked this conversation as resolved.
Show resolved Hide resolved
## Install

<OnboardingOptionButtons
options={["error-monitoring", "performance", "profiling"]}
/>

Sentry captures data by using an SDK within your application’s runtime. This means that you have to add `@sentry/node` as a runtime dependency to your application:
Sentry captures data by using an SDK within your application’s runtime.

<PlatformContent includePath="getting-started-install" />

## Configure

Sentry should be initialized as early in your app as possible. It is essential that you call `Sentry.init` before you require any other modules in your application—otherwise, auto-instrumentation of these modules will _not_ work.

<PlatformSection notSupported={["javascript.nestjs"]}>
Once this is done, Sentry's Node SDK captures unhandled exceptions as well as tracing data for your application.
</PlatformSection>
nicohrubec marked this conversation as resolved.
Show resolved Hide resolved

You need to create a file named `instrument.js` that imports and initializes Sentry:

Expand Down
4 changes: 1 addition & 3 deletions platform-includes/getting-started-use/javascript.nestjs.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<SignInNote />

```javascript {filename: main.ts} {17}
// Import this first!
import './instrument';

// Now import other modules
import * as Sentry from "@sentry/node";
import * as Sentry from "@sentry/nestjs";
import {
BaseExceptionFilter,
HttpAdapterHost,
Expand Down
Loading