Manually initialize browser agent after assigning NREUM loader and info

In some situations, the browser agent doesn’t seem to be setup fully in time for the nrvideo core library when it starts sending events.

I would notice the nrvideo core library send heartbeats but no subsequent REST requests were made.

I assumed that the browser agent isn’t setup since I set the NREUM loader and info later in the lifecycle because I pull the account info from a separate HTTP request depending on the skin the website is loaded with.

Setup:

  1. Browser agent injected (I guess here it automatically loads the agent with empty NREUM as I removed it from the javascript snippet)
  2. Make request to get account info for NREUM loader and config depending on the query parameter the webpage’s skin is loaded with.
  3. Set the NREUM loader and config to the object with the account info fetched.
  4. NrVideo core library is loaded
  5. NrVideo core library starts sending events. ← Issue here where events are not sending REST requests to bam.nr-data.net but NrVideo core logs show it is emitting the events.

Hi @john.lam, thanks for posting your question on the Explorer’s Hub, regarding the Browser agent and video-core-js.

That sounds correct. The Browser agent should be used as-is. The Browser agent should be the first <script> tag in the head, as specified in JavaScript placement requirements, to get all the instrumentation set up, before the rest of the page is loaded.

If you have any trouble after that, please share.

1 Like

For my situation, isn’t there a way we can modify the Browser agent’s script to make it work for my requirement?

Having a way to manually load the Browser agent after setting the NREUM account info would be ideal!