-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
feat(dev-toolbar): Dev Toolbar Docs #12117
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 7 commits
5ce67cf
a60a08a
b00fd13
e1f7980
350e8b4
c74bf31
3cd322f
16c3714
e733a48
f3bce4c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| --- | ||
| title: Dev Toolbar | ||
c298lee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| sidebar_order: 120 | ||
| description: "Bring critical Sentry insights and tools directly into your web app for easier troubleshooting with the Dev Toolbar." | ||
c298lee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| --- | ||
|
|
||
| <Alert level="info"> | ||
| The Dev Toolbar is currently in **beta**. Beta features are still in progress and may have bugs. Please reach out on | ||
| [GitHub](https://github.com/getsentry/sentry-toolbar/issues) if you have any feedback or concerns. | ||
| </Alert> | ||
|
|
||
| Developers spend a lot of time troubleshooting their web apps on local, staging, and production environments. The Sentry Dev Toolbar pulls data from [sentry.io](http://sentry.io) and surfaces relevant, actionable issues to you when you have the most context for understanding it: as you browse your own site. The Dev Toolbar is a floating widget in your web app, offering meaningful Sentry insights for the specific page being viewed through three different **page-aware** panels: Issues, Feedback, and Feature Flags. | ||
|
|
||
|  | ||
c298lee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Issues Panel | ||
|
|
||
| The issues panel shows you your highest priority frontend [issues](https://docs.sentry.io/product/issues/) for the page you are currently viewing. From the Dev Toolbar, you can quickly jump into specific issues in Sentry to get more detailed information (e.g. Sentry project, issue title, and description, and when the issue was first and last seen) and take action (e.g. assign to a team member or mark as resolved). With the issues panel, you can browse the pages that are most important to your business and understand the top issues impacting your user base. | ||
c298lee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|  | ||
|
|
||
| ## Feedback Panel | ||
|
|
||
| The feedback panel shows you the most recent user feedback messages for the page you are on, so you can more easily contextualize user feedback. The feedback often describes suboptimal experiences that are not strictly code-thrown errors, such as misleading UX, broken links, and typos. The feedback panel works by pulling feedback messages from [Sentry’s User Feedback Widget](https://docs.sentry.io/product/user-feedback/#user-feedback-widget). Just like with the Issues panel, clicking on a particular user feedback will take you to the full detailed User Feedback page within Sentry. | ||
c298lee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|  | ||
c298lee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Feature Flags Panel | ||
|
|
||
| Feature flags are a powerful tool that allow you to control the visibility of features in your app, enabling you to ship, test, and experiment with confidence. The feature flag panel allows you to quickly view and override feature flags locally. You can override any feature flag to be `true` or `false` for your browser session, so you can verify its behavior and observe the impact it might have on errors. Learn more about how to [configure the feature flag panel](/product/dev-toolbar/setup/#implement-feature-flag-adapter). | ||
c298lee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
| <Note> | ||
c298lee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| [Learn more](/product/explore/feature-flags/) about what data Sentry can track related to your feature flagging system. | ||
c298lee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| </Note> | ||
c298lee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|
|
||
|  | ||
c298lee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| ## Login Flow | ||
|
|
||
| After setting up the Dev Toolbar you’ll see a “Login to Sentry” button floating in the center of the page. To access any information from your Sentry organization you have to click this button and login to sentry. | ||
c298lee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|  | ||
c298lee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| After clicking the button, you will see a pop up for logging in to Sentry. | ||
c298lee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|  | ||
c298lee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| If it's your first time setting up the Dev Toolbar, there will be a button with a link to Sentry's Dev Toolbar settings page to configure your domain. | ||
|  | ||
c298lee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| You'll need to add your domain URL to Allowed Origins in Sentry on the Settings > Project > Dev Toolbar page. | ||
c298lee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
|  | ||
c298lee marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Learn more about setting up the toolbar, including configuring a feature flag provider and integrating the toolbar in different environments, on the next page. | ||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,150 @@ | ||||||
| --- | ||||||
| title: "Set Up" | ||||||
| sidebar_order: 10 | ||||||
| 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." | ||||||
| --- | ||||||
|
|
||||||
| <Alert level="info"> | ||||||
| The Dev Toolbar is currently in **beta**. Beta features are still in progress and may have bugs. Please reach out on | ||||||
| [GitHub](https://github.com/getsentry/sentry-toolbar/issues) if you have any feedback or concerns. | ||||||
| </Alert> | ||||||
|
|
||||||
| ## Set Up Your Web App | ||||||
|
|
||||||
| <Alert level="warning"> | ||||||
| [Enabling tracing](/platforms/javascript/tracing/) is a prerequisite using the Developer Toolbar. Tracing is used to collect page-specific issues and feedback through transactions. | ||||||
c298lee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| </Alert> | ||||||
|
|
||||||
| You need to complete two steps to get the toolbar rendered on the page: | ||||||
| 1. Add or dynamically inject the following script into your web app: | ||||||
| ```html | ||||||
| <script src="https://browser.sentry-cdn.com/sentry-toolbar/latest/toolbar.min.js"></script> | ||||||
| ``` | ||||||
| It is recommended that you add the script tag at the bottom of the page so it doesn’t block other critical JavaScript. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Since placement is important, can we be a little more specific here? Should it be at the body of the |
||||||
|
|
||||||
| 2. Call `window.SentryToolbar.init(initConfig)` to set up a toolbar instance on each page where you want to see the Dev Toolbar. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This makes it feel like you have to add both to every page instead of just the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @ryan953 I'm not sure how to rewrite so that it's clear that only the init needs to be added to every page. Any ideas?
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Both need to exist together whenever, and can be inserted whenever a full pageload happens. So if we're talking nextjs they can go in the custom Only having |
||||||
| ```html | ||||||
| <html> | ||||||
| <head>...</head> | ||||||
| <body> | ||||||
| … | ||||||
| <script src="https://browser.sentry-cdn.com/sentry-toolbar/latest/toolbar.min.js"></script> | ||||||
| <script> | ||||||
| window.SentryToolbar.init({ … }); | ||||||
| </script> | ||||||
| </body> | ||||||
| </html> | ||||||
| ``` | ||||||
|
|
||||||
| ### Unmounting The Toolbar | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm a little confused by this, why would you want to mount the toolbar and then later unmount it on the same page? Am I misunderstanding this? Is there a brief use case we can provide to illustrate when you would want to do this? |
||||||
|
|
||||||
| 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. | ||||||
| ```html | ||||||
| <script src="https://browser.sentry-cdn.com/sentry-toolbar/latest/toolbar.min.js"></script> | ||||||
| <script> | ||||||
| const unmountToolbar = window.SentryToolbar.init({ … }); | ||||||
|
|
||||||
| // sometime later... | ||||||
| unmountToolbar(); | ||||||
| </script> | ||||||
| ``` | ||||||
|
|
||||||
| ## Init Configuration Fields | ||||||
|
||||||
|
|
||||||
| The following fields can be passed into the `.init()` function. | ||||||
c298lee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| At minimum, you should be calling `.init()` with these three fields: | ||||||
c298lee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| ```javascript | ||||||
| window.SentryToolbar.init({ | ||||||
| organizationSlug: 'acme', | ||||||
| projectIdOrSlug: 'website', | ||||||
| environment: 'production' | ||||||
| }); | ||||||
| ``` | ||||||
| And you can include any additional fields from this list: | ||||||
c298lee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| | Field Name | Type | Description | Default Value | | ||||||
c298lee marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
| | ----- | ----- | ----- | ----- | | ||||||
| | `organizationSlug` | `string` | The organization that users should login to. For example \'acme\' | *Required Value* | | ||||||
| | `projectIdOrSlug` | `string \| number` | The project for which this website/webapp is associated. | *Required Value* | | ||||||
| | `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` | | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Do we need to share all the different ways to set this to see results for all environments here('undefined', '""', or '[]')? It would simplify things if we just picked one. |
||||||
| | `placement (optional)` | `'right-edge' \| 'bottom-right-corner'` | Where to render the toolbar on the screen. | `'right-edge'` | | ||||||
| | `theme (optional)` | `'system' \| 'dark' \| 'light'` | Whether to use dark or light mode. | `'system'` | | ||||||
| | `featureFlags (optional)` | `FeatureFlagAdapter \| undefined` | See [Implement FeatureFlagAdapter](/product/dev-toolbar/setup//#implement-feature-flag-adapter) below | `undefined` | | ||||||
| | `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'` | | ||||||
| | `domId (optional)` | `string \| undefined` | The `id` given to the \<div\> that is created to contain the toolbar html. | `'sentry-toolbar'` | | ||||||
| | `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` | | ||||||
| | `mountPoint (optional)` | `HTMLElement \| () => HTMLElement \| undefined` | Where to mount the toolbar in the DOM. | `document.body` | | ||||||
|
|
||||||
| ## Implement Feature Flag Adapter | ||||||
|
|
||||||
| 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. | ||||||
|
|
||||||
| We plan to [create adapters for OpenFeature and LaunchDarkly](https://github.com/getsentry/sentry-toolbar/issues/150) soon. | ||||||
|
|
||||||
| The adapter interface is: | ||||||
| ```javascript | ||||||
| type FlagValue = boolean | string | number | undefined; | ||||||
| type FlagMap = Record<string, FlagValue>; | ||||||
| interface FeatureFlagAdapter { | ||||||
| /** | ||||||
| * All known flag names and their evaluated values. | ||||||
| */ | ||||||
| getFlagMap: () => Promise<FlagMap>; | ||||||
|
|
||||||
| /** | ||||||
| * Any overridden or manually set flags and values. | ||||||
| */ | ||||||
| getOverrides: () => Promise<FlagMap>; | ||||||
|
|
||||||
| /** | ||||||
| * Manually set a flag to be a specific value, overriding the evaluated value. | ||||||
| */ | ||||||
| setOverride: (name: string, override: FlagValue) => void; | ||||||
|
|
||||||
| /** | ||||||
| * A callback to clear all overrides from this browser. | ||||||
| */ | ||||||
| clearOverrides: () => void; | ||||||
|
|
||||||
| /** | ||||||
| * Deeplink into your external feature-flag provider and find out more about | ||||||
| * this specific flag. | ||||||
| */ | ||||||
| urlTemplate?: undefined | ((name: string) => string | URL | undefined); | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| [MockFeatureFlagIntegration.tsx](https://github.com/getsentry/sentry-toolbar/blob/301c31d561a81e3fd8ffc9532aad3a60af685916/src/env/demo/MockFeatureFlagIntegration.tsx) is an example adapter to use as a reference. | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This feels like it needs to be above the interface but I can't think of how I would word it. |
||||||
|
|
||||||
|
|
||||||
| ## Deploying To Dev, Staging, and Production Environments | ||||||
| Since the Dev Toolbar is deployed onto specific pages, it's strongly recommended that you consider which environments the toolbar should apply to. | ||||||
|
|
||||||
| 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 however, 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. | ||||||
|
|
||||||
| 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. | ||||||
|
|
||||||
|
|
||||||
| The code might look like this: | ||||||
| ```javascript | ||||||
| // example conditions to render the toolbar in different environments. | ||||||
|
|
||||||
| const env = process.env.SENTRY_ENVIRONMENT || 'development'; | ||||||
| const isEmployee = user.email.endsWith('@joshys-pizza.com') | ||||||
|
|
||||||
| const isDev = env === 'development' || env === 'staging'; | ||||||
| const isEmployeeInProd = env === 'production' && isEmployee; | ||||||
| if (isDev || isEmployeeInProd) { | ||||||
| SentryToolbar.init({ ... }); | ||||||
| } | ||||||
| ``` | ||||||
|
|
||||||
| 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. | ||||||
|
|
||||||
| ## Conditionally Inserting Script Tag | ||||||
|
|
||||||
| 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. | ||||||
| This example code will be eventually implemented as an NPM package, but for now it can be done manually. | ||||||
Uh oh!
There was an error while loading. Please reload this page.