Skip to content
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

Revert 50 feat/amplitude options #51

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 0 additions & 24 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -49,30 +49,6 @@ 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:

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

> Read more: [Configurations](https://www.docs.developers.amplitude.com/data/sdks/typescript-browser/#configuration), [Endpoints](https://www.docs.developers.amplitude.com/analytics/apis/http-v2-api/#endpoints)

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

```ts
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
Expand Down
14 changes: 3 additions & 11 deletions src/preset/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,13 @@ import { addons } from "@storybook/addons";
import { STORY_CHANGED, STORY_ARGS_UPDATED } from "@storybook/core-events";
import { parsePath } from "../parsePath";

import * as amplitude from "@amplitude/analytics-browser";
import * as amplitude from "@amplitude/analytics-browser"

addons.register("storybook/amplitude", (api) => {
if (process.env.NODE_ENV === "production") {
amplitude.init(
globalWindow.AMPLITUDE_PROD_API_KEY,
null,
globalWindow.AMPLITUDE_OPTIONS
);
amplitude.init(globalWindow.AMPLITUDE_PROD_API_KEY);
} else {
amplitude.init(
globalWindow.AMPLITUDE_DEV_API_KEY,
null,
globalWindow.AMPLITUDE_OPTIONS
);
amplitude.init(globalWindow.AMPLITUDE_DEV_API_KEY);
}

api.on(STORY_CHANGED, () => {
Expand Down
Loading