Skip to content
This repository was archived by the owner on Jan 8, 2019. It is now read-only.

Commit b19bf99

Browse files
committed
Tweak example app
1 parent 409982c commit b19bf99

File tree

1 file changed

+35
-34
lines changed

1 file changed

+35
-34
lines changed

example/app.js

Lines changed: 35 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
/* global bugsnag, Vue, bugsnag__vue */
2+
13
// www.bugsnag.com
24
// https://github.com/bugsnag/bugsnag-vue/tree/master/example
35
//
@@ -9,51 +11,51 @@
911
// Initialize Bugsnag to begin tracking errors. Only an api key is required, but here are some other helpful configuration details:
1012
const bugsnagClient = bugsnag({
1113

12-
// get your own api key at bugsnag.com
13-
apiKey: 'API_KEY',
14+
// get your own api key at bugsnag.com
15+
apiKey: 'API_KEY',
1416

15-
// if you track deploys or use source maps, make sure to set the correct version.
16-
appVersion: '1.2.3',
17+
// if you track deploys or use source maps, make sure to set the correct version.
18+
appVersion: '1.2.3',
1719

18-
// Bugsnag can track the number of “sessions” that happen in your application, and calculate a crash rate for each release. This defaults to false.
19-
autoCaptureSessions: true,
20+
// Bugsnag can track the number of “sessions” that happen in your application, and calculate a crash rate for each release. This defaults to false.
21+
autoCaptureSessions: true,
2022

21-
// defines the release stage for all events that occur in this app.
22-
releaseStage: 'development',
23+
// defines the release stage for all events that occur in this app.
24+
releaseStage: 'development',
2325

24-
// defines which release stages bugsnag should report. e.g. ignore staging errors.
25-
notifyReleaseStages: [ 'development', 'production'],
26+
// defines which release stages bugsnag should report. e.g. ignore staging errors.
27+
notifyReleaseStages: [ 'development', 'production' ],
2628

27-
// one of the most powerful tools in our library, beforeSend lets you evaluate, modify, add and remove data before sending the error to bugsnag. The actions here will be applied to *all* errors, handled and unhandled.
28-
beforeSend: function (report) {
29-
if (report.errorClass === 'Error' && report.severity === 'warning') {
30-
report.updateMetaData('example', {thing: "one"})
31-
}
29+
// one of the most powerful tools in our library, beforeSend lets you evaluate, modify, add and remove data before sending the error to bugsnag. The actions here will be applied to *all* errors, handled and unhandled.
30+
beforeSend: function (report) {
31+
if (report.errorClass === 'Error' && report.severity === 'warning') {
32+
report.updateMetaData('example', { thing: 'one' })
33+
}
3234
// note that if you return false from the beforeSend, this will cancel the entire error report.
33-
},
35+
},
3436

35-
// attached any user data you'd like to report.
36-
user: {
37-
name: "Katherine Johnson",
38-
email: "kj@nasa.gov",
39-
id: "0112358"
40-
},
37+
// attached any user data you'd like to report.
38+
user: {
39+
name: 'Katherine Johnson',
40+
email: 'kj@nasa.gov',
41+
id: '0112358'
42+
},
4143

42-
// add any custom attributes relevant to your app. Note that metadata can be added here, in a specific notify() or in a beforeSend.
43-
metaData: { company: {
44-
name: "Hogwarts School of Witchcraft and Wizardry"
45-
}
46-
},
47-
// N.B. our notifer automatically creates a metadata tab called "React" and populates it with component info.
44+
// add any custom attributes relevant to your app. Note that metadata can be added here, in a specific notify() or in a beforeSend.
45+
metaData: {
46+
company: {
47+
name: 'Hogwarts School of Witchcraft and Wizardry'
48+
}
49+
},
50+
// N.B. our notifer automatically creates a metadata tab called "Vue" and populates it with component info.
4851

49-
// because this is a demo app, below extends the default of 10 notifications per pageload. click away!
50-
maxEvents: 50
52+
// because this is a demo app, below extends the default of 10 notifications per pageload. click away!
53+
maxEvents: 50
5154
})
5255

5356
// attach the Vue plugin to your bugsnag-js client
5457
bugsnagClient.use(bugsnag__vue(Vue))
5558

56-
5759
// Define the <bad-button/> component
5860
Vue.component('bad-button', {
5961
template: '#bad-button-template',
@@ -85,14 +87,14 @@ var app = new Vue({
8587
if (val) {
8688
try {
8789
// potentially buggy code goes here
88-
//for this example, we're just throwing an error explicitly, but you do not need this syntax in your try clause.
90+
// for this example, we're just throwing an error explicitly, but you do not need this syntax in your try clause.
8991
throw new Error('Bad thing!')
9092
} catch (e) {
9193
console.log('a handled error has been reported to your Bugsnag dashboard')
9294
// below modifies the handled error, and then sends it to your dashboard.
9395
bugsnagClient.notify(e, {
9496
context: 'Don\'t worry - I handled it.'
95-
});
97+
})
9698
}
9799
}
98100
}
@@ -126,7 +128,6 @@ var app = new Vue({
126128
}
127129
})
128130

129-
130131
// below is the simplest notification syntax, akin to logging.
131132
console.log('a notification has been reported to your Bugsnag dashboard')
132133
bugsnagClient.notify('End of file')

0 commit comments

Comments
 (0)