Component names
This page documents the Bugsee JavaScript SDK, which is in beta (0.1.x) and can change between betas.
Minification renames your components, so a click or an error that happens inside UserCard can end up attributed to something like t or e. The component name plugins fix that at build time. They label the DOM elements a component renders with the component's name, in a data-bugsee-component attribute. Bugsee reads that attribute in the browser to attribute clicks and errors to the component, even in a minified build.
The plugins are optional and have nothing to do with source maps. Without them, everything is still captured and your stack traces are still readable once you upload source maps. They only add the component name.
| Framework | How | Package |
|---|---|---|
| React, Preact, Solid | A Babel plugin with no options. Needs @babel/core 7. | @bugsee/babel-plugin-component-annotate |
| Svelte, SvelteKit | A Svelte preprocessor. Needs svelte 4 or newer. | @bugsee/svelte-plugin-component-annotate |
| Vue | A runtime mixin, not a build plugin. | Included in @bugsee/vue |
React, Preact and Solid
Install the plugin as a development dependency:
npm install --save-dev @bugsee/babel-plugin-component-annotate
Add it to your Babel configuration:
module.exports = {
plugins: [['@bugsee/babel-plugin-component-annotate']],
};
The plugin adds data-bugsee-component="<ComponentName>" to each host element, such as a <button> or <div>, that a PascalCase function or class component renders. It does not annotate component elements.
If you build with Vite and @vitejs/plugin-react, pass the plugin through that plugin's Babel option. For Solid, use vite-plugin-solid's Babel option.
Svelte and SvelteKit
Install the preprocessor as a development dependency:
npm install --save-dev @bugsee/svelte-plugin-component-annotate
Add it to the preprocess list in svelte.config.js:
import { componentAnnotatePreprocessor } from '@bugsee/svelte-plugin-component-annotate';
export default {
preprocess: [componentAnnotatePreprocessor()],
};
On SvelteKit 3 there is no svelte.config.js. Pass preprocess to the sveltekit() Vite plugin instead:
import { componentAnnotatePreprocessor } from '@bugsee/svelte-plugin-component-annotate';
import { sveltekit } from '@sveltejs/kit/vite';
export default {
plugins: [sveltekit({ preprocess: [componentAnnotatePreprocessor()] })],
};
The name comes from the file name, so UserCard.svelte becomes UserCard. For index.svelte and SvelteKit route files, the folder name is used.
| Option | Type | Default | Description |
|---|---|---|---|
renderSpans | boolean | false | Also record a render span for each component's initialization in your performance data. Needs @bugsee/svelte. |
Vue
Vue does not need a build plugin. Register the component mixin that @bugsee/vue provides; see Vue.
Related pages
- React, Solid, Svelte and Vue — the framework setup pages
- Symbolication overview — readable stack traces, which is a separate step