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

[SP1] Amplitude 설정 #189

Merged
merged 9 commits into from
Sep 23, 2023
Merged

[SP1] Amplitude 설정 #189

merged 9 commits into from
Sep 23, 2023

Conversation

solar3070
Copy link
Member

@solar3070 solar3070 commented Sep 19, 2023

Summary

Screenshot

image

[chrome extension 캡쳐]
크롬 익스텐션 설치를 권장합니다! 이벤트 로그를 편하게 볼 수 있습니다.

Comment

  • env 파일을 .env.development, .env.production으로 나누었습니다. 알려드린 앰플리튜드 키를 각각 넣어주세요!
NEXT_PUBLIC_AMPLITUDE_API_KEY=
  • 사용 예시
    click_main_part, click_main_activity, click_review_part 이벤트를 트래킹했습니다. 참고해서 작성해주시면 됩니다.
import { track } from '@amplitude/analytics-browser';
track('click_main_activity', { activity: type });

Copy link
Contributor

@f0rever0 f0rever0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

확인했습니다~ 얼른 트랙킹 붙여서 확인해보고 싶네요 ☺️

const AMPLITUDE_API_KEY = process.env.NEXT_PUBLIC_AMPLITUDE_API_KEY;

function useAmplitude() {
const [amplitude, setAmplitude] = useState<typeof import('@amplitude/analytics-browser')>();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import한 값을 typeof 로 바로 지정할 수도 있군요 !!

const [amplitude, setAmplitude] = useState<typeof import('@amplitude/analytics-browser')>();

useEffect(() => {
const initAmplitude = async () => {
Copy link
Member

@SeojinSeojin SeojinSeojin Sep 20, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

init은 한 페이지에서 한 번만 불려도 될 것 같은데요 ..!!
만약 페이지 하나가 컴포넌트 3개를 거느리고 있고, 각 컴포넌트에서 useAmplitude를 호출하면, initAmplitude가 3번 호출되어서 amplitudeModule.init도 3번 호출되고, 그러면 view_${pageName}도 3번 찍히게 될 것 같습니다 ..!!!
(훅 관련한 기억이 긴가민가해서 틀린 추측일 수도 있습니다!)

@pull-request-size pull-request-size bot added size/L and removed size/M labels Sep 22, 2023
@solar3070 solar3070 merged commit 3b3b737 into develop Sep 23, 2023
@solar3070 solar3070 deleted the feat/#185-amplitude-setting branch September 23, 2023 04:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Amplitude 설정
3 participants