From 563ea00453a40da7e2336b18e2bcadc50667754a Mon Sep 17 00:00:00 2001 From: Hans Li Date: Tue, 9 Dec 2025 11:23:21 -0800 Subject: [PATCH 01/12] Fixed gha --- .github/workflows/ruby.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 32b961b..b3e3e1c 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -25,9 +25,9 @@ jobs: # - '3.0' steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v6 - name: Set up Ruby - uses: ruby/setup-ruby@0a29871fe2b0200a17a4497bae54fe5df0d973aa # v1.115.3 + uses: ruby/setup-ruby@d697be2f83c6234b20877c3b5eac7a7f342f0d0c # v1.269.0 with: ruby-version: ${{ matrix.ruby-version }} bundler-cache: true # runs 'bundle install' and caches installed gems automatically From cab679c663e002d97831fc069f869b4c53039dbe Mon Sep 17 00:00:00 2001 From: Hans Li Date: Tue, 9 Dec 2025 12:33:33 -0800 Subject: [PATCH 02/12] Fixed tests and millisecond bugs --- lib/mixpanel-ruby/events.rb | 4 ++-- lib/mixpanel-ruby/groups.rb | 2 +- lib/mixpanel-ruby/people.rb | 2 +- lib/mixpanel-ruby/tracker.rb | 2 +- mixpanel-ruby.gemspec | 2 +- spec/mixpanel-ruby/events_spec.rb | 4 ++-- spec/mixpanel-ruby/groups_spec.rb | 4 ++-- spec/mixpanel-ruby/tracker_spec.rb | 10 +++++----- 8 files changed, 15 insertions(+), 15 deletions(-) diff --git a/lib/mixpanel-ruby/events.rb b/lib/mixpanel-ruby/events.rb index fbe4b56..be653cd 100644 --- a/lib/mixpanel-ruby/events.rb +++ b/lib/mixpanel-ruby/events.rb @@ -55,7 +55,7 @@ def track(distinct_id, event, properties={}, ip=nil) properties = { 'distinct_id' => distinct_id, 'token' => @token, - 'time' => Time.now.to_f, + 'time' => (Time.now.to_f * 1000).to_i, 'mp_lib' => 'ruby', '$lib_version' => Mixpanel::VERSION, }.merge(properties) @@ -103,7 +103,7 @@ def import(api_key, distinct_id, event, properties={}, ip=nil) properties = { 'distinct_id' => distinct_id, 'token' => @token, - 'time' => Time.now.to_f, + 'time' => (Time.now.to_f * 1000).to_i, 'mp_lib' => 'ruby', '$lib_version' => Mixpanel::VERSION, }.merge(properties) diff --git a/lib/mixpanel-ruby/groups.rb b/lib/mixpanel-ruby/groups.rb index 8b09e2c..9e78fac 100644 --- a/lib/mixpanel-ruby/groups.rb +++ b/lib/mixpanel-ruby/groups.rb @@ -170,7 +170,7 @@ def delete_group(group_key, group_id, optional_params={}) def update(message) data = { '$token' => @token, - '$time' => Time.now.to_f, + '$time' => Time.now.to_i * 1000, }.merge(message) message = {'data' => data} diff --git a/lib/mixpanel-ruby/people.rb b/lib/mixpanel-ruby/people.rb index 8cf57ee..8bcbf34 100644 --- a/lib/mixpanel-ruby/people.rb +++ b/lib/mixpanel-ruby/people.rb @@ -223,7 +223,7 @@ def delete_user(distinct_id, optional_params={}) def update(message) data = { '$token' => @token, - '$time' => Time.now.to_f, + '$time' => (Time.now.to_f * 1000).to_i, }.merge(message) message = {'data' => data} diff --git a/lib/mixpanel-ruby/tracker.rb b/lib/mixpanel-ruby/tracker.rb index 5327f71..123fa8b 100644 --- a/lib/mixpanel-ruby/tracker.rb +++ b/lib/mixpanel-ruby/tracker.rb @@ -165,7 +165,7 @@ def generate_tracking_url(distinct_id, event, properties={}, endpoint=nil) properties = { 'distinct_id' => distinct_id, 'token' => @token, - 'time' => Time.now.to_f, + 'time' => (Time.now.to_f * 1000).to_i, 'mp_lib' => 'ruby', '$lib_version' => Mixpanel::VERSION, }.merge(properties) diff --git a/mixpanel-ruby.gemspec b/mixpanel-ruby.gemspec index d1c61e2..171d8e2 100644 --- a/mixpanel-ruby.gemspec +++ b/mixpanel-ruby.gemspec @@ -15,7 +15,7 @@ spec = Gem::Specification.new do |spec| spec.required_ruby_version = '>= 2.0.0' spec.add_development_dependency 'activesupport', '~> 4.0' - spec.add_development_dependency 'rake', '~> 0' + spec.add_development_dependency 'rake', '~> 13' spec.add_development_dependency 'rspec', '~> 3.0' spec.add_development_dependency 'webmock', '~> 1.18' end diff --git a/spec/mixpanel-ruby/events_spec.rb b/spec/mixpanel-ruby/events_spec.rb index 6d9bc20..57f6ade 100644 --- a/spec/mixpanel-ruby/events_spec.rb +++ b/spec/mixpanel-ruby/events_spec.rb @@ -27,7 +27,7 @@ 'mp_lib' => 'ruby', '$lib_version' => Mixpanel::VERSION, 'token' => 'TEST TOKEN', - 'time' => @time_now.to_i + 'time' => @time_now.to_i * 1000 } }]]) end @@ -46,7 +46,7 @@ 'mp_lib' => 'ruby', '$lib_version' => Mixpanel::VERSION, 'token' => 'TEST TOKEN', - 'time' => @time_now.to_i + 'time' => @time_now.to_i * 1000 } } } ]]) diff --git a/spec/mixpanel-ruby/groups_spec.rb b/spec/mixpanel-ruby/groups_spec.rb index 063c4d8..45f0170 100644 --- a/spec/mixpanel-ruby/groups_spec.rb +++ b/spec/mixpanel-ruby/groups_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -require 'active_support/time' +require "active_support/time" require 'mixpanel-ruby/groups' @@ -23,7 +23,7 @@ '$token' => 'TEST TOKEN', '$group_key' => 'TEST GROUP KEY', '$group_id' => 'TEST GROUP ID', - '$time' => @time_now.to_i * 1000, + '$time' => (@time_now.to_f * 1000).to_i, '$set' => { '$groupname' => 'Mixpanel', '$grouprevenue' => 200 diff --git a/spec/mixpanel-ruby/tracker_spec.rb b/spec/mixpanel-ruby/tracker_spec.rb index cf32bd3..1fe54eb 100644 --- a/spec/mixpanel-ruby/tracker_spec.rb +++ b/spec/mixpanel-ruby/tracker_spec.rb @@ -29,7 +29,7 @@ 'mp_lib' => 'ruby', '$lib_version' => Mixpanel::VERSION, 'token' => 'TEST TOKEN', - 'time' => @time_now.to_i + 'time' => @time_now.to_i * 1000 } expected_data = {'event' => event, 'properties' => properties.merge(default_properties)} @@ -61,7 +61,7 @@ with { |req| body = req.body } message_urlencoded = body[/^data=(.*?)(?:&|$)/, 1] - message_json = Base64.strict_decode64(URI.unescape(message_urlencoded)) + message_json = Base64.strict_decode64(CGI.unescape(message_urlencoded)) message = JSON.load(message_json) expect(message).to eq({ 'event' => 'TEST EVENT', @@ -71,7 +71,7 @@ 'mp_lib' => 'ruby', '$lib_version' => Mixpanel::VERSION, 'token' => 'TEST TOKEN', - 'time' => @time_now.to_i + 'time' => @time_now.to_i * 1000 } }) end @@ -94,7 +94,7 @@ 'mp_lib' => 'ruby', '$lib_version' => Mixpanel::VERSION, 'token' => 'TEST TOKEN', - 'time' => @time_now.to_i + 'time' => @time_now.to_i * 1000 } } ], @@ -106,7 +106,7 @@ 'mp_lib' => 'ruby', '$lib_version' => Mixpanel::VERSION, 'token' => 'TEST TOKEN', - 'time' => @time_now.to_i + 'time' => @time_now.to_i * 1000 } }, 'api_key' => 'API_KEY', From 0f0869a44528b1657c5558b415d67d603c11c8da Mon Sep 17 00:00:00 2001 From: Hans Li Date: Tue, 9 Dec 2025 12:34:21 -0800 Subject: [PATCH 03/12] Fixed tests and millisecond bugs --- .github/workflows/ruby.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index b3e3e1c..75f97c3 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -15,14 +15,12 @@ jobs: strategy: matrix: ruby-version: - - '2.0' - - '2.1' - '2.2' - '2.3' - '2.5' - '2.6' - # - '2.7' - # - '3.0' + - '2.7' + - '3.0' steps: - uses: actions/checkout@v6 From f4ff82002bfa39254e400018b8df28f3f67109db Mon Sep 17 00:00:00 2001 From: Hans Li Date: Tue, 9 Dec 2025 12:34:37 -0800 Subject: [PATCH 04/12] Updated --- mixpanel-ruby.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mixpanel-ruby.gemspec b/mixpanel-ruby.gemspec index 171d8e2..47baded 100644 --- a/mixpanel-ruby.gemspec +++ b/mixpanel-ruby.gemspec @@ -12,7 +12,7 @@ spec = Gem::Specification.new do |spec| spec.homepage = 'https://mixpanel.com/help/reference/ruby' spec.license = 'Apache License 2.0' - spec.required_ruby_version = '>= 2.0.0' + spec.required_ruby_version = '>= 2.2.0' spec.add_development_dependency 'activesupport', '~> 4.0' spec.add_development_dependency 'rake', '~> 13' From 4550f230b63675d31e5911113a0d0596c5617644 Mon Sep 17 00:00:00 2001 From: Hans Li Date: Tue, 9 Dec 2025 12:35:52 -0800 Subject: [PATCH 05/12] Updated matrix --- .github/workflows/ruby.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 75f97c3..5212129 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -21,6 +21,10 @@ jobs: - '2.6' - '2.7' - '3.0' + - '3.1' + - '3.2' + - '3.3' + - '3.4' steps: - uses: actions/checkout@v6 From 06aa6d017bb60a94a125993ab15851c313e2397c Mon Sep 17 00:00:00 2001 From: Hans Li Date: Tue, 9 Dec 2025 12:37:08 -0800 Subject: [PATCH 06/12] support up to 3.3 --- .github/workflows/ruby.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 5212129..ff40e57 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -24,7 +24,6 @@ jobs: - '3.1' - '3.2' - '3.3' - - '3.4' steps: - uses: actions/checkout@v6 From 3cc6b8ca80f6b3b2958c07cdb6fd119e25a0cc46 Mon Sep 17 00:00:00 2001 From: Hans Li Date: Tue, 9 Dec 2025 12:49:00 -0800 Subject: [PATCH 07/12] Support 3.4 --- .github/workflows/ruby.yml | 1 + mixpanel-ruby.gemspec | 2 ++ 2 files changed, 3 insertions(+) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index ff40e57..5212129 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -24,6 +24,7 @@ jobs: - '3.1' - '3.2' - '3.3' + - '3.4' steps: - uses: actions/checkout@v6 diff --git a/mixpanel-ruby.gemspec b/mixpanel-ruby.gemspec index 47baded..3f15ee5 100644 --- a/mixpanel-ruby.gemspec +++ b/mixpanel-ruby.gemspec @@ -13,6 +13,8 @@ spec = Gem::Specification.new do |spec| spec.license = 'Apache License 2.0' spec.required_ruby_version = '>= 2.2.0' + spec.add_dependency 'mutex_m' + spec.add_runtime_dependency "base64" spec.add_development_dependency 'activesupport', '~> 4.0' spec.add_development_dependency 'rake', '~> 13' From 45789d7e7736f966ed6d33f02aa1f750bc28ebfb Mon Sep 17 00:00:00 2001 From: Hans Li Date: Tue, 9 Dec 2025 12:50:30 -0800 Subject: [PATCH 08/12] Remove 2.2 --- .github/workflows/ruby.yml | 1 - mixpanel-ruby.gemspec | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/ruby.yml b/.github/workflows/ruby.yml index 5212129..3e6812b 100644 --- a/.github/workflows/ruby.yml +++ b/.github/workflows/ruby.yml @@ -15,7 +15,6 @@ jobs: strategy: matrix: ruby-version: - - '2.2' - '2.3' - '2.5' - '2.6' diff --git a/mixpanel-ruby.gemspec b/mixpanel-ruby.gemspec index 3f15ee5..a443974 100644 --- a/mixpanel-ruby.gemspec +++ b/mixpanel-ruby.gemspec @@ -12,7 +12,7 @@ spec = Gem::Specification.new do |spec| spec.homepage = 'https://mixpanel.com/help/reference/ruby' spec.license = 'Apache License 2.0' - spec.required_ruby_version = '>= 2.2.0' + spec.required_ruby_version = '>= 2.3.0' spec.add_dependency 'mutex_m' spec.add_runtime_dependency "base64" From b60716eceb18c3fac89718986ba6821e132e883b Mon Sep 17 00:00:00 2001 From: Hans Li Date: Tue, 9 Dec 2025 12:55:20 -0800 Subject: [PATCH 09/12] Update mixpanel-ruby.gemspec Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- mixpanel-ruby.gemspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mixpanel-ruby.gemspec b/mixpanel-ruby.gemspec index a443974..0bc5c16 100644 --- a/mixpanel-ruby.gemspec +++ b/mixpanel-ruby.gemspec @@ -13,7 +13,7 @@ spec = Gem::Specification.new do |spec| spec.license = 'Apache License 2.0' spec.required_ruby_version = '>= 2.3.0' - spec.add_dependency 'mutex_m' + spec.add_runtime_dependency 'mutex_m' spec.add_runtime_dependency "base64" spec.add_development_dependency 'activesupport', '~> 4.0' From b07712808fed4af963c8cf62f7e9e4e85996b1ab Mon Sep 17 00:00:00 2001 From: Hans Li Date: Tue, 9 Dec 2025 12:55:36 -0800 Subject: [PATCH 10/12] Update lib/mixpanel-ruby/groups.rb Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- lib/mixpanel-ruby/groups.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/mixpanel-ruby/groups.rb b/lib/mixpanel-ruby/groups.rb index 9e78fac..42048dc 100644 --- a/lib/mixpanel-ruby/groups.rb +++ b/lib/mixpanel-ruby/groups.rb @@ -170,7 +170,7 @@ def delete_group(group_key, group_id, optional_params={}) def update(message) data = { '$token' => @token, - '$time' => Time.now.to_i * 1000, + '$time' => (Time.now.to_f * 1000).to_i, }.merge(message) message = {'data' => data} From da8a51e76abcd9cb7b9b142890345c734a63895f Mon Sep 17 00:00:00 2001 From: Copilot <198982749+Copilot@users.noreply.github.com> Date: Tue, 9 Dec 2025 13:04:05 -0800 Subject: [PATCH 11/12] Fix inconsistent timestamp format in groups_spec.rb test expectations (#128) * Initial plan * Fix inconsistent timestamp format in groups_spec.rb tests Changed 9 occurrences from `@time_now.to_i * 1000` to `(@time_now.to_f * 1000).to_i` to ensure consistent millisecond precision across all test expectations. Co-authored-by: hans-lizihan <7879022+hans-lizihan@users.noreply.github.com> --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: hans-lizihan <7879022+hans-lizihan@users.noreply.github.com> --- spec/mixpanel-ruby/groups_spec.rb | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/spec/mixpanel-ruby/groups_spec.rb b/spec/mixpanel-ruby/groups_spec.rb index 45f0170..07b6528 100644 --- a/spec/mixpanel-ruby/groups_spec.rb +++ b/spec/mixpanel-ruby/groups_spec.rb @@ -39,7 +39,7 @@ '$token' => 'TEST TOKEN', '$group_key' => 'TEST GROUP KEY', '$group_id' => 'TEST GROUP ID', - '$time' => @time_now.to_i * 1000, + '$time' => (@time_now.to_f * 1000).to_i, '$set' => { 'created_at' => '2013-01-02T03:04:05' } @@ -54,7 +54,7 @@ '$token' => 'TEST TOKEN', '$group_key' => 'TEST GROUP KEY', '$group_id' => 'TEST GROUP ID', - '$time' => @time_now.to_i * 1000, + '$time' => (@time_now.to_f * 1000).to_i, '$set' => { 'created_at' => '2013-01-02T02:04:05' } @@ -70,7 +70,7 @@ '$token' => 'TEST TOKEN', '$group_key' => 'TEST GROUP KEY', '$group_id' => 'TEST GROUP ID', - '$time' => @time_now.to_i * 1000, + '$time' => (@time_now.to_f * 1000).to_i, '$set' => { 'created_at' => '2013-01-02T02:04:05' } @@ -86,7 +86,7 @@ '$token' => 'TEST TOKEN', '$group_key' => 'TEST GROUP KEY', '$group_id' => 'TEST GROUP ID', - '$time' => @time_now.to_i * 1000, + '$time' => (@time_now.to_f * 1000).to_i, '$set_once' => { '$groupname' => 'Mixpanel', '$grouprevenue' => 200 @@ -102,7 +102,7 @@ '$token' => 'TEST TOKEN', '$group_key' => 'TEST GROUP KEY', '$group_id' => 'TEST GROUP ID', - '$time' => @time_now.to_i * 1000, + '$time' => (@time_now.to_f * 1000).to_i, '$remove' => { 'Albums' => 'Diamond Dogs' } @@ -117,7 +117,7 @@ '$token' => 'TEST TOKEN', '$group_key' => 'TEST GROUP KEY', '$group_id' => 'TEST GROUP ID', - '$time' => @time_now.to_i * 1000, + '$time' => (@time_now.to_f * 1000).to_i, '$union' => { 'Albums' => ['Diamond Dogs'] } @@ -130,7 +130,7 @@ '$token' => 'TEST TOKEN', '$group_key' => 'TEST GROUP KEY', '$group_id' => 'TEST GROUP ID', - '$time' => @time_now.to_i * 1000, + '$time' => (@time_now.to_f * 1000).to_i, '$unset' => ['Albums'] }]]) end @@ -141,7 +141,7 @@ '$token' => 'TEST TOKEN', '$group_key' => 'TEST GROUP KEY', '$group_id' => 'TEST GROUP ID', - '$time' => @time_now.to_i * 1000, + '$time' => (@time_now.to_f * 1000).to_i, '$unset' => ['Albums', 'Vinyls'] }]]) end @@ -152,7 +152,7 @@ '$token' => 'TEST TOKEN', '$group_key' => 'TEST GROUP KEY', '$group_id' => 'TEST GROUP ID', - '$time' => @time_now.to_i * 1000, + '$time' => (@time_now.to_f * 1000).to_i, '$delete' => '' }]]) end From f6c8371cd82f7049519dff34882e25548e1d3660 Mon Sep 17 00:00:00 2001 From: Hans Li Date: Tue, 9 Dec 2025 13:56:11 -0800 Subject: [PATCH 12/12] Fixed --- spec/mixpanel-ruby/groups_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/mixpanel-ruby/groups_spec.rb b/spec/mixpanel-ruby/groups_spec.rb index 07b6528..877f42a 100644 --- a/spec/mixpanel-ruby/groups_spec.rb +++ b/spec/mixpanel-ruby/groups_spec.rb @@ -1,5 +1,5 @@ require 'spec_helper' -require "active_support/time" +require 'active_support/time' require 'mixpanel-ruby/groups'