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 2ae5ab7 commit cb8472e
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ enum PokeAmplitudeEventPropertyValue: String, AmplitudeEventPropertyValueConvert
case pokeMainAlarm = "poke_main_alarm"
case pokeMainFriend = "poke_main_friend"
case pokeMainRecommendNotMyFriend = "poke_main_recommend_notmyfriend"
case pokeMainRecommendMyFriend = "poke_main_recommend_myfriend"

func toString() -> String {
self.rawValue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -211,10 +211,16 @@ extension PokeMainVC: UIGestureRecognizerDelegate {

extension PokeMainVC {
private func bindViewModel() {
let profileImageTap = Publishers.Merge4(pokedUserContentView.profileImageTap,
friendSectionContentView.profileImageTap,
firstProfileCardGroupView.profileImageTap,
secondProfileCardGroupView.profileImageTap).asDriver()
let profileImageTap = Publishers.Merge4(
pokedUserContentView.profileImageTap
.map { ($0, PokeAmplitudeEventPropertyValue.pokeMainAlarm) },
friendSectionContentView.profileImageTap
.map { ($0, PokeAmplitudeEventPropertyValue.pokeMainFriend) },
firstProfileCardGroupView.profileImageTap
.map { ($0, PokeAmplitudeEventPropertyValue.pokeMainRecommendNotMyFriend) },
secondProfileCardGroupView.profileImageTap
.map { ($0, PokeAmplitudeEventPropertyValue.pokeMainRecommendNotMyFriend) })
.asDriver()

let randomUserSectionFriendProfileImageTap = Publishers.Merge(
firstProfileCardGroupView.friendProfileImageTap,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class PokeMainViewModel:
let friendSectionKokButtonTap: Driver<PokeUserModel?>
let nearbyFriendsSectionKokButtonTap: Driver<PokeUserModel?>
let refreshRequest: Driver<Void>
let profileImageTap: Driver<PokeUserModel?>
let profileImageTap: Driver<(PokeUserModel?, PokeAmplitudeEventPropertyValue)>
let randomUserSectionFriendProfileImageTap: Driver<Int?>
}

Expand Down Expand Up @@ -140,14 +140,21 @@ extension PokeMainViewModel {
}.store(in: cancelBag)

input.profileImageTap
.compactMap { $0 }
.compactMap { $0.0 }
.sink { [weak self] user in
self?.onProfileImageTapped?(user.playgroundId)
}.store(in: cancelBag)

input.profileImageTap
.map { $0.1 }
.sink { [weak self] clickView in
self?.trackClickMemberProfileEvent(clickView: clickView)
}.store(in: cancelBag)

input.randomUserSectionFriendProfileImageTap
.compactMap { $0 }
.sink { [weak self] playgroundId in
self?.trackClickMemberProfileEvent(clickView: .pokeMainRecommendMyFriend)
self?.onProfileImageTapped?(playgroundId)
}.store(in: cancelBag)

Expand Down Expand Up @@ -242,4 +249,13 @@ extension PokeMainViewModel {

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

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

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

0 comments on commit cb8472e

Please sign in to comment.