diff --git a/sentry_sdk/_types.py b/sentry_sdk/_types.py index 4e3c195cc6..6afb619121 100644 --- a/sentry_sdk/_types.py +++ b/sentry_sdk/_types.py @@ -77,6 +77,7 @@ class SDKInfo(TypedDict): ], # TODO: We can expand on this type "check_in_id": str, "contexts": dict[str, dict[str, object]], + "debug_meta": dict[str, Any], "dist": str, "duration": Optional[float], "environment": str, diff --git a/sentry_sdk/client.py b/sentry_sdk/client.py index cf345c41f9..71bbad9a9b 100644 --- a/sentry_sdk/client.py +++ b/sentry_sdk/client.py @@ -474,12 +474,13 @@ def _prepare_event( scope, # type: Optional[Scope] ): # type: (...) -> Optional[Event] + is_transaction = event.get("type") == "transaction" + is_checkin = event.get("type") == "check_in" if event.get("timestamp") is None: event["timestamp"] = datetime.now(timezone.utc) if scope is not None: - is_transaction = event.get("type") == "transaction" spans_before = len(event.get("spans", [])) event_ = scope.apply_to_event(event, hint, self.options) @@ -541,6 +542,11 @@ def _prepare_event( if event.get("platform") is None: event["platform"] = "python" + if not is_transaction and not is_checkin: + event.setdefault("debug_meta", {}).update( + {"project_root": self.options["project_root"]} + ) + event = handle_in_app( event, self.options["in_app_exclude"], diff --git a/tests/new_scopes_compat/test_new_scopes_compat_event.py b/tests/new_scopes_compat/test_new_scopes_compat_event.py index db1e5fec4b..606d3f4535 100644 --- a/tests/new_scopes_compat/test_new_scopes_compat_event.py +++ b/tests/new_scopes_compat/test_new_scopes_compat_event.py @@ -136,6 +136,7 @@ def create_expected_error_event(trx, span): "integrations": integrations, }, "platform": "python", + "debug_meta": {"project_root": mock.ANY}, "_meta": { "user": {"ip_address": {"": {"rem": [["!config", "s"]]}}}, "extra": {