1
1
import os
2
2
import time
3
+ import warnings
3
4
from threading import Thread , Lock
4
5
from contextlib import contextmanager
5
6
21
22
22
23
def is_auto_session_tracking_enabled (hub = None ):
23
24
# type: (Optional[sentry_sdk.Hub]) -> Union[Any, bool, None]
24
- """Utility function to find out if session tracking is enabled."""
25
- # TODO: add deprecation warning
25
+ """DEPRECATED: Utility function to find out if session tracking is enabled."""
26
+
27
+ # Internal callers should use private _is_auto_session_tracking_enabled, instead.
28
+ warnings .warn (
29
+ "This function is deprecated and will be removed in the next major release. "
30
+ "There is no public API replacement." ,
31
+ DeprecationWarning ,
32
+ stacklevel = 2 ,
33
+ )
26
34
27
35
if hub is None :
28
36
hub = sentry_sdk .Hub .current
@@ -44,7 +52,9 @@ def auto_session_tracking(hub=None, session_mode="application"):
44
52
45
53
if hub is None :
46
54
hub = sentry_sdk .Hub .current
47
- should_track = is_auto_session_tracking_enabled (hub )
55
+ with warnings .catch_warnings ():
56
+ warnings .simplefilter ("ignore" , DeprecationWarning )
57
+ should_track = is_auto_session_tracking_enabled (hub )
48
58
if should_track :
49
59
hub .start_session (session_mode = session_mode )
50
60
try :
@@ -57,12 +67,26 @@ def auto_session_tracking(hub=None, session_mode="application"):
57
67
def is_auto_session_tracking_enabled_scope (scope ):
58
68
# type: (sentry_sdk.Scope) -> bool
59
69
"""
60
- Utility function to find out if session tracking is enabled.
70
+ DEPRECATED: Utility function to find out if session tracking is enabled.
71
+ """
61
72
62
- TODO: This uses the new scopes. When the Hub is removed, the function
63
- is_auto_session_tracking_enabled should be removed and this function
64
- should be renamed to is_auto_session_tracking_enabled.
73
+ warnings .warn (
74
+ "This function is deprecated and will be removed in the next major release. "
75
+ "There is no public API replacement." ,
76
+ DeprecationWarning ,
77
+ stacklevel = 2 ,
78
+ )
79
+
80
+ # Internal callers should use private _is_auto_session_tracking_enabled, instead.
81
+ return _is_auto_session_tracking_enabled (scope )
82
+
83
+
84
+ def _is_auto_session_tracking_enabled (scope ):
85
+ # type: (sentry_sdk.Scope) -> bool
65
86
"""
87
+ Utility function to find out if session tracking is enabled.
88
+ """
89
+
66
90
should_track = scope ._force_auto_session_tracking
67
91
if should_track is None :
68
92
client_options = sentry_sdk .get_client ().options
@@ -81,7 +105,7 @@ def auto_session_tracking_scope(scope, session_mode="application"):
81
105
auto_session_tracking should be removed and this function
82
106
should be renamed to auto_session_tracking.
83
107
"""
84
- should_track = is_auto_session_tracking_enabled_scope (scope )
108
+ should_track = _is_auto_session_tracking_enabled (scope )
85
109
if should_track :
86
110
scope .start_session (session_mode = session_mode )
87
111
try :
0 commit comments