Skip to content

Commit

Permalink
♻️ :: [#496] logoug이 일어날때마다 feature단에서 케이스마다 직접 Analytics user id를 ni…
Browse files Browse the repository at this point in the history
…l로 지정해주는 코드 리팩토링

PreferenceManage에서 clear() 메서드를 만들어 userinfo를 nil로 만들기와 analytics user id nil지정
  • Loading branch information
baekteun committed Apr 23, 2024
1 parent 5a15548 commit 4229f1d
Show file tree
Hide file tree
Showing 13 changed files with 9 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public final class LocalAuthDataSourceImpl: LocalAuthDataSource {
keychain.delete(type: .accessToken)
keychain.delete(type: .refreshToken)
keychain.delete(type: .accessExpiresIn)
PreferenceManager.userInfo = nil
PreferenceManager.clear()
}

public func checkIsExistAccessToken() -> Bool {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import AnalyticsLogManager
import AuthDomainInterface
import ErrorModule
import Foundation
Expand Down Expand Up @@ -66,7 +65,6 @@ public final class ContainSongsViewModel: ViewModelType {
let wmError = error.asWMError
if wmError == .tokenExpired {
logoutRelay.accept(wmError)
AnalyticsLogManager.setUserID(userID: nil)
return logoutUseCase.execute()
.andThen(.never())
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import AnalyticsLogManager
import AuthDomainInterface
import BaseDomainInterface
import BaseFeatureInterface
Expand Down Expand Up @@ -82,7 +81,6 @@ public final class MultiPurposePopupViewModel: ViewModelType {
let wmError = error.asWMError
if wmError == .tokenExpired {
logoutRelay.accept(error)
AnalyticsLogManager.setUserID(userID: nil)
return logoutUseCase.execute()
.andThen(.never())
} else {
Expand Down Expand Up @@ -118,7 +116,6 @@ public final class MultiPurposePopupViewModel: ViewModelType {
let wmError = error.asWMError
if wmError == .tokenExpired {
logoutRelay.accept(error)
AnalyticsLogManager.setUserID(userID: nil)
return logoutUseCase.execute()
.andThen(.never())
} else {
Expand Down Expand Up @@ -148,7 +145,6 @@ public final class MultiPurposePopupViewModel: ViewModelType {
let wmError = error.asWMError
if wmError == .tokenExpired {
logoutRelay.accept(error)
AnalyticsLogManager.setUserID(userID: nil)
return logoutUseCase.execute()
.andThen(.never())
} else {
Expand Down Expand Up @@ -183,7 +179,6 @@ public final class MultiPurposePopupViewModel: ViewModelType {
let wmError = error.asWMError
if wmError == .tokenExpired {
logoutRelay.accept(error)
AnalyticsLogManager.setUserID(userID: nil)
return logoutUseCase.execute()
.andThen(.never())
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import AnalyticsLogManager
import AuthDomainInterface
import BaseFeature
import Combine
Expand Down Expand Up @@ -213,7 +212,6 @@ final class PlayerViewModel: ViewModelType {
logoutUseCase.execute()
.andThen(Observable.just(()))
.bind { _ in
AnalyticsLogManager.setUserID(userID: nil)
output.onLogout.send(())
}
.disposed(by: disposeBag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import AnalyticsLogManager
import AuthDomainInterface
import BaseDomainInterface
import BaseFeature
Expand Down Expand Up @@ -152,7 +151,6 @@ public final class PlayListDetailViewModel: ViewModelType {

if wmError == .tokenExpired {
logoutRelay.accept(wmError)
AnalyticsLogManager.setUserID(userID: nil)
return logoutUseCase.execute()
.andThen(.never())
}
Expand Down Expand Up @@ -221,7 +219,6 @@ public final class PlayListDetailViewModel: ViewModelType {
let wmError = error.asWMError
if wmError == .tokenExpired {
logoutRelay.accept(wmError)
AnalyticsLogManager.setUserID(userID: nil)
return logoutUseCase.execute()
.andThen(.never())
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import AnalyticsLogManager
import AppDomainInterface
import AuthDomainInterface
import BaseFeature
Expand Down Expand Up @@ -113,7 +112,6 @@ public final class IntroViewModel: ViewModelType {
.flatMap { isExist in
output.userInfoResult.onNext(.success(""))
if isExist {
AnalyticsLogManager.setUserID(userID: nil)
return logoutUseCase.execute()
.andThen(Observable.just(false))
} else {
Expand All @@ -138,7 +136,6 @@ public final class IntroViewModel: ViewModelType {
logoutUseCase.execute()
.andThen(Observable.just(()))
.bind {
AnalyticsLogManager.setUserID(userID: nil)
Utility.PreferenceManager.startPage = 4
}
.disposed(by: disposeBag)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import AnalyticsLogManager
import AuthDomainInterface
import AuthenticationServices
import BaseFeature
import CryptoSwift
import KeychainModule
import LogManager
import NaverThirdPartyLogin
import RxCocoa
import RxRelay
Expand Down Expand Up @@ -83,7 +83,7 @@ public final class LoginViewModel: NSObject, ViewModelType { // 네이버 델리
.asObservable()
}
.bind {
AnalyticsLogManager.setUserID(userID: $0.id)
LogManager.setUserID(userID: $0.id)
PreferenceManager.shared.setUserInfo(
ID: AES256.encrypt(string: $0.id),
platform: $0.platform,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import AnalyticsLogManager
import AuthDomainInterface
import BaseFeature
import Foundation
Expand Down Expand Up @@ -67,7 +66,6 @@ public final class AfterLoginViewModel: ViewModelType {
input.pressLogOut
.compactMap { PreferenceManager.userInfo?.platform }
.flatMap { [naverLoginInstance, logoutUseCase] platform in
AnalyticsLogManager.setUserID(userID: nil)
switch platform {
case "naver":
naverLoginInstance?.resetToken()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import AnalyticsLogManager
import AuthDomainInterface
import BaseDomainInterface
import BaseFeature
Expand Down Expand Up @@ -171,7 +170,6 @@ public final class FavoriteViewModel: ViewModelType {

if wmError == .tokenExpired {
output.onLogout.accept(wmError)
AnalyticsLogManager.setUserID(userID: nil)
return logoutUseCase.execute()
.andThen(.never())
}
Expand Down Expand Up @@ -243,7 +241,6 @@ public final class FavoriteViewModel: ViewModelType {

if wmError == .tokenExpired {
output.onLogout.accept(wmError)
AnalyticsLogManager.setUserID(userID: nil)
return logoutUseCase.execute()
.andThen(.never())
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import AnalyticsLogManager
import AuthDomainInterface
import BaseDomainInterface
import BaseFeature
Expand Down Expand Up @@ -169,7 +168,6 @@ public final class MyPlayListViewModel: ViewModelType {
let wmError = error.asWMError
if wmError == .tokenExpired {
output.onLogout.accept(wmError)
AnalyticsLogManager.setUserID(userID: nil)
return logoutUseCase.execute()
.andThen(.never())
} else {
Expand Down Expand Up @@ -223,7 +221,6 @@ public final class MyPlayListViewModel: ViewModelType {
let wmError = error.asWMError
if wmError == .tokenExpired {
output.onLogout.accept(wmError)
AnalyticsLogManager.setUserID(userID: nil)
return logoutUseCase.execute()
.andThen(.never())
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import AnalyticsLogManager
import AuthDomainInterface
import BaseDomainInterface
import BaseFeature
Expand Down Expand Up @@ -92,7 +91,6 @@ public final class ProfilePopViewModel {

if wmError == .tokenExpired {
output.onLogout.accept(error)
AnalyticsLogManager.setUserID(userID: nil)
return logoutUseCase.execute()
.andThen(.never())
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
// Copyright © 2023 yongbeomkwak. All rights reserved.
//

import AnalyticsLogManager
import AuthDomainInterface
import BaseDomainInterface
import BaseFeature
Expand Down Expand Up @@ -61,7 +60,6 @@ public final class RequestViewModel: ViewModelType {
naverLoginInstance?.requestDeleteToken()
}

AnalyticsLogManager.setUserID(userID: nil)
return logoutUseCase.execute()
.andThen(Single.just(entity))
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

import Foundation
import LogManager
import RxSwift

public extension PreferenceManager {
Expand Down Expand Up @@ -61,4 +62,9 @@ public extension PreferenceManager {
)
Utility.PreferenceManager.userInfo = userInfo
}

static func clear() {
LogManager.setUserID(userID: nil)
PreferenceManager.userInfo = nil
}
}

0 comments on commit 4229f1d

Please sign in to comment.