Error message not being logged to console even though debugMode set to true

radiumcrm

Posted on
Sep 21 2015

I have the following set up code in my ember application:

Raygun.init('ZCfpkrJEWIcnlZGDb8aYPw==',
  allowInsecureSubmissions: true
  ignoreAjaxAbort: true
  ignoreAjaxError: false
  debugMode: true
  ignore3rdPartyErrors: false
  wrapAsynchronousCallbacks: true
  excludedUserAgents: ['PhantomJS']
  excludedHostnames: [
    'localhost'
    '.dev'
  ]).attach()

But the errors are not logged to the console, instead the following is logged:

Raygun4JS: cancelling send as error originates from an excluded hostname

What I want is to not send error messages for localhost errors and errors to be logged to the console which seems quite normal.

Am I doing something wrong or why can I not have these requirements?


Callum

Posted on
Sep 22 2015

The behaviour of the excludedHostnames and excludedUserAgents config options applies a coarse-grained filter for errors sent in the current environment, in that when an error is sent, the current hostname/user-agent is checked and if any matches, the send is cancelled outright. Additional behaviour such as logging to the console needs to be implemented separately with onBeforeSend, as requirements here are unbounded and could contain any possible custom logic e.g displaying an error UI component or logging additional app state data.

To cancel the send and log the error to the console instead when the hostname matches, use an implementation like this:

Raygun.onBeforeSend(function (payload) {  
  if (window.location.hostname.indexOf('localhost') === 0) { // or location.host if you wish to check the port too
    console.log(payload);
    return false;
  }

  return payload;
});

Reply