Welcome to mirror list, hosted at ThFree Co, Russian Federation.

context_payload_processor.rb « processor « error_tracking « gitlab « lib - gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 758f6aa11d73c900b735acf412915548c7aa2d24 (plain)
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
# frozen_string_literal: true

module Gitlab
  module ErrorTracking
    module Processor
      class ContextPayloadProcessor < ::Raven::Processor
        # This processor is added to inject application context into Sentry
        # events generated by Sentry built-in integrations. When the
        # integrations are re-implemented and use Gitlab::ErrorTracking, this
        # processor should be removed.
        def process(payload)
          return payload if ::Feature.enabled?(:sentry_processors_before_send, default_enabled: :yaml)

          context_payload = Gitlab::ErrorTracking::ContextPayloadGenerator.generate(nil, {})
          payload.deep_merge!(context_payload)
        end

        def self.call(event)
          return event unless ::Feature.enabled?(:sentry_processors_before_send, default_enabled: :yaml)

          Gitlab::ErrorTracking::ContextPayloadGenerator.generate(nil, {}).each do |key, value|
            event.public_send(key).deep_merge!(value) # rubocop:disable GitlabSecurity/PublicSend
          end

          event
        end
      end
    end
  end
end