Skip to content

Commit

Permalink
Core: Updates Sentry integration for v2.10+
Browse files Browse the repository at this point in the history
TYPE: Bugfix
LINK: OGC-1745
  • Loading branch information
Daverball committed Jul 16, 2024
1 parent 4aa7f49 commit d2b6f04
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ repos:
- id: sass-lint
files: '^src/.*\.scss'
- repo: https://github.com/pre-commit/mirrors-eslint
rev: v9.6.0
rev: v9.7.0
hooks:
- id: eslint
files: '^src/.*\.jsx?$'
Expand Down
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ install_requires =
requests
rjsmin
sedate
sentry_sdk<2.10.0
sentry_sdk
sortedcontainers
sqlalchemy<1.4.0
sqlalchemy-utils
Expand Down
9 changes: 4 additions & 5 deletions src/onegov/core/sentry.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
from onegov.core.framework import Framework
from onegov.core.orm import DB_CONNECTION_ERRORS
from morepath.core import excview_tween_factory # type:ignore[import-untyped]
from sentry_sdk import Scope, capture_event, get_client
from sentry_sdk.hub import Hub, _should_send_default_pii
from sentry_sdk import capture_event, get_client
from sentry_sdk.integrations import Integration
from sentry_sdk.integrations._wsgi_common import RequestExtractor
from sentry_sdk.scope import Scope, should_send_default_pii
from sentry_sdk.tracing import SOURCE_FOR_STYLE
from sentry_sdk.utils import (
capture_internal_exceptions,
Expand Down Expand Up @@ -95,8 +95,7 @@ def sentry_tween(request: 'CoreRequest') -> 'Response':
return sentry_tween

def with_sentry_middleware(self: Framework) -> bool:
hub = Hub.current
integration = hub.get_integration(OneGovCloudIntegration)
integration = get_client().get_integration(OneGovCloudIntegration)
if integration is None:
return False

Expand Down Expand Up @@ -189,7 +188,7 @@ def event_processor(event: 'Event', hint: 'Hint') -> 'Event':

user_data.setdefault(
'role', getattr(request.identity, 'role', 'anonymous'))
if _should_send_default_pii():
if should_send_default_pii():
user_info.setdefault(
'ip_address', request.environ.get('HTTP_X_REAL_IP'))
user_info.setdefault('email', request.identity.userid)
Expand Down

0 comments on commit d2b6f04

Please sign in to comment.