Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Hotjar 설치 #60

Merged
merged 3 commits into from
Apr 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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