Skip to content

vantran/amplitude-api

 
 

Repository files navigation

Amplitude API

Build Status Code Climate Gem Version

Installation

gem install amplitude-api

Basic Usage

The following code snippet will immediately track an event to the Amplitude API. The time on the event will automatically be the time of the request.

# Configure your Amplitude API key
AmplitudeAPI.api_key = "abcdef123456"

event = AmplitudeAPI::Event.new({
  user_id: "123",
  event_type: "clicked on home",
  event_properties: {
    cause: "button",
    arbitrary: "properties"
  }
})
AmplitudeAPI.track(event)

Currently, we are using this in Rails and using ActiveJob to dispatch events asynchronously. I plan on moving background/asynchronous support into this gem.

What's Next

  • Thread support for background dispatching in bulk
  • device_id support as an alternative to user_id
  • Configurable default account to use when no user_id present

Other useful resources

Contributing

I'd love to hear how you're using this. Please check out the issues.

About

A Ruby library for interacting with the Amplitude API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%