Sha256: 26801327eceefb5a384b328fe7b41dab5fe8fca3c3d7f2448d6a80317cfebbf3

Contents?: true

Size: 606 Bytes

Versions: 7

Compression:

Stored size: 606 Bytes

Contents

module ReTrack
  module Tracker
    extend ActiveSupport::Concern

    included do
      before_filter :rt_track_referer
    end

    private

      def rt_track_referer
        session[:retrack].nil? && !request_from_a_known_bot? &&
          session[:retrack] = SessionData.to_hash(request)
      end

      def request_from_a_known_bot?
        bot_user_agents = ['GoogleBot', 'Mediapartners-Google', 'msnbot',
          'TwengaBot', 'DigExt; DTS Agent', 'YandexImages']
        bot_user_agents_re = /\b(#{bot_user_agents * '|'})\b/i
        request.user_agent =~ bot_user_agents_re
      end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
re_track-0.7.4 lib/re_track/tracker.rb
re_track-0.7.2 lib/re_track/tracker.rb
re_track-0.7.1 lib/re_track/tracker.rb
re_track-0.7.0 lib/re_track/tracker.rb
re_track-0.6.0 lib/re_track/tracker.rb
re_track-0.5.2 lib/re_track/tracker.rb
re_track-0.5.1 lib/re_track/tracker.rb