Skip to content

Commit 46f9d0d

Browse files
Alex KrawiecAlex Krawiec
authored andcommitted
Update todos and various small copy changes, format w/ prettier
1 parent 0a3c284 commit 46f9d0d

File tree

5 files changed

+138
-105
lines changed

5 files changed

+138
-105
lines changed

docs/product/sentry-basics/distributed-tracing/create-new-project.mdx

Lines changed: 45 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ description: "Learn how to create your Sentry projects, which will scope events
66

77
In order to capture errors and other events, you need to have a project set up in Sentry. In this walkthrough we'll be creating a frontend project in React and a separate backend project in Express.
88

9-
Because you can create a Sentry _Project_ for each language or framework used in your application (for example, you might have separate projects for your API server and frontend client), a single application might have multiple projects associated with it. Once you've set up all the projects that correspond to different parts of your application in Sentry, you'll be able to scope events to a distinct application in your organization and assign responsibility to specific users and teams. For more information, see [best practices for creating projects](/organization/getting-started/#4-create-projects).
9+
Because you can create a Sentry Project for _each_ language or framework used in your application (for example, you might have separate projects for your API server and frontend client), a single application might have multiple projects associated with it. Once you've set up all the projects that correspond to different parts of your application in Sentry, you'll be able to scope events to a distinct application in your organization and assign responsibility to specific users and teams. For more information, see [best practices for creating projects](/organization/getting-started/#4-create-projects).
1010

1111
## Create a Frontend Project
1212

@@ -18,24 +18,32 @@ Follow the steps below to create a new Sentry project for a sample React applica
1818

1919
1. Click "Create Project" and configure it as appropriate for your application:
2020

21-
- **Choose your platform**: Select the language or framework for your project based on the code you wish to monitor. In this case, choose **React**.
21+
- **Choose your platform**: Select the language or framework for your project based on the code you wish to monitor. In this case, choose **React**.
2222

23-
- **Set your alert frequency**: For the purpose of this tutorial, select **Alert me on high priority issues**.
23+
- **Set your alert frequency**: For the purpose of this tutorial, select **Alert me on high priority issues**.
2424

25-
> If you're wary of alert fatigue, learn more about how to set up your alerts in [Alerts Best Practices](/product/alerts/best-practices/).
25+
> If you're wary of alert fatigue, learn more about how to set up your alerts in [Alerts Best Practices](/product/alerts/best-practices/).
2626
27-
- **Name your project and assign it a team**: Name your project in the **Project name** field and assign a team by selecting one in the **Team** dropdown (or click **+** to create a new team).
27+
- **Name your project and assign it a team**: Name your project in the **Project name** field and assign a team by selecting one in the **Team** dropdown (or click **+** to create a new team).
28+
29+
- Click **Create Project**. This takes you to the quick Configure React SDK guide, which provides an overview of how to configure the SDK. This tutorial covers the SDK setup in more detail.
30+
31+
- You'll notice that the Sentry React SDK setup code has come pre-populated with the project's unique DSN (Data Source Name). The DSN tells the SDK where to send events, so events are associated with the right project. You'll need to paste the DSN key into the SDK configuration code later in the tutorial. You can make a note of it now, or you can also find a project's DSN anytime in **[Project] > Settings > Client Keys (DSN)**
2832

29-
- Click **Create Project**. This takes you to the quick Configure React SDK guide, which provides an overview of how to configure the SDK. This tutorial covers the SDK setup in more detail.
30-
31-
- You'll notice that the Sentry React SDK setup code has come pre-populated with the project's unique DSN (Data Source Name). The DSN tells the SDK where to send events, so events are associated with the right project. You'll need to paste the DSN key into the SDK configuration code later in the tutorial. You can make a note of it now, or you can also find a project's DSN anytime in **[Project] > Settings > Client Keys (DSN)**
3233
1. Click **Take me to Issues** to go to your new project's **Issues** page.
3334

3435
### UI Walkthrough
3536

3637
The interactive demo below walks through how to create a new project in the UI.
3738

38-
<div style={{"height":"0px","paddingBottom":"calc(56.88524590163935% + 41px)","position":"relative","width":"100%"}}>
39+
<div
40+
style={{
41+
height: "0px",
42+
paddingBottom: "calc(56.88524590163935% + 41px)",
43+
position: "relative",
44+
width: "100%",
45+
}}
46+
>
3947
<iframe
4048
src="https://demo.arcade.software/4z9l5xNZfpXFGAFc03az?embed"
4149
frameborder="0"
@@ -44,7 +52,14 @@ The interactive demo below walks through how to create a new project in the UI.
4452
mozallowfullscreen
4553
allowfullscreen
4654
allow="fullscreen;"
47-
style={{"colorScheme":"light","height":"100%","left":"0px","position":"absolute","top":"0px","width":"100%"}}
55+
style={{
56+
colorScheme: "light",
57+
height: "100%",
58+
left: "0px",
59+
position: "absolute",
60+
top: "0px",
61+
width: "100%",
62+
}}
4863
title="FE Tutorial -> Create Project"
4964
></iframe>
5065
</div>
@@ -59,13 +74,13 @@ Next, follow the steps below to create a new Sentry project for a sample Backend
5974

6075
1. Click "Create Project" and configure it as appropriate for your application:
6176

62-
- **Choose your platform**: In this case, choose **Express**.
77+
- **Choose your platform**: In this case, choose **Express**.
6378

64-
- **Set your alert frequency**: Once again, select **Alert me on high priority issues**.
79+
- **Set your alert frequency**: Once again, select **Alert me on high priority issues**.
6580

66-
- **Name your project and assign it a team**: Make sure to give it a different project name than your frontend application.
81+
- **Name your project and assign it a team**: Make sure to give it a different project name than your frontend application.
6782

68-
- Click **Create Project**. This takes you to the quick Configure Express SDK guide, which provides an overview of how to configure the SDK.
83+
- Click **Create Project**. This takes you to the quick Configure Express SDK guide, which provides an overview of how to configure the SDK.
6984

7085
1. Copy the DSN key and keep it handy.
7186

@@ -75,7 +90,14 @@ Next, follow the steps below to create a new Sentry project for a sample Backend
7590

7691
### UI Walkthrough
7792

78-
<div style={{"height":"0px","paddingBottom":"calc(56.88524590163935% + 41px)","position":"relative","width":"100%"}}>
93+
<div
94+
style={{
95+
height: "0px",
96+
paddingBottom: "calc(56.88524590163935% + 41px)",
97+
position: "relative",
98+
width: "100%",
99+
}}
100+
>
79101
<iframe
80102
src="https://demo.arcade.software/YXX8LAOHGSP4mWWBMMtM?embed"
81103
frameborder="0"
@@ -84,13 +106,18 @@ Next, follow the steps below to create a new Sentry project for a sample Backend
84106
mozallowfullscreen
85107
allowfullscreen
86108
allow="fullscreen;"
87-
style={{"colorScheme":"light","height":"100%","left":"0px","position":"absolute","top":"0px","width":"100%"}}
109+
style={{
110+
colorScheme: "light",
111+
height: "100%",
112+
left: "0px",
113+
position: "absolute",
114+
top: "0px",
115+
width: "100%",
116+
}}
88117
title="Tracing Tutorial -> Create Express Project"
89118
></iframe>
90119
</div>
91120

92-
93-
94121
## Next
95122

96123
Now that you have your Sentry projects set up, you can [Add the Sentry SDK to Your Frontend Project](/product/sentry-basics/distributed-tracing/initialize-sentry-sdk-frontend/).

docs/product/sentry-basics/distributed-tracing/generate-first-error.mdx

Lines changed: 24 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ If you're using your own source code, skip this step. Instead, select your [plat
1616

1717
1. In the `tracing-tutorial-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`.
1818

19-
```jsx diff {filename:App.js} {7}
19+
```jsx diff {filename:App.js}
2020
<div className="btn-parent">
2121
<button className="btn" onClick={() => getProduct("clown-shoes")}>
2222
Clown Shoes
@@ -29,28 +29,27 @@ If you're using your own source code, skip this step. Instead, select your [plat
2929
</button>
3030
</div>
3131
```
32+
3233
There's a middleware function handling the `/products/debug-sentry` route in the `server.js` file of the `tracing-tutorial-backend` repo that throws a sample error:
3334

3435
```javascript {filename:server.js}
3536
app.get("/products/debug-sentry", (req, res) => {
36-
console.log('Sentry Error thrown!');
37-
throw new Error("My first Sentry error!");
38-
});
37+
console.log("Sentry Error thrown!");
38+
throw new Error("My first Sentry error!");
39+
});
3940
```
4041

41-
42-
4342
1. Save the file.
4443

45-
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 to the bottom of the `App.js` file in the `tracing-tutorial-frontend` repo, you'll see this is what the frontend displays when the call to the backend doesn't return any data.
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 a `500 error` message displayed.
4645

47-
1. Open the terminal window that's running the `tracing-tutorial-backend` server. Here, you'll see a log letting you know that an error has occurred.
46+
1. Open the terminal window that's running the `tracing-tutorial-backend` server. Here, you'll see a log letting you know that an error has occurred:
4847

4948
```bash
5049
Sentry Error thrown!
5150
```
5251

53-
52+
This confirms that the error we just produced on the frontend has triggered a corresponding error on the backend.
5453

5554
## 2. View the Error in Sentry
5655

@@ -66,7 +65,14 @@ Now that you've triggered an error, let's see what it looks like in Sentry.
6665

6766
The interactive demo below walks through how to view a distributed trace in Sentry.
6867

69-
<div style={{"height":"0px","paddingBottom":"calc(52.1021021021021% + 41px)","position":"relative","width":"100%"}}>
68+
<div
69+
style={{
70+
height: "0px",
71+
paddingBottom: "calc(52.1021021021021% + 41px)",
72+
position: "relative",
73+
width: "100%",
74+
}}
75+
>
7076
<iframe
7177
src="https://demo.arcade.software/xPc1a1WUYTnQqPvBQGnQ?embed"
7278
frameborder="0"
@@ -75,7 +81,14 @@ The interactive demo below walks through how to view a distributed trace in Sent
7581
mozallowfullscreen
7682
allowfullscreen
7783
allow="fullscreen;"
78-
style={{"colorScheme":"light","height":"100%","left":"0px","position":"absolute","top":"0px","width":"100%"}}
84+
style={{
85+
colorScheme: "light",
86+
height: "100%",
87+
left: "0px",
88+
position: "absolute",
89+
top: "0px",
90+
width: "100%",
91+
}}
7992
title="FE Tutorial - View First Error"
8093
></iframe>
8194
</div>

docs/product/sentry-basics/distributed-tracing/index.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: Distributed Tracing Tutorial
33
sidebar_order: 1
4-
description: "Follow this tutorial to set up Sentry error monitoring and distributed tracing for a sample fullstack JavaScript application. By the end, you'll be able to trigger an error and a trace and see it in Sentry.io"
4+
description: "Follow this tutorial to set up Sentry error monitoring and distributed tracing for a sample fullstack JavaScript application. By the end, you'll be able to trigger an error and a trace and see it in Sentry.io."
55
---
66

77
This step-by-step tutorial walks you through setting up Sentry in both a frontend (React) and backend (Express) sample application. After completing this tutorial you'll be able to trace the source and impact of your issues across projects and platforms. As part of this tutorial, you will:

docs/product/sentry-basics/distributed-tracing/initialize-sentry-sdk-backend.mdx

Lines changed: 52 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@ This section walks you through how to import the sample application into your lo
99
If you're using your own source code, you can skip this section. Instead:
1010

1111
- Select your [platform](/platforms/) and follow its **Getting Started** guide to add the Sentry SDK to your code.
12-
- Then, skip to the [next step](/product/sentry-basics/integrate-frontend/generate-first-error/).
13-
{/* TODO: UPDATE THIS LINK */}
12+
- Then, skip to the [next step](/product/sentry-basics/distributed-tracing/generate-first-error/).
1413

1514
## 1. Clone the Sample Application
1615

@@ -21,18 +20,16 @@ The sample application is a basic backend application using Express and Node.
2120
1. Clone the forked repository to your local environment:
2221

2322
```bash
24-
git clone [email protected]:<your_username>/frontend-tutorial.git
23+
git clone [email protected]:<your_username>/tracing-tutorial-backend.git
2524
```
26-
{/* TODO: UPDATE NAME OF THIS REPO */}
2725

2826
1. Open the `tracing-tutorial-backend` project in your preferred code editor.
29-
{/* TODO: UPDATE NAME OF THIS REPO */}
3027

3128
## 2. Add the Sentry Node SDK
3229

3330
Sentry captures data by using a platform-specific SDK that you add to your application's runtime. To use the SDK, import and configure it in your source code. This demo project uses [Sentry's Node SDK](https://github.com/getsentry/sentry-javascript/tree/master/packages/node).
3431

35-
1. Navigate to the tracing-tutorial-backend` project folder and install the Sentry Express SDK using NPM.
32+
1. Navigate to the `tracing-tutorial-backend` project folder and install the Sentry Express SDK using NPM.
3633

