How to use the @bugsnag/core/lib/es-utils.filter 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-inline-script-content / inline-script-content.js View on Github external
client.config.beforeSend.unshift(report => {
      // remove any of our own frames that may be part the stack this
      // happens before the inline script check as it happens for all errors
      report.stacktrace = filter(report.stacktrace, f => !(/__trace__$/.test(f.method)))

      const frame = report.stacktrace[0]

      // if frame.file exists and is not the original location of the page, this can't be an inline script
      if (frame && frame.file && frame.file.replace(/#.*$/, '') !== originalLocation.replace(/#.*$/, '')) return

      // grab the last script known to have run
      const currentScript = getCurrentScript()
      if (currentScript) {
        const content = currentScript.innerHTML
        report.updateMetaData(
          'script',
          'content',
          content.length <= MAX_SCRIPT_LENGTH ? content : content.substr(0, MAX_SCRIPT_LENGTH)
        )
      }
github bugsnag / bugsnag-js / packages / plugin-console-breadcrumbs / console-breadcrumbs.js View on Github external
exports.configSchema = {
  consoleBreadcrumbsEnabled: {
    defaultValue: () => undefined,
    validate: (value) => value === true || value === false || value === undefined,
    message: 'should be true|false'
  }
}

if (process.env.NODE_ENV !== 'production') {
  exports.destroy = () => CONSOLE_LOG_METHODS.forEach(method => {
    if (typeof console[method]._restore === 'function') console[method]._restore()
  })
}

const CONSOLE_LOG_METHODS = filter([ 'log', 'debug', 'info', 'warn', 'error' ], method =>
  typeof console !== 'undefined' && typeof console[method] === 'function'
)