The project is in a healthy, maintained state
Rudder is a platform for collecting, storing and routing customer event data to dozens of tools. Rudder is open-source, can run in your cloud environment (AWS, GCP, Azure or even your data-centre) and provides a powerful transformation framework to process your event data on the fly.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
 Dependencies

Development

>= 1.11
>= 0
>= 10.0
~> 3.0
= 1.23.0
~> 0.9.5
~> 3.7
 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_analytics_sync'

You can also install it yourself by running the following command:

gem install rudder_analytics_sync

Using the SDK

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

analytics = RudderAnalyticsSync::Client.new(
  write_key: 'WRITE_KEY', # Required
  data_plane_url: 'DATA_PLANE_URL',
  stub: false,
  gzip: true,  # Set to false to disable Gzip compression
  on_error: proc { |error_code, error_body, exception, response|
    # defaults to an empty proc
  }
)

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: 12345,
  event: 'Test Event'
)

Gzip support

From version 2.0.0, the Ruby SDK supports Gzip compression and it is enabled (set to true) by default. However, you can disable this feature by setting the Gzip parameter to false while initializing the SDK, as shown:

analytics = RudderAnalyticsSync::Client.new(
  write_key: 'WRITE_KEY', # required
  data_plane_url: 'DATA_PLANE_URL',
  stub: false,
  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.

Sending events

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

From version 2.0.0, the Ruby SDK supports screen events.

Manually batching events

You can manually batch your events using analytics.batch, as shown:

analytics.batch do |batch|
  batch.context = {...}       # Shared context for all the events
  batch.integrations = {...}  # Shared integrations hash for all the events
  batch.identify(...)
  batch.track(...)
  batch.track(...)
  ...
end

License

The RudderStack Ruby SDK is released under the MIT license.