-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathsentry.rb
More file actions
55 lines (45 loc) · 1.45 KB
/
sentry.rb
File metadata and controls
55 lines (45 loc) · 1.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
require "active_support/parameter_filter"
require "./app/lib/email_parameter_filter_proc"
if Settings.sentry.dsn.present?
Sentry.init do |config|
config.dsn = Settings.sentry.dsn
config.breadcrumbs_logger = %i[active_support_logger http_logger]
config.debug = true
config.environment = Settings.sentry.environment
filter = ActiveSupport::ParameterFilter.new(
[EmailParameterFilterProc.new(mask: Settings.sentry.filter_mask)],
mask: Settings.sentry.filter_mask,
)
config.before_send = lambda do |event, _hint|
if event.exception && event.exception.values.present?
event.exception.values.each do |exception| # rubocop:disable Style/HashEachMethods
exception.value = filter.filter_param(nil, exception.value)
end
end
if event.extra
event.extra = filter.filter(event.extra)
end
if event.user
event.user = filter.filter(event.user)
end
if event.contexts
event.contexts = filter.filter(event.contexts)
end
event
end
config.before_breadcrumb = lambda do |breadcrumb, _hint|
if breadcrumb.data
breadcrumb.data = filter.filter(breadcrumb.data)
end
breadcrumb
end
end
end
# Uncomment out the below to test Sentry - this
# will raise 2 issues in Sentry
# begin
# 1 / 0
# rescue ZeroDivisionError => exception
# Sentry.capture_exception(exception)
# end
# Sentry.capture_message("test message")