The setAnalyticsMask function allows you to modify the request/response headers, body, or query parameters before they are sent to Atatus. You can utilize this function to make alterations such as removing specific header or body fields. It will give you the flexibility to customize the request data that is ultimately sent to Atatus.

Compatibility

Requires Node.js agent version 1.6.1 or higher.

Syntax

atatus.setAnalyticsMask(fn)

Parameter

Parameter Type Description
fn Function (Required) Mask any field in analytics payload.

Example

copy
icon/buttons/copy
import atatus from "atatus-nodejs";

atatus.setAnalyticsMask((event) => {
  event.responseHeaders['x-powered-by'] = '';

  try {
    if (event.name === 'POST /login') {
      if (event.requestBody) {
        let requestBody = JSON.parse(event.requestBody);
        if (requestBody.password) {
          requestBody.password = '****';
        }
        event.requestBody = JSON.stringify(requestBody);
      }
    }

    if (event.name === 'GET /api/token') {
      if (event.responseBody) {
        let responseBody = JSON.parse(event.responseBody);
        if (responseBody.token) {
          responseBody.token = '****';
        }
        event.responseBody = JSON.stringify(responseBody);
      }
    }

  } catch (e) {
    console.error('Error in mask event ', e)
  }
});