Skip to content

Commit

Permalink
fix: amplitude initialization in preset manager
Browse files Browse the repository at this point in the history
This adds the option to post to the EU endpoint and set other amplitude options.
  • Loading branch information
tijmenvangurp authored and Mae Capozzi committed Feb 13, 2024
1 parent 8f921f9 commit 6c35636
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/preset/manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,21 @@ 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);
amplitude.init(
globalWindow.AMPLITUDE_PROD_API_KEY,
null,
globalWindow.AMPLITUDE_OPTIONS
);
} else {
amplitude.init(globalWindow.AMPLITUDE_DEV_API_KEY);
amplitude.init(
globalWindow.AMPLITUDE_DEV_API_KEY,
null,
globalWindow.AMPLITUDE_OPTIONS
);
}

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

0 comments on commit 6c35636

Please sign in to comment.