Because
Node.jsSDK

Redaction

Redact sensitive data from spans before it leaves your application.

Because redacts sensitive data at the span level before it is sent. Redacted values are stored as [REDACTED] and rendered as a muted placeholder in the dashboard.

HTTP headers (automatic)

For http spans, the following request and response headers are always redacted automatically - no configuration needed:

  • Authorization
  • Cookie / Set-Cookie
  • X-Api-Key
  • X-Auth-Token
  • X-Api-Secret
  • X-Access-Token
  • Proxy-Authorization

Field redaction syntax

All redact options accept an array of field specifiers. Two forms are supported:

FormExampleBehaviour
Simple name'password'Redacts any field with that key at any depth
Dot path'customer.name'Redacts only that exact path from the root

Use dot paths when the same key name appears in multiple places and you only want to redact one of them:

// 'name' would redact both customer.name AND currentPlan.name
// dot paths let you be precise:
redact: ['customer.name', 'customer.billing.accountName', 'customer.billing.accountNumber']

// output after redaction:
{
  customer: {
    name: '[REDACTED]',
    address: '42 Eucalyptus Drive, Sydney NSW 2000',
    accountNumber: 'ACME-00123',   // untouched - different path
    billing: {
      accountName: '[REDACTED]',
      bsb: '062-000',
      accountNumber: '[REDACTED]'
    }
  },
  currentPlan: {
    name: 'Standard',              // untouched - different path
    type: 'SINGLE_RATE'
  }
}

Table spans - .redact(fields)

Chain .redact() on the table builder. Fields are matched against the original key name before any label transforms are applied:

because
  .table('Current Bill')
  .fromObject({
    name: customer.name, // redacted
    address: customer.address,
    peakKwh: usage.peak
  })
  .redact(['name'])
  .build();

Works with both .fromObject() and .fromRecords(). Dot paths are not applicable here - tables are flat.


Other span types - redact option

Pass a redact array to addSpan to redact fields from input and output. Applied recursively through nested objects and arrays:

because.addSpan('db', 'Customer lookup', {
  redact: [
    'customer.name',
    'customer.billing.accountName',
    'customer.billing.accountNumber'
  ],
  input: { filter: { accountNumber: 'ACME-00123' } },
  output: {
    customer: {
      name: 'Jane Smith',
      billing: { accountName: 'Jane Smith', accountNumber: '12345678' }
    },
    currentPlan: { name: 'Standard' } // not redacted - different path
  }
});

Trace output - setOutput

Pass a redact array as the second argument:

because.setOutput(
  {
    cheapest: { company: 'Nexen Power', name: 'Flex TOU' },
    customer: { name: customer.name, address: customer.address }
  },
  ['customer.name']
);

Manual redaction

Use because.REDACTED to redact a value yourself before passing it anywhere:

import because from '@refactorlabs/because';

because.addSpan('json', 'Payload', {
  output: {
    apiKey: because.REDACTED,
    endpoint: config.endpoint
  }
});

On this page