Sha256: f91ad420e9129a9ad6694bcf2bdcba44799e6d127a9f29642392c46cec135f36

Contents?: true

Size: 905 Bytes

Versions: 18

Compression:

Stored size: 905 Bytes

Contents

class TestTrack::NotifyAssignmentJob
  attr_reader :visitor_id, :assignment

  def initialize(opts)
    @visitor_id = opts.delete(:visitor_id)
    @assignment = opts.delete(:assignment)

    %w(visitor_id assignment).each do |param_name|
      raise "#{param_name} must be present" if send(param_name).blank?
    end
    raise "unknown opts: #{opts.keys.to_sentence}" if opts.present?
  end

  def perform
    tracking_result = track
    unless assignment.feature_gate?
      TestTrack::Remote::AssignmentEvent.create!(
        visitor_id: visitor_id,
        split_name: assignment.split_name,
        context: assignment.context,
        mixpanel_result: tracking_result
      )
    end
  end

  private

  def track
    return "failure" unless TestTrack.enabled?
    result = TestTrack.analytics.track(TestTrack::AnalyticsEvent.new(visitor_id, assignment))
    result ? "success" : "failure"
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
test_track_rails_client-4.0.0.alpha26 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha25 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha24 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha23 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha22 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha21 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha20 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha19 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha18 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha17 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha16 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha15 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha14 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha13 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha12 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha11 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha10 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-4.0.0.alpha9 app/models/test_track/notify_assignment_job.rb