Sha256: b4e6fcd566e0e5ed3149c38502135ffe9b30fa02c60dbd8d97e5ff506ecb5bc9

Contents?: true

Size: 849 Bytes

Versions: 15

Compression:

Stored size: 849 Bytes

Contents

# frozen_string_literal: true

module GraphqlRails
  module Integrations
    # sentry integration
    module Sentry
      require 'active_support/concern'

      # controller extension which logs errors to sentry
      module SentryLogger
        extend ActiveSupport::Concern

        included do
          around_action :log_to_sentry

          protected

          def log_to_sentry
            Raven.context.transaction.pop
            Raven.context.transaction.push "#{self.class}##{action_name}"
            yield
          rescue Exception => error # rubocop:disable Lint/RescueException
            Raven.capture_exception(error) unless error.is_a?(GraphQL::ExecutionError)
            raise error
          end
        end
      end

      def self.enable
        GraphqlRails::Controller.include(SentryLogger)
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
graphql_rails-3.0.0 lib/graphql_rails/integrations/sentry.rb
graphql_rails-2.4.0 lib/graphql_rails/integrations/sentry.rb
graphql_rails-2.3.0 lib/graphql_rails/integrations/sentry.rb
graphql_rails-2.2.0 lib/graphql_rails/integrations/sentry.rb
graphql_rails-2.1.0 lib/graphql_rails/integrations/sentry.rb
graphql_rails-2.0.0 lib/graphql_rails/integrations/sentry.rb
graphql_rails-1.2.6 lib/graphql_rails/integrations/sentry.rb
graphql_rails-1.2.4 lib/graphql_rails/integrations/sentry.rb
graphql_rails-1.2.3 lib/graphql_rails/integrations/sentry.rb
graphql_rails-1.2.2 lib/graphql_rails/integrations/sentry.rb
graphql_rails-1.2.1 lib/graphql_rails/integrations/sentry.rb
graphql_rails-1.2.0 lib/graphql_rails/integrations/sentry.rb
graphql_rails-1.1.0 lib/graphql_rails/integrations/sentry.rb
graphql_rails-1.0.0 lib/graphql_rails/integrations/sentry.rb
graphql_rails-0.8.0 lib/graphql_rails/integrations/sentry.rb