Skip to content

Bridge analyticsScreen API #49

@dfabulich

Description

@dfabulich

In Firebase Analytics, they expect you to manually logEvent for each screen in your app. (They had some automagical screen view detection for UIKit and Android Activities, but not for SwiftUI or Jetpack Compose.)

On iOS, Google has provided a View extension to make tracking screens a little bit more convenient. It would be really handy for skip-firebase to bridge this API. Today, when I try to use it, I get a "Skip is unable to match this API call" error in my Skip Lite app. It would be great if skip-firebase were to bridge this API.

https://github.com/firebase/firebase-ios-sdk/blob/9cb17fca6368d49c2df4854f8e4099073395156d/FirebaseAnalytics/Sources/Analytics%2BSwiftUI.swift

https://github.com/firebase/firebase-ios-sdk/blob/main/FirebaseAnalytics/README.md

Before

struct ContentView: View {
  var body: some View {
    Text("Hello, world!")
      // Logging screen name with class and a custom parameter.
      .onAppear {
        Analytics.logEvent(AnalyticsEventScreenView,
                           parameters: [AnalyticsParameterScreenName: "main_content",
                                        AnalyticsParameterScreenClass: "ContentView",
                                        "my_custom_param": 5])
      }

       // OR Logging screen name only.
      .onAppear {
        Analytics.logEvent(AnalyticsEventScreenView,
                           parameters: [AnalyticsParameterScreenName: "main_content"])
      }
  }
}

After

struct ContentView: View {
  var body: some View {
    Text("Hello, world!")
       // Logging screen name with class and a custom parameter.
      .analyticsScreen(name: "main_content",
                       class: "ContentView",
                       extraParameters: ["my_custom_param": 5])

      // OR Logging screen name only, class and extra parameters are optional.
      .analyticsScreen(name: "main_content")
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions