Taroko::Drucker
Ruby client for Drucker event tracking system.
Installation
Add this line to your application's Gemfile:
gem 'taroko-drucker'
And then execute:
$ bundle
Setup
Setup your application unique ID into Drucker:
# config/initializers/drucker.rb
Taroko::Drucker.setup do |config|
config.project_id = 'YOUR_PROJECT_ID' # must be a UUID
end
Usage
To send an event to Drucker:
Taroko::Drucker::Event.create(event_type: 'purchase', count: 1)
# returns `true` if event sent to Drucker successfully, otherwise `false`.
# or
event = Taroko::Drucker.new
event.create(event_type: 'purchase', count: 1)
# returns `true` if event sent to Drucker successfully, otherwise `false`.
Taroko::Drucker::Event.create
accepts following parameters:
Name | Required | Data type | Description | Example |
---|---|---|---|---|
event_type | yes | string/symbol | Event type | :renewal , 'renewal' , :purchase , 'purchase' , etc |
count | yes | integer | Event happens times | 1, 2, etc |
user_id | no | UUID | Unique ID of the user | e1cc5111-33db-491c-9e73-fca4953bec34 |
user_attributes | no | hash | Data which describes the user | { first_name: 'Jon', last_name: 'Snow' } |
attributes | no | hash | Data which describes the event | { session_id: 'adsfsadf' } |
Notice that if you send incorrect type of params, it'll raise ArgumentError
with messages.
Debug mode
Sometimes you want to know the response from Drucker:
event_agent = Taroko::Drucker::Event.new
event_agent.create(params) # returns `false` if event is not record by Drucker correctly.
event_agent.error #=> { status: 400, body: 'error message from Drucker server' }
Development
Run all tests:
bundle exec rake
Contributing
Bug reports and pull requests are welcome on GitHub at https://github.com/resumecompanion/drucker-client-ruby.