From 9de161cad4e35c4a00a6e7e1cb0a4f901cdb5c19 Mon Sep 17 00:00:00 2001 From: Alan Hamlett Date: Sun, 4 Feb 2024 12:15:57 +0100 Subject: [PATCH] Add support for Safari Technology Preview --- README.md | 5 +++++ WakaTime/Extensions/AXUIElementExtension.swift | 7 +++++++ WakaTime/Extensions/NSRunningApplicationExtension.swift | 2 ++ WakaTime/Helpers/MonitoringManager.swift | 4 ++++ 4 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 8e63430..87049fb 100644 --- a/README.md +++ b/README.md @@ -27,6 +27,10 @@ To uninstall, move `WakaTime.app` into your mac Trash. If you don’t use any other WakaTime plugins, run `rm -r ~/.wakatime*`. +## Supported Apps + +Before requesting support for a new app, first check the [list of supported apps][supported apps]. + ## SwiftLint To fix linter warning(s), run `swiftlint --fix`. @@ -51,3 +55,4 @@ Made with :heart: by the WakaTime Team. [dashboard]: https://wakatime.com/ [contributing]: CONTRIBUTING.md [authors]: AUTHORS +[supported apps]: https://github.com/wakatime/macos-wakatime/blob/main/WakaTime/Extensions/NSRunningApplicationExtension.swift#L3 diff --git a/WakaTime/Extensions/AXUIElementExtension.swift b/WakaTime/Extensions/AXUIElementExtension.swift index 6a9ffa5..360a07b 100644 --- a/WakaTime/Extensions/AXUIElementExtension.swift +++ b/WakaTime/Extensions/AXUIElementExtension.swift @@ -69,6 +69,13 @@ extension AXUIElement { title != "Safari" else { return nil } return title + case .safaripreview: + guard + let title = extractPrefix(rawTitle, separator: " - "), + title != "Safari", + title != "Safari Technology Preview" + else { return nil } + return title case .imessage: guard let title = extractPrefix(rawTitle, separator: " - ") else { return nil } return title diff --git a/WakaTime/Extensions/NSRunningApplicationExtension.swift b/WakaTime/Extensions/NSRunningApplicationExtension.swift index e3b90db..f1f57e6 100644 --- a/WakaTime/Extensions/NSRunningApplicationExtension.swift +++ b/WakaTime/Extensions/NSRunningApplicationExtension.swift @@ -8,6 +8,7 @@ enum MonitoredApp: String, CaseIterable { case imessage = "com.apple.MobileSMS" case postman = "com.postmanlabs.mac" case safari = "com.apple.Safari" + case safaripreview = "com.apple.SafariTechnologyPreview" case slack = "com.tinyspeck.slackmacgap" case warp = "dev.warp.Warp-Stable" case whatsapp = "net.whatsapp.WhatsApp" @@ -29,6 +30,7 @@ enum MonitoredApp: String, CaseIterable { static let electronAppIds = [MonitoredApp.postman.rawValue, MonitoredApp.figma.rawValue, MonitoredApp.canva.rawValue, MonitoredApp.warp.rawValue, MonitoredApp.slack.rawValue, MonitoredApp.safari.rawValue, + MonitoredApp.safaripreview.rawValue, MonitoredApp.imessage.rawValue, MonitoredApp.chrome.rawValue, MonitoredApp.arcbrowser.rawValue] } diff --git a/WakaTime/Helpers/MonitoringManager.swift b/WakaTime/Helpers/MonitoringManager.swift index 1fb4eea..508078f 100644 --- a/WakaTime/Helpers/MonitoringManager.swift +++ b/WakaTime/Helpers/MonitoringManager.swift @@ -73,6 +73,10 @@ class MonitoringManager { return HeartbeatData( entity: title, category: .browsing) + case .safaripreview: + return HeartbeatData( + entity: title, + category: .browsing) case .chrome: return HeartbeatData( entity: title,