3734
{/* TODO: UPDATE NAME OF THIS REPO */}
3835

@@ -50,21 +47,19 @@ Sentry captures data by using a platform-specific SDK that you add to your appli
5047

5148
1. Create a file at the root level of your project and call it `instrument.js`. Import and initialize the SDK using the following code:
5249

53-
```javascript {filename:instrument.js}
50+
```javascript {filename:instrument.js}
5451
const Sentry = require("@sentry/node");
5552
const { nodeProfilingIntegration } = require("@sentry/profiling-node");
5653

5754
Sentry.init({
58-
dsn: "sample_DSN_key",
59-
integrations: [
60-
nodeProfilingIntegration(),
61-
],
62-
// Tracing
63-
// Capture 100% of the transactions
64-
tracesSampleRate: 1.0,
65-
66-
// Set sampling rate for profiling - this is relative to tracesSampleRate
67-
profilesSampleRate: 1.0,
55+
dsn: "sample_DSN_key",
56+
integrations: [nodeProfilingIntegration()],
57+
// Tracing
58+
// Capture 100% of the transactions
59+
tracesSampleRate: 1.0,
60+
61+
// Set sampling rate for profiling - this is relative to tracesSampleRate
62+
profilesSampleRate: 1.0,
6863
});
6964
```
7065

@@ -85,57 +80,58 @@ Sentry captures data by using a platform-specific SDK that you add to your appli
8580

8681
The options set in `Sentry.init()` are called the SDK's configuration. The only required configuration option is the DSN. However, the SDK supports many other configuration options. Learn more in our [Configuration](/platforms/javascript/guides/react/configuration/) docs.
8782

88-
The configuration above enables Sentry's error monitoring feature, as well as its [Tracing](will add link later) and [Session Replay](/platforms/javascript/guides/react/session-replay) features.
83+
The configuration above enables Sentry's error monitoring feature, as well as its **Tracing** and [Session Replay](/platforms/javascript/guides/react/session-replay) features.
84+
{/* TODO: Add link for tracing here when tracing doc is live */}
8985

9086
1. Import `instrument.js` at the top of your `server.js` file. Then import `Sentry` and set up the error handler after all controllers and before any other middleware:
9187

92-
``` javascript {filename:server.js} {1-7, 26-36}
93-
// IMPORTANT: Make sure to import `instrument.js` at the top of your file.
94-
// If you're using ECMAScript Modules (ESM) syntax, use `import "./instrument.js";`
95-
require("./instrument.js");
88+
```javascript diff {filename:server.js}
89+
+ // IMPORTANT: Make sure to import `instrument.js` at the top of your file.
90+
+ // If you're using ECMAScript Modules (ESM) syntax, use `import "./instrument.js";`
91+
+ require("./instrument.js");
9692
97-
// All other imports below
98-
// Import with `import * as Sentry from "@sentry/node"` if you are using ESM
99-
const Sentry = require("@sentry/node");
100-
const express = require("express");
101-
const productsRoute = require('./routes/products');
102-
const cors = require('cors')
93+
+ // All other imports below
94+
+ // Import with `import * as Sentry from "@sentry/node"` if you are using ESM
95+
const Sentry = require("@sentry/node");
96+
const express = require("express");
97+
const productsRoute = require('./routes/products');
98+
const cors = require('cors')
10399
104-
const app = express();
100+
const app = express();
105101
106-
app.use(express.static('public'));
107-
app.use(cors());
102+
app.use(express.static('public'));
103+
app.use(cors());
108104
109-
app.get('/', (req, res) => {
110-
res.send('<h1>Hello, Express.js Server here!</h1>');
111-
});
105+
app.get('/', (req, res) => {
106+
res.send('<h1>Hello, Express.js Server here!</h1>');
107+
});
112108
113-
app.get("/products/debug-sentry", (req, res) => {
114-
console.log("Sentry Error thrown!");
115-
throw new Error("My first Sentry error!");
116-
});
109+
app.get("/products/debug-sentry", (req, res) => {
110+
console.log("Sentry Error thrown!");
111+
throw new Error("My first Sentry error!");
112+
});
117113
118-
// The error handler must be registered before any other error middleware and after all controllers
119-
Sentry.setupExpressErrorHandler(app);
114+
+ // The error handler must be registered before any other error middleware and after all controllers
115+
+ Sentry.setupExpressErrorHandler(app);
120116
121-
// Optional fallthrough error handler
122-
app.use(function onError(err, req, res, next) {
123-
// The error id is attached to `res.sentry` to be returned
124-
// and optionally displayed to the user for support.
125-
console.log('500 error thrown!');
126-
res.statusCode = 500;
127-
res.end(res.sentry + "\n");
128-
});
117+
+ // Optional fallthrough error handler
118+
+ app.use(function onError(err, req, res, next) {
119+
+ // The error id is attached to `res.sentry` to be returned
120+
+ // and optionally displayed to the user for support.
121+
+ console.log('500 error thrown!');
122+
+ res.statusCode = 500;
123+
+ res.end(res.sentry + "\n");
124+
+ });
129125
130-
app.use('/products', productsRoute);
126+
app.use('/products', productsRoute);
131127
132-
const port = 3001;
128+
const port = 3001;
133129
134-
app.listen(port, () => {
135-
console.log(`Server is running on port 3001`);
136-
});
130+
app.listen(port, () => {
131+
console.log(`Server is running on port 3001`);
132+
});
137133
138-
```
134+
```
139135

140136
## 3. Build and Run the Sample Application
141137

@@ -147,7 +143,7 @@ In the `tracing-tutorial-backend` project folder:
147143
npm install
148144
```
149145

150-
1. Start the application in develop mode.
146+
1. Start the application in develop mode:
151147

152148
```bash
153149
node server.js
@@ -159,14 +155,12 @@ In the `tracing-tutorial-backend` project folder:
159155
Server is running on port 3001
160156
```
161157

162-
> **Troubleshooting tip**: If the application fails to start due to syntax errors or errors for missing dependencies/modules, make sure you're using Node 18+ and install dependencies again. Run `nvm use 18` and then `npm install`.
158+
> **Troubleshooting tip**: If the application fails to start due to syntax errors or errors for missing dependencies/modules, make sure you're using Node 18+ and install dependencies again. If you're using [nvm](https://github.com/nvm-sh/nvm), ensure you are on the right node version with `nvm use 18` and then `npm install`.
163159
164160
1. Open the sample application in your browser.
165161

166162
The sample app should be running at [http://localhost:3001/](http://localhost:3001/) or the URL output in your terminal in the last step.
167163

168-
169-
170164
## Next
171165

172166
Well done! You now have a sample Express backend app running with the Sentry SDK initialized. Next, [Generate your first cross-project error](/product/sentry-basics/distributed-tracing/generate-first-error/) to start using Sentry's Distributed Tracing feature.

0 commit comments

Comments
 (0)