feat: add error metric writing method. call it during honeybadger errors
parent
2d9f86a508
commit
560491d410
|
@ -3,6 +3,7 @@ import HoneyBadger from 'honeybadger-js'
|
|||
import {CLOUD, GIT_SHA} from 'src/shared/constants'
|
||||
|
||||
import {getUserFlags} from 'src/shared/utils/featureFlag'
|
||||
import {reportPoints, PointTags, PointFields} from 'src/cloud/apis/reporting'
|
||||
|
||||
if (CLOUD) {
|
||||
HoneyBadger.configure({
|
||||
|
@ -12,6 +13,19 @@ if (CLOUD) {
|
|||
})
|
||||
}
|
||||
|
||||
export const reportSingleErrorMetric = (
|
||||
tags: PointTags = {},
|
||||
fields: PointFields = {},
|
||||
measurement = 'ui_error'
|
||||
) => {
|
||||
if (CLOUD) {
|
||||
const points = {
|
||||
points: [{measurement, tags, fields: {errorCount: 1, ...fields}}],
|
||||
}
|
||||
reportPoints(points)
|
||||
}
|
||||
}
|
||||
|
||||
// See https://docs.honeybadger.io/lib/javascript/guides/reporting-errors.html#additional-options
|
||||
interface HoneyBadgerAdditionalOptions {
|
||||
component?: string
|
||||
|
@ -44,6 +58,15 @@ export const reportError = (
|
|||
|
||||
if (CLOUD) {
|
||||
HoneyBadger.notify(error, {context, ...options})
|
||||
|
||||
let errorType = 'generic (untagged) error'
|
||||
if (options.name) {
|
||||
errorType = options.name
|
||||
} else if (options.component) {
|
||||
errorType = options.component
|
||||
}
|
||||
|
||||
reportSingleErrorMetric({errorType})
|
||||
} else {
|
||||
const honeyBadgerContext = (HoneyBadger as any).context
|
||||
/* eslint-disable no-console */
|
||||
|
|
Loading…
Reference in New Issue