Sha256: bfebddba596f4457287e898b5b47a31283f6e1ed2c4561404a67652ffe14b9d1

Contents?: true

Size: 723 Bytes

Versions: 9

Compression:

Stored size: 723 Bytes

Contents

# Copyright (c) 2015 Sqreen. All Rights Reserved.
# Please refer to our terms for more information: https://www.sqreen.com/terms.html

require 'sqreen/rules/matcher_rule'
require 'sqreen/frameworks'

module Sqreen
  module Rules
    # Look for crawlers and post them in metrics
    class CrawlerUserAgentMatchesMetricsCB < MatcherRuleCB
      CRAWLER_CATEGORY = 'crawler'.freeze

      def pre(_inst, _args, _budget = nil, &_block)
        ua = framework.client_user_agent
        return unless ua
        found = match(ua)
        return unless found
        Sqreen.log.debug { "Found UA #{ua} - found: #{found}" }
        record_observation(CRAWLER_CATEGORY, ua, 1)
        advise_action(nil)
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
sqreen-1.18.6-java lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.18.6 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.18.5-java lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.18.5 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.18.4-java lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.18.4 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.18.3-java lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.18.3 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.18.3.beta2 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb