ojo / ios

:iphone:
0 stars 0 forks source link

Analytics: an alternative to Mixpanel #60

Closed btc closed 7 years ago

btc commented 7 years ago

Due to #45, we cannot use Mixpanel analytics. What's a good alternative?

Right now, I need to be able to time session length like so:

final class Analytics {

    typealias Properties = [AnyHashable:Any]

    private var client: AnalyticsType? // TODO

    private var currentStation: Station?

    func trackListeningSessionBegin(station s: Station) {
        currentStation = s
        time(event: "Listening Session")
    }

    func trackListeningSessionEnd() {
        if let s = currentStation {
            let p = ["Station": s.tag]
            track(event: "Listening Session", properties: p)
            currentStation = nil
        }

    }

    private func time(event: String) {
        client?.time(event: event)
    }

    private func track(event: String, properties: Properties = [:]) {
        client?.track(event: event, properties: properties)
    }
}
LeoNatan commented 7 years ago

Why not Google Analytics?

btc commented 7 years ago

I haven't heard good things about Google Analytics for mobile platforms...

But you raise a good point. I should investigate it and see where people believe it falls short, and evaluate for myself.

btc commented 7 years ago

Note to self:

With the help of a Mixpanel eng, I created a custom build of their library that doesn't include method swizzling. Going to use it for now. However, the client is used through a protocol so we can swap it out if we need to.