Skip to content

Commit e8c77a6

Browse files
onurtemizkanimatwawanamydea
authored
Restructure Node SDK docs. (#5710)
Summary: - Removed references to client-side usage / snippets. - Restructured the sidebar to match the flow of other JavaScript docs. - Moved parts to `platform-includes` when possible. - Removed outdated remarks / warnings about old versions. Co-authored-by: Isabel <[email protected]> Co-authored-by: Francesco Novy <[email protected]>
1 parent 20e7349 commit e8c77a6

File tree

22 files changed

+240
-230
lines changed

22 files changed

+240
-230
lines changed

src/platform-includes/capture-error/node.mdx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
You can pass an error object to `captureException()` to get it captured as event. It's possible to throw strings as errors in which case no stacktrace can be recorded.
1+
You can pass an `Error` object to `captureException()` to have it captured as event. It's also possible to pass non-`Error` objects and strings, but be aware that the resulting events in Sentry may be missing a stack trace.
22

33
```javascript
4+
import * as Sentry from '@sentry/node';
5+
46
try {
5-
// ...
7+
aFunctionThatMightFail()
68
} catch (e) {
79
Sentry.captureException(e);
810
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
`event`
2+
3+
: For breadcrumbs created from browser events, the Sentry SDK often supplies the event to the breadcrumb as a hint. This can be used to extract data from the target DOM element into a breadcrumb, for example.
4+
5+
`level` / `input`
6+
7+
: For breadcrumbs created from console log interceptions. This holds the original console log level and the original input data to the log function.
8+
9+
`response` / `input`
10+
11+
: For breadcrumbs created from HTTP requests. This holds the response object (from the fetch API) and the input parameters to the fetch function.
12+
13+
`request` / `response` / `event`
14+
15+
: For breadcrumbs created from HTTP requests. This holds the request and response object (from the node HTTP API) as well as the node event (`response` or `error`).
16+
17+
`xhr`
18+
19+
: For breadcrumbs created from HTTP requests made using the legacy `XMLHttpRequest` API. This holds the original `xhr` object.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
`level` / `input`
2+
3+
: For breadcrumbs created from console log interceptions. This holds the original console log level and the original input data to the log function.
4+
5+
`request` / `response` / `event`
6+
7+
: For breadcrumbs created from HTTP requests. This holds the request and response object (from the node HTTP API) as well as the node event (`response` or `error`).
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```javascript {tabTitle: JavaScript}
2+
import * as Sentry from "@sentry/node";
3+
import { CaptureConsole as CaptureConsoleIntegration } from "@sentry/integrations";
4+
5+
Sentry.init({
6+
dsn: "___PUBLIC_DSN___",
7+
integrations: [new CaptureConsoleIntegration(
8+
{
9+
// array of methods that should be captured
10+
// defaults to ['log', 'info', 'warn', 'error', 'debug', 'assert']
11+
levels: string[];
12+
}
13+
)],
14+
});
15+
```

src/platform-includes/configuration/decluttering/javascript.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ You can also use `denyUrls` if you want to block specific URLs forever.
1212

1313
<Alert level="warning" title="Note">
1414

15-
Prior to version 5.17.0, `allowUrls` and `denyUrls` were called `whitelistUrls` and `blacklistUrls` respectively. These options are still supported for backwards compatibility reasons, but they will be removed in version 7.0. For more information, please see our [Inclusive Language Policy](https://develop.sentry.dev/inclusion/).
15+
Previously, `allowUrls` and `denyUrls` were called `whitelistUrls` and `blacklistUrls` respectively. These options are removed in version 7.0. For more information, please see our [Inclusive Language Policy](https://develop.sentry.dev/inclusion/).
1616

1717
</Alert>
1818

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
```javascript {tabTitle: JavaScript}
2+
import * as Sentry from "@sentry/browser";
3+
import { ReportingObserver as ReportingObserverIntegration } from "@sentry/integrations";
4+
5+
Sentry.init({
6+
dsn: "___PUBLIC_DSN___",
7+
integrations: [new ReportingObserverIntegration()],
8+
});
9+
```
10+
11+
```javascript {tabTitle: CDN}
12+
<script
13+
src="https://browser.sentry-cdn.com/{{ packages.version('sentry.javascript.browser') }}/bundle.min.js"
14+
integrity="sha384-{{ packages.checksum('sentry.javascript.browser', 'bundle.min.js', 'sha384-base64') }}"
15+
crossorigin="anonymous"
16+
></script>
17+
18+
<script
19+
src="https://browser.sentry-cdn.com/{{ packages.version('sentry.javascript.browser') }}/reportingobserver.min.js"
20+
integrity="sha384-{{ packages.checksum('sentry.javascript.browser', 'reportingobserver.min.js', 'sha384-base64') }}"
21+
crossorigin="anonymous"
22+
></script>
23+
24+
Sentry.init({
25+
dsn: "___PUBLIC_DSN___",
26+
integrations: [new Sentry.Integrations.ReportingObserver()],
27+
});
28+
```
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
```javascript {tabTitle: JavaScript}
2+
import * as Sentry from "@sentry/node";
3+
import { RewriteFrames as RewriteFramesIntegration } from "@sentry/integrations";
4+
5+
Sentry.init({
6+
dsn: "___PUBLIC_DSN___",
7+
integrations: [new RewriteFramesIntegration(
8+
{
9+
// root path that will be stripped from the current frame's filename by the default iteratee if the filename is an absolute path
10+
root: string;
11+
12+
// a custom prefix that will be used by the default iteratee (default: `app://`)
13+
prefix: string;
14+
15+
// function that takes the frame, applies a transformation, and returns it
16+
iteratee: (frame) => frame;
17+
}
18+
)],
19+
});
20+
```
21+
22+
#### Usage Examples
23+
24+
For example, if the full path to your file is `/www/src/app/file.js`:
25+
26+
| Usage | Path in Stack Trace | Description |
27+
| --------------------------------- | ------------------------ | ----------------------------------------------------------------------------------------------------------------------------- |
28+
| `RewriteFrames()` | `app:///file.js` | The default behavior is to replace the absolute path, except the filename, and prefix it with the default prefix (`app:///`). |
29+
| `RewriteFrames({prefix: 'foo/'})` | `foo/file.js` | Prefix `foo/` is used instead of the default prefix `app:///`. |
30+
| `RewriteFrames({root: '/www'})` | `app:///src/app/file.js` | `root` is defined as `/www`, so only that part is trimmed from beginning of the path. |
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
```javascript {tabTitle: JavaScript}
2+
import * as Sentry from "@sentry/node";
3+
import * as _ from "@sentry/tracing"
4+
// Note: You MUST import the package in some way for tracing to work
5+
6+
Sentry.init({
7+
dsn: "___PUBLIC_DSN___",
8+
9+
// To set a uniform sample rate
10+
tracesSampleRate: 0.2
11+
12+
// Alternatively, to control sampling dynamically
13+
tracesSampler: samplingContext => { ... }
14+
});
15+
```

src/platform-includes/performance/connect-services/node.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ const transaction = Sentry.startTransaction({
2424
name: 'transaction_name',
2525
...traceparentData,
2626
});
27-
```
27+
```

src/platform-includes/sourcemaps/best-practices/javascript.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ plugins: [
2929
authToken: process.env.SENTRY_AUTH_TOKEN,
3030
org: "___ORG_SLUG___",
3131
project: "___PROJECT_SLUG___",
32-
include: "build",
32+
include: "build",
3333
configFile: "sentry.properties",
3434
release: process.env.SENTRY_RELEASE,
3535
}),

