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

Accept Hash in before_send* callbacks again #2529

Merged
merged 3 commits into from
Jan 29, 2025
Merged

Accept Hash in before_send* callbacks again #2529

merged 3 commits into from
Jan 29, 2025

Conversation

st0012
Copy link
Collaborator

@st0012 st0012 commented Jan 28, 2025

It was unintentionally dropped in #2504. But because we do want to stop accepting Hash value in the future, I made it print deprecation messages when a Hash is passed as well.

Closes #2526

Copy link

codecov bot commented Jan 28, 2025

Codecov Report

Attention: Patch coverage is 0% with 5 lines in your changes missing coverage. Please review.

Project coverage is 69.72%. Comparing base (1ee671c) to head (f699525).
Report is 1 commits behind head on master.

Files with missing lines Patch % Lines
sentry-ruby/lib/sentry/client.rb 0.00% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2529      +/-   ##
==========================================
+ Coverage   69.32%   69.72%   +0.40%     
==========================================
  Files         125      125              
  Lines        4721     4724       +3     
==========================================
+ Hits         3273     3294      +21     
+ Misses       1448     1430      -18     
Components Coverage Δ
sentry-ruby 60.54% <0.00%> (+0.54%) ⬆️
sentry-rails 96.76% <ø> (ø)
sentry-sidekiq 97.08% <ø> (ø)
sentry-resque 92.85% <ø> (ø)
sentry-delayed_job 95.65% <ø> (ø)
sentry-opentelemetry 99.31% <ø> (ø)
Files with missing lines Coverage Δ
sentry-ruby/lib/sentry/client.rb 47.82% <0.00%> (-1.07%) ⬇️

... and 4 files with indirect coverage changes

@st0012 st0012 requested review from solnic and sl0thentr0py January 28, 2025 14:06
@edariedl
Copy link
Contributor

Hello, I understand that returning the Hash from the before_send* is deprecated byt this PR. But, the official documentation still suggests to do it if someone wants to scrub the data before they are sent to Sentry see https://docs.sentry.io/platforms/ruby/guides/rails/data-management/sensitive-data/#scrubbing-data

require "active_support/parameter_filter"

Sentry.init do |config|
  #...

  # this example uses Rails' parameter filter to sanitize the event payload
  # for Rails 6+
  filter = ActiveSupport::ParameterFilter.new(Rails.application.config.filter_parameters)
  # for Rails 5
  filter = ActionDispatch::Http::ParameterFilter.new(Rails.application.config.filter_parameters)
  config.before_send = lambda do |event, hint|
    filter.filter(event.to_hash)
  end
end

Is there a new suggested way to scrub the date given the current one will be deprecated?

@st0012
Copy link
Collaborator Author

st0012 commented Jan 28, 2025

#2524 is what we'll use to track the documentation update and the author provided a good example to work with the event types for now.

@sl0thentr0py sl0thentr0py merged commit a064512 into master Jan 29, 2025
145 of 148 checks passed
@sl0thentr0py sl0thentr0py deleted the fix-#2526 branch January 29, 2025 09:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Event not sent when scrubbing sensitive data in before_send on sentry-ruby 5.22.2
3 participants