Skip to content

Commit

Permalink
[Feat] sopt-makers#354 - PokeMain 뷰의 버튼 터치 이벤트 트래킹
Browse files Browse the repository at this point in the history
  • Loading branch information
lsj8706 committed Jan 21, 2024
1 parent c135c43 commit 2ae5ab7
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ public enum AmplitudeEventType: String {
case clickPlaygroundCommunity = "click_playground_community"
case clickPoke = "click_poke"
case clickMemberProfile = "click_memberProfile"
case clickClickPoke = "clickPoke"
case clickPokeIcon = "click_poke_icon"
case clickPokeAlarmDetail = "click_poke_alarm_detail"
case clickPokeQuit = "click_poke_quit"

// 뷰 이벤트
case viewAppHome = "view_apphome"
case viewPokeOnboarding = "view_poke_onboarding"
case viewPokeMain = "view_poke_main"
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,9 @@ import Core

enum PokeAmplitudeEventPropertyValue: String, AmplitudeEventPropertyValueConvertible {
case onboarding = "onboarding"
case pokeMainAlarm = "poke_main_alarm"
case pokeMainFriend = "poke_main_friend"
case pokeMainRecommendNotMyFriend = "poke_main_recommend_notmyfriend"

func toString() -> String {
self.rawValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,20 @@ extension PokeMainViewModel {
self?.useCase.checkPokeNewUser()
}.store(in: cancelBag)

input.viewDidLoad
.sink { _ in
AmplitudeInstance.shared.trackWithUserType(event: .viewPokeMain)
}.store(in: cancelBag)

input.naviBackButtonTap
.sink { [weak self] _ in
AmplitudeInstance.shared.trackWithUserType(event: .clickPokeQuit)
self?.onNaviBackTap?()
}.store(in: cancelBag)

input.pokedSectionHeaderButtonTap
.sink { [weak self] _ in
AmplitudeInstance.shared.trackWithUserType(event: .clickPokeAlarmDetail)
self?.onPokeNotificationsTap?()
}.store(in: cancelBag)

Expand All @@ -116,6 +123,7 @@ extension PokeMainViewModel {
return value
}
.sink { [weak self] userModel, messageModel in
self?.trackClickPokeEvent(clickView: .pokeMainAlarm)
self?.useCase.poke(userId: userModel.userId, message: messageModel, willBeNewFriend: userModel.isFirstMeet)
}.store(in: cancelBag)

Expand Down Expand Up @@ -143,6 +151,17 @@ extension PokeMainViewModel {
self?.onProfileImageTapped?(playgroundId)
}.store(in: cancelBag)

// Amplitude 트래킹
input.friendSectionKokButtonTap
.sink { [weak self] _ in
self?.trackClickPokeEvent(clickView: .pokeMainFriend)
}.store(in: cancelBag)

input.nearbyFriendsSectionKokButtonTap
.sink { [weak self] _ in
self?.trackClickPokeEvent(clickView: .pokeMainRecommendNotMyFriend)
}.store(in: cancelBag)

return output
}

Expand Down Expand Up @@ -213,3 +232,14 @@ extension PokeMainViewModel {
}.store(in: cancelBag)
}
}

extension PokeMainViewModel {
private func trackClickPokeEvent(clickView: PokeAmplitudeEventPropertyValue) {
let properties = AmplitudeEventPropertyBuilder<PokeAmplitudeEventPropertyValue>()
.addViewType()
.add(key: .clickViewType, value: clickView)
.build()

AmplitudeInstance.shared.track(eventType: .clickPokeIcon, eventProperties: properties)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,6 @@ private extension PokeOnboardingViewModel {
.add(key: .viewProfile, value: playgroundId)
.build()

AmplitudeInstance.shared.track(eventType: .clickPoke, eventProperties: properties)
AmplitudeInstance.shared.track(eventType: .clickPokeIcon, eventProperties: properties)
}
}

0 comments on commit 2ae5ab7

Please sign in to comment.