Skip to content

Commit

Permalink
[NDD-150] 구글 애널리틱스 설정 완료 (0.5h/1h) (#48)
Browse files Browse the repository at this point in the history
* chore: ga 설정을 위해 react-ga4 종속성 추가

* chore: env파일 사용을 위한 웹팩 플러그인 추가

* feat: Google Analytics 최소 설정 완료
  • Loading branch information
milk717 authored Nov 15, 2023
1 parent 143d912 commit 0518004
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 0 deletions.
40 changes: 40 additions & 0 deletions FE/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 2 additions & 0 deletions FE/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
"axios": "^1.6.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-ga4": "^2.1.0",
"react-router-dom": "^6.18.0",
"recoil": "^0.7.7"
},
Expand All @@ -36,6 +37,7 @@
"@typescript-eslint/parser": "^6.9.1",
"babel-loader": "^9.1.3",
"copy-webpack-plugin": "^11.0.0",
"dotenv-webpack": "^8.0.1",
"eslint": "^8.53.0",
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.1",
Expand Down
6 changes: 6 additions & 0 deletions FE/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import ReactDOM from 'react-dom/client';
import ReactGA from 'react-ga4';
import { worker } from '@/mocks/browser';
import App from '@/App';

Expand All @@ -9,6 +10,11 @@ async function deferRender() {
return worker.start();
}

//GA 추적 태그 설정
if (process.env.REACT_APP_GTAG_ID) {
ReactGA.initialize(process.env.REACT_APP_GTAG_ID);
}

deferRender()
.then(() => {
const rootElement = document.getElementById('root');
Expand Down
2 changes: 2 additions & 0 deletions FE/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const path = require('path');
const webpack = require('webpack');
const CopyPlugin = require('copy-webpack-plugin');
const Dotenv = require('dotenv-webpack');

module.exports = {
mode: process.env.production === 'true' ? 'production' : 'development',
Expand Down Expand Up @@ -44,6 +45,7 @@ module.exports = {
new CopyPlugin({
patterns: [{ from: 'public/mockServiceWorker.js', to: '' }],
}),
new Dotenv(),
],
module: {
rules: [
Expand Down

0 comments on commit 0518004

Please sign in to comment.