Sha256: f420fd75ad986baa1e63d3be940d434ec2a933ea6bb23b8cd886c55245094c2e

Contents?: true

Size: 740 Bytes

Versions: 39

Compression:

Stored size: 740 Bytes

Contents

# typed: ignore

# 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

39 entries across 39 versions & 1 rubygems

Version Path
sqreen-1.20.4.beta1 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.19.4 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.20.3 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.20.2 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.21.0.beta2 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.21.0.beta1 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.20.1-java lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.20.1 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.20.0-java lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.20.0 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.19.3-java lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.19.3 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.19.2-java lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.19.2 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.19.1-java lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.19.1 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.19.0-java lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.19.0 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb
sqreen-1.19.0.beta1 lib/sqreen/rules/crawler_user_agent_matches_metrics_cb.rb