-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: amplitude tracking 코드 작성 (#733)
* feat: amplitude 트래킹 코드 구현 Co-authored-by: JinHo Kim <[email protected]> * chore: 불필요한 console.log제거 * feat: 이벤트 생성, 시작버튼 클릭, 지출내역 체류시간 track 함수 제작 * feat: track 코드에 진입 브라우저 프로퍼티 추가 * feat: 정산 시작하기 track 코드 추가 * feat: 이벤트 로더에서 총액 계산 * feat: 이벤트 초대 클릭 track 코드 추가 * feat: 지출내역 시작, 종료 tracking 코드 추가 * feat: 송금하기 tracking 코드 추가 * chore: 필요하지 않은 의존성 제거 * style: lint 맞춰줌 * fix: 개발 편의로 인한 sentry 주석 해제 --------- Co-authored-by: 이태훈 <[email protected]> Co-authored-by: JinHo Kim <[email protected]>
- Loading branch information
1 parent
158bd62
commit 3d7967d
Showing
22 changed files
with
438 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
client/src/components/AmplitudeInitializer/AmplitudeInitializer.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import {useEffect} from 'react'; | ||
|
||
import {useAmplitudeStore} from '@store/amplitudeStore'; | ||
|
||
const AmplitudeInitializer = ({children}: React.PropsWithChildren) => { | ||
const {amplitude} = useAmplitudeStore(); | ||
|
||
useEffect(() => { | ||
amplitude.init(process.env.AMPLITUDE_KEY, undefined, { | ||
defaultTracking: true, | ||
}); | ||
}, []); | ||
|
||
return children; | ||
}; | ||
|
||
export default AmplitudeInitializer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
import {useAmplitudeStore} from '@store/amplitudeStore'; | ||
|
||
import detectBrowser from '@utils/detectBrowser'; | ||
|
||
type EventUniqueData = { | ||
eventName: string; | ||
eventToken: string; | ||
}; | ||
|
||
type ShareMethod = 'link' | 'kakao'; | ||
|
||
export type EventSummary = EventUniqueData & { | ||
totalExpenseAmount: number; // 총 지출금액 | ||
allMembersCount: number; // 행사에 참여한 총 인원 | ||
billsCount: number; // 총 지출내역 수 | ||
isAdmin: boolean; // 관리자 여부 | ||
shareMethod: ShareMethod; // 공유 방법 | ||
}; | ||
|
||
type SendMethod = 'clipboard' | 'toss' | 'kakaopay'; | ||
|
||
type SendMoneyData = EventUniqueData & { | ||
sendMethod: SendMethod; | ||
amount: number; | ||
}; | ||
|
||
const useAmplitude = () => { | ||
const {amplitude} = useAmplitudeStore(); | ||
const domainEnv = process.env.NODE_ENV; | ||
|
||
const track = (eventName: string, eventProps: Record<string, any> = {}) => { | ||
amplitude.track(eventName, { | ||
domain: domainEnv, | ||
browser: detectBrowser(), | ||
...eventProps, | ||
}); | ||
}; | ||
|
||
const trackStartCreateEvent = () => { | ||
track('정산 시작하기 버튼 클릭'); | ||
}; | ||
|
||
const trackCompleteCreateEvent = (eventUniqueData: EventUniqueData) => { | ||
track('이벤트 생성 완료', { | ||
...eventUniqueData, | ||
}); | ||
}; | ||
|
||
const trackShareEvent = (eventSummary: EventSummary) => { | ||
track('이벤트 초대 클릭', { | ||
...eventSummary, | ||
}); | ||
}; | ||
|
||
const trackAddBillStart = (eventUniqueData: EventUniqueData) => { | ||
track('지출내역 추가 시작', { | ||
...eventUniqueData, | ||
}); | ||
}; | ||
|
||
const trackAddBillEnd = (eventUniqueData: EventUniqueData) => { | ||
track('지출내역 추가 완료', { | ||
...eventUniqueData, | ||
}); | ||
}; | ||
|
||
const trackSendMoney = (sendMoneyData: SendMoneyData) => { | ||
track('송금 버튼 클릭', { | ||
...sendMoneyData, | ||
}); | ||
}; | ||
|
||
return { | ||
trackStartCreateEvent, | ||
trackCompleteCreateEvent, | ||
trackShareEvent, | ||
trackAddBillStart, | ||
trackAddBillEnd, | ||
trackSendMoney, | ||
}; | ||
}; | ||
|
||
export default useAmplitude; |
Oops, something went wrong.