Skip to content

Instantly share code, notes, and snippets.

@doubleedesign
Created December 30, 2024 09:32
Show Gist options
  • Save doubleedesign/250f05d3014e36da372771e185d996b0 to your computer and use it in GitHub Desktop.
Save doubleedesign/250f05d3014e36da372771e185d996b0 to your computer and use it in GitHub Desktop.
Log all Storybook events to the browser console for debugging
import { addons } from '@storybook/manager-api';
import events from '@storybook/core-events';
addons.register('my-manager-addon', () => {
const channel = addons.getChannel();
Object.values(events).forEach((event) => {
channel.on(event, (data) => {
console.log(event, data);
});
});
//...addon code as applicable
});
import { addons } from '@storybook/preview-api';
import events from '@storybook/core-events';
const channel = addons.getChannel();
Object.values(events).forEach((event) => {
channel.on(event, (data) => {
console.log(event, data);
});
});
@doubleedesign
Copy link
Author

Note: You don't need both of these at the same time, they are two separate options.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment