Class: Labkit::UserExperienceSli::Current
- Inherits:
-
ActiveSupport::CurrentAttributes
- Object
- ActiveSupport::CurrentAttributes
- Labkit::UserExperienceSli::Current
- Defined in:
- lib/labkit/user_experience_sli/current.rb
Overview
The ‘Current` class represents a container for the current set of `Labkit::UserExperienceSli::Experience` instances started and not yet completed.
It uses ‘ActiveSupport::CurrentAttributes` to provide a thread-safe way to store and access experiences throughout the request and background job lifecycle.
Example usage:
Labkit::UserExperienceSli::Current.active_experiences << my_experience
Labkit::UserExperienceSli::Current.rehydrate("create_merge_request", "start_time" => "2025-08-22T10:02:15.237Z")
Constant Summary collapse
- AGGREGATION_KEY =
'labkit_user_experiences'
Instance Method Summary collapse
Instance Method Details
#active_experiences ⇒ Object
23 24 25 |
# File 'lib/labkit/user_experience_sli/current.rb', line 23 def active_experiences self._active_experiences ||= {} end |
#rehydrate(experience_id, **data) ⇒ Object
27 28 29 30 31 |
# File 'lib/labkit/user_experience_sli/current.rb', line 27 def rehydrate(experience_id, **data) instance = Labkit::UserExperienceSli.get(experience_id).rehydrate(data) active_experiences[instance.id] = instance instance end |