Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does Mixpanel Work with SwiftUI Widgets? #629

Open
kumarneel opened this issue Feb 14, 2024 · 0 comments
Open

Does Mixpanel Work with SwiftUI Widgets? #629

kumarneel opened this issue Feb 14, 2024 · 0 comments

Comments

@kumarneel
Copy link

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant