Skip to content

Commit

Permalink
Start delivery regardless of auto_capture_sessions
Browse files Browse the repository at this point in the history
If auto_capture_sessions is False we still want to deliver any manual
sessions that may be left, so we should still start session delivery in
this case
  • Loading branch information
imjoehaines committed Dec 7, 2023
1 parent a2c2956 commit 7e88138
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 8 deletions.
3 changes: 2 additions & 1 deletion bugsnag/sessiontracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,10 @@ def __init__(self, configuration):
self.delivery_thread = None

def start_session(self):
if not self.auto_sessions and self.config.auto_capture_sessions:
if not self.auto_sessions:
self.auto_sessions = True
self.__start_delivery()

start_time = strftime('%Y-%m-%dT%H:%M:00', gmtime())
new_session = {
'id': uuid4().hex,
Expand Down
11 changes: 4 additions & 7 deletions tests/test_sessiontracker.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def test_session_tracker_starts_delivery_when_auto_capture_is_on(self):

assert self.server.sent_session_count == 1

def test_session_tracker_doesnt_start_delivery_when_auto_capture_is_off(self): # noqa
def test_session_tracker_starts_delivery_when_auto_capture_is_off(self):
client = Client(
api_key='a05afff2bd2ffaf0ab0f52715bbdcffd',
auto_capture_sessions=False,
Expand All @@ -188,11 +188,8 @@ def test_session_tracker_doesnt_start_delivery_when_auto_capture_is_off(self):

client.session_tracker.start_session()

assert client.session_tracker.delivery_thread is None
force_timer_to_fire(client.session_tracker.delivery_thread)

# we expect not to receive a session request, so this wait should
# timeout
with pytest.raises(MissingRequestError):
self.server.wait_for_session()
self.server.wait_for_session()

assert self.server.sent_session_count == 0
assert self.server.sent_session_count == 1

0 comments on commit 7e88138

Please sign in to comment.