Skip to content

Commit

Permalink
Merge pull request #177 from wakatime/feature/zoom-whatsapp
Browse files Browse the repository at this point in the history
Support for Zoom and WhatsApp
  • Loading branch information
alanhamlett authored Nov 29, 2023
2 parents 605c910 + ec6483f commit ef48139
Show file tree
Hide file tree
Showing 4 changed files with 81 additions and 77 deletions.
121 changes: 60 additions & 61 deletions WakaTime/Extensions/AXUIElementExtension.swift
Original file line number Diff line number Diff line change
Expand Up @@ -39,67 +39,66 @@ extension AXUIElement {

func title(for app: MonitoredApp) -> String? {
switch app {
case .figma:
guard
let title = extractPrefix(rawTitle, separator: ""),
title != "Figma",
title != "Drafts"
else { return nil }

return title
case .postman:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Postman"
else { return nil }

return title
case .warp:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Warp"
else { return nil }
return title
case .slack:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Slack"
else { return nil }
return title
case .safari:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Safari"
else { return nil }
return title
case .imessage:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "iMessage"
else { return nil }
return title
case .canva:
guard
let title = extractPrefix(rawTitle, separator: " - ", minCount: 2),
title != "Canva",
title != "Home"
else { return nil }

return title
case .xcode:
return nil
case .chrome:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Chrome"
else { return nil }
return title
case .arcbrowser:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Arc"
else { return nil }
return title
case .figma:
guard
let title = extractPrefix(rawTitle, separator: ""),
title != "Figma",
title != "Drafts"
else { return nil }

return title
case .postman:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Postman"
else { return nil }

return title
case .warp:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Warp"
else { return nil }
return title
case .slack:
guard let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true) else { return nil }
return title
case .safari:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Safari"
else { return nil }
return title
case .imessage:
guard let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true) else { return nil }
return title
case .canva:
guard
let title = extractPrefix(rawTitle, separator: " - ", minCount: 2),
title != "Canva",
title != "Home"
else { return nil }
return title
case .xcode:
fatalError("Xcode should never use window title as entity")
case .chrome:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Chrome"
else { return nil }
return title
case .arcbrowser:
guard
let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true),
title != "Arc"
else { return nil }
return title
case .whatsapp:
guard let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true) else { return nil }
return title
case .zoom:
guard let title = extractPrefix(rawTitle, separator: " - ", fullTitle: true) else { return nil }
return title
}
}

Expand Down
16 changes: 9 additions & 7 deletions WakaTime/Extensions/NSRunningApplicationExtension.swift
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
import Cocoa

enum MonitoredApp: String, CaseIterable {
case xcode = "com.apple.dt.Xcode"
case figma = "com.figma.Desktop"
case arcbrowser = "company.thebrowser.Browser"
case canva = "com.canva.CanvaDesktop"
case chrome = "com.google.Chrome"
case figma = "com.figma.Desktop"
case imessage = "com.apple.MobileSMS"
case postman = "com.postmanlabs.mac"
case warp = "dev.warp.Warp-Stable"
case slack = "com.tinyspeck.slackmacgap"
case safari = "com.apple.Safari"
case imessage = "com.apple.MobileSMS"
case chrome = "com.google.Chrome"
case arcbrowser = "company.thebrowser.Browser"
case slack = "com.tinyspeck.slackmacgap"
case warp = "dev.warp.Warp-Stable"
case whatsapp = "net.whatsapp.WhatsApp"
case xcode = "com.apple.dt.Xcode"
case zoom = "us.zoom.xos"

init?(from bundleId: String) {
if let app = MonitoredApp(rawValue: bundleId) {
Expand Down
14 changes: 8 additions & 6 deletions WakaTime/Helpers/MonitoringManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -64,38 +64,40 @@ class MonitoringManager {
case .warp:
return HeartbeatData(
entity: title,
language: "Warp Activity",
category: .coding)
case .slack:
return HeartbeatData(
entity: title,
language: "Slack Activity",
category: .communicating)
case .safari:
return HeartbeatData(
entity: title,
language: "Safari Activity",
category: .browsing)
case .chrome:
return HeartbeatData(
entity: title,
language: "Chrome Activity",
category: .browsing)
case .arcbrowser:
return HeartbeatData(
entity: title,
language: "Arc Browser Activity",
category: .browsing)
case .imessage:
return HeartbeatData(
entity: title,
language: "iMessage Activity",
category: .communicating)
case .canva:
return HeartbeatData(
entity: title,
language: "Canva Design",
category: .designing)
case .whatsapp:
return HeartbeatData(
entity: title,
category: .meeting)
case .zoom:
return HeartbeatData(
entity: title,
category: .meeting)
case .xcode:
fatalError("Xcode should never use window title")
}
Expand Down
7 changes: 4 additions & 3 deletions WakaTime/WakaTime.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,13 @@ enum EntityType: String {
}

enum Category: String {
case coding
case browsing
case building
case coding
case communicating
case debugging
case designing
case communicating
case browsing
case meeting
}

protocol StatusBarDelegate: AnyObject {
Expand Down

0 comments on commit ef48139

Please sign in to comment.