execute function after session closes

There's not really a clear answer for what it means for a session to be "closed", so Prodigy currently doesn't track this. (It also generally tries to avoid any functionality that's too intrusive on the annotator client.) Like, does a session close when you close the browser tab? And what if you open it again with the same ?session marker, is that considered a new session start? What if a user just leaves the tab open and never closes it, does the session time out? These are all things that impact the decision you end up with.

One option would be to just add a button to the UI that the user can click to "end" their session explicitly, and it could then send the session ID and dataset ID to a custom endpoint, and that endpoint fetches the examples from the database and emails them. I've posted a super basic snippet for a button here:

The app.py that defines the endpoints is included in your Prodigy installation, so you could just hack in a new endpoint. Or you host your own microservice for it. It really just needs to access the general Prodigy database, so you don't necessarily need to define that code in your recipe – just any environment with Prodigy installed and access to the DB.