altertable 1.2.0 → 1.4.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: 7472be3a607d8398965c62ed90f5531fe33b21d77fa4827bd73259d7a714eba5
4
- data.tar.gz: 536319ad37e423c82ab298d5804aaf22de1563ece73226abaa42b5fd6bd93c39
3
+ metadata.gz: f0c02045e8016662d903687752f44da29671aca4d2d0eddaef0760d01592a680
4
+ data.tar.gz: 7c773edb0b142b0cfffdef1559c15da1984447f787c8dddec75eabf5499dae5c
5
5
  SHA512:
6
- metadata.gz: 231d0b578dd8fe4ed8856d07fe233b4e256ce3650ce9a11260a21c01d352fcb9bc291477ab526c2d8984078caa4b879f92da667483af5e475d6ea08089999283
7
- data.tar.gz: 7ba2dd340e96f6d906c44456032b6a959e0cfa3f106bf5bf42d2982ac710da4856e4fb1e6d028a030afab62a3ed702e5a27e9fbd920725ff3b4926da40e64e35
6
+ metadata.gz: eca34e9a16479ec5775c9fb3ff63cc53d351143661a078350248cb00a226817572983d35f5acc8f896f2591d2215cabae5870a77b0250363c21abcb0ba52a383
7
+ data.tar.gz: abc75821bf9ed8cdca3b813b46c4791318f4122bd85b572151984b8a98d26abb3e9c04a75b2c092063169872abb606f63e30d30c3f12e6a2f2c9eb1baf29f10e
@@ -0,0 +1 @@
1
+ github: [altertable-ai]
@@ -0,0 +1,13 @@
1
+ ## What
2
+
3
+ <!-- What does this PR do? One sentence is fine. -->
4
+
5
+ ## Why
6
+
7
+ <!-- Link an issue or explain the motivation. -->
8
+
9
+ ## Checklist
10
+
11
+ - [ ] Tests added or updated
12
+ - [ ] `CHANGELOG.md` updated (skip for docs/CI-only changes)
13
+ - [ ] Breaking change noted in commit footer (`BREAKING CHANGE: …`) and changelog
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "1.2.0"
2
+ ".": "1.4.0"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,36 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.4.0](https://github.com/altertable-ai/altertable-ruby/compare/altertable/v1.3.0...altertable/v1.4.0) (2026-11-09)
4
+
5
+
6
+ ### Features
7
+
8
+ * add audience collection mode ([#55](https://github.com/altertable-ai/altertable-ruby/issues/55)) ([7ecb88c](https://github.com/altertable-ai/altertable-ruby/commit/7ecb88cd5d8951c35b811dcde3577d7233112856))
9
+ * deprecate analytics environment routing ([#56](https://github.com/altertable-ai/altertable-ruby/issues/56)) ([020e3bf](https://github.com/altertable-ai/altertable-ruby/commit/020e3bf406bdacd805dd33d8b5879f34120f6f5d))
10
+
11
+
12
+ ### Bug Fixes
13
+
14
+ * **httpx:** resolve request paths against the base URL ([#57](https://github.com/altertable-ai/altertable-ruby/issues/57)) ([f3473fb](https://github.com/altertable-ai/altertable-ruby/commit/f3473fbd4710ce79eb0092bfefbd2f48da488014))
15
+
16
+ ## [Unreleased]
17
+
18
+ ### Features
19
+
20
+ * Add `mode: :audience` to collect events without identity fields. Product mode remains the default.
21
+
22
+ ### Changed
23
+
24
+ * Deprecate the `environment` option: it is ignored and no longer sent. Use an environment-bound Product Analytics API key.
25
+
26
+
27
+ ## [1.3.0](https://github.com/altertable-ai/altertable-ruby/compare/altertable/v1.2.0...altertable/v1.3.0) (2026-09-04)
28
+
29
+
30
+ ### Features
31
+
32
+ * **client:** add batch track, identify, and alias ([#53](https://github.com/altertable-ai/altertable-ruby/issues/53)) ([2aff25b](https://github.com/altertable-ai/altertable-ruby/commit/2aff25b8b6f8767da113fce38901160dffbd9733))
33
+
3
34
  ## [1.2.0](https://github.com/altertable-ai/altertable-ruby/compare/altertable/v1.1.2...altertable/v1.2.0) (2026-08-27)
4
35
 
5
36
 
data/CODE_OF_CONDUCT.md CHANGED
@@ -70,14 +70,14 @@ Community leaders will follow these Community Impact Guidelines in determining t
70
70
 
71
71
  ## Attribution
72
72
 
73
- This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct.html][v2.1].
73
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 2.1, available at [https://www.contributor-covenant.org/version/2/1/code_of_conduct/][v2.1].
74
74
 
75
75
  Community Impact Guidelines were inspired by [Mozilla's code of conduct enforcement ladder][Mozilla CoC].
76
76
 
77
- For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations][translations].
77
+ For answers to common questions about this code of conduct, see the FAQ at [https://www.contributor-covenant.org/faq/][FAQ]. Translations are available at [https://www.contributor-covenant.org/translations/][translations].
78
78
 
79
79
  [homepage]: https://www.contributor-covenant.org
80
- [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct.html
81
- [Mozilla CoC]: https://github.com/mozilla/diversity
82
- [FAQ]: https://www.contributor-covenant.org/faq
83
- [translations]: https://www.contributor-covenant.org/translations
80
+ [v2.1]: https://www.contributor-covenant.org/version/2/1/code_of_conduct/
81
+ [Mozilla CoC]: https://github.com/mozilla/inclusion
82
+ [FAQ]: https://www.contributor-covenant.org/faq/
83
+ [translations]: https://www.contributor-covenant.org/translations/
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- altertable (1.2.0)
4
+ altertable (1.4.0)
5
5
 
6
6
  GEM
7
7
  remote: https://rubygems.org/
data/README.md CHANGED
@@ -22,7 +22,7 @@ Initialize the client and track your first event. Call `track()` to record an ac
22
22
  require 'altertable'
23
23
 
24
24
  # Initialize the Altertable client
25
- Altertable.init('pk_live_abc123', environment: 'production')
25
+ Altertable.init('pk_live_abc123')
26
26
 
27
27
  # Track an event
28
28
  Altertable.track('button_clicked', 'user_123', properties: {
@@ -40,52 +40,95 @@ Initialize the global Altertable client instance.
40
40
  `Altertable.init(api_key, options = {})`
41
41
 
42
42
  ```ruby
43
- Altertable.init('pk_live_abc123', environment: 'production', debug: true)
43
+ Altertable.init('pk_live_abc123', debug: true)
44
44
  ```
45
45
 
46
46
  ### Tracking Events
47
47
 
48
48
  Record an action performed by a user.
49
49
 
50
- `Altertable.track(event, distinct_id, **options)`
50
+ `Altertable.track(event, distinct_id = nil, **options)`
51
+ `Altertable.track(event_payload, **options)`
52
+ `Altertable.track(event_payloads, **options)`
51
53
 
52
54
  ```ruby
53
55
  Altertable.track('item_purchased', 'user_123', properties: {
54
56
  item_id: 'item_999',
55
57
  price: 19.99
56
58
  })
59
+
60
+ Altertable.track({
61
+ event: 'item_purchased',
62
+ distinct_id: 'user_123',
63
+ properties: { item_id: 'item_999', price: 19.99 }
64
+ })
65
+
66
+ Altertable.track([
67
+ { event: 'signup', distinct_id: 'user_1', properties: { plan: 'pro' } },
68
+ { event: 'login', distinct_id: 'user_2', timestamp: '2025-06-15T14:30:00.000Z' }
69
+ ])
70
+ ```
71
+
72
+ ### Audience Measurement
73
+
74
+ Initialize with `mode: :audience` to collect events without identity fields:
75
+
76
+ ```ruby
77
+ Altertable.init('pk_live_abc123', mode: :audience)
78
+ Altertable.track('Docs Opened', properties: { section: 'installation' })
57
79
  ```
58
80
 
81
+ Audience events send only `event`, `timestamp`, and `properties`; distinct, anonymous,
82
+ device, and session fields are dropped. `identify` and `alias` are ignored.
83
+ Requests come from your server, so they cannot distinguish browser visitors.
84
+
59
85
  ### Identifying Users
60
86
 
61
87
  Link a user ID to their traits (like email or name).
62
88
 
63
- `Altertable.identify(user_id, **options)`
89
+ `Altertable.identify(user_id, **options)`
90
+ `Altertable.identify(identify_payload, **options)`
91
+ `Altertable.identify(identify_payloads, **options)`
64
92
 
65
93
  ```ruby
66
94
  Altertable.identify('user_123', traits: {
67
95
  email: 'user@example.com',
68
96
  name: 'John Doe'
69
97
  })
98
+
99
+ Altertable.identify([
100
+ { user_id: 'user_1', traits: { email: 'one@example.com' } },
101
+ { user_id: 'user_2', traits: { email: 'two@example.com' } }
102
+ ])
70
103
  ```
71
104
 
72
105
  ### Alias
73
106
 
74
107
  Merge a previous anonymous ID with a newly identified user ID.
75
108
 
76
- `Altertable.alias(distinct_id, new_user_id, **options)`
109
+ `Altertable.alias(distinct_id, new_user_id, **options)`
110
+ `Altertable.alias(alias_payload, **options)`
111
+ `Altertable.alias(alias_payloads, **options)`
77
112
 
78
113
  ```ruby
79
114
  Altertable.alias('anon_session_456', 'user_123')
115
+
116
+ Altertable.alias([
117
+ { distinct_id: 'anon_1', new_user_id: 'user_1' },
118
+ { distinct_id: 'anon_2', new_user_id: 'user_2' }
119
+ ])
80
120
  ```
81
121
 
122
+ A Hash payload posts one object; an Array posts a JSON array on the same endpoint. Omitted `timestamp` values default to the current time as ISO 8601.
123
+
82
124
  ## Configuration
83
125
 
84
126
  You can configure the client by passing options during initialization.
85
127
 
86
128
  | Option | Type | Default | Description |
87
129
  |---|---|---|---|
88
- | `environment` | String | `"production"` | Environment name (e.g., `production`, `development`). |
130
+ | `mode` | Symbol, String | `:product` | Collection mode: `:product` or `:audience`. Fixed for the client lifetime. |
131
+ | `environment` | String | — | Deprecated and ignored. It is accepted for compatibility but never sent; use an environment-bound Product Analytics API key. |
89
132
  | `base_url` | String | `"https://api.altertable.ai"` | Base URL for API requests. |
90
133
  | `request_timeout` | Integer | `5` | Request timeout in seconds. |
91
134
  | `release` | String | `nil` | Application release version (e.g., commit hash). |
data/SECURITY.md CHANGED
@@ -8,7 +8,7 @@ Only the latest minor release receives security patches.
8
8
 
9
9
  **Do not open a public issue.**
10
10
 
11
- Email security@altertable.ai with:
11
+ Email <security@altertable.ai> with:
12
12
 
13
13
  1. Description of the vulnerability
14
14
  2. Steps to reproduce
@@ -60,7 +60,7 @@ module Altertable
60
60
  @client = client.with(
61
61
  timeout: { operation_timeout: @timeout },
62
62
  headers: @headers,
63
- base_url: @base_url
63
+ origin: @base_url
64
64
  )
65
65
  end
66
66
 
@@ -9,14 +9,21 @@ module Altertable
9
9
  class Client
10
10
  DEFAULT_BASE_URL = "https://api.altertable.ai"
11
11
  DEFAULT_TIMEOUT = 5
12
+ # @deprecated Environments are selected by the Product Analytics API key.
13
+ # Retained so applications that reference the public constant continue to load.
12
14
  DEFAULT_ENVIRONMENT = "production"
13
15
 
14
16
  def initialize(api_key, options = {})
15
17
  raise ConfigurationError, "API Key is required" if api_key.nil? || api_key.empty?
16
18
 
19
+ @mode = case options.fetch(:mode, :product)
20
+ when :product, "product" then :product
21
+ when :audience, "audience" then :audience
22
+ else
23
+ raise ConfigurationError, 'Invalid tracking mode. Use "product" or "audience".'
24
+ end
17
25
  @api_key = api_key
18
26
  @base_url = options[:base_url] || DEFAULT_BASE_URL
19
- @environment = options[:environment] || DEFAULT_ENVIRONMENT
20
27
  @timeout = options[:request_timeout] || DEFAULT_TIMEOUT
21
28
  @release = options[:release]
22
29
  @debug = options[:debug] || false
@@ -31,55 +38,52 @@ module Altertable
31
38
  @adapter = select_adapter(adapter_name, { base_url: @base_url, timeout: @timeout, headers: headers, proxy: options[:proxy] })
32
39
  end
33
40
 
34
- def track(event, distinct_id, **options)
35
- properties = options[:properties] || {}
36
- timestamp = options[:timestamp] || Time.now.utc.iso8601(3)
37
- payload = {
38
- timestamp: timestamp,
39
- event: event,
40
- environment: @environment,
41
- distinct_id: distinct_id,
42
- properties: {
43
- '$lib': "altertable-ruby",
44
- '$lib_version': Altertable::VERSION
45
- }.merge(properties)
46
- }
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)
50
-
51
- post("/track", payload)
41
+ def track(event, distinct_id = nil, **options)
42
+ case event
43
+ when Array
44
+ payloads = map_batch(event, "events") { |item| track_payload_from_item(merge_payload(item, options)) }
45
+ post("/track", payloads)
46
+ when Hash
47
+ post("/track", track_payload_from_item(merge_payload(event, options)))
48
+ else
49
+ post("/track", track_payload(event, distinct_id, options))
50
+ end
52
51
  end
53
52
 
54
53
  def identify(user_id, **options)
55
- traits = options[:traits] || {}
56
- timestamp = options[:timestamp] || Time.now.utc.iso8601(3)
57
- payload = {
58
- timestamp: timestamp,
59
- environment: @environment,
60
- distinct_id: user_id,
61
- traits: traits
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)
54
+ return if reject_identity_call?
65
55
 
66
- post("/identify", payload)
56
+ case user_id
57
+ when Array
58
+ payloads = map_batch(user_id, "identifies") { |item| identify_payload_from_item(merge_payload(item, options)) }
59
+ post("/identify", payloads)
60
+ when Hash
61
+ post("/identify", identify_payload_from_item(merge_payload(user_id, options)))
62
+ else
63
+ post("/identify", identify_payload(user_id, options))
64
+ end
67
65
  end
68
66
 
69
- def alias(distinct_id, new_user_id, **options)
70
- timestamp = options[:timestamp] || Time.now.utc.iso8601(3)
71
- payload = {
72
- timestamp: timestamp,
73
- environment: @environment,
74
- distinct_id: distinct_id,
75
- new_user_id: new_user_id
76
- }
67
+ def alias(distinct_id, new_user_id = nil, **options)
68
+ return if reject_identity_call?
77
69
 
78
- post("/alias", payload)
70
+ case distinct_id
71
+ when Array
72
+ payloads = map_batch(distinct_id, "aliases") { |item| alias_payload_from_item(merge_payload(item, options)) }
73
+ post("/alias", payloads)
74
+ when Hash
75
+ post("/alias", alias_payload_from_item(merge_payload(distinct_id, options)))
76
+ else
77
+ post("/alias", alias_payload(distinct_id, new_user_id, options))
78
+ end
79
79
  end
80
80
 
81
81
  private
82
82
 
83
+ def reject_identity_call?
84
+ @mode == :audience
85
+ end
86
+
83
87
  def select_adapter(name, options)
84
88
  case name
85
89
  when :faraday
@@ -107,6 +111,112 @@ module Altertable
107
111
  false
108
112
  end
109
113
 
114
+ def map_batch(items, name, &block)
115
+ raise ArgumentError, "#{name} must be a non-empty Array" unless items.is_a?(Array) && !items.empty?
116
+
117
+ items.each_with_index do |item, index|
118
+ raise ArgumentError, "#{name}[#{index}] must be a Hash" unless item.is_a?(Hash)
119
+ end
120
+
121
+ items.map(&block)
122
+ end
123
+
124
+ def merge_payload(item, options)
125
+ return item if options.empty?
126
+
127
+ item.merge(options)
128
+ end
129
+
130
+ def item_value(item, key)
131
+ if item.key?(key)
132
+ item[key]
133
+ elsif item.key?(key.to_s)
134
+ item[key.to_s]
135
+ end
136
+ end
137
+
138
+ def item_options(item, *keys)
139
+ keys.each_with_object({}) do |key, opts|
140
+ opts[key] = item_value(item, key) if item.key?(key) || item.key?(key.to_s)
141
+ end
142
+ end
143
+
144
+ def blank?(value)
145
+ value.nil? || (value.respond_to?(:empty?) && value.empty?)
146
+ end
147
+
148
+ def default_timestamp
149
+ Time.now.utc.iso8601(3)
150
+ end
151
+
152
+ def track_payload_from_item(item)
153
+ event = item_value(item, :event)
154
+ distinct_id = item_value(item, :distinct_id)
155
+ raise ArgumentError, "event is required" if blank?(event)
156
+ raise ArgumentError, "distinct_id is required" if @mode == :product && blank?(distinct_id)
157
+
158
+ track_payload(event, distinct_id, item_options(item, :properties, :anonymous_id, :device_id, :timestamp))
159
+ end
160
+
161
+ def identify_payload_from_item(item)
162
+ user_id = item_value(item, :user_id)
163
+ raise ArgumentError, "user_id is required" if blank?(user_id)
164
+
165
+ identify_payload(user_id, item_options(item, :traits, :anonymous_id, :device_id, :timestamp))
166
+ end
167
+
168
+ def alias_payload_from_item(item)
169
+ distinct_id = item_value(item, :distinct_id)
170
+ new_user_id = item_value(item, :new_user_id)
171
+ raise ArgumentError, "distinct_id is required" if blank?(distinct_id)
172
+ raise ArgumentError, "new_user_id is required" if blank?(new_user_id)
173
+
174
+ alias_payload(distinct_id, new_user_id, item_options(item, :timestamp))
175
+ end
176
+
177
+ def track_payload(event, distinct_id, options)
178
+ properties = options[:properties] || {}
179
+ payload = {
180
+ timestamp: options[:timestamp] || default_timestamp,
181
+ event: event,
182
+ distinct_id: distinct_id,
183
+ properties: {
184
+ '$lib': "altertable-ruby",
185
+ '$lib_version': Altertable::VERSION
186
+ }.merge(properties)
187
+ }
188
+ payload[:properties]["$release"] = @release if @release
189
+ return audience_payload(payload) if @mode == :audience
190
+
191
+ payload[:anonymous_id] = options[:anonymous_id] if options.key?(:anonymous_id)
192
+ payload[:device_id] = options[:device_id] if options.key?(:device_id)
193
+ payload
194
+ end
195
+
196
+ # Select wire fields explicitly so per-event options cannot override client policy.
197
+ def audience_payload(payload)
198
+ { mode: "audience", event: payload[:event], timestamp: payload[:timestamp], properties: payload[:properties] }
199
+ end
200
+
201
+ def identify_payload(user_id, options)
202
+ payload = {
203
+ timestamp: options[:timestamp] || default_timestamp,
204
+ distinct_id: user_id,
205
+ traits: options[:traits] || {}
206
+ }
207
+ payload[:anonymous_id] = options[:anonymous_id] if options.key?(:anonymous_id)
208
+ payload[:device_id] = options[:device_id] if options.key?(:device_id)
209
+ payload
210
+ end
211
+
212
+ def alias_payload(distinct_id, new_user_id, options)
213
+ {
214
+ timestamp: options[:timestamp] || default_timestamp,
215
+ distinct_id: distinct_id,
216
+ new_user_id: new_user_id
217
+ }
218
+ end
219
+
110
220
  def post(path, payload)
111
221
  res = @adapter.post(path, body: payload.to_json)
112
222
  handle_response(res)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Altertable
4
- VERSION = "1.2.0"
4
+ VERSION = "1.4.0"
5
5
  end
data/lib/altertable.rb CHANGED
@@ -10,7 +10,7 @@ module Altertable
10
10
  @client = Client.new(api_key, options)
11
11
  end
12
12
 
13
- def track(event, distinct_id, **options)
13
+ def track(event, distinct_id = nil, **options)
14
14
  client.track(event, distinct_id, **options)
15
15
  end
16
16
 
@@ -18,7 +18,7 @@ module Altertable
18
18
  client.identify(user_id, **options)
19
19
  end
20
20
 
21
- def alias(distinct_id, new_user_id, **options)
21
+ def alias(distinct_id, new_user_id = nil, **options)
22
22
  client.alias(distinct_id, new_user_id, **options)
23
23
  end
24
24
 
data/rbi/altertable.rbi CHANGED
@@ -29,29 +29,36 @@ module Altertable
29
29
  class Client
30
30
  DEFAULT_BASE_URL = T.let(T.unsafe(nil), String)
31
31
  DEFAULT_TIMEOUT = T.let(T.unsafe(nil), Integer)
32
+ # @deprecated Environments are selected by the Product Analytics API key.
32
33
  DEFAULT_ENVIRONMENT = T.let(T.unsafe(nil), String)
33
34
 
34
35
  sig { params(api_key: String, options: T::Hash[Symbol, T.untyped]).void }
35
36
  def initialize(api_key, options = {}); end
36
37
 
37
- sig { params(event: String, distinct_id: String, options: T.untyped).returns(T.untyped) }
38
- def track(event, distinct_id, **options); end
38
+ sig { params(event: T.any(String, T::Hash[T.any(Symbol, String), T.untyped], T::Array[T::Hash[T.any(Symbol, String), T.untyped]]), distinct_id: T.nilable(String), options: T.untyped).returns(T.untyped) }
39
+ def track(event, distinct_id = nil, **options); end
39
40
 
40
- sig { params(user_id: String, options: T.untyped).returns(T.untyped) }
41
+ sig { params(user_id: T.any(String, T::Hash[T.any(Symbol, String), T.untyped], T::Array[T::Hash[T.any(Symbol, String), T.untyped]]), options: T.untyped).returns(T.untyped) }
41
42
  def identify(user_id, **options); end
42
43
 
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
44
+ sig { params(distinct_id: T.any(String, T::Hash[T.any(Symbol, String), T.untyped], T::Array[T::Hash[T.any(Symbol, String), T.untyped]]), new_user_id: T.nilable(String), options: T.untyped).returns(T.untyped) }
45
+ def alias(distinct_id, new_user_id = nil, **options); end
45
46
 
46
47
  private
47
48
 
48
49
  sig { params(name: T.nilable(Symbol), options: T::Hash[Symbol, T.untyped]).returns(T.untyped) }
49
50
  def select_adapter(name, options); end
50
51
 
52
+ sig { returns(T::Boolean) }
53
+ def reject_identity_call?; end
54
+
55
+ sig { params(payload: T::Hash[Symbol, T.untyped]).returns(T::Hash[Symbol, T.untyped]) }
56
+ def audience_payload(payload); end
57
+
51
58
  sig { params(gem_name: String).returns(T::Boolean) }
52
59
  def try_require(gem_name); end
53
60
 
54
- sig { params(path: String, payload: T::Hash[T.any(Symbol, String), T.untyped]).returns(T.untyped) }
61
+ sig { params(path: String, payload: T.any(T::Hash[T.any(Symbol, String), T.untyped], T::Array[T::Hash[T.any(Symbol, String), T.untyped]])).returns(T.untyped) }
55
62
  def post(path, payload); end
56
63
 
57
64
  sig { params(res: T.untyped).returns(T.untyped) }
@@ -124,14 +131,14 @@ module Altertable
124
131
  sig { params(api_key: String, options: T::Hash[Symbol, T.untyped]).returns(Client) }
125
132
  def self.init(api_key, options = {}); end
126
133
 
127
- sig { params(event: String, distinct_id: String, options: T.untyped).returns(T.untyped) }
128
- def self.track(event, distinct_id, **options); end
134
+ sig { params(event: T.any(String, T::Hash[T.any(Symbol, String), T.untyped], T::Array[T::Hash[T.any(Symbol, String), T.untyped]]), distinct_id: T.nilable(String), options: T.untyped).returns(T.untyped) }
135
+ def self.track(event, distinct_id = nil, **options); end
129
136
 
130
- sig { params(user_id: String, options: T.untyped).returns(T.untyped) }
137
+ sig { params(user_id: T.any(String, T::Hash[T.any(Symbol, String), T.untyped], T::Array[T::Hash[T.any(Symbol, String), T.untyped]]), options: T.untyped).returns(T.untyped) }
131
138
  def self.identify(user_id, **options); end
132
139
 
133
- sig { params(distinct_id: String, new_user_id: String, options: T.untyped).returns(T.untyped) }
134
- def self.alias(distinct_id, new_user_id, **options); end
140
+ sig { params(distinct_id: T.any(String, T::Hash[T.any(Symbol, String), T.untyped], T::Array[T::Hash[T.any(Symbol, String), T.untyped]]), new_user_id: T.nilable(String), options: T.untyped).returns(T.untyped) }
141
+ def self.alias(distinct_id, new_user_id = nil, **options); end
135
142
 
136
143
  sig { returns(Client) }
137
144
  def self.client; end
@@ -1,8 +1,8 @@
1
1
  module Altertable
2
2
  class Client
3
+ @mode: :product | :audience
3
4
  @api_key: String
4
5
  @base_url: String
5
- @environment: String
6
6
  @timeout: Integer | Float
7
7
  @release: String?
8
8
  @debug: bool
@@ -11,21 +11,31 @@ module Altertable
11
11
 
12
12
  DEFAULT_BASE_URL: String
13
13
  DEFAULT_TIMEOUT: Integer
14
+ # @deprecated Environments are selected by the Product Analytics API key.
14
15
  DEFAULT_ENVIRONMENT: String
15
16
 
16
17
  def initialize: (String api_key, ?::Hash[Symbol, untyped] options) -> void
17
18
 
18
- def track: (String event, String distinct_id, **untyped options) -> untyped
19
+ def track: (String event, ?String? distinct_id, **untyped options) -> untyped
20
+ | (::Hash[Symbol | String, untyped] event_payload, **untyped options) -> untyped
21
+ | (::Array[::Hash[Symbol | String, untyped]] event_payloads, **untyped options) -> untyped
19
22
 
20
23
  def identify: (String user_id, **untyped options) -> untyped
24
+ | (::Hash[Symbol | String, untyped] identify_payload, **untyped options) -> untyped
25
+ | (::Array[::Hash[Symbol | String, untyped]] identify_payloads, **untyped options) -> untyped
21
26
 
22
27
  def alias: (String distinct_id, String new_user_id, **untyped options) -> untyped
28
+ | (::Hash[Symbol | String, untyped] alias_payload, **untyped options) -> untyped
29
+ | (::Array[::Hash[Symbol | String, untyped]] alias_payloads, **untyped options) -> untyped
23
30
 
24
31
  private
25
32
 
33
+ def reject_identity_call?: () -> bool
34
+ def audience_payload: (::Hash[Symbol, untyped] payload) -> ::Hash[Symbol, untyped]
35
+
26
36
  def select_adapter: (Symbol? name, ::Hash[Symbol, untyped] options) -> untyped
27
37
  def try_require: (String gem_name) -> bool
28
- def post: (String path, ::Hash[Symbol | String, untyped] payload) -> untyped
38
+ def post: (String path, ::Hash[Symbol | String, untyped] | ::Array[::Hash[Symbol | String, untyped]] payload) -> untyped
29
39
  def handle_response: (untyped res) -> untyped
30
40
  def handle_error: (Exception error) -> untyped
31
41
  end
data/sig/altertable.rbs CHANGED
@@ -3,11 +3,17 @@ 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 distinct_id, **untyped options) -> untyped
6
+ def self.track: (String event, ?String? distinct_id, **untyped options) -> untyped
7
+ | (::Hash[Symbol | String, untyped] event_payload, **untyped options) -> untyped
8
+ | (::Array[::Hash[Symbol | String, untyped]] event_payloads, **untyped options) -> untyped
7
9
 
8
10
  def self.identify: (String user_id, **untyped options) -> untyped
11
+ | (::Hash[Symbol | String, untyped] identify_payload, **untyped options) -> untyped
12
+ | (::Array[::Hash[Symbol | String, untyped]] identify_payloads, **untyped options) -> untyped
9
13
 
10
14
  def self.alias: (String distinct_id, String new_user_id, **untyped options) -> untyped
15
+ | (::Hash[Symbol | String, untyped] alias_payload, **untyped options) -> untyped
16
+ | (::Array[::Hash[Symbol | String, untyped]] alias_payloads, **untyped options) -> untyped
11
17
 
12
18
  def self.client: () -> Client
13
19
  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: 1.2.0
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Altertable
@@ -170,8 +170,10 @@ executables: []
170
170
  extensions: []
171
171
  extra_rdoc_files: []
172
172
  files:
173
+ - ".github/FUNDING.yml"
173
174
  - ".github/ISSUE_TEMPLATE/bug_report.yml"
174
175
  - ".github/ISSUE_TEMPLATE/feature_request.yml"
176
+ - ".github/PULL_REQUEST_TEMPLATE.md"
175
177
  - ".github/workflows/ci.yml"
176
178
  - ".github/workflows/release-please.yml"
177
179
  - ".github/workflows/semantic-pull-request.yml"