Sha256: d96edfe26a54595f32763f30a6dfa28d55666290ae315f2f3d235142aef8baec

Contents?: true

Size: 881 Bytes

Versions: 11

Compression:

Stored size: 881 Bytes

Contents

require 'json'

module OmniAuth
  module Auth0
    # Module to provide necessary telemetry for API requests.
    module Telemetry

      # Return a telemetry hash to be encoded and sent to Auth0.
      # @return hash
      def telemetry
        telemetry = {
          name: 'omniauth-auth0',
          version: OmniAuth::Auth0::VERSION,
          env: {
            ruby: RUBY_VERSION
          }
        }
        add_rails_version telemetry
      end

      # JSON-ify and base64 encode the current telemetry.
      # @return string
      def telemetry_encoded
        Base64.urlsafe_encode64(JSON.dump(telemetry))
      end

      private

      def add_rails_version(telemetry)
        return telemetry unless Gem.loaded_specs['rails'].respond_to? :version
        telemetry[:env][:rails] = Gem.loaded_specs['rails'].version.to_s
        telemetry
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
omniauth-auth0-3.1.1 lib/omniauth/auth0/telemetry.rb
omniauth-auth0-3.1.0 lib/omniauth/auth0/telemetry.rb
omniauth-auth0-3.0.0 lib/omniauth/auth0/telemetry.rb
omniauth-auth0-2.6.0 lib/omniauth/auth0/telemetry.rb
omniauth-auth0-2.5.0 lib/omniauth/auth0/telemetry.rb
omniauth-auth0-2.4.2 lib/omniauth/auth0/telemetry.rb
omniauth-auth0-2.4.1 lib/omniauth/auth0/telemetry.rb
omniauth-auth0-2.4.0 lib/omniauth/auth0/telemetry.rb
omniauth-auth0-2.3.1 lib/omniauth/auth0/telemetry.rb
omniauth-auth0-2.3.0 lib/omniauth/auth0/telemetry.rb
omniauth-auth0-2.2.0 lib/omniauth/auth0/telemetry.rb