user2411290
user2411290

Reputation: 641

How to measure how long specific actions take to complete for users in iOS app

I have an iOS app that I wrote with Swift with Firebase Auth/DB for the backend. I would like to measure how long it takes for a user to complete specific actions. I'm actually not interested in the response time, but am interested in the total time it takes to complete something.

In other words, I want to measure how long it takes to login, click on a button, receive a push notification, click "Ok" on that notification, etc. I also want to log how many seconds it took to get from one thing to the next (i.e. login time: 2.5 seconds, time to push a specific button: 4 seconds, etc.).

I am trying out Firebase Analytics, and it almost works, but not quite. I can log specific events, such as login, button presses, etc., but it just logs the that the event occurs, not how long it took.

Ideally, I would record all of this data on the specific users I give to try my app, so I could look at all the data, find averages and other useful information.

Upvotes: 0

Views: 143

Answers (1)

S. Doe
S. Doe

Reputation: 163

consider using a a Timer, maybe something like this.

import UIKit
class Whatever: UIViewController {
var timer = Timer()
var currentTime = 0.00

func timeCounter() {
    currentTime += 0.01
}

override func viewDidLoad() {
    timer = Timer.scheduledTimer(timeInterval: 0.01, target: self, selector: #selector(Whatever.timeCounter), userInfo: nil, repeats: true)
}

@IBAction func buttonPressed(_ sender: Any) {
    timer.invalidate()
    //whatever button does
}
}

This way when the application begins the timer will begin, when the final button is pushed the timer will stop. You will have the value of how long it took stored as currentTime.

Hope this helps!

Upvotes: 1

Related Questions