diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 0985dc3f9..bdc1139d9 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -221,8 +221,6 @@ class ApplicationController < ActionController::Base helper_method :internal_navigation? def feed_style_preference - # TODO: Future functionality will let current_user override this value with UX preferences - # if current_user exists and has a different preference. Settings::UserExperience.feed_style end helper_method :feed_style_preference diff --git a/app/models/async_info.rb b/app/models/async_info.rb index b2f548b48..5c30cdbb2 100644 --- a/app/models/async_info.rb +++ b/app/models/async_info.rb @@ -5,6 +5,7 @@ # @see UserDecorator # @see ApplicationPolicy class AsyncInfo + include FieldTest::Helpers # @api public # # Generate a Hash of the relevant user data. @@ -46,7 +47,7 @@ class AsyncInfo trusted: user.trusted?, moderator_for_tags: user.moderator_for_tags, config_body_class: user.config_body_class, - feed_style: feed_style_preference, + feed_style: feed_style_preference_variable(user), created_at: user.created_at, admin: user.any_admin?, policies: [ @@ -75,4 +76,12 @@ class AsyncInfo rescue Pundit::NotAuthorizedError false end + + def feed_style_preference_variable(user) + after_date = user.registered_at >= Time.zone.parse("2024-02-20") + flag_on = FeatureFlag.enabled?(:feed_style_test_running) + return field_test(:feed_style_20240220, participant: user) if after_date && flag_on + + feed_style_preference + end end diff --git a/config/field_test.yml b/config/field_test.yml index a92bf690f..c0ed796aa 100644 --- a/config/field_test.yml +++ b/config/field_test.yml @@ -27,6 +27,27 @@ ################################################################################ ################################################################################ experiments: + feed_style_20240220: + started_at: 2024-02-20 + variants: + - basic + - rich + weights: + - 50 + - 50 + goals: + - user_creates_pageview + - user_creates_article_reaction + - user_creates_comment + - user_views_pages_on_at_least_two_different_days_within_a_week + - user_views_pages_on_at_least_four_different_days_within_a_week + - user_creates_article_reaction_on_four_different_days_within_a_week + - user_creates_comment_on_at_least_four_different_days_within_a_week + - user_views_pages_on_at_least_three_different_hours_within_a_day + - user_views_pages_on_at_least_four_different_hours_within_a_day + - user_views_pages_on_at_least_twelve_different_hours_within_five_days + - user_views_pages_on_at_least_nine_different_days_within_two_weeks + comments_to_display_20240129: started_at: 2024-01-29 variants: