Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,47 @@ Sentry.init({
});
```

## Options

### `shouldHandleError`

A function that decides whether an error is captured. By default, errors with a 5xx status code (and errors with a 2xx status code or lower) are captured, and errors with a 3xx or 4xx status code aren't.

```typescript
declare function shouldHandleError(
error: Error,
request: FastifyRequest,
reply: FastifyReply
): boolean;
```

```javascript
Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [
Sentry.fastifyIntegration({
shouldHandleError(error, request, reply) {
return reply.statusCode >= 500;
},
}),
],
});
```

If you use TypeScript, cast the request and reply to get full type safety:

```typescript
import type { FastifyRequest, FastifyReply } from "fastify";

Sentry.fastifyIntegration({
shouldHandleError(error, minimalRequest, minimalReply) {
const request = minimalRequest as FastifyRequest;
const reply = minimalReply as FastifyReply;
return reply.statusCode >= 500;
},
});
```

## Supported Versions

- `fastify`: `^3.21.0 || ^4.0.0`
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Scrubbing Sensitive Data"
description: "Learn about filtering or scrubbing sensitive data within the Sentry JavaScript SDK, so that data is not sent with the event. You can also configure server-side scrubbing to ensure the data is not stored."
customCanonicalTag: "/platforms/javascript/guides/koa/data-management/sensitive-data/"
customCanonicalTag: "/platforms/javascript/guides/node/data-management/sensitive-data/"
sidebar_order: 100
keywords:
- pii
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Rollup
description: "Upload your source maps with the Sentry Rollup Plugin."
sidebar_order: 5
customCanonicalTag: "/platforms/javascript/guides/koa/sourcemaps/uploading/rollup/"
customCanonicalTag: "/platforms/javascript/guides/node/sourcemaps/uploading/rollup/"
---

<Alert>
Expand Down
8 changes: 8 additions & 0 deletions docs/platforms/javascript/guides/bun/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,14 @@ categories:
- server-only
---

<Alert title="Using a Web Framework?">

Express, Fastify, Hapi, Hono, and Koa don't need any extra setup. Follow this guide, and the SDK instruments them automatically.

Elysia has its own Sentry SDK. Follow the [Elysia guide](/platforms/javascript/guides/elysia/) instead.

</Alert>

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

<StepConnector selector="h2" showNumbers={true}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,4 +67,4 @@ To read the DSN from a Worker binding, pass a callback instead of a plain option
app.use(sentry(app, (env) => ({ dsn: env.SENTRY_DSN })));
```

For the full setup, including verification and the other runtimes, see the **[Hono Quick Start Guide](/platforms/javascript/guides/hono/)**.
To set up Sentry for Hono on other runtimes, see [Hono](/platforms/javascript/guides/hono/).
2 changes: 1 addition & 1 deletion docs/platforms/javascript/guides/cloudflare/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ This guide covers Cloudflare Workers. If you're deploying a Cloudflare Pages app
If you're using any of the listed frameworks, follow their specific setup instructions:

- **[Astro](/platforms/javascript/guides/cloudflare/frameworks/astro/)**
- **[Hono](/platforms/javascript/guides/hono/)** (with @sentry/hono)
- **[Hono](/platforms/javascript/guides/cloudflare/frameworks/hono/)** (with @sentry/hono)
- **[Hydrogen](/platforms/javascript/guides/cloudflare/frameworks/hydrogen-react-router/)**
- **[Next.js](/platforms/javascript/guides/cloudflare/frameworks/nextjs/)**
- **[Nuxt](/platforms/javascript/guides/cloudflare/frameworks/nuxt/)**
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
title: "Scrubbing Sensitive Data"
description: "Learn about filtering or scrubbing sensitive data within the Sentry JavaScript SDK, so that data is not sent with the event. You can also configure server-side scrubbing to ensure the data is not stored."
customCanonicalTag: "/platforms/javascript/guides/koa/data-management/sensitive-data/"
customCanonicalTag: "/platforms/javascript/guides/node/data-management/sensitive-data/"
sidebar_order: 100
keywords:
- pii
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Rollup
description: "Upload your source maps with the Sentry Rollup Plugin."
sidebar_order: 5
customCanonicalTag: "/platforms/javascript/guides/koa/sourcemaps/uploading/rollup/"
customCanonicalTag: "/platforms/javascript/guides/node/sourcemaps/uploading/rollup/"
---

<Alert>
Expand Down
6 changes: 6 additions & 0 deletions docs/platforms/javascript/guides/deno/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ This SDK is currently in **beta**. Beta features are still in progress and may h

</Alert>

<Alert title="Using a Web Framework?">

Express, Fastify, Hapi, Hono, and Koa don't need any extra setup. Follow this guide, and the SDK instruments them automatically.

</Alert>

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

<StepConnector selector="h2" showNumbers={true}>
Expand Down

This file was deleted.

44 changes: 42 additions & 2 deletions docs/platforms/javascript/guides/express/index.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,51 @@
---
title: Express
description: "Learn how to manually set up Sentry in your Express app and capture your first errors."
description: "Learn how to set up Sentry in your Express app on Node.js, Bun, or Deno."
sdk: sentry.javascript.node
fallbackGuide: javascript.node
inheritCommonContent: false
categories:
- server
- server-only
---

<PlatformContent includePath="getting-started-node" />
[Express](https://expressjs.com/) doesn't need its own Sentry SDK. Set up Sentry for the runtime your app runs on, and the SDK instruments Express automatically: `expressIntegration` captures errors from your routes and middleware, and creates spans for incoming requests when tracing is enabled.

## Set Up Sentry for Your Runtime

- <LinkWithPlatformIcon
platform="javascript.node"
label="Node.js"
url="/platforms/javascript/guides/node/"
/>
- <LinkWithPlatformIcon
platform="javascript.bun"
label="Bun"
url="/platforms/javascript/guides/bun/"
/>
- <LinkWithPlatformIcon
platform="javascript.deno"
label="Deno"
url="/platforms/javascript/guides/deno/"
/>

## Customize Error Capturing

Errors with a 3xx or 4xx status code are skipped, since they're usually expected redirects or client errors. To change which errors are captured, pass a `shouldHandleError` callback to `expressIntegration()`:

```javascript
Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [
Sentry.expressIntegration({
shouldHandleError(error) {
const status = Number(error.status ?? error.statusCode ?? 500);
// Capture 401/403 in addition to the default 5xx errors
return status === 401 || status === 403 || status >= 500;
},
}),
],
});
```

If you capture errors yourself in your own error-handling middleware, set `shouldHandleError: false` to avoid duplicate events.
14 changes: 0 additions & 14 deletions docs/platforms/javascript/guides/express/index__v7.x.mdx

This file was deleted.

This file was deleted.

This file was deleted.

9 changes: 0 additions & 9 deletions docs/platforms/javascript/guides/fastify/features/index.mdx

This file was deleted.

27 changes: 24 additions & 3 deletions docs/platforms/javascript/guides/fastify/index.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,34 @@
---
title: Fastify
description: "Learn how to manually set up Sentry in your Fastify app and capture your first errors."
description: "Learn how to set up Sentry in your Fastify app on Node.js, Bun, or Deno."
sdk: sentry.javascript.node
fallbackGuide: javascript.node
inheritCommonContent: false
categories:
- server
- server-only
---

<PlatformContent includePath="getting-started-primer" />
[Fastify](https://fastify.dev/) doesn't need its own Sentry SDK. Set up Sentry for the runtime your app runs on, and the SDK instruments Fastify automatically: `fastifyIntegration` captures errors from your routes and hooks, and creates spans for incoming requests when tracing is enabled.

<PlatformContent includePath="getting-started-node" />
## Set Up Sentry for Your Runtime

- <LinkWithPlatformIcon
platform="javascript.node"
label="Node.js"
url="/platforms/javascript/guides/node/"
/>
- <LinkWithPlatformIcon
platform="javascript.bun"
label="Bun"
url="/platforms/javascript/guides/bun/"
/>
- <LinkWithPlatformIcon
platform="javascript.deno"
label="Deno"
url="/platforms/javascript/guides/deno/"
/>

## Customize Error Capturing

Errors with a 3xx or 4xx status code are skipped. To change which errors are captured, pass a `shouldHandleError` callback to `fastifyIntegration()`. See the [Fastify integration](/platforms/javascript/guides/node/configuration/integrations/fastify/#shouldhandleerror) for all options.

This file was deleted.

This file was deleted.

25 changes: 23 additions & 2 deletions docs/platforms/javascript/guides/hapi/index.mdx
Original file line number Diff line number Diff line change
@@ -1,11 +1,32 @@
---
title: Hapi
description: "Learn how to manually set up Sentry in your Hapi app and capture your first errors."
description: "Learn how to set up Sentry in your Hapi app on Node.js, Bun, or Deno."
sdk: sentry.javascript.node
fallbackGuide: javascript.node
inheritCommonContent: false
categories:
- server
- server-only
---

<PlatformContent includePath="getting-started-node" />
[Hapi](https://hapi.dev/) doesn't need its own Sentry SDK. Set up Sentry for the runtime your app runs on, and the SDK instruments Hapi automatically: `hapiIntegration` registers an error handler when your server starts, and creates spans for incoming requests when tracing is enabled.

## Set Up Sentry for Your Runtime

- <LinkWithPlatformIcon
platform="javascript.node"
label="Node.js"
url="/platforms/javascript/guides/node/"
/>
- <LinkWithPlatformIcon
platform="javascript.bun"
label="Bun"
url="/platforms/javascript/guides/bun/"
/>
- <LinkWithPlatformIcon
platform="javascript.deno"
label="Deno"
url="/platforms/javascript/guides/deno/"
/>

To configure the integration, see the [Hapi integration](/platforms/javascript/guides/node/configuration/integrations/hapi/).

This file was deleted.

Loading
Loading