diff --git a/iOS-NOTTODO/iOS-NOTTODO/Global/Enum/AnalyticsEvent.swift b/iOS-NOTTODO/iOS-NOTTODO/Global/Enum/AnalyticsEvent.swift index 25be0f23..ae1fcd0a 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Global/Enum/AnalyticsEvent.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Global/Enum/AnalyticsEvent.swift @@ -55,20 +55,25 @@ enum AnalyticsEvent { case viewSignIn case clickSignIn(provider: String) case completeSignIn(provider: String) + case clickAdModalCta + case clickAdModalClose(again: String) var name: String { switch self { case .viewSignIn: return "view_signin" case .clickSignIn: return "click_signin" case .completeSignIn: return "complete_signin" + case .clickAdModalCta: return "click_ad_modal_cta" + case .clickAdModalClose: return "click_ad_modal_close" } } var parameters: [String: Any]? { switch self { - case .viewSignIn: return nil + case .viewSignIn, .clickAdModalCta: return nil case .clickSignIn(provider: let provider ): return ["provider": provider] case .completeSignIn(provider: let provider): return ["provider": provider] + case .clickAdModalClose(again: let again): return ["again": again] } } } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Global/Enum/DefaultKeys.swift b/iOS-NOTTODO/iOS-NOTTODO/Global/Enum/DefaultKeys.swift index f9844a91..1ac506d8 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Global/Enum/DefaultKeys.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Global/Enum/DefaultKeys.swift @@ -27,5 +27,5 @@ struct DefaultKeys { static let socialToken = "socialToken" static let accessToken = "accessToken" static let fcmToken = "fcmToken" - static let isSelected = "isSelected" + static let isDeprecatedBtnClicked = "isDeprecatedBtnClicked" } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Global/Enum/KeychainUtil.swift b/iOS-NOTTODO/iOS-NOTTODO/Global/Enum/KeychainUtil.swift index b3daa9cd..d5ca9364 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Global/Enum/KeychainUtil.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Global/Enum/KeychainUtil.swift @@ -46,10 +46,10 @@ public final class KeychainUtil { UserDefaults.standard.string(forKey: DefaultKeys.appleEmail) ?? "연동된 이메일 정보가 없습니다" } - static func isSelected() -> Bool { - UserDefaults.standard.bool(forKey: DefaultKeys.isSelected) + static func isDeprecatedBtnClicked() -> Bool { + UserDefaults.standard.bool(forKey: DefaultKeys.isDeprecatedBtnClicked) } - + static func removeUserInfo() { if UserDefaults.standard.bool(forKey: DefaultKeys.isAppleLogin) { UserDefaults.standard.removeObject(forKey: DefaultKeys.appleName) diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/Modal/CommonNotificationViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/Modal/CommonNotificationViewController.swift index 6f76e237..211c4963 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/Modal/CommonNotificationViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Common/Modal/CommonNotificationViewController.swift @@ -13,6 +13,10 @@ import SafariServices final class CommonNotificationViewController: UIViewController { + // MARK: - Property + + var tapCloseButton: (() -> Void)? + // MARK: - UI Components private let backgroundView = UIView() @@ -24,7 +28,7 @@ final class CommonNotificationViewController: UIViewController { private lazy var formButton = UIButton() private lazy var closeButton = UIButton() private lazy var deprecatedButton = UIButton() - + // MARK: - View Life Cycle override func viewDidLoad() { @@ -161,15 +165,18 @@ extension CommonNotificationViewController { @objc func didFormButtonTap() { - + guard let url = URL(string: MyInfoURL.googleForm.url) else { return } let safariView: SFSafariViewController = SFSafariViewController(url: url) safariView.delegate = self self.present(safariView, animated: true, completion: nil) + + AmplitudeAnalyticsService.shared.send(event: AnalyticsEvent.Login.clickAdModalCta) } @objc func didCancelButtonTap() { + self.tapCloseButton?() dismissViewController() } @@ -177,7 +184,7 @@ extension CommonNotificationViewController { func didDeprecatedButtonTap() { deprecatedButton.isSelected.toggle() KeychainUtil.setBool(deprecatedButton.isSelected, - forKey: DefaultKeys.isSelected) + forKey: DefaultKeys.isDeprecatedBtnClicked) } } diff --git a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/HomeViewController.swift b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/HomeViewController.swift index bd19779e..13df4837 100644 --- a/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/HomeViewController.swift +++ b/iOS-NOTTODO/iOS-NOTTODO/Presentation/Home/ViewControllers/HomeViewController.swift @@ -23,16 +23,14 @@ final class HomeViewController: UIViewController { private var current: Date? private lazy var safeArea = self.view.safeAreaLayoutGuide - private var isSelected: Bool { - return KeychainUtil.isSelected() - } + private var didCloseButtonTap: Bool = false + private var didDeprecatedButtonTap: Bool { return KeychainUtil.isDeprecatedBtnClicked() } // MARK: - UI Components private var missionCollectionView = UICollectionView(frame: .zero, collectionViewLayout: .init()) private lazy var missionDataSource = HomeDataSource(collectionView: missionCollectionView, missionList: missionList) - private lazy var alertViewContrilelr = CommonNotificationViewController() private let weekCalendar = CalendarView(calendarScope: .week, scrollDirection: .horizontal) private let addButton = UIButton() @@ -40,8 +38,8 @@ final class HomeViewController: UIViewController { override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) - - showPopup(isSelected: isSelected) + + showPopup(isSelected: didCloseButtonTap) AmplitudeAnalyticsService.shared.send(event: AnalyticsEvent.Home.viewHome) dailyLoadData() @@ -53,7 +51,6 @@ final class HomeViewController: UIViewController { setUI() setLayout() - } } @@ -88,7 +85,7 @@ extension HomeViewController { } private func setLayout() { - + view.addSubviews(weekCalendar, missionCollectionView, addButton) weekCalendar.calendar.select(today) @@ -220,7 +217,7 @@ extension HomeViewController: FSCalendarDelegate, FSCalendarDataSource, FSCalend AmplitudeAnalyticsService.shared.send(event: AnalyticsEvent.Home.clickWeeklyDate(date: Utils.dateFormatterString(format: nil, date: date))) } - + func calendar(_ calendar: FSCalendar, titleFor date: Date) -> String? { Utils.dateFormatterString(format: "EEEEEE", date: date) } @@ -238,12 +235,12 @@ extension HomeViewController: FSCalendarDelegate, FSCalendarDataSource, FSCalend } func calendar(_ calendar: FSCalendar, cellFor date: Date, at position: FSCalendarMonthPosition) -> FSCalendarCell { - + let cell = calendar.dequeueReusableCell(withIdentifier: MissionCalendarCell.identifier, for: date, at: position) as! MissionCalendarCell guard let percentage = getPercentage(for: date) else { return cell } cell.configure(percent: percentage) - + return cell } } @@ -288,9 +285,9 @@ extension HomeViewController { } private func requestDeleteMission(index: Int, id: Int) { - HomeAPI.shared.deleteMission(id: id) { [weak self] _ in + HomeAPI.shared.deleteMission(id: id) { [weak self] _ in guard let self else { return } - + self.dailyLoadData() self.weeklyLoadData() self.missionDataSource.updateSnapShot(missionList: self.missionList) @@ -356,11 +353,17 @@ extension HomeViewController { extension HomeViewController { private func showPopup(isSelected: Bool) { - if !isSelected { + + if !(isSelected || didDeprecatedButtonTap) { let nextView = CommonNotificationViewController() nextView.modalPresentationStyle = .overFullScreen nextView.modalTransitionStyle = .crossDissolve self.present(nextView, animated: true) + + nextView.tapCloseButton = { + self.didCloseButtonTap = true + AmplitudeAnalyticsService.shared.send(event: AnalyticsEvent.Login.clickAdModalClose(again: self.didDeprecatedButtonTap ? "yes": "no" )) + } } } }