Skip to content

Commit 6256595

Browse files
redoxalbert20260301Albert
authored
Initial commit (#3)
#1 went fairly poorly with gemini-3-flash ; I took over --------- Co-authored-by: Albert <albert20260301@gmail.com> Co-authored-by: Albert <albert@openclaw.ai>
1 parent 8400707 commit 6256595

17 files changed

Lines changed: 499 additions & 1 deletion

‎.github/workflows/ci.yml‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ jobs:
1919
ports:
2020
- 15001:15001
2121
env:
22-
ALTERTABLE_MOCK_API_KEY: test_pk_abc123
22+
ALTERTABLE_MOCK_API_KEYS: test_pk_abc123
2323
options: >-
2424
--health-cmd "exit 0"
2525
--health-interval 5s

‎.gitmodules‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "specs"]
2+
path = specs
3+
url = https://github.com/altertable-ai/altertable-client-specs.git

‎.rubocop.yml‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require:
2+
- rubocop-performance
3+
- rubocop-rspec
4+
5+
AllCops:
6+
NewCops: enable
7+
Exclude:
8+
- 'vendor/**/*'
9+
- 'spec/spec_helper.rb'
10+
11+
Layout/LineLength:
12+
Max: 120
13+
14+
Style/Documentation:
15+
Enabled: false
16+
17+
Style/FrozenStringLiteralComment:
18+
Enabled: true

‎CHANGELOG.md‎

Whitespace-only changes.

‎Gemfile‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
source "https://rubygems.org"
2+
3+
gemspec
4+
5+
gem "rspec"
6+
gem "testcontainers"
7+
gem "base64"

‎Gemfile.lock‎

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
PATH
2+
remote: .
3+
specs:
4+
altertable-ruby (0.1.0)
5+
6+
GEM
7+
remote: https://rubygems.org/
8+
specs:
9+
addressable (2.8.9)
10+
public_suffix (>= 2.0.2, < 8.0)
11+
ast (2.4.3)
12+
base64 (0.3.0)
13+
bigdecimal (4.0.1)
14+
diff-lcs (1.6.2)
15+
docker-api (2.4.0)
16+
excon (>= 0.64.0)
17+
multi_json
18+
excon (1.4.0)
19+
logger
20+
json (2.19.0)
21+
json-schema (6.2.0)
22+
addressable (~> 2.8)
23+
bigdecimal (>= 3.1, < 5)
24+
language_server-protocol (3.17.0.5)
25+
lint_roller (1.1.0)
26+
logger (1.7.0)
27+
mcp (0.8.0)
28+
json-schema (>= 4.1)
29+
multi_json (1.19.1)
30+
parallel (1.27.0)
31+
parser (3.3.10.2)
32+
ast (~> 2.4.1)
33+
racc
34+
prism (1.9.0)
35+
public_suffix (7.0.5)
36+
racc (1.8.1)
37+
rainbow (3.1.1)
38+
rake (13.3.1)
39+
regexp_parser (2.11.3)
40+
rspec (3.13.2)
41+
rspec-core (~> 3.13.0)
42+
rspec-expectations (~> 3.13.0)
43+
rspec-mocks (~> 3.13.0)
44+
rspec-core (3.13.6)
45+
rspec-support (~> 3.13.0)
46+
rspec-expectations (3.13.5)
47+
diff-lcs (>= 1.2.0, < 2.0)
48+
rspec-support (~> 3.13.0)
49+
rspec-mocks (3.13.8)
50+
diff-lcs (>= 1.2.0, < 2.0)
51+
rspec-support (~> 3.13.0)
52+
rspec-support (3.13.7)
53+
rubocop (1.85.1)
54+
json (~> 2.3)
55+
language_server-protocol (~> 3.17.0.2)
56+
lint_roller (~> 1.1.0)
57+
mcp (~> 0.6)
58+
parallel (~> 1.10)
59+
parser (>= 3.3.0.2)
60+
rainbow (>= 2.2.2, < 4.0)
61+
regexp_parser (>= 2.9.3, < 3.0)
62+
rubocop-ast (>= 1.49.0, < 2.0)
63+
ruby-progressbar (~> 1.7)
64+
unicode-display_width (>= 2.4.0, < 4.0)
65+
rubocop-ast (1.49.0)
66+
parser (>= 3.3.7.2)
67+
prism (~> 1.7)
68+
rubocop-capybara (2.22.1)
69+
lint_roller (~> 1.1)
70+
rubocop (~> 1.72, >= 1.72.1)
71+
rubocop-factory_bot (2.28.0)
72+
lint_roller (~> 1.1)
73+
rubocop (~> 1.72, >= 1.72.1)
74+
rubocop-performance (1.26.1)
75+
lint_roller (~> 1.1)
76+
rubocop (>= 1.75.0, < 2.0)
77+
rubocop-ast (>= 1.47.1, < 2.0)
78+
rubocop-rspec (2.31.0)
79+
rubocop (~> 1.40)
80+
rubocop-capybara (~> 2.17)
81+
rubocop-factory_bot (~> 2.22)
82+
rubocop-rspec_rails (~> 2.28)
83+
rubocop-rspec_rails (2.29.1)
84+
rubocop (~> 1.61)
85+
ruby-progressbar (1.13.0)
86+
testcontainers (0.2.0)
87+
testcontainers-core (= 0.2.0)
88+
testcontainers-core (0.2.0)
89+
docker-api (~> 2.2)
90+
unicode-display_width (3.2.0)
91+
unicode-emoji (~> 4.1)
92+
unicode-emoji (4.2.0)
93+
94+
PLATFORMS
95+
arm64-darwin-25
96+
ruby
97+
98+
DEPENDENCIES
99+
altertable-ruby!
100+
base64
101+
rake (~> 13.0)
102+
rspec
103+
rubocop (~> 1.0)
104+
rubocop-performance (~> 1.0)
105+
rubocop-rspec (~> 2.0)
106+
testcontainers
107+
108+
BUNDLED WITH
109+
2.6.7

