Skip to content

Commit

Permalink
[feat] 학교 대항전 amplitude 추가
Browse files Browse the repository at this point in the history
  • Loading branch information
euije committed Mar 19, 2024
1 parent 63e330a commit cbac56f
Show file tree
Hide file tree
Showing 5 changed files with 74 additions and 5 deletions.
2 changes: 1 addition & 1 deletion app/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import '@/styles/globals.css';
import { StyledComponentsRegistry } from '@/component/Provider/StyledComponentsRegistry';
import { ReactQueryClientProvider } from '@/component/Provider/ReactQueryClientProvider';
import { PrimerStyleProvider } from '@/component/Provider/PrimerStyleProvider';
import { WEB_URL } from '@/util/string';
import { AMPLITUDE_KEY, WEB_URL } from '@/util/string';

export const metadata: Metadata = {
metadataBase: new URL(WEB_URL!),
Expand Down
13 changes: 10 additions & 3 deletions app/school-attack/[[...groupId]]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import React, {
} from 'react';
import Image from 'next/image';
import { css } from 'styled-components';
import { useRouter } from 'next/navigation';
import { useRouter, useSearchParams } from 'next/navigation';
import {
Dialog,
Pagination,
Expand Down Expand Up @@ -64,7 +64,7 @@ import {
useQuery,
useQueryClient,
} from '@tanstack/react-query';
import { MUTATION_KEY, QUERY_KEY } from '@/util/string';
import { AMPLITUDE_KEY, MUTATION_KEY, QUERY_KEY } from '@/util/string';
import {
getSchoolAttackStatistics,
getSchoolAttackStatisticsDetail,
Expand All @@ -74,10 +74,12 @@ import { redirect, useParams } from 'next/navigation';
import { UserPostCommentRequest } from '@/repository/schema';
import { getUserPostComment, postUserPostComment } from '@/repository/user';
import { sendGAEvent } from '@next/third-parties/google';
import * as amplitude from '@amplitude/analytics-browser';

const maxWidth = 425;

export default function Page() {
const params = useSearchParams();
const router = useRouter();
const { groupId } = useParams();

Expand Down Expand Up @@ -178,10 +180,15 @@ export default function Page() {

useEffect(() => {
if (typeof window != 'undefined') {
amplitude.init(AMPLITUDE_KEY as string, { defaultTracking: true });

const gtag = window.gtag;
gtag('event', 'school_attack_visit');
amplitude.logEvent('school_attack_visit', {
id: params.has('id') ? (params.get('id') as string) : undefined,
});
}
}, []);
}, [params]);

return (
<ThemeProvider colorMode='dark' preventSSRMismatch>
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"deploy": "touch out/.nojekyll && gh-pages -d out --dotfiles"
},
"dependencies": {
"@amplitude/analytics-browser": "^2.5.3",
"@next/third-parties": "^14.1.3",
"@primer/octicons-react": "latest",
"@primer/react": "latest",
Expand Down
2 changes: 2 additions & 0 deletions util/string.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,5 @@ export const MUTATION_KEY = {

export const BASE_URL = process.env.NEXT_PUBLIC_SERVER_URL;
export const WEB_URL = process.env.NEXT_PUBLIC_WEB_URL;

export const AMPLITUDE_KEY = process.env.NEXT_PUBLIC_AMPLITUDE_KEY;
61 changes: 60 additions & 1 deletion yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,65 @@
resolved "https://registry.yarnpkg.com/@alloc/quick-lru/-/quick-lru-5.2.0.tgz#7bf68b20c0a350f936915fcae06f58e32007ce30"
integrity sha512-UrcABB+4bUrFABwbluTIBErXwvbsU/V7TZWfmbgJfbkwiBuziS9gxdODUyuiecfdGQ85jglMW6juS3+z5TsKLw==

"@amplitude/analytics-browser@^2.5.3":
version "2.5.3"
resolved "https://registry.yarnpkg.com/@amplitude/analytics-browser/-/analytics-browser-2.5.3.tgz#ded954be984fa740f091f8a72b9791ec8c033009"
integrity sha512-q38XeLTeJ7L0NDphrkjSMBMjCDyxiK6GBL5w7/HBp9RDoCHGwLI8JkT07JEuEUnVwz38g3kvXuzyvoSLV5Zp7g==
dependencies:
"@amplitude/analytics-client-common" "^2.1.1"
"@amplitude/analytics-core" "^2.2.2"
"@amplitude/analytics-types" "^2.5.0"
"@amplitude/plugin-page-view-tracking-browser" "^2.2.3"
"@amplitude/plugin-web-attribution-browser" "^2.1.4"
tslib "^2.4.1"

"@amplitude/analytics-client-common@^2.1.1":
version "2.1.1"
resolved "https://registry.yarnpkg.com/@amplitude/analytics-client-common/-/analytics-client-common-2.1.1.tgz#a65d31034bf4ef8cae45d27c155815588164d3d0"
integrity sha512-AsF5pq0eHj8nCstrDIBfn4EseYs+A8qR6Q4I47i4/SC/7bbalJ2GIsgLk2azQ86fINfR8a/iSXQ+uAs/xlv6Zg==
dependencies:
"@amplitude/analytics-connector" "^1.4.8"
"@amplitude/analytics-core" "^2.2.2"
"@amplitude/analytics-types" "^2.5.0"
tslib "^2.4.1"

"@amplitude/analytics-connector@^1.4.8":
version "1.5.0"
resolved "https://registry.yarnpkg.com/@amplitude/analytics-connector/-/analytics-connector-1.5.0.tgz#89a78b8c6463abe4de1d621db4af6c62f0d62b0a"
integrity sha512-T8mOYzB9RRxckzhL0NTHwdge9xuFxXEOplC8B1Y3UX3NHa3BLh7DlBUZlCOwQgMc2nxDfnSweDL5S3bhC+W90g==

"@amplitude/analytics-core@^2.2.2":
version "2.2.2"
resolved "https://registry.yarnpkg.com/@amplitude/analytics-core/-/analytics-core-2.2.2.tgz#94683e8a4563c310890877251f266990ba7c607f"
integrity sha512-k3m8qmbnqu5L91h/btSMC6HAItTNgN4nkbKDWOae6dXeoLClewryXf9yo/e1pzn5TY7lxNNY1FvuErcg7z2+Ig==
dependencies:
"@amplitude/analytics-types" "^2.5.0"
tslib "^2.4.1"

"@amplitude/analytics-types@^2.5.0":
version "2.5.0"
resolved "https://registry.yarnpkg.com/@amplitude/analytics-types/-/analytics-types-2.5.0.tgz#d0d1ed66474b268909ccd89a06909e99f466bc14"
integrity sha512-aY69WxUvVlaCU+9geShjTsAYdUTvegEXH9i4WK/97kNbNLl4/7qUuIPe4hNireDeKLuQA9SA3H7TKynuNomDxw==

"@amplitude/plugin-page-view-tracking-browser@^2.2.3":
version "2.2.3"
resolved "https://registry.yarnpkg.com/@amplitude/plugin-page-view-tracking-browser/-/plugin-page-view-tracking-browser-2.2.3.tgz#8709c00a94072bca227949ba7f943da3e05cce64"
integrity sha512-3w1cXI+2X6TQPmaLK9H2IpCm1a3PsvoFLzbDC1zijkMxcCkVo7ZDn4C1CA00isu/NxATie6YNU/THkjqVC9JQA==
dependencies:
"@amplitude/analytics-client-common" "^2.1.1"
"@amplitude/analytics-types" "^2.5.0"
tslib "^2.4.1"

"@amplitude/plugin-web-attribution-browser@^2.1.4":
version "2.1.4"
resolved "https://registry.yarnpkg.com/@amplitude/plugin-web-attribution-browser/-/plugin-web-attribution-browser-2.1.4.tgz#31a79e10767ade1813f84664de8711a29ad24d33"
integrity sha512-Cc65idSxrDoscef6TXFL2XKizvk6qLhPNYbZAPnloEaCTG3KbVk8m6NaDflfPrWhsEEy7cmZjXr7gsY/3/eBZQ==
dependencies:
"@amplitude/analytics-client-common" "^2.1.1"
"@amplitude/analytics-core" "^2.2.2"
"@amplitude/analytics-types" "^2.5.0"
tslib "^2.4.1"

"@babel/code-frame@^7.23.5":
version "7.23.5"
resolved "https://registry.yarnpkg.com/@babel/code-frame/-/code-frame-7.23.5.tgz#9009b69a8c602293476ad598ff53e4562e15c244"
Expand Down Expand Up @@ -4233,7 +4292,7 @@ tsconfig-paths@^4.2.0:
minimist "^1.2.6"
strip-bom "^3.0.0"

tslib@^2.3.0, tslib@^2.4.0, tslib@^2.6.2:
tslib@^2.3.0, tslib@^2.4.0, tslib@^2.4.1, tslib@^2.6.2:
version "2.6.2"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.6.2.tgz#703ac29425e7b37cd6fd456e92404d46d1f3e4ae"
integrity sha512-AEYxH93jGFPn/a2iVAwW87VuUIkR1FVUKB77NwMF7nBTDkDrrT/Hpt/IrCJ0QXhW27jTBDcf5ZY7w6RiqTMw2Q==
Expand Down

0 comments on commit cbac56f

Please sign in to comment.