Heap Server-Side API Client for Ruby
This gem is tested on Ruby 1.8.7 and above.
gem 'heap', '~> 1.0'
Otherwise, install the heap gem and activate it in your code manually.
gem install heap
Place the following code in a file that executes when your application initializes.
.app_id = 'YOUR_APP_ID'
In a Ruby on Rails application, place the following snippet in an initializer,
if Rails.env.production? .app_id = 'YOUR_APP_ID' else .app_id = 'YOUR_DEV_APP_ID' end
In some testing environments, connecting to outside servers is undesirable. Set
stubbed accessor to
true to have all API calls succeed without
generating any network traffic.
class StubbedHeapTest < MiniTest::Test def setup Heap.stubbed = true end def teardown Heap.stubbed = false end ... end
Track a server-side event. The properties are optional.
.track 'user-handle', 'event-name', property: 'value'
Add properties to a user.
.add_user_properties 'user-handle', plan: 'premium1'
If the global API client instance stored in
Heap is not a good fit for your
application's architecture, create your own client instances.
heap_client = .new app_id: 'YOUR_APP_ID' heap_client.track 'user-handle', 'event-name', property: 'value'
Legacy Gem Releases
If you are using a pre-1.0 gem, please consider upgrading to an officially
supported release. In the meantime, you can pin the old version in your
gem 'heap', '~> 0.3'
Copyright (c) 2016 Heap Inc., released under the MIT license.