Sha256: a95aa8c7b975b8390ba51a49bef7c510562d1387a14571f3ea23fc37ef58d116

Contents?: true

Size: 732 Bytes

Versions: 80

Compression:

Stored size: 732 Bytes

Contents

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

require 'sqreen/rules_callbacks/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

80 entries across 80 versions & 2 rubygems

Version Path
sqreen-1.15.3.beta2 lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.15.3.beta1 lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.15.2 lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.15.1 lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.15.0-java lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.15.0 lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.14.2-java lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.14.2 lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.14.1-java lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.14.1 lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.14.0-java lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.14.0 lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.14.0.beta3-java lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.14.0.beta3 lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.14.0.beta2 lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.14.0.beta1 lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.13.4-java lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-alt-1.13.4 lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.13.4 lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb
sqreen-1.13.2-java lib/sqreen/rules_callbacks/crawler_user_agent_matches_metrics.rb