Class: Algolia::Insights
- Inherits:
-
Object
- Object
- Algolia::Insights
- Defined in:
- lib/algolia/insights.rb
Constant Summary collapse
- MIN_RUBY_VERSION =
'1.9.0'
Instance Method Summary collapse
-
#initialize(app_id, api_key, region = 'us', params = {}) ⇒ Insights
constructor
A new instance of Insights.
- #send_event(event) ⇒ Object
- #send_events(events) ⇒ Object
- #user(user_token) ⇒ Object
Constructor Details
#initialize(app_id, api_key, region = 'us', params = {}) ⇒ Insights
Returns a new instance of Insights.
6 7 8 9 10 11 12 13 14 15 16 17 |
# File 'lib/algolia/insights.rb', line 6 def initialize(app_id, api_key, region = 'us', params = {}) headers = params[:headers] || {} @app_id = app_id @api_key = api_key @url = "https://insights.#{region}.algolia.io" @headers = headers.merge({ Protocol::HEADER_APP_ID => app_id, Protocol::HEADER_API_KEY => api_key, 'Content-Type' => 'application/json; charset=utf-8', 'User-Agent' => ["Algolia for Ruby (#{::Algolia::VERSION})", "Ruby (#{RUBY_VERSION})"].join('; ') }) end |
Instance Method Details
#send_event(event) ⇒ Object
23 24 25 |
# File 'lib/algolia/insights.rb', line 23 def send_event(event) send_events([event]) end |
#send_events(events) ⇒ Object
27 28 29 |
# File 'lib/algolia/insights.rb', line 27 def send_events(events) perform_request(:POST, '/1/events', {}, { 'events' => events }.to_json) end |
#user(user_token) ⇒ Object
19 20 21 |
# File 'lib/algolia/insights.rb', line 19 def user(user_token) UserInsights.new(self, user_token) end |