Skip to content

jipiboily/forwardlytics-ruby

Repository files navigation

Forwardlytics: the Ruby client

Sends stuff to Forwardlytics.

Where are we at? What needs to be done and what's in the pipeline? See Forawrdlytics on waffle.io

Build Status Stories in Progress

Installation

Add this line to your application's Gemfile:

gem 'forwardlytics'

And then execute:

$ bundle

How to use it?

Setup

You need to set both FORWARDLYTICS_API_KEY and FORWARDLYTICS_URL environment variables.

FORWARDLYTICS_API_KEY is the API key you configured on Forwardlytics.

FORWARDLYTICS_URL is the URL to reach your instance of Forwardlytics.

Example:

FORWARDLYTICS_API_KEY=123ma
FORWARDLYTICS_URL=http://localhost:3000

Exception handler

Forwardlytics will do its work in threads, so if any exception is raised, it will be silent. We don't want that, so we made an exception handler. Here is how you could configure it in your project:

Forwardlytics.exception_handler = -> (ex) {
  puts "Exception in Forwardlytics caught by exception_handler: #{ex}"
  Bugsnag.notify(ex)
}

Dispatch events and identifications

For user identification:

Forwardlytics.identify(
  user_id: 42,
  traits: {
    email: '[email protected]',
    created_at: 1462183499,
    some: 'thing?'
  }
)

For event tracking:

Forwardlytics.track(
  event: 'Updated Alert',
  user_id: 42,
  properties: {
    some_id: 123,
    some_other_prop: "",
})

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/jipiboily/forwardlytics. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the Contributor Covenant code of conduct.

License

The gem is available as open source under the terms of the MIT License.