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

A few Ad Blocking Recovery components are rendered unconditionally #7179

Closed
kuasha420 opened this issue Jun 17, 2023 · 8 comments
Closed

A few Ad Blocking Recovery components are rendered unconditionally #7179

kuasha420 opened this issue Jun 17, 2023 · 8 comments
Labels
Module: AdSense Google AdSense module related issues P1 Medium priority Type: Bug Something isn't working

Comments

@kuasha420
Copy link
Contributor

kuasha420 commented Jun 17, 2023

Bug Description

As spotted by the eagle-eyed @aaemnnosttv, a few of the Ad Blocking Recovery "entrypoint" component are being rendered unconditionally instead of only being rendered when the adBlockerDetection feature flag is enabled which is not correct.

While this is not causing any bugs at the moment (because the components themselves doesn't cause any side effect that depends on things (ie. API endpoints) behind the the feature flag, it should always be rendered when the feature flag is enabled for consistently and to avoid the problems similar to one reported here for Key Metrics.


Do not alter or remove anything below. The following sections will be managed by moderators only.

Acceptance criteria

  • Any Ad Blocking Recovery components that are "entrypoint" to the Ad Blocking Recovery feature should only be rendered when the feature flag is enabled. This includes notification, Setup CTA, Settings CTA, Settings view and edit component, notices, banners etc.
  • Any Ad Blocking Recovery related logic (ie. call to any Ad Blocking Recovery specific API, actions or selectors) should be encapsulated inside the aforementioned components and should not bleed outwards.
  • Any redundant check for the adBlockerDetection feature flag inside the component or any of it's children should be removed as the component will not be rendered at all if the flag is not enabled.
  • Currently the AdBlockingRecoveryCTA and AdBlockingRecoveryToggle components are rendered unconditionally in SettingsForm and SettingsView but this may not be an exhausting list.

Implementation Brief

Test Coverage

  • No new tests needed; make sure the existing tests pass

QA Brief

  • Enable the adBlockerDetection feature flag using a site that has AdSense set up and can see the Ad Blocker Detection settings in the AdSense settings.
  • Visit Site Kit Settings and load the AdSense module.
  • Ad Blocking Detection CTA should still be visible. There should be no browser console errors.
  • Disable the adBlockerDetection feature flag and visit AdSense settings. Ad Blocking Detection CTA should not appear in "Edit" mode for AdSense and there should be no browser console errors.

Changelog entry

  • Ensure Ad Blocking Recovery elements are only present when the feature is enabled.
@kuasha420 kuasha420 added P0 High priority P1 Medium priority Module: AdSense Google AdSense module related issues and removed P1 Medium priority labels Jun 17, 2023
@techanvil
Copy link
Collaborator

AC ✅

@techanvil techanvil assigned techanvil and unassigned techanvil Jun 21, 2023
@tofumatt tofumatt assigned tofumatt and unassigned tofumatt Jun 21, 2023
@aaemnnosttv aaemnnosttv self-assigned this Jun 21, 2023
@aaemnnosttv
Copy link
Collaborator

I've added notes on where they can be removed, but to whoever reviews the IB: what about amending these ACs to allow the existing checks to remain? 🤔

@tofumatt it depends on the case; I think most will not make sense to keep because checking this within a component that itself should only render when that feature/condition should be guarding its render would also require that you use that feature within every hook which may not be possible in some cases. So that's largely the issue here, which is that the check within the component does not protect against side-effects from hooks. For example, we wouldn't check if a module is active in every component, right? It depends on the component, but we always need to be mindful of the unconditional nature of hooks.

This same issue happened very recently with KMW: #6262 (comment)

If we really want to apply it at the component level, then we'd need to leverage an HOC, e.g. withFeature( 'foo' )( Component ) similar to how we use whenActive() for dashboard widgets. That still relies on implementing it at the individual component level for each though. Our convention has been to check the feature and { featureEnabled && <Component /> } everywhere else I can think of so I'd be a bit concerned about introducing a component-level guard like that which hides that condition if you were reading through and only saw <Component /> the way it is here.

The majority of ABD components will be rendered here so I'd so all of those shouldn't be a concern for this same reason.

Otherwise IB LGTM but I haven't verified the exhaustiveness of the components affected here.

@aaemnnosttv aaemnnosttv assigned tofumatt and unassigned aaemnnosttv Jun 21, 2023
@tofumatt
Copy link
Collaborator

@aaemnnosttv Fair point! I did think that as well—if the feature flag weren't enabled the selectors in those components would still run, so removing them makes sense.

I did check the components exhaustively, so this IB should be good-to-go now 🙂

@tofumatt tofumatt assigned aaemnnosttv and unassigned tofumatt Jun 22, 2023
@aaemnnosttv
Copy link
Collaborator

IB ✅

@aaemnnosttv aaemnnosttv removed their assignment Jun 23, 2023
@aaemnnosttv aaemnnosttv added Type: Bug Something isn't working P1 Medium priority and removed P0 High priority labels Jun 23, 2023
@tofumatt tofumatt self-assigned this Jun 23, 2023
@tofumatt tofumatt removed their assignment Jun 23, 2023
@nfmohit nfmohit assigned nfmohit and tofumatt and unassigned nfmohit Jun 25, 2023
@tofumatt tofumatt assigned nfmohit and unassigned tofumatt Jun 26, 2023
@nfmohit nfmohit removed their assignment Jun 26, 2023
@tofumatt tofumatt removed their assignment Jun 27, 2023
@wpdarren wpdarren self-assigned this Jun 27, 2023
@wpdarren
Copy link
Collaborator

wpdarren commented Jun 27, 2023

QA Update: ⚠️

@tofumatt this might not be related to this ticket but I have noticed on Site Kit Dashboard within the Monetization area, that the CTA for setting up ABR is not appearing. I am sure it was displaying previously, but maybe when I tested it, we used code in the console to trigger it - not 100% sure. Should it be appearing at this stage in engineering?

Verified:

  • With adBlockerDetection feature flag enabled and using a site that has AdSense set up, I can see the Ad Blocker Detection CTA in the AdSense edit settings. There are no browser console errors.

image

  • With adBlockerDetection feature flag disabled and using a site that has AdSense set up, the Ad Blocker Detection CTA in the AdSense edit settings. There are no browser console errors.

image

@tofumatt
Copy link
Collaborator

Do you mean it's not appearing when the Ad Blocker Detection feature flag is disabled? If so that should be fine.

If it was previously appearing with the feature flag enabled and still isn't… I don't think this should've caused that change, but let me know which it is. 🙂

@wpdarren
Copy link
Collaborator

@tofumatt the feature flag is enabled and the CTA is not appearing on the Site Kit dashboard. If it's not related to this issue I can move this on and flag this in the channel to Arafat.

@tofumatt tofumatt removed their assignment Jun 27, 2023
@wpdarren
Copy link
Collaborator

QA Update: ✅

The issue with the ABR CTA not appeaing on the Site Kit dashboard is outside of this ticket. Have raised it in Slack.

Verified:

  • With adBlockerDetection feature flag enabled and using a site that has AdSense set up, I can see the Ad Blocker Detection CTA in the AdSense edit settings. There are no browser console errors.

image

  • With adBlockerDetection feature flag disabled and using a site that has AdSense set up, the Ad Blocker Detection CTA in the AdSense edit settings. There are no browser console errors.

image

@wpdarren wpdarren removed their assignment Jun 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Module: AdSense Google AdSense module related issues P1 Medium priority Type: Bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants