Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 9 additions & 5 deletions sentry_sdk/sessions.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,23 +10,27 @@
from sentry_sdk.utils import format_timestamp

if MYPY:
from typing import Callable
from typing import Optional
from typing import Any
from typing import Callable
from typing import Dict
from typing import List
from typing import Generator
from typing import List
from typing import Optional
from typing import Union


def is_auto_session_tracking_enabled(hub=None):
# type: (Optional[sentry_sdk.Hub]) -> bool
# type: (Optional[sentry_sdk.Hub]) -> Union[Any, bool, None]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you sure this shouldn't have stayed bool?

perhaps a return bool(should_track) can avoid mypy errors

"""Utility function to find out if session tracking is enabled."""
if hub is None:
hub = sentry_sdk.Hub.current

should_track = hub.scope._force_auto_session_tracking

if should_track is None:
client_options = hub.client.options if hub.client else {}
should_track = client_options["auto_session_tracking"]
should_track = client_options.get("auto_session_tracking", False)

return should_track


Expand Down