Skip to content

Commit 24e34b8

Browse files
authored
docs(js): Use client from init method in js snippets (#10460)
1 parent 5c014d9 commit 24e34b8

File tree

2 files changed

+2
-5
lines changed

2 files changed

+2
-5
lines changed

platform-includes/performance/automatic-instrumentation-custom-routing/javascript.mdx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ By default, the `browserTracingIntegration()` will create a `pageload` span for
55
To make sure that spans are created correctly for a custom routing setup, you'll need to opt out of the default span creation by setting `instrumentNavigation: false` and `instrumentPageLoad: false` in the `browserTracingIntegration()` options. You can then manually create spans like this:
66

77
```javascript
8-
Sentry.init({
8+
const client = Sentry.init({
99
integrations: [
1010
Sentry.browserTracingIntegration({
1111
// disable automatic span creation
@@ -15,8 +15,6 @@ Sentry.init({
1515
],
1616
});
1717

18-
const client = Sentry.getClient()
19-
2018
// We start the pageload span as early as possible!
2119
let pageLoadSpan = Sentry.startBrowserTracingPageLoadSpan(client, {
2220
name: window.location.pathname,

platform-includes/performance/opentelemetry-setup/javascript.node.mdx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,15 +33,14 @@ function setupSentry() {
3333
setupGlobalHub();
3434

3535
// Make sure to call `Sentry.init` BEFORE initializing the OpenTelemetry SDK
36-
Sentry.init({
36+
const client = Sentry.init({
3737
dsn: "___PUBLIC_DSN___",
3838
tracesSampleRate: 1.0,
3939
// set the instrumenter to use OpenTelemetry instead of Sentry
4040
instrumenter: "otel",
4141
// ...
4242
});
4343

44-
const client = getClient();
4544
setupEventContextTrace(client);
4645

4746
// You can wrap whatever local storage context manager you want to use

0 commit comments

Comments
 (0)