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

Prevent Guardian Ad-Lite purchase by users who have either of adFree or rejectTracking benefits already #6675

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

Conversation

tjmw
Copy link
Member

@tjmw tjmw commented Jan 6, 2025

What are you doing in this PR?

If a non signed-in user already has the adFree or rejectTracking benefit, they shouldn't be able to purchase Guardian Ad-Lite. We're assuming that a signed-in user with adFree or rejectTracking wouldn't make it to the checkout as there's no user journey for this.

Trello Card

Why are you doing this?

It doesn't make sense to buy Guardian Ad-Lite if you get ad free reading or can already reject tracking.

How to test

I've tested locally and in CODE. When a signed out user already has the ad-free or reject-tracking benefit, an error is shown:

Screenshot 2025-01-10 at 11 55 40

A user without these benefits is able to purchase successfully.

How can we measure success?

Have we considered potential risks?

Accessibility test checklist

Screenshots

Copy link
Contributor

github-actions bot commented Jan 6, 2025

Size Change: +427 B (+0.02%)

Total Size: 2.39 MB

ℹ️ View Unchanged
Filename Size Change
./public/compiled-assets/javascripts/[countryGroupId]/events/router.js 90.5 kB 0 B
./public/compiled-assets/javascripts/[countryGroupId]/lazyRouter.js 93.3 kB 0 B
./public/compiled-assets/javascripts/[countryGroupId]/router.js 259 kB +75 B (+0.03%)
./public/compiled-assets/javascripts/ausMomentMap.js 108 kB 0 B
./public/compiled-assets/javascripts/contributionsRedirectStyles.js 20 B 0 B
./public/compiled-assets/javascripts/digitalSubscriptionLandingPage.js 228 kB +80 B (+0.04%)
./public/compiled-assets/javascripts/downForMaintenancePage.js 67.7 kB 0 B
./public/compiled-assets/javascripts/error404Page.js 67.6 kB 0 B
./public/compiled-assets/javascripts/error500Page.js 67.5 kB 0 B
./public/compiled-assets/javascripts/favicons.js 617 B 0 B
./public/compiled-assets/javascripts/paperSubscriptionCheckoutPage.js 166 kB +73 B (+0.04%)
./public/compiled-assets/javascripts/paperSubscriptionLandingPage.js 88 kB 0 B
./public/compiled-assets/javascripts/payPalErrorPage.js 66.1 kB 0 B
./public/compiled-assets/javascripts/payPalErrorPageStyles.js 20 B 0 B
./public/compiled-assets/javascripts/promotionTerms.js 73.9 kB 0 B
./public/compiled-assets/javascripts/subscriptionsLandingPage.js 73.2 kB 0 B
./public/compiled-assets/javascripts/subscriptionsRedemptionPage.js 119 kB +60 B (+0.05%)
./public/compiled-assets/javascripts/supporterPlusLandingPage.js 227 kB 0 B
./public/compiled-assets/javascripts/unsupportedBrowserStyles.js 20 B 0 B
./public/compiled-assets/javascripts/weeklySubscriptionCheckoutPage.js 163 kB +67 B (+0.04%)
./public/compiled-assets/javascripts/weeklySubscriptionLandingPage.js 88.1 kB 0 B
./public/compiled-assets/webpack/136.js 2.17 kB 0 B
./public/compiled-assets/webpack/186.js 3.35 kB 0 B
./public/compiled-assets/webpack/187.js 21.8 kB 0 B
./public/compiled-assets/webpack/3.js 19.2 kB 0 B
./public/compiled-assets/webpack/311.js 40.1 kB 0 B
./public/compiled-assets/webpack/344.js 2 kB 0 B
./public/compiled-assets/webpack/397.js 10.2 kB 0 B
./public/compiled-assets/webpack/426.js 41.1 kB +72 B (+0.18%)
./public/compiled-assets/webpack/643.js 22.4 kB 0 B
./public/compiled-assets/webpack/706.js 107 kB 0 B
./public/compiled-assets/webpack/754.js 9.98 kB 0 B
./public/compiled-assets/webpack/847.js 26 kB 0 B
./public/compiled-assets/webpack/checkout.js 14.3 kB 0 B
./public/compiled-assets/webpack/GuardianAdLiteLanding.js 9.09 kB 0 B
./public/compiled-assets/webpack/oneTimeCheckout.js 9.97 kB 0 B
./public/compiled-assets/webpack/ThankYou.js 1.07 kB 0 B

compressed-size-action

for {
benefits <- userBenefitsApiService
.getUserBenefits(userDetails.userDetails.identityId)
.leftMap(_ => ServerError("Something went wrong calling the user benefits API"))
Copy link
Member Author

Choose a reason for hiding this comment

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

If there's an issue with calling the user benefits API the purchase will be blocked and we'll show a generic error message to the user.

userDetails: UserDetails,
isSignedIn: Boolean,
)

private def createSubscription(implicit
settings: AllSettings,
request: CreateRequest,
): EitherT[Future, CreateSubscriptionError, CreateSubscriptionResponse] = {

val maybeLoggedInUserDetails =
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this now be "maybeUserDetails" since the signed in status can vary?

Copy link
Member Author

Choose a reason for hiding this comment

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

I had this same thought and decided to leave it as is because in the case of this val it's still either:

  1. None or
  2. The details of a user who is signed in.

I.e. maybeLoggedInUserDetails won't ever contain information about a user who isn't signed in. Though like you say it's true that the Option type UserDetailsWithSignedInStatus can represent this state. What do you reckon?

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, right. That's quite subtle but seems fine to leave as is

@tjmw tjmw marked this pull request as ready for review January 10, 2025 11:48
@rupertbates
Copy link
Member

Does this work for test users? We're going to need to query the code version of user-benefits api I think.

@tjmw tjmw changed the title Prevent Guardian Ad-Lite purchase by users who have the adFree benefit already Prevent Guardian Ad-Lite purchase by users who have either of adFree or rejectTracking benefits already Jan 17, 2025
@tjmw tjmw force-pushed the tw/prevent-guardian-light-purchase branch from 2bd1b98 to 1f5716c Compare January 17, 2025 15:28
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