Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 2 additions & 14 deletions sentry_sdk/integrations/flask.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,11 @@
RequestExtractor,
)
from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware
from sentry_sdk.scope import should_send_default_pii
from sentry_sdk.traces import SegmentNameSource
from sentry_sdk.utils import (
capture_internal_exceptions,
ensure_integration_enabled,
event_from_exception,
has_data_collection_enabled,
package_version,
)

Expand Down Expand Up @@ -146,13 +144,7 @@ def _request_started(app: "Flask", **kwargs: "Any") -> None:

scope = sentry_sdk.get_isolation_scope()

if has_data_collection_enabled(client.options):
if client.options["data_collection"]["user_info"]:
with capture_internal_exceptions():
user_properties = _get_flask_user_properties()
if user_properties:
scope.set_user(user_properties)
elif should_send_default_pii():
if client.options["data_collection"]["user_info"]:
with capture_internal_exceptions():
user_properties = _get_flask_user_properties()
if user_properties:
Expand Down Expand Up @@ -205,11 +197,7 @@ def inner(event: "Event", hint: "dict[str, Any]") -> "Event":
FlaskRequestExtractor(request).extract_into_event(event)

client_options = sentry_sdk.get_client().options
if has_data_collection_enabled(client_options):
if client_options["data_collection"]["user_info"]:
with capture_internal_exceptions():
_add_user_to_event(event)
elif should_send_default_pii():
if client_options["data_collection"]["user_info"]:
with capture_internal_exceptions():
_add_user_to_event(event)

Expand Down
Loading
Loading