How to Track Usage in Dash App


I am interested to know whether there is a built-in function to track usage of the app? If not, any workarounds? Can anyone share your experience implementing it?


1 Like

@meg how I have done this in two ways. The first is with flask.logging which is built into the dash.Dash app object.

How I continue to do it, is by creating a logging function that logs simple actions and values to SQLite:

def send_log(vals):
    c = sqlite3.connect('log.db')
    c.cursor.execute( 'insert into myapp_log (col1, col2, col3, col4) values (?,?,?,?)',vals)
    return False
    return True

def did_something(...)
    log = [ some, list, of, loggable, values ]
    if send_log(log):
        # handle error in some way

    # do normal callback function stuff
    return output

In this way I can log things happening in a very straightforward, lightweight way.

EDIT: and I get precisely the log values that I want, and the ability to easily visualize them with a portable SQLite database without having some other process running. KISS. :slight_smile:


Thanks @russellthehippo.

As far as I know, dash_enterprise_auth provides the capability of returning username and other user info as well. Have you implemented something to log the time that users stayed on the app?


I have not done this; this is tough to do. My first thought is to track user interaction events and come up with some arbitrary logic to define what a session’s “start” and “end” are.

My next thought isclient-side callbacks or using or something similar.

My last thought is…Google Analytics can do this for you.