Skip to content

Commit

Permalink
fix: 検証環境のStorybookのページからGAの流入を除外する (#4434)
Browse files Browse the repository at this point in the history
* fix: 特定のページからの流入を除外するテスト

* fix: GAのパラメーターの追加

* fix: ReactGAのinitializeが成功しているかの確認

* fix: GAの設定の確認

* fix: storybook node envからGAのkeyが出し分けできるか確認

* fix: chromaticのデプロイ時に環境変数を追加

* fix: 本番環境と同等の環境変数を渡して確認する

* fix: google analyticsのkeyをテスト用から本番用に変更

* fix: 本番環境時のみkeyを読み込むようにCIを修正

* fix: レビュー指摘の修正

* fix: レビュー指摘の修正漏れを追加

* fix: 変数を切り出し

---------

Co-authored-by: uknmr <y.kinmori@gmail.com>
ama-9 and uknmr authored Apr 3, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
1 parent e7dd884 commit a24c84a
Showing 2 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ commands:
run-chromatic-master:
steps:
- checkout
- run: pnpm run chromatic --project-token=${CHROMATIC_PROJECT_TOKEN} --auto-accept-changes --only-changed
- run: STORYBOOK_NODE_ENV="production" pnpm run chromatic --project-token=${CHROMATIC_PROJECT_TOKEN} --auto-accept-changes --only-changed
install-noto-sans-cjk-jp:
steps:
- run:
12 changes: 9 additions & 3 deletions .storybook/preview.tsx
Original file line number Diff line number Diff line change
@@ -14,7 +14,11 @@ import tailwindConfig from '../tailwind.config'

import '../src/styles/index.css'

ReactGA.initialize('G-65N1S3NF5R')
const isProduction = process.env.STORYBOOK_NODE_ENV === 'production'

if (isProduction) {
ReactGA.initialize('G-65N1S3NF5R')
}

const preview: Preview = {
parameters: {
@@ -81,8 +85,10 @@ const preview: Preview = {
const ThemeProvider = callThemeProvider(context.parameters.withTheming, theme)

useEffect(() => {
ReactGA.send({ hitType: 'pageview', title: context.title })
}, [])
if (isProduction) {
ReactGA.send({ hitType: 'pageview', title: context.title })
}
}, [context.title])

return (
<ThemeProvider>

0 comments on commit a24c84a

Please sign in to comment.