Skip to content
Browse files

#1044 support and document the airbrake-js xhr reporter

  • Loading branch information...
1 parent a0929bc commit 666ce5515732554769af38a50f32f02cb94b2891 @stevecrozz stevecrozz committed
View
15 README.md
@@ -243,17 +243,20 @@ This tab will be hidden if no user information is available.
Javascript error notifications
--------------------------------------
-
You can log javascript errors that occur in your application by including the
[airbrake-js](https://github.com/airbrake/airbrake-js) javascript library.
-Install airbrake-js according to the docs at
-[airbrake-js](https://github.com/airbrake/airbrake-js) and set your project and
-host as early as possible:
+Install airbrake-js according to the docs at and set your project and host as
+soon as you want to start reporting errors. Then follow along with the
+documentation at https://github.com/airbrake/airbrake-js/blob/master/README.md
```javascript
-Airbrake.setProject("ERRBIT API KEY", "ERRBIT API KEY");
-Airbrake.setHost("http://errbit.yourdomain.com");
+var airbrake = new airbrakeJs.Client({
+ projectId: 'ERRBIT API KEY',
+ projectKey: 'ERRBIT API KEY (again)',
+ reporter: 'xhr',
+ host: 'https://myerrbit.com'
+});
```
Plugins and Integrations
View
1 app/controllers/api/v3/notices_controller.rb
@@ -10,6 +10,7 @@ class Api::V3::NoticesController < ApplicationController
def create
response.headers['Access-Control-Allow-Origin'] = '*'
response.headers['Access-Control-Allow-Headers'] = 'origin, content-type, accept'
+ return render(status: 200, text: '') if request.method == 'OPTIONS'
report = AirbrakeApi::V3::NoticeParser.new(
params.merge(JSON.parse(request.raw_post) || {})).report
View
2 config/routes.rb
@@ -64,7 +64,7 @@
end
match '/api/v3/projects/:project_id/create-notice' => 'api/v3/notices#create', via: [:post]
- match '/api/v3/projects/:project_id/notices' => 'api/v3/notices#create', via: [:post]
+ match '/api/v3/projects/:project_id/notices' => 'api/v3/notices#create', via: [:post, :options]
root to: 'apps#index'
end
View
6 spec/controllers/api/v3/notices_controller_spec.rb
@@ -12,6 +12,12 @@
expect(response.headers['Access-Control-Allow-Headers']).to eq('origin, content-type, accept')
end
+ it 'responds to an OPTIONS request' do
+ process :create, 'OPTIONS', project_id: 'nothingspecial'
+ expect(response.headers['Access-Control-Allow-Origin']).to eq('*')
+ expect(response.headers['Access-Control-Allow-Headers']).to eq('origin, content-type, accept')
+ end
+
it 'returns created notice id in json format' do
post :create, legit_body, legit_params
notice = Notice.last

0 comments on commit 666ce55

Please sign in to comment.
Something went wrong with that request. Please try again.