Skip to content

tw/trakio-ruby

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

46 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Official trak.io Ruby Library

Installation

Add this line to your application's Gemfile:

gem 'trakio-ruby'

And then execute:

$ bundle

Or install it yourself as:

$ gem install trakio-ruby

Examples

For more indepth documentation see: https://docs.trak.io/ruby.html

Creating an instance, and then tracking an event.

    # create the instance
    trakio = Trakio.new 'my_api_token'
    # track my-event
    resp = trakio.track distinct_id: '[email protected]', event: 'my-event'
    # resp will look like { 'status': 'success', 'trak_id': '12345' }

Creating a default instance, and then tracking an event.

    # set token on default instance
    Trakio.init 'my_api_token'
    # track our event
    resp = Trakio.track distinct_id: '[email protected]', event: 'my-event'
    # resp will look like { 'status': 'success', 'trak_id': '12345' }

Creating an instance and aliasing an entry

    # set token on default instance
    Trakio.init 'my_api_token'

    resp = Trakio.alias distinct_id: '[email protected]', alias: ['[email protected]']
    # resp will look like { 'status': 'success', 'trak_id': '12345', 'distinct_ids': ['[email protected]', '[email protected]'] }

    # an equivilent is shown below

    resp = Trakio.alias distinct_id: '[email protected]', alias: '[email protected]'
    # resp will look like { 'status': 'success', 'trak_id': '12345', 'distinct_ids': ['[email protected]', '[email protected]'] }

Creating an instance and using identify

    # set token on default instance
    Trakio.init 'my_api_token'

    resp = Trakio.identify distinct_id: '[email protected]', properties: { name: 'Tobie' }
    # resp will look like { 'status': 'success', 'trak_id': '12345', 'distinct_ids': ['[email protected]'] }

Creating an instance and using annotate

    # set token on default instance
    Trakio.init 'my_api_token'

    resp = Trakio.annotate event: 'event', channel: 'channel'
    # resp will look like { 'status': 'success', 'trak_id': '12345', 'properties': {} }

Creating and Running Tests

  • Tests can be run by running the following commands bundle exec rspec
  • Tests can be added by either adding into an existing spec file, or creating a new one.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Ruby 100.0%