Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 35 additions & 43 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).
2 changes: 1 addition & 1 deletion specs
Submodule specs updated 33 files
+2 −0 .gitignore
+78 −0 AGENTS.md
+0 −21 HEARTBEAT.md
+19 −22 README.md
+0 −88 SOUL.md
+2 −14 http/SPEC.md
+5 −50 lakehouse/SPEC.md
+0 −0 product-analytics/CONSTANTS.md
+20 −75 product-analytics/SPEC.md
+0 −0 product-analytics/TEST_PLAN.md
+1 −1 product-analytics/fixtures/README.md
+14 −0 product-analytics/fixtures/alias_basic.json
+3 −9 product-analytics/fixtures/identify_basic.json
+7 −11 product-analytics/fixtures/track_basic.json
+20 −0 product-analytics/fixtures/track_null_properties.json
+0 −186 scripts/bootstrap-sdk-repo.sh
+0 −153 skills/bootstrap-sdk/SKILL.md
+0 −20 skills/build-product-analytics-sdk/fixtures/alias_basic.json
+0 −23 skills/build-product-analytics-sdk/fixtures/track_null_properties.json
+0 −143 skills/build-readme/SKILL.md
+0 −98 skills/maintainer-routine/SKILL.md
+0 −156 skills/release-sdk/SKILL.md
+0 −201 skills/review-pr/SKILL.md
+0 −127 skills/sync-repos/SKILL.md
+0 −1 skills/sync-repos/templates/.github/FUNDING.yml
+0 −47 skills/sync-repos/templates/.github/ISSUE_TEMPLATE/bug_report.yml
+0 −21 skills/sync-repos/templates/.github/ISSUE_TEMPLATE/feature_request.yml
+0 −13 skills/sync-repos/templates/.github/PULL_REQUEST_TEMPLATE.md
+0 −83 skills/sync-repos/templates/CODE_OF_CONDUCT.md
+0 −32 skills/sync-repos/templates/CONTRIBUTING.md
+0 −21 skills/sync-repos/templates/LICENSE
+0 −18 skills/sync-repos/templates/SECURITY.md
+0 −179 skills/triage-issues/SKILL.md
Loading