A Honeybadger client for Google Apps Scripts.
This library is already published as an Apps Script, making it easy to include in your project. To add it to your script, do the following in the Apps Script code editor:
Click on the menu item "Resources > Libraries..."
In the "Find a Library" text box, enter the script ID M4hoogS1IHPlDGE3VXDWwuTI3yRUM8Pyy
and click the "Select" button.
Choose a version in the dropdown box (usually best to pick the latest version).
Click the "Save" button.
If you are setting explicit scopes in your manifest file, ensure that the following scope is included:
https://www.googleapis.com/auth/script.external_request
If you're whitelisting URLs accessible by UrlFetchApp make sure you add "https://api.honeybadger.io/"
to urlFetchWhitelist
key.
Honeybadger.configure({
apiKey: '[ YOUR API KEY HERE ]',
environment: 'production'
});
apiKey
- Your Honeybadger API key.environment
- environment name to be sent to Honeybadger. If not passed it'll be sent as 'production'.
Unfortunately Google App Scripts don't provide a way to catch all unhandled exception, so you will need to wrap your function's code in try-catch like this:
function yourFunction() {
try {
// Your code
} catch(e) {
Honeybadger.notify(e);
}
}
You can also pass additional options to notify
function:
Honeybadger.notify(error, {
fingerprint: 'custom_fingerprint' // Override default fingerprint
});
You can pass additional context that will be sent alongside your notifications. E.g.:
Honeybadger.context({
user_id: Session.getTemporaryActiveUserKey(),
user_locale: Session.getActiveUserLocale(),
user_email: Session.getActiveUser().getEmail()
});
git clone https://github.com/Bajena/honeybadger-gas.git <project_name>
cd <project_name>
npm install
yarn
What is scriptId ? https://github.com/google/clasp#scriptid-required
{
"scriptId": <your_script_id>,
"rootDir": "dist"
}
npm run build
clasp push
This software is released under the MIT License, see LICENSE.txt.