From c49fb0d069e7eec33cea28fbfae4149e2674b52c Mon Sep 17 00:00:00 2001 From: Eric Duong Date: Tue, 31 Oct 2023 14:36:10 -0400 Subject: [PATCH] chore(data-warehouse): filter sensitive values (#18315) add handler --- posthog/settings/sentry.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/posthog/settings/sentry.py b/posthog/settings/sentry.py index 606cb0cfae1c0..d38d73300f792 100644 --- a/posthog/settings/sentry.py +++ b/posthog/settings/sentry.py @@ -15,7 +15,7 @@ from datetime import timedelta -def before_send_transaction(event, hint): +def before_send(event, hint): for exception in event.get("exception", {}).get("values", []): for frame in exception.get("stacktrace", {}).get("frames", []): args = frame.get("vars", {}).get("args", {}) @@ -24,6 +24,10 @@ def before_send_transaction(event, hint): if "sensitive" in key: frame["vars"]["args"][key] = "[Filtered]" + return event + + +def before_send_transaction(event, hint): url_string = event.get("request", {}).get("url") if url_string and "decide" in url_string: DECIDE_SAMPLE_RATE = 0.00001 # 0.001% @@ -155,6 +159,7 @@ def sentry_init() -> None: # Configures the sample rate for error events, in the range of 0.0 to 1.0 (default). # If set to 0.1 only 10% of error events will be sent. Events are picked randomly. traces_sampler=traces_sampler, + before_send=before_send, before_send_transaction=before_send_transaction, _experiments={ # https://docs.sentry.io/platforms/python/profiling/