Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

πŸ”€ :: (#1189) λˆ„λ½ 둜그 및 μˆ˜μ •,μΆ”κ°€λœ 둜그 μž‘μ—… #1192

Merged
merged 2 commits into from
Aug 19, 2024
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
17 changes: 17 additions & 0 deletions Projects/App/Sources/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ final class AppDelegate: UIResponder, UIApplicationDelegate {
} else {
LogManager.setUserID(userID: nil)
}
initializeUserProperty()

Analytics.logEvent(AnalyticsEventAppOpen, parameters: nil)

Expand Down Expand Up @@ -116,6 +117,22 @@ extension AppDelegate {
}
}
}

private func initializeUserProperty() {
if let loginPlatform = PreferenceManager.userInfo?.platform {
LogManager.setUserProperty(property: .loginPlatform(platform: loginPlatform))
} else {
LogManager.clearUserProperty(property: .loginPlatform(platform: ""))
}

if let fruitTotal = PreferenceManager.userInfo?.itemCount {
LogManager.setUserProperty(property: .fruitTotal(count: fruitTotal))
} else {
LogManager.clearUserProperty(property: .fruitTotal(count: -1))
}

LogManager.setUserProperty(property: .playlistSongTotal(count: PlayState.shared.count))
}
}

#if DEBUG || QA
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,4 @@ enum ArtistAnalyticsLog: AnalyticsLogType {
case clickArtistSubscriptionButton(artist: String)
case clickArtistPlayButton(type: String, artist: String)
case clickArtistTabbarTab(tab: String, artist: String)
case selectMusicItem(id: String, location: String)
case deselectMusicItem(id: String, location: String)
KangTaeHoon marked this conversation as resolved.
Show resolved Hide resolved
}
Original file line number Diff line number Diff line change
Expand Up @@ -107,13 +107,15 @@ private extension ArtistDetailViewController {
.disposed(by: disposeBag)

output.showLogin
.bind(with: self) { owner, _ in
.bind(with: self) { owner, entry in
let viewController = owner.textPopupFactory.makeView(
text: "둜그인이 ν•„μš”ν•œ μ„œλΉ„μŠ€μž…λ‹ˆλ‹€.\n둜그인 ν•˜μ‹œκ² μŠ΅λ‹ˆκΉŒ?",
cancelButtonIsHidden: false,
confirmButtonText: nil,
cancelButtonText: nil,
completion: {
let log = CommonAnalyticsLog.clickLoginButton(entry: entry)
LogManager.analytics(log)
let loginVC = owner.signInFactory.makeView()
loginVC.modalPresentationStyle = .fullScreen
owner.present(loginVC, animated: true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,9 @@ private extension ArtistMusicContentViewController {
confirmButtonText: nil,
cancelButtonText: nil,
completion: {
let log = CommonAnalyticsLog.clickLoginButton(entry: .addMusics)
LogManager.analytics(log)

let loginVC = owner.signInFactory.makeView()
loginVC.modalPresentationStyle = .overFullScreen
owner.present(loginVC, animated: true)
Expand Down Expand Up @@ -230,8 +233,11 @@ extension ArtistMusicContentViewController: SongCartViewDelegate {
input.allSongSelected.onNext(flag)

case .addSong:
let log = CommonAnalyticsLog.clickAddMusicsButton(location: .artist)
LogManager.analytics(log)

if PreferenceManager.userInfo == nil {
output.showLogin.onNext(())
output.showLogin.onNext(.addMusics)
return
}
guard songs.count <= limit else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public final class ArtistDetailViewModel: ViewModelType {
let dataSource: BehaviorRelay<ArtistEntity?> = BehaviorRelay(value: nil)
let isSubscription: BehaviorRelay<Bool> = BehaviorRelay(value: false)
let showToast: PublishSubject<String> = PublishSubject()
let showLogin: PublishSubject<Void> = PublishSubject()
let showLogin: PublishSubject<CommonAnalyticsLog.LoginButtonEntry> = PublishSubject()
let showWarningNotification: PublishSubject<Void> = PublishSubject()
let occurredError: PublishSubject<String> = PublishSubject()
}
Expand Down Expand Up @@ -84,7 +84,7 @@ public final class ArtistDetailViewModel: ViewModelType {
.withLatestFrom(PreferenceManager.$userInfo)
.filter { userInfo in
if userInfo == nil {
output.showLogin.onNext(())
output.showLogin.onNext(.artistSubscribe)
return false
}
return true
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public final class ArtistMusicContentViewModel: ViewModelType {
let indexOfSelectedSongs: BehaviorRelay<[Int]> = BehaviorRelay(value: [])
let songEntityOfSelectedSongs: BehaviorRelay<[SongEntity]> = BehaviorRelay(value: [])
let showToast: PublishSubject<String> = .init()
let showLogin: PublishSubject<Void> = .init()
let showLogin: PublishSubject<CommonAnalyticsLog.LoginButtonEntry> = .init()
}

public func transform(from input: Input) -> Output {
Expand Down Expand Up @@ -81,15 +81,12 @@ public final class ArtistMusicContentViewModel: ViewModelType {
.withLatestFrom(output.indexOfSelectedSongs, resultSelector: { index, selectedSongs -> [Int] in
let songID: String = output.dataSource.value[index].songID
if selectedSongs.contains(index) {
LogManager.analytics(ArtistAnalyticsLog.deselectMusicItem(id: songID, location: "artist"))
guard let removeTargetIndex = selectedSongs.firstIndex(where: { $0 == index })
else { return selectedSongs }
var newSelectedSongs = selectedSongs
newSelectedSongs.remove(at: removeTargetIndex)
return newSelectedSongs

} else {
LogManager.analytics(ArtistAnalyticsLog.selectMusicItem(id: songID, location: "artist"))
return selectedSongs + [index]
}
})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import LogManager

enum ContainSongsAnalyticsLog: AnalyticsLogType {
case clickCreatePlaylistButton(location: CreatePlaylistLocation)
case completeAddMusics(playlistId: String, count: Int)
}

enum CreatePlaylistLocation: String, AnalyticsLogEnumParametable {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import Combine
import Foundation
import LogManager
import SongsDomainInterface
import Utility

Expand Down Expand Up @@ -40,6 +41,7 @@ public final class PlayState {
playlist.subscribeListChanges()
.map { Array($0) }
.sink { [weak self] playlistItems in
LogManager.setUserProperty(property: .playlistSongTotal(count: playlistItems.count))
self?.updatePlaylistChangesToLocalDB(playList: playlistItems)
}
.store(in: &subscription)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import BaseDomainInterface
import ErrorModule
import Foundation
import Localization
import LogManager
import PlaylistDomainInterface
import PriceDomainInterface
import RxRelay
Expand Down Expand Up @@ -131,6 +132,13 @@ public final class ContainSongsViewModel: ViewModelType {

return self.addSongIntoPlaylistUseCase
.execute(key: model.key, songs: self.songs)
.do(onSuccess: { _ in
let log = ContainSongsAnalyticsLog.completeAddMusics(
playlistId: model.key,
count: self.songs.count
)
LogManager.analytics(log)
})
.catch { (error: Error) in
let wmError = error.asWMError

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,9 @@ private extension ChartContentViewController {
confirmButtonText: nil,
cancelButtonText: nil,
completion: {
let log = CommonAnalyticsLog.clickLoginButton(entry: .addMusics)
LogManager.analytics(log)

let loginVC = owner.signInFactory.makeView()
loginVC.modalPresentationStyle = .overFullScreen
owner.present(loginVC, animated: true)
Expand Down Expand Up @@ -264,6 +267,8 @@ extension ChartContentViewController: SongCartViewDelegate {
input.allSongSelected.onNext(flag)

case .addSong:
let log = CommonAnalyticsLog.clickAddMusicsButton(location: .chart)
LogManager.analytics(log)
if PreferenceManager.userInfo == nil {
output.showLogin.onNext(())
return
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import BaseFeature
import CreditDomainInterface
import CreditSongListFeatureInterface
import Localization
import LogManager
import ReactorKit
import RxSwift
import Utility
Expand Down Expand Up @@ -167,6 +168,9 @@ private extension CreditSongListTabItemReactor {
navigateType: .textPopup(
text: LocalizationStrings.needLoginWarning,
completion: { [signInIsRequiredSubject] in
let log = CommonAnalyticsLog.clickLoginButton(entry: .addMusics)
LogManager.analytics(log)

signInIsRequiredSubject.onNext(())
}
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import BaseFeature
import BaseFeatureInterface
import CreditSongListFeatureInterface
import DesignSystem
import LogManager
import RxSwift
import SignInFeatureInterface
import Then
Expand Down Expand Up @@ -46,6 +47,9 @@ final class CreditSongListTabItemViewController:
elementKind: UICollectionView.elementKindSectionHeader
) { [reactor] headerView, _, _ in
headerView.setPlayButtonHandler {
let log = CommonAnalyticsLog.clickPlayButton(location: .creditSongList, type: .random)
LogManager.analytics(log)

reactor?.action.onNext(.randomPlayButtonDidTap)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,9 @@ private extension NewSongsContentViewController {
confirmButtonText: nil,
cancelButtonText: nil,
completion: {
let log = CommonAnalyticsLog.clickLoginButton(entry: .addMusics)
LogManager.analytics(log)

let loginVC = owner.signInFactory.makeView()
loginVC.modalPresentationStyle = .overFullScreen
owner.present(loginVC, animated: true)
Expand Down Expand Up @@ -274,6 +277,9 @@ extension NewSongsContentViewController: SongCartViewDelegate {
input.allSongSelected.onNext(flag)

case .addSong:
let log = CommonAnalyticsLog.clickAddMusicsButton(location: .recentMusic)
LogManager.analytics(log)

if PreferenceManager.userInfo == nil {
output.showLogin.onNext(())
return
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import LogManager

enum NoticePopupAnalyticsLog: AnalyticsLogType {
case clickNoticeItem(id: String, location: String = "notice_popup")
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import BaseFeature
import DesignSystem
import LogManager
import NoticeDomainInterface
import RxCocoa
import RxSwift
Expand Down Expand Up @@ -44,6 +45,11 @@ public class NoticePopupViewController: UIViewController, ViewControllerFromStor
inputBind()
}

override public func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
LogManager.analytics(CommonAnalyticsLog.viewPage(pageName: .noticePopup))
}

public static func viewController(
viewModel: NoticePopupViewModel
) -> NoticePopupViewController {
Expand Down Expand Up @@ -99,6 +105,9 @@ private extension NoticePopupViewController {

output.dismissAndCallDelegate
.bind(with: self) { owner, entity in
let log = NoticePopupAnalyticsLog.clickNoticeItem(id: "\(entity.id)", location: "notice_popup")
LogManager.analytics(log)

owner.dismiss(animated: true) {
owner.delegate?.noticeTapped(model: entity)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@ enum MusicDetailAnalyticsLog: AnalyticsLogType {
case clickSingingRoomButton(id: String)
case clickLyricsButton(id: String)
case clickLikeMusicButton(id: String, like: Bool)
case clickMusicPickButton(id: String)
case clickPlaylistButton(id: String)
}
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,9 @@ private extension MusicDetailReactor {
navigate: NavigateType.textPopup(
text: LocalizationStrings.needLoginWarning,
completion: { [signInIsRequiredSubject] in
let log = CommonAnalyticsLog.clickLoginButton(entry: .songLike)
LogManager.analytics(log)

signInIsRequiredSubject.onNext(())
}
)
Expand Down Expand Up @@ -384,19 +387,23 @@ private extension MusicDetailReactor {
}

func musicPickButtonDidTap() -> Observable<Mutation> {
let log = CommonAnalyticsLog.clickAddMusicsButton(location: .songDetail)
LogManager.analytics(log)

guard PreferenceManager.userInfo != nil else {
return navigateMutation(
navigate: NavigateType.textPopup(
text: LocalizationStrings.needLoginWarning,
completion: { [signInIsRequiredSubject] in
let log = CommonAnalyticsLog.clickLoginButton(entry: .addMusics)
LogManager.analytics(log)

signInIsRequiredSubject.onNext(())
}
)
)
}
guard let song = currentState.selectedSong, !song.videoID.isEmpty else { return .empty() }
let log = Log.clickMusicPickButton(id: song.videoID)
LogManager.analytics(log)
return navigateMutation(navigate: .musicPick(id: song.videoID))
}

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import LogManager

enum FAQAnalyticsLog: AnalyticsLogType {
case selectFaqCategory(category: String)
case clickFaqItem(title: String)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import LogManager

enum InquiryAnalyticsLog: AnalyticsLogType {
case clickInquirySubmitButton(type: LogInquiryType)

enum LogInquiryType: String, AnalyticsLogEnumParametable {
case bug = "버그 제보"
case feature = "κΈ°λŠ₯ μ œμ•ˆ"
case addSong = "λ…Έλž˜ μΆ”κ°€"
case modifySong = "λ…Έλž˜ μˆ˜μ •"
case weeklyChart = "μ£Όκ°„μ°¨νŠΈ μ˜μƒ"
case credit = "μ°Έμ—¬ 정보"

init(mailSource: InquiryType) {
switch mailSource {
case .reportBug:
self = .bug
case .suggestFunction:
self = .feature
case .addSong:
self = .addSong
case .modifySong:
self = .modifySong
case .weeklyChart:
self = .weeklyChart
case .credit:
self = .credit
case .unknown:
self = .bug
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,14 @@ import LogManager
enum MyInfoAnalyticsLog: AnalyticsLogType {
case clickProfileImage
case clickProfileChangeButton
case completeProfileChange
case clickNicknameChangeButton
case completeNicknameChange
case clickFruitDrawEntryButton(location: FruitDrawEntryLocation)
case clickFruitStorageButton
case clickFaqButton
case clickNoticeButton
case clickQnaButton
case clickInquiryButton
case clickTeamButton
case clickSettingButton
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import LogManager

enum NoticeAnalyticsLog: AnalyticsLogType {
case clickNoticeItem(id: String, location: String = "notice")
}
Loading
Loading