If your organization has strict requirements about Content Security Policy (CSP) v2, you may need to host the New Relic Browser agent in order to properly install and run it. For example, if the New Relic domain hosting the Browser agent is being blocked by your website, you may see an error similar to this:
Browser agent.js is unable to run because it violates the following Content Security Protocol directive: script-src = *.google.com other URLs
.js file. This allows the page to reference the
.js file during page load.
In order to host the Browser agent with your app, make sure you follow these requirements:
CSP and Browser agent
Application or platform
Your app or platform where your site is hosted must meet New Relic Browser's standard compatibility requirements. Exception: CSP restrictions prevent you from linking an APM app for Browser monitoring.
You must have a Pro+SPA Browser subscription for your app.
Host location for domains
Browser agent version
Your selected app must use the latest Browser agent version.
Follow your organization's standard procedures to request a CSP exception. Then add both of these New Relic Browser domains to your CSP whitelist:
https://js-agent.newrelic.com: This is where the New Relic Browser agent is hosted. The Browser agent download requires three files to run. Two are downloaded after the initial agent is run to continue capturing performance data.
https://bam.nr-data.net: This is the endpoint where the New Relic Browser agent receives data from your site.
Here is example HTML to add to the head of your site:
Content-Security-Policy: default-src 'self' https://js-agent.newrelic.com https://bam.nr-data.net
To create and host a
- Go to rpm.newrelic.com/browser.
- From the list of Browser apps, select the app for which you want to self-host the Browser agent.
- Save and exit the Browser app's Application settings page.
Continue with the procedures to create a
.js file for your page.
- Delete the first line (
- Save the text file as
nr-spa-VERSION_NUMBER.min.js, where VERSION_NUMBER is the latest Browser agent version.
- Reference the
.jsfile in the
<head>of your webpage.
If you need more help, check out these support and learning resources:
- Browse the Explorers Hub to get help from the community and join in discussions.
- Find answers on our sites and learn how to use our support portal.
- Run New Relic Diagnostics, our troubleshooting tool for Linux, Windows, and macOS.
- Review New Relic's data security and licenses documentation.