From 67441ca6270f4547f0a7dfbc26236769086866ae Mon Sep 17 00:00:00 2001 From: Jordan Chapelle Date: Thu, 9 Jan 2025 10:46:43 +0100 Subject: [PATCH] feat: Matomo --- .../Alerts/CustomScheduleAlertView.swift | 4 ++++ .../Scheduled panel/ScheduleOptionView.swift | 6 ++++++ .../Scheduled panel/ScheduleSendOption.swift | 21 +++++++++++++++++++ MailCore/Utils/Matomo+Extension.swift | 4 +++- 4 files changed, 34 insertions(+), 1 deletion(-) diff --git a/Mail/Views/Alerts/CustomScheduleAlertView.swift b/Mail/Views/Alerts/CustomScheduleAlertView.swift index 0e7a60534..926420134 100644 --- a/Mail/Views/Alerts/CustomScheduleAlertView.swift +++ b/Mail/Views/Alerts/CustomScheduleAlertView.swift @@ -18,12 +18,15 @@ import InfomaniakCoreCommonUI import InfomaniakCoreSwiftUI +import InfomaniakDI import MailCore import MailCoreUI import MailResources import SwiftUI struct CustomScheduleAlertView: View { + @LazyInjectService private var matomo: MatomoUtils + @State private var isShowingError = false @State private var selectedDate: Date @@ -78,5 +81,6 @@ struct CustomScheduleAlertView: View { return } confirmAction(selectedDate) + matomo.track(eventWithCategory: .scheduleSend, name: "customSchedule") } } diff --git a/Mail/Views/New Message/Scheduled panel/ScheduleOptionView.swift b/Mail/Views/New Message/Scheduled panel/ScheduleOptionView.swift index 5303242bc..90d38427b 100644 --- a/Mail/Views/New Message/Scheduled panel/ScheduleOptionView.swift +++ b/Mail/Views/New Message/Scheduled panel/ScheduleOptionView.swift @@ -16,11 +16,16 @@ along with this program. If not, see . */ +import InfomaniakCoreCommonUI import InfomaniakCoreSwiftUI +import InfomaniakDI +import MailCore import MailCoreUI import SwiftUI struct ScheduleOptionView: View { + @LazyInjectService private var matomo: MatomoUtils + @Environment(\.dismiss) private var dismiss let option: ScheduleSendOption @@ -31,6 +36,7 @@ struct ScheduleOptionView: View { var body: some View { if let scheduleDate = option.date { Button { + matomo.track(eventWithCategory: .scheduleSend, name: option.matomoName) setScheduleAction(scheduleDate) dismiss() } label: { diff --git a/Mail/Views/New Message/Scheduled panel/ScheduleSendOption.swift b/Mail/Views/New Message/Scheduled panel/ScheduleSendOption.swift index 1f72817bd..71974cab5 100644 --- a/Mail/Views/New Message/Scheduled panel/ScheduleSendOption.swift +++ b/Mail/Views/New Message/Scheduled panel/ScheduleSendOption.swift @@ -111,6 +111,27 @@ enum ScheduleSendOption: Identifiable, Equatable { } } + var matomoName: String { + switch self { + case .laterThisMorning: + "laterThisMorning" + case .thisAfternoon: + "thisAfternoon" + case .thisEvening: + "thisEvening" + case .tomorrowMorning: + "tomorrowMorning" + case .nextMonday: + "nextMonday" + case .nextMondayMorning: + "nextMondayMorning" + case .nextMondayAfternoon: + "nextMondayAfternoon" + case .lastSchedule(let value): + "lastSchedule" + } + } + static var allSimpleCases: [ScheduleSendOption] = [ .laterThisMorning, .thisAfternoon, diff --git a/MailCore/Utils/Matomo+Extension.swift b/MailCore/Utils/Matomo+Extension.swift index 42f254a2f..28a181229 100644 --- a/MailCore/Utils/Matomo+Extension.swift +++ b/MailCore/Utils/Matomo+Extension.swift @@ -53,7 +53,6 @@ public extension MatomoUtils.EventCategory { static let promptAIEngine = MatomoUtils.EventCategory(displayName: "promptAiEngine") static let replyBottomSheet = MatomoUtils.EventCategory(displayName: "replyBottomSheet") static let restoreEmailsBottomSheet = MatomoUtils.EventCategory(displayName: "restoreEmailsBottomSheet") - static let scheduleSend = MatomoUtils.EventCategory(displayName: "scheduleSend") static let search = MatomoUtils.EventCategory(displayName: "search") static let setAsDefaultApp = MatomoUtils.EventCategory(displayName: "setAsDefaultApp") static let snackbar = MatomoUtils.EventCategory(displayName: "snackbar") @@ -94,6 +93,9 @@ public extension MatomoUtils.EventCategory { static let settingsThreadMode = MatomoUtils.EventCategory(displayName: "settingsThreadMode") static let settingsAutoAdvance = MatomoUtils.EventCategory(displayName: "settingsAutoAdvance") static let settingsDataPrivacy = MatomoUtils.EventCategory(displayName: "settingsDataPrivacy") + + // Schedule send + static let scheduleSend = MatomoUtils.EventCategory(displayName: "scheduleSend") } // MARK: - Helpers