Skip to content

Commit e655ac6

Browse files
authored
fix(js): Fix span status example (#15065)
This snippet was incorrect. Closes getsentry/sentry-javascript#17808 <!-- CURSOR_SUMMARY --> --- > [!NOTE] > Corrects the `span.setStatus` example to use the `code` property instead of `status` in JavaScript tracing docs. > > - **Docs (JavaScript tracing)**: > - Correct `span.setStatus` example to use `{ code: 2 }` instead of `{ status: 2 }` in `docs/platforms/javascript/common/tracing/instrumentation/index.mdx`. > > <sup>Written by [Cursor Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit 6a5896e. This will update automatically on new commits. Configure [here](https://cursor.com/dashboard?tab=bugbot).</sup> <!-- /CURSOR_SUMMARY -->
1 parent 6a0c037 commit e655ac6

File tree

1 file changed

+11
-11
lines changed
  • docs/platforms/javascript/common/tracing/instrumentation

1 file changed

+11
-11
lines changed

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -108,36 +108,36 @@ To add spans that aren't active, you can create independent spans. This is usefu
108108
<PlatformCategorySection supported={['browser']}>
109109

110110
### Setting an inactive span active (browser only)
111-
111+
112112
_Available Since: `10.15.0`_
113-
113+
114114
In browser environments, you might run into use cases, where the callback-based span APIs are not sufficient.
115-
In such cases (see example below), you can use `startInactiveSpan` to start an initially inactive span and then
115+
In such cases (see example below), you can use `startInactiveSpan` to start an initially inactive span and then
116116
set it active until you manually end the span.
117117

118118
```javascript
119119
let checkoutSpan;
120-
120+
121121
on('startCheckout', () => {
122122
checkoutSpan = Sentry.startInactiveSpan({name: 'checkout-flow'});
123123
Sentry.setActiveSpanInBrowser(checkoutSpan);
124124
})
125-
125+
126126
doSomeWork();
127-
127+
128128
on('endCheckout', () => {
129129
// Ending the span automatically removes it as the active span
130130
checkoutSpan.end();
131131
})
132132
```
133-
133+
134134
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.
135-
135+
136136
<Alert>
137-
137+
138138
Note that `setActiveSpanInBrowser` is only available in browser environments! If you're running code in the server
139139
(for example for server-side rendering), make sure to guard this call to only run in the browser.
140-
140+
141141
</Alert>
142142

143143
</PlatformCategorySection>
@@ -260,7 +260,7 @@ By default, spans will have an `unknown` status. You can manually update the sta
260260
// 0: unknown
261261
// 1: ok
262262
// 2: error
263-
span.setStatus({ status: 2 });
263+
span.setStatus({ code: 2 });
264264
```
265265

266266
Alternatively, you can also use the <PlatformLink to='/apis/#setHttpStatus'>`Sentry.setHttpStatus()`</PlatformLink> utility function to set a more specific error status.

0 commit comments

Comments
 (0)