altertable 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e0d8bbcf3d0a16093a6dd081bebe5d26d36abd91abeee71d8f11bac2ccfbac2c
4
- data.tar.gz: 23ed4a849df8c765bc6bf383bf0b58b368d6b6c63be1105b27acc2589a2ad7c7
3
+ metadata.gz: 574aa97c12dd4aa1269c82025cb2d754e6efacd84b5ab731677be50489e53798
4
+ data.tar.gz: 90686c8a67e974d038bf4cf72749c02ef981e159096ab033b6273e50b3ad3f87
5
5
  SHA512:
6
- metadata.gz: 40b209ff5eb900a7ffbad8a0bac3abb67b11a0e5191eb4fdcd8c2d4db1acb3e5135bef6345c54c3846cb2452dada718796059e9462787086d14c9659e37ad532
7
- data.tar.gz: 073c87ac9409ed80d4c03d7762493dc5e9126811736385b313db3fa590dd55d6144fdea582ca85a1c1837bfa60b7a83374d174f051199ca82f6334c3bc317497
6
+ metadata.gz: 84bfd405b72decd8ab65dced443a74ea5d6bf7b53a16cd206b965e2735085fb3e36e52a71e0a100aa10a6e60801d3e28a1e89a65cdec00e078f97bd35842f071
7
+ data.tar.gz: ac1939bddc0385a4df1727b98e1eb33d7c85cef7d76d9fb9c151afd22bb8b132522656d6ff75d50126bbb0575c279b0ea722f29c79ff6ed6280db161b5b998ea
@@ -40,3 +40,18 @@ jobs:
40
40
 
41
41
  - name: Run tests
42
42
  run: bundle exec rake spec
