JayThomason / Tutti

Tutti is a shared music application for the car being made in conjunction with Audi.
3 stars 1 forks source link

Implement Logging Solution #217

Closed JayThomason closed 10 years ago

JayThomason commented 10 years ago

One of our deliverables requires that we record key metrics about app usage. These metrics might include usage time, number of songs per jam, and number of users per jam.

The design that I am considering right now looks like this:

JayThomason commented 10 years ago

So far I have added the log table to the SQLite database and I have methods to manipulate the fields in it (https://github.com/JayThomason/Tutti/commit/db3656bc5a557c0b74d4ca8daee6af7dfb163d2d).

Next I need to add some code to keep track of the number of songs in the jam (I'm just going to track the maximum for now, ie. the max number of songs that are in the jam at any one time), and then I need to insert calls to do the logging throughout the codebase.

JayThomason commented 10 years ago

With these two commits (https://github.com/JayThomason/tutti-server/commit/783a69db3097657be7b98a118db41b2d729de2dd and https://github.com/JayThomason/tutti-server/commit/3799edfea482838719bcb4fe2e14a1d88d7a67a4) I have updated the server code to remove the old server endpoints. I added the /log endpoint which takes a JSON list of jams encoded as JSON objects with four fields: the start_time (unix time client side when the jam was created), length (approx. length of jam in seconds), num_users, and num_songs).

JayThomason commented 10 years ago

As of here (https://github.com/JayThomason/Tutti/commit/56dab521ac2a59c1e741aea328e79606bbdb582f), all that is left to do for the logger is test it more and add an Alarm that runs every so often to dump the jams in the database to the server.

JayThomason commented 10 years ago

Status update: I've started building the alarm system that will active about once per day and try to log the data in the local sqlite db to the log server (https://github.com/JayThomason/Tutti/commit/273ea64e7ec5cd6c99851a6c41b8be0759797ece). I'm going off of this sample application to implement this functionality.

JayThomason commented 10 years ago

It seems that there is no way to reliably check whether you have already set a specific alarm in the Android AlarmManager, so I've had to rely on using a shared preferences bool.

As of (https://github.com/JayThomason/Tutti/commit/2bb8f7844a75ed8fc736fab23717e7db34c23aa4) the logger alarm will fire every ~6 hours. I changed the time down from about 1 day because I want more resolution when watching metrics over the next two weeks or so. I think that the only optimization left to be made is to ensure that the alarm is reset when the phone is turned off and back on again.

JayThomason commented 10 years ago

Logger alarm is being set on reboot (https://github.com/JayThomason/Tutti/commit/ef11bc703f97c07ec7b8c872e2daa9b59218416c). Gonna close this issue for now because it seems to be working. We can test tomorrow and prepare to submit to the play store.