Skip to content

Repository files navigation

Altertable Ruby SDK

Build StatusGem VersionLicense: MIT

Official Ruby SDK for Altertable Product Analytics.

Install

Install the gem with a single command:

gem install altertable

Quick Start

Initialize the client and track your first event. Call track() to record an action a user performed.

require'altertable'# Initialize the Altertable clientAltertable.init('pk_live_abc123',environment: 'production')# Track an eventAltertable.track('button_clicked','user_123',properties: {button_id: 'signup_btn',page: 'home'})

API Reference

Initialization

Initialize the global Altertable client instance.

Altertable.init(api_key, options = {})

Altertable.init('pk_live_abc123',environment: 'production',debug: true)

Tracking Events

Record an action performed by a user.

Altertable.track(event, distinct_id, **options)

Altertable.track('item_purchased','user_123',properties: {item_id: 'item_999',price: 19.99})

Identifying Users

Link a user ID to their traits (like email or name).

Altertable.identify(user_id, **options)

Altertable.identify('user_123',traits: {email: 'user@example.com',name: 'John Doe'})

Alias

Merge a previous anonymous ID with a newly identified user ID.

Altertable.alias(distinct_id, new_user_id, **options)

Altertable.alias('anon_session_456','user_123')

Configuration

You can configure the client by passing options during initialization.

OptionTypeDefaultDescription
environmentString"production"Environment name (e.g., production, development).
base_urlString"https://api.altertable.ai"Base URL for API requests.
request_timeoutInteger5Request timeout in seconds.
releaseStringnilApplication release version (e.g., commit hash).
debugBooleanfalseEnable debug logging.
on_errorProcnilCallback for handling errors.
adapterSymbolauto-detectHTTP adapter to use (:faraday, :httpx, :net_http).

License

The gem is available as open source under the terms of the MIT License.

About

Altertable's Product Analytics Ruby API Client

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

2 watching

Forks

Releases

Packages

Contributors

Languages