Sha256: e2e9b457a11ac918a427007c0ddaeefd00f1e05a3899206f0b255e865c81d852

Contents?: true

Size: 927 Bytes

Versions: 26

Compression:

Stored size: 927 Bytes

Contents

class TestTrack::NotifyAssignmentJob
  attr_reader :mixpanel_distinct_id, :visitor_id, :assignment

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

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

  def perform
    TestTrack::Remote::AssignmentEvent.create!(
      visitor_id: visitor_id,
      split_name: assignment.split_name,
      context: assignment.context,
      mixpanel_result: track
    )
  end

  private

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

Version data entries

26 entries across 26 versions & 1 rubygems

Version Path
test_track_rails_client-2.0.0 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-1.3.0 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-1.2.0 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-1.1.0 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-1.0.0 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.20 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.19 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.18 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.17 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.16 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.15 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.14 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.13 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.12 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.11 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.10 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.9 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.8 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.7 app/models/test_track/notify_assignment_job.rb
test_track_rails_client-0.9.6 app/models/test_track/notify_assignment_job.rb