diff options
Diffstat (limited to 'lib/error_tracking/collector/sentry_auth_parser.rb')
-rw-r--r-- | lib/error_tracking/collector/sentry_auth_parser.rb | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/lib/error_tracking/collector/sentry_auth_parser.rb b/lib/error_tracking/collector/sentry_auth_parser.rb new file mode 100644 index 00000000000..4945b8f73e1 --- /dev/null +++ b/lib/error_tracking/collector/sentry_auth_parser.rb @@ -0,0 +1,25 @@ +# frozen_string_literal: true + +module ErrorTracking + module Collector + class SentryAuthParser + def self.parse(request) + # Sentry client sends auth in X-Sentry-Auth header + # + # Example of content: + # "Sentry sentry_version=7, sentry_client=sentry-ruby/4.5.1, sentry_timestamp=1623923398, + # sentry_key=afadk312..., sentry_secret=123456asd32131..." + auth = request.headers['X-Sentry-Auth'] + + # Sentry DSN contains key and secret. + # The key is required while secret is optional. + # We are going to use only the key since secret is deprecated. + public_key = auth[/sentry_key=(\w+)/, 1] + + { + public_key: public_key + } + end + end + end +end |