{"action":"opened","issue":{"url":"https://api.github.com/repos/elastic/apm-agent-nodejs/issues/290","repository_url":"https://api.github.com/repos/elastic/apm-agent-nodejs","labels_url":"https://api.github.com/repos/elastic/apm-agent-nodejs/issues/290/labels{/name}","comments_url":"https://api.github.com/repos/elastic/apm-agent-nodejs/issues/290/comments","events_url":"https://api.github.com/repos/elastic/apm-agent-nodejs/issues/290/events","html_url":"https://github.com/elastic/apm-agent-nodejs/issues/290","id":309264674,"number":290,"title":"addFilter example outdated","user":{"login":"Thetortuga","id":11147922,"avatar_url":"https://avatars0.githubusercontent.com/u/11147922?v=4","gravatar_id":"","url":"https://api.github.com/users/Thetortuga","html_url":"https://github.com/Thetortuga","followers_url":"https://api.github.com/users/Thetortuga/followers","following_url":"https://api.github.com/users/Thetortuga/following{/other_user}","gists_url":"https://api.github.com/users/Thetortuga/gists{/gist_id}","starred_url":"https://api.github.com/users/Thetortuga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Thetortuga/subscriptions","organizations_url":"https://api.github.com/users/Thetortuga/orgs","repos_url":"https://api.github.com/users/Thetortuga/repos","events_url":"https://api.github.com/users/Thetortuga/events{/privacy}","received_events_url":"https://api.github.com/users/Thetortuga/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":0,"created_at":"2018-03-28T08:18:42Z","updated_at":"2018-03-28T08:18:42Z","closed_at":null,"author_association":"NONE","body":"Hi,\r\n\r\nI am trying to use the addFilter feature to filter out some request.\r\nThe example in the doc seems to be outdated:\r\n\r\n```js\r\napm.addFilter(function (payload) {\r\n  if (payload.context.request && payload.context.request.headers) {\r\n    // redact sensitive data\r\n    payload.context.request.headers['x-secret'] = '[REDACTED]'\r\n  }\r\n  // remember to return the modified payload\r\n  return payload\r\n})\r\n```\r\nIndeed, `payload.context` does not exist. Instead, we could make something like that :\r\n```js\r\napm.addFilter(function (payload) {\r\n  payload.transactions.map((transaction) => {\r\n    if (transaction.type === 'request' &&  transaction.context.request.headers) {\r\n      transaction.context.request.headers['x-secret'] = '[REDACTED]'\r\n    }\r\n  })\r\n  return payload\r\n})\r\n```\r\n"}}
{"actor":{"display_login":"Thetortuga"}}