Sha256: ac78122598e7d97ad40209cef1e3203500b8ff68e5133cfcea4b984b9ca69ec7

Contents?: true

Size: 1.07 KB

Versions: 5

Compression:

Stored size: 1.07 KB

Contents

require 'landable/traffic/tracker'
require 'landable/traffic/crawl_tracker'
require 'landable/traffic/ping_tracker'
require 'landable/traffic/scan_tracker'
require 'landable/traffic/scrape_tracker'
require 'landable/traffic/user_tracker'
require 'landable/traffic/noop_tracker'

module Landable
  module Traffic
    def track_with_landable!
      yield and return if untracked?

      begin
        @tracker = Tracker.for self
        @tracker.track
      rescue => e
        Rails.logger.error e
        if respond_to? :newrelic_notice_error
          newrelic_notice_error e
        end
      end

      yield

      begin
        @tracker.save
      rescue => e
        Rails.logger.error e
        if respond_to? :newrelic_notice_error
          newrelic_notice_error e
        end
      end
    end

    def untracked?
      untracked_user? || untracked_path?
    end

    def untracked_user?
      Landable.configuration.dnt_enabled && request.headers["DNT"] == "1"
    end

    def untracked_path?
      Landable.configuration.untracked_paths.include? request.fullpath
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
landable-1.12.3 lib/landable/traffic.rb
landable-1.12.2 lib/landable/traffic.rb
landable-1.12.1 lib/landable/traffic.rb
landable-1.11.1 lib/landable/traffic.rb
landable-1.11.0 lib/landable/traffic.rb