Skip to content

Commit 965009d

Browse files
Alex KrawiecAlex Krawiec
authored andcommitted
Flesh out generating first error doc
1 parent 4c0abf8 commit 965009d

File tree

1 file changed

+90
-0
lines changed

1 file changed

+90
-0
lines changed
Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
---
2+
title: Capture Your First Distributed Tracing Error
3+
sidebar_order: 3
4+
description: "Learn how to capture your first error and view it in Sentry."
5+
---
6+
7+
Now that the sample apps are up and running on your local environment and integrated with the Sentry SDKs, you're ready to generate the first error. Please ensure you have BOTH apps running (on http://localhost:3000 and http://localhost:3001).
8+
9+
You should see the 'One-Stop Shop' site running on http://localhost:3000. When you click on any of the product buttons, this will trigger a call to the backend for product info. As long as your Express server is running, you should see titles, images and descriptions for each product.
10+
11+
## 1. Trigger an Error
12+
13+
To start using Sentry's error monitoring feature, you need some errors first. Let's add in an obvious error that will be easy to see in Sentry.
14+
15+
If you're using your own source code, skip this step. Instead, select your [platform](/platforms/) and follow its **Verify** step inside the **Getting Started** guide to introduce an error.
16+
17+
1. In the `tracing-frontend` repo, open `src/App.js` and update the `onClick` handler by replacing the string passed to the `getProduct()` function from `nonfat-water` to `debug-sentry`.
18+
19+
```jsx {filename:App.js}
20+
<div className="btn-parent">
21+
<button className="btn" onClick={() => getProduct("clown-shoes")}>
22+
Clown Shoes
23+
</button>
24+
</div>
25+
<div className="btn-parent">
26+
<button className="btn" onClick={() => getProduct("debug-sentry")}>
27+
Nonfat Water
28+
</button>
29+
</div>
30+
```
31+
Take note that in the `server.js` file of the `backend-tracing` repo, there is a middleware function handling the `/products/debug-sentry` route, which throws a sample error:
32+
33+
```javascript{filename:server.js}
34+
app.get("/products/debug-sentry", (req, res) => {
35+
console.log('Sentry Error thrown!');
36+
throw new Error("My first Sentry error!");
37+
});
38+
```
39+
40+
41+
42+
1. Save the file.
43+
44+
1. Go back to the browser window and try clicking on the **Nonfat Water** button again, you will no longer see the expected product information. Instead, you'll see text saying something went wrong. If you look at line 88 of the `App.js` file in the `frontend-tracing` repo, you'll see this is what the frontend displays when it's call to the backend doesn't return any data.
45+
46+
1. Open the terminal window that's running the `backend-tracing` server. Here, you'll see that a log letting you know that an error has occurred.
47+
48+
```bash
49+
Sentry Error thrown!
50+
```
51+
52+
53+
54+
## 2. View the Error in Sentry
55+
56+
Now that you've triggered an error, let's see what it looks like in Sentry.
57+
58+
1. Open the **Issues** page in [Sentry.io](https://sentry.io/). Make sure your project is selected in the projects dropdown.
59+
60+
2. Select the error from the issues list to to view the full details and context of this error.
61+
62+
Note that Sentry aggregates similar errors (events) into one [Issue](/product/issues/). If you trigger this error multiple times, you won't see more issues appear. Instead, you'll see the number of events for that issue increase.
63+
64+
3. On the [Issue Details](/product/issues/issue-details/) page, scroll down to the stack trace.
65+
66+
Notice that the stack trace is _minified_. JavaScript is typically minified to reduce to the size of the source code. This means you can't see the actual lines of code from your app in the stack trace.
67+
68+
With a little configuration, Sentry can unminify your code back to its readable form and display your source code in each stack frame. You'll set this up in the next section.
69+
70+
### UI Walkthrough
71+
72+
The interactive demo below walks through how to view error details in Sentry.
73+
74+
<div style={{"height":"0px","paddingBottom":"calc(52.1021021021021% + 41px)","position":"relative","width":"100%"}}>
75+
<iframe
76+
src="https://demo.arcade.software/nTTSJdR4TyqHATbVMOzA?embed"
77+
frameborder="0"
78+
loading="lazy"
79+
webkitallowfullscreen
80+
mozallowfullscreen
81+
allowfullscreen
82+
allow="fullscreen;"
83+
style={{"colorScheme":"light","height":"100%","left":"0px","position":"absolute","top":"0px","width":"100%"}}
84+
title="FE Tutorial - View First Error"
85+
></iframe>
86+
</div>
87+
88+
## Next
89+
90+
At this point, you've verified that Sentry is monitoring errors for your app. So you know there's an issue, but where do you go to fix it? In the next section, you'll learn how to [Enable Readable Stack Traces in Your Errors](/product/sentry-basics/integrate-frontend/upload-source-maps/) so Sentry can show you exactly which line in which file is causing the issue.

0 commit comments

Comments
 (0)