Commit 951835e69020e28fedf356c71d3816d6e4e40234
1 parent
4eed9f65
Exists in
master
and in
1 other branch
Update readme with javascript error reporting
I've added description how to setup airbrake-js to log javascript errors in errbit and how one can test v3 api using airbrake ruby client.
Showing
1 changed file
with
46 additions
and
3 deletions
Show diff stats
README.md
@@ -305,13 +305,56 @@ it will be displayed under the *User Details* tab: | @@ -305,13 +305,56 @@ it will be displayed under the *User Details* tab: | ||
305 | Javascript error notifications | 305 | Javascript error notifications |
306 | -------------------------------------- | 306 | -------------------------------------- |
307 | 307 | ||
308 | -You can log javascript errors that occur in your application by including the | ||
309 | -following script tag before any javascript is loaded in your application. | 308 | +You can log javascript errors that occur in your application by including |
309 | +[airbrake-js](https://github.com/airbrake/airbrake-js) javascript library. | ||
310 | 310 | ||
311 | +First you need to add airbrake-shim.js to your site and set some basic configuration | ||
312 | +options: | ||
313 | + | ||
314 | +``` | ||
315 | +<script src="airbrake-shim.js" data-airbrake-project-id="ERRBIT API KEY" data-airbrake-project-key="ERRBIT API KEY" data-airbrake-environment-name="production" data-airbrake-host="http://errbit.yourdomain.com"></script> | ||
311 | ``` | 316 | ``` |
312 | -<script src="//YOUR-ERRBIT-HOST/javascripts/notifier.js" type="text/javascript"></script> | 317 | + |
318 | +Or you can just add shim file and set these options using: | ||
319 | + | ||
313 | ``` | 320 | ``` |
321 | +Airbrake.setProject("ERRBIT API KEY", "ERRBIT API KEY"); | ||
322 | +Airbrake.setHost("http://errbit.yourdomain.com"); | ||
323 | +``` | ||
324 | + | ||
325 | +And that's it. | ||
326 | + | ||
327 | +Testing API V3 using ruby airbrake client | ||
328 | +----------------------------------------- | ||
329 | + | ||
330 | +If you want you test standard airbrake ruby gem with API V3. To do that you | ||
331 | +need to change your airbrake initializer file to something like this: | ||
332 | + | ||
333 | +``` | ||
334 | +Airbrake.configure do |config| | ||
335 | + config.api_key = ENV['airbrake_api_key'] | ||
336 | + config.host = ENV['airbrake_host'] | ||
337 | + config.port = ENV['airbrake_port'].to_i | ||
338 | + config.secure = ENV['airbrake_secure'] == 'true' | ||
339 | + config.project_id = ENV['airbrake_api_key'] | ||
340 | +end | ||
341 | + | ||
342 | +class Airbrake::Sender | ||
343 | + def json_api_enabled? | ||
344 | + true | ||
345 | + end | ||
346 | +end | ||
347 | +``` | ||
348 | + | ||
349 | +It is important to set project_id option to the same value as api_key, because | ||
350 | +project_id is required for building url to api endpoint. And airbrake has a bug | ||
351 | +that removes api_key from endpoint url. The only way to get this value is by passing | ||
352 | +it as project_id. This little monkey-patch is required because airbrake gem only | ||
353 | +uses v3 api when host is set to collect.airbrake.io. | ||
314 | 354 | ||
355 | +V3 request don't have framework option so you won't see this value in your error | ||
356 | +notices in errbit. Besides that everything looks the same. It was tested using | ||
357 | +rake airbrake:test for both v2 and v3. | ||
315 | 358 | ||
316 | Using custom fingerprinting methods | 359 | Using custom fingerprinting methods |
317 | ----------------------------------- | 360 | ----------------------------------- |