src/platforms/common/configuration/filtering.mdx

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -69,25 +69,7 @@ In this example, the fingerprint is forced to a common value if an exception of
6969

7070
#### Hints for Breadcrumbs
7171

72-
`event`
73-
74-
: For breadcrumbs created from browser events, the Sentry SDK often supplies the event to the breadcrumb as a hint. This, for instance, can be used to extract data from the target DOM element into a breadcrumb.
75-
76-
`level` / `input`
77-
78-
: For breadcrumbs created from console log interceptions. This holds the original console log level and the original input data to the log function.
79-
80-
`response` / `input`
81-
82-
: For breadcrumbs created from HTTP requests. This holds the response object (from the fetch API) and the input parameters to the fetch function.
83-
84-
`request` / `response` / `event`
85-
86-
: For breadcrumbs created from HTTP requests. This holds the request and response object (from the node HTTP API) as well as the node event (`response` or `error`).
87-
88-
`xhr`
89-
90-
: For breadcrumbs created from HTTP requests done via the legacy `XMLHttpRequest` API. This holds the original xhr object.
72+
<PlatformContent includePath="configuration/breadcrumb-hints" />
9173

9274
</PlatformSection>
9375

src/platforms/common/performance/index.mdx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ supported:
2020
- rust
2121
- native
2222
- php
23+
- node
2324
notSupported:
2425
- javascript.cordova
2526
- native.breakpad
@@ -89,7 +90,7 @@ Learn more about how the options work in <PlatformLink to="/configuration/sampli
8990

