@@ -87,24 +87,24 @@ def get(self):
8787 "init_kwargs, expected_cookies" ,
8888 [
8989 pytest .param (
90- {"send_default_pii " : True },
90+ {"data_collection " : {} },
9191 {
92- "jwt" : "tokenval" ,
92+ "jwt" : SENSITIVE_DATA_SUBSTITUTE ,
9393 "theme" : "dark" ,
9494 "lang" : "en" ,
95- "identity" : "alice" ,
95+ "identity" : SENSITIVE_DATA_SUBSTITUTE ,
9696 },
97- id = "send_default_pii_true " ,
97+ id = "data_collection_default " ,
9898 ),
9999 pytest .param (
100- {"send_default_pii " : False },
101- None ,
102- id = "send_default_pii_false" ,
103- ) ,
104- pytest . param (
105- {} ,
106- None ,
107- id = "defaults " ,
100+ {"data_collection " : { "cookies" : { "mode" : "denylist" , "terms" : []}} },
101+ {
102+ "jwt" : SENSITIVE_DATA_SUBSTITUTE ,
103+ "theme" : "dark" ,
104+ "lang" : "en" ,
105+ "identity" : SENSITIVE_DATA_SUBSTITUTE ,
106+ } ,
107+ id = "data_collection_denylist_empty_terms " ,
108108 ),
109109 pytest .param (
110110 {"data_collection" : {"cookies" : {"mode" : "off" }}},
@@ -155,19 +155,6 @@ def get(self):
155155 },
156156 id = "data_collection_allowlist_sensitive_term" ,
157157 ),
158- pytest .param (
159- {
160- "send_default_pii" : False ,
161- "data_collection" : {"cookies" : {"mode" : "denylist" }},
162- },
163- {
164- "jwt" : SENSITIVE_DATA_SUBSTITUTE ,
165- "theme" : "dark" ,
166- "lang" : "en" ,
167- "identity" : SENSITIVE_DATA_SUBSTITUTE ,
168- },
169- id = "data_collection_wins_over_send_default_pii" ,
170- ),
171158 ],
172159)
173160def test_cookie_data_collection (
@@ -194,19 +181,14 @@ async def get(self):
194181
195182_QUERY_PARAM_DATA_COLLECTION_CASES = [
196183 pytest .param (
197- {"send_default_pii" : True },
198- "toy=tennisball&color=red&auth=secret" ,
199- id = "send_default_pii_true" ,
200- ),
201- pytest .param (
202- {"send_default_pii" : False },
203- None ,
204- id = "send_default_pii_false" ,
184+ {"data_collection" : {"url_query_params" : {"mode" : "denylist" , "terms" : []}}},
185+ "toy=tennisball&color=red&auth=%5BFiltered%5D" ,
186+ id = "data_collection_denylist_empty_terms" ,
205187 ),
206188 pytest .param (
207- {},
189+ {"data_collection" : { "url_query_params" : { "mode" : "off" }} },
208190 None ,
209- id = "defaults " ,
191+ id = "data_collection_off " ,
210192 ),
211193 pytest .param (
212194 {"data_collection" : {}},
@@ -240,19 +222,6 @@ async def get(self):
240222 "toy=%5BFiltered%5D&color=%5BFiltered%5D&auth=%5BFiltered%5D" ,
241223 id = "data_collection_allowlist_sensitive_term" ,
242224 ),
243- pytest .param (
244- {"data_collection" : {"url_query_params" : {"mode" : "off" }}},
245- None ,
246- id = "data_collection_off" ,
247- ),
248- pytest .param (
249- {
250- "send_default_pii" : True ,
251- "data_collection" : {"url_query_params" : {"mode" : "off" }},
252- },
253- None ,
254- id = "data_collection_wins_over_send_default_pii" ,
255- ),
256225]
257226
258227
@@ -279,19 +248,10 @@ def test_url_query_data_collection(
279248
280249 (server_span ,) = [item .payload for item in items ]
281250
282- data_collection_enabled = "data_collection" in init_kwargs
283- url_attrs_expected = data_collection_enabled or init_kwargs .get (
284- "send_default_pii" , False
285- )
286-
287251 if expected_query is None :
288252 assert "url.query" not in server_span ["attributes" ]
289- if url_attrs_expected :
290- assert server_span ["attributes" ]["url.full" ].endswith ("/hi" )
291- assert server_span ["attributes" ]["url.path" ] == "/hi"
292- else :
293- assert "url.full" not in server_span ["attributes" ]
294- assert "url.path" not in server_span ["attributes" ]
253+ assert server_span ["attributes" ]["url.full" ].endswith ("/hi" )
254+ assert server_span ["attributes" ]["url.path" ] == "/hi"
295255 else :
296256 assert server_span ["attributes" ]["url.query" ] == expected_query
297257 assert server_span ["attributes" ]["url.full" ].endswith (f"/hi?{ expected_query } " )
@@ -465,7 +425,17 @@ def test_request_body_data_collection_event_processor(
465425 assert "data" not in event ["request" ]
466426
467427
468- @pytest .mark .parametrize ("send_pii" , [True , False ])
428+ @pytest .mark .parametrize (
429+ "data_collection, expect_query" ,
430+ [
431+ pytest .param ({}, True , id = "data_collection_default" ),
432+ pytest .param (
433+ {"url_query_params" : {"mode" : "off" }},
434+ False ,
435+ id = "data_collection_url_query_params_off" ,
436+ ),
437+ ],
438+ )
469439@pytest .mark .parametrize (
470440 "handler,code" ,
471441 [
@@ -480,12 +450,13 @@ def test_transactions(
480450 capture_items ,
481451 handler ,
482452 code ,
483- send_pii ,
453+ data_collection ,
454+ expect_query ,
484455):
485456 sentry_init (
486457 integrations = [TornadoIntegration ()],
487458 traces_sample_rate = 1.0 ,
488- send_default_pii = send_pii ,
459+ data_collection = data_collection ,
489460 )
490461
491462 items = capture_items ("event" , "span" )
@@ -533,15 +504,14 @@ def test_transactions(
533504 assert server_segment ["status" ] == ("ok" if code == 200 else "error" )
534505 assert client_segment ["trace_id" ] == server_segment ["trace_id" ]
535506
536- if send_pii :
507+ assert server_segment ["attributes" ]["url.path" ] == "/hi"
508+ if expect_query :
537509 assert server_segment ["attributes" ]["url.query" ] == "foo=bar"
538510 assert server_segment ["attributes" ]["url.full" ].endswith ("/hi?foo=bar" )
539511 assert server_segment ["attributes" ]["url.full" ].startswith ("http://" )
540- assert server_segment ["attributes" ]["url.path" ] == "/hi"
541512 else :
542513 assert "url.query" not in server_segment ["attributes" ]
543- assert "url.full" not in server_segment ["attributes" ]
544- assert "url.path" not in server_segment ["attributes" ]
514+ assert server_segment ["attributes" ]["url.full" ].endswith ("/hi" )
545515
546516
547517def test_400_not_logged (tornado_testcase , sentry_init , capture_events ):
@@ -561,7 +531,10 @@ def get(self):
561531
562532
563533def test_user_auth (tornado_testcase , sentry_init , capture_events ):
564- sentry_init (integrations = [TornadoIntegration ()], send_default_pii = True )
534+ sentry_init (
535+ integrations = [TornadoIntegration ()],
536+ data_collection = {"user_info" : True },
537+ )
565538 events = capture_events ()
566539
567540 class UserHandler (RequestHandler ):
@@ -629,7 +602,7 @@ def get_current_user(self):
629602
630603
631604def test_formdata (tornado_testcase , sentry_init , capture_events ):
632- sentry_init (integrations = [TornadoIntegration ()], send_default_pii = True )
605+ sentry_init (integrations = [TornadoIntegration ()], data_collection = {} )
633606 events = capture_events ()
634607
635608 class FormdataHandler (RequestHandler ):
@@ -654,7 +627,7 @@ def post(self):
654627
655628
656629def test_json (tornado_testcase , sentry_init , capture_events ):
657- sentry_init (integrations = [TornadoIntegration ()], send_default_pii = True )
630+ sentry_init (integrations = [TornadoIntegration ()], data_collection = {} )
658631 events = capture_events ()
659632
660633 class FormdataHandler (RequestHandler ):
0 commit comments