From b1af15e796b5b4b66d752a822c84c8c2ee40c090 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Sun, 21 Jan 2024 17:35:35 +0900 Subject: [PATCH 01/15] =?UTF-8?q?[Chore]=20#354=20-=20Amplitude=20?= =?UTF-8?q?=EB=B2=84=EC=A0=84=20=EC=97=85=EB=8D=B0=EC=9D=B4=ED=8A=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/Sources/{Enum => Amplitude}/AmplitudeEventType.swift | 0 .../Projects/Core/Sources/Amplitude/AmplitudeInstance.swift | 2 +- SOPT-iOS/Tuist/Dependencies.swift | 2 +- 3 files changed, 2 insertions(+), 2 deletions(-) rename SOPT-iOS/Projects/Core/Sources/{Enum => Amplitude}/AmplitudeEventType.swift (100%) diff --git a/SOPT-iOS/Projects/Core/Sources/Enum/AmplitudeEventType.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift similarity index 100% rename from SOPT-iOS/Projects/Core/Sources/Enum/AmplitudeEventType.swift rename to SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift index 6663be8e..6edb71ae 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift @@ -32,7 +32,7 @@ public extension Amplitude { func trackWithUserType(event: AmplitudeEventType) { let eventType: String = event.rawValue let userType = UserDefaultKeyList.Auth.getUserType() - var eventProperties: [String: Any] = ["view_type": userType.rawValue.lowercased()] + let eventProperties: [String: Any] = ["view_type": userType.rawValue.lowercased()] AmplitudeInstance.shared.track(eventType: eventType, eventProperties: eventProperties, options: nil) } diff --git a/SOPT-iOS/Tuist/Dependencies.swift b/SOPT-iOS/Tuist/Dependencies.swift index fc5caba4..1213d1a4 100644 --- a/SOPT-iOS/Tuist/Dependencies.swift +++ b/SOPT-iOS/Tuist/Dependencies.swift @@ -20,7 +20,7 @@ let spm = SwiftPackageManagerDependencies([ .remote(url: "https://github.com/Quick/Quick.git", requirement: .upToNextMajor(from: "5.0.0")), .remote(url: "https://github.com/Quick/Nimble.git", requirement: .upToNextMajor(from: "10.0.0")), .remote(url: "https://github.com/airbnb/lottie-ios", requirement: .upToNextMajor(from: "4.1.3")), - .remote(url: "https://github.com/amplitude/Amplitude-Swift", requirement: .upToNextMajor(from: "0.5.0")) + .remote(url: "https://github.com/amplitude/Amplitude-Swift", requirement: .upToNextMajor(from: "1.0.0")) ], baseSettings: Settings.settings( configurations: XCConfig.framework )) From 8a34513ba84a872f607cd54223cb7307b754988a Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Sun, 21 Jan 2024 18:17:42 +0900 Subject: [PATCH 02/15] =?UTF-8?q?[Feat]=20#354=20-=20=ED=91=B8=EC=8B=9C=20?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=20=EB=8F=99=EC=9D=98=20=EC=97=AC=EB=B6=80?= =?UTF-8?q?=EB=A5=BC=20Amplitude=20User=20Properties=EC=97=90=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/Sources/Amplitude/AmplitudeInstance.swift | 9 +++++++++ .../Amplitude/AmplitudeUserPropertyKey.swift | 13 +++++++++++++ .../AppLifecycleAdapter/AppLifecycleAdapter.swift | 8 ++++++++ .../Sources/MainScene/ViewModel/MainViewModel.swift | 6 ++---- 4 files changed, 32 insertions(+), 4 deletions(-) create mode 100644 SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift index 6edb71ae..b594d3ae 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift @@ -36,4 +36,13 @@ public extension Amplitude { AmplitudeInstance.shared.track(eventType: eventType, eventProperties: eventProperties, options: nil) } + + func addPushNotificationAuthorizationIdentity(isAuthorized: Bool) { + let identify = Identify() + let key: AmplitudeUserPropertyKey = .notificationAuthorized + identify.set(property: key.rawValue, value: isAuthorized) + identify.unset(property: "testProperty") + + AmplitudeInstance.shared.identify(identify: identify) + } } diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift new file mode 100644 index 00000000..d294373f --- /dev/null +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift @@ -0,0 +1,13 @@ +// +// AmplitudeUserPropertyKey.swift +// Core +// +// Created by sejin on 1/21/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation + +public enum AmplitudeUserPropertyKey: String { + case notificationAuthorized = "notification_authorized" +} diff --git a/SOPT-iOS/Projects/Demo/Sources/AppLifecycleAdapter/AppLifecycleAdapter.swift b/SOPT-iOS/Projects/Demo/Sources/AppLifecycleAdapter/AppLifecycleAdapter.swift index e70f6201..a705ee42 100644 --- a/SOPT-iOS/Projects/Demo/Sources/AppLifecycleAdapter/AppLifecycleAdapter.swift +++ b/SOPT-iOS/Projects/Demo/Sources/AppLifecycleAdapter/AppLifecycleAdapter.swift @@ -31,6 +31,7 @@ extension AppLifecycleAdapter { .receive(on: DispatchQueue.main) .sink(receiveValue: { [weak self] _ in self?.reissureTokens() + self?.checkNotificationSetting() }).store(in: self.cancelBag) } @@ -44,4 +45,11 @@ extension AppLifecycleAdapter { self.authService.reissuance { _ in } } + + private func checkNotificationSetting() { + UNUserNotificationCenter.current().getNotificationSettings { setting in + let isNotificationAuthorized = setting.authorizationStatus == .authorized + AmplitudeInstance.shared.addPushNotificationAuthorizationIdentity(isAuthorized: isNotificationAuthorized) + } + } } diff --git a/SOPT-iOS/Projects/Features/MainFeature/Sources/MainScene/ViewModel/MainViewModel.swift b/SOPT-iOS/Projects/Features/MainFeature/Sources/MainScene/ViewModel/MainViewModel.swift index 7aa161e8..7ba8cb2d 100644 --- a/SOPT-iOS/Projects/Features/MainFeature/Sources/MainScene/ViewModel/MainViewModel.swift +++ b/SOPT-iOS/Projects/Features/MainFeature/Sources/MainScene/ViewModel/MainViewModel.swift @@ -235,10 +235,8 @@ extension MainViewModel { // APNS 권한 허용 확인 let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound] UNUserNotificationCenter.current().requestAuthorization(options: authOptions) { granted, error in - if let error = error { - print(error) - } - + if let error = error { print(error) } + AmplitudeInstance.shared.addPushNotificationAuthorizationIdentity(isAuthorized: granted) print("APNs-알림 권한 허용 유무 \(granted)") if granted { From c75735093bfb9563868f698e88d8b0573c424088 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Sun, 21 Jan 2024 19:55:52 +0900 Subject: [PATCH 03/15] =?UTF-8?q?[Chore]=20#354=20-=20=ED=91=B8=EC=8B=9C?= =?UTF-8?q?=20=EC=95=8C=EB=A6=BC=20=EB=8F=99=EC=9D=98=20=EC=97=AC=EB=B6=80?= =?UTF-8?q?=20User=20Property=20key=20=EB=B3=80=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Projects/Core/Sources/Amplitude/AmplitudeInstance.swift | 4 ++-- .../Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift index b594d3ae..9e2f79b0 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift @@ -29,7 +29,7 @@ public extension Amplitude { AmplitudeInstance.shared.track(eventType: eventType, eventProperties: eventProperties, options: nil) } - func trackWithUserType(event: AmplitudeEventType) { + func trackWithUserType(event: AmplitudeEventType, otherProperties: [String: Any]? = nil) { let eventType: String = event.rawValue let userType = UserDefaultKeyList.Auth.getUserType() let eventProperties: [String: Any] = ["view_type": userType.rawValue.lowercased()] @@ -39,7 +39,7 @@ public extension Amplitude { func addPushNotificationAuthorizationIdentity(isAuthorized: Bool) { let identify = Identify() - let key: AmplitudeUserPropertyKey = .notificationAuthorized + let key: AmplitudeUserPropertyKey = .statusOfPushNotification identify.set(property: key.rawValue, value: isAuthorized) identify.unset(property: "testProperty") diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift index d294373f..1abce01b 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift @@ -9,5 +9,5 @@ import Foundation public enum AmplitudeUserPropertyKey: String { - case notificationAuthorized = "notification_authorized" + case statusOfPushNotification = "status_of_push_notification" } From 0c58ffd29d212e1532657e4cbe0ad8d88e3c5480 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Sun, 21 Jan 2024 19:57:50 +0900 Subject: [PATCH 04/15] =?UTF-8?q?[Feat]=20#354=20-=20Amplitude=20EventProp?= =?UTF-8?q?ertyBuilder=20=EA=B5=AC=ED=98=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AmplitudeEventPropertyBuilder.swift | 29 +++++++++++++++++++ .../Amplitude/AmplitudeEventPropertyKey.swift | 18 ++++++++++++ ...plitudeEventPropertyValueConvertible.swift | 13 +++++++++ .../Sources/Amplitude/AmplitudeInstance.swift | 1 - 4 files changed, 60 insertions(+), 1 deletion(-) create mode 100644 SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyBuilder.swift create mode 100644 SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyKey.swift create mode 100644 SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyValueConvertible.swift diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyBuilder.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyBuilder.swift new file mode 100644 index 00000000..1a906f16 --- /dev/null +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyBuilder.swift @@ -0,0 +1,29 @@ +// +// AmplitudeEventPropertyBuilder.swift +// Core +// +// Created by sejin on 1/21/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation + +public class AmplitudeEventPropertyBuilder { + private var eventProperties = [String: Any]() + + public init() {} + + public func add(key: String, value: Any) -> Self { + self.eventProperties[key] = value + return self + } + + public func add(key: AmplitudeEventPropertyKey, value: AmplitudeEventPropertyValueConvertible) -> Self { + self.eventProperties[key.rawValue] = value.toString() + return self + } + + public func build() -> [String: Any] { + return eventProperties + } +} diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyKey.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyKey.swift new file mode 100644 index 00000000..521a27a4 --- /dev/null +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyKey.swift @@ -0,0 +1,18 @@ +// +// AmplitudeEventPropertyKey.swift +// Core +// +// Created by sejin on 1/21/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation + +public enum AmplitudeEventPropertyKey: String { + case viewType = "view_type" + case clickViewType = "click_view_type" + + // 콕 찌르기 피쳐 관련 Key + case viewProfile = "view_profile" // 멤버 프로필 id + case friendType = "friend_type" +} diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyValueConvertible.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyValueConvertible.swift new file mode 100644 index 00000000..ac227a7d --- /dev/null +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyValueConvertible.swift @@ -0,0 +1,13 @@ +// +// AmplitudeEventPropertyValueConvertible.swift +// Core +// +// Created by sejin on 1/21/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation + +public protocol AmplitudeEventPropertyValueConvertible { + func toString() -> String +} diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift index 9e2f79b0..b17ededd 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift @@ -41,7 +41,6 @@ public extension Amplitude { let identify = Identify() let key: AmplitudeUserPropertyKey = .statusOfPushNotification identify.set(property: key.rawValue, value: isAuthorized) - identify.unset(property: "testProperty") AmplitudeInstance.shared.identify(identify: identify) } From 6c0348d2ffe8beddd12d155f371b383ac3b7b65d Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Sun, 21 Jan 2024 20:11:18 +0900 Subject: [PATCH 05/15] =?UTF-8?q?[Feat]=20#354=20-=20AmplitudeEventType?= =?UTF-8?q?=EC=9D=98=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=EB=A5=BC=20=ED=81=B4?= =?UTF-8?q?=EB=A6=AD=EA=B3=BC=20=EB=B7=B0=20=EC=9D=B4=EB=B2=A4=ED=8A=B8?= =?UTF-8?q?=EB=A1=9C=20=EB=B6=84=EB=A6=AC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Amplitude/AmplitudeEventType.swift | 37 +++++++++++-------- .../Sources/Enum/ServiceTypeTransform.swift | 24 ++++++------ .../MainScene/ViewModel/MainViewModel.swift | 6 +-- 3 files changed, 36 insertions(+), 31 deletions(-) diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift index 807844d6..45705989 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift @@ -9,20 +9,25 @@ import Foundation public enum AmplitudeEventType: String { - // 서비스 클릭 이벤트 - case main = "view_apphome" - case alarm = "click_alarm" - case myPage = "click_mypage" - case attendacne = "click_attendance" - case group = "click_group" - case project = "click_project" - case member = "click_member" - case officialHomepage = "click_homepage" - case soptamp = "click_soptamp" - case instagram = "click_instagram" - case youtube = "click_youtube" - case review = "click_review" - case faq = "click_faq" - case playgroundCommunity = "click_playground_community" - case poke = "click_poke" + // 클릭 이벤트 + case clickAlarm = "click_alarm" + case clickMyPage = "click_mypage" + case clickAttendacne = "click_attendance" + case clickGroup = "click_group" + case clickProject = "click_project" + case clickMember = "click_member" + case clickOfficialHomepage = "click_homepage" + case clickSoptamp = "click_soptamp" + case clickInstagram = "click_instagram" + case clickYoutube = "click_youtube" + case clickReview = "click_review" + case clickFaq = "click_faq" + case clickPlaygroundCommunity = "click_playground_community" + case clickPoke = "click_poke" + case clickMemberProfile = "click_memberProfile" + case clickClickPoke = "clickPoke" + + // 뷰 이벤트 + case viewAppHome = "view_apphome" + case viewPokeOnboarding = "view_poke_onboarding" } diff --git a/SOPT-iOS/Projects/Core/Sources/Enum/ServiceTypeTransform.swift b/SOPT-iOS/Projects/Core/Sources/Enum/ServiceTypeTransform.swift index d8885d12..c96efe1f 100644 --- a/SOPT-iOS/Projects/Core/Sources/Enum/ServiceTypeTransform.swift +++ b/SOPT-iOS/Projects/Core/Sources/Enum/ServiceTypeTransform.swift @@ -11,16 +11,16 @@ import Foundation public extension ServiceType { var toAmplitudeEventType: AmplitudeEventType { switch self { - case .officialHomepage: return .officialHomepage - case .review: return .review - case .project: return .project - case .faq: return .faq - case .youtube: return .youtube - case .attendance: return .attendacne - case .member: return .member - case .group: return .group - case .instagram: return .instagram - case .playgroundCommunity: return .playgroundCommunity + case .officialHomepage: return .clickOfficialHomepage + case .review: return .clickReview + case .project: return .clickProject + case .faq: return .clickFaq + case .youtube: return .clickYoutube + case .attendance: return .clickAttendacne + case .member: return .clickMember + case .group: return .clickGroup + case .instagram: return .clickInstagram + case .playgroundCommunity: return .clickPlaygroundCommunity } } } @@ -28,8 +28,8 @@ public extension ServiceType { public extension AppServiceType { var toAmplitudeEventType: AmplitudeEventType { switch self { - case .soptamp: return .soptamp - case .poke: return .poke + case .soptamp: return .clickSoptamp + case .poke: return .clickPoke } } } diff --git a/SOPT-iOS/Projects/Features/MainFeature/Sources/MainScene/ViewModel/MainViewModel.swift b/SOPT-iOS/Projects/Features/MainFeature/Sources/MainScene/ViewModel/MainViewModel.swift index 7ba8cb2d..882d051e 100644 --- a/SOPT-iOS/Projects/Features/MainFeature/Sources/MainScene/ViewModel/MainViewModel.swift +++ b/SOPT-iOS/Projects/Features/MainFeature/Sources/MainScene/ViewModel/MainViewModel.swift @@ -78,14 +78,14 @@ extension MainViewModel { .sink { [weak self] _ in guard let self = self else { return } self.onNoticeButtonTap?() - self.trackAmplitude(event: .alarm) + self.trackAmplitude(event: .clickAlarm) }.store(in: cancelBag) input.myPageButtonTapped .sink { [weak self] _ in guard let self = self else { return } self.onMyPageButtonTap?(self.userType) - self.trackAmplitude(event: .myPage) + self.trackAmplitude(event: .clickMyPage) }.store(in: cancelBag) input.cellTapped @@ -147,7 +147,7 @@ extension MainViewModel { guard let self = self else { return } self.requestAuthorizationForNotification() self.useCase.getServiceState() - self.trackAmplitude(event: .main) + self.trackAmplitude(event: .viewAppHome) }.store(in: cancelBag) return output From c135c435dc9a6a900bc3e936307b77d85dc30b34 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Sun, 21 Jan 2024 20:42:49 +0900 Subject: [PATCH 06/15] =?UTF-8?q?[Feat]=20#354=20-=20=EC=98=A8=EB=B3=B4?= =?UTF-8?q?=EB=94=A9=20=EB=B7=B0=EC=9D=98=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=ED=8A=B8=EB=9E=98=ED=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AmplitudeEventPropertyBuilder.swift | 18 +++++++++++-- .../Sources/Amplitude/AmplitudeInstance.swift | 13 +++------- .../Sources/Utils/trackAmplitudeEvent.swift | 16 ------------ .../PokeAmplitudeEventPropertyValue.swift | 18 +++++++++++++ .../ViewModel/PokeOnboardingViewModel.swift | 25 +++++++++++++++++++ 5 files changed, 62 insertions(+), 28 deletions(-) delete mode 100644 SOPT-iOS/Projects/Core/Sources/Utils/trackAmplitudeEvent.swift create mode 100644 SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyBuilder.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyBuilder.swift index 1a906f16..540fe549 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyBuilder.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyBuilder.swift @@ -8,17 +8,31 @@ import Foundation -public class AmplitudeEventPropertyBuilder { +public class AmplitudeEventPropertyBuilder { private var eventProperties = [String: Any]() public init() {} + /// ViewType 은 UserType과 같다. + public func addViewType() -> Self { + let key: AmplitudeEventPropertyKey = .viewType + let userType = UserDefaultKeyList.Auth.getUserType() + let value = userType.rawValue.lowercased() + self.eventProperties[key.rawValue] = value + return self + } + public func add(key: String, value: Any) -> Self { self.eventProperties[key] = value return self } - public func add(key: AmplitudeEventPropertyKey, value: AmplitudeEventPropertyValueConvertible) -> Self { + public func add(key: AmplitudeEventPropertyKey, value: Any) -> Self { + self.eventProperties[key.rawValue] = value + return self + } + + public func add(key: AmplitudeEventPropertyKey, value: Value) -> Self { self.eventProperties[key.rawValue] = value.toString() return self } diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift index b17ededd..4ab9402e 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift @@ -16,15 +16,8 @@ public struct AmplitudeInstance { } public extension Amplitude { - func track(event: AmplitudeEventType, userType: UserType, otherProperties: [String: Any]? = nil) { - let eventType: String = event.rawValue - var eventProperties: [String: Any] = ["view_type": userType.rawValue.lowercased()] - - if let otherProperties = otherProperties { - for (key, value) in otherProperties { - eventProperties.updateValue(value, forKey: key) - } - } + func track(eventType: AmplitudeEventType, eventProperties: [String: Any]? = nil) { + let eventType: String = eventType.rawValue AmplitudeInstance.shared.track(eventType: eventType, eventProperties: eventProperties, options: nil) } @@ -41,7 +34,7 @@ public extension Amplitude { let identify = Identify() let key: AmplitudeUserPropertyKey = .statusOfPushNotification identify.set(property: key.rawValue, value: isAuthorized) - + AmplitudeInstance.shared.identify(identify: identify) } } diff --git a/SOPT-iOS/Projects/Core/Sources/Utils/trackAmplitudeEvent.swift b/SOPT-iOS/Projects/Core/Sources/Utils/trackAmplitudeEvent.swift deleted file mode 100644 index b00e3a83..00000000 --- a/SOPT-iOS/Projects/Core/Sources/Utils/trackAmplitudeEvent.swift +++ /dev/null @@ -1,16 +0,0 @@ -// -// trackAmplitudeEvent.swift -// Core -// -// Created by sejin on 2023/09/21. -// Copyright © 2023 SOPT-iOS. All rights reserved. -// - -import UIKit - -public extension UIViewController { - func track(event: AmplitudeEventType, otherProperties: [String: Any]? = nil) { - let userType = UserDefaultKeyList.Auth.getUserType() - AmplitudeInstance.shared.track(event: event, userType: userType, otherProperties: otherProperties) - } -} diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift new file mode 100644 index 00000000..5bb07c67 --- /dev/null +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift @@ -0,0 +1,18 @@ +// +// PokeAmplitudeEventPropertyValue.swift +// PokeFeature +// +// Created by sejin on 1/21/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation +import Core + +enum PokeAmplitudeEventPropertyValue: String, AmplitudeEventPropertyValueConvertible { + case onboarding = "onboarding" + + func toString() -> String { + self.rawValue + } +} diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeOnboardingScene/ViewModel/PokeOnboardingViewModel.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeOnboardingScene/ViewModel/PokeOnboardingViewModel.swift index 75b79b53..30d1bc8f 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeOnboardingScene/ViewModel/PokeOnboardingViewModel.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeOnboardingScene/ViewModel/PokeOnboardingViewModel.swift @@ -50,6 +50,7 @@ extension PokeOnboardingViewModel { input.viewDidLoaded .withUnretained(self) .sink(receiveValue: { [weak self] _ in + AmplitudeInstance.shared.trackWithUserType(event: .viewPokeOnboarding) self?.usecase.getRandomAcquaintances() }).store(in: cancelBag) @@ -68,11 +69,13 @@ extension PokeOnboardingViewModel { return value } .sink(receiveValue: { [weak self] userModel, messageModel in + self?.trackClickPokeEvent(playgroundId: userModel.playgroundId) self?.usecase.poke(userId: userModel.userId, message: messageModel) }).store(in: cancelBag) input.avatarTapped .sink(receiveValue: { [weak self] userModel in + self?.trackClickMemberProfileEvent(playgroundId: userModel.playgroundId) self?.onAvartarTapped?(String(describing: userModel.playgroundId)) }).store(in: cancelBag) @@ -116,3 +119,25 @@ extension PokeOnboardingViewModel { }.store(in: cancelBag) } } + +private extension PokeOnboardingViewModel { + func trackClickMemberProfileEvent(playgroundId: Int) { + let properties = AmplitudeEventPropertyBuilder() + .addViewType() + .add(key: .clickViewType, value: .onboarding) + .add(key: .viewProfile, value: playgroundId) + .build() + + AmplitudeInstance.shared.track(eventType: .clickMemberProfile, eventProperties: properties) + } + + func trackClickPokeEvent(playgroundId: Int) { + let properties = AmplitudeEventPropertyBuilder() + .addViewType() + .add(key: .clickViewType, value: .onboarding) + .add(key: .viewProfile, value: playgroundId) + .build() + + AmplitudeInstance.shared.track(eventType: .clickPoke, eventProperties: properties) + } +} From 2ae5ab7a6bb069d053283ab478eb0e5e0ed87dc7 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Sun, 21 Jan 2024 22:39:43 +0900 Subject: [PATCH 07/15] =?UTF-8?q?[Feat]=20#354=20-=20PokeMain=20=EB=B7=B0?= =?UTF-8?q?=EC=9D=98=20=EB=B2=84=ED=8A=BC=20=ED=84=B0=EC=B9=98=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=20=ED=8A=B8=EB=9E=98=ED=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Amplitude/AmplitudeEventType.swift | 5 +++- .../PokeAmplitudeEventPropertyValue.swift | 3 ++ .../ViewModel/PokeMainViewModel.swift | 30 +++++++++++++++++++ .../ViewModel/PokeOnboardingViewModel.swift | 2 +- 4 files changed, 38 insertions(+), 2 deletions(-) diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift index 45705989..da551eae 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift @@ -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" } diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift index 5bb07c67..d4acf5e8 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift @@ -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 diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/ViewModel/PokeMainViewModel.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/ViewModel/PokeMainViewModel.swift index 8519179f..7694ca35 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/ViewModel/PokeMainViewModel.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/ViewModel/PokeMainViewModel.swift @@ -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) @@ -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) @@ -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 } @@ -213,3 +232,14 @@ extension PokeMainViewModel { }.store(in: cancelBag) } } + +extension PokeMainViewModel { + private func trackClickPokeEvent(clickView: PokeAmplitudeEventPropertyValue) { + let properties = AmplitudeEventPropertyBuilder() + .addViewType() + .add(key: .clickViewType, value: clickView) + .build() + + AmplitudeInstance.shared.track(eventType: .clickPokeIcon, eventProperties: properties) + } +} diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeOnboardingScene/ViewModel/PokeOnboardingViewModel.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeOnboardingScene/ViewModel/PokeOnboardingViewModel.swift index 30d1bc8f..83d8eecb 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeOnboardingScene/ViewModel/PokeOnboardingViewModel.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeOnboardingScene/ViewModel/PokeOnboardingViewModel.swift @@ -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) } } From cb8472eb8786843f1bc1bc27c802eb21b4422771 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Sun, 21 Jan 2024 22:51:47 +0900 Subject: [PATCH 08/15] =?UTF-8?q?[Feat]=20#354=20-=20PokeMain=20=EB=A9=94?= =?UTF-8?q?=EC=9D=B8=20=EB=B7=B0=EC=9D=98=20=ED=94=84=EB=A1=9C=ED=95=84=20?= =?UTF-8?q?=EC=9D=B4=EB=AF=B8=EC=A7=80=20=ED=84=B0=EC=B9=98=20=EC=9D=B4?= =?UTF-8?q?=EB=B2=A4=ED=8A=B8=20=ED=8A=B8=EB=9E=98=ED=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PokeAmplitudeEventPropertyValue.swift | 1 + .../Sources/PokeMainScene/VC/PokeMainVC.swift | 14 +++++++++---- .../ViewModel/PokeMainViewModel.swift | 20 +++++++++++++++++-- 3 files changed, 29 insertions(+), 6 deletions(-) diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift index d4acf5e8..93473501 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift @@ -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 diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/VC/PokeMainVC.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/VC/PokeMainVC.swift index 8192a08a..0ce54f3c 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/VC/PokeMainVC.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/VC/PokeMainVC.swift @@ -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, diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/ViewModel/PokeMainViewModel.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/ViewModel/PokeMainViewModel.swift index 7694ca35..875dcd6e 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/ViewModel/PokeMainViewModel.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/ViewModel/PokeMainViewModel.swift @@ -45,7 +45,7 @@ public class PokeMainViewModel: let friendSectionKokButtonTap: Driver let nearbyFriendsSectionKokButtonTap: Driver let refreshRequest: Driver - let profileImageTap: Driver + let profileImageTap: Driver<(PokeUserModel?, PokeAmplitudeEventPropertyValue)> let randomUserSectionFriendProfileImageTap: Driver } @@ -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) @@ -242,4 +249,13 @@ extension PokeMainViewModel { AmplitudeInstance.shared.track(eventType: .clickPokeIcon, eventProperties: properties) } + + private func trackClickMemberProfileEvent(clickView: PokeAmplitudeEventPropertyValue) { + let properties = AmplitudeEventPropertyBuilder() + .addViewType() + .add(key: .clickViewType, value: clickView) + .build() + + AmplitudeInstance.shared.track(eventType: .clickMemberProfile, eventProperties: properties) + } } From 0594bbe814f69f677ec7a9cdb469e038d7422383 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Sun, 21 Jan 2024 23:08:00 +0900 Subject: [PATCH 09/15] =?UTF-8?q?[Feat]=20#354=20-=20PokeEventTracker=20?= =?UTF-8?q?=EC=83=9D=EC=84=B1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Amplitude/AmplitudeEventType.swift | 1 + .../Sources/Amplitude/PokeEventTracker.swift | 34 ++++++++++++++++ .../ViewModel/PokeMainViewModel.swift | 39 +++++-------------- 3 files changed, 45 insertions(+), 29 deletions(-) create mode 100644 SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeEventTracker.swift diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift index da551eae..b579cf49 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift @@ -33,4 +33,5 @@ public enum AmplitudeEventType: String { case viewAppHome = "view_apphome" case viewPokeOnboarding = "view_poke_onboarding" case viewPokeMain = "view_poke_main" + case viewPokeAlarmDetail = "view_poke_alarm_detail" } diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeEventTracker.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeEventTracker.swift new file mode 100644 index 00000000..fa19403a --- /dev/null +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeEventTracker.swift @@ -0,0 +1,34 @@ +// +// PokeEventTracker.swift +// PokeFeature +// +// Created by sejin on 1/21/24. +// Copyright © 2024 SOPT-iOS. All rights reserved. +// + +import Foundation +import Core + +struct PokeEventTracker { + func trackViewEvent(with viewEvent: AmplitudeEventType) { + AmplitudeInstance.shared.trackWithUserType(event: viewEvent) + } + + func trackClickPokeEvent(clickView: PokeAmplitudeEventPropertyValue) { + let properties = AmplitudeEventPropertyBuilder() + .addViewType() + .add(key: .clickViewType, value: clickView) + .build() + + AmplitudeInstance.shared.track(eventType: .clickPokeIcon, eventProperties: properties) + } + + func trackClickMemberProfileEvent(clickView: PokeAmplitudeEventPropertyValue) { + let properties = AmplitudeEventPropertyBuilder() + .addViewType() + .add(key: .clickViewType, value: clickView) + .build() + + AmplitudeInstance.shared.track(eventType: .clickMemberProfile, eventProperties: properties) + } +} diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/ViewModel/PokeMainViewModel.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/ViewModel/PokeMainViewModel.swift index 875dcd6e..deb339e1 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/ViewModel/PokeMainViewModel.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMainScene/ViewModel/PokeMainViewModel.swift @@ -33,6 +33,7 @@ public class PokeMainViewModel: private let useCase: PokeMainUseCase private let isRouteFromRoot: Bool private var cancelBag = CancelBag() + private let eventTracker = PokeEventTracker() // MARK: - Inputs @@ -94,19 +95,19 @@ extension PokeMainViewModel { }.store(in: cancelBag) input.viewDidLoad - .sink { _ in - AmplitudeInstance.shared.trackWithUserType(event: .viewPokeMain) + .sink { [weak self] _ in + self?.eventTracker.trackViewEvent(with: .viewPokeMain) }.store(in: cancelBag) input.naviBackButtonTap .sink { [weak self] _ in - AmplitudeInstance.shared.trackWithUserType(event: .clickPokeQuit) + self?.eventTracker.trackViewEvent(with: .clickPokeQuit) self?.onNaviBackTap?() }.store(in: cancelBag) input.pokedSectionHeaderButtonTap .sink { [weak self] _ in - AmplitudeInstance.shared.trackWithUserType(event: .clickPokeAlarmDetail) + self?.eventTracker.trackViewEvent(with: .clickPokeAlarmDetail) self?.onPokeNotificationsTap?() }.store(in: cancelBag) @@ -123,7 +124,7 @@ extension PokeMainViewModel { return value } .sink { [weak self] userModel, messageModel in - self?.trackClickPokeEvent(clickView: .pokeMainAlarm) + self?.eventTracker.trackClickPokeEvent(clickView: .pokeMainAlarm) self?.useCase.poke(userId: userModel.userId, message: messageModel, willBeNewFriend: userModel.isFirstMeet) }.store(in: cancelBag) @@ -148,25 +149,25 @@ extension PokeMainViewModel { input.profileImageTap .map { $0.1 } .sink { [weak self] clickView in - self?.trackClickMemberProfileEvent(clickView: clickView) + self?.eventTracker.trackClickMemberProfileEvent(clickView: clickView) }.store(in: cancelBag) input.randomUserSectionFriendProfileImageTap .compactMap { $0 } .sink { [weak self] playgroundId in - self?.trackClickMemberProfileEvent(clickView: .pokeMainRecommendMyFriend) + self?.eventTracker.trackClickMemberProfileEvent(clickView: .pokeMainRecommendMyFriend) self?.onProfileImageTapped?(playgroundId) }.store(in: cancelBag) // Amplitude 트래킹 input.friendSectionKokButtonTap .sink { [weak self] _ in - self?.trackClickPokeEvent(clickView: .pokeMainFriend) + self?.eventTracker.trackClickPokeEvent(clickView: .pokeMainFriend) }.store(in: cancelBag) input.nearbyFriendsSectionKokButtonTap .sink { [weak self] _ in - self?.trackClickPokeEvent(clickView: .pokeMainRecommendNotMyFriend) + self?.eventTracker.trackClickPokeEvent(clickView: .pokeMainRecommendNotMyFriend) }.store(in: cancelBag) return output @@ -239,23 +240,3 @@ extension PokeMainViewModel { }.store(in: cancelBag) } } - -extension PokeMainViewModel { - private func trackClickPokeEvent(clickView: PokeAmplitudeEventPropertyValue) { - let properties = AmplitudeEventPropertyBuilder() - .addViewType() - .add(key: .clickViewType, value: clickView) - .build() - - AmplitudeInstance.shared.track(eventType: .clickPokeIcon, eventProperties: properties) - } - - private func trackClickMemberProfileEvent(clickView: PokeAmplitudeEventPropertyValue) { - let properties = AmplitudeEventPropertyBuilder() - .addViewType() - .add(key: .clickViewType, value: clickView) - .build() - - AmplitudeInstance.shared.track(eventType: .clickMemberProfile, eventProperties: properties) - } -} From c87a8f98f28bf57047a0b2f968dc77ba06b3340e Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Sun, 21 Jan 2024 23:09:43 +0900 Subject: [PATCH 10/15] =?UTF-8?q?[Feat]=20#354=20-=20PokeNotification=20?= =?UTF-8?q?=EB=B7=B0=EC=9D=98=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=ED=8A=B8?= =?UTF-8?q?=EB=9E=98=ED=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Amplitude/PokeAmplitudeEventPropertyValue.swift | 1 + .../ViewModel/PokeNotificationViewModel.swift | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift index 93473501..55fa48cd 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift @@ -15,6 +15,7 @@ enum PokeAmplitudeEventPropertyValue: String, AmplitudeEventPropertyValueConvert case pokeMainFriend = "poke_main_friend" case pokeMainRecommendNotMyFriend = "poke_main_recommend_notmyfriend" case pokeMainRecommendMyFriend = "poke_main_recommend_myfriend" + case pokeAlarm = "poke_alarm" func toString() -> String { self.rawValue diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeNotificationScene/ViewModel/PokeNotificationViewModel.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeNotificationScene/ViewModel/PokeNotificationViewModel.swift index 814d3243..e299d674 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeNotificationScene/ViewModel/PokeNotificationViewModel.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeNotificationScene/ViewModel/PokeNotificationViewModel.swift @@ -32,6 +32,7 @@ public final class PokeNotificationViewModel: PokeNotificationViewModelType { private let usecase: PokeNotificationUsecase private let cancelBag = CancelBag() + private let eventTracker = PokeEventTracker() init(usecase: PokeNotificationUsecase) { self.usecase = usecase @@ -43,6 +44,11 @@ extension PokeNotificationViewModel { let output = Output() self.bindOutput(output: output, cancelBag: cancelBag) + input.viewDidLoaded + .sink { [weak self] _ in + self?.eventTracker.trackViewEvent(with: .viewPokeAlarmDetail) + }.store(in: cancelBag) + input.viewDidLoaded .merge(with: input.reachToBottom) .sink(receiveValue: { [weak self] _ in @@ -56,6 +62,7 @@ extension PokeNotificationViewModel { return value } .sink(receiveValue: { [weak self] userModel, messageModel in + self?.eventTracker.trackClickPokeEvent(clickView: .pokeAlarm) self?.usecase.poke(user: userModel, message: messageModel) }).store(in: cancelBag) From 129660f7a2a7cee0df7a52241b50907979bb9d8d Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Sun, 21 Jan 2024 23:15:10 +0900 Subject: [PATCH 11/15] =?UTF-8?q?[Feat]=20#354=20-=20PokeMyFriends=20?= =?UTF-8?q?=EB=B7=B0=EC=9D=98=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=ED=8A=B8?= =?UTF-8?q?=EB=9E=98=ED=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Amplitude/AmplitudeEventType.swift | 1 + .../PokeAmplitudeEventPropertyValue.swift | 1 + .../Sources/Amplitude/PokeEventTracker.swift | 20 +++++++++++++ .../ViewModel/PokeMyFriendsViewModel.swift | 4 +++ .../ViewModel/PokeOnboardingViewModel.swift | 28 +++---------------- 5 files changed, 30 insertions(+), 24 deletions(-) diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift index b579cf49..34a9752f 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift @@ -34,4 +34,5 @@ public enum AmplitudeEventType: String { case viewPokeOnboarding = "view_poke_onboarding" case viewPokeMain = "view_poke_main" case viewPokeAlarmDetail = "view_poke_alarm_detail" + case viewPokeFriend = "view_poke_friend" } diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift index 55fa48cd..dff0fb96 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeAmplitudeEventPropertyValue.swift @@ -16,6 +16,7 @@ enum PokeAmplitudeEventPropertyValue: String, AmplitudeEventPropertyValueConvert case pokeMainRecommendNotMyFriend = "poke_main_recommend_notmyfriend" case pokeMainRecommendMyFriend = "poke_main_recommend_myfriend" case pokeAlarm = "poke_alarm" + case friend = "friend" func toString() -> String { self.rawValue diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeEventTracker.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeEventTracker.swift index fa19403a..ac966bac 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeEventTracker.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeEventTracker.swift @@ -23,6 +23,16 @@ struct PokeEventTracker { AmplitudeInstance.shared.track(eventType: .clickPokeIcon, eventProperties: properties) } + func trackClickPokeEvent(clickView: PokeAmplitudeEventPropertyValue, playgroundId: Int) { + let properties = AmplitudeEventPropertyBuilder() + .addViewType() + .add(key: .clickViewType, value: clickView) + .add(key: .viewProfile, value: playgroundId) + .build() + + AmplitudeInstance.shared.track(eventType: .clickPokeIcon, eventProperties: properties) + } + func trackClickMemberProfileEvent(clickView: PokeAmplitudeEventPropertyValue) { let properties = AmplitudeEventPropertyBuilder() .addViewType() @@ -31,4 +41,14 @@ struct PokeEventTracker { AmplitudeInstance.shared.track(eventType: .clickMemberProfile, eventProperties: properties) } + + func trackClickMemberProfileEvent(clickView: PokeAmplitudeEventPropertyValue, playgroundId: Int) { + let properties = AmplitudeEventPropertyBuilder() + .addViewType() + .add(key: .clickViewType, value: clickView) + .add(key: .viewProfile, value: playgroundId) + .build() + + AmplitudeInstance.shared.track(eventType: .clickMemberProfile, eventProperties: properties) + } } diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMyFriendsScene/ViewModel/PokeMyFriendsViewModel.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMyFriendsScene/ViewModel/PokeMyFriendsViewModel.swift index ccb08bf2..fcbbfa5b 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMyFriendsScene/ViewModel/PokeMyFriendsViewModel.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMyFriendsScene/ViewModel/PokeMyFriendsViewModel.swift @@ -27,6 +27,7 @@ public class PokeMyFriendsViewModel: private let useCase: PokeMyFriendsUseCase private var cancelBag = CancelBag() private var myFriends: PokeMyFriendsModel? + private let eventTracker = PokeEventTracker() // MARK: - Inputs @@ -58,6 +59,7 @@ extension PokeMyFriendsViewModel { input.viewDidLoad .withUnretained(self) .sink { owner, _ in + owner.eventTracker.trackViewEvent(with: .viewPokeFriend) owner.useCase.getFriends() }.store(in: cancelBag) @@ -74,12 +76,14 @@ extension PokeMyFriendsViewModel { return value } .sink {[weak self] userModel, messageModel in + self?.eventTracker.trackClickPokeEvent(clickView: .friend, playgroundId: userModel.playgroundId) self?.useCase.poke(userId: userModel.userId, message: messageModel) }.store(in: cancelBag) input.profileImageTap .compactMap { $0 } .sink { [weak self] user in + self?.eventTracker.trackClickMemberProfileEvent(clickView: .friend, playgroundId: user.playgroundId) self?.onProfileImageTapped?(user.playgroundId) }.store(in: cancelBag) diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeOnboardingScene/ViewModel/PokeOnboardingViewModel.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeOnboardingScene/ViewModel/PokeOnboardingViewModel.swift index 83d8eecb..b4a52e5c 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeOnboardingScene/ViewModel/PokeOnboardingViewModel.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeOnboardingScene/ViewModel/PokeOnboardingViewModel.swift @@ -35,6 +35,8 @@ public final class PokeOnboardingViewModel: PokeOnboardingViewModelType { // MARK: Privates private let usecase: PokeOnboardingUsecase + private let eventTracker = PokeEventTracker() + // MARK: - Lifecycles public init(usecase: PokeOnboardingUsecase) { @@ -69,13 +71,13 @@ extension PokeOnboardingViewModel { return value } .sink(receiveValue: { [weak self] userModel, messageModel in - self?.trackClickPokeEvent(playgroundId: userModel.playgroundId) + self?.eventTracker.trackClickPokeEvent(clickView: .onboarding, playgroundId: userModel.playgroundId) self?.usecase.poke(userId: userModel.userId, message: messageModel) }).store(in: cancelBag) input.avatarTapped .sink(receiveValue: { [weak self] userModel in - self?.trackClickMemberProfileEvent(playgroundId: userModel.playgroundId) + self?.eventTracker.trackClickMemberProfileEvent(clickView: .onboarding, playgroundId: userModel.playgroundId) self?.onAvartarTapped?(String(describing: userModel.playgroundId)) }).store(in: cancelBag) @@ -119,25 +121,3 @@ extension PokeOnboardingViewModel { }.store(in: cancelBag) } } - -private extension PokeOnboardingViewModel { - func trackClickMemberProfileEvent(playgroundId: Int) { - let properties = AmplitudeEventPropertyBuilder() - .addViewType() - .add(key: .clickViewType, value: .onboarding) - .add(key: .viewProfile, value: playgroundId) - .build() - - AmplitudeInstance.shared.track(eventType: .clickMemberProfile, eventProperties: properties) - } - - func trackClickPokeEvent(playgroundId: Int) { - let properties = AmplitudeEventPropertyBuilder() - .addViewType() - .add(key: .clickViewType, value: .onboarding) - .add(key: .viewProfile, value: playgroundId) - .build() - - AmplitudeInstance.shared.track(eventType: .clickPokeIcon, eventProperties: properties) - } -} From 0ef13a2fc6c1b0dd01403384d6d4009ea3006cd1 Mon Sep 17 00:00:00 2001 From: Sejin Lee Date: Sun, 21 Jan 2024 23:42:11 +0900 Subject: [PATCH 12/15] =?UTF-8?q?[Feat]=20#354=20-=20PokeMyFriendsList=20?= =?UTF-8?q?=EB=B7=B0=EC=9D=98=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20=ED=8A=B8?= =?UTF-8?q?=EB=9E=98=ED=82=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AmplitudeEventPropertyBuilder.swift | 10 +++++++ .../Amplitude/AmplitudeEventType.swift | 1 + .../Interface/Sources/Enum/PokeRelation.swift | 15 ++++++++++- .../Sources/Amplitude/PokeEventTracker.swift | 26 +++++++------------ .../PokeMyFriendsListViewModel.swift | 7 +++++ 5 files changed, 42 insertions(+), 17 deletions(-) diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyBuilder.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyBuilder.swift index 540fe549..9a89e0c4 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyBuilder.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventPropertyBuilder.swift @@ -32,11 +32,21 @@ public class AmplitudeEventPropertyBuilder) -> Self { + self.eventProperties[key.rawValue] = value + return self + } + public func add(key: AmplitudeEventPropertyKey, value: Value) -> Self { self.eventProperties[key.rawValue] = value.toString() return self } + public func removeOptional() -> Self { + self.eventProperties = self.eventProperties.compactMapValues { $0 } + return self + } + public func build() -> [String: Any] { return eventProperties } diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift index 34a9752f..d2ce7b5b 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift @@ -35,4 +35,5 @@ public enum AmplitudeEventType: String { case viewPokeMain = "view_poke_main" case viewPokeAlarmDetail = "view_poke_alarm_detail" case viewPokeFriend = "view_poke_friend" + case viewPokeFriendDetail = "view_poke_friend_detail" } diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Interface/Sources/Enum/PokeRelation.swift b/SOPT-iOS/Projects/Features/PokeFeature/Interface/Sources/Enum/PokeRelation.swift index 6690a753..c202e649 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Interface/Sources/Enum/PokeRelation.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Interface/Sources/Enum/PokeRelation.swift @@ -15,4 +15,17 @@ public enum PokeRelation: String { case soulmate = "천생연분" } - +extension PokeRelation { + public var toEnglishName: String { + switch self { + case .nonFriend: + return "nonFriend" + case .newFriend: + return "newFriend" + case .bestFriend: + return "bestFriend" + case .soulmate: + return "soulmate" + } + } +} diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeEventTracker.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeEventTracker.swift index ac966bac..0557f6a2 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeEventTracker.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/Amplitude/PokeEventTracker.swift @@ -8,45 +8,39 @@ import Foundation import Core +import PokeFeatureInterface struct PokeEventTracker { func trackViewEvent(with viewEvent: AmplitudeEventType) { AmplitudeInstance.shared.trackWithUserType(event: viewEvent) } - func trackClickPokeEvent(clickView: PokeAmplitudeEventPropertyValue) { + func trackViewFriendsListEvent(friendType: PokeRelation) { let properties = AmplitudeEventPropertyBuilder() .addViewType() - .add(key: .clickViewType, value: clickView) + .add(key: .friendType, value: friendType.toEnglishName) .build() - AmplitudeInstance.shared.track(eventType: .clickPokeIcon, eventProperties: properties) + AmplitudeInstance.shared.track(eventType: .viewPokeFriendDetail, eventProperties: properties) } - - func trackClickPokeEvent(clickView: PokeAmplitudeEventPropertyValue, playgroundId: Int) { + + func trackClickPokeEvent(clickView: PokeAmplitudeEventPropertyValue, playgroundId: Int? = nil) { let properties = AmplitudeEventPropertyBuilder() .addViewType() .add(key: .clickViewType, value: clickView) .add(key: .viewProfile, value: playgroundId) + .removeOptional() .build() AmplitudeInstance.shared.track(eventType: .clickPokeIcon, eventProperties: properties) } - - func trackClickMemberProfileEvent(clickView: PokeAmplitudeEventPropertyValue) { - let properties = AmplitudeEventPropertyBuilder() - .addViewType() - .add(key: .clickViewType, value: clickView) - .build() - - AmplitudeInstance.shared.track(eventType: .clickMemberProfile, eventProperties: properties) - } - - func trackClickMemberProfileEvent(clickView: PokeAmplitudeEventPropertyValue, playgroundId: Int) { + + func trackClickMemberProfileEvent(clickView: PokeAmplitudeEventPropertyValue, playgroundId: Int? = nil) { let properties = AmplitudeEventPropertyBuilder() .addViewType() .add(key: .clickViewType, value: clickView) .add(key: .viewProfile, value: playgroundId) + .removeOptional() .build() AmplitudeInstance.shared.track(eventType: .clickMemberProfile, eventProperties: properties) diff --git a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMyFriendsListScene/ViewModel/PokeMyFriendsListViewModel.swift b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMyFriendsListScene/ViewModel/PokeMyFriendsListViewModel.swift index 81a6afd1..af1a855e 100644 --- a/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMyFriendsListScene/ViewModel/PokeMyFriendsListViewModel.swift +++ b/SOPT-iOS/Projects/Features/PokeFeature/Sources/PokeMyFriendsListScene/ViewModel/PokeMyFriendsListViewModel.swift @@ -26,6 +26,7 @@ public class PokeMyFriendsListViewModel: private let useCase: PokeMyFriendsUseCase private var cancelBag = CancelBag() + private let eventTracker = PokeEventTracker() public let relation: PokeRelation var friends = [PokeUserModel]() @@ -64,6 +65,12 @@ extension PokeMyFriendsListViewModel { let output = Output() self.bindOutput(output: output, cancelBag: cancelBag) + input.viewDidLoad + .sink { [weak self] _ in + guard let self = self else { return } + self.eventTracker.trackViewFriendsListEvent(friendType: self.relation) + }.store(in: cancelBag) + input.viewDidLoad .merge(with: input.reachToBottom) .withUnretained(self) From db3287928a31632b6b8487cf56b71310294a0e95 Mon Sep 17 00:00:00 2001 From: Lee SeJin Date: Mon, 22 Jan 2024 23:34:28 +0900 Subject: [PATCH 13/15] =?UTF-8?q?[Fix]=20#354=20-=20=EB=A9=A4=EB=B2=84=20?= =?UTF-8?q?=ED=94=84=EB=A1=9C=ED=95=84=20=EC=9D=B4=EB=B2=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=9D=B4=EB=A6=84=20=EC=86=8C=EB=AC=B8=EC=9E=90=EB=A1=9C=20?= =?UTF-8?q?=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Projects/Core/Sources/Amplitude/AmplitudeEventType.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift index d2ce7b5b..6c9fa32c 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeEventType.swift @@ -24,7 +24,7 @@ public enum AmplitudeEventType: String { case clickFaq = "click_faq" case clickPlaygroundCommunity = "click_playground_community" case clickPoke = "click_poke" - case clickMemberProfile = "click_memberProfile" + case clickMemberProfile = "click_memberprofile" case clickPokeIcon = "click_poke_icon" case clickPokeAlarmDetail = "click_poke_alarm_detail" case clickPokeQuit = "click_poke_quit" From f4d16dd293b153586d8b5b836bb7690d060a3c22 Mon Sep 17 00:00:00 2001 From: Lee SeJin Date: Mon, 22 Jan 2024 23:42:03 +0900 Subject: [PATCH 14/15] =?UTF-8?q?[Fix]=20#354=20-=20=ED=91=B8=EC=8B=9C=20?= =?UTF-8?q?=EC=95=8C=EB=A6=BC=20=EB=8F=99=EC=9D=98=20=EC=97=AC=EB=B6=80=20?= =?UTF-8?q?User=20Property=20=ED=82=A4=20=EC=9D=B4=EB=A6=84=20=EB=B3=80?= =?UTF-8?q?=EA=B2=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift index 1abce01b..a439dbbb 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift @@ -9,5 +9,5 @@ import Foundation public enum AmplitudeUserPropertyKey: String { - case statusOfPushNotification = "status_of_push_notification" + case statusOfPushNotification = "state_of_push_notification" } From 23dc252a22661317293df6d6bd451ae10383121e Mon Sep 17 00:00:00 2001 From: Lee SeJin Date: Tue, 23 Jan 2024 00:49:20 +0900 Subject: [PATCH 15/15] =?UTF-8?q?[Fix]=20#354=20-=20=EC=9D=B4=EB=B2=A4?= =?UTF-8?q?=ED=8A=B8=20=EB=B3=80=EC=88=98=EB=AA=85=20=EC=88=98=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Projects/Core/Sources/Amplitude/AmplitudeInstance.swift | 4 ++-- .../Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift index 4ab9402e..2cb77eae 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeInstance.swift @@ -25,14 +25,14 @@ public extension Amplitude { func trackWithUserType(event: AmplitudeEventType, otherProperties: [String: Any]? = nil) { let eventType: String = event.rawValue let userType = UserDefaultKeyList.Auth.getUserType() - let eventProperties: [String: Any] = ["view_type": userType.rawValue.lowercased()] + let eventProperties: [String: Any] = [AmplitudeEventPropertyKey.viewType.rawValue: userType.rawValue.lowercased()] AmplitudeInstance.shared.track(eventType: eventType, eventProperties: eventProperties, options: nil) } func addPushNotificationAuthorizationIdentity(isAuthorized: Bool) { let identify = Identify() - let key: AmplitudeUserPropertyKey = .statusOfPushNotification + let key: AmplitudeUserPropertyKey = .stateOfPushNotification identify.set(property: key.rawValue, value: isAuthorized) AmplitudeInstance.shared.identify(identify: identify) diff --git a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift index a439dbbb..dc8edb3f 100644 --- a/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift +++ b/SOPT-iOS/Projects/Core/Sources/Amplitude/AmplitudeUserPropertyKey.swift @@ -9,5 +9,5 @@ import Foundation public enum AmplitudeUserPropertyKey: String { - case statusOfPushNotification = "state_of_push_notification" + case stateOfPushNotification = "state_of_push_notification" }