9091
## Verify
9192

92-
<PlatformSection supported={["react-native", "java.spring", "java.spring-boot", "android", "javascript", "apple", "dart", "rust"]} >
93+
<PlatformSection supported={["react-native", "java.spring", "java.spring-boot", "android", "javascript", "apple", "dart", "rust"]}>
9394

9495
Verify that performance monitoring is working correctly by using our <PlatformLink to="/performance/instrumentation/automatic-instrumentation/">automatic instrumentation</PlatformLink> or by starting and finishing a transaction using <PlatformLink to="/performance/instrumentation/custom-instrumentation/">custom instrumentation</PlatformLink>.
9596

src/platforms/common/performance/instrumentation/custom-instrumentation.mdx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ sidebar_order: 20
44
supported:
55
- javascript
66
- javascript.cordova
7+
- node
78
- react-native
89
- dotnet
910
- python

src/platforms/common/performance/instrumentation/index.mdx

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ sidebar_order: 20
44
description: "Learn how to instrument performance in your app."
55
notSupported:
66
- javascript.cordova
7-
- node
87
- native.breakpad
98
- native.crashpad
109
- native.minidumps

src/platforms/javascript/common/configuration/integrations/default.mdx

Lines changed: 25 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,7 @@ redirect_from:
77
- /platforms/javascript/default-integrations/
88
---
99

10-
All of Sentry’s SDKs provide integrations, which extend functionality of the SDK.
11-
12-
System integrations are enabled by default to integrate into the standard library or the interpreter itself. They are documented so you can be both aware of what they do and disable them if they cause issues.
10+
System integrations are enabled by default to integrate into the standard library or the interpreter itself. They're documented so you can understand what they do and disable them if they cause issues.
1311

1412
## Enabled by Default
1513

@@ -22,15 +20,15 @@ message, or URLs in a given exception.
2220

2321
It ignores errors that start with `Script error` or `Javascript error: Script error` by default.
2422

25-
To configure this integration, use `ignoreErrors`, `denyUrls`,
23+
To configure this integration, use the `ignoreErrors`, `denyUrls`,
2624
and `allowUrls` SDK options directly. Keep in mind that `denyURLs` and `allowURLs`
27-
work only for captured exceptions, not raw message events.
25+
only work for captured exceptions, not raw message events.
2826

2927
### FunctionToString
3028

3129
_Import name: `Sentry.Integrations.FunctionToString`_
3230

33-
This integration allows the SDK to provide original functions and method names, even when our error or breadcrumbs handlers wrap them.
31+
This integration allows the SDK to provide original functions and method names, even when those functions or methods are wrapped by our error or breadcrumb handlers.
3432

3533
### TryCatch
3634

@@ -92,7 +90,7 @@ Available options:
9290

9391
_Import name: `Sentry.Integrations.LinkedErrors`_
9492

95-
This integration allows you to configure linked errors. They’ll be recursively read up to a specified limit and lookup will be performed by a specific key. By default, the Sentry SDK sets the limit to five and the key used is `cause`.
93+
This integration allows you to configure linked errors. They’ll be recursively read up to a specified limit, and lookup will be performed by a specific key. By default, the Sentry SDK sets the limit to five and the key used is `"cause"`.
9694

9795
Available options:
9896

@@ -122,35 +120,49 @@ document
122120
});
123121
```
124122

125-
### HttpContext (previously: UserAgent)
123+
### HttpContext
124+
125+
_(Previously: `UserAgent`)_
126126

127127
_Import name: `Sentry.Integrations.HttpContext`_
128128

129129
<Note>
130130

131131
Before version 7.0.0 of the Sentry SDK, this integration was called `UserAgent`.
132-
It was renamed because the integration handles more than just user-agent data.
132+
It was renamed because the integration handles more than user-agent data.
133133

134134
_Import name: `Sentry.Integrations.UserAgent`_
135135

136136
</Note>
137137

138-
This integration attaches HTTP request information, such as URL, user-agent, referrer and other headers to the event.
138+
This integration attaches HTTP request information, such as URL, user-agent, referrer, and other headers to the event.
139139
It allows us to correctly catalog and tag events with specific OS, browser, and version information.
140140

141141
### Dedupe
142142

143143
_Import name: `Sentry.Integrations.Dedupe`_
144144

145-
This integration deduplicates certain events. It can be helpful if you are receiving many duplicate errors. Note that Sentry will only compare stack traces and fingerprints. This integration is enabled by default for Browser.
145+
This integration deduplicates certain events. It can be helpful if you're receiving many duplicate errors. Note that Sentry only compares stack traces and fingerprints. This integration is enabled by default for Browser.
146146

147147
<PlatformContent includePath="configuration/dedupe" />
148148

149149
## Modifying System Integrations
150150

151-
To disable system integrations set `defaultIntegrations: false` when calling `init()`.
151+
To disable system integrations, set `defaultIntegrations: false` when calling `init()`.
152+
153+
To override their settings, provide a new instance with your config to the `integrations` option. For example, to turn off browser capturing console calls:
154+
155+
```javascript
156+
Sentry.init({
157+
dsn: '___PUBLIC_DSN___',
152158

153-
To override their settings, provide a new instance with your config to `integrations` option. For example, to turn off browser capturing console calls: `integrations: [new Sentry.Integrations.Breadcrumbs({ console: false })]`.
159+
integrations: [
160+
new Sentry.Integrations.Breadcrumbs({
161+
console: false
162+
})
163+
]
164+
});
165+
```
154166

155167
### Removing an Integration
156168

src/platforms/javascript/common/configuration/integrations/plugin.mdx

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,39 +6,43 @@ redirect_from:
66
- /platforms/javascript/pluggable-integrations/
77
---
88

9-
These pluggable integrations are snippets of code that augment functionality for specific applications and/or frameworks. We document them so you can see what they do and that they can be enabled.
9+
These pluggable integrations are snippets of code that augment functionality for specific applications and/or frameworks. We document them so you can understand what they do and enable them, if needed.
1010

1111
## How to Enable
1212

13-
Install the `@sentry/integrations` package and provide a new instance with your config to `integrations` option. Include the plugin after the SDK has been loaded.
13+
Install the `@sentry/integrations` package and provide a new instance with your config to the `integrations` option. Include the plugin after the SDK has been loaded.
1414

1515
For example:
1616

1717
<PlatformContent includePath="configuration/enable-pluggable-integrations" />
1818

19+
<PlatformSection supported={["javascript"]}>
20+
1921
### ExtraErrorData
2022

2123
_Import name: `Sentry.Integrations.ExtraErrorData`_
2224

23-
This integration extracts all non-native attributes from the Error object and attaches them to the event as the `extra` data. If the error object has a `.toJSON()` method, the `ExtraErrorData` integration will run it to extract additional information.
25+
This integration extracts all non-native attributes from the `error` object and attaches them to the event as the `extra` data. If the error object has a `.toJSON()` method, the `ExtraErrorData` integration will run it to extract additional information.
2426

2527
Available options:
2628

2729
<PlatformContent includePath="configuration/extra-error-data" />
2830

31+
</PlatformSection>
32+
2933
### CaptureConsole
3034

3135
_Import name: `Sentry.Integrations.CaptureConsole`_
3236

33-
This integration captures all `Console API` calls and redirects them to Sentry using the SDK's `captureMessage` or `captureException` call depending on the log level. It then retriggers to preserve default native behavior.
37+
This integration captures all `Console API` calls and redirects them to Sentry using the SDK's `captureMessage` or `captureException` call, depending on the log level. It then re-triggers to preserve default native behavior:
3438

3539
<PlatformContent includePath="configuration/capture-console" />
3640

3741
### Debug
3842

3943
_Import name: `Sentry.Integrations.Debug`_
4044

41-
This integration allows you to inspect the content of the processed event, that will be passed to `beforeSend` and effectively send to the Sentry SDK. It will *always* run as the last integration, no matter when it was registered.
45+
This integration allows you to inspect the content of the processed event that will be passed to `beforeSend`, and effectively send it to the Sentry SDK. It will *always* run as the last integration, no matter when it was registered.
4246

4347
Available options:
4448

@@ -50,9 +54,9 @@ Available options:
5054

5155
_Import name: `Sentry.Integrations.Offline`_
5256

53-
This integration uses the web browser's [online and offline events](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/Online_and_offline_events) to detect when no network connectivity is available. If offline, it saves events to the web browser's client-side storage (typically IndexedDB) then automatically uploads events when network connectivity is restored.
57+
This integration uses the web browser's [online and offline events](https://developer.mozilla.org/en-US/docs/Web/API/NavigatorOnLine/Online_and_offline_events) to detect when no network connectivity is available. If offline, it saves events to the web browser's client-side storage (typically IndexedDB), then automatically uploads events when network connectivity is restored.
5458

55-
This plugin does not attempt to provide local storage or retries for other scenarios. For example, if the browser has a local area connection but no internet connection, then it may report that it's online, and Sentry's `Offline` plugin will not attempt to save or retry any send failures in this case.
59+
This plugin does not attempt to provide local storage or retries for other scenarios. For example, if the browser has a local area connection but no internet connection, then it may report that it's online, and Sentry's `Offline` plugin will not attempt to save or retry any send failures in this case:
5660

5761
<PlatformContent includePath="configuration/offline" />
5862

@@ -64,7 +68,7 @@ _Import name: `Sentry.Integrations.RewriteFrames`_
6468

6569
This integration allows you to apply a transformation to each frame of the stack trace. In the streamlined scenario, it can be used to change the name of the file frame it originates from, or it can be fed with an iterated function to apply any arbitrary transformation.
6670

67-
On Windows machines, you have to use Unix paths and skip the volume letter in `root` option to enable. For example `C:\\Program Files\\Apache\\www` won’t work, however, `/Program Files/Apache/www` will.
71+
On Windows machines, you have to use Unix paths and skip the volume letter in the `root` option to enable it. For example, `C:\\Program Files\\Apache\\www` won’t work, however, `/Program Files/Apache/www` will.
6872

6973
Available options:
7074

0 commit comments

Comments
 (0)