Skip to content

Commit 724c6e0

Browse files
Merge pull request #400 from bugsnag/release/v4.8.0
Release v4.8.0
2 parents a8ac181 + 1e09d28 commit 724c6e0

File tree

17 files changed

+123
-236
lines changed

17 files changed

+123
-236
lines changed

.github/workflows/license-audit.yml

Lines changed: 0 additions & 39 deletions
This file was deleted.

.github/workflows/maze-runner.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
python-version: ['3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
12+
python-version: ['3.5', '3.6', '3.7', '3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
1313

1414
steps:
1515
- uses: actions/checkout@v4

.github/workflows/python-package.yml

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,17 @@ jobs:
99
strategy:
1010
fail-fast: false
1111
matrix:
12-
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11', '3.12']
12+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12', '3.13']
1313
os: ['ubuntu-latest']
1414
include:
15-
- python-version: '3.5'
16-
os: 'ubuntu-20.04'
17-
pip-trusted-host: 'pypi.python.org pypi.org files.pythonhosted.org'
18-
- python-version: '3.6'
19-
os: 'ubuntu-20.04'
15+
# Python 3.5 and 3.6 tests skipped pending PLAT-14414
16+
# - python-version: '3.5'
17+
# os: 'ubuntu-22.04'
18+
# pip-trusted-host: 'pypi.python.org pypi.org files.pythonhosted.org'
19+
# - python-version: '3.6'
20+
# os: 'ubuntu-22.04'
21+
- python-version: '3.7'
22+
os: 'ubuntu-22.04'
2023

2124
steps:
2225
- uses: actions/checkout@v4

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
.aws-sam
22
maze-runner.log
33
maze_output
4+
Gemfile.lock
45

56
*.py[co]
67

@@ -37,3 +38,4 @@ htmlcov
3738
my_env
3839
venv
3940
.idea
41+
*.iml

CHANGELOG.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
11
Changelog
22
=========
33

4+
## v4.8.0 (2024-07-08)
5+
6+
### Enhancements
7+
8+
* Remove deprecated `datetime.utcnow()` method call from utils class
9+
[#394](https://github.com/bugsnag/bugsnag-python/pull/394).
10+
* Set default endpoints based on API key
11+
[#399](https://github.com/bugsnag/bugsnag-php/pull/399)
12+
413
## v4.7.1 (2024-05-22)
514

615
### Bug fixes

Gemfile.lock

Lines changed: 0 additions & 143 deletions
This file was deleted.

bugsnag/client.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,11 @@ class Client:
3232
"""
3333

3434
def __init__(self, configuration: Optional[Configuration] = None,
35-
install_sys_hook=True, **kwargs):
35+
install_sys_hook=True, configure=True, **kwargs):
3636
self.configuration = configuration or Configuration() # type: Configuration # noqa: E501
3737
self.session_tracker = SessionTracker(self.configuration)
38-
self.configuration.configure(**kwargs)
38+
if configure:
39+
self.configuration.configure(**kwargs)
3940
self._context = ContextLocalState(self)
4041
self._request_tracker = RequestTracker()
4142

bugsnag/configuration.py

Lines changed: 37 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,11 @@
3030
validate_int_setter,
3131
validate_path_setter
3232
)
33-
from bugsnag.delivery import (create_default_delivery, DEFAULT_ENDPOINT,
34-
DEFAULT_SESSIONS_ENDPOINT)
33+
from bugsnag.delivery import (create_default_delivery,
34+
DEFAULT_ENDPOINT,
35+
DEFAULT_SESSIONS_ENDPOINT,
36+
HUB_ENDPOINT,
37+
HUB_SESSIONS_ENDPOINT)
3538
from bugsnag.uwsgi import warn_if_running_uwsgi_without_threads
3639
from bugsnag.error import Error
3740

@@ -55,6 +58,11 @@
5558
_sentinel = object()
5659

5760

61+
def _is_hub_api_key(api_key: str) -> bool:
62+
hub_prefix = "00000"
63+
return api_key is not None and api_key.startswith(hub_prefix)
64+
65+
5866
class Configuration:
5967
"""
6068
Global app-level Bugsnag configuration settings.
@@ -83,8 +91,8 @@ def __init__(self, logger=_sentinel):
8391
"django.http.Http404",
8492
"django.http.response.Http404",
8593
]
86-
self.endpoint = DEFAULT_ENDPOINT
87-
self.session_endpoint = DEFAULT_SESSIONS_ENDPOINT
94+
self.endpoint = None
95+
self.session_endpoint = None
8896
self.auto_capture_sessions = True
8997
self.traceback_exclude_modules = []
9098

@@ -126,8 +134,6 @@ def configure(self, api_key=None, app_type=None, app_version=None,
126134
Validate and set configuration options. Will warn if an option is of an
127135
incorrect type.
128136
"""
129-
if api_key is not None:
130-
self.api_key = api_key
131137
if app_type is not None:
132138
self.app_type = app_type
133139
if app_version is not None:
@@ -140,8 +146,6 @@ def configure(self, api_key=None, app_type=None, app_version=None,
140146
self.auto_capture_sessions = auto_capture_sessions
141147
if delivery is not None:
142148
self.delivery = delivery
143-
if endpoint is not None:
144-
self.endpoint = endpoint
145149
if hostname is not None:
146150
self.hostname = hostname
147151
if ignore_classes is not None:
@@ -162,8 +166,6 @@ def configure(self, api_key=None, app_type=None, app_version=None,
162166
self.send_code = send_code
163167
if send_environment is not None:
164168
self.send_environment = send_environment
165-
if session_endpoint is not None:
166-
self.session_endpoint = session_endpoint
167169
if traceback_exclude_modules is not None:
168170
self.traceback_exclude_modules = traceback_exclude_modules
169171
if logger is not _sentinel:
@@ -175,6 +177,11 @@ def configure(self, api_key=None, app_type=None, app_version=None,
175177
if max_breadcrumbs is not None:
176178
self.max_breadcrumbs = max_breadcrumbs
177179

180+
# Default endpoints depend on the API key
181+
if api_key is not None:
182+
self.api_key = api_key
183+
self._initialize_endpoints(endpoint, session_endpoint, self.api_key)
184+
178185
return self
179186

180187
def get(self, name):
@@ -584,6 +591,26 @@ def _create_null_logger(self) -> logging.Logger:
584591

585592
return logger
586593

594+
def _initialize_endpoints(self, endpoint, session_endpoint, api_key):
595+
# Default endpoints depending on the API key, if not already set
596+
if (
597+
endpoint is None and
598+
session_endpoint is None and
599+
self.endpoint is None and
600+
self.session_endpoint is None
601+
):
602+
if _is_hub_api_key(api_key):
603+
self.endpoint = HUB_ENDPOINT
604+
self.session_endpoint = HUB_SESSIONS_ENDPOINT
605+
else:
606+
self.endpoint = DEFAULT_ENDPOINT
607+
self.session_endpoint = DEFAULT_SESSIONS_ENDPOINT
608+
# Do set endpoints if explicitly provided
609+
if endpoint is not None:
610+
self.endpoint = endpoint
611+
if session_endpoint is not None:
612+
self.session_endpoint = session_endpoint
613+
587614

588615
class RequestConfiguration:
589616
"""

bugsnag/delivery.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828

2929
DEFAULT_ENDPOINT = 'https://notify.bugsnag.com'
3030
DEFAULT_SESSIONS_ENDPOINT = 'https://sessions.bugsnag.com'
31+
HUB_ENDPOINT = 'https://notify.insighthub.smartbear.com'
32+
HUB_SESSIONS_ENDPOINT = 'https://sessions.insighthub.smartbear.com'
3133

3234
__all__ = ('default_headers', 'Delivery')
3335

@@ -82,8 +84,10 @@ def deliver_sessions(self, config, payload: Any, options=None):
8284
"""
8385
Sends sessions to Bugsnag
8486
"""
85-
if (config.endpoint != DEFAULT_ENDPOINT and config.session_endpoint ==
86-
DEFAULT_SESSIONS_ENDPOINT):
87+
if ((config.endpoint != DEFAULT_ENDPOINT and
88+
config.session_endpoint == DEFAULT_SESSIONS_ENDPOINT) or
89+
(config.endpoint != HUB_ENDPOINT and
90+
config.session_endpoint == HUB_SESSIONS_ENDPOINT)):
8791
if not self.sent_session_warning:
8892
warnings.warn('The session endpoint has not been configured. '
8993
'No sessions will be sent to Bugsnag.')

bugsnag/legacy.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from bugsnag.configuration import RequestConfiguration
88
from bugsnag.client import Client
99

10-
default_client = Client()
10+
default_client = Client(configure=False)
1111
configuration = default_client.configuration
1212
logger = configuration.logger
1313
ExcInfoType = Tuple[Type, Exception, types.TracebackType]

0 commit comments

Comments
 (0)