Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix custom scrubber configuration docs #410

Merged
merged 1 commit into from
Jul 10, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions lib/sentry/plug_context.ex
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ defmodule Sentry.PlugContext do

Then pass it into Sentry.Plug:

use Sentry.PlugContext, body_scrubber: &scrub_params/1
plug Sentry.PlugContext, body_scrubber: &MyModule.scrub_params/1

You can also pass it in as a `{module, fun}` like so:

use Sentry.PlugContext, body_scrubber: {MyModule, :scrub_params}
plug Sentry.PlugContext, body_scrubber: {MyModule, :scrub_params}

*Please Note*: If you are sending large files you will want to scrub them out.

Expand All @@ -54,11 +54,11 @@ defmodule Sentry.PlugContext do

Then pass it into Sentry.Plug:

use Sentry.PlugContext, header_scrubber: &scrub_headers/1
plug Sentry.PlugContext, header_scrubber: &MyModule.scrub_headers/1

It can also be passed in as a `{module, fun}` like so:

use Sentry.PlugContext, header_scrubber: {MyModule, :scrub_headers}
plug Sentry.PlugContext, header_scrubber: {MyModule, :scrub_headers}

### Cookie Scrubber

Expand All @@ -67,8 +67,8 @@ defmodule Sentry.PlugContext do

To configure scrubbing, we can set all configuration keys:

use Sentry.PlugContext, header_scrubber: &scrub_headers/1,
body_scrubber: &scrub_params/1, cookie_scrubber: &scrub_cookies/1
plug Sentry.PlugContext, header_scrubber: &MyModule.scrub_headers/1,
body_scrubber: &MyModule.scrub_params/1, cookie_scrubber: &MyModule.scrub_cookies/1

### Including Request Identifiers

Expand All @@ -78,7 +78,7 @@ defmodule Sentry.PlugContext do
which header key Sentry should check. It will default to "x-request-id",
which Plug.RequestId (and therefore Phoenix) also default to.

use Sentry.PlugContext, request_id_header: "application-request-id"
plug Sentry.PlugContext, request_id_header: "application-request-id"
"""

if Code.ensure_loaded?(Plug) do
Expand Down
6 changes: 5 additions & 1 deletion test/plug_capture_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ defmodule Sentry.PlugCaptureTest do
pass: ["*/*"],
json_decoder: Jason

plug Sentry.PlugContext
plug Sentry.PlugContext, body_scrubber: &PhoenixEndpoint.scrub_params/1

plug PhoenixRouter

def scrub_params(conn) do
Sentry.PlugContext.default_body_scrubber(conn)
end
end

test "sends error to Sentry" do
Expand Down