43
+
44
+ typing:
45
+ name: "Typing & lint"
46
+ runs-on: ubuntu-latest
47
+ steps:
48
+ - uses: actions/checkout@v4
49
+ - name: Set up Ruby
50
+ uses: ruby/setup-ruby@v1
51
+ with:
52
+ ruby-version: "3.4"
53
+ bundler-cache: true
54
+ - name: Validate RBS
55
+ run: bundle exec rbs validate
56
+ - name: Typecheck with Sorbet
57
+ run: bundle exec srb tc
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "0.4.0"
2
+ ".": "1.0.0"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,16 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.0.0](https://github.com/altertable-ai/altertable-ruby/compare/altertable/v0.4.0...altertable/v1.0.0) (2026-03-09)
4
+
5
+
6
+ ### ⚠ BREAKING CHANGES
7
+
8
+ * update method signatures to v0.9.0 specs ([#23](https://github.com/altertable-ai/altertable-ruby/issues/23))
9
+
10
+ ### Features
11
+
12
+ * update method signatures to v0.9.0 specs ([#23](https://github.com/altertable-ai/altertable-ruby/issues/23)) ([1c26f52](https://github.com/altertable-ai/altertable-ruby/commit/1c26f5229aa4bd3811ac83351df06d3275496d2f))
13
+
3
14
  ## [0.4.0](https://github.com/altertable-ai/altertable-ruby/compare/altertable/v0.3.0...altertable/v0.4.0) (2026-03-09)
4
15
 
5
16
 
data/Gemfile CHANGED
@@ -5,3 +5,5 @@ gemspec
5
5
  gem "rspec"
6
6
  gem "testcontainers"
7
7
  gem "base64"
8
+
9
+ gem 'tapioca', require: false, group: [:development, :test]
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- altertable (0.4.0)
4
+ altertable (1.0.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
@@ -10,11 +10,13 @@ GEM
10
10
  public_suffix (>= 2.0.2, < 8.0)
11
11
  ast (2.4.3)
12
12
  base64 (0.3.0)
13
+ benchmark (0.5.0)
13
14
  bigdecimal (4.0.1)
14
15
  diff-lcs (1.6.2)
15
16
  docker-api (2.4.0)
16
17
  excon (>= 0.64.0)
17
18
  multi_json
19
+ erubi (1.13.1)
18
20
  excon (1.4.0)
19
21
  logger
20
22
  faraday (2.14.1)
@@ -40,6 +42,7 @@ GEM
40
42
  multi_json (1.19.1)
41
43
  net-http (0.9.1)
42
44
  uri (>= 0.11.1)
45
+ netrc (0.11.0)
43
46
  parallel (1.27.0)
44
47
  parser (3.3.10.2)
45
48
  ast (~> 2.4.1)
@@ -49,7 +52,14 @@ GEM
49
52
  racc (1.8.1)
50
53
  rainbow (3.1.1)
51
54
  rake (13.3.1)
55
+ rbi (0.3.9)
56
+ prism (~> 1.0)
57
+ rbs (>= 3.4.4)
58
+ rbs (3.10.3)
59
+ logger
60
+ tsort
52
61
  regexp_parser (2.11.3)
62
+ rexml (3.4.4)
53
63
  rspec (3.13.2)
54
64
  rspec-core (~> 3.13.0)
55
65
  rspec-expectations (~> 3.13.0)
@@ -96,18 +106,48 @@ GEM
96
106
  rubocop-rspec_rails (2.29.1)
97
107
  rubocop (~> 1.61)
98
108
  ruby-progressbar (1.13.0)
109
+ sorbet (0.6.12997)
110
+ sorbet-static (= 0.6.12997)
111
+ sorbet-runtime (0.6.12997)
112
+ sorbet-static (0.6.12997-universal-darwin)
113
+ sorbet-static (0.6.12997-x86_64-linux)
114
+ sorbet-static-and-runtime (0.6.12997)
115
+ sorbet (= 0.6.12997)
116
+ sorbet-runtime (= 0.6.12997)
117
+ spoom (1.6.3)
118
+ erubi (>= 1.10.0)
119
+ prism (>= 0.28.0)
120
+ rbi (>= 0.3.3)
121
+ rexml (>= 3.2.6)
122
+ sorbet-static-and-runtime (>= 0.5.10187)
123
+ thor (>= 0.19.2)
124
+ tapioca (0.16.11)
125
+ benchmark
126
+ bundler (>= 2.2.25)
127
+ netrc (>= 0.11.0)
128
+ parallel (>= 1.21.0)
129
+ rbi (~> 0.2)
130
+ sorbet-static-and-runtime (>= 0.5.11087)
131
+ spoom (>= 1.2.0)
132
+ thor (>= 1.2.0)
133
+ yard-sorbet
99
134
  testcontainers (0.2.0)
100
135
  testcontainers-core (= 0.2.0)
101
136
  testcontainers-core (0.2.0)
102
137
  docker-api (~> 2.2)
138
+ thor (1.5.0)
139
+ tsort (0.2.0)
103
140
  unicode-display_width (3.2.0)
104
141
  unicode-emoji (~> 4.1)
105
142
  unicode-emoji (4.2.0)
106
143
  uri (1.1.1)
144
+ yard (0.9.38)
145
+ yard-sorbet (0.9.0)
146
+ sorbet-runtime
147
+ yard
107
148
 
108
149
  PLATFORMS
109
150
  arm64-darwin-25
110
- ruby
111
151
  x86_64-linux
112
152
 
113
153
  DEPENDENCIES
@@ -118,10 +158,14 @@ DEPENDENCIES
118
158
  faraday-retry
119
159
  httpx
120
160
  rake (~> 13.0)
161
+ rbs
121
162
  rspec (~> 3.0, >= 0)
122
163
  rubocop (~> 1.0)
123
164
  rubocop-performance (~> 1.0)
124
165
  rubocop-rspec (~> 2.0)
166
+ sorbet
167
+ sorbet-runtime
168
+ tapioca
125
169
  testcontainers
126
170
 
127
171
  BUNDLED WITH
data/README.md CHANGED
@@ -29,25 +29,25 @@ Altertable.init('your_api_key', {
29
29
  ### Tracking Events
30
30
 
31
31
  ```ruby
32
- Altertable.track('button_clicked', 'user_123', {
32
+ Altertable.track('button_clicked', 'user_123', properties: {
33
33
  button_id: 'signup_btn',
34
34
  page: 'home'
35
- })
35
+ }, timestamp: Time.now.utc.iso8601)
36
36
  ```
37
37
 
38
38
  ### Identifying Users
39
39
 
40
40
  ```ruby
41
- Altertable.identify('user_123', {
41
+ Altertable.identify('user_123', traits: {
42
42
  email: 'user@example.com',
43
43
  name: 'John Doe'
44
- })
44
+ }, anonymous_id: 'previous_anon_id')
45
45
  ```
46
46
 
47
47
  ### Alias
48
48
 
49
49
  ```ruby
50
- Altertable.alias('new_user_id', 'previous_anonymous_id')
50
+ Altertable.alias('previous_anonymous_id', 'new_user_id')
51
51
  ```
52
52
 
53
53
  ## License
data/altertable.gemspec CHANGED
@@ -19,7 +19,7 @@ Gem::Specification.new do |spec|
19
19
  spec.metadata["changelog_uri"] = "https://github.com/altertable-ai/altertable-ruby/blob/main/CHANGELOG.md"
20
20
 
21
21
  spec.files = Dir.chdir(File.expand_path(__dir__)) do
22
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
22
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features|sorbet)/}) }
23
23
  end
24
24
  spec.bindir = "exe"
25
25
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
@@ -31,6 +31,9 @@ Gem::Specification.new do |spec|
31
31
  spec.add_development_dependency "rubocop-performance", "~> 1.0"
32
32
  spec.add_development_dependency "rubocop-rspec", "~> 2.0"
33
33
  spec.add_development_dependency "testcontainers"
34
+ spec.add_development_dependency "rbs"
35
+ spec.add_development_dependency "sorbet"
36
+ spec.add_development_dependency "sorbet-runtime"
34
37
 
35
38
  # Optional adapter support (development only)
36
39
  spec.add_development_dependency "faraday", "~> 2.0"
@@ -31,9 +31,11 @@ module Altertable
31
31
  @adapter = select_adapter(adapter_name, { base_url: @base_url, timeout: @timeout, headers: headers })
32
32
  end
33
33
 
34
- def track(event, distinct_id, properties = {})
34
+ def track(event, distinct_id, **options)
35
+ properties = options[:properties] || {}
36
+ timestamp = options[:timestamp] || Time.now.utc.iso8601(3)
35
37
  payload = {
36
- timestamp: Time.now.utc.iso8601(3),
38
+ timestamp: timestamp,
37
39
  event: event,
38
40
  environment: @environment,
39
41
  distinct_id: distinct_id,
@@ -43,26 +45,33 @@ module Altertable
43
45
  }.merge(properties)
44
46
  }
45
47
  payload[:properties]["$release"] = @release if @release
48
+ payload[:anonymous_id] = options[:anonymous_id] if options.key?(:anonymous_id)
49
+ payload[:device_id] = options[:device_id] if options.key?(:device_id)
46
50
 
47
51
  post("/track", payload)
48
52
  end
49
53
 
50
- def identify(user_id, traits = {})
54
+ def identify(user_id, **options)
55
+ traits = options[:traits] || {}
56
+ timestamp = options[:timestamp] || Time.now.utc.iso8601(3)
51
57
  payload = {
52
- timestamp: Time.now.utc.iso8601(3),
58
+ timestamp: timestamp,
53
59
  environment: @environment,
54
60
  distinct_id: user_id,
55
61
  traits: traits
56
62
  }
63
+ payload[:anonymous_id] = options[:anonymous_id] if options.key?(:anonymous_id)
64
+ payload[:device_id] = options[:device_id] if options.key?(:device_id)
57
65
 
58
66
  post("/identify", payload)
59
67
  end
60
68
 
61
- def alias(new_user_id, previous_id)
69
+ def alias(distinct_id, new_user_id, **options)
70
+ timestamp = options[:timestamp] || Time.now.utc.iso8601(3)
62
71
  payload = {
63
- timestamp: Time.now.utc.iso8601(3),
72
+ timestamp: timestamp,
64
73
  environment: @environment,
65
- distinct_id: previous_id,
74
+ distinct_id: distinct_id,
66
75
  new_user_id: new_user_id
67
76
  }
68
77
 
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Altertable
4
- VERSION = "0.4.0"
4
+ VERSION = "1.0.0"
5
5
  end
data/lib/altertable.rb CHANGED
@@ -10,16 +10,16 @@ module Altertable
10
10
  @client = Client.new(api_key, options)
11
11
  end
12
12
 
13
- def track(event, user_id, properties = {})
14
- client.track(event, user_id, properties)
13
+ def track(event, distinct_id, **options)
14
+ client.track(event, distinct_id, **options)
15
15
  end
16
16
 
17
- def identify(user_id, traits = {})
18
- client.identify(user_id, traits)
17
+ def identify(user_id, **options)
18
+ client.identify(user_id, **options)
19
19
  end
20
20
 
21
- def alias(new_user_id, previous_id)
22
- client.alias(new_user_id, previous_id)
21
+ def alias(distinct_id, new_user_id, **options)
22
+ client.alias(distinct_id, new_user_id, **options)
23
23
  end
24
24
 
25
25
  def client
data/mise.toml ADDED
@@ -0,0 +1,2 @@
1
+ [tools]
2
+ ruby = "3.4"
data/rbi/altertable.rbi CHANGED
@@ -34,14 +34,14 @@ module Altertable
34
34
  sig { params(api_key: String, options: T::Hash[Symbol, T.untyped]).void }
35
35
  def initialize(api_key, options = {}); end
36
36
 
37
- sig { params(event: String, distinct_id: String, properties: T::Hash[T.any(Symbol, String), T.untyped]).returns(T.untyped) }
38
- def track(event, distinct_id, properties = {}); end
37
+ sig { params(event: String, distinct_id: String, options: T.untyped).returns(T.untyped) }
38
+ def track(event, distinct_id, **options); end
39
39
 
40
- sig { params(user_id: String, traits: T::Hash[T.any(Symbol, String), T.untyped]).returns(T.untyped) }
41
- def identify(user_id, traits = {}); end
40
+ sig { params(user_id: String, options: T.untyped).returns(T.untyped) }
41
+ def identify(user_id, **options); end
42
42
 
43
- sig { params(new_user_id: String, previous_id: String).returns(T.untyped) }
44
- def alias(new_user_id, previous_id); end
43
+ sig { params(distinct_id: String, new_user_id: String, options: T.untyped).returns(T.untyped) }
44
+ def alias(distinct_id, new_user_id, **options); end
45
45
 
46
46
  private
47
47
 
@@ -77,16 +77,16 @@ module Altertable
77
77
  sig { params(base_url: String, timeout: T.any(Integer, Float), headers: T.nilable(T::Hash[String, String])).void }
78
78
  def initialize(base_url:, timeout:, headers: nil); end
79
79
 
80
- sig { params(path: String, body: T.nilable(String), params: T.nilable(T::Hash[T.any(Symbol, String), T.untyped])).returns(Response) }
81
- def post(path, body: nil, params: nil); end
80
+ sig { params(path: String, body: T.nilable(String), params: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]), block: T.nilable(T.proc.params(arg0: T.untyped).void)).returns(Response) }
81
+ def post(path, body: nil, params: nil, &block); end
82
82
  end
83
83
 
84
84
  class FaradayAdapter < Base
85
85
  sig { params(base_url: String, timeout: T.any(Integer, Float), headers: T.nilable(T::Hash[String, String])).void }
86
86
  def initialize(base_url:, timeout:, headers: nil); end
87
87
 
88
- sig { params(path: String, body: T.nilable(String), params: T.nilable(T::Hash[T.any(Symbol, String), T.untyped])).returns(Response) }
89
- def post(path, body: nil, params: nil); end
88
+ sig { params(path: String, body: T.nilable(String), params: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]), block: T.nilable(T.proc.params(arg0: T.untyped).void)).returns(Response) }
89
+ def post(path, body: nil, params: nil, &block); end
90
90
 
