1

I am successfully using airbrake in my ruby on rails app with one exception.

On visiting a specific view, I am occasionally getting a 401 unauthorized error:

POST https://api.airbrake.io/api/v3/projects/0/notices?key= 401 (Unauthorized) api.airbrake.io/api/v3/projects/0/notices?key=:1

The key appears to be missing however it is only missing sometimes..

I am setting my airbrake credentials in my app.js file as follows:

// Airbrake project creds
// projectId, projectKey
Airbrake.setProject(projID, projKey);

window.onerror = function(message, file, line) {
  Airbrake.push({error: {message: message, fileName: file, lineNumber: line}});
}

Why might this fail sometimes but work other times on one specific view?

captainrad
  • 3,760
  • 16
  • 41
  • 74

1 Answers1

1

You see that error because Airbrake.setProject is not called in time or projID, projKey are undefined. But I can't say why without seeing full app.js contents and knowing how you load that file.

BTW you can find more robust onerror handler here.

Also I recommend you to open GitHub issue when you have airbrake-js specific questions.

Vladimir Mihailenco
  • 3,382
  • 2
  • 24
  • 38