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

Don't check allowed sections or default off tags for affiliate links in frontend #27561

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

emma-imber
Copy link
Contributor

@emma-imber emma-imber commented Oct 25, 2024

What does this change?

This change removes the check for supported sections and default off tags for articles where showAffiliateLinks is not defined. We are moving to treat Composer as the source of truth for affiliate links, so if showAffiliateLinks is not defined for an article, we will default to not showing affiliate links. If affiliate links should be shown on an article, showAffiliateLinks should be defined.

This change has meant we can simplify the logic and function in frontend, and I have updated and removed some tests to reflect the logic change. I've also added comments to document the tests, as they were pretty opaque. The diff isn't super helpful for the test file, might be easier to read without the diff highlighting

@emma-imber emma-imber changed the title Don't check allowed sections for affiliate links in frontend Don't check allowed sections or default off tags for affiliate links in frontend Oct 30, 2024
@emma-imber emma-imber marked this pull request as ready for review October 30, 2024 15:14
@emma-imber emma-imber requested a review from a team as a code owner October 30, 2024 15:14
Copy link
Contributor

@deedeeh deedeeh left a comment

Choose a reason for hiding this comment

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

Thank you Emma for a great Dev time on Affiliate links which gave me confidence to review your PR ✨

} else {
supportedSections.contains(section) && !tagPaths.exists(path => defaultOffTags.contains(path))
}
} else false
} else false
Copy link
Contributor

@dskamiotis dskamiotis Nov 14, 2024

Choose a reason for hiding this comment

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

This makes it much clearer to understand, just confirming my understanding that the logic now defaults to not showing affiliate links if showAffiliateLinks is not defined?
To echo Dina the great dev time talk really helped understand the flow of affiliate 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.

Yep that's correct. In the cases that we want to show affiliate links, the value showAffiliateLinks should be defined. Defaulting to false is safer and shouldn't cause issues where we do want to see affiliate links

Copy link
Contributor

Choose a reason for hiding this comment

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

Great so unless we get showAffiliateLinks from composer (the new source of truth) we will not show them Im assuming 👍

Comment on lines -262 to -263
supportedSections = Configuration.affiliateLinks.affiliateLinkSections,
defaultOffTags = Configuration.affiliateLinks.defaultOffTags,
Copy link
Contributor

@dskamiotis dskamiotis Nov 14, 2024

Choose a reason for hiding this comment

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

Just confirming my understanding, uses similar logic as below to determine whether to add affiliate links?
Both functions have the same name shouldAddAffiliateLinks but serve slightly different purpose?
This one checking 2 paragraphs and the length of the second; and the function in HtmlCleaner being more towards checking the tags associated with the content?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This logic is in Composer so the duplication here isn't necessary

} else {
supportedSections.contains(section) && !tagPaths.exists(path => defaultOffTags.contains(path))
}
} else false
} else false
Copy link
Contributor

Choose a reason for hiding this comment

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

Great so unless we get showAffiliateLinks from composer (the new source of truth) we will not show them Im assuming 👍

@emma-imber emma-imber force-pushed the ei/tidy-affiliates-sections-logic branch from c6efb93 to d10baec Compare November 18, 2024 16:27
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