Class: SearchClickTracking::Service
- Inherits:
-
Common::Client::Base
- Object
- Common::Client::Base
- SearchClickTracking::Service
- Includes:
- Common::Client::Concerns::Monitoring
- Defined in:
- lib/search_click_tracking/service.rb
Overview
This class builds a wrapper around Search.gov web click tracking API.
Constant Summary collapse
- STATSD_KEY_PREFIX =
'api.search_click_tracking'
Instance Attribute Summary collapse
-
#module_code ⇒ Object
readonly
Returns the value of attribute module_code.
-
#position ⇒ Object
readonly
Returns the value of attribute position.
-
#query ⇒ Object
readonly
Returns the value of attribute query.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
-
#user_agent ⇒ Object
readonly
Returns the value of attribute user_agent.
Instance Method Summary collapse
-
#initialize(url, query, position, user_agent, module_code = 'I14Y') ⇒ Service
constructor
A new instance of Service.
-
#track_click ⇒ Object
POSTs click tracking query param data to search.gov.
Methods included from Common::Client::Concerns::Monitoring
Methods inherited from Common::Client::Base
configuration, #raise_backend_exception
Methods included from SentryLogging
#log_exception_to_sentry, #log_message_to_sentry, #non_nil_hash?, #normalize_level, #rails_logger
Constructor Details
#initialize(url, query, position, user_agent, module_code = 'I14Y') ⇒ Service
Returns a new instance of Service.
23 24 25 26 27 28 29 |
# File 'lib/search_click_tracking/service.rb', line 23 def initialize(url, query, position, user_agent, module_code = 'I14Y') @url = url @query = query @position = position @user_agent = user_agent @module_code = module_code end |
Instance Attribute Details
#module_code ⇒ Object (readonly)
Returns the value of attribute module_code.
21 22 23 |
# File 'lib/search_click_tracking/service.rb', line 21 def module_code @module_code end |
#position ⇒ Object (readonly)
Returns the value of attribute position.
21 22 23 |
# File 'lib/search_click_tracking/service.rb', line 21 def position @position end |
#query ⇒ Object (readonly)
Returns the value of attribute query.
21 22 23 |
# File 'lib/search_click_tracking/service.rb', line 21 def query @query end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
21 22 23 |
# File 'lib/search_click_tracking/service.rb', line 21 def url @url end |
#user_agent ⇒ Object (readonly)
Returns the value of attribute user_agent.
21 22 23 |
# File 'lib/search_click_tracking/service.rb', line 21 def user_agent @user_agent end |
Instance Method Details
#track_click ⇒ Object
POSTs click tracking query param data to search.gov
33 34 35 36 37 38 39 |
# File 'lib/search_click_tracking/service.rb', line 33 def track_click with_monitoring do Faraday.post(url_with_params, '') end rescue => e e end |