Class: TestTrack::WebSession

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

Constant Summary collapse

1.year

Instance Method Summary collapse

Constructor Details

#initialize(controller) ⇒ WebSession

Returns a new instance of WebSession.



4
5
6
# File 'app/models/test_track/web_session.rb', line 4

def initialize(controller)
  @controller = controller
end

Instance Method Details

#log_in!(identity, forget_current_visitor: nil) ⇒ Object



37
38
39
40
41
# File 'app/models/test_track/web_session.rb', line 37

def log_in!(identity, forget_current_visitor: nil)
  visitors.forget_unauthenticated! if forget_current_visitor
  visitors.authenticate!(identity)
  true
end

#manageObject



8
9
10
11
12
13
14
15
16
# File 'app/models/test_track/web_session.rb', line 8

def manage
  yield
ensure
  if current_visitor.id_loaded?
    manage_cookies!
    manage_response_headers!
  end
  visitors.notify_unsynced_assignments!
end

#sign_up!(identity) ⇒ Object



43
44
45
46
47
# File 'app/models/test_track/web_session.rb', line 43

def sign_up!(identity)
  visitors.authenticate!(identity)
  TestTrack.analytics.sign_up!(current_visitor.id)
  true
end

#state_hashObject



26
27
28
29
30
31
32
33
34
35
# File 'app/models/test_track/web_session.rb', line 26

def state_hash
  {
    url: TestTrack.public_url,
    cookieDomain: cookie_domain,
    cookieName: visitor_cookie_name,
    splits: current_visitor.split_registry.to_hash,
    assignments: current_visitor.assignment_json,
    experienceSamplingWeight: current_visitor.split_registry.experience_sampling_weight
  }
end

#visitor_dslObject



22
23
24
# File 'app/models/test_track/web_session.rb', line 22

def visitor_dsl
  TestTrack::VisitorDsl.new(current_visitor)
end

#visitor_dsl_for(identity) ⇒ Object



18
19
20
# File 'app/models/test_track/web_session.rb', line 18

def visitor_dsl_for(identity)
  TestTrack::VisitorDsl.new(visitors.for_identity(identity))
end