Skip to content

Commit 2049778

Browse files
committed
update Deno quick start guide
1 parent 0126b1f commit 2049778

File tree

4 files changed

+113
-37
lines changed

4 files changed

+113
-37
lines changed
Lines changed: 86 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
---
22
title: Deno
3+
description: Learn how to manually set up Sentry in your Deno app and capture your first errors.
34
sdk: sentry.javascript.deno
45
categories:
56
- javascript
@@ -10,31 +11,44 @@ categories:
1011

1112
<Alert>
1213

13-
The Deno SDK is currently in Beta.
14+
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
1415

1516
</Alert>
1617

17-
The minimum supported Deno version is 2.
18-
1918
<PlatformContent includePath="getting-started-prerequisites" />
2019

21-
## Configure
20+
## Step 1: Install
2221

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

24+
<OnboardingOptionButtons
25+
options={["error-monitoring", "performance", "logs"]}
26+
/>
2527

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

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

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

32-
```javascript {tabTitle: Deno}
34+
```javascript {filename: main.ts}
3335
import * as Sentry from "npm:@sentry/deno";
36+
// your other imports
37+
```
38+
39+
## Step 2: Configure
40+
41+
### Initialize the Sentry SDK
42+
43+
Initialize Sentry as early as possible in your app:
44+
45+
```javascript {filename: main.ts}
46+
import * as Sentry from "npm:@sentry/deno";
47+
// your other imports
3448

3549
Sentry.init({
3650
dsn: "___PUBLIC_DSN___",
37-
51+
3852
// Adds request headers and IP for users, for more info visit:
3953
// https://docs.sentry.io/platforms/javascript/guides/deno/configuration/options/#sendDefaultPii
4054
sendDefaultPii: true,
@@ -47,56 +61,91 @@ Sentry.init({
4761
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
4862
tracesSampleRate: 1.0,
4963
// ___PRODUCT_OPTION_END___ performance
64+
// ___PRODUCT_OPTION_START___ logs
65+
66+
// Enable logs to be sent to Sentry
67+
enableLogs: true,
68+
// ___PRODUCT_OPTION_END___ logs
5069
});
5170
```
5271

53-
```javascript {tabTitle: npm}
54-
import * as Sentry from "@sentry/deno";
72+
### Enable Network Access
5573

56-
Sentry.init({
57-
dsn: "___PUBLIC_DSN___",
58-
// ___PRODUCT_OPTION_START___ performance
59-
60-
// Set tracesSampleRate to 1.0 to capture 100%
61-
// of transactions for performance monitoring.
62-
// We recommend adjusting this value in production
63-
// Learn more at
64-
// https://docs.sentry.io/platforms/javascript/configuration/options/#traces-sample-rate
65-
tracesSampleRate: 1.0,
66-
// ___PRODUCT_OPTION_END___ performance
67-
});
68-
```
69-
To ensure the SDK can send events, you should enable network access for your
70-
ingestion domain:
74+
To make sure the SDK can send events, enable network access for your Sentry ingestion domain:
7175

7276
```bash
7377
deno run --allow-net=___ORG_INGEST_DOMAIN___ index.ts
7478
```
7579

76-
## Allow access to your source files
80+
### Allow Access to Source Files
7781

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

8084
```bash
8185
deno run --allow-read=./src index.ts
8286
```
8387

84-
## Verify
88+
## Step 3: Add Readable Stack Traces With Source Maps (Optional)
89+
90+
<PlatformContent includePath="getting-started-sourcemaps-short-version" />
8591

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

88-
Verify your setup by adding the following snippet anywhere in your code and running it:
94+
Let's test your setup and confirm that Sentry is working correctly and sending data to your Sentry project.
95+
96+
### Issues
97+
98+
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:
8999

90100
```javascript
91101
setTimeout(() => {
92-
throw new Error();
102+
try {
103+
foo();
104+
} catch (e) {
105+
Sentry.captureException(e);
106+
}
107+
}, 99);
108+
```
109+
110+
<OnboardingOption optionId="performance">
111+
### Tracing
112+
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:
113+
```javascript
114+
Sentry.startSpan({
115+
op: "test",
116+
name: "My First Test Transaction",
117+
}, () => {
118+
setTimeout(() => {
119+
try {
120+
foo();
121+
} catch (e) {
122+
Sentry.captureException(e);
123+
}
124+
}, 99);
93125
});
94126
```
127+
</OnboardingOption>
95128

96-
<Alert>
129+
### View Captured Data in Sentry
97130

98-
Learn more about manually capturing an error or message in our <PlatformLink to="/usage/">Usage documentation</PlatformLink>.
131+
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).
99132

100-
</Alert>
133+
<PlatformContent includePath="getting-started-verify-locate-data" />
134+
135+
## Next Steps
136+
137+
At this point, you should have integrated Sentry into your Deno application and should already be sending data to your Sentry project.
138+
139+
Now's a good time to customize your setup and look into more advanced topics. Our next recommended steps for you are:
140+
141+
- Extend Sentry to your frontend using one of our [frontend SDKs](/)
142+
- Learn how to <PlatformLink to="/usage">manually capture errors</PlatformLink>
143+
- Continue to <PlatformLink to="/configuration">customize your configuration</PlatformLink>
144+
- Get familiar with [Sentry's product features](/product) like tracing, insights, and alerts
145+
146+
<Expandable permalink={false} title="Are you having problems setting up the SDK?">
147+
148+
- Find various topics in <PlatformLink to="/troubleshooting">Troubleshooting</PlatformLink>
149+
- [Get support](https://sentry.zendesk.com/hc/en-us/)
101150

102-
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.
151+
</Expandable>
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Expandable title="Want to learn more about these features?">
2+
3+
- [**Issues**](/product/issues) (always enabled): Sentry's core error monitoring product that automatically reports errors,
4+
uncaught exceptions, and unhandled rejections. If you have something that
5+
looks like an exception, Sentry can capture it.
6+
- [**Tracing**](/product/tracing): Track software performance while seeing the
7+
impact of errors across multiple systems. For example, distributed tracing
8+
allows you to follow a request from the frontend to the backend and back.
9+
- [**Logs**](/product/explore/logs): Centralize and analyze your application logs to
10+
correlate them with errors and performance issues. Search, filter, and
11+
visualize log data to understand what's happening in your applications.
12+
13+
</Expandable>
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
## Prerequisites
2+
3+
You need:
4+
5+
- A Sentry [account](https://sentry.io/signup/) and [project](/product/projects/)
6+
- Your application up and running
7+
- Deno version >= `2.0.0`
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<Expandable title="Need help locating the captured errors in your Sentry project?">
2+
3+
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).
4+
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).
5+
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).
6+
7+
</Expandable>

0 commit comments

Comments
 (0)