Skip to content

Commit a9c0762

Browse files
docs: Update README with general description and examples (#3302)
1 parent a14c513 commit a9c0762

File tree

1 file changed

+45
-4
lines changed

1 file changed

+45
-4
lines changed

packages/nextjs/README.md

Lines changed: 45 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,13 +7,54 @@
77

88
# Official Sentry SDK for NextJS
99

10-
TODO: npm version, npm dm, npm dt, typedoc
11-
1210
## Links
1311

1412
- [Official SDK Docs](https://docs.sentry.io/quickstart/)
1513
- [TypeDoc](http://getsentry.github.io/sentry-javascript/)
1614

17-
## Usage
15+
## General
16+
17+
This package is a wrapper around `@sentry/node` for the server and `@sentry/react` for the client, with added functionality related to NextJS.
18+
19+
To use this SDK, call `Sentry.init(options)` as early as possible in the server and the client;
20+
this will initialize the SDK and hook into the environment.
21+
22+
23+
```javascript
24+
import * as Sentry from '@sentry/nextjs';
25+
26+
Sentry.init({
27+
dsn: '__DSN__',
28+
// ...
29+
});
30+
```
31+
32+
To set context information or send manual events, use the exported functions of `@sentry/minimal`.
33+
Note that these functions will not perform any action before you have called `Sentry.init()`:
34+
35+
```javascript
36+
import * as Sentry from '@sentry/nextjs';
37+
38+
// Set user information, as well as tags and further extras
39+
Sentry.configureScope(scope => {
40+
scope.setExtra('battery', 0.7);
41+
scope.setTag('user_mode', 'admin');
42+
scope.setUser({ id: '4711' });
43+
// scope.clear();
44+
});
45+
46+
// Add a breadcrumb for future events
47+
Sentry.addBreadcrumb({
48+
message: 'My Breadcrumb',
49+
// ...
50+
});
1851

19-
TODO
52+
// Capture exceptions, messages or manual events
53+
Sentry.captureMessage('Hello, world!');
54+
Sentry.captureException(new Error('Good bye'));
55+
Sentry.captureEvent({
56+
message: 'Manual',
57+
stacktrace: [
58+
// ...
59+
],
60+
});```

0 commit comments

Comments
 (0)