Skip to content

Commit

Permalink
Merge pull request #5307 from gaetanmaisse/ts-migration/addon-google-…
Browse files Browse the repository at this point in the history
…analytics

Migrate addon google analytics to TS
  • Loading branch information
ndelangen committed Jan 21, 2019
2 parents f3f1807 + c71c901 commit 88edb65
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 0 additions & 1 deletion addons/google-analytics/package.json
Expand Up @@ -15,7 +15,6 @@
"url": "https://github.com/storybooks/storybook.git"
},
"license": "MIT",
"jsnext:main": "src/index.js",
"scripts": {
"prepare": "node ../../scripts/prepare.js"
},
Expand Down
@@ -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
@@ -0,0 +1 @@
declare module 'global';
13 changes: 13 additions & 0 deletions addons/google-analytics/tsconfig.json
@@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"rootDir": "./src",
"types": ["webpack-env"]
},
"include": [
"src/**/*"
],
"exclude": [
"src/__tests__/**/*"
]
}

0 comments on commit 88edb65

Please sign in to comment.