# storybook-amplitude

> Storybook Addon for Amplitude

Latest version **0.1.2** (published 2020-02-10) · MIT license · 0 weekly downloads

## Install

```sh
npm install storybook-amplitude
pnpm add storybook-amplitude
yarn add storybook-amplitude
bun add storybook-amplitude
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2020-02-10 |
| First published | 2020-01-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 8.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | QuintoAndar |
| Maintainers | cherrylipstick |
| Keywords | addon, storybook, amplitude |

## Links

- npm: https://www.npmjs.com/package/storybook-amplitude
- npm.io page: https://npm.io/package/storybook-amplitude

## Dependencies (4)

- [global](https://npm.io/package/global.md) ^4.4.0
- [amplitude-js](https://npm.io/package/amplitude-js.md) ^5.8.0
- [@storybook/addons](https://npm.io/package/@storybook/addons.md) ^5.2.8
- [@storybook/core-events](https://npm.io/package/@storybook/core-events.md) ^5.2.8

## Recent versions

- 0.1.2 (latest) — 2020-02-10
- 0.1.1 — 2020-02-05
- 0.1.0 — 2020-01-22

## README

# Storybook Addon Amplitude

Storybook Addon Amplitude provides support for [Amplitude](https://amplitude.com/) on [Storybook](https://storybook.js.org).

## Getting Started

Install:

```sh
npm install storybook-amplitude --save-dev
```

within `.storybook/main.js`:

```js
module.exports = {
  addons: ['storybook-amplitude/register']
};
```

Then, set an environment variable with your API key:

```
window.STORYBOOK_AMPLITUDE_API_KEY = '561t966209h0789k7ffr2c3nmn0sau90'
```

### Configuration

You can use a custom event name setting an environment variable:

```
window.STORYBOOK_AMPLITUDE_EVENT = 'Your custom event'
```

The default value is `Story Viewed`.

## Event anatomy

> lt;dr: the event will be sent with `Story Viewed` (or your custom event name) and the custom property object with `viewMode`, `group`, `page` and `story`.

The [Storybook provides](https://storybook.js.org/docs/addons/api) just the `path` and `storyId` on the `api` provided by `register` callback. The `strings` are like these examples:

- `/story/fundamentals-principles--page`
- `/docs/design-spacing--page`
- `/docs/components-accordion--base`
- `/story/components-accordion--base`

So, we've split the path and created an object with this anatomy:

`/<viewMode>/<group>-<page>--<story>`

Examples:

| Path                                   | ViewMode | Group        | Page       | Story    |
| -------------------------------------- | -------- | ------------ | ---------- | -------- |
| `/story/fundamentals-principles--page` | story    | fundamentals | principles | `null`   |
| `/docs/design-spacing--page`           | docs     | design       | spacing    | `null`   |
| `/docs/components-accordion--base`     | docs     | components   | accordion  | base     |
| `/story/components-button--disabled`   | story    | components   | button     | disabled |

Creating an util function that returns an object with viewMode, group, page and story. Something like this:

```js
{
  viewMode: 'docs',
  group: 'components',
  page: 'button',
  story: 'disabled'
}
```

## Support

Do you need a help? [Open a issue here!](https://github.com/quintoandar/storybook-amplitude/issues/new)

---
_Source: https://npm.io/package/storybook-amplitude · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
