Open
Description
openedon Feb 14, 2024
I wanted to track some things in my Widget built in SwiftUI. I apologize if this has already been answered, I did not find the answer online. Thanks in advance!
A basic example below...
struct MyWidget: Widget {
init() {
Mixpanel.initialize(token: Secrets.MixPanel, trackAutomaticEvents: true)
}
var body: some WidgetConfiguration {
StaticConfiguration(
kind: MyWidget.kind,
provider: TimelineProvider()
) { entry in
WidgetView(entry: entry)
}
.configurationDisplayName("My Widget")
.description("")
.supportedFamilies([.systemMedium])
.contentMarginsDisabled()
}
My view would be
struct WidgetView: View {
var body: some View {
VStack {
}
.onAppear {
// Log a Mixpanel Event inside Widget Target
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Metadata
Assignees
Labels
No labels