Skip to content

Bajena/honeybadger-gas

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Honeybadger for Google Apps Scripts

CircleCI

A Honeybadger client for Google Apps Scripts.

Setup

Add the library to your script

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.

Add script.external_request scope (optional)

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

Add Honeybadger to urlFetchWhitelist key in appscript.json file (optional)

If you're whitelisting URLs accessible by UrlFetchApp make sure you add "https://api.honeybadger.io/" to urlFetchWhitelist key.

Usage

Initialize client

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'.

Send error notifications to Honeybadger

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
});

Add execution context

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()
});

Tech Stack

Prerequisites

Development

Clone the repository

git clone https://github.com/Bajena/honeybadger-gas.git <project_name>

Install dependencies

cd <project_name>
npm install
yarn

Configuration

Open .clasp.json, change scriptId

What is scriptId ? https://github.com/google/clasp#scriptid-required

{
  "scriptId": <your_script_id>,
  "rootDir": "dist"
}

Development and build project

npm run build

Push

clasp push

License

This software is released under the MIT License, see LICENSE.txt.

About

Honeybadger client for Google Apps Scripts

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published