-
Notifications
You must be signed in to change notification settings - Fork 328
Enhancement/11435 Create EmailReporting Settings Analytics Disconnected notice #11831
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
base: develop
Are you sure you want to change the base?
Enhancement/11435 Create EmailReporting Settings Analytics Disconnected notice #11831
Conversation
|
Storybook is ready:
|
|
Build files for 3e286ab are ready:
|
|
Size Change: +459 B (+0.02%) Total Size: 2.19 MB ℹ️ View Unchanged
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @jimmymadon looking good in overall, I left you few comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can complete the coverage by including two more cases to verify that notice is not showing in these scenarios:
does not render when Analytics is activedoes not render if Analytics was once connected
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We usually preload settings, it will be beneficial to include new route to the googlesitekit_apifetch_preload_paths hook together with existing /core/user/data/email-reporting-settings prefetched route
| $this->settings = $settings; | ||
| public function __construct( Email_Reporting_Settings $settings, Options $options ) { | ||
| $this->settings = $settings; | ||
| $this->was_analytics_4_connected = new Was_Analytics_4_Connected( $options ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is not the best place to instantiate the Was_Analytics_4_Connected, we should instantiate it in the constructor of Google\Site_Kit\Core\Email_Reporting\Email_Reporting and pass it as DI to the REST_Email_Reporting_Controller when instantiating it, so only an instance is received and set as class property here
| * @access private | ||
| * @ignore | ||
| */ | ||
| class Was_Analytics_4_Connected extends Setting { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets include get_default method to return false by default to value is always returned/set and get_sanitize_callback with return 'boolval' to have established pattern of sanitising fields on save
| $was_analytics_4_connected = new Was_Analytics_4_Connected( $this->options ); | ||
| $was_analytics_4_connected->set( true ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although I like the simplified approach by marking the settings directly on deactivation instead of listening to the settings change, instantiating Email_Reporting settings cross namespace this way isn't the best design. I would propose we create a new action here, for example do_action('googlesitekit_analytics_4_on_deactivation') or something similar and then hook into it from Google\Site_Kit\Core\Email_Reporting\Email_Reporting::register where Was_Analytics_4_Connected instance is already set.
I would like to get @eugene-manuilov thoughts on this too before we add a new hook here
Summary
Addresses issue:
<EmailReportingSettingsAnalyticsDisconnectedNotice>settings analytics disconnected inline notice component #11435Relevant technical choices
PR Author Checklist
Do not alter or remove anything below. The following sections will be managed by moderators only.
Code Reviewer Checklist
Merge Reviewer Checklist