Skip to content

Commit

Permalink
✨ react-ga4로 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
jaryapp committed Aug 21, 2023
1 parent e40627a commit 001a91f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
1 change: 1 addition & 0 deletions packages/mobile/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
"react-device-detect": "^2.2.2",
"react-dom": "^18.0.0",
"react-ga": "^3.3.1",
"react-ga4": "^2.1.0",
"react-helmet": "^6.1.0",
"react-helmet-async": "^1.3.0",
"react-hot-toast": "^2.3.0",
Expand Down
7 changes: 5 additions & 2 deletions packages/mobile/src/hooks/useGA.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { useEffect, useState } from "react";
import ReactGA from "react-ga";
import ReactGA from "react-ga4";
import { useLocation } from "react-router-dom";

const useGA = () => {
Expand All @@ -14,7 +14,10 @@ const useGA = () => {

useEffect(() => {
if (initialized) {
ReactGA.pageview(location.pathname + location.search);
ReactGA.send({
hitType: "pageview",
page: location.pathname + location.search,
});
}
}, [ initialized, location ]);
};
Expand Down
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-ga4@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/react-ga4/-/react-ga4-2.1.0.tgz#56601f59d95c08466ebd6edfbf8dede55c4678f9"
integrity sha512-ZKS7PGNFqqMd3PJ6+C2Jtz/o1iU9ggiy8Y8nUeksgVuvNISbmrQtJiZNvC/TjDsqD0QlU5Wkgs7i+w9+OjHhhQ==

react-ga@^3.3.1:
version "3.3.1"
resolved "https://registry.yarnpkg.com/react-ga/-/react-ga-3.3.1.tgz#d8e1f4e05ec55ed6ff944dcb14b99011dfaf9504"
Expand Down

0 comments on commit 001a91f

Please sign in to comment.