Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion Wable-iOS.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -837,6 +837,7 @@
DD2967642D6DAC3100143851 /* Core */ = {
isa = PBXGroup;
children = (
DDFE04392DE618590040ED75 /* Amplitude */,
DE93210E2DE4C3DE00629B88 /* Literals */,
DD29676E2D6DAC3100143851 /* Bundle */,
DD29675D2D6DAC3100143851 /* DI */,
Expand Down Expand Up @@ -1597,6 +1598,14 @@
path = ViewController;
sourceTree = "<group>";
};
DDFE04392DE618590040ED75 /* Amplitude */ = {
isa = PBXGroup;
children = (
DE8E863E2D91A032000A4292 /* AmplitudeManager.swift */,
);
path = Amplitude;
sourceTree = "<group>";
};
DE0BFB5B2DA4EC3700F06656 /* View */ = {
isa = PBXGroup;
children = (
Expand Down Expand Up @@ -1996,7 +2005,6 @@
DE7C53092D761DB900076E5D /* Helper */ = {
isa = PBXGroup;
children = (
DE8E863E2D91A032000A4292 /* AmplitudeManager.swift */,
DE83891A2D906C0C00C089E6 /* Types.swift */,
DE7C53172D761F3A00076E5D /* ReuseIdentifiable.swift */,
DE8E86402D91A092000A4292 /* Extension */,
Expand Down
129 changes: 129 additions & 0 deletions Wable-iOS/Core/Amplitude/AmplitudeManager.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
//
// AmplitudeManager.swift
// Wable-iOS
//
// Created by 김진웅 on 3/24/25.
//

import Foundation

import AmplitudeSwift

final class AmplitudeManager {
static let shared = AmplitudeManager()

private let amplitude: Amplitude

private init() {
amplitude = Amplitude(configuration: Configuration(apiKey: Bundle.amplitudeAppKey))
}

func trackEvent(tag: EventTag) {
amplitude.track(eventType: tag.value)
}
}

extension AmplitudeManager {

// MARK: - EventTag

enum EventTag: CaseIterable {
case clickCommunityBotnavi
case clickViewitBotnavi
case clickHomeBotnavi
case clickNewsBotnavi
case clickNotiBotnavi
case clickMyprofileBotnavi
case clickLikePost
case clickGhostPost
case clickWritePost
case clickDeletePost
case clickWithdrawghostPopup
case clickApplyghostPopup
case clickUploadLinkpost
case clickViralinkTeamzone
case clickApplyTeamzone
case clickUploadComment
case clickWriteComment
case clickWriteRecomment
case clickLikeComment
case clickGhostComment
case clickNews
case clickAnnouncement
case clickGameschedule
case clickRanking
case clickActivitiesnoti
case clickInfonoti
case clickSigninKakao
case clickSigninApple
case clickAgreePopupSignup
case clickNextYearSignup
case clickDetourTeamSignup
case clickNextTeamSignup
case clickChangePictureProfileSignup
case clickAddPictureProfileSignup
case clickNextProfileSignup
case clickCompleteTncSignup
case clickJoinPopupSignup
case clickUploadPost
case clickAttachPhoto
case clickWriteFirstpost
case clickCompleteLogout
case clickDeleteAccount
case clickNextDeletereason
case clickNextDeleteguide
case clickDoneDeleteaccount
case clickGobackHome

var value: String {
switch self {
case .clickCommunityBotnavi: return "click_community_botnavi"
case .clickViewitBotnavi: return "click_viewit_botnavi"
case .clickHomeBotnavi: return "click_home_botnavi"
case .clickNewsBotnavi: return "click_news_botnavi"
case .clickNotiBotnavi: return "click_noti_botnavi"
case .clickMyprofileBotnavi: return "click_myprofile_botnavi"
case .clickLikePost: return "click_like_post"
case .clickGhostPost: return "click_ghost_post"
case .clickWritePost: return "click_write_post"
case .clickDeletePost: return "click_delete_post"
case .clickWithdrawghostPopup: return "click_withdrawghost_popup"
case .clickApplyghostPopup: return "click_applyghost_popup"
case .clickUploadLinkpost: return "click_upload_linkpost"
case .clickViralinkTeamzone: return "click_virallink_teamzone"
case .clickApplyTeamzone: return "click_apply_teamzone"
case .clickUploadComment: return "click_upload_comment"
case .clickWriteComment: return "click_write_comment"
case .clickWriteRecomment: return "click_write_recomment"
case .clickLikeComment: return "click_like_comment"
case .clickGhostComment: return "click_ghost_comment"
case .clickNews: return "click_news"
case .clickAnnouncement: return "click_announcement"
case .clickGameschedule: return "click_gameschedule"
case .clickRanking: return "click_ranking"
case .clickActivitiesnoti: return "click_activitiesnoti"
case .clickInfonoti: return "click_infonoti"
case .clickSigninKakao: return "click_signin_kakao"
case .clickSigninApple: return "click_signin_apple"
case .clickAgreePopupSignup: return "click_agree_popup_signup"
case .clickNextYearSignup: return "click_next_year_signup"
case .clickDetourTeamSignup: return "click_detour_team_signup"
case .clickNextTeamSignup: return "click_next_team_signup"
case .clickChangePictureProfileSignup: return "click_change_picture_profile_signup"
case .clickAddPictureProfileSignup: return "click_add_picture_profile_signup"
case .clickNextProfileSignup: return "click_next_profile_signup"
case .clickCompleteTncSignup: return "click_complete_tnc_signup"
case .clickJoinPopupSignup: return "click_join_popup_signup"
case .clickUploadPost: return "click_upload_post"
case .clickAttachPhoto: return "click_attach_photo"
case .clickWriteFirstpost: return "click_write_firstpost"
case .clickCompleteLogout: return "click_complete_logout"
case .clickDeleteAccount: return "click_delete_account"
case .clickNextDeletereason: return "click_next_deletereason"
case .clickNextDeleteguide: return "click_next_deleteguide"
case .clickDoneDeleteaccount: return "click_done_deleteaccount"
case .clickGobackHome: return "click_goback_home"
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ private extension CommunityInviteCell {
@objc func copyLinkButtonDidTap(_ sender: UIButton) {
guard sender.configuration?.title == Constant.defaultTitle else { return }

AmplitudeManager.shared.trackEvent(tag: .clickViralinkTeamzone)

copyLinkClosure?()

showCopyLinkCompletedState()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,8 @@ private extension CommunityViewController {

let cancelAction = WableSheetAction(title: "취소", style: .gray)
let registerAction = WableSheetAction(title: "신청하기", style: .primary) { [weak self] in
AmplitudeManager.shared.trackEvent(tag: .clickApplyTeamzone)

self?.registerRelay.send(item)
}
wableSheet.addActions(cancelAction, registerAction)
Expand Down
24 changes: 0 additions & 24 deletions Wable-iOS/Presentation/Helper/AmplitudeManager.swift

This file was deleted.

24 changes: 23 additions & 1 deletion Wable-iOS/Presentation/Home/View/HomeDetailViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,8 @@ private extension HomeDetailViewController {
self.present(PhotoDetailViewController(image: image), animated: true)
},
likeButtonTapHandler: {
AmplitudeManager.shared.trackEvent(tag: .clickLikeComment)
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue

Fix incorrect event tag for content like action.

The event tag .clickLikeComment is being used for liking content/posts, but the tag name suggests it's for liking comments. This creates confusion in analytics data.

Apply this diff to use the correct event tag:

-                    AmplitudeManager.shared.trackEvent(tag: .clickLikeComment)
+                    AmplitudeManager.shared.trackEvent(tag: .clickLikePost)
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
AmplitudeManager.shared.trackEvent(tag: .clickLikeComment)
AmplitudeManager.shared.trackEvent(tag: .clickLikePost)
🤖 Prompt for AI Agents
In Wable-iOS/Presentation/Home/View/HomeDetailViewController.swift at line 224,
the event tag used for tracking the like action is incorrectly set to
.clickLikeComment, which implies liking a comment rather than content or posts.
Replace the event tag with the correct one that accurately represents liking
content, such as .clickLikeContent or the appropriate tag defined for content
likes, to ensure analytics data is accurate and clear.


self.didContentHeartTappedSubject.send(cell.likeButton.isLiked)
},
settingButtonTapHandler: {
Expand Down Expand Up @@ -316,14 +318,23 @@ private extension HomeDetailViewController {
}
},
ghostButtonTapHandler: {
AmplitudeManager.shared.trackEvent(tag: .clickGhostPost)

let viewController = WableSheetViewController(title: StringLiterals.Ghost.sheetTitle)

viewController.addActions(
WableSheetAction(title: "고민할게요", style: .gray),
WableSheetAction(
title: "고민할게요",
style: .gray,
handler: {
AmplitudeManager.shared.trackEvent(tag: .clickWithdrawghostPopup)
}),
WableSheetAction(
title: "네 맞아요",
style: .primary,
handler: {
AmplitudeManager.shared.trackEvent(tag: .clickApplyghostPopup)

viewController.dismiss(animated: true, completion: {
self.didGhostTappedSubject.send((item.content.id, item.content.contentInfo.author.id, .content))
})
Expand All @@ -336,6 +347,8 @@ private extension HomeDetailViewController {
)

cell.commentButton.addAction(UIAction(handler: { _ in
AmplitudeManager.shared.trackEvent(tag: .clickWriteComment)

self.createCommentButton.isEnabled = false
self.didCommentTappedSubject.send()

Expand Down Expand Up @@ -478,20 +491,26 @@ private extension HomeDetailViewController {
}
},
ghostButtonTapHandler: {
AmplitudeManager.shared.trackEvent(tag: .clickGhostComment)

let viewController = WableSheetViewController(title: StringLiterals.Ghost.sheetTitle)

viewController.addActions(
WableSheetAction(
title: "고민할게요",
style: .gray,
handler: {
AmplitudeManager.shared.trackEvent(tag: .clickWithdrawghostPopup)

viewController.dismiss(animated: true)
}
),
WableSheetAction(
title: "네 맞아요",
style: .primary,
handler: {
AmplitudeManager.shared.trackEvent(tag: .clickApplyghostPopup)

viewController.dismiss(animated: true, completion: {
self.didGhostTappedSubject.send((item.comment.id, item.comment.author.id, .comment))
})
Expand All @@ -502,6 +521,8 @@ private extension HomeDetailViewController {
self.present(viewController, animated: true)
},
replyButtonTapHandler: {
AmplitudeManager.shared.trackEvent(tag: .clickWriteRecomment)

self.createCommentButton.isEnabled = false
self.didReplyTappedSubject.send((item.comment.id, item.comment.author.id))

Expand Down Expand Up @@ -555,6 +576,7 @@ private extension HomeDetailViewController {
return
}

AmplitudeManager.shared.trackEvent(tag: .clickUploadComment)
self.didCreateTappedSubject.send(self.commentTextView.text)
}), for: .touchUpInside)

Expand Down
14 changes: 13 additions & 1 deletion Wable-iOS/Presentation/Home/View/HomeViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ private extension HomeViewController {
self.present(PhotoDetailViewController(image: image), animated: true)
},
likeButtonTapHandler: {
AmplitudeManager.shared.trackEvent(tag: .clickLikePost)

self.didHeartTappedSubject.send((item.content.id, cell.likeButton.isLiked))
},
settingButtonTapHandler: {
Expand All @@ -207,6 +209,8 @@ private extension HomeViewController {
title: "삭제하기",
style: .primary,
handler: {
AmplitudeManager.shared.trackEvent(tag: .clickDeletePost)

viewController.dismiss(animated: true, completion: {
self.didDeleteTappedSubject.send(item.content.id)
})
Expand Down Expand Up @@ -292,20 +296,24 @@ private extension HomeViewController {
}
},
ghostButtonTapHandler: {
AmplitudeManager.shared.trackEvent(tag: .clickGhostPost)

let viewController = WableSheetViewController(title: StringLiterals.Ghost.sheetTitle)

viewController.addActions(
WableSheetAction(
title: "고민할게요",
style: .gray,
handler: {
viewController.dismiss(animated: true)
AmplitudeManager.shared.trackEvent(tag: .clickWithdrawghostPopup)
}
),
WableSheetAction(
title: "네 맞아요",
style: .primary,
handler: {
AmplitudeManager.shared.trackEvent(tag: .clickApplyghostPopup)

viewController.dismiss(animated: true, completion: {
self.didGhostTappedSubject.send((item.content.id, item.content.contentInfo.author.id))
})
Expand Down Expand Up @@ -335,6 +343,8 @@ private extension HomeViewController {
navigationView.notificationButton.addAction(
UIAction(
handler: { _ in
AmplitudeManager.shared.trackEvent(tag: .clickNotiBotnavi)

let viewController = NotificationPageViewController()

self.navigationController?.pushViewController(viewController, animated: true)
Expand Down Expand Up @@ -491,6 +501,8 @@ extension HomeViewController {

private extension HomeViewController {
@objc func plusButtonDidTap() {
AmplitudeManager.shared.trackEvent(tag: .clickWritePost)

let viewController = WritePostViewController(
viewModel: WritePostViewModel(
createContentUseCase: CreateContentUseCase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,8 @@ private extension WritePostViewController {

private extension WritePostViewController {
@objc func addButtonDidTap() {
AmplitudeManager.shared.trackEvent(tag: .clickAttachPhoto)

switch PHPhotoLibrary.authorizationStatus(for: .addOnly) {
case .denied, .restricted:
presentSettings()
Expand All @@ -223,12 +225,13 @@ private extension WritePostViewController {
}

@objc func postButtonDidTap() {
AmplitudeManager.shared.trackEvent(tag: .clickUploadPost)

guard let title = titleTextView.text else { return }

let content = contentTextView.text == StringLiterals.Write.sheetMessage ? nil : contentTextView.text

postButtonTapRelay.send((title: title, content: content, image: imageView.image))
WableLogger.log("postButtonTapRelay 실행 완료", for: .debug)
}

@objc func popButtonDidTap() {
Expand Down
Loading