Exclude JS Errors from browser

Browser Question Template

I am trying to find a way to exclude some known JS errors from being scraped and shows in the JS Error section in the Browser section.
setErrorHandler (browser agent API) | New Relic Documentation

Found the above documentation that suggests to add some Ajax code. I am running on Pro + SPA plan and believe the data is scraped via Newrelic APM Agent isntalled. I need to know how I can acoomodate the above option via this agent.

Hello @Surya_Makam.

Welcome to the community, it is great to see you!

While this is out of my scope as I am not a support engineer, I am going to loop one of our support engineers in from the Browser team to help out. Please note they will respond here shortly, when available.

Please reach out if you find you have other questions we can assist with!

Hi @Surya_Makam - this is Jonathan with the Synthetics support team let’s see if we can help demystify the setErrorHandler method!

You’ll want to be sure you have your Browser agent installed correctly and functioning, it sounds like you already have your Browser agent functioning.

  • The setErrorHandler method gets called every time the Browser agent encounters a JavaScript error.
  • You will need to create an AJAX function in your application to pass errors through the setErrorHandler method which returns a boolean:
    • True means the New Relic agent excludes the error
    • False means the New Relic agent reports your error

:arrow_right: This is a good example of using the setErrorHandler and the addPageAction to create a custom error message, or to selectively exclude known errors.

Do let us know if that helps get you on the right track!

1 Like