91
91
  private
92
92
 
@@ -98,8 +98,8 @@ module Altertable
98
98
  sig { params(base_url: String, timeout: T.any(Integer, Float), headers: T.nilable(T::Hash[String, String])).void }
99
99
  def initialize(base_url:, timeout:, headers: nil); end
100
100
 
101
- sig { params(path: String, body: T.nilable(String), params: T.nilable(T::Hash[T.any(Symbol, String), T.untyped])).returns(Response) }
102
- def post(path, body: nil, params: nil); end
101
+ sig { params(path: String, body: T.nilable(String), params: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]), block: T.nilable(T.proc.params(arg0: T.untyped).void)).returns(Response) }
102
+ def post(path, body: nil, params: nil, &block); end
103
103
 
104
104
  private
105
105
 
@@ -111,22 +111,22 @@ module Altertable
111
111
  sig { params(base_url: String, timeout: T.any(Integer, Float), headers: T.nilable(T::Hash[String, String])).void }
112
112
  def initialize(base_url:, timeout:, headers: nil); end
113
113
 
114
- sig { params(path: String, body: T.nilable(String), params: T.nilable(T::Hash[T.any(Symbol, String), T.untyped])).returns(Response) }
115
- def post(path, body: nil, params: nil); end
114
+ sig { params(path: String, body: T.nilable(String), params: T.nilable(T::Hash[T.any(Symbol, String), T.untyped]), block: T.nilable(T.proc.params(arg0: T.untyped).void)).returns(Response) }
115
+ def post(path, body: nil, params: nil, &block); end
116
116
  end
