Skip to content

Commit

Permalink
Merge pull request #1239 from wakmusic/1237-new-log
Browse files Browse the repository at this point in the history
  • Loading branch information
baekteun authored Aug 26, 2024
2 parents 4e0a0b4 + e3ea1a7 commit c5fc96b
Show file tree
Hide file tree
Showing 9 changed files with 37 additions and 11 deletions.
4 changes: 4 additions & 0 deletions Projects/App/Sources/Application/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,10 @@ extension AppDelegate {
LogManager.clearUserProperty(property: .fruitTotal(count: -1))
}

if let playPlatform = PreferenceManager.songPlayPlatformType {
LogManager.setUserProperty(property: .songPlayPlatform(platform: playPlatform.display))
}

LogManager.setUserProperty(property: .playlistSongTotal(count: PlayState.shared.count))
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ enum SettingAnalyticsLog: AnalyticsLogType {
case clickNotificationButton
case clickTermsOfServiceButton
case clickPrivacyPolicyButton
case clickSongPlayPlatform
case completeSelectSongPlayPlatform(platform: String)
case clickOpensourceButton
case clickRemoveCacheButton
case completeRemoveCache(size: String)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ final class SettingReactor: Reactor {
return .just(.changedNotificationAuthorizationStatus(granted))
}

let updatePlayTypeMutation = PreferenceManager.$playWithYoutubeMusic
let updatePlayTypeMutation = PreferenceManager.$songPlayPlatformType
.distinctUntilChanged()
.map { $0 ?? .youtube }
.flatMap { playType -> Observable<Mutation> in
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,11 +224,14 @@ private extension PlayTypeTogglePopupViewController {
self.view.backgroundColor = .clear
contentView.clipsToBounds = true

let playType = PreferenceManager.playWithYoutubeMusic ?? .youtube
let playType = PreferenceManager.songPlayPlatformType ?? .youtube
self.selectedItemString = playType.display

firstItemButton.setTitleWithOption(title: playType.display)
secondItemButton.setTitleWithOption(title: playType.display, shouldCheckAppIsInstalled: true)
firstItemButton.setTitleWithOption(title: YoutubePlayType.youtube.display)
secondItemButton.setTitleWithOption(
title: YoutubePlayType.youtubeMusic.display,
shouldCheckAppIsInstalled: true
)

firstItemButton.isSelected = playType == .youtube
secondItemButton.isSelected = playType == .youtubeMusic
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -234,6 +234,7 @@ extension SettingViewController: UITableViewDelegate {
LogManager.analytics(SettingAnalyticsLog.clickNotificationButton)
reactor?.action.onNext(.appPushSettingNavigationDidTap)
case .playType:
LogManager.analytics(SettingAnalyticsLog.clickSongPlayPlatform)
showPlayTypeTogglePopup()
case .serviceTerms: LogManager.analytics(SettingAnalyticsLog.clickTermsOfServiceButton)
reactor?.action.onNext(.serviceTermsNavigationDidTap)
Expand All @@ -260,9 +261,23 @@ extension SettingViewController: UITableViewDelegate {
completion: { selectedItemString in
switch selectedItemString {
case YoutubePlayType.youtube.display:
PreferenceManager.playWithYoutubeMusic = .youtube
PreferenceManager.songPlayPlatformType = .youtube
LogManager.analytics(
SettingAnalyticsLog.completeSelectSongPlayPlatform(platform: YoutubePlayType.youtube.display)
)
LogManager.setUserProperty(
property: .songPlayPlatform(platform: YoutubePlayType.youtube.display)
)
case YoutubePlayType.youtubeMusic.display:
PreferenceManager.playWithYoutubeMusic = .youtubeMusic
PreferenceManager.songPlayPlatformType = .youtubeMusic
LogManager.analytics(
SettingAnalyticsLog.completeSelectSongPlayPlatform(
platform: YoutubePlayType.youtubeMusic.display
)
)
LogManager.setUserProperty(
property: .songPlayPlatform(platform: YoutubePlayType.youtubeMusic.display)
)
default:
break
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ private extension SettingItemTableViewCell {
switch type {
case let .navigate(category):
let pushNotificationAuthorizationStatus = PreferenceManager.pushNotificationAuthorizationStatus ?? false
let playType = PreferenceManager.playWithYoutubeMusic ?? .youtube
let playType = PreferenceManager.songPlayPlatformType ?? .youtube
switch category {
case .appPush:
self.subTitleLabel.text = pushNotificationAuthorizationStatus ? "켜짐" : "꺼짐"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public enum AnalyticsUserProperty {
case fruitTotal(count: Int)
case playlistSongTotal(count: Int)
case latestSearchKeyword(keyword: String)
case songPlayPlatform(platform: String)
}

extension AnalyticsUserProperty: UserPropertyRepresentable {
Expand All @@ -27,6 +28,7 @@ extension AnalyticsUserProperty: UserPropertyRepresentable {
case let .fruitTotal(count): return "\(count)"
case let .playlistSongTotal(count): return "\(count)"
case let .latestSearchKeyword(keyword): return keyword
case let .songPlayPlatform(platform): return platform
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public final class PreferenceManager {
case ignoredPopupIDs // 다시보지 않는 팝업 IDs
case readNoticeIDs // 이미 읽은 공지 IDs
case pushNotificationAuthorizationStatus // 기기알림 on/off 상태
case playWithYoutubeMusic // 유튜브뮤직으로 재생할지 여부
case songPlayPlatformType // 유튜브뮤직으로 재생할지 여부
}

@UserDefaultWrapper(key: Constants.recentRecords.rawValue, defaultValue: nil)
Expand All @@ -46,8 +46,8 @@ public final class PreferenceManager {
@UserDefaultWrapper(key: Constants.pushNotificationAuthorizationStatus.rawValue, defaultValue: nil)
public static var pushNotificationAuthorizationStatus: Bool?

@UserDefaultWrapper(key: Constants.playWithYoutubeMusic.rawValue, defaultValue: YoutubePlayType.youtube)
public static var playWithYoutubeMusic: YoutubePlayType?
@UserDefaultWrapper(key: Constants.songPlayPlatformType.rawValue, defaultValue: YoutubePlayType.youtube)
public static var songPlayPlatformType: YoutubePlayType?
}

@propertyWrapper
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ public struct WakmusicYoutubePlayer: WakmusicPlayer {
private let youtubeURLGenerator: any YoutubeURLGeneratable
private let ids: [String]
private var openerPlatform: OpenerPlatform {
let platform = PreferenceManager.playWithYoutubeMusic ?? .youtube
let platform = PreferenceManager.songPlayPlatformType ?? .youtube
switch platform {
case .youtube: return .youtube
case .youtubeMusic: return .youtubeMusic
Expand Down

0 comments on commit c5fc96b

Please sign in to comment.