Skip to content

Commit deade2d

Browse files
authored
Added default value for auto_session_tracking
* fix(asgi): Added default value for auto_session_tracking to make it work when `init()` is not called. refs #1334
1 parent 91b0387 commit deade2d

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

sentry_sdk/sessions.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,27 @@
1010
from sentry_sdk.utils import format_timestamp
1111

1212
if MYPY:
13-
from typing import Callable
14-
from typing import Optional
1513
from typing import Any
14+
from typing import Callable
1615
from typing import Dict
17-
from typing import List
1816
from typing import Generator
17+
from typing import List
18+
from typing import Optional
19+
from typing import Union
1920

2021

2122
def is_auto_session_tracking_enabled(hub=None):
22-
# type: (Optional[sentry_sdk.Hub]) -> bool
23+
# type: (Optional[sentry_sdk.Hub]) -> Union[Any, bool, None]
2324
"""Utility function to find out if session tracking is enabled."""
2425
if hub is None:
2526
hub = sentry_sdk.Hub.current
27+
2628
should_track = hub.scope._force_auto_session_tracking
29+
2730
if should_track is None:
2831
client_options = hub.client.options if hub.client else {}
29-
should_track = client_options["auto_session_tracking"]
32+
should_track = client_options.get("auto_session_tracking", False)
33+
3034
return should_track
3135

3236

0 commit comments

Comments
 (0)