117
117
  end
118
118
 
119
119
  sig { params(api_key: String, options: T::Hash[Symbol, T.untyped]).returns(Client) }
120
120
  def self.init(api_key, options = {}); end
121
121
 
122
- sig { params(event: String, user_id: String, properties: T::Hash[T.any(Symbol, String), T.untyped]).returns(T.untyped) }
123
- def self.track(event, user_id, properties = {}); end
122
+ sig { params(event: String, distinct_id: String, options: T.untyped).returns(T.untyped) }
123
+ def self.track(event, distinct_id, **options); end
124
124
 
125
- sig { params(user_id: String, traits: T::Hash[T.any(Symbol, String), T.untyped]).returns(T.untyped) }
126
- def self.identify(user_id, traits = {}); end
125
+ sig { params(user_id: String, options: T.untyped).returns(T.untyped) }
126
+ def self.identify(user_id, **options); end
127
127
 
128
- sig { params(new_user_id: String, previous_id: String).returns(T.untyped) }
129
- def self.alias(new_user_id, previous_id); end
128
+ sig { params(distinct_id: String, new_user_id: String, options: T.untyped).returns(T.untyped) }
129
+ def self.alias(distinct_id, new_user_id, **options); end
130
130
 
131
131
  sig { returns(Client) }
132
132
  def self.client; end
