Sha256: 43b86f8d646ac51c27aee1155ce72690b295bfd95c6025f00dd093f9d16b7dd9

Contents?: true

Size: 1.07 KB

Versions: 2

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'
require 'landable/traffic/event_publisher'

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

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

      yield

      begin
        @tracker.save
      rescue => e
        Rails.logger.error e
        newrelic_notice_error e if respond_to? :newrelic_notice_error
      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

2 entries across 2 versions & 1 rubygems

Version Path
landable-1.14.0 lib/landable/traffic.rb
landable-1.13.2 lib/landable/traffic.rb