google / site-kit-wp Public
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
Simplify AdSense account status detection function getAdSenseAccountStatus
#427
Comments
|
The action item for this issue that specifies "messages should be moved to This seems another good candidate for moving things into a data store rather than just to a different component. There's also the specification to "Use a switch statement at component mount to construct strings/data based on status/reason", but I don't know why we would only set this data on component mount. What's the reason for this specificity? I think we can construct the strings on render, not only on mount. I'm also unsure about "Also move calls to The main issue with that function—to my eyes—is how detached it is from the component rendering its content. I started an IB for this one, but that function seems to be doing a lot and isn't too documented so I might be missing things. |
Just a minor clarification, the
That's a fair point, however all these messages depend on the
I can't comment on this since I didn't write this (note that the "Acceptance criteria" are the "official" list of things to look out for), but I agree with you, this should happen in
Agreed, that makes more sense to me.
Indeed, and this is only the start to making it easier to follow and understand. Because of the complexity, I want to keep this issue fairly constrained to only moved all the variables dependent on the actual "source of truth" variables ( |
|
Btw the rest of the IB that you already wrote looks good (except for the detail about the strings being set, which I mentioned at the top of the above comment). Would be great if you could update it based on the discussion. |
|
IB |
Not yet written unfortunately, but I agree it would be safer to refactor with test coverage in place. Most of these are currently parked in Revisit Later. |
|
As mentioned: it would be safer to refactor this after E2E tests are implemented, but even without writing them as part of this PR (before changes are made), this looks to be a considerable/meticulous refactor. Right now the approach Because this involves AdSense as well (which we currently have a minimal local development/testing story for), I see this as a medium-sized issue because either development or QA will involve a user without a reliable AdSense account. |
|
@felixarntz CR |





Feature Description
In the AdSense module, the function
getAdSenseAccountStatusis responsible for determining the user's AdSense account status after AdSense is activated. Once the status is determined, the function currently returns all of the data needed to display the final state.We can simplify this function by returning only the status data, moving the strings to the components where they are displayed.
The
AdSenseModuleStatuscomponent callsgetAdSenseAccountStatuspassing the resulting status data and displaying one of two sub-componentsAdSenseSetupInstructionsandAdSenseInProcessStatuswhich then take responsibility for displaying the correct strings based on the status/reason.Action items for this Issue:
getAdSenseAccountStatusfunction to only return clientId, accountStatus & issue data points (client id is required to construct deep links).AdSenseSetupInstructionsorAdSenseInProcessStatus.sendAnalyticsTrackingEventout of the utility function up intoAdSenseModuleStatuswhere a single call can handle sending the tracking statusVerification
AdSenseSetupInstructionsandAdSenseInProcessStatus)Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
getAdSenseAccountStatus()function in JS should only returnclientId(AdSense client ID),accountStatus(slug such asno-accountorads-display-pendingfor example), andissue(a user-facing string with information about the problem if there is one).issuevariable must always be a user-facing string with a reason, or alternatively false. It must never be a camelCase string or another string that is not user-facing (since it is displayed to the user in theAdSenseSetupInstructionscomponent).AdSenseInProcessStatuscomponent).getAdSenseAccountStatus()function.Implementation Brief
{ ...this.state }spread (site-kit-wp/assets/js/modules/adsense/dashboard/adsense-module-status.js
Line 130 in b42304c
AdSenseSetupInstructionsrequires.getAdSenseAccountStatusshould return an object with only the following keys:accountStatus,clientId,issue.__()) ingetAdSenseAccountStatus(). Onlyissueshould be set, but this is user-facing content returned from the AdSense API. Other user-facing messages/strings generated in that function should be moved closer to the components that output the strings.sendAnalyticsTrackingEvent()calls to the component that actually renders the scenario they are tracking instead of in one large function.Changelog entry
The text was updated successfully, but these errors were encountered: