Dashboard for tracking Errors in Anvil App

I always struggled with various runtime errors that users faced on my anvil apps. And there was no easy way for me to track them. So I decided to create a dashboard that allows better tracking and collaboration on errors.

And the results were great. So far, I have already discovered and fixed many errors that had been around since god knows when. Hence, I am making this available for community use.

Clone Links -
Dependency -Anvil | Login

Dashboard - Anvil | Login

You can also clone the preview app to see how it works (Some features are missing here)
Anvil | Login

Features

  • Group same errors, merge similar errors and maintain a timeline of any updates and occurrences for it.
  • Mark any error as fixed or ignore the ones that don’t need to be fixed.
  • See details for any error including the detailed traceback, users facing it, device details for users, link to session logs, etc.
  • Keep a track of errors that were previously fixed but had reappeared.
  • Filter, search and sort errors. You can also search by email to see errors faced by a user
  • Allows multiple users to collaborate

How to use

  1. Clone the Dependency and the Dashboard

  2. Add the Dependency to the App you want to use it for.

  3. Add the following existing tables from the Dashboard to your App:’

    • app_data
    • errors
    • timeline

Since the dashboard is an anvil app itself, you can publish it at any URL you want and share it with other users too.

How to collect errors

In your main app, you can call the following function to collect error

from Error_Tracker.error_tracker import collect_error

try: 
   #Something
except Exception as e:
   collect_error(e)

Or you can attach it to your Error Handler

def error_handler(err):
   collect_error(err)

set_default_error_handling(error_handler)

You can also collect the device and browser details or any custom data you require.

collect_err(err, collect_device_info = True)

#Or collect any custom data

collect_err(err, url_hash = get_url_hash(), form = get_open_form())

Note: By default, it will not collect any errors in debug environment

Managing Users

By default, any logged out user will not be able to access the dashboard. Any new accounts that are created also need to be enabled by the app owner You can enable accounts by checking the enabled column of the user.

Let me know if you face any issues or need any help

8 Likes

This is the sort of thing that every eventually has to build into their Anvil app, and having a base level of it ready to use is super helpful.

2 Likes

@divyeshlakhotia amazing work! Everything is polished to the standard of an extension that I would easily pay for. Many thanks for sharing this with the community.

I have a question that I suspect I already have the answer to, but for the sake of being sure I’ll ask it anyway :sweat_smile:.

Does the error tracking work for errors on the server side as well as the client side? Or is the idea that an exception raised in the server code will be sent to the client anyway, so everything can be logged from there?

And a follow-up to my question: is there anything in the dashboard that indicates whether the error happened on the client code or server code? Although I suppose looking at the traceback would normally answer that question.

Actually, I hadn’t thought much about the server side while making this dependency. However, since the errors are returned back to the client anyway, the error tracker should track them too. But not very well. It appears that all errors sent from the server start with "AnvilWrappedError: " and they don’t come with tracebacks (But you can see the traceback when seeing the App logs for that session).

But I suppose I can probably deal with server side errors better. Will try coming up with solutions for that.

1 Like

@divyeshlakhotia thanks for quick reply :slight_smile:

No pressure, I was just asking. I might also tinker around with it and if I make any meaningful updates I’ll share them with you :slight_smile:

1 Like

Sure. FYI, you might want to check out sys.excepthook on server. It should globally catch errors. Not tested on Anvil server yet though

1 Like