Skip to content

Commit

Permalink
Merge branch 'master' into feature/typer-integration
Browse files Browse the repository at this point in the history
  • Loading branch information
patrick91 authored Dec 16, 2024
2 parents adb1183 + 81b8063 commit dc49206
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions sentry_sdk/spotlight.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ def capture_envelope(self, envelope):

SPOTLIGHT_JS_ENTRY_PATH = "/assets/main.js"
SPOTLIGHT_JS_SNIPPET_PATTERN = (
'<script type="module" crossorigin src="{}"></script>'
"<script>window.__spotlight = {{ initOptions: {{ sidecarUrl: '{spotlight_url}', fullPage: false }} }};</script>\n"
'<script type="module" crossorigin src="{spotlight_js_url}"></script>\n'
)
SPOTLIGHT_ERROR_PAGE_SNIPPET = (
'<html><base href="{spotlight_url}">\n'
Expand Down Expand Up @@ -113,7 +114,8 @@ def spotlight_script(self):
)
urllib.request.urlopen(req)
self._spotlight_script = SPOTLIGHT_JS_SNIPPET_PATTERN.format(
spotlight_js_url
spotlight_url=self._spotlight_url,
spotlight_js_url=spotlight_js_url,
)
except urllib.error.URLError as err:
sentry_logger.debug(
Expand Down Expand Up @@ -210,13 +212,13 @@ def setup_spotlight(options):
if not isinstance(url, str):
return None

if (
settings is not None
and settings.DEBUG
and env_to_bool(os.environ.get("SENTRY_SPOTLIGHT_ON_ERROR", "1"))
and env_to_bool(os.environ.get("SENTRY_SPOTLIGHT_MIDDLEWARE", "1"))
):
with capture_internal_exceptions():
with capture_internal_exceptions():
if (
settings is not None
and settings.DEBUG
and env_to_bool(os.environ.get("SENTRY_SPOTLIGHT_ON_ERROR", "1"))
and env_to_bool(os.environ.get("SENTRY_SPOTLIGHT_MIDDLEWARE", "1"))
):
middleware = settings.MIDDLEWARE
if DJANGO_SPOTLIGHT_MIDDLEWARE_PATH not in middleware:
settings.MIDDLEWARE = type(middleware)(
Expand Down

0 comments on commit dc49206

Please sign in to comment.