Skip to content

Commit

Permalink
Log Recaptcha errors in Sentry
Browse files Browse the repository at this point in the history
  • Loading branch information
jimchamp committed Feb 19, 2025
1 parent 53fbed0 commit 70fd537
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion openlibrary/plugins/recaptcha/recaptcha.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,4 +35,11 @@ def validate(self, value=None):
)
return True

return r.json().get('success', '')
data = r.json()
if not data.get('success', False) and 'error-codes' in data:
from openlibrary.plugins.openlibrary.sentry import sentry

if sentry and sentry.enabled:
sentry.capture_message(f"Recaptcha Error: {data['error-codes']}")

return data.get('success', '')
3 changes: 3 additions & 0 deletions openlibrary/utils/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ def capture_exception(self, ex, extras: dict | None = None):
scope.add_event_processor(add_web_ctx_to_event)
sentry_sdk.capture_exception(ex)

def capture_message(self, message: str):
sentry_sdk.capture_message(message)


@dataclass
class InfogamiRoute:
Expand Down

0 comments on commit 70fd537

Please sign in to comment.