Skip to content

Instantly share code, notes, and snippets.

@colinfwren
Created November 29, 2024 23:21
Show Gist options
  • Save colinfwren/80359dcb986b186c2efafc0a863a3115 to your computer and use it in GitHub Desktop.
Save colinfwren/80359dcb986b186c2efafc0a863a3115 to your computer and use it in GitHub Desktop.
Ading Screen names to post hog
import SwiftUI
import PostHog
struct ContentView: View {
@State private var tabSelection: Int = 0
var body: some View {
TabView(selection: $tabSelection) {
Tab("First View", value: 0) {
FirstTab()
.postHogScreenView("First View")
}
Tab("Second View", value: 1) {
SecondTab()
.postHogScreenView("Second View")
}
}
.onChange(of: tabSelection) { fromTab, toTab in
PostHogSDK.shared.capture("changed tab", properties: ["from": fromTab, "to": toTab])
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment