diff --git a/README.md b/README.md index 62b28a6..01c2348 100644 --- a/README.md +++ b/README.md @@ -1,98 +1,90 @@ # Altertable Ruby SDK -[![Build Status](https://github.com/altertable-ai/altertable-ruby/actions/workflows/ci.yml/badge.svg)](https://github.com/altertable-ai/altertable-ruby/actions) -[![Gem Version](https://badge.fury.io/rb/altertable.svg)](https://rubygems.org/gems/altertable) -[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](https://opensource.org/licenses/MIT) - -Official Ruby SDK for Altertable Product Analytics. +You can use this SDK to send Product Analytics events to Altertable from Ruby applications. ## Install -Install the gem with a single command: - ```bash gem install altertable ``` -## Quick Start - -Initialize the client and track your first event. Call `track()` to record an action a user performed. +## Quick start ```ruby require 'altertable' -# Initialize the Altertable client Altertable.init('pk_live_abc123', environment: 'production') -# Track an event Altertable.track('button_clicked', 'user_123', properties: { button_id: 'signup_btn', page: 'home' }) ``` -## API Reference +## API reference ### Initialization -Initialize the global Altertable client instance. - `Altertable.init(api_key, options = {})` +Initializes the global client instance. + ```ruby -Altertable.init('pk_live_abc123', environment: 'production', debug: true) +Altertable.init('pk_live_abc123', debug: true) ``` -### Tracking Events - -Record an action performed by a user. +### Tracking `Altertable.track(event, distinct_id, **options)` +Sends an event for a user. + ```ruby -Altertable.track('item_purchased', 'user_123', properties: { - item_id: 'item_999', - price: 19.99 -}) +Altertable.track('purchase', 'user_123', properties: { amount: 19.99 }) ``` -### Identifying Users - -Link a user ID to their traits (like email or name). +### Identity `Altertable.identify(user_id, **options)` +Associates traits with a user. + ```ruby -Altertable.identify('user_123', traits: { - email: 'user@example.com', - name: 'John Doe' -}) +Altertable.identify('user_123', traits: { email: 'user@example.com' }) ``` ### Alias -Merge a previous anonymous ID with a newly identified user ID. - `Altertable.alias(distinct_id, new_user_id, **options)` +Merges an anonymous identifier into a known user identifier. + ```ruby -Altertable.alias('anon_session_456', 'user_123') +Altertable.alias('anon_456', 'user_123') ``` ## Configuration -You can configure the client by passing options during initialization. - | Option | Type | Default | Description | |---|---|---|---| -| `environment` | String | `"production"` | Environment name (e.g., `production`, `development`). | -| `base_url` | String | `"https://api.altertable.ai"` | Base URL for API requests. | -| `request_timeout` | Integer | `5` | Request timeout in seconds. | -| `release` | String | `nil` | Application release version (e.g., commit hash). | -| `debug` | Boolean | `false` | Enable debug logging. | -| `on_error` | Proc | `nil` | Callback for handling errors. | -| `adapter` | Symbol | auto-detect | HTTP adapter to use (`:faraday`, `:httpx`, `:net_http`). | +| `environment` | `String` | `"production"` | Environment name (for example `production` or `development`). | +| `base_url` | `String` | `"https://api.altertable.ai"` | API base URL. | +| `request_timeout` | `Integer` | `5` | Request timeout in seconds. | +| `release` | `String \| nil` | `nil` | Application release version. | +| `debug` | `Boolean` | `false` | Enables debug logging. | +| `on_error` | `Proc \| nil` | `nil` | Error callback hook. | +| `adapter` | `Symbol` | auto-detect | HTTP adapter (`:faraday`, `:httpx`, `:net_http`). | + +## Development + +Prerequisites: Ruby 3.1+ and Bundler. + +```bash +bundle install +bundle exec rake spec +bundle exec rubocop +``` ## License -The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT). +See [LICENSE](LICENSE). \ No newline at end of file diff --git a/specs b/specs index ef983f0..3a1195e 160000 --- a/specs +++ b/specs @@ -1 +1 @@ -Subproject commit ef983f0c2e8ff3859e0a11f360ba0721d89b5e6d +Subproject commit 3a1195e48e40c4f629f11e7181ae098b5d330ecd