Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ RUN apt-get -q update && \
COPY . .

ARG BUNDLE_GITHUB__COM
ENV BUNDLER_VERSION=2.1.4
ENV BUNDLER_VERSION=2.2.29
RUN gem update --system \
&& gem install bundler -v $BUNDLER_VERSION \
&& bundle install -j 4
Expand Down
12 changes: 11 additions & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,11 @@ PATH
remote: .
specs:
event_tracker (1.2.0)
activejob
activerecord
mixpanel-ruby (~> 2.2, >= 2.2.0)
rails (~> 6.1.6)
rspec-sidekiq
sidekiq (~> 6.4, >= 6.4.1)

GEM
remote: https://rubygems.org/
Expand Down Expand Up @@ -86,6 +87,7 @@ GEM
ast (2.4.2)
builder (3.2.4)
concurrent-ruby (1.1.10)
connection_pool (2.2.5)
crass (1.0.6)
diff-lcs (1.5.0)
erubi (1.10.0)
Expand Down Expand Up @@ -143,6 +145,7 @@ GEM
thor (~> 1.0)
rainbow (3.1.1)
rake (12.3.3)
redis (4.2.5)
regexp_parser (2.5.0)
rexml (3.2.5)
rspec (3.11.0)
Expand All @@ -157,6 +160,9 @@ GEM
rspec-mocks (3.11.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.11.0)
rspec-sidekiq (3.0.3)
rspec-core (~> 3.0, >= 3.0.0)
sidekiq (>= 2.4.0)
rspec-support (3.11.0)
rubocop (1.28.2)
parallel (~> 1.10)
Expand Down Expand Up @@ -185,6 +191,10 @@ GEM
rubocop-thread_safety (0.4.4)
rubocop (>= 0.53.0)
ruby-progressbar (1.11.0)
sidekiq (6.4.1)
connection_pool (>= 2.2.2)
rack (~> 2.0)
redis (>= 4.2.0)
sprockets (4.0.3)
concurrent-ruby (~> 1.0)
rack (> 1, < 3)
Expand Down
9 changes: 4 additions & 5 deletions event_tracker.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ Gem::Specification.new do |spec|
spec.version = EventTracker::VERSION
spec.authors = ['Richard Millan']
spec.email = ['[email protected]']

spec.required_ruby_version = '>= 2.7.6'
spec.summary = 'Gem for sharing event-tracking functionality between Rails apps'
spec.homepage = 'https://github.com/returnly/event_tracker'

Expand All @@ -22,9 +22,7 @@ Gem::Specification.new do |spec|
'public gem pushes.'
end

spec.files = `git ls-files -z`.split("\x0").reject do |f|
f.match(%r{^(test|spec|features)/})
end
spec.files = Dir.glob('lib/**/*')
spec.bindir = 'exe'
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
spec.require_paths = ['lib']
Expand All @@ -33,8 +31,9 @@ Gem::Specification.new do |spec|
spec.add_development_dependency 'rake', '~> 12.0'
spec.add_development_dependency 'rspec', '~> 3.0'

spec.add_dependency 'activejob'
spec.add_dependency 'activerecord'
spec.add_dependency 'mixpanel-ruby', '~> 2.2', '>= 2.2.0'
spec.add_dependency 'rails', '~> 6.1.6'
spec.add_dependency 'rspec-sidekiq'
spec.add_dependency 'sidekiq', '~> 6.4', '>= 6.4.1'
end
1 change: 1 addition & 0 deletions lib/event_tracker/jobs/development_job.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# frozen_string_literal: true

require 'rails'
require_relative 'tracker_job'

Expand Down
7 changes: 4 additions & 3 deletions lib/event_tracker/jobs/tracker_job.rb
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
# frozen_string_literal: true

require 'active_job'
require 'sidekiq'

module EventTracker
module Jobs
class TrackerJob < ::ActiveJob::Base
queue_as :default
class TrackerJob
include Sidekiq::Worker
sidekiq_options queue: :default

def perform(_doer_id, _event_name, _event_label, _properties)
raise NotImplementedError, 'Implement in adapter'
Expand Down
2 changes: 1 addition & 1 deletion lib/event_tracker/tracker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ def context_with_(properties)
end

def development?
Rails.env.development?
::Rails.env.development?
end
end
end
2 changes: 1 addition & 1 deletion lib/event_tracker/trackers/development.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module EventTracker
module Trackers
class Development < Base
def track(event_name, event_label, properties)
EventTracker::Jobs::DevelopmentJob.perform_later(@doer_id, event_name, event_label, properties)
EventTracker::Jobs::DevelopmentJob.perform_async(@doer_id, event_name, event_label, properties)
end
end
end
Expand Down
17 changes: 15 additions & 2 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,20 @@
# frozen_string_literal: true

require 'active_job'
require 'event_tracker'
require 'rspec-sidekiq'

RSpec::Sidekiq.configure do |config|
# Clears all job queues before each example
config.clear_all_enqueued_jobs = true # default => true

# Whether to use terminal colours when outputting messages
config.enable_terminal_colours = true # default => true

# Warn when jobs are not enqueued to Redis but to a job array
config.warn_when_jobs_not_processed_by_sidekiq = true # default => true
end

Rails.logger = Logger.new($stdout)

RSpec.configure do |config|
# Enable flags like --only-failures and --next-failure
Expand All @@ -12,6 +25,6 @@
end

config.before(:all) do
ActiveJob::Base.queue_adapter = :test
Sidekiq::Testing.inline!
end
end