How to use the @bugsnag/core/lib/es-utils.map function in @bugsnag/core

To help you get started, we’ve selected a few @bugsnag/core 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 bugsnag / bugsnag-js / packages / plugin-console-breadcrumbs / console-breadcrumbs.js View on Github external
exports.init = (client) => {
  const isDev = /^dev(elopment)?$/.test(client.config.releaseStage)

  const explicitlyDisabled = client.config.consoleBreadcrumbsEnabled === false
  const implicitlyDisabled = (client.config.autoBreadcrumbs === false || isDev) && client.config.consoleBreadcrumbsEnabled !== true
  if (explicitlyDisabled || implicitlyDisabled) return

  map(CONSOLE_LOG_METHODS, method => {
    const original = console[method]
    console[method] = (...args) => {
      client.leaveBreadcrumb('Console output', reduce(args, (accum, arg, i) => {
        // do the best/simplest stringification of each argument
        let stringified = '[Unknown value]'
        // this may fail if the input is:
        // - an object whose [[Prototype]] is null (no toString)
        // - an object with a broken toString or @@toPrimitive implementation
        try { stringified = String(arg) } catch (e) {}
        // if it stringifies to [object Object] attempt to JSON stringify
        if (stringified === '[object Object]') {
          // catch stringify errors and fallback to [object Object]
          try { stringified = JSON.stringify(arg) } catch (e) {}
        }
        accum[`[${i}]`] = stringified
        return accum
github bugsnag / bugsnag-js / packages / plugin-node-in-project / in-project.js View on Github external
init: client => client.config.beforeSend.push(report => {
    if (!client.config.projectRoot) return
    const projectRoot = normalizePath(client.config.projectRoot)
    report.stacktrace = map(report.stacktrace, stackframe => {
      stackframe.inProject = typeof stackframe.file === 'string' &&
        stackframe.file.indexOf(projectRoot) === 0 &&
        !/\/node_modules\//.test(stackframe.file)
      return stackframe
    })
  })
}
github bugsnag / bugsnag-js / packages / plugin-strip-project-root / strip-project-root.js View on Github external
init: client => client.config.beforeSend.push(report => {
    if (!client.config.projectRoot) return
    const projectRoot = normalizePath(client.config.projectRoot)
    report.stacktrace = map(report.stacktrace, stackframe => {
      if (typeof stackframe.file === 'string' && stackframe.file.indexOf(projectRoot) === 0) {
        stackframe.file = stackframe.file.replace(projectRoot, '')
      }
      return stackframe
    })
  })
}
github bugsnag / bugsnag-js / packages / plugin-strip-query-string / strip-query-string.js View on Github external
client.config.beforeSend.push(report => {
      report.stacktrace = map(report.stacktrace, frame => ({ ...frame, file: strip(frame.file) }))
    })
  }