Closed luisbravoa closed 1 year ago
Thanks for reaching out @luisbravoa. We will take this question internally and discuss amongst the team.
Hi @luisbravoa I thought I would reach out and let you know we have discussed internally whether we want to include the bundles in the npm package and have concluded, at least for now, that we will not be including them. If you would like to use a <script src=""
element to pull in the browser agent, our recommendation is to use our public CDN.
While we desire that customers using the Copy/Paste method of installing the browser agent copy the snippet from New Relic and embed the loader in their HTML, we understand that one size does not fit all. If you would like to use a script src tag, below is an example.
<script src="https://js-agent.newrelic.com/nr-loader-spa-1.239.1.min.js"></script>
All the loaders follow the same naming pattern nr-loader-[agentType]-[version].min.js
where [agentType]
can be rum
for the lite agent, full
for the pro agent, and spa
for the spa agent. The [version]
value will always match the version in our published releases. You may also leave off the .min
part if you would like an unminified version of the agent loader.
Keep in mind that this is not an officially supported installation mechanism because it does require the browser to download an additional resource before the agent can wrap globals and start intercepting events for harvesting. However, we do our best to try and capture as much information as possible to provide a complete observability picture. We do not currently recommend using async
or defer
for the agent loader script. Either of these could exacerbate the issue of missing data and, if the agent is not started before page load, may result in the agent not collecting any data. These attributes could also change the order in which globals are wrapped leading to strange interactions with other third-party libraries.
Hello @patrickhousley ,
Thanks for the consideration. My concerned would be the additional requests needed for the agent to be initialized. For our use case we prefer having the agent embedded in the document so we can minimize points of failure at application startup. To this end we are currently bundling the agent implementation ourselves and injecting it in the document, which work we expected.
Thanks again.
Hi @luisbravoa and thanks for providing more information about your use-case. Is your application served through some type of SSR or server-side application that can utilize APM injection? A lot of our language/APM agents support injecting the browser agent into the HTML.
We also have NerdGraph and Rest APIs that you could use to retrieve all the details you need from New Relic for instrumenting a specific browser entity. This is actually what the APM agents are doing behind the scenes to inject the browser agent 😉 .
You could also use something like node-fetch to retrieve the JS loader snippet from our CDN during your build.
Hey @patrickhousley ,
At this time we are not using the APM injection, the client logging is decoupled from the server logging, it might change in the future. Does APM agent injection allow for multiple browser agent instances? We have microfrontends and the library allows for each microfrontend to have it's on agent instance.
I believe we are implementing the fetching of the browser entity info.
Does APM agent injection allow for multiple browser agent instances? We have microfrontends and the library allows for each microfrontend to have it's on agent instance.
It really depends on how each MMF is served up so it's hard to say.
I think you are on the right track with implementing the fetching of the browser entity info. I would also suggest trying out the NPM package but it sounds like the timing of such an agent may not fit your use-case either.
Are you thinking on providing a bundled version of the library? The last version
0.0.9
did provide a bundled version that we could just inject into theindex.html
of the app and initialize early in the app's lifecycle, instead of including it in the application bundle.Summary
Having the bundled version allows the browser agent to be initialised before the application so fatal errors can be reported.
Desired Behavior
Provide an browser agent bundle like in version
0.0.9
.