Skip to content

Ruby SDK for RudderStack - Open-source, warehouse-first Customer Data Pipeline and Segment-alternative. Collects and routes clickstream data and builds your customer data lake on your data warehouse.

License

Notifications You must be signed in to change notification settings

rudderlabs/rudder-sdk-ruby

 
 

Repository files navigation

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.

About

Ruby SDK for RudderStack - Open-source, warehouse-first Customer Data Pipeline and Segment-alternative. Collects and routes clickstream data and builds your customer data lake on your data warehouse.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Ruby 100.0%