1
0
mirror of synced 2025-12-22 11:26:57 -05:00
Files
docs/lib/failbot.js
Peter Bengtsson ed53e2dd77 use @github/failbot with got (#22842)
* use @github/failbot

Part of #1222

* tests are not working yet

* fix unit tests

* cleanup
2021-11-16 16:48:40 +00:00

35 lines
773 B
JavaScript

import got from 'got'
import { Failbot, HTTPBackend, LogBackend } from '@github/failbot'
const HAYSTACK_APP = 'docs'
export function report(error, metadata) {
// If there's no HAYSTACK_URL set, bail early
if (!process.env.HAYSTACK_URL) return
const backends = [
new HTTPBackend({
haystackURL: process.env.HAYSTACK_URL,
fetchFn: got,
}),
]
if (process.env.NODE_ENV !== 'test') {
backends.push(new LogBackend({ log: console.log.bind(console) }))
}
const failbot = new Failbot({
app: HAYSTACK_APP,
backends: backends,
})
return failbot.report(error, metadata)
}
// Kept for legacy so you can continue to do:
//
// import FailBot from './lib/failbot.js'
// ...
// FailBot.report(myError)
//
export default {
report,
}