Keeping track of play time.

Does anyone have the best way to, from day 1, keep track of the users playtime? I would like some things to happen like, enable ads after 10 minutes of gameplay, have daily login rewards, have player lifetime stats etc? What would be the best way to implement this. I can’t imagine update playerpref every second would be efficient.

Thanks

That rather depends on what resolution (how exact) you want this to be. A very simple way to Keep track is (as you mentioned yourself) using PlayerPrefs to keep these values, and have a repeating invoke every Minute that increments that by one. So you have one-Minute resolution, with a very low performance Impact. Best thing: you can implement this as a single object for all your game Levels within a couple of munites.

Same for daily Logins. On game start, look at the last login (game start) date (you Need to save that in PlayerPrefs), and if it is different, add another day to the login counte etc. If there is no previous login, save that date separately, as that is your first login.

While all this may be interesting, be sure to be upfront about what data you store and for what purpose so as to not run aground GDPR Guidelines - especially if you transmit that to a server. That’s why I prefer PlayerPrefs (or a text file) - it’s local and no breach of privacy can be construed.