|
10 | 10 | from sentry_sdk.integrations import DidNotEnable, Integration |
11 | 11 | from sentry_sdk.integrations._wsgi_common import _filter_headers |
12 | 12 | from sentry_sdk.integrations.asgi import SentryAsgiMiddleware |
13 | | -from sentry_sdk.scope import should_send_default_pii |
14 | 13 | from sentry_sdk.traces import SOURCE_FOR_STYLE as SEGMENT_SOURCE_FOR_STYLE |
15 | 14 | from sentry_sdk.traces import Span, get_current_span |
16 | 15 | from sentry_sdk.utils import ( |
17 | 16 | capture_internal_exceptions, |
18 | 17 | ensure_integration_enabled, |
19 | 18 | event_from_exception, |
20 | | - has_data_collection_enabled, |
21 | 19 | parse_url, |
22 | 20 | ) |
23 | 21 |
|
@@ -196,56 +194,27 @@ async def _request_websocket_started(app: "Quart", **kwargs: "Any") -> None: |
196 | 194 |
|
197 | 195 | client_options = sentry_sdk.get_client().options |
198 | 196 | filtered_query_string = None |
199 | | - if has_data_collection_enabled(client_options): |
200 | | - query_string = request_websocket.query_string.decode( |
201 | | - "utf-8", errors="replace" |
202 | | - ) |
203 | | - if query_string: |
204 | | - filtered_query_string = ( |
205 | | - _apply_data_collection_filtering_to_query_string( |
206 | | - query_string=query_string, |
207 | | - behaviour=client_options["data_collection"]["url_query_params"], |
208 | | - ) |
209 | | - ) |
210 | | - if filtered_query_string: |
211 | | - segment.set_attribute( |
212 | | - "url.query", |
213 | | - filtered_query_string, |
214 | | - ) |
215 | | - |
216 | | - parsed_url = parse_url(request_websocket.url) |
217 | | - segment.set_attribute( |
218 | | - "url.full", |
219 | | - f"{parsed_url.url}?{filtered_query_string}" |
220 | | - if filtered_query_string |
221 | | - else parsed_url.url, |
222 | | - ) |
223 | | - |
224 | | - if client_options["data_collection"]["user_info"]: |
225 | | - user_properties = {} |
226 | | - |
227 | | - if len(request_websocket.access_route) >= 1: |
228 | | - segment.set_attribute( |
229 | | - "client.address", request_websocket.access_route[0] |
230 | | - ) |
231 | | - user_properties["ip_address"] = request_websocket.access_route[0] |
232 | 197 |
|
233 | | - current_user_id = _get_current_user_id_from_quart() |
234 | | - if current_user_id: |
235 | | - user_properties["id"] = current_user_id |
236 | | - |
237 | | - if user_properties: |
238 | | - existing_user_properties = scope._user or {} |
239 | | - scope.set_user({**existing_user_properties, **user_properties}) |
240 | | - |
241 | | - elif should_send_default_pii(): |
242 | | - segment.set_attribute("url.full", request_websocket.url) |
243 | | - segment.set_attribute( |
244 | | - "url.query", |
245 | | - request_websocket.query_string.decode("utf-8", errors="replace"), |
| 198 | + query_string = request_websocket.query_string.decode("utf-8", errors="replace") |
| 199 | + if query_string: |
| 200 | + filtered_query_string = _apply_data_collection_filtering_to_query_string( |
| 201 | + query_string=query_string, |
| 202 | + behaviour=client_options["data_collection"]["url_query_params"], |
246 | 203 | ) |
| 204 | + if filtered_query_string: |
| 205 | + segment.set_attribute("url.query", filtered_query_string) |
| 206 | + |
| 207 | + parsed_url = parse_url(request_websocket.url) |
| 208 | + segment.set_attribute( |
| 209 | + "url.full", |
| 210 | + f"{parsed_url.url}?{filtered_query_string}" |
| 211 | + if filtered_query_string |
| 212 | + else parsed_url.url, |
| 213 | + ) |
247 | 214 |
|
| 215 | + if client_options["data_collection"]["user_info"]: |
248 | 216 | user_properties = {} |
| 217 | + |
249 | 218 | if len(request_websocket.access_route) >= 1: |
250 | 219 | segment.set_attribute( |
251 | 220 | "client.address", request_websocket.access_route[0] |
@@ -285,17 +254,7 @@ def inner(event: "Event", hint: "dict[str, Any]") -> "Event": |
285 | 254 | request_info["headers"] = _filter_headers(dict(request.headers)) |
286 | 255 |
|
287 | 256 | client_options = sentry_sdk.get_client().options |
288 | | - if has_data_collection_enabled(client_options): |
289 | | - if client_options["data_collection"]["user_info"]: |
290 | | - if len(request.access_route) >= 1: |
291 | | - request_info["env"] = {"REMOTE_ADDR": request.access_route[0]} |
292 | | - |
293 | | - current_user_id = _get_current_user_id_from_quart() |
294 | | - if current_user_id: |
295 | | - user_info = event.setdefault("user", {}) |
296 | | - user_info["id"] = current_user_id |
297 | | - |
298 | | - elif should_send_default_pii(): |
| 257 | + if client_options["data_collection"]["user_info"]: |
299 | 258 | if len(request.access_route) >= 1: |
300 | 259 | request_info["env"] = {"REMOTE_ADDR": request.access_route[0]} |
301 | 260 |
|
|
0 commit comments