Class: TestTrack::NotifyAssignmentJob

Inherits:
Object
  • Object
show all
Defined in:
app/models/test_track/notify_assignment_job.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ NotifyAssignmentJob

Returns a new instance of NotifyAssignmentJob.



4
5
6
7
8
9
10
11
12
# File 'app/models/test_track/notify_assignment_job.rb', line 4

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

Instance Attribute Details

#assignmentObject (readonly)

Returns the value of attribute assignment.



2
3
4
# File 'app/models/test_track/notify_assignment_job.rb', line 2

def assignment
  @assignment
end

#visitor_idObject (readonly)

Returns the value of attribute visitor_id.



2
3
4
# File 'app/models/test_track/notify_assignment_job.rb', line 2

def visitor_id
  @visitor_id
end

Instance Method Details

#performObject



14
15
16
17
18
19
20
21
22
23
24
# File 'app/models/test_track/notify_assignment_job.rb', line 14

def perform
  tracking_result = maybe_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