diff --git a/sentry_sdk/integrations/pyramid.py b/sentry_sdk/integrations/pyramid.py index 7707917c68..e2f29b8054 100644 --- a/sentry_sdk/integrations/pyramid.py +++ b/sentry_sdk/integrations/pyramid.py @@ -8,13 +8,11 @@ from sentry_sdk.integrations import DidNotEnable, Integration, _check_minimum_version from sentry_sdk.integrations._wsgi_common import RequestExtractor from sentry_sdk.integrations.wsgi import SentryWsgiMiddleware -from sentry_sdk.scope import should_send_default_pii from sentry_sdk.traces import SOURCE_FOR_STYLE as SEGMENT_SOURCE_FOR_STYLE from sentry_sdk.utils import ( capture_internal_exceptions, ensure_integration_enabled, event_from_exception, - has_data_collection_enabled, package_version, reraise, ) @@ -92,12 +90,7 @@ def sentry_patched_call_view( scope = sentry_sdk.get_isolation_scope() - if has_data_collection_enabled(client.options): - if client.options["data_collection"]["user_info"]: - user_id = request.authenticated_userid - if user_id: - scope.set_user({"id": user_id}) - elif should_send_default_pii(): + if client.options["data_collection"]["user_info"]: user_id = request.authenticated_userid if user_id: scope.set_user({"id": user_id}) @@ -233,12 +226,8 @@ def pyramid_event_processor(event: "Event", hint: "Dict[str, Any]") -> "Event": PyramidRequestExtractor(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(): - user_info = event.setdefault("user", {}) - user_info.setdefault("id", request.authenticated_userid) - elif should_send_default_pii(): + + if client_options["data_collection"]["user_info"]: with capture_internal_exceptions(): user_info = event.setdefault("user", {}) user_info.setdefault("id", request.authenticated_userid) diff --git a/tests/integrations/pyramid/test_pyramid.py b/tests/integrations/pyramid/test_pyramid.py index 798accbf73..57548b4620 100644 --- a/tests/integrations/pyramid/test_pyramid.py +++ b/tests/integrations/pyramid/test_pyramid.py @@ -93,7 +93,7 @@ def errors(request): def test_has_context(route, get_client, sentry_init, capture_events): - sentry_init(integrations=[PyramidIntegration()]) + sentry_init(integrations=[PyramidIntegration()], data_collection={}) events = capture_events() @route("/context_message/{msg}") @@ -110,7 +110,6 @@ def hi2(request): "env": {"SERVER_NAME": "localhost", "SERVER_PORT": "80"}, "headers": {"Host": "localhost"}, "method": "GET", - "query_string": "", "url": "http://localhost/context_message/yoo", } assert event["transaction"] == "hi2" @@ -182,6 +181,7 @@ def test_large_json_request( integrations=[PyramidIntegration()], max_request_body_size="always", max_value_length=max_value_length, + data_collection={}, ) data = {"foo": {"bar": "a" * (1034)}} @@ -215,7 +215,7 @@ def index(request): @pytest.mark.parametrize("data", [{}, []], ids=["empty-dict", "empty-list"]) def test_flask_empty_json_request(sentry_init, capture_events, route, get_client, data): - sentry_init(integrations=[PyramidIntegration()]) + sentry_init(integrations=[PyramidIntegration()], data_collection={}) @route("/") def index(request): @@ -238,7 +238,11 @@ def index(request): def test_json_not_truncated_if_max_request_body_size_is_always( sentry_init, capture_events, route, get_client ): - sentry_init(integrations=[PyramidIntegration()], max_request_body_size="always") + sentry_init( + integrations=[PyramidIntegration()], + max_request_body_size="always", + data_collection={}, + ) data = { "key{}".format(i): "value{}".format(i) for i in range(MAX_DATABAG_BREADTH + 10) @@ -268,6 +272,7 @@ def test_files_and_form( integrations=[PyramidIntegration()], max_request_body_size="always", max_value_length=max_value_length, + data_collection={}, ) data = { @@ -403,11 +408,11 @@ def test_error_in_authenticated_userid( from sentry_sdk.integrations.logging import LoggingIntegration sentry_init( - send_default_pii=True, integrations=[ PyramidIntegration(), LoggingIntegration(event_level=logging.ERROR), ], + data_collection={}, ) logger = logging.getLogger("test_pyramid")