Skip to content

Commit 983a17a

Browse files
committed
rename and reword
1 parent a79d6f6 commit 983a17a

File tree

2 files changed

+19
-8
lines changed

2 files changed

+19
-8
lines changed

docs/platforms/javascript/common/apis.mdx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,8 @@ See <PlatformLink to="/tracing/instrumentation/">Tracing Instrumentation</Platfo
637637
</SdkApi>
638638

639639
<SdkApi
640-
name="setSpanActive"
641-
signature="function setSpanActive(span: Span): void"
640+
name="setActiveSpanInBrowser"
641+
signature="function setActiveSpanInBrowser(span: Span): void"
642642
availableSince="10.14.0"
643643
categorySupported={["browser"]}
644644
parameters={[
@@ -665,7 +665,7 @@ See <PlatformLink to="/tracing/instrumentation/">Tracing Instrumentation</Platfo
665665

666666
on('startCheckout', () => {
667667
checkoutSpan = Sentry.startInactiveSpan({name: 'checkout-flow'});
668-
Sentry.setSpanActive(checkoutSpan);
668+
Sentry.setActiveSpanInBrowser(checkoutSpan);
669669
})
670670

671671
doSomeWork();

docs/platforms/javascript/common/tracing/instrumentation/index.mdx

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,25 +107,36 @@ To add spans that aren't active, you can create independent spans. This is usefu
107107

108108
<PlatformCategorySection supported={['browser']}>
109109

110-
In some cases, you may need to start an inactive span and make it the active span.
111-
In contrast to [startSpanManual](#starting-an-active-span-with-manual-end-startspanmanual), the period for which
112-
the span is active is not bound to the callback. Instead, it will remain active until you manually end the span.
110+
### Setting an inactive span active (browser only)
111+
112+
In browser environments, you might run into use cases, where the callback-based span APIs are not sufficient.
113+
In such cases (see example below), you can use `startInactiveSpan` to start an initially inactive span and then
114+
set it active until you manually end the span.
113115

114116
```javascript
115117
let checkoutSpan;
116118

117119
on('startCheckout', () => {
118120
checkoutSpan = Sentry.startInactiveSpan({name: 'checkout-flow'});
119-
Sentry.setSpanActive(checkoutSpan);
121+
Sentry.setActiveSpanInBrowser(checkoutSpan);
120122
})
121123

122124
doSomeWork();
123125

124126
on('endCheckout', () => {
125-
// Ending the span automatically removes it as the active span on the scope
127+
// Ending the span automatically removes it as the active span
126128
checkoutSpan.end();
127129
})
128130
```
131+
132+
Using `startInactiveSpan` in combination with `setActiveSpanInBrowser` allows you to create an inactive span that can be made active until you manually end it. In contrast, [`startSpanManual`](#starting-an-active-span-with-manual-end-startspanmanual) allows you to end the span manually at any point, but it only remains active within the callback.
133+
134+
<Alert>
135+
136+
Note that `setActiveSpanInBrowser` is only available in browser environments! If you're running code in the server
137+
(for example for server-side rendering), make sure to guard this call to only run in the browser.
138+
139+
</Alert>
129140

130141
</PlatformCategorySection>
131142

0 commit comments

Comments
 (0)