Skip to content

Instantly share code, notes, and snippets.

@colinfwren
Created November 29, 2024 23:23
Show Gist options
  • Save colinfwren/0a1d9d4e5361a0b1d567926b09d8b67c to your computer and use it in GitHub Desktop.
Save colinfwren/0a1d9d4e5361a0b1d567926b09d8b67c to your computer and use it in GitHub Desktop.
Analytics enum
import PostHog
enum Analytics {
case eventOne
case eventTwo
case changedTab
var eventName: String {
switch self {
case .eventOne: return "eventOne"
case .eventTwo: return "eventTwo"
case .changedTab: return "changed tab"
}
}
func capture() {
PostHogSDK.shared.capture(self.eventName)
}
// overload capture for values to be passed into properties dictionary
func capture(from: Int, to: Int) {
PostHogSDK.shared.capture(self.eventName, properties: [from: from, to: to])
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment