mixpanel-ruby 3.0.0 → 3.2.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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. data/.github/dependabot.yml +14 -0
  3. data/.github/modules.json +18 -0
  4. data/.github/scripts/generate-changelog.sh +87 -0
  5. data/.github/workflows/pr-title-check.yml +51 -0
  6. data/.github/workflows/prepare-release.yml +189 -0
  7. data/.github/workflows/release-rubygems.yml +217 -0
  8. data/.github/workflows/ruby.yml +31 -2
  9. data/CHANGELOG.md +30 -0
  10. data/Readme.rdoc +65 -0
  11. data/lib/mixpanel-ruby/consumer.rb +54 -6
  12. data/lib/mixpanel-ruby/credentials.rb +26 -0
  13. data/lib/mixpanel-ruby/events.rb +69 -11
  14. data/lib/mixpanel-ruby/flags/flags_provider.rb +28 -10
  15. data/lib/mixpanel-ruby/flags/local_flags_provider.rb +104 -40
  16. data/lib/mixpanel-ruby/flags/remote_flags_provider.rb +4 -2
  17. data/lib/mixpanel-ruby/tracker.rb +39 -9
  18. data/lib/mixpanel-ruby/version.rb +1 -1
  19. data/lib/mixpanel-ruby.rb +1 -0
  20. data/openfeature-provider/CHANGELOG.md +5 -0
  21. data/openfeature-provider/Gemfile +7 -0
  22. data/openfeature-provider/README.md +288 -0
  23. data/openfeature-provider/RELEASE.md +52 -0
  24. data/openfeature-provider/lib/mixpanel/openfeature/provider.rb +170 -0
  25. data/openfeature-provider/lib/mixpanel/openfeature/version.rb +7 -0
  26. data/openfeature-provider/lib/mixpanel/openfeature.rb +4 -0
  27. data/openfeature-provider/mixpanel-ruby-openfeature.gemspec +25 -0
  28. data/openfeature-provider/spec/mixpanel_openfeature_provider_spec.rb +606 -0
  29. data/openfeature-provider/spec/spec_helper.rb +23 -0
  30. data/spec/mixpanel-ruby/consumer_spec.rb +81 -0
  31. data/spec/mixpanel-ruby/credentials_security_spec.rb +108 -0
  32. data/spec/mixpanel-ruby/credentials_spec.rb +54 -0
  33. data/spec/mixpanel-ruby/events_spec.rb +152 -0
  34. data/spec/mixpanel-ruby/flags/local_flags_spec.rb +209 -2
  35. data/spec/mixpanel-ruby/flags/remote_flags_spec.rb +36 -0
  36. data/spec/mixpanel-ruby/tracker_spec.rb +18 -0
  37. metadata +23 -3
@@ -1,6 +1,7 @@
1
1
  require 'json'
2
2
  require 'mixpanel-ruby/flags/remote_flags_provider'
3
3
  require 'mixpanel-ruby/flags/types'
4
+ require 'mixpanel-ruby/credentials'
4
5
  require 'webmock/rspec'
5
6
 
6
7
  describe Mixpanel::Flags::RemoteFlagsProvider do
@@ -17,6 +18,7 @@ describe Mixpanel::Flags::RemoteFlagsProvider do
17
18
  config,
18
19
  mock_tracker,
19
20
  mock_error_handler
21
+ # credentials defaults to nil
20
22
  )
21
23
  end
22
24
 
@@ -438,4 +440,38 @@ describe Mixpanel::Flags::RemoteFlagsProvider do
438
440
  provider.send(:track_exposure_event, 'test_flag', variant, test_context)
439
441
  end
440
442
  end
443
+
444
+ describe 'service account credentials' do
445
+ it 'uses service account credentials for authentication' do
446
+ credentials = Mixpanel::ServiceAccountCredentials.new('test-user', 'test-secret', 'test-project')
447
+
448
+ response = create_success_response({
449
+ 'test_flag' => {
450
+ 'variant_key' => 'treatment',
451
+ 'variant_value' => 'treatment'
452
+ }
453
+ })
454
+
455
+ stub_request(:get, endpoint_url_regex)
456
+ .with(
457
+ basic_auth: ['test-user', 'test-secret']
458
+ )
459
+ .to_return(
460
+ status: 200,
461
+ body: response.to_json,
462
+ headers: { 'Content-Type' => 'application/json' }
463
+ )
464
+
465
+ credentials_provider = Mixpanel::Flags::RemoteFlagsProvider.new(
466
+ test_token,
467
+ config,
468
+ mock_tracker,
469
+ mock_error_handler,
470
+ credentials
471
+ )
472
+
473
+ result = credentials_provider.get_variant_value('test_flag', 'fallback', test_context, report_exposure: false)
474
+ expect(result).to eq('treatment')
475
+ end
476
+ end
441
477
  end
@@ -131,4 +131,22 @@ describe Mixpanel::Tracker do
131
131
  expect(expect).to eq(found)
132
132
  end
133
133
  end
134
+
135
+ describe 'service account credentials' do
136
+ it 'should pass credentials to flags providers when passed directly' do
137
+ credentials = Mixpanel::ServiceAccountCredentials.new('user', 'secret', 'project123')
138
+
139
+ tracker = Mixpanel::Tracker.new(
140
+ 'TEST TOKEN',
141
+ nil,
142
+ credentials: credentials,
143
+ local_flags_config: {},
144
+ remote_flags_config: {}
145
+ )
146
+
147
+ # Verify credentials were passed to providers by checking internal state
148
+ expect(tracker.local_flags.instance_variable_get(:@credentials)).to eq(credentials)
149
+ expect(tracker.remote_flags.instance_variable_get(:@credentials)).to eq(credentials)
150
+ end
151
+ end
134
152
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mixpanel-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.0
4
+ version: 3.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Mixpanel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-01-05 00:00:00.000000000 Z
11
+ date: 2026-07-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: mutex_m
@@ -170,9 +170,16 @@ executables: []
170
170
  extensions: []
171
171
  extra_rdoc_files: []
172
172
  files:
173
+ - ".github/dependabot.yml"
174
+ - ".github/modules.json"
175
+ - ".github/scripts/generate-changelog.sh"
176
+ - ".github/workflows/pr-title-check.yml"
177
+ - ".github/workflows/prepare-release.yml"
178
+ - ".github/workflows/release-rubygems.yml"
173
179
  - ".github/workflows/ruby.yml"
174
180
  - ".gitignore"
175
181
  - ".rspec"
182
+ - CHANGELOG.md
176
183
  - Gemfile
177
184
  - LICENSE
178
185
  - Rakefile
@@ -184,6 +191,7 @@ files:
184
191
  - demo/simple_messages.rb
185
192
  - lib/mixpanel-ruby.rb
186
193
  - lib/mixpanel-ruby/consumer.rb
194
+ - lib/mixpanel-ruby/credentials.rb
187
195
  - lib/mixpanel-ruby/error.rb
188
196
  - lib/mixpanel-ruby/events.rb
189
197
  - lib/mixpanel-ruby/flags/flags_provider.rb
@@ -196,7 +204,19 @@ files:
196
204
  - lib/mixpanel-ruby/tracker.rb
197
205
  - lib/mixpanel-ruby/version.rb
198
206
  - mixpanel-ruby.gemspec
207
+ - openfeature-provider/CHANGELOG.md
208
+ - openfeature-provider/Gemfile
209
+ - openfeature-provider/README.md
210
+ - openfeature-provider/RELEASE.md
211
+ - openfeature-provider/lib/mixpanel/openfeature.rb
212
+ - openfeature-provider/lib/mixpanel/openfeature/provider.rb
213
+ - openfeature-provider/lib/mixpanel/openfeature/version.rb
214
+ - openfeature-provider/mixpanel-ruby-openfeature.gemspec
215
+ - openfeature-provider/spec/mixpanel_openfeature_provider_spec.rb
216
+ - openfeature-provider/spec/spec_helper.rb
199
217
  - spec/mixpanel-ruby/consumer_spec.rb
218
+ - spec/mixpanel-ruby/credentials_security_spec.rb
219
+ - spec/mixpanel-ruby/credentials_spec.rb
200
220
  - spec/mixpanel-ruby/error_spec.rb
201
221
  - spec/mixpanel-ruby/events_spec.rb
202
222
  - spec/mixpanel-ruby/flags/local_flags_spec.rb
@@ -225,7 +245,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
225
245
  - !ruby/object:Gem::Version
226
246
  version: '0'
227
247
  requirements: []
228
- rubygems_version: 3.5.16
248
+ rubygems_version: 3.5.22
229
249
  signing_key:
230
250
  specification_version: 4
231
251
  summary: Official Mixpanel tracking library for ruby