You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
description: "Get started with Sentry's Dev Toolbar, bringing critical Sentry insights and tools into your web app to help your team troubleshoot more effectively."
5
5
---
@@ -9,50 +9,84 @@ description: "Get started with Sentry's Dev Toolbar, bringing critical Sentry in
9
9
[GitHub](https://github.com/getsentry/sentry-toolbar/issues) if you have any feedback or concerns.
10
10
</Alert>
11
11
12
-
## Set Up Your Web App
12
+
## Pre-Requisites
13
13
14
-
<Alertlevel="warning">
15
-
[Enabling tracing](/platforms/javascript/tracing/) is a prerequisite to using the Dev Toolbar. Tracing is used to collect page-specific issues and feedback through transactions.
16
-
</Alert>
14
+
For the Sentry Dev Toolbar to work best, [enable tracing](/platforms/javascript/tracing/) in your app. With tracing enabled, the Dev Toolbar will be able to associate issues and feedback with the current URL in the browser location.
17
15
18
-
You need to complete two steps to get the toolbar rendered on the page:
19
-
1. Add or dynamically inject the following script into your web app:
It is recommended that you add the script tag at the bottom of the page so it doesn’t block other critical JavaScript.
24
-
25
-
2. Call `window.SentryToolbar.init(initConfig)` to set up a toolbar instance on each page where you want to see the Dev Toolbar. Take care to also [conditionally load the toolbar in your production environment](#deploying-to-production-environments).
3. Edit [Project Settings](https://sentry.io/orgredirect/organizations/:orgslug/settings/projects/) in Sentry so the Toolbar is allowed to connect from your dev, staging, and production domains.
40
-

41
-
42
-
43
-
### Unmounting The Toolbar
44
-
45
-
If you have called `SentryToolbar.init({...})` to render the toolbar, but now want to manually remove or unmount it from the page, you can call the cleanup function that is returned from `init()`. This will unmount all the injected HTML and CSS. Login credentials will not be removed, so you can re-insert the toolbar and still be authenticated.
Since the Dev Toolbar will be visible to users within your app, it's important to consider which environments should render it.
19
+
20
+
In dev and staging environments, include the Toolbar so that all developers and testers can use it and quickly go from the page they're looking at back to Sentry for further debugging.
21
+
22
+
In production environments, the Dev Toolbar can make it easier to reproduce real issues your users are having. However the Toolbar should not be rendered for all users of the site -- only when an employee/engineer/etc visits.
23
+
24
+
Once you decide where and when you want the Toolbar to appear, you'll write those conditions into your codebase. The specific implementation is something you'll need to write based on how your app works and how your dev team is set up.
25
+
26
+
For example, the conditions to show show the Toolbar in dev and staging might look like this:
Or if your web application requires authentication to access, you could add a conditional where the Dev Toolbar is shown always when deployed to development **and** staging, but in production only show the Toolbar **if** an employee is logged in.
38
+
39
+
## 2. Allow Domains
40
+
41
+
You will need to edit the [Project Settings](https://sentry.io/orgredirect/organizations/:orgslug/settings/projects/) page to allow the Toolbar to connect to Sentry by configuring your dev, staging, and production domains. Only add domains that you trust and control to this list.
42
+
43
+

44
+
45
+
## 3. Install
54
46
55
-
The following options can be passed into the `.init()` function.
47
+
Next you must include the Toolbar code in your app:
Remember to conditionally include the Toolbar code only in environments that need it. This will help reduce network traffic for your users who do not have the credentials needed to login.
63
+
64
+
## 4. Configure
65
+
66
+
Finally, call `SentryToolbar.init(initConfig)` to render a Toolbar instance on each page where you want to see the Dev Toolbar. This will prompt any visitor to the page to login to your Sentry organization.
If the toolbar `<script>` is included on your site, and `SentryToolbar.init()` is called, then a "Login to Sentry" button will be visible to the public. This is not ideal, but your data in Sentry will still be safe as users outside of your Sentry organization will not be able to login.
87
+
88
+
89
+
### Init Configuration Options
56
90
57
91
At minimum, you should be calling `.init()` with these two options:
58
92
```javascript
@@ -61,29 +95,78 @@ window.SentryToolbar.init({
61
95
projectIdOrSlug:'website',
62
96
});
63
97
```
64
-
And you can include any additional options from this list:
98
+
99
+
And you can also include any additional options from this list:
65
100
66
101
| Option | Type | Description | Default Value |
67
102
| ----- | ----- | ----- | ----- |
68
103
|`organizationSlug`|`string`| The organization that users should login to. For example \'acme\'|*Required Value*|
69
104
|`projectIdOrSlug`|`string \| number`| The project for which this website/webapp is associated. |*Required Value*|
70
105
|`environment (optional)`|`string \| string[] \| undefined`| The environment of this deployment. Used to narrow search results in the Toolbar UI. Set to `undefined` or `""` or `[]` if you want to see results from all environments. |`undefined`|
71
-
|`placement (optional)`|`'right-edge' \| 'bottom-right-corner'`| Where to render the toolbar on the screen. |`'right-edge'`|
106
+
|`placement (optional)`|`'right-edge' \| 'bottom-right-corner'`| Where to render the Toolbar on the screen. |`'right-edge'`|
72
107
|`theme (optional)`|`'system' \| 'dark' \| 'light'`| Whether to use dark or light mode. |`'system'`|
73
-
|`featureFlags (optional)`|`FeatureFlagAdapter \| undefined`| See [Implement FeatureFlagAdapter](/product/dev-toolbar/setup//#implement-feature-flag-adapter) below |`undefined`|
108
+
|`featureFlags (optional)`|`FeatureFlagAdapter \| undefined`| See [Feature Flag Panel](/product/dev-toolbar/setup//#feature-flag-Panel) below |`undefined`|
74
109
|`sentryOrigin (optional)`|`string \| undefined`| The origin where Sentry can be found. Used for loading the connection to Sentry, and generating links to the website. For example: `'https://acme.sentry.io'`|`'https://sentry.io'`|
75
-
|`domId (optional)`|`string \| undefined`| The `id` given to the \<div\> that is created to contain the toolbar html. |`'sentry-toolbar'`|
110
+
|`domId (optional)`|`string \| undefined`| The `id` given to the \<div\> that is created to contain the Toolbar html. |`'sentry-toolbar'`|
76
111
|`debug (optional)`|`string \| undefined`| A comma separated string of debug targets to enable. Example: `'logging,state'`. If the list contains 'all' or 'true' then all targets will be enabled. Valid targets: `'logging' 'login-success' 'settings' 'state'`|`undefined`|
77
-
|`mountPoint (optional)`|`HTMLElement \| () => HTMLElement \| undefined`| Where to mount the toolbar in the DOM. |`document.body`|
112
+
|`mountPoint (optional)`|`HTMLElement \| () => HTMLElement \| undefined`| Where to mount the Toolbar in the DOM. |`document.body`|
113
+
114
+
### Unmounting the Toolbar
115
+
116
+
If you have called `SentryToolbar.init({...})` to render the Toolbar, but now want to manually remove or unmount it from the page, you can call the cleanup function that is returned from `init()`. This will unmount all the injected HTML and CSS. Login credentials will not be removed, so you can re-insert the toolbar and still be authenticated.
If you're using feature flags inside your product then also setup [Feature Flag Evaluation and Change Tracking](/platforms/javascript/feature-flags/) within your SDK.
128
+
</Alert>
129
+
130
+
In order to integrate your feature flagging platform with the Dev Toolbar, you will need an adapter that can read flag data from your provider. It will also store and retrieve a list of overrides to apply to your local browser session.
131
+
132
+
There is a built-in `OpenFeatureAdapter` that is compatible with the [open-feature/js-sdk-contrib](https://github.com/open-feature/js-sdk-contrib). To use it, call the `SentryToolbar.OpenFeatureAdapter` implementation.
133
+
134
+
```html {tabTitle: CDN}
135
+
<script>
136
+
// Define your provider
137
+
constprovider=newFlagdWebProvider({...});
80
138
81
-
In order to integrate your feature flagging platform with the Dev Toolbar, you will need an adapter that can read flag data from your provider, and also store and retrieve a list of overrides to apply to your local browser session.
139
+
// Set the provider into the OpenFeature SDK
140
+
OpenFeature.setProvider(provider);
82
141
83
-
We plan to [create adapters for OpenFeature and LaunchDarkly](https://github.com/getsentry/sentry-toolbar/issues/150) soon.
You can also create your own adapter by implementing the [`FeatureFlagAdapter` interface](https://github.com/getsentry/sentry-toolbar/blob/main/src/lib/types/featureFlags.ts).
[MockFeatureFlagAdapter.tsx](https://github.com/getsentry/sentry-toolbar/blob/main/src/env/demo/MockFeatureFlagAdapter.tsx) is an example adapter to use as a reference.
119
-
120
-
121
-
## Deploying To Dev and Staging Environments
122
-
Since the Dev Toolbar is deployed onto specific pages, it's strongly recommended that you consider which environments the toolbar should apply to.
123
-
124
-
In dev and staging environments, you might want to *unconditionally* include the toolbar so that all developers and testers can use it and quickly go from the page they're looking at back to Sentry for further debugging.
In production, it's strongly recommended to *conditionally* include the Dev Toolbar `<script>` tag so that only members of your Sentry organization can see it. The specific implementation for conditionally including the Dev Toolbar is something you'll need to write based on how your app works and how your dev team is set up.
139
-
140
-
For example, if your web application requires authentication to access, you could add a conditional where the Dev Toolbar is shown always when deployed to development **and** staging, but in production only show the toolbar **if** an employee is logged in.
141
-
142
-
If the toolbar `<script>` is accidentally included on your site, and `SentryToolbar.init()` is called, then a "Login to Sentry" button will be visible to the public. This is not ideal, but your data in Sentry will still be safe as users outside of your Sentry organization will not be able to authenticate themselves.
143
-
144
-
## Conditionally Inserting Script Tag
145
-
146
-
It's possible to dynamically insert the script tag inside a single-page app, prior to calling `SentryToolbar.init()`, so that it’s only visible to authorized users. See [`docs/conditional-script.md`](https://github.com/getsentry/sentry-toolbar/blob/main/docs/conditional-script.md) for example code. This will help reduce network traffic for your users because they do not have the credentials needed to login.
147
-
This example code will be eventually implemented as an NPM package, but for now it can be done manually.
0 commit comments