Class: AmplitudeAnalytics::AmplitudeDestinationPlugin
- Inherits:
-
DestinationPlugin
- Object
- Plugin
- EventPlugin
- DestinationPlugin
- AmplitudeAnalytics::AmplitudeDestinationPlugin
- Defined in:
- lib/amplitude/plugin.rb
Overview
AmplitudeDestinationPlugin
Instance Attribute Summary collapse
-
#workers ⇒ Object
readonly
Returns the value of attribute workers.
Attributes inherited from DestinationPlugin
Attributes inherited from Plugin
Instance Method Summary collapse
- #execute(event) ⇒ Object
- #flush ⇒ Object
-
#initialize ⇒ AmplitudeDestinationPlugin
constructor
A new instance of AmplitudeDestinationPlugin.
- #setup(client) ⇒ Object
- #shutdown ⇒ Object
- #verify_event(event) ⇒ Object
Methods inherited from DestinationPlugin
Methods inherited from EventPlugin
Constructor Details
#initialize ⇒ AmplitudeDestinationPlugin
68 69 70 71 72 73 |
# File 'lib/amplitude/plugin.rb', line 68 def initialize super @workers = Workers.new @storage = nil @configuration = nil end |
Instance Attribute Details
#workers ⇒ Object (readonly)
Returns the value of attribute workers.
66 67 68 |
# File 'lib/amplitude/plugin.rb', line 66 def workers @workers end |
Instance Method Details
#execute(event) ⇒ Object
88 89 90 91 92 93 |
# File 'lib/amplitude/plugin.rb', line 88 def execute(event) event = @timeline.process(event) raise InvalidEventError, 'Invalid event.' unless verify_event(event) @storage.push(event) end |
#flush ⇒ Object
95 96 97 |
# File 'lib/amplitude/plugin.rb', line 95 def flush @workers.flush end |
#setup(client) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/amplitude/plugin.rb', line 75 def setup(client) @configuration = client.configuration @storage = client.configuration.storage @workers.setup(client.configuration, @storage) @storage.setup(client.configuration, @workers) end |
#shutdown ⇒ Object
99 100 101 102 |
# File 'lib/amplitude/plugin.rb', line 99 def shutdown @timeline.shutdown @workers.stop end |
#verify_event(event) ⇒ Object
82 83 84 85 86 |
# File 'lib/amplitude/plugin.rb', line 82 def verify_event(event) return false unless event.is_a?(BaseEvent) && event.event_type && (event.user_id || event.device_id) true end |