data/rbi/todo.rbi ADDED
@@ -0,0 +1,6 @@
1
+ module Faraday; end
2
+ class Faraday::ConnectionFailed < StandardError; end
3
+ class Faraday::TimeoutError < StandardError; end
4
+ module HTTPX; end
5
+ class HTTPX::Error < StandardError; end
6
+ class HTTPX::ErrorResponse; end
@@ -15,11 +15,11 @@ module Altertable
15
15
 
16
16
  def initialize: (String api_key, ?::Hash[Symbol, untyped] options) -> void
17
17
 
18
- def track: (String event, String distinct_id, ?::Hash[Symbol | String, untyped] properties) -> untyped
18
+ def track: (String event, String distinct_id, **untyped options) -> untyped
19
19
 
20
- def identify: (String user_id, ?::Hash[Symbol | String, untyped] traits) -> untyped
20
+ def identify: (String user_id, **untyped options) -> untyped
21
21
 
22
- def alias: (String new_user_id, String previous_id) -> untyped
22
+ def alias: (String distinct_id, String new_user_id, **untyped options) -> untyped
23
23
 
24
24
  private
25
25
 
data/sig/altertable.rbs CHANGED
@@ -3,11 +3,11 @@ module Altertable
3
3
 
4
4
  def self.init: (String api_key, ?::Hash[Symbol, untyped] options) -> Client
5
5
 
6
- def self.track: (String event, String user_id, ?::Hash[Symbol | String, untyped] properties) -> untyped
6
+ def self.track: (String event, String distinct_id, **untyped options) -> untyped
7
7
 
8
- def self.identify: (String user_id, ?::Hash[Symbol | String, untyped] traits) -> untyped
8
+ def self.identify: (String user_id, **untyped options) -> untyped
9
9
 
10
- def self.alias: (String new_user_id, String previous_id) -> untyped
10
+ def self.alias: (String distinct_id, String new_user_id, **untyped options) -> untyped
11
11
 
12
12
  def self.client: () -> Client
13
13
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: altertable
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Altertable
@@ -93,6 +93,48 @@ dependencies:
93
93
  - - ">="
94
94
  - !ruby/object:Gem::Version
95
95
  version: '0'
96
+ - !ruby/object:Gem::Dependency
97
+ name: rbs
98
+ requirement: !ruby/object:Gem::Requirement
99
+ requirements:
100
+ - - ">="
101
+ - !ruby/object:Gem::Version
102
+ version: '0'
103
+ type: :development
104
+ prerelease: false
105
+ version_requirements: !ruby/object:Gem::Requirement
106
+ requirements:
107
+ - - ">="
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: sorbet
112
+ requirement: !ruby/object:Gem::Requirement
113
+ requirements:
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ version: '0'
117
+ type: :development
118
+ prerelease: false
119
+ version_requirements: !ruby/object:Gem::Requirement
120
+ requirements:
121
+ - - ">="
122
+ - !ruby/object:Gem::Version
123
+ version: '0'
124
+ - !ruby/object:Gem::Dependency
125
+ name: sorbet-runtime
126
+ requirement: !ruby/object:Gem::Requirement
127
+ requirements:
128
+ - - ">="
129
+ - !ruby/object:Gem::Version
130
+ version: '0'
131
+ type: :development
132
+ prerelease: false
133
+ version_requirements: !ruby/object:Gem::Requirement
134
+ requirements:
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: '0'
96
138
  - !ruby/object:Gem::Dependency
97
139
  name: faraday
98
140
  requirement: !ruby/object:Gem::Requirement
@@ -178,7 +220,9 @@ files:
178
220
  - lib/altertable/client.rb
179
221
  - lib/altertable/errors.rb
180
222
  - lib/altertable/version.rb
223
+ - mise.toml
181
224
  - rbi/altertable.rbi
225
+ - rbi/todo.rbi
182
226
  - release-please-config.json
183
227
  - sig/altertable.rbs
184
228
  - sig/altertable/adapters.rbs