<commit_before>const { schema } = require('./common')
const stringWithLength = require('@bugsnag/core/lib/validators/string-with-length')

const ALLOWED_IN_RENDERER = [
  // a list of config keys that are allowed to be supplied to the renderer client
  // this must be kept in sync with the typescript "AllowedRendererConfig" type
  'onError', 'onBreadcrumb', 'logger', 'metadata', 'user', 'context', 'codeBundleId', 'plugins', 'appType'
]

module.exports.schema = {
  ...schema,
  projectRoot: {
    defaultValue: () => null,
    validate: value => value === null || stringWithLength(value),
    message: 'should be string'
  },
  releaseStage: {
    ...schema.releaseStage,
    defaultValue: () => null
  },
  logger: Object.assign({}, schema.logger, {
    defaultValue: () => getPrefixedConsole()
  }),
  codeBundleId: {
    defaultValue: () => undefined,
    message: 'should be a string',
    validate: val => (val === undefined || stringWithLength(val))
  }
}

module.exports.mergeOptions = (mainOpts, rendererOpts) => {
  return Object.keys(module.exports.schema).reduce((accum, k) => {
    if (rendererOpts[k]) {
      if (ALLOWED_IN_RENDERER.includes(k)) {
        if (k === 'metadata') {
          // ensure that metadata set in renderer config doesn't blow away all preexisting metadata
          return { ...accum, [k]: mergeMetadata(mainOpts[k], rendererOpts[k]) }<commit_msg>Allow merging renderer options that are falsy<commit_after>const { schema } = require('./common')
const stringWithLength = require('@bugsnag/core/lib/validators/string-with-length')

const ALLOWED_IN_RENDERER = [
  // a list of config keys that are allowed to be supplied to the renderer client
  // this must be kept in sync with the typescript "AllowedRendererConfig" type
  'onError', 'onBreadcrumb', 'logger', 'metadata', 'user', 'context', 'codeBundleId', 'plugins', 'appType'
]

module.exports.schema = {
  ...schema,
  projectRoot: {
    defaultValue: () => null,
    validate: value => value === null || stringWithLength(value),
    message: 'should be string'
  },
  releaseStage: {
    ...schema.releaseStage,
    defaultValue: () => null
  },
  logger: Object.assign({}, schema.logger, {
    defaultValue: () => getPrefixedConsole()
  }),
  codeBundleId: {
    defaultValue: () => undefined,
    message: 'should be a string',
    validate: val => (val === undefined || stringWithLength(val))
  }
}

module.exports.mergeOptions = (mainOpts, rendererOpts) => {
  return Object.keys(module.exports.schema).reduce((accum, k) => {
    if (Object.prototype.hasOwnProperty.call(rendererOpts, k)) {
      if (ALLOWED_IN_RENDERER.includes(k)) {
        if (k === 'metadata') {
          // ensure that metadata set in renderer config doesn't blow away all preexisting metadata
          return { ...accum, [k]: mergeMetadata(mainOpts[k], rendererOpts[k]) }
{'fraction_non_alphanumeric': 0.14887640449438203, 'fraction_numerical': 0.0, 'mean_word_length': 3.7721943048576216, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6947169', 'n_tokens_mistral': 865, 'n_tokens_neox': 868, 'n_words': 227}