mirror of
https://github.com/simple-login/app.git
synced 2024-11-16 17:08:30 +01:00
076d5108d8
* dep: update sentry_sdk * feat(sentry): ignore 416 status codes
21 lines
638 B
Python
21 lines
638 B
Python
from typing import Optional
|
|
|
|
from sentry_sdk.types import Event, Hint
|
|
|
|
_HTTP_CODES_TO_IGNORE = [416]
|
|
|
|
|
|
def _should_send(_event: Event, hint: Hint) -> bool:
|
|
# Check if this is an HTTP Exception event
|
|
if "exc_info" in hint:
|
|
exc_type, exc_value, exc_traceback = hint["exc_info"]
|
|
# Check if it's a Werkzeug HTTPException (raised for HTTP status codes)
|
|
if hasattr(exc_value, "code") and exc_value.code in _HTTP_CODES_TO_IGNORE:
|
|
return False
|
|
return True
|
|
|
|
|
|
def sentry_before_send(event: Event, hint: Hint) -> Optional[Event]:
|
|
if _should_send(event, hint):
|
|
return event
|
|
return None
|