Class: Spree::BaseAnalyticsEventHandler

Inherits:
Object
  • Object
show all
Defined in:
app/models/spree/base_analytics_event_handler.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts = {}) ⇒ BaseAnalyticsEventHandler

Initializes the event handler

Parameters:

  • client (Object)

    The client object

  • opts (Hash) (defaults to: {})

    The options

Options Hash (opts):



9
10
11
12
13
14
15
# File 'app/models/spree/base_analytics_event_handler.rb', line 9

def initialize(opts = {})
  @user = opts[:user]
  @session = opts[:session]
  @request = opts[:request]
  @store = opts[:store]
  @visitor_id = opts[:visitor_id]
end

Instance Attribute Details

#requestObject (readonly)

Returns the value of attribute request.



17
18
19
# File 'app/models/spree/base_analytics_event_handler.rb', line 17

def request
  @request
end

#sessionObject (readonly)

Returns the value of attribute session.



17
18
19
# File 'app/models/spree/base_analytics_event_handler.rb', line 17

def session
  @session
end

#storeObject (readonly)

Returns the value of attribute store.



17
18
19
# File 'app/models/spree/base_analytics_event_handler.rb', line 17

def store
  @store
end

#userObject (readonly)

Returns the value of attribute user.



17
18
19
# File 'app/models/spree/base_analytics_event_handler.rb', line 17

def user
  @user
end

#visitor_idObject (readonly)

Returns the value of attribute visitor_id.



17
18
19
# File 'app/models/spree/base_analytics_event_handler.rb', line 17

def visitor_id
  @visitor_id
end

Instance Method Details

#clientObject

Returns the client

Returns:

  • (Object)

    The client object

Raises:

  • (NotImplementedError)


21
22
23
# File 'app/models/spree/base_analytics_event_handler.rb', line 21

def client
  raise NotImplementedError, 'Subclasses must implement the client method'
end

#event_human_name(event_name) ⇒ String

Returns the human name for the event

Parameters:

  • event_name (String)

    eg. ‘order_completed’

Returns:

  • (String)

    eg. ‘Order Completed’



37
38
39
# File 'app/models/spree/base_analytics_event_handler.rb', line 37

def event_human_name(event_name)
  Analytics.events[event_name.to_sym]
end

#handle_event(event_name, properties = {}) ⇒ Object

Handles the event rubocop:disable Lint/UnusedMethodArgument

Parameters:

  • event_name (String)

    eg. ‘order_completed’

  • properties (Hash) (defaults to: {})

    eg. { product: Spree::Product, taxon: Spree::Taxon, query: String }

Raises:

  • (NotImplementedError)


29
30
31
# File 'app/models/spree/base_analytics_event_handler.rb', line 29

def handle_event(event_name, properties = {})
  raise NotImplementedError, 'Subclasses must implement the handle method'
end