From 336edf7b0e90d8d63bfc9babc14fbaf82bf9afe4 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Mon, 19 Feb 2024 14:12:55 +0100 Subject: [PATCH] Deprecate `last_event_id()`. (#2749) --- scripts/init_serverless_sdk.py | 1 + sentry_sdk/api.py | 1 + sentry_sdk/hub.py | 10 +++++++++- 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/scripts/init_serverless_sdk.py b/scripts/init_serverless_sdk.py index e620c1067b..be545b680b 100644 --- a/scripts/init_serverless_sdk.py +++ b/scripts/init_serverless_sdk.py @@ -5,6 +5,7 @@ Then the Handler function sstring should be replaced with 'sentry_sdk.integrations.init_serverless_sdk.sentry_lambda_handler' """ + import os import sys import re diff --git a/sentry_sdk/api.py b/sentry_sdk/api.py index ffa525ca66..1b56571bfa 100644 --- a/sentry_sdk/api.py +++ b/sentry_sdk/api.py @@ -205,6 +205,7 @@ def flush( @hubmethod def last_event_id(): # type: () -> Optional[str] + return Hub.current.last_event_id() diff --git a/sentry_sdk/hub.py b/sentry_sdk/hub.py index 21b59283aa..c339528821 100644 --- a/sentry_sdk/hub.py +++ b/sentry_sdk/hub.py @@ -283,7 +283,15 @@ def scope(self): def last_event_id(self): # type: () -> Optional[str] - """Returns the last event ID.""" + """ + Returns the last event ID. + + .. deprecated:: 1.40.5 + This function is deprecated and will be removed in a future release. The functions `capture_event`, `capture_message`, and `capture_exception` return the event ID directly. + """ + logger.warning( + "Deprecated: last_event_id is deprecated. This will be removed in the future. The functions `capture_event`, `capture_message`, and `capture_exception` return the event ID directly." + ) return self._last_event_id def bind_client(