mirror of
https://github.com/BillyOutlast/posthog.com.git
synced 2026-02-05 20:01:20 +01:00
Co-authored-by: Vincent (Wen Yu) Ge <gewenyu99@gmail.com> Co-authored-by: greptile-apps[bot] <165735046+greptile-apps[bot]@users.noreply.github.com> Co-authored-by: David Newell <david@posthog.com> Co-authored-by: edwinyjlim <edwinyjlim@gmail.com> Co-authored-by: Edwin Lim <edwin@posthog.com>
17 lines
608 B
Plaintext
17 lines
608 B
Plaintext
```python
|
|
from flask import Flask, jsonify
|
|
from posthog import Posthog
|
|
|
|
posthog = Posthog('<ph_project_api_key>', host='<ph_client_api_host>')
|
|
|
|
@app.errorhandler(Exception)
|
|
def handle_exception(e):
|
|
# Capture methods, including capture_exception, return the UUID of the captured event,
|
|
# which you can use to find specific errors users encountered
|
|
event_id = posthog.capture_exception(e)
|
|
|
|
# You can show the event ID to your user, and ask them to include it in bug reports
|
|
response = jsonify({'message': str(e), 'error_id': event_id})
|
|
response.status_code = 500
|
|
return response
|
|
``` |