‎README.md‎

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Altertable Ruby SDK
2+
3+
Official Ruby SDK for Altertable Product Analytics.
4+
5+
## Installation
6+
7+
Add this line to your application's Gemfile:
8+
9+
```ruby
10+
gem 'altertable-ruby'
11+
```
12+
13+
And then execute:
14+
15+
$ bundle install
16+
17+
## Usage
18+
19+
### Initialization
20+
21+
```ruby
22+
require 'altertable'
23+
24+
Altertable.init('your_api_key', {
25+
environment: 'production'
26+
})
27+
```
28+
29+
### Tracking Events
30+
31+
```ruby
32+
Altertable.track('button_clicked', 'user_123', {
33+
button_id: 'signup_btn',
34+
page: 'home'
35+
})
36+
```
37+
38+
### Identifying Users
39+
40+
```ruby
41+
Altertable.identify('user_123', {
42+
email: 'user@example.com',
43+
name: 'John Doe'
44+
})
45+
```
46+
47+
### Alias
48+
49+
```ruby
50+
Altertable.alias('new_user_id', 'previous_anonymous_id')
51+
```
52+
53+
## License
54+
55+
The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).

‎Rakefile‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# frozen_string_literal: true
2+
3+
require "rspec/core/rake_task"
4+
5+
RSpec::Core::RakeTask.new(:spec)
6+
7+
task default: :spec

‎altertable-ruby.gemspec‎

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# frozen_string_literal: true
2+
3+
Gem::Specification.new do |spec|
4+
spec.name = "altertable-ruby"
5+
spec.version = "0.1.0"
6+
spec.authors = ["Altertable"]
7+
spec.email = ["support@api.altertable.ai"]
8+
9+
spec.summary = "Altertable Product Analytics Ruby SDK"
10+
spec.description = "Official Ruby client for Altertable Product Analytics"
11+
spec.homepage = "https://github.com/altertable-ai/altertable-ruby"
12+
spec.license = "MIT"
13+
spec.required_ruby_version = Gem::Requirement.new(">= 2.6.0")
14+
15+
spec.metadata["homepage_uri"] = spec.homepage
16+
spec.metadata["source_code_uri"] = spec.homepage
17+
spec.metadata["changelog_uri"] = "https://github.com/altertable-ai/altertable-ruby/blob/main/CHANGELOG.md"
18+
19+
spec.files = Dir.chdir(File.expand_path(__dir__)) do
20+
`git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
21+
end
22+
spec.bindir = "exe"
23+
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
24+
spec.require_paths = ["lib"]
25+
26+
spec.add_development_dependency "rake", "~> 13.0"
27+
spec.add_development_dependency "rspec", "~> 3.0"
28+
spec.add_development_dependency "rubocop", "~> 1.0"
29+
spec.add_development_dependency "rubocop-performance", "~> 1.0"
30+
spec.add_development_dependency "rubocop-rspec", "~> 2.0"
31+
spec.add_development_dependency "testcontainers"
32+
end

‎lib/altertable.rb‎

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# frozen_string_literal: true
2+
3+
require_relative "altertable/version"
4+
require_relative "altertable/errors"
5+
require_relative "altertable/client"
6+
7+
module Altertable
8+
class << self
9+
def init(api_key, options = {})
10+
@client = Client.new(api_key, options)
11+
end
12+
13+
def track(event, user_id, properties = {})
14+
client.track(event, user_id, properties)
15+
end
16+
17+
def identify(user_id, traits = {})
18+
client.identify(user_id, traits)
19+
end
20+
21+
def alias(new_user_id, previous_id)
22+
client.alias(new_user_id, previous_id)
23+
end
24+
25+
def client
26+
raise ConfigurationError, "Altertable client not initialized. Call Altertable.init(api_key) first." unless @client
27+
28+
@client
29+
end
30+
end
31+
end

0 commit comments

Comments
 (0)