Skip to content

A TCA high-order reducer to easily integrate with Google Firebase Analytics.

Notifications You must be signed in to change notification settings

otondin/tca-analytics

Repository files navigation

TCAFeatureAnalytics

A TCA high-order reducer to easily integrate feature actions with Google Firebase Analytics.

Requirements

  • iOS 16+
  • Swift 5.9+

Usage example:

Parent Feature

import FeatureAnalytics

@Reducer
struct MyFeature {

    ...
    
    enum Action {
        case onAppear
        case actionA
        case actionB
    }
    
    var body: some ReducerOf<Self> {
        ...
        AnalyticsReducer()
    }
}

Feature Action Extension

extension MyFeature.Action: AnalyticsActionCapable {

    public var featureDescription { "My Feature" }
    
    public enum ActionDescription: String {
        case screenView = "screen_view"
        case actionA = "action_a"
    }
    
    public var event: AnalyticsEven? {
        switch self {
        case .onAppear:
            return .screenView(AnalyticsAction.screenView.rawValue, screenClass: featureDescription)
            
        case .actionA:
            return .action(ActionDescription.actionA.rawValue, from: featureDescrition)
        
        default:
            return nil
        }
    } 
}

About

A TCA high-order reducer to easily integrate with Google Firebase Analytics.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages