Skip to content

Analytics for my apps. Currently using Telemetry as the provider

Notifications You must be signed in to change notification settings

rryam/RRAnalyticsKit

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

RRAnalyticsKit

Analytics for my apps. Currently using Telemetry as the provider

Usage

For example, I've a method evaluate() in MainViewModel that acts as the parent class for RGBViewModel, HSBViewModel and CMYKViewModel. I would like to send an event that contains the color model, current score, high score, and seconds taken -

let metadata = ["Color Model": String(describing: Self.self),
                "Score": String(describing: currentScore),
                "High Score": String(describing: highScore),
                "Seconds Taken": String(describing: secondsTaken)]

RRAnalyticsKit.publish(event: .onClickButton(ButtonText.evaluate), metadata: metadata)

For a SwiftUI view's lifecycle, you can use View.sendViewData(with:onAppear:onDisappear:) -

struct ContentView: View {
    @State private var showAnalyticsView = false
    
    var body: some View {
        Button(action: { showAnalyticsView.toggle() }) {
            Text("RRAnalyticsKit")
        }
        .fullScreenCover(isPresented: $showAnalyticsView) { 
            AnalyticsView()
                .sendViewData(with: ["Parent View": String(describing: Self.self)], onAppear: true, onDisappear: true)
        }
    }
}

struct AnalyticsView: View {
    var body: some View {
        Text("AnalyticsView")
    }
}

About

Analytics for my apps. Currently using Telemetry as the provider

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages