Skip to content

Commit

Permalink
fix(spotlight): Use the spotlight_url passed into the SDK when loadin…
Browse files Browse the repository at this point in the history
…g Spotlight (#3871)

When we inject spotlight, we don't set the correct sidecar URL. This is an issue when a user defines a custom sidecar URL where we are able to load Spotlight UI from the correct URL but don't tell it the correct sidecar URL, making it non-functional.

---------

Co-authored-by: Ivana Kellyer <ivana.kellyer@sentry.io>
  • Loading branch information
BYK and sentrivana authored Dec 14, 2024
1 parent 1239499 commit 81b8063
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 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

0 comments on commit 81b8063

Please sign in to comment.