Heap Server-Side API Client for Ruby
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.
Heap.app_id = 'YOUR_APP_ID'
In a Ruby on Rails application, place the following snippet in an initializer,
if Rails.env.production? Heap.app_id = 'YOUR_APP_ID' else Heap.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.
Heap.track 'event-name', 'user-identity', property: 'value'
Add properties to a user.
Heap.add_user_properties 'user-identity', 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 = Heap.new app_id: 'YOUR_APP_ID' heap_client.track 'user-identity', 'event-name', property: 'value'
After cloning the repository, install the required gems.
Make sure the tests pass after making a change.
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.