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 <76437239+imatwawana@users.noreply.github.com> Co-authored-by: Francesco Novy <francesco.novy@sentry.io>
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
}),

0 commit comments

Comments
 (0)