Sha256: cf83c3d2f62aa2cdd778c0ac5df87152adfef34461ea7dc2176c9d530d9b15e8

Contents?: true

Size: 1.02 KB

Versions: 4

Compression:

Stored size: 1.02 KB

Contents

# typed: true

require 'datadog/tracing/contrib/analytics'

module Datadog
  module Tracing
    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.tracing[: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
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
ddtrace-1.2.0 lib/datadog/tracing/contrib/action_view/utils.rb
ddtrace-1.1.0 lib/datadog/tracing/contrib/action_view/utils.rb
ddtrace-1.0.0 lib/datadog/tracing/contrib/action_view/utils.rb
ddtrace-1.0.0.beta2 lib/datadog/tracing/contrib/action_view/utils.rb