Class: TestTrack::WebSession
- Inherits:
-
Object
- Object
- TestTrack::WebSession
- Defined in:
- app/models/test_track/web_session.rb
Constant Summary collapse
- COOKIE_LIFESPAN =
Used for visitor cookie
1.year
Instance Method Summary collapse
-
#initialize(controller) ⇒ WebSession
constructor
A new instance of WebSession.
- #log_in!(identity, forget_current_visitor: nil) ⇒ Object
- #manage ⇒ Object
- #sign_up!(identity) ⇒ Object
- #state_hash ⇒ Object
- #visitor_dsl ⇒ Object
- #visitor_dsl_for(identity) ⇒ Object
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 |
#manage ⇒ Object
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_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_hash ⇒ Object
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: , cookieName: , splits: current_visitor.split_registry.to_hash, assignments: current_visitor.assignment_json, experienceSamplingWeight: current_visitor.split_registry.experience_sampling_weight } end |
#visitor_dsl ⇒ Object
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 |