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

Migrate addon google analytics to TS #5307

Merged
merged 2 commits into from
Jan 21, 2019
Merged
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
1 change: 0 additions & 1 deletion addons/google-analytics/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
"url": "https://github.com/storybooks/storybook.git"
},
"license": "MIT",
"jsnext:main": "src/index.js",
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this because there was no src/index.js file.
Also I did not add main and type attributes as there is nothing to "export".

"scripts": {
"prepare": "node ../../scripts/prepare.js"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { window } from 'global';
import addons from '@storybook/addons';
import { addons } from '@storybook/addons';
import { STORY_CHANGED, STORY_ERRORED, STORY_MISSING } from '@storybook/core-events';

import ReactGA from 'react-ga';
Expand All @@ -11,13 +11,13 @@ addons.register('storybook/google-analytics', api => {
const { url } = api.getUrlState();
ReactGA.pageview(url);
});
api.on(STORY_ERRORED, ({ description }) => {
api.on(STORY_ERRORED, ({ description }: { description: string }) => {
ReactGA.exception({
description,
fatal: true,
});
});
api.on(STORY_MISSING, ({ id }) => {
api.on(STORY_MISSING, ({ id }: { id: string }) => {
ReactGA.exception({
description: `attempted to render ${id}, but it is missing`,
fatal: false,
Expand Down
1 change: 1 addition & 0 deletions addons/google-analytics/src/typings.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
declare module 'global';
13 changes: 13 additions & 0 deletions addons/google-analytics/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"types": ["webpack-env"]
},
"include": [
"src/**/*"
],
"exclude": [
"src/__tests__/**/*"
]
}