var Hoptoad = require("hoptoad-notifier").Hoptoad; module.exports = function hoptoadNotifier (key, notify) { var notify = notify || ["staging", "production"]; var env = process.connectEnv.name; Hoptoad.key = key; Hoptoad.environment = env return function (err, req, res, next) { if (notify.indexOf(env) >= 0) { err.url = req.url; err.action = req.method; Hoptoad.notify(err); } next(err); } };