Adding page view goal for experiments (#17696)
With comments, publishing articles, and reactions we had symmetry on two goals: - Create a _subject_ (e.g. Comment, Published Article, Reaction) - Create four _subjects_ within a week. For page views we only had "Create four _subjects_ within a week." This PR addes the "Create a _subject_". To do this required adjusting some tests as they were too specific in nature (looking at an expected count). In addition, in consultation with Jennie, I've updated the experiment order to better reflect some hierarchical importance. **Rollback considerations:** This also includes a feature flag that we can explicitly disable if we overload the application with workers handling reaction goals. Using `FeatureFlag.accessible?(:field_test_event_single_create_pageview)` returns `true` unless we explicitly disable this flag. Related to forem/forem#17673 Related to forem/forem#17669 Closes forem/forem#17691
This commit is contained in:
parent
ad7ad333bf
commit
127e3ac248
3 changed files with 28 additions and 11 deletions
|
|
@ -58,6 +58,11 @@ class AbExperiment
|
|||
end
|
||||
|
||||
def convert_pageview_goal(experiment:, experiment_start_date:)
|
||||
# TODO: Remove once we know that this test is not over-heating the application. That would be a
|
||||
# few days after the deploy to DEV of this change.
|
||||
if FeatureFlag.accessible?(:field_test_event_single_create_pageview)
|
||||
field_test_converted(experiment, participant: user, goal: goal) # base is someone viewed a page
|
||||
end
|
||||
pageview_goal(experiment,
|
||||
[7.days.ago, experiment_start_date].max,
|
||||
"DATE(created_at)",
|
||||
|
|
|
|||
|
|
@ -12,18 +12,20 @@ experiments:
|
|||
- 80
|
||||
- 20
|
||||
goals:
|
||||
- user_creates_pageview
|
||||
- user_creates_article_reaction
|
||||
- user_creates_comment
|
||||
- user_creates_comment_on_at_least_four_different_days_within_a_week
|
||||
- user_views_pages_on_at_least_four_different_days_within_a_week
|
||||
- user_views_pages_on_at_least_four_different_hours_within_a_day
|
||||
- user_views_pages_on_at_least_nine_different_days_within_two_weeks
|
||||
- user_views_pages_on_at_least_twelve_different_hours_within_five_days
|
||||
- user_publishes_post
|
||||
- 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_publishes_post_on_four_different_days_within_a_week
|
||||
# These are historical and may be userful
|
||||
- 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
|
||||
- user_publishes_post_at_least_two_times_within_week
|
||||
- user_publishes_post_at_least_two_times_within_two_weeks
|
||||
- user_publishes_post_on_four_different_days_within_a_week
|
||||
- user_creates_article_reaction
|
||||
- user_creates_article_reaction_on_four_different_days_within_a_week
|
||||
exclude:
|
||||
bots: true
|
||||
|
||||
|
|
|
|||
|
|
@ -125,6 +125,14 @@ RSpec.describe AbExperiment::GoalConversionHandler do
|
|||
field_test(AbExperiment::CURRENT_FEED_STRATEGY_EXPERIMENT, participant: user)
|
||||
end
|
||||
|
||||
it "records a field test when user views a page", :aggregate_failures do
|
||||
create(:page_view, user_id: user.id)
|
||||
handler.call
|
||||
expect(FieldTest::Event.last.field_test_membership.participant_id).to eq(user.id.to_s)
|
||||
expect(FieldTest::Event.pluck(:name))
|
||||
.to include(goal)
|
||||
end
|
||||
|
||||
it "records user_views_pages_on_at_least_four_different_days_within_a_week field test conversion",
|
||||
:aggregate_failures do
|
||||
7.times do |n|
|
||||
|
|
@ -164,7 +172,8 @@ RSpec.describe AbExperiment::GoalConversionHandler do
|
|||
create(:page_view, user_id: user.id, created_at: n.days.ago)
|
||||
end
|
||||
handler.call
|
||||
expect(FieldTest::Event.all.size).to be(0)
|
||||
expect(FieldTest::Event.pluck(:name))
|
||||
.not_to include("user_views_pages_on_at_least_twelve_different_hours_within_five_days")
|
||||
end
|
||||
|
||||
it "records user_views_pages_on_at_least_four_different_hours_within_a_day field test conversionn",
|
||||
|
|
@ -175,7 +184,7 @@ RSpec.describe AbExperiment::GoalConversionHandler do
|
|||
handler.call
|
||||
expect(FieldTest::Event.last.field_test_membership.participant_id).to eq(user.id.to_s)
|
||||
expect(FieldTest::Event.pluck(:name))
|
||||
.to include("user_views_pages_on_at_least_four_different_hours_within_a_day")
|
||||
.to eq([goal, "user_views_pages_on_at_least_four_different_hours_within_a_day"])
|
||||
end
|
||||
|
||||
it "does not record user_views_article_four_hours_in_day field test conversion for non-qualifying activity" do
|
||||
|
|
@ -183,7 +192,8 @@ RSpec.describe AbExperiment::GoalConversionHandler do
|
|||
create(:page_view, user_id: user.id, created_at: n.hours.ago)
|
||||
end
|
||||
handler.call
|
||||
expect(FieldTest::Event.all.size).to be(0)
|
||||
expect(FieldTest::Event.pluck(:name))
|
||||
.not_to include("user_views_pages_on_at_least_four_different_hours_within_a_day")
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue