Skip to content

Commit 0c0865f

Browse files
committed
Merge branch 'develop' into enhancement/11722-ga-event-analytics-setup.
2 parents 54cd414 + 8c023da commit 0c0865f

18 files changed

+298
-23
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Test Credentials
2+
3+
on:
4+
workflow_dispatch:
5+
6+
permissions:
7+
contents: read
8+
9+
concurrency:
10+
group: test-credentials-${{ github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
test-gcp-credentials:
15+
name: Test GCP credentials
16+
runs-on: ubuntu-latest
17+
timeout-minutes: 5
18+
steps:
19+
- uses: google-github-actions/auth@v3
20+
with:
21+
credentials_json: ${{ secrets.TEST_GCP_CREDENTIALS }}
22+
- uses: google-github-actions/setup-gcloud@v2
23+
- run: gcloud config get-value project > /dev/null && echo "GCP credentials test succeeded"
24+
25+
test-gh-bot-token:
26+
name: Test GitHub bot token
27+
runs-on: ubuntu-latest
28+
timeout-minutes: 5
29+
steps:
30+
- run: gh api user --jq '.login'
31+
env:
32+
GITHUB_TOKEN: ${{ secrets.TEST_GH_BOT_TOKEN }}
33+
34+
test-zenhub-gql-api-token:
35+
name: Test Zenhub GraphQL API token
36+
runs-on: ubuntu-latest
37+
timeout-minutes: 5
38+
steps:
39+
- run: |
40+
curl -X POST https://api.zenhub.com/public/graphql \
41+
-H "Authorization: Bearer $ZENHUB_GQL_API_TOKEN" \
42+
-H "Content-Type: application/json" \
43+
-d '{"query": "{ viewer { githubUser { login } } }"}' \
44+
--fail --silent --show-error
45+
env:
46+
ZENHUB_GQL_API_TOKEN: ${{ secrets.TEST_ZENHUB_GQL_API_TOKEN }}
47+

assets/js/components/SelectionPanel/index.stories.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,8 @@ function Template( {
105105
export const Default = Template.bind( {} );
106106
Default.storyName = 'Default';
107107
Default.scenario = {
108-
delay: 1500,
108+
readySelector:
109+
'.googlesitekit-selection-panel-item:first-of-type .mdc-checkbox__native-control:focus',
109110
};
110111

111112
export const WithSavedItems = Template.bind( {} );

assets/js/components/wp-dashboard/WPDashboardWidgets.stories.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ ReadyWithActivateAnalyticsCTA.args = {
116116
},
117117
};
118118

119-
ReadyWithActivateAnalyticsCTA.scenario = {
120-
// delay: 6000, // This extra delay is required to fix unstable VRTs. TODO: remove if not required.
121-
};
119+
ReadyWithActivateAnalyticsCTA.scenario = {};
122120

123121
export const ReadyWithCompleteAnalyticsActivationCTA = Template.bind( {} );
124122
ReadyWithCompleteAnalyticsActivationCTA.storyName =

assets/js/modules/analytics-4/components/dashboard/DashboardAllTrafficWidgetGA4/indexEntityDashboard.stories.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,12 @@ const widgetComponentProps = getWidgetComponentProps(
4949
);
5050

5151
function Template() {
52-
return <DashboardAllTrafficWidgetGA4 { ...widgetComponentProps } />;
52+
// Min height added to fix rare VRT instability where the mobile VRT for Zero Data was not capturing the full height.
53+
return (
54+
<div style={ { minHeight: '980px' } }>
55+
<DashboardAllTrafficWidgetGA4 { ...widgetComponentProps } />
56+
</div>
57+
);
5358
}
5459

5560
const baseAllTrafficOptions = {
@@ -167,7 +172,7 @@ EntityDashboardLoaded.args = {
167172
};
168173
EntityDashboardLoaded.scenario = {
169174
readySelector: '[id^="googlesitekit-chart-"] svg',
170-
delay: 200,
175+
delay: 400, // This extended delay is required to fix rare VRT instability where the chart in this scenario does not render in the standard delay.
171176
};
172177

173178
export const EntityDashboardLoading = Template.bind( {} );
@@ -225,7 +230,7 @@ EntityDashboardDataUnavailable.args = {
225230
};
226231
EntityDashboardDataUnavailable.scenario = {
227232
readySelector: '[id^="googlesitekit-chart-"] svg',
228-
delay: 200,
233+
delay: 400, // This extended delay is required to fix rare VRT instability where the chart in this scenario does not render in the standard delay.
229234
};
230235

231236
export const EntityDashboardZeroData = Template.bind( {} );
@@ -269,7 +274,7 @@ EntityDashboardZeroData.args = {
269274
};
270275
EntityDashboardZeroData.scenario = {
271276
readySelector: '[id^="googlesitekit-chart-"] svg',
272-
delay: 200,
277+
delay: 400, // This extended delay is required to fix rare VRT instability where the chart in this scenario does not render in the standard delay.
273278
};
274279

275280
export const EntityDashboardError = Template.bind( {} );
@@ -316,7 +321,7 @@ EntityDashboardOneRowOfData.args = {
316321
};
317322
EntityDashboardOneRowOfData.scenario = {
318323
readySelector: '[id^="googlesitekit-chart-"] svg',
319-
delay: 200,
324+
delay: 400, // This extended delay is required to fix rare VRT instability where the chart in this scenario does not render in the standard delay.
320325
};
321326

322327
export const NoDataInComparisonDateRange = Template.bind( {} );
@@ -332,7 +337,7 @@ NoDataInComparisonDateRange.args = {
332337
};
333338
NoDataInComparisonDateRange.scenario = {
334339
readySelector: '[id^="googlesitekit-chart-"] svg',
335-
delay: 200,
340+
delay: 400, // This extended delay is required to fix rare VRT instability where the chart in this scenario does not render in the standard delay.
336341
};
337342

338343
export default {

assets/js/modules/analytics-4/components/dashboard/DashboardAllTrafficWidgetGA4/indexMainDashboard.stories.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ MainDashboardLoaded.args = {
173173
};
174174
MainDashboardLoaded.scenario = {
175175
readySelector: '[id^="googlesitekit-chart-"] svg',
176-
delay: 200,
176+
delay: 400, // This extended delay is required to fix rare VRT instability where the chart in this scenario does not render in the standard delay.
177177
};
178178

179179
export const MainDashboardLoading = Template.bind( {} );
@@ -235,7 +235,7 @@ MainDashboardDataUnavailable.args = {
235235
};
236236
MainDashboardDataUnavailable.scenario = {
237237
readySelector: '[id^="googlesitekit-chart-"] svg',
238-
delay: 200,
238+
delay: 400, // This extended delay is required to fix rare VRT instability where the chart in this scenario does not render in the standard delay.
239239
};
240240

241241
export const MainDashboardZeroData = Template.bind( {} );
@@ -279,7 +279,7 @@ MainDashboardZeroData.args = {
279279
};
280280
MainDashboardZeroData.scenario = {
281281
readySelector: '[id^="googlesitekit-chart-"] svg',
282-
delay: 200,
282+
delay: 400, // This extended delay is required to fix rare VRT instability where the chart in this scenario does not render in the standard delay.
283283
};
284284

285285
export const MainDashboardError = Template.bind( {} );
@@ -326,7 +326,7 @@ MainDashboardOneRowOfData.args = {
326326
};
327327
MainDashboardOneRowOfData.scenario = {
328328
readySelector: '[id^="googlesitekit-chart-"] svg',
329-
delay: 200,
329+
delay: 400, // This extended delay is required to fix rare VRT instability where the chart in this scenario does not render in the standard delay.
330330
};
331331

332332
export const NoDataInComparisonDateRange = Template.bind( {} );
@@ -342,7 +342,7 @@ NoDataInComparisonDateRange.args = {
342342
};
343343
NoDataInComparisonDateRange.scenario = {
344344
readySelector: '[id^="googlesitekit-chart-"] svg',
345-
delay: 200,
345+
delay: 400, // This extended delay is required to fix rare VRT instability where the chart in this scenario does not render in the standard delay.
346346
};
347347

348348
export default {

assets/js/modules/search-console/components/dashboard/SearchFunnelWidgetGA4/index.stories.js

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -294,9 +294,9 @@ ReadyWithActivateAnalyticsCTA.args = {
294294
provideSearchConsoleMockReport( registry, searchConsoleArgs );
295295
},
296296
};
297-
298297
ReadyWithActivateAnalyticsCTA.scenario = {
299-
delay: 3000,
298+
readySelector: '[id^="googlesitekit-chart-"] svg',
299+
delay: 400, // This extended delay is required to fix rare VRT instability where the chart in this scenario does not render in the standard delay.
300300
};
301301

302302
export const ReadyWithCompleteAnalyticsActivationCTA = Template.bind( {} );
@@ -336,9 +336,9 @@ ReadyWithCreateKeyEventCTA.args = {
336336
}
337337
},
338338
};
339-
340339
ReadyWithCreateKeyEventCTA.scenario = {
341-
delay: 3000,
340+
readySelector: '[id^="googlesitekit-chart-"] svg',
341+
delay: 400, // This extended delay is required to fix rare VRT instability where the chart in this scenario does not render in the standard delay.
342342
};
343343

344344
export const Loading = Template.bind( {} );
@@ -485,7 +485,10 @@ NoDataInComparisonDateRange.args = {
485485
}
486486
},
487487
};
488-
NoDataInComparisonDateRange.scenario = {};
488+
NoDataInComparisonDateRange.scenario = {
489+
readySelector: '[id^="googlesitekit-chart-"] svg',
490+
delay: 400, // This extended delay is required to fix rare VRT instability where the chart in this scenario does not render in the standard delay.
491+
};
489492

490493
export default {
491494
title: 'Modules/SearchConsole/Widgets/SearchFunnelWidgetGA4',

includes/Core/Email_Reporting/Email_Reporting.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,14 @@ class Email_Reporting {
105105
*/
106106
protected $initiator_task;
107107

108+
/**
109+
* Monitor task instance.
110+
*
111+
* @since n.e.x.t
112+
* @var Monitor_Task
113+
*/
114+
protected $monitor_task;
115+
108116
/**
109117
* Worker task instance.
110118
*
@@ -145,6 +153,7 @@ public function __construct(
145153
$this->email_log = new Email_Log( $this->context );
146154
$this->scheduler = new Email_Reporting_Scheduler( $frequency_planner );
147155
$this->initiator_task = new Initiator_Task( $this->scheduler, $subscribed_users_query );
156+
$this->monitor_task = new Monitor_Task( $this->scheduler, $this->settings );
148157
$this->worker_task = new Worker_Task( $max_execution_limiter, $batch_query, $this->scheduler );
149158
}
150159

@@ -163,8 +172,10 @@ public function register() {
163172

164173
if ( $this->settings->is_email_reporting_enabled() ) {
165174
$this->scheduler->schedule_initiator_events();
175+
$this->scheduler->schedule_monitor();
166176

167177
add_action( Email_Reporting_Scheduler::ACTION_INITIATOR, array( $this->initiator_task, 'handle_callback_action' ), 10, 1 );
178+
add_action( Email_Reporting_Scheduler::ACTION_MONITOR, array( $this->monitor_task, 'handle_monitor_action' ) );
168179
add_action( Email_Reporting_Scheduler::ACTION_WORKER, array( $this->worker_task, 'handle_callback_action' ), 10, 3 );
169180

170181
} else {
@@ -178,6 +189,7 @@ function ( $old_value, $new_value ) {
178189

179190
if ( $is_enabled && ! $was_enabled ) {
180191
$this->scheduler->schedule_initiator_events();
192+
$this->scheduler->schedule_monitor();
181193
return;
182194
}
183195

includes/Core/Email_Reporting/Email_Reporting_Scheduler.php

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ class Email_Reporting_Scheduler {
2424
const ACTION_INITIATOR = 'googlesitekit_email_reporting_initiator';
2525
const ACTION_WORKER = 'googlesitekit_email_reporting_worker';
2626
const ACTION_FALLBACK = 'googlesitekit_email_reporting_fallback';
27+
const ACTION_MONITOR = 'googlesitekit_email_reporting_monitor';
2728

2829
/**
2930
* Frequency planner instance.
@@ -122,13 +123,26 @@ public function schedule_fallback( $frequency, $timestamp, $delay = HOUR_IN_SECO
122123
wp_schedule_single_event( $timestamp + $delay, self::ACTION_FALLBACK, array( $frequency ) );
123124
}
124125

126+
/**
127+
* Ensures the monitor event is scheduled daily.
128+
*
129+
* @since n.e.x.t
130+
*/
131+
public function schedule_monitor() {
132+
if ( wp_next_scheduled( self::ACTION_MONITOR ) ) {
133+
return;
134+
}
135+
136+
wp_schedule_event( time(), 'daily', self::ACTION_MONITOR );
137+
}
138+
125139
/**
126140
* Unschedules all email reporting related events.
127141
*
128142
* @since n.e.x.t
129143
*/
130144
public function unschedule_all() {
131-
foreach ( array( self::ACTION_INITIATOR, self::ACTION_WORKER, self::ACTION_FALLBACK ) as $hook ) {
145+
foreach ( array( self::ACTION_INITIATOR, self::ACTION_WORKER, self::ACTION_FALLBACK, self::ACTION_MONITOR ) as $hook ) {
132146
wp_unschedule_hook( $hook );
133147
}
134148
}
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
<?php
2+
/**
3+
* Class Google\Site_Kit\Core\Email_Reporting\Monitor_Task
4+
*
5+
* @package Google\Site_Kit\Core\Email_Reporting
6+
* @copyright 2025 Google LLC
7+
* @license https://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
8+
* @link https://sitekit.withgoogle.com
9+
*/
10+
11+
namespace Google\Site_Kit\Core\Email_Reporting;
12+
13+
use Google\Site_Kit\Core\User\Email_Reporting_Settings as User_Email_Reporting_Settings;
14+
15+
/**
16+
* Restores missing initiator schedules for email reporting.
17+
*
18+
* @since n.e.x.t
19+
* @access private
20+
* @ignore
21+
*/
22+
class Monitor_Task {
23+
24+
/**
25+
* Scheduler instance.
26+
*
27+
* @since n.e.x.t
28+
*
29+
* @var Email_Reporting_Scheduler
30+
*/
31+
private $scheduler;
32+
33+
/**
34+
* Settings instance.
35+
*
36+
* @since n.e.x.t
37+
*
38+
* @var Email_Reporting_Settings
39+
*/
40+
private $settings;
41+
42+
/**
43+
* Constructor.
44+
*
45+
* @since n.e.x.t
46+
*
47+
* @param Email_Reporting_Scheduler $scheduler Scheduler instance.
48+
* @param Email_Reporting_Settings $settings Email reporting settings.
49+
*/
50+
public function __construct( Email_Reporting_Scheduler $scheduler, Email_Reporting_Settings $settings ) {
51+
$this->scheduler = $scheduler;
52+
$this->settings = $settings;
53+
}
54+
55+
/**
56+
* Handles the monitor cron callback.
57+
*
58+
* The monitor ensures each initiator schedule exists and recreates any
59+
* missing ones without disturbing existing events.
60+
*
61+
* @since n.e.x.t
62+
*/
63+
public function handle_monitor_action() {
64+
if ( ! $this->settings->is_email_reporting_enabled() ) {
65+
return;
66+
}
67+
68+
foreach ( array( User_Email_Reporting_Settings::FREQUENCY_WEEKLY, User_Email_Reporting_Settings::FREQUENCY_MONTHLY, User_Email_Reporting_Settings::FREQUENCY_QUARTERLY ) as $frequency ) {
69+
if ( wp_next_scheduled( Email_Reporting_Scheduler::ACTION_INITIATOR, array( $frequency ) ) ) {
70+
continue;
71+
}
72+
73+
$this->scheduler->schedule_initiator_once( $frequency );
74+
}
75+
}
76+
}

includes/Core/Util/Uninstallation.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ class Uninstallation {
6060
Email_Reporting_Scheduler::ACTION_INITIATOR,
6161
Email_Reporting_Scheduler::ACTION_WORKER,
6262
Email_Reporting_Scheduler::ACTION_FALLBACK,
63+
Email_Reporting_Scheduler::ACTION_MONITOR,
6364
OAuth_Client::CRON_REFRESH_PROFILE_DATA,
6465
Remote_Features_Cron::CRON_ACTION,
6566
Synchronize_AdSenseLinked::CRON_SYNCHRONIZE_ADSENSE_LINKED,

0 commit comments

Comments
 (0)