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 d54f693 commit 63c32d1
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 10 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ Changelog
* Avoid using deprecated `flask.__version__` attribute
[#365](https://github.com/bugsnag/bugsnag-python/pull/365)

### Bug fixes

* Ensure the session delivery queue is started regardless of `auto_capture_sessions` configuration
[#367](https://github.com/bugsnag/bugsnag-python/pull/367)

## v4.6.0 (2023-09-05)

### Enhancements
Expand Down
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
14 changes: 5 additions & 9 deletions tests/test_sessiontracker.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import pytest
import logging
import platform

from bugsnag import Client
from bugsnag.configuration import Configuration
from bugsnag.notifier import _NOTIFIER_INFORMATION
from bugsnag.sessiontracker import SessionTracker
from tests.utils import IntegrationTest, MissingRequestError
from tests.utils import IntegrationTest
from unittest.mock import Mock


Expand Down Expand Up @@ -178,7 +177,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 +187,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 63c32d1

Please sign in to comment.