Fix NewRelic browser monitoring - #22
Merged
Merged
Conversation
…g_footer() call
The NewRelic Python agent removed the `get_browser_timing_footer()` API;
`get_browser_timing_header()` now returns the complete browser monitoring
script. Every request was hitting the generic exception handler in both
`newrelic_browser_timing()` and `_get_newrelic_browser_scripts()`, logging
"module 'newrelic.agent' has no attribute 'get_browser_timing_footer'" and
returning empty strings, which meant no browser JS was ever injected.
Changes:
- Remove all calls to `newrelic.agent.get_browser_timing_footer()` in app.py
- Simplify `_get_newrelic_browser_scripts()` to `_get_newrelic_browser_script()`
returning a single string instead of a tuple
- Simplify `_inject_newrelic_into_html()` to only inject the header script
- Remove `newrelic_footer` from context processor return values
- Remove `{{ newrelic_footer }}` from all three Jinja2 templates:
base.html, display.html, display/slideshow.html
- Bump version to 0.3.5
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The NewRelic agent's get_browser_timing_header() is typed as returning Any, which causes a mypy no-any-return error when used in a function declared to return str. Wrapping with str() satisfies the type checker. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
Fixes New Relic browser monitoring injection after the Python agent removed get_browser_timing_footer(), ensuring the browser script is injected via get_browser_timing_header() only and cleaning up template usage accordingly.
Changes:
- Remove New Relic “footer” injection from Jinja2 templates and simplify the Flask context processor to only provide
newrelic_header. - Update the React admin
index.htmlinjection helper to inject a single New Relic browser script into<head>. - Bump application version to
0.3.5.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
pyproject.toml |
Bumps project version to 0.3.5. |
kiosk_show_replacement/app.py |
Removes footer usage; updates context processor and HTML injection to use header-only script. |
kiosk_show_replacement/templates/base.html |
Removes {{ newrelic_footer }} from the base template. |
kiosk_show_replacement/templates/display.html |
Removes {{ newrelic_footer }} from the display template. |
kiosk_show_replacement/templates/display/slideshow.html |
Removes {{ newrelic_footer }} from the slideshow display template. |
kiosk_show_replacement/__init__.py |
Bumps package __version__ to 0.3.5. |
Add TestNewRelicBrowserTiming test class covering: - Context processor injects browser script when newrelic agent is available - Context processor returns empty markup when newrelic is not installed - Context processor handles exceptions from get_browser_timing_header gracefully - Admin SPA HTML injection works when built frontend exists Tests use sys.modules patching to mock the newrelic.agent module without requiring the newrelic package to be installed in the test environment. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
get_browser_timing_footer()APIget_browser_timing_header()alone; the footer function no longer exists{{ newrelic_footer }}from all Jinja2 templates and simplify the injection logic inapp.pyTest plan
get_browser_timing_footererrors in container logs/admin/loginand/display/<name>to confirm NewRelic browser JS is present in<head>🤖 Generated with Claude Code