From 336edf7b0e90d8d63bfc9babc14fbaf82bf9afe4 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Mon, 19 Feb 2024 14:12:55 +0100 Subject: [PATCH 1/2] 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( From 93f89e00f2705a90eb77cb69dd2316cac3242e87 Mon Sep 17 00:00:00 2001 From: Anton Pirker Date: Mon, 19 Feb 2024 14:25:07 +0100 Subject: [PATCH 2/2] Added last_event_id() to the stuff that has been removed. --- MIGRATION_GUIDE.md | 1 + 1 file changed, 1 insertion(+) diff --git a/MIGRATION_GUIDE.md b/MIGRATION_GUIDE.md index 7936fa52bf..9a24e8d11d 100644 --- a/MIGRATION_GUIDE.md +++ b/MIGRATION_GUIDE.md @@ -22,6 +22,7 @@ Looking to upgrade from Sentry SDK 1.x to 2.x? Here's a comprehensive list of wh - Removed support for Celery 3.\*. - Removed support for Django 1.8, 1.9, 1.10. - Removed support for Flask 0.\*. +- Removed `last_event_id()` top level API. The last event Id is still returned by `capture_event()`, `capture_exception()` and `capture_message()` but the top level api `sentry_sdk.last_event_id()` has been removed. - `sentry_sdk._functools` was removed. - A number of compatibility utilities were removed from `sentry_sdk._compat`: the constants `PY2` and `PY33`; the functions `datetime_utcnow`, `utc_from_timestamp`, `implements_str`, `contextmanager`; and the aliases `text_type`, `string_types`, `number_types`, `int_types`, `iteritems`, `binary_sequence_types`. - The deprecated `with_locals` configuration option was removed. Use `include_local_variables` instead. See https://docs.sentry.io/platforms/python/configuration/options/#include-local-variables.