Skip to content

Commit

Permalink
Merge branch 'dev' into production
Browse files Browse the repository at this point in the history
  • Loading branch information
jaryapp committed Aug 20, 2023
2 parents 34e980f + 65d4d4b commit 07cb64b
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 19 deletions.
18 changes: 0 additions & 18 deletions packages/mobile/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,6 @@
href="https://cbnu-cmi.s3.ap-northeast-2.amazonaws.com/images/1678586426871.png"
rel="icon"
/>

<!-- Global site tag (gtag.js) - Google Analytics -->
<script
async
src="https://www.googletagmanager.com/gtag/js?id=UA-236608494-2"
></script>

<script>
window.dataLayer = window.dataLayer || [];

function gtag() {
dataLayer.push(arguments);
}

gtag("js", new Date());

gtag("config", "UA-236608494-2");
</script>
</head>
<body>
<div id="root"></div>
Expand Down
1 change: 1 addition & 0 deletions packages/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"react": "^18.0.0",
"react-device-detect": "^2.2.2",
"react-dom": "^18.0.0",
"react-ga": "^3.3.1",
"react-helmet": "^6.1.0",
"react-helmet-async": "^1.3.0",
"react-hot-toast": "^2.3.0",
Expand Down
4 changes: 3 additions & 1 deletion packages/mobile/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ import Article from "src/page/Article";
import ArticleDetail from "src/page/Article/Detail";
import Board from "src/page/Board";
import BoardArticle from "src/page/Board/Article";
import "src/polyfills";
import { isWebView } from "src/utils/webview";

import "src/polyfills";
import GA from "./components/atoms/GA";
import useFCMToken from "./hooks/useFCMToken";
import useWindowSizeDetect from "./hooks/useWindowSizeDetect";
import "./mobile.scss";
Expand Down Expand Up @@ -74,6 +75,7 @@ function App() {
return (
<BrowserRouter>
<DeepLink />
<GA />
<Routes>
{routes.map((route) => {
return (
Expand Down
9 changes: 9 additions & 0 deletions packages/mobile/src/components/atoms/GA/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import useGA from "src/hooks/useGA";

const GA = () => {
useGA();

return null;
};

export default GA;
22 changes: 22 additions & 0 deletions packages/mobile/src/hooks/useGA.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
import { useEffect, useState } from "react";
import ReactGA from "react-ga";
import { useLocation } from "react-router-dom";

const useGA = () => {
const location = useLocation();
const [ initialized, setInitialized ] = useState(false);

useEffect(() => {
ReactGA.initialize("G-90WFEB8J9K");

setInitialized(true);
}, []);

useEffect(() => {
if (initialized) {
ReactGA.pageview(location.pathname + location.search);
}
}, [ initialized, location ]);
};

export default useGA;
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -14234,6 +14234,11 @@ react-fast-compare@^3.1.1, react-fast-compare@^3.2.0:
resolved "https://registry.yarnpkg.com/react-fast-compare/-/react-fast-compare-3.2.0.tgz#641a9da81b6a6320f270e89724fb45a0b39e43bb"
integrity sha512-rtGImPZ0YyLrscKI9xTpV8psd6I8VAtjKCzQDlzyDvqJA8XOW78TXYQwNRNd8g8JZnDu8q9Fu/1v4HPAVwVdHA==

react-ga@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-3.3.1.tgz#d8e1f4e05ec55ed6ff944dcb14b99011dfaf9504"
integrity sha512-4Vc0W5EvXAXUN/wWyxvsAKDLLgtJ3oLmhYYssx+YzphJpejtOst6cbIHCIyF50Fdxuf5DDKqRYny24yJ2y7GFQ==

react-helmet-async@^1.3.0:
version "1.3.0"
resolved "https://registry.yarnpkg.com/react-helmet-async/-/react-helmet-async-1.3.0.tgz#7bd5bf8c5c69ea9f02f6083f14ce33ef545c222e"
Expand Down

0 comments on commit 07cb64b

Please sign in to comment.