rollbar / rollbar.js

Error tracking and logging from Javascript to Rollbar

Home Page:https://docs.rollbar.com/docs/javascript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How to remove `request.POST` data?

pqvst opened this issue · comments

What's the easiest way of removing the entire request.POST object that is included by default when using rollbar.errorHandler with express.js?

I tried:

scrubPaths: ['request.POST'],

But that causes an error in rollbar itself:

API error: Invalid format. data.request.POST should be object,null,array.

You could put a transform function in your Rollbar config:

  transform: function(payload) {
    if (payload.request && payload.request.POST) {
      payload.request.POST = null;
    }
  }

Ah ok, that's what I thought. I added the following to ensure bodies (and headers) are never sent to rollbar.

transform: (data) => {
  delete data.request?.headers;
  delete data.request?.body;
  delete data.request?.GET;
  delete data.request?.HEAD;
  delete data.request?.POST;
  delete data.request?.PUT;
  delete data.request?.DELETE;
  delete data.request?.CONNECT;
  delete data.request?.OPTIONS;
  delete data.request?.TRACE;
  delete data.request?.PATCH;
},

As a request, it would be nice if there were simple config flags for this though:

captureBody: false,
captureHeaders: false

Agreed.