Skip to content
Open
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
123 changes: 86 additions & 37 deletions docs/platforms/javascript/guides/deno/index.mdx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
title: Deno
description: Learn how to manually set up Sentry in your Deno app and capture your first errors.
sdk: sentry.javascript.deno
categories:
- javascript
Expand All @@ -10,31 +11,44 @@ categories:

<Alert>

The Deno SDK is currently in Beta.
This SDK is currently in **beta**. Beta features are still in progress and may have bugs. Please reach out on [GitHub](https://github.com/getsentry/sentry-javascript/issues/new/choose) if you have any feedback or concerns

</Alert>

The minimum supported Deno version is 2.

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

## Configure
## Step 1: Install

Configuration should happen as early as possible in your application's lifecycle.
Choose the features you want to configure, and this guide will show you how:

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

In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/).
<PlatformContent includePath="getting-started-features-expandable" />

Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
### Import the Sentry SDK

<OnboardingOptionButtons options={["error-monitoring", "performance", "logs"]} />
Import the Sentry Deno SDK directly from the npm registry, before importing any other modules:

```javascript {tabTitle: Deno}
```javascript {filename: main.ts}
import * as Sentry from "npm:@sentry/deno";
// your other imports
```

## Step 2: Configure

### Initialize the Sentry SDK

Initialize Sentry as early as possible in your app:

```javascript {filename: main.ts}
import * as Sentry from "npm:@sentry/deno";
// your other imports

Sentry.init({
dsn: "___PUBLIC_DSN___",

// Adds request headers and IP for users, for more info visit:
// https://docs.sentry.io/platforms/javascript/guides/deno/configuration/options/#sendDefaultPii
sendDefaultPii: true,
Expand All @@ -47,56 +61,91 @@ Sentry.init({
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
tracesSampleRate: 1.0,
// ___PRODUCT_OPTION_END___ performance
// ___PRODUCT_OPTION_START___ logs

// Enable logs to be sent to Sentry
enableLogs: true,
// ___PRODUCT_OPTION_END___ logs
});
```

```javascript {tabTitle: npm}
import * as Sentry from "@sentry/deno";
### Enable Network Access

Sentry.init({
dsn: "___PUBLIC_DSN___",
// ___PRODUCT_OPTION_START___ performance

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
// Learn more at
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
tracesSampleRate: 1.0,
// ___PRODUCT_OPTION_END___ performance
});
```
To ensure the SDK can send events, you should enable network access for your
ingestion domain:
To make sure the SDK can send events, enable network access for your Sentry ingestion domain:

```bash
deno run --allow-net=___ORG_INGEST_DOMAIN___ index.ts
```

## Allow access to your source files
### Allow Access to Source Files

To ensure the SDK can include your source code in stack traces, you should enable read access for your source files:
Grant read access to your source files so that the SDK can include your source code in stack traces:

```bash
deno run --allow-read=./src index.ts
```

## Verify
## Step 3: Add Readable Stack Traces With Source Maps (Optional)

<PlatformContent includePath="getting-started-sourcemaps-short-version" />

This snippet includes an intentional error, so you can test that everything is working as soon as you set it up.
## Step 4: Verify Your Setup

Verify your setup by adding the following snippet anywhere in your code and running it:
Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project.

### Issues

First, let's verify that Sentry captures errors and creates issues in your Sentry project. Add the following code snippet to your main application file, which will call an undefined function, triggering an error that Sentry will capture:

```javascript
setTimeout(() => {
throw new Error();
try {
foo();
} catch (e) {
Sentry.captureException(e);
}
}, 99);
```

<OnboardingOption optionId="performance">
### Tracing
To test your tracing configuration, update the previous code snippet by starting a trace to measure the time it takes for the execution of your code:
```javascript
Sentry.startSpan({
op: "test",
name: "My First Test Transaction",
}, () => {
setTimeout(() => {
try {
foo();
} catch (e) {
Sentry.captureException(e);
}
}, 99);
});
```
</OnboardingOption>

<Alert>
### View Captured Data in Sentry

Learn more about manually capturing an error or message in our <PlatformLink to="/usage/">Usage documentation</PlatformLink>.
Finally, head over to your project on [Sentry.io](https://sentry.io/) to view the collected data (it takes a couple of moments for the data to appear).

</Alert>
<PlatformContent includePath="getting-started-verify-locate-data" />

## Next Steps

At this point, you should have integrated Sentry into your Deno application and should already be sending data to your Sentry project.

Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are:

- Extend Sentry to your frontend using one of our [frontend SDKs](/)
- Learn how to <PlatformLink to="/usage">manually capture errors</PlatformLink>
- Continue to <PlatformLink to="/configuration">customize your configuration</PlatformLink>
- Get familiar with [Sentry's product features](/product) like tracing, insights, and alerts

<Expandable permalink={false} title="Are you having problems setting up the SDK?">

- Find various topics in <PlatformLink to="/troubleshooting">Troubleshooting</PlatformLink>
- [Get support](https://sentry.zendesk.com/hc/en-us/)

To view and resolve the recorded error, log into [sentry.io](https://sentry.io) and select your project. Clicking on the error's title will open a page where you can see detailed information and mark it as resolved.
</Expandable>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<Expandable title="Want to learn more about these features?">

- [**Issues**](/product/issues) (always enabled): Sentry's core error monitoring product that automatically reports errors,
uncaught exceptions, and unhandled rejections. If you have something that
looks like an exception, Sentry can capture it.
- [**Tracing**](/product/tracing): Track software performance while seeing the
impact of errors across multiple systems. For example, distributed tracing
allows you to follow a request from the frontend to the backend and back.
- [**Logs**](/product/explore/logs): Centralize and analyze your application logs to
correlate them with errors and performance issues. Search, filter, and
visualize log data to understand what's happening in your applications.

</Expandable>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
## Prerequisites

You need:

- A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/)
- Your application up and running
- Deno version >= `2.0.0`
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<Expandable title="Need help locating the captured errors in your Sentry project?">

1. Open the [**Issues**](https://sentry.io/issues) page and select an error from the issues list to view the full details and context of this error. For more details, see this [interactive walkthrough](/product/sentry-basics/integrate-frontend/generate-first-error/#ui-walkthrough).
2. Open the [**Traces**](https://sentry.io/explore/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 [**Logs**](https://sentry.io/explore/logs) page and filter by service, environment, or search keywords to view log entries from your application. For an interactive UI walkthrough, click [here](/product/explore/logs/#overview).

</Expandable>
Loading