Skip to content

feat: Update setup docs for JS SDKs #6836

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
May 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
```javascript
Sentry.init({
// ...

beforeBreadcrumb(breadcrumb, hint) {
if (breadcrumb.category === "ui.click") {
const { target } = hint.event;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
```javascript
Sentry.init({
// ...

beforeSend(event, hint) {
const error = hint.originalException;
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
```javascript
Sentry.init({
// ...

beforeSend(event, hint) {
const error = hint.originalException;
if (
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
```javascript
Sentry.init({
// ...

beforeBreadcrumb(breadcrumb, hint) {
return breadcrumb.category === "ui.click" ? null : breadcrumb;
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,3 @@
Make sure you've got the JavaScript SDK available:

```html
<script
src="https://browser.sentry-cdn.com/{{ packages.version('sentry.javascript.browser') }}/bundle.min.js"
integrity="sha384-{{ packages.checksum('sentry.javascript.browser', 'bundle.min.js', 'sha384-base64') }}"
crossorigin="anonymous"
></script>
```

If you're using a framework like [React](/platforms/javascript/guides/react/) or [Angular](/platforms/javascript/guides/angular/), the best place to collect user feedback is in your error-handling component. (Please see platform-specific docs for examples.) If you're not using a framework, you can collect feedback right before the event is sent, using `beforeSend`:

```html
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,20 @@ Sentry.init({
tracePropagationTargets: ["localhost", "https://yourserver.io/api"],
routingInstrumentation: Sentry.routingInstrumentation,
}),
// Registers the Replay integration,
// which automatically captures Session Replays
new Sentry.Replay(),
],

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});

platformBrowserDynamic()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,17 @@ import * as Sentry from "@sentry/ember";

Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [new Sentry.Replay()],

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production,
tracesSampleRate: 1.0,

// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});

export default class App extends Application {
Expand Down
9 changes: 7 additions & 2 deletions src/platform-includes/getting-started-config/javascript.mdx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Once this is done, Sentry's JavaScript SDK captures all unhandled exceptions and transactions.
Once this is done, Sentry's JavaScript SDK captures all unhandled exceptions, transactions, and Session Replays, based on the sample rates set.

```javascript
import * as Sentry from "@sentry/browser";
Expand All @@ -9,11 +9,16 @@ Sentry.init({
// Alternatively, use `process.env.npm_package_version` for a dynamic release version
// if your build tool supports it.
release: "[email protected]",
integrations: [new Sentry.BrowserTracing()],
integrations: [new Sentry.BrowserTracing(), new Sentry.Replay()],

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});
```
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,17 @@ import App from "./App";

Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [new Sentry.BrowserTracing()],
integrations: [new Sentry.BrowserTracing(), new Sentry.Replay()],

// We recommend adjusting this value in production, or using tracesSampler
// for finer control
// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});

const container = document.getElementById(“app”);
Expand Down
44 changes: 41 additions & 3 deletions src/platform-includes/getting-started-config/javascript.remix.mdx
Original file line number Diff line number Diff line change
@@ -1,13 +1,16 @@
To use this SDK, initialize Sentry in your Remix entry points for both the client and server.

```typescript {filename: entry.client.tsx}
Create two files in the root directory of your project, `entry.client.tsx` and `entry.server.tsx` (if they don't exist yet). In these files, add your initialization code for the client-side SDK and server-side SDK, respectively.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@AbhiPrasad could you sanity check this?


The two configuration types are mostly the same, except that some configuration features, like Session Replay, only work in `entry.client.tsx`.

```typescript {tabTitle:Client} {filename: entry.client.tsx}
import { useLocation, useMatches } from "@remix-run/react";
import * as Sentry from "@sentry/remix";
import { useEffect } from "react";

Sentry.init({
dsn: "___DSN___",
tracesSampleRate: 1,
integrations: [
new Sentry.BrowserTracing({
routingInstrumentation: Sentry.remixRouterInstrumentation(
Expand All @@ -16,8 +19,43 @@ Sentry.init({
useMatches
),
}),
// Replay is only available in the client
new Sentry.Replay(),
],
// ...

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});
```

```typescript {tabTitle:Server} {filename: entry.server.tsx}
import { useLocation, useMatches } from "@remix-run/react";
import * as Sentry from "@sentry/remix";
import { useEffect } from "react";

Sentry.init({
dsn: "___DSN___",
integrations: [
new Sentry.BrowserTracing({
routingInstrumentation: Sentry.remixRouterInstrumentation(
useEffect,
useLocation,
useMatches
),
}),
],

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,
});
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,17 @@ import * as Sentry from "@sentry/svelte";
// Initialize the Sentry SDK here
Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [new Sentry.BrowserTracing()],
integrations: [new Sentry.BrowserTracing(), new Sentry.Replay()],

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});

const app = new App({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,18 @@ Sentry.init({
new Sentry.BrowserTracing({
routingInstrumentation: Sentry.vueRouterInstrumentation(router),
}),
new Sentry.Replay(),
],

// Set tracesSampleRate to 1.0 to capture 100%
// of transactions for performance monitoring.
// We recommend adjusting this value in production
tracesSampleRate: 1.0,

// Capture Replay for 10% of all sessions,
// plus for 100% of sessions with an error
replaysSessionSampleRate: 0.1,
replaysOnErrorSampleRate: 1.0,
});

// ...
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
```bash
# Using yarn
yarn add @sentry/electron
```bash {tabTitle:npm}
npm install --save @sentry/electron
```

# Using npm
npm install @sentry/electron
```bash {tabTitle:Yarn}
yarn add @sentry/electron
```
21 changes: 17 additions & 4 deletions src/platform-includes/getting-started-install/javascript.mdx
Original file line number Diff line number Diff line change
@@ -1,14 +1,27 @@
```bash {tabTitle: yarn}
yarn add @sentry/browser
In order to get started using the Sentry JavaScript SDK, add the following code to the top of your application, before all other scripts:

```html
<script
src="https://js.sentry-cdn.com/___PUBLIC_KEY___.min.js"
crossorigin="anonymous"
></script>
```

```bash {tabTitle: npm}
The Loader Script allows you to configure some SDK features from the Sentry UI, without having to redeploy your application. The [Loader Script documentation](/platforms/javascript/install/loader/) shows more information about how to use it.

Alternatively, you can also install the SDK via a package manager:

```bash {tabTitle:npm}
npm install --save @sentry/browser
```

```bash {tabTitle:Yarn}
yarn add @sentry/browser
```

<Note>

We also support alternate [installation methods](/platforms/javascript/install/) such as a CDN and lazy loading.
We also support installation via [CDN bundles](/platforms/javascript/install/loader/#cdn).

</Note>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
```bash
# Using npm
```bash {tabTitle:npm}
npm install --save @sentry/react
```

# Using yarn
```bash {tabTitle:Yarn}
yarn add @sentry/react
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
npm install --save @sentry/remix
```

```bash {tabTitle:yarn}
```bash {tabTitle:Yarn}
yarn add @sentry/remix
```
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
npm install --save @sentry/svelte
```

```bash {tabTitle:yarn}
```bash {tabTitle:Yarn}
yarn add @sentry/svelte
```
9 changes: 5 additions & 4 deletions src/platform-includes/getting-started-install/node.mdx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
```bash
# Using yarn
yarn add @sentry/node
# Using npm
```bash {tabTitle:npm}
npm install --save @sentry/node
```

```bash {tabTitle:Yarn}
yarn add @sentry/node
```
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
```javascript
// If you're using one of our framework SDK packages, like `@sentry/angular`,
// If you're using one of our framework SDK packages, like `@sentry/react`,
// substitute its name for `@sentry/browser` here
import * as Sentry from "@sentry/browser";

Sentry.init({
dsn: "___PUBLIC_DSN___",

// This enables automatic instrumentation (highly recommended), but is not
// necessary for purely manual usage.
// If you only want to use manual instrumentation, remove the BrowserTracing integration and add
// Sentry.addTracingExtensions() above your Sentry.init() call.
// This enables automatic instrumentation (highly recommended),
// but is not necessary for purely manual usage
// If you only want to use manual instrumentation:
// * Remove the `BrowserTracing` integration
// * add `Sentry.addTracingExtensions()` above your Sentry.init() call
integrations: [new Sentry.BrowserTracing()],

// We recommend adjusting this value in production, or using tracesSampler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ Sentry.init({

// This enables automatic instrumentation (highly recommended), but is not
// necessary for purely manual usage.
// If you only want to use manually, remove the BrowserTracing integration and add
// Sentry.addTracingExtensions() above your Sentry.init() call.
// If you only want to use manual instrumentation:
// * Remove the `BrowserTracing` integration
// * add `Sentry.addTracingExtensions()` above your Sentry.init() call
integrations: [new Sentry.BrowserTracing()],

// We recommend adjusting this value in production, or using tracesSampler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@ Sentry.init({
Vue: Vue,
dsn: "___PUBLIC_DSN___",

// This enables automatic instrumentation (highly recommended), but is not
// necessary for purely manual usage
// If you only want to use manually, remove the BrowserTracing integration and add
// Sentry.addTracingExtensions() above your Sentry.init() call.
// This enables automatic instrumentation (highly recommended),
// but is not necessary for purely manual usage
// If you only want to use manual instrumentation:
// * Remove the `BrowserTracing` integration
// * add `Sentry.addTracingExtensions()` above your Sentry.init() call
integrations: [new Sentry.BrowserTracing()],

// We recommend adjusting this value in production, or using tracesSampler
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ To enable tracing, include the `BrowserTracing` integration in your SDK configur
After configuration, you will see both `pageload` and `navigation` transactions in the Sentry UI.

```javascript
// If you're using one of our framework SDK packages, like `@sentry/angular`,
// If you're using one of our framework SDK packages, like `@sentry/react`,
// substitute its name for `@sentry/browser` here
import * as Sentry from "@sentry/browser";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Tracing is included by default in the Sentry JavaScript npm packages.
Tracing is available by default in the Sentry JavaScript npm packages.

If you are using the Loader Script, make sure to enable "Performance" under **Settings > Projects > Client Keys (DSN)**.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ OpenTelemetry support is only supported for server-side instrumentation.
npm install @sentry/nextjs @sentry/opentelemetry-node
```

```bash {tabTitle:yarn}
```bash {tabTitle:Yarn}
yarn add @sentry/nextjs @sentry/opentelemetry-node
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
npm install @sentry/node @sentry/opentelemetry-node
```

```bash {tabTitle:yarn}
```bash {tabTitle:Yarn}
yarn add @sentry/node @sentry/opentelemetry-node
```

Expand Down
Loading