-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbackground.js
More file actions
32 lines (30 loc) · 869 Bytes
/
Copy pathbackground.js
File metadata and controls
32 lines (30 loc) · 869 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
/*
* On install/update of plugin configure Raygun
*/
chrome.runtime.onInstalled.addListener(function () {
Raygun.init('[Add your API key]', { apiUrl: 'https://api.raygun.com' }).attach();
Raygun.setUser('demo@example.net', false, 'demo@example.net', 'Ronald', 'Ronald Raygun', 'BAE62917-ACE8-ab3D-9287-B6A33B8E8C55');
});
/*
* Example of receiving a message that throws an unhandled error.
* A try catch block here is required as there is no global error handler.
*/
chrome.runtime.onMessage.addListener(function (message) {
executeWithRaygunHandling(function() {
if (message === 'error1') {
// Expected ReferenceError: brain is not defined
brain.trigger('eyes.open');
}
});
});
/*
* Utility method to reduce try catch code.
*/
function executeWithRaygunHandling(fn) {
try {
fn();
} catch (e) {
Raygun.send(e);
}
}