Sha256: 556351e3f64063407a9d49e0cbd107c1b8ecaf52c18bc429d2a09510ecb525bc

Contents?: true

Size: 952 Bytes

Versions: 5

Compression:

Stored size: 952 Bytes

Contents

# typed: true
require 'ddtrace/contrib/analytics'

module Datadog
  module Contrib
    module ActionView
      # common utilities for Rails
      module Utils
        module_function

        # in Rails the template name includes the template full path
        # and it's better to avoid storing such information. This method
        # returns the relative path from `views/` or the template name
        # if a `views/` folder is not in the template full path. A wrong
        # usage ensures that this method will not crash the tracing system.
        def normalize_template_name(name)
          return if name.nil?

          base_path = Datadog.configuration[:action_view][:template_base_path]
          sections_view = name.split(base_path)

          if sections_view.length == 1
            name.split('/')[-1]
          else
            sections_view[-1]
          end
        rescue
          name.to_s
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
ddtrace-0.54.2 lib/ddtrace/contrib/action_view/utils.rb
ddtrace-0.54.1 lib/ddtrace/contrib/action_view/utils.rb
ddtrace-0.54.0 lib/ddtrace/contrib/action_view/utils.rb
ddtrace-0.53.0 lib/ddtrace/contrib/action_view/utils.rb
ddtrace-0.52.0 lib/ddtrace/contrib/action_view/utils.rb