Skip to content

Commit

Permalink
Merge pull request #60 from Nexters/feat/hotjar
Browse files Browse the repository at this point in the history
feat: Hotjar 설치
  • Loading branch information
eric-jy-park authored Apr 10, 2024
2 parents 6350d5c + 8d6a1e5 commit 1326a04
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
"next-themes": "^0.2.1",
"react": "^18",
"react-dom": "^18",
"react-hotjar": "^6.3.1",
"sonner": "^1.3.1",
"tailwind-merge": "^2.2.0",
"vaul": "^0.8.0",
Expand Down
7 changes: 7 additions & 0 deletions pnpm-lock.yaml

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

24 changes: 24 additions & 0 deletions src/app/ga-provider.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Script from "next/script";

const GAProvider = () => (
<>
<Script
async
src={`https://www.googletagmanager.com/gtag/js?
id=G-K20DRKXNTC`}
/>
<Script
id="google-analytics"
dangerouslySetInnerHTML={{
__html: `
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'G-K20DRKXNTC');
`,
}}
/>
</>
);
export default GAProvider;
15 changes: 15 additions & 0 deletions src/app/global-provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,10 @@

import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ReactQueryDevtools } from "@tanstack/react-query-devtools";
import { hotjar } from 'react-hotjar';
import axios, { AxiosError, AxiosResponse } from "axios";
import React from "react";
import GAProvider from "./ga-provider";

export const queryClient = new QueryClient({
defaultOptions: {
Expand All @@ -25,12 +27,25 @@ axios.interceptors.response.use(
}
);

const HJID = 4939296;
const HJSV = 6;

export const GlobalProvider = ({ children }: { children: React.ReactNode }) => {
const [client] = React.useState(() => new QueryClient());

React.useEffect(() => {
if (process.env.NODE_ENV !== 'development') {
hotjar.initialize({
id: HJID,
sv: HJSV
});
}
}, []);

return (
<QueryClientProvider client={client}>
{children}
<GAProvider/>
<ReactQueryDevtools />
</QueryClientProvider>
);
Expand Down

0 comments on commit 1326a04

Please sign in to comment.