newrelic / newrelic-browser-agent

New Relic Browser Agent
Apache License 2.0
84 stars 44 forks source link

Two instances of new-relic browser app targeting diferents accounts are colliding #818

Closed Khaos93 closed 8 months ago

Khaos93 commented 1 year ago

two instances of new-relic browser app targeting diferents accounts are colliding

Description

I am part of a team developing a widget that gets integrated into various websites. To monitor the widget's performance, we employ New Relic MicroAgents usint this library available at https://www.npmjs.com/package/@newrelic/browser-agent. However, a challenge arises as this widget is loaded onto pages that already have the New Relic Browser tracking code embedded (using the JS snippet provided by New Relic in the application settings). Consequently, when clients load the widget, it appears to collide with the existing MicroAgent instance, causing the New Relic tracking of their websites stop sending data to this new relic and start sending data to our account it. it seems that the microAgent is overriding the information of the other agent

Is there a solution to circumvent this issue and enable multiple New Relic agents to target different New Relic accounts simultaneously on the same website?

Steps to Reproduce

Expected Behavior

Relevant Logs / Console output

workato-integration[bot] commented 1 year ago

https://new-relic.atlassian.net/browse/NR-180763

patrickhousley commented 1 year ago

Thank you for reporting this issue @Khaos93 . Can you provide the versions of the agent that is being loaded on the page and the npm package?

Khaos93 commented 1 year ago

npm package is using: 1.238.0 JS snippet browser agent: nr-loader-spa-1221.min.js

patrickhousley commented 1 year ago

Thanks for the additional info @Khaos93 . We have made a few changes in the agent since 1221 that could help with this issue. Is there any way you could try upgrading the agent that is injected on the page to the latest version?

Khaos93 commented 1 year ago

we already updated the agent to 1.247 version that new-relic recommend us in the browser-application but the issue is still happening

patrickhousley commented 1 year ago

Thanks @Khaos93 . Just to confirm, you tried using 1.247 for both the page agent and the micro agent? If so, I will try to look into this as soon as possible.

Khaos93 commented 1 year ago

yes, the test was using the 1.247 version for both the page agent and the micro agent, thanks

patrickhousley commented 11 months ago

Hi @Khaos93 . I was able to setup a test case locally using https://github.com/mits-gossau/event-driven-web-components-realworld-example-app as a test base project. The page loads a full agent and the article page component loads a micro agent. In our testing, we do not see the page level agent changed to start reporting to the micro agent app ID. Is it possible for you to provide a small reproduction of this issue?

patrickhousley commented 11 months ago

Hi @Khaos93 I am going to close this issue due to inactivity. Feel free to reopen it with the requested additional information.

shaun0024 commented 10 months ago

Hi @Khaos93 . I was able to setup a test case locally using https://github.com/mits-gossau/event-driven-web-components-realworld-example-app as a test base project. The page loads a full agent and the article page component loads a micro agent. In our testing, we do not see the page level agent changed to start reporting to the micro agent app ID. Is it possible for you to provide a small reproduction of this issue?

@patrickhousley wondering if you might have the test code you used against this https://github.com/mits-gossau/event-driven-web-components-realworld-example-app repo that you can share?

patrickhousley commented 9 months ago

Hey @shaun0024 let me reopen this and recreate the code for you.

workato-integration[bot] commented 9 months ago

Work has been completed on this issue.

shaun0024 commented 9 months ago

Hey @shaun0024 let me reopen this and recreate the code for you.

Thank you @patrickhousley , much appreciated

patrickhousley commented 9 months ago

@shaun0024 Please find attached the example app. Just use python3 -m http.server in the root directory to start the server. The src/index.html file contains a a full agent using copy/paste and loading assets from our CDN while the component src/es/components/molecules/TagList.js has a micro agent.

When you load the page, you will get data for the full agent in the page and a PageView and JSError from the micro agent. If you switch tabs and come back, you should see some INS calls (insights). You will need to update both agents with valid license keys and settings from New Relic.

event-driven-web-components-realworld-newrelic-test.zip

shaun0024 commented 9 months ago

@shaun0024 Please find attached the example app. Just use python3 -m http.server in the root directory to start the server. The src/index.html file contains a a full agent using copy/paste and loading assets from our CDN while the component src/es/components/molecules/TagList.js has a micro agent.

When you load the page, you will get data for the full agent in the page and a PageView and JSError from the micro agent. If you switch tabs and come back, you should see some INS calls (insights). You will need to update both agents with valid license keys and settings from New Relic.

event-driven-web-components-realworld-newrelic-test.zip

Thank you very much @patrickhousley!

patrickhousley commented 8 months ago

@shaun0024 I am going to close this ticket due to the lack of engagement. If there is a bug or issue you would like us to look at, please feel free to open a new ticket.