Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare for Popular Tasks AB test #3740

Merged
merged 1 commit into from
Aug 21, 2024

Conversation

unoduetre
Copy link
Contributor

@unoduetre unoduetre commented Aug 19, 2024

⚠️ This repo is Continuously Deployed: make sure you follow the guidance ⚠️

Follow these steps if you are doing a Rails upgrade.

What

Add AB testing logic to collection in preparation for the popular task AB test.

Allowed variants: A,B,C,Z

Control: C

Test name: PopularTasks alphagov/govuk-fastly#93

We should be able to merge this code now without users seeing any changes, ie before we have the list of links for each variants.

Why

So that all technical work is complete and ready to go.

Trello card

@govuk-ci govuk-ci temporarily deployed to collections-pr-3740 August 19, 2024 13:54 Inactive
@unoduetre unoduetre force-pushed the 2783-set-up-ab-test-logic-in-collections-m-l branch from c692d93 to 6a4e0b3 Compare August 19, 2024 14:02
@govuk-ci govuk-ci temporarily deployed to collections-pr-3740 August 19, 2024 14:02 Inactive
@unoduetre unoduetre force-pushed the 2783-set-up-ab-test-logic-in-collections-m-l branch from 6a4e0b3 to 7912eeb Compare August 19, 2024 14:17
@govuk-ci govuk-ci temporarily deployed to collections-pr-3740 August 19, 2024 14:17 Inactive
@unoduetre unoduetre force-pushed the 2783-set-up-ab-test-logic-in-collections-m-l branch from 7912eeb to ab23894 Compare August 19, 2024 14:28
@govuk-ci govuk-ci temporarily deployed to collections-pr-3740 August 19, 2024 14:28 Inactive
@unoduetre unoduetre force-pushed the 2783-set-up-ab-test-logic-in-collections-m-l branch from ab23894 to c8015fe Compare August 19, 2024 14:30
@govuk-ci govuk-ci temporarily deployed to collections-pr-3740 August 19, 2024 14:30 Inactive
@unoduetre unoduetre force-pushed the 2783-set-up-ab-test-logic-in-collections-m-l branch from c8015fe to f732073 Compare August 19, 2024 14:33
@govuk-ci govuk-ci temporarily deployed to collections-pr-3740 August 19, 2024 14:33 Inactive
@unoduetre unoduetre marked this pull request as ready for review August 19, 2024 14:37
Copy link
Contributor

@hannako hannako left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your work on this Mat

I've requested quite a few changes, as we need the popular tasks to be displayed for variants A and B on all 16 browse pages not just benefits and business. Sorry that wasn't made clearer to you.

I've made suggested changes which hopefully make sense and will help you get it ready for re-review - happy to pair on anything that's unclear.

end

def popular_tasks_page_under_test?
request.path.starts_with?(%r{/browse/business|/browse/benefits})
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We're AB testing across all 16 mainstream browse pages. I didn't make this decision clear enough on the trello tickets, so I can see why you've assumed otherwise.

So you'll need some regex here. This kind of thing?

def browse_page_under_test?
   /\/browse\/[a-z,-]*$/.match?(request.path)
end

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -3,8 +3,44 @@ def display_popular_links_for_slug?(slug)
I18n.exists?(slug.to_s, scope: "browse.popular_links")
end

def variant_a_popular_links(slug)
I18n.t(slug.to_s, scope: "browse.popular_links")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this meant to say I18n.t(slug.to_s, scope: "browse.popular_links_a") etc. Otherwise all these methods are fetching from the same key

Copy link
Contributor Author

@unoduetre unoduetre Aug 20, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, that's intentional. You mentioned that the work should be done in two stages, so when the actual tests are to be set up, another PR should simply switch those to e.g. popular_links_a etc. I can do it and now and copy the text instead, if that's your preference.

end

def variant_popular_links_for_slug(slug)
default_variant_popular_links = variant_c_popular_links(slug)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will work for the pages that already have popular tasks (business and benefits) but the c variant for the other 14 is no popular tasks section.

The method on line 2 (display_popular_links_for_slug?(slug)) can be rewritten to check if there's any control data in the locale file. If there's no data, the method returns false and hides the section.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@@ -17,3 +17,47 @@ en:
url: /self-assessment-tax-returns
- title: "Pay employers' PAYE"
url: /pay-paye-tax
popular_links_a:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the way you've structured the locale file will make it hard to review the next PR to add the popular task links. We'll have to scroll down to find a slug in three different sections to check the popular tasks for each variant. As we have 16 pages, that's not an insignificant burden!

I think it might be easier if you could add a variant_a, variant_b within each existing slug instead. For business and benefits, there would also need to be a control key.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

def variant_popular_links_for_slug(slug)
default_variant_popular_links = variant_c_popular_links(slug)

if no_popular_tasks_ab_test?
Copy link
Contributor

@hannako hannako Aug 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need

if popular_tasks_variant_a_page?
# show variant a links
elsif popular_tasks_variant_b_page?
# show variant b links
else (variant z or variant c)
# show original (links||nothing)
end

The links||nothing would come from default_variant_popular_links

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

app/helpers/browse_helper.rb Outdated Show resolved Hide resolved
@unoduetre unoduetre force-pushed the 2783-set-up-ab-test-logic-in-collections-m-l branch from f732073 to 8a9d302 Compare August 21, 2024 11:08
@govuk-ci govuk-ci temporarily deployed to collections-pr-3740 August 21, 2024 11:08 Inactive
Copy link
Contributor

@hannako hannako left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for reworking Mat.

@hannako hannako merged commit 3349fb2 into main Aug 21, 2024
14 checks passed
@hannako hannako deleted the 2783-set-up-ab-test-logic-in-collections-m-l branch August 21, 2024 12:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants