npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@amplitude/storybook-addon-amplitude

v3.0.0

Published

A storybook addon to capture events in Amplitude

Readme

storybook-addon-amplitude

A Storybook addon to capture events in Amplitude.

version MIT License Auto Release PRs Welcome All Contributors

Read the blog post here.

Prerequisites

  • Node.js 20 or higher
  • Storybook 9.0 or higher
  • An Amplitude account (free tier available)

Version Compatibility

| Storybook Version | Addon Version | | ----------------- | ------------- | | 9.x | 3.x | | 8.x | >= 2.1.0 | | 7.x | 2.0.0-2.0.1 | | 6.x | 1.x |

What does it do?

The Amplitude Storybook addon emits events to Amplitude on two different occasions: when a user navigates to a new page and when a user changes a story's args.

Getting Started

The first thing you'll need to do is sign up for Amplitude. If you already have an account, great! If you don't, you can sign up here for free.

Once you have an account, you can create a new project which will have an associated API key.

Note: You may want to create both a prod project and a dev project so you can test without influencing your data

To do this, navigate to the Settings page.

Amplitude organization settings nav

Then, select Projects in the sidebar.

Amplitude projects nav

In the top right-hand corner, click the Create Project button and follow the instructions.

Amplitude create new project

Next, install the package as a devDependency in your project:

# Using yarn
yarn add @amplitude/storybook-addon-amplitude --dev

# Using npm
npm install @amplitude/storybook-addon-amplitude --save-dev

in storybook/main.js

module.exports: {
  addons: [
+   '@amplitude/storybook-addon-amplitude',
  ]
}

Then, set your Amplitude API keys in ./storybook/manager.js

window.AMPLITUDE_DEV_API_KEY = "<amplitude-dev-api-key>";
window.AMPLITUDE_PROD_API_KEY = "<amplitude-prod-api-key>";

If you want to post to the EU endpoint make sure to set the serverUrl option:

window.AMPLITUDE_OPTIONS = {
  serverUrl: "https://api.eu.amplitude.com/2/httpapi",
};

Read more: Configurations, Endpoints

If you are in a TypeScript project you might want to add the following declarations:

declare global {
  interface Window {
    AMPLITUDE_DEV_API_KEY: string;
    AMPLITUDE_PROD_API_KEY: string;
    AMPLITUDE_OPTIONS: {
      serverUrl?: string;
    };
  }
}

Now your Storybook will begin emitting events to your project in Amplitude. You're ready to start creating charts in Amplitude!

Example Charts

Weekly unique users viewing Storybook documentation

Amplitude weekly unique users chart

Most commonly referenced categories

Amplitude referenced categories chart

Most viewed components

Amplitude most viewed components chart

Components with most modified arguments

Amplitude most modified arguments chart

Event Taxonomy

User navigates to a new page

When a user switches to a new page, this addon emits an event to Amplitude that looks like this:

{
  event_type: "viewed documentation",
  event_properties: {
    category: "actions",
    page: "button"
  }
}

Tracking the event in this way allows you to build charts in Amplitude to show:

  1. How many people have viewed your Storybook over time
  2. What categories people are viewing most frequently
  3. What pages people are viewing most frequently

User changes a story's args

When a user changes a story's args, this addon emits an event that looks like this:

{
  event_type: "updated story args",
  event_properties: {
    category: "actions",
    page: "button"
  }
}

Tracking the event in this way allows you to build charts in Amplitude to answer:

  1. How often do people use the story args functionality?
  2. In which category of pages people update the story args most frequently?
  3. On which pages people update the story args most frequently?

Troubleshooting

Events not showing up in Amplitude?

  • Verify your API keys are correctly set in storybook/manager.ts
  • Set window.AMPLITUDE_OPTIONS = { logLevel: 4 }; in storybook/manager.ts and check your browser's console for any error messages
  • Ensure you're using the correct server URL for your region

Storybook not loading?

  • Make sure the addon is properly installed and configured in storybook/main.ts
  • Check that your Storybook version is compatible (9.0 or higher)

Contributing

We are always happy to receive contributions! Please refer to our CONTRIBUTING guidelines for more details.

License

This project is licensed under the MIT License - see the LICENSE file for details.

Credits

Owner: Amplitude Inc

Current Maintainer: Jimmy Wilson (@jimmynotjim)

Contributors:

This project follows the all-contributors specification. Contributions of any kind welcome!