Project

ruddertest

0.01
No release in over 3 years
The Rudder ruby analytics library
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 4.1.11
~> 0.1.4
~> 4.4
~> 3.6.2
~> 10.3
~> 3.0
~> 0.51.0
= 1.2.1
 Project Readme

The Customer Data Platform for Developers

Website · Documentation · Community Slack


RudderStack Ruby SDK

The RudderStack Ruby SDK lets you send customer event data from your Ruby applications to your specified destinations.

SDK setup requirements

Installation

To install the RudderStack Ruby SDK, add this line to your application's Gem file:

gem 'rudder-sdk-ruby'

You can also install the SDK into your environment gems by running the following command:

gem install 'rudder-sdk-ruby'

Using the SDK

To use the Ruby SDK, create a client instance as shown:

require 'rudder-sdk-ruby'

analytics = Rudder::Analytics.new(
  :write_key => 'WRITE_KEY',
  :data_plane_url => 'DATA_PLANE_URL',
  :gzip => true
)
Make sure to replace WRITE_KEY and DATA_PLANE_URL in the above snippet with the actual values from your RudderStack dashboard.

You can then use this client to send the events. A sample track call sent using the client is shown below:

analytics.track(
  :user_id => '1hKOmRA4GRlm',
  :event => 'Item Sold',
  :properties => { :revenue => 9.95, :shipping => 'Free' }
)

Gzipping requests

The Gzip feature is enabled by default in the Ruby SDK. However, you can disable this feature by setting the gzip parameter to false while initializing the SDK:

analytics = Rudder::Analytics.new(
  :write_key => 'WRITE_KEY', # required
  :data_plane_url => 'DATA_PLANE_URL',
  :gzip => false, // Set to true to enable Gzip compression
  :on_error => proc { |error_code, error_body, exception, response|
    # defaults to an empty proc
  }
)
Note: Gzip requires rudder-server version 1.4 or later. Otherwise, your events might fail.

Sending events

Refer to the RudderStack Ruby SDK documentation for more information on the supported event types.

Test queue

Enable the stub option while initializing the SDK to stub all the requests, making it easier for you to test with this library.

License

The RudderStack Ruby SDK is released under the MIT license.