Feature Idea: Can I query javascript errors on new relic insights?

Has that been resolved?

@mauro_luna We have not announced this feature being added as of yet. I see you started the feature request so you will be notified if is it added! I am also letting the product managers know of your continued interest.

+1 - please add my name to the request


I’ve added you to this Feature request!

Please add my name to this request

Happy to, @martha_negron! Adding a feature request for you now! :thumbsup:

+1 - please add my name to the request.


You got it, @leandro.romero! Adding your input to a feature request right now! :thumbsup:

Is this in the works yet?

+1 and please add my name to this request too.

Hi @dmhart unfortunately I don’t have any hard information on whether the feature is in the works myself, it’s also worth bearing in mind that while we take feature request seriously and our product managers review every one when plotting our roadmap, it’s not a guarantee the feature would be implemented. It ensures the idea is put on the table and discussed though.

I have however filed a feature request on your behalf, which in the event the feature was chosen for development attention, will mean that you would be notified by email if it’s rolled out to product, as I’ve tagged your customer details to this feature request.

Hello! please vote if you want to obtain js errors in insights!

I gave this a +1. I would also like to add that it would be super helpful if we could get the JS error ID as part of the Insights data returned in order to drill into the error details on the Browser JS Errors dashboard (unless you can provide the same graphs on the Insights dashboard).

Thanks so much for providing more detail @eric3. Those details are really important to our engineering teams.

For those that would like a workaround solution until the feature is applied, you can use this as an example to create a custom event within Insights which you can then query on for dashboards or alerts.

You will need your Insights API key and the account id where the event will be stored.

I am using JQuery here to make the API call but you could replace the $ajax with your own implementation using XMLHttpRequest if you want to reduce 3rd party dependencies.

I have not tested this sample so you should verify prior to implementing in a live environment!

New Relic may change their object naming conventions so reference to newrelic.info.applicationID may not work in future implementations of the Browser injected script!

newrelic.setErrorHandler(function (err) {

        var stack = e.error.stack; 
        var message = e.error.toString(); 
        var pageURL = window.location.href;

            method: 'POST', 
            url: 'https://insights-collector.newrelic.com/v1/accounts/[Your Account Id]/events', 
            headers: { 'X-Insert-Key': '[Your Insights API Key]' }, 
            data: { 
                "appId": newrelic.info.applicationID, 

     return false;

If anyone has implemented this workaround, please do feedback on if it worked or any changes that are required.

1 Like

I’m also interested in this feature.

Similar to stefan_garnham’s work around, I came up with the following solution which lets you then run a query similar to the following SELECT * FROM PageAction where actionName = 'JSError'

newrelic.setErrorHandler(function(error) {
    newrelic.addPageAction('JSError', {
        message: error.message,
        errorName: error.name,
        errorStackTrace: error.stack,
        url: window.location.toString(),
        otherField: someOtherValueYouMayWantHere
1 Like

I ended up using PageActions to log these errors separately and create an insights dashboard. Note that stefan_garnham’s method didn’t work (I ran into CORS issues), but addPageAction does it!

const data = {
  'api.endpointAnonymized' : getEndpointAnonymized(error),
  'api.httpStatus'         : getFromApi(error, 'httpStatus'),
  'api.method'             : getFromApi(error, 'method'),
  'api.url'                : getFromApi(error, 'url'),
  message                  : error.message,
  'page.url'               : error.page.url,
  'redux.actionType'       : getActionType(error, elementToTrackTo),
  type                     : error.type,
  'user.id'                : error.user.id,
  'user.role'              : error.user.role,

  new relic insights can only facet by one field, so we have to create some to get meaningful data
  these are named "facets" just to denote that they're explicitly used for this one aspect of filtering
data['facets.api.basicData']      = getApiBasicData(error, data);
data['facets.user.idAndRole']     = `${data['user.id']}-${data['user.role']}`;
data['facets.page.urlAnonymized'] = anonymizeUrl(error.page.url);

// https://docs.newrelic.com/docs/browser/new-relic-browser/browser-agent-spa-api/add-page-action
window.newrelic.addPageAction('Client Error', data);


Love it @averyvery - this is an excellent workaround. Really appreciate you sharing.

We’re also interested in having JS errors available in Insights