Skip to content
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
15 changes: 15 additions & 0 deletions src/includes/platforms/configuration/integrations/plugin.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -107,3 +107,18 @@ Available options:
<PlatformContent includePath="configuration/reporting-observer" />

</PlatformSection>

<PlatformSection supported={["javascript"]}>

### ContextLines

_Import name: `Sentry.Integrations.ContextLines`_

This integration adds source code from inline JavaScript of the current page's HTML (e.g. JS in `<script>` tags) to stack traces of captured errors.
It _can't_ collect source code from assets referenced by your HTML (e.g. `<script src="..." />`).

The `ContextLines` integration is useful when you have inline JS code in HTML pages that can't be accessed by Sentry's backend, for example, due to a login-protected page.

<PlatformContent includePath="configuration/contextlines" />

</PlatformSection>
69 changes: 69 additions & 0 deletions src/platform-includes/configuration/contextlines/javascript.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
<SignInNote />

```javascript {tabTitle: ESM}
import * as Sentry from "@sentry/browser";
import { ContextLines } from "@sentry/integrations";

Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [
new ContextLines({
// The number of lines to collect around each stack frame's line number
// Defaults to 7
frameContextLines: 7,
}),
],
});
```

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

<script>
Sentry.onLoad(function () {
Sentry.init({
integrations: [
new Sentry.Integrations.ContextLines({
// The number of lines to collect before and after each stack frame's line number
// Defaults to 7
frameContextLines: 7,
}),
],
});
});
</script>
```

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

<script>
Sentry.init({
dsn: "___PUBLIC_DSN___",
integrations: [
new Sentry.Integrations.ContextLines({
// The number of lines to collect around each stack frame's line number
// Defaults to 7
frameContextLines: 7,
}),
],
});
</script>
```