Skip to content

Commit

Permalink
feat: Use new Sentry.addIntegration() (#8247)
Browse files Browse the repository at this point in the history
  • Loading branch information
mydea authored Oct 16, 2023
1 parent ff253fa commit eee9771
Show file tree
Hide file tree
Showing 17 changed files with 32 additions and 45 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ For example:

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

Alternatively, you can add integrations lazily via `client.addIntegration()`.
Alternatively, you can add integrations lazily via `Sentry.addIntegration()`.
This is useful if you only want to enable an integration in a specific environment or if you want to lazy-load an integration.
For all other cases, we recommend you use the `integrations` option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,7 @@ Sentry.init({
integrations: [],
});

const client = Sentry.getCurrentHub().getClient();
if (client) {
client.addIntegration(new ReportingObserver());
}
Sentry.addIntegration(new ReportingObserver());
```

```html {tabTitle: Loader}
Expand All @@ -31,10 +28,7 @@ if (client) {
integrations: [],
});
const client = Sentry.getCurrentHub().getClient();
if (client) {
client.addIntegration(new Sentry.Integrations.ReportingObserver());
}
Sentry.addIntegration(new Sentry.Integrations.ReportingObserver());
});
</script>
```
Expand All @@ -57,9 +51,6 @@ if (client) {
integrations: [],
});
const client = Sentry.getCurrentHub().getClient();
if (client) {
client.addIntegration(new Sentry.Integrations.ReportingObserver());
}
Sentry.addIntegration(new Sentry.Integrations.ReportingObserver());
</script>
```
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,5 @@ Sentry.init({
integrations: [],
});

const client = Sentry.getCurrentHub().getClient();
if (client) {
client.addIntegration(new DedupeIntegration());
}
Sentry.addIntegration(new DedupeIntegration());
```
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ Sentry.init({
});

// Sometime later
const { getCurrentHub, Replay } = await import("@sentry/angular-ivy");
getCurrentHub().getClient().addIntegration(new Replay());
const { Replay } = await import("@sentry/angular-ivy");
Sentry.addIntegration(new Replay());
```
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,5 @@ Sentry.init({

// Sometime later
const { Replay } = await import("@sentry/electron/renderer");
getCurrentHub().getClient().addIntegration(new Replay());
Sentry.addIntegration(new Replay());
```
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ Sentry.init({
});

// Sometime later
const { getCurrentHub, Replay } = await import("@sentry/ember");
getCurrentHub().getClient().addIntegration(new Replay());
const { Replay } = await import("@sentry/ember");
Sentry.addIntegration(new Replay());
```
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ Sentry.init({
});

// Sometime later
const { getCurrentHub, Replay } = await import("@sentry/gatsby");
getCurrentHub().getClient().addIntegration(new Replay());
const { Replay } = await import("@sentry/gatsby");
Sentry.addIntegration(new Replay());
```
4 changes: 2 additions & 2 deletions src/platform-includes/session-replay/setup/javascript.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,6 @@ Sentry.init({
});

// Sometime later
const { getCurrentHub, Replay } = await import("@sentry/browser");
getCurrentHub().getClient().addIntegration(new Replay());
const { Replay } = await import("@sentry/browser");
Sentry.addIntegration(new Replay());
```
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ Sentry.init({
});

// Sometime later
const { getCurrentHub, Replay } = await import("@sentry/nextjs");
getCurrentHub().getClient().addIntegration(new Replay());
const { Replay } = await import("@sentry/nextjs");
Sentry.addIntegration(new Replay());
```
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ Sentry.init({
});

// Sometime later
const { getCurrentHub, Replay } = await import("@sentry/react");
getCurrentHub().getClient().addIntegration(new Replay());
const { Replay } = await import("@sentry/react");
Sentry.addIntegration(new Replay());
```
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ Sentry.init({
});

// Sometime later
const { getCurrentHub, Replay } = await import("@sentry/remix");
getCurrentHub().getClient().addIntegration(new Replay());
const { Replay } = await import("@sentry/remix");
Sentry.addIntegration(new Replay());
```
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ Sentry.init({
});

// Sometime later
const { getCurrentHub, Replay } = await import("@sentry/svelte");
getCurrentHub().getClient().addIntegration(new Replay());
const { Replay } = await import("@sentry/svelte");
Sentry.addIntegration(new Replay());
```
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,6 @@ Sentry.init({
});

// Sometime later
const { getCurrentHub, Replay } = await import("@sentry/sveltekit");
getCurrentHub().getClient().addIntegration(new Replay());
const { Replay } = await import("@sentry/sveltekit");
Sentry.addIntegration(new Replay());
```
4 changes: 2 additions & 2 deletions src/platform-includes/session-replay/setup/javascript.vue.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ Sentry.init({
});

// Sometime later
const { getCurrentHub, Replay } = await import("@sentry/vue");
getCurrentHub().getClient().addIntegration(new Replay());
const { Replay } = await import("@sentry/vue");
Sentry.addIntegration(new Replay());
```
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ You can add additional integrations in your `init` call:

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

Alternatively, you can add integrations lazily via `client.addIntegration()`.
Alternatively, you can add integrations lazily via `Sentry.addIntegration()`.
This is useful if you only want to enable an integration in a specific environment or if you want to lazy-load an integration.
For all other cases, we recommend you use the `integrations` option.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ Sentry.init({
});

// You can access the active replay instance from anywhere in your code like this:
const client = Sentry.getCurrentHub().getClient();
const replay = client?.getIntegration(Sentry.Replay);
const replay = Sentry.getCurrentHub().getIntegration(Sentry.Replay);

// This starts in `session` mode, regardless of sample rates
replay.start();
Expand Down
8 changes: 4 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2558,10 +2558,10 @@
dependencies:
dequal "^2.0.2"

"@sentry-internal/global-search@^0.5.7":
version "0.5.7"
resolved "https://registry.yarnpkg.com/@sentry-internal/global-search/-/global-search-0.5.7.tgz#2749d24b01123b5d92f6326a33c5d4c81ec8c239"
integrity sha512-+fN8bsdXqo0nqppNR2JvZ5acEDKhVA/uCsE0jvLNcGqQgbr6JREbTje/nCCZNgoDwJ+BoTROALKIx/YBlhdp7g==
"@sentry-internal/global-search@^0.5.8":
version "0.5.8"
resolved "https://registry.yarnpkg.com/@sentry-internal/global-search/-/global-search-0.5.8.tgz#440f830be09f6bd7ca626422b1e49aae29822234"
integrity sha512-wG/w1N6qNEzg8Vj310+H7hL8bpSyB2C6DVMTtI4sxK69Jdk+KdAY07mqkYEP2BLgMdA2zO/3VpZs4qZqMz9a/A==
dependencies:
"@types/react" ">=16"
"@types/react-dom" ">=16"
Expand Down

1 comment on commit eee9771

@vercel
Copy link

@vercel vercel bot commented on eee9771 Oct 16, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

sentry-docs – ./

sentry-docs-git-master.sentry.dev
docs.sentry.io
sentry-docs.sentry.dev

Please sign in to comment.