How to use honeybadger-js - 7 common examples

To help you get started, we’ve selected a few honeybadger-js examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github influxdata / influxdb / ui / src / shared / utils / errors.ts View on Github external
}

  const context = {
    ...additionalContext,
    ...getUserFlags(),
  }

  let options: HoneyBadgerAdditionalOptions = {}
  if (additionalOptions) {
    options = {...additionalOptions}

    delete options.context // already included in the above context object
  }

  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
    }

    event('ui error', {error: errorType}, {errorCount: 1})
  } else {
    console.error(error)
  }
}
github ello / webapp / src / main.js View on Github external
// only use fastclick if we are on iOS
if (isIOS()) {
  require('react-fastclick')
}
/* eslint-enable global-require */

function shouldScroll(prevRouterProps, currentRouterProps) {
  const { location } = currentRouterProps
  if (location.action === 'PUSH' && location.query.submissionType) {
    return false
  }
  return location.action !== 'REPLACE'
}

if (ENV.HONEYBADGER_API_KEY && ENV.HONEYBADGER_ENVIRONMENT) {
  Honeybadger.configure({
    api_key: ENV.HONEYBADGER_API_KEY,
    environment: ENV.HONEYBADGER_ENVIRONMENT,
  })
}

updateTimeAgoStrings({ about: '' })

const APP_VERSION = '4.0.0'

const createSelectLocationState = () => {
  let prevRoutingState
  let prevRoutingStateJS
  return (state) => {
    const routingState = state.routing
    if (typeof prevRoutingState === 'undefined' || prevRoutingState !== routingState) {
      prevRoutingState = routingState
github influxdata / influxdb / ui / src / shared / utils / errors.ts View on Github external
import {ErrorInfo} from 'react'
import HoneyBadger from 'honeybadger-js'
import {CLOUD, GIT_SHA} from 'src/shared/constants'

import {getUserFlags} from 'src/shared/utils/featureFlag'
import {event} from 'src/cloud/utils/reporting'

if (CLOUD) {
  HoneyBadger.configure({
    apiKey: process.env.HONEYBADGER_KEY,
    revision: GIT_SHA,
    environment: process.env.HONEYBADGER_ENV,
  })
}

// See https://docs.honeybadger.io/lib/javascript/guides/reporting-errors.html#additional-options
interface HoneyBadgerAdditionalOptions {
  component?: string
  context?: {[key: string]: any}
  cookies?: {[key: string]: any}
  name?: string
  params?: {[key: string]: any}
}

export const reportError = (
github honeybadger-io / honeybadger-vue / src / index.js View on Github external
install (Vue, options) {
    if (Vue.config.debug) {
      console.log(`Honeybadger configured with ${options.apiKey}`)
    }
    const honeybadger = Honeybadger.configure(options)
    Vue.$honeybadger = honeybadger
    Vue.prototype.$honeybadger = Vue.$honeybadger
    const chainedErrorHandler = Vue.config.errorHandler
    let extractContext = function (vm) {
      var options = typeof vm === 'function' && vm.cid != null ? vm.options : vm._isVue ? vm.$options ||
        vm.constructor.options : vm || {}
      var name = options.name || options._componentTag
      var file = options.__file
      return {
        isRoot: vm.$root === vm,
        name: name,
        props: options.propsData,
        parentVnodeTag: options._parentVnode ? options._parentVnode.tag : undefined,
        file: file
      }
    }
github influxdata / influxdb / ui / src / shared / actions / me.ts View on Github external
export const getMe = () => async dispatch => {
  try {
    dispatch(setMe(RemoteDataState.Loading))
    const user = await client.users.me()
    updateReportingContext({userID: user.id, userEmail: user.name})

    gaEvent('cloudAppUserDataReady', {
      identity: {
        id: user.id,
        email: user.name,
      },
    })

    HoneyBadger.setContext({
      user_id: user.id,
    })

    dispatch(setMe(RemoteDataState.Done, user as MeState))
  } catch (error) {
    console.error(error)
    dispatch(setMe(RemoteDataState.Error))
  }
}
github influxdata / influxdb / ui / src / shared / actions / me.ts View on Github external
export const getMe = () => async dispatch => {
  try {
    const user = await client.users.me()
    updateReportingContext({userID: user.id, userEmail: user.name})

    gaEvent('cloudAppUserDataReady', {
      identity: {
        id: user.id,
        email: user.name,
      },
    })

    updateReportingContext({
      userID: user.id,
    })
    HoneyBadger.setContext({
      user_id: user.id,
    })

    dispatch(setMe(user as MeState))
  } catch (error) {
    console.error(error)
  }
}
github influxdata / influxdb / ui / src / organizations / actions / creators.ts View on Github external
export const setOrg = (org: Organization) => {
  HoneyBadger.setContext({
    orgID: org.id,
  })
  return {
    type: SET_ORG,
    org,
  } as const
}

honeybadger-js

A JavaScript library for integrating apps with the Honeybadger Rails Error Notifier.

MIT
Latest version published 4 years ago

Package Health Score

53 / 100
Full package analysis

Similar packages