Closed nfmohit closed 1 month ago
Thank you for the IB, @ankitrox ! Please take a look at my comments below:
- Return if module is not connected.
Let's also wait for getModules
to resolve before we check for the module's connection status.
- If more than an hour has passed since last sync, dispatch an action
syncPublicationOnboardingState
which would update the settings on server as well as in the local state for the module.
It would also be beneficial to mention that this should also run if getPublicationOnboardingStateLastSyncedAtMs
is not set, i.e. 0
as well.
Please let me know if you have any questions, thank you!
Thank you @nfmohit .
I have updated the couple of points mentioned in the feedback.
Thank you @ankitrox ! I have made some small improvements to the IB, namely:
undefined
if getModules
has not resolved, simply using resolveSelect
should be sufficient.The IB LGTM 👍 ✅
@kuasha420 has addressed this correctly in his PR but I just wanted to note how we should not be introducing any module-specific effects/coupling into core components like DashboardEntryPoint
or DashboardMainApp
. See #8211
Not sure if we need to update the QAB but I tried to set it up but I can't get the 'GET:modules/reader-revenue-manager/data/publications' request.
Video is attached for reference:
Hi @kelvinballoo, I just tested develop and the endpoint is correct and is getting hit. Can you try again? I'm not sure why it didn't work for you, maybe the zip on develop didn't update correctly.
Hi @kuasha420 , thanks. I've been able to get the request now:
From where do I actually find the time stamp though? ⚠️
I ran the snippet googlesitekit.data.select('modules/reader-revenue-manager').getSettings()
but I don't see anything related to timestamp from there:
Hi @kelvinballoo Sorry for the confusion. The timestamp is stored as publicationOnboardingStateLastSyncedAtMs
which is 0
in your screenshot. Hope that clears it up.
Hi @kuasha420 Noted that publicationOnboardingStateLastSyncedAtMs being 0 is the timestamped. One follow up question from there:
Once 1 hour has passed, revisiting the dashboard should do the sync again using the endpoint and update the timestamp accordingly.
What am I expecting for the update to the timestamp? 1 for 1 hour ? Or any other value?
Hi @kuasha420 , as per our sync, I'm always getting the publicationOnboardingStateLastSyncedAtMs
as 0, even the first round or after 1 hour+.
Assigning to you for investigation.
@kelvinballoo Moving this back to QA now that #9163 has been merged, as @kuasha420 mentioned that it should address the issue here https://github.com/google/site-kit-wp/pull/9163#pullrequestreview-2225486186
Tested this and it's looking good now. Moving ticket to Approval.
In the network tab, there is a request to GET:modules/reader-revenue-manager/data/publications and the publicationOnboardingStateLastSyncedAtMs was updated to the time the request was triggered. ✅
For subsequent refreshes in the next 1 hour, there was no request to the above endpoint and timestamp remain unchanged. ✅
Once 1 hour has passed, revisiting the dashboard does the sync again using the endpoint and updates the timestamp accordingly. ✅
Feature Description
The
maybeSyncPublicationOnboardingState()
action should be implemented for the Reader Revenue Manager module that periodically dispatches thesyncPublicationOnboardingState()
action (once every hour) to sync the value of thepublicationOnboardingState
module setting.maybeSyncPublicationOnboardingState()
action should be dispatched in the Site Kit dashboard on load, similar to how it is done forsyncGoogleTagSettings()
.Do not alter or remove anything below. The following sections will be managed by moderators only.
Acceptance criteria
maybeSyncPublicationOnboardingState()
action should be implemented for themodules/reader-revenue-manager
data store.publicationOnboardingStateLastSyncedAtMs
module setting and determine if it has been more than an hour since the last sync. If so, thesyncPublicationOnboardingState()
action should be dispatched.maybeSyncPublicationOnboardingState()
action should be dispatched in the Site Kit dashboard on load, similar to how it is done forsyncGoogleTagSettings()
.Implementation Brief
assets/js/components/DashboardEntryPoint.js
, collect actions object of RRM module usinguseDispatch
rrmActions?.maybeSyncPublicationOnboardingState()
insideuseMount
hook.maybeSyncPublicationOnboardingState
insideassets/js/module/reader-revenue-manager/datastore/publications.js
getModules
to resolved.null
if module is not connected.getSettings
selector on module and wait for it to be resolved so that settings are available before we make another check. Refer this for similar approach.getPublicationOnboardingStateLastSyncedAtMs
selector on module. If the value is present and an hour has not passed since last sync, return from the action and do nothing. Refer here.syncPublicationOnboardingState
which would update the settings on server as well as in the local state for the module based on following.getPublicationOnboardingStateLastSyncedAtMs
is zero.Test Coverage
Add tests for
maybeSyncPublicationOnboardingState
action with different values forpublicationOnboardingStateLastSyncedAtMs
setting.QA Brief
ONBOARDING_STATE_UNSPECIFIED
andpublicationOnboardingStateLastSyncedAtMs
is zero. This can be verified by usinggooglesitekit.data.select('modules/reader-revenue-manager').getSettings()
.GET:modules/reader-revenue-manager/data/publications
and thepublicationOnboardingStateLastSyncedAtMs
should be updated. Use the above snippet to verify the timestamp.Changelog entry