Skip to content

Commit b0bdda6

Browse files
authored
Merge branch 'develop' into fix/506-amp-tag-detection
2 parents 45f7b4a + 1a2b1e7 commit b0bdda6

File tree

3 files changed

+90
-83
lines changed

3 files changed

+90
-83
lines changed

assets/js/modules/analytics/dashboard/dashboard-widget.js

Lines changed: 76 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -170,88 +170,84 @@ class AnalyticsDashboardWidget extends Component {
170170
{ ! receivingData && (
171171
error ? getDataErrorComponent( __( 'Analytics', 'google-site-kit' ), error, true, true, true ) : getNoDataComponent( __( 'Analytics', 'google-site-kit' ), true, true, true )
172172
) }
173-
{ receivingData && (
174-
<Fragment>
175-
<div className={ `
176-
mdc-layout-grid__cell
177-
mdc-layout-grid__cell--span-12
178-
${ wrapperClass }
179-
` }>
180-
<Layout
181-
header
182-
title={ sprintf( __( 'Audience overview for the last %s', 'google-site-kit' ), dateRangeFrom ) }
183-
headerCtaLabel={ __( 'See full stats in Analytics', 'google-site-kit' ) }
184-
headerCtaLink="http://analytics.google.com"
185-
>
186-
<AnalyticsDashboardWidgetOverview
187-
selectedStats={ selectedStats }
188-
handleStatSelection={ this.handleStatSelection }
189-
handleDataError={ this.handleDataError }
190-
handleDataSuccess={ this.handleDataSuccess }
191-
/>
192-
<AnalyticsDashboardWidgetSiteStats
193-
selectedStats={ selectedStats }
194-
series={ series }
195-
vAxes={ vAxes }
196-
dateRangeFrom={ dateRangeFrom }
197-
/>
198-
</Layout>
199-
</div>
200-
<div className={ `
201-
mdc-layout-grid__cell
202-
mdc-layout-grid__cell--span-12
203-
${ wrapperClass }
204-
` }>
205-
<Layout
206-
header
207-
footer
208-
title={ sprintf( __( 'Top content over the last %s', 'google-site-kit' ), dateRangeFrom ) }
209-
headerCtaLink="https://analytics.google.com"
210-
headerCtaLabel={ __( 'See full stats in Analytics', 'google-site-kit' ) }
211-
footerCtaLabel={ __( 'Analytics', 'google-site-kit' ) }
212-
footerCtaLink="https://analytics.google.com"
213-
>
214-
<AnalyticsDashboardWidgetTopPagesTable />
215-
</Layout>
216-
</div>
217-
<div className={ `
218-
mdc-layout-grid__cell
219-
mdc-layout-grid__cell--span-12
220-
${ wrapperClass }
221-
` }>
222-
<Layout
223-
header
224-
footer
225-
title={ sprintf( __( 'Top acquisition sources over the last %s', 'google-site-kit' ), dateRangeFrom ) }
226-
headerCtaLink="https://analytics.google.com"
227-
headerCtaLabel={ __( 'See full stats in Analytics', 'google-site-kit' ) }
228-
footerCtaLabel={ __( 'Analytics', 'google-site-kit' ) }
229-
footerCtaLink="https://analytics.google.com"
230-
>
231-
<div className="mdc-layout-grid">
232-
<div className="mdc-layout-grid__inner">
233-
<div className="
234-
mdc-layout-grid__cell
235-
mdc-layout-grid__cell--span-4-desktop
236-
mdc-layout-grid__cell--span-8-tablet
237-
mdc-layout-grid__cell--span-4-phone
238-
">
239-
<DashboardAcquisitionPieChart />
240-
</div>
241-
<div className="
242-
mdc-layout-grid__cell
243-
mdc-layout-grid__cell--span-8-desktop
244-
mdc-layout-grid__cell--span-8-tablet
245-
mdc-layout-grid__cell--span-4-phone
246-
">
247-
<AnalyticsDashboardWidgetTopAcquisitionSources />
248-
</div>
249-
</div>
173+
<div className={ `
174+
mdc-layout-grid__cell
175+
mdc-layout-grid__cell--span-12
176+
${ wrapperClass }
177+
` }>
178+
<Layout
179+
header
180+
title={ sprintf( __( 'Audience overview for the last %s', 'google-site-kit' ), dateRangeFrom ) }
181+
headerCtaLabel={ __( 'See full stats in Analytics', 'google-site-kit' ) }
182+
headerCtaLink="http://analytics.google.com"
183+
>
184+
<AnalyticsDashboardWidgetOverview
185+
selectedStats={ selectedStats }
186+
handleStatSelection={ this.handleStatSelection }
187+
handleDataError={ this.handleDataError }
188+
handleDataSuccess={ this.handleDataSuccess }
189+
/>
190+
<AnalyticsDashboardWidgetSiteStats
191+
selectedStats={ selectedStats }
192+
series={ series }
193+
vAxes={ vAxes }
194+
dateRangeFrom={ dateRangeFrom }
195+
/>
196+
</Layout>
197+
</div>
198+
<div className={ `
199+
mdc-layout-grid__cell
200+
mdc-layout-grid__cell--span-12
201+
${ wrapperClass }
202+
` }>
203+
<Layout
204+
header
205+
footer
206+
title={ sprintf( __( 'Top content over the last %s', 'google-site-kit' ), dateRangeFrom ) }
207+
headerCtaLink="https://analytics.google.com"
208+
headerCtaLabel={ __( 'See full stats in Analytics', 'google-site-kit' ) }
209+
footerCtaLabel={ __( 'Analytics', 'google-site-kit' ) }
210+
footerCtaLink="https://analytics.google.com"
211+
>
212+
<AnalyticsDashboardWidgetTopPagesTable />
213+
</Layout>
214+
</div>
215+
<div className={ `
216+
mdc-layout-grid__cell
217+
mdc-layout-grid__cell--span-12
218+
${ wrapperClass }
219+
` }>
220+
<Layout
221+
header
222+
footer
223+
title={ sprintf( __( 'Top acquisition sources over the last %s', 'google-site-kit' ), dateRangeFrom ) }
224+
headerCtaLink="https://analytics.google.com"
225+
headerCtaLabel={ __( 'See full stats in Analytics', 'google-site-kit' ) }
226+
footerCtaLabel={ __( 'Analytics', 'google-site-kit' ) }
227+
footerCtaLink="https://analytics.google.com"
228+
>
229+
<div className="mdc-layout-grid">
230+
<div className="mdc-layout-grid__inner">
231+
<div className="
232+
mdc-layout-grid__cell
233+
mdc-layout-grid__cell--span-4-desktop
234+
mdc-layout-grid__cell--span-8-tablet
235+
mdc-layout-grid__cell--span-4-phone
236+
">
237+
<DashboardAcquisitionPieChart />
250238
</div>
251-
</Layout>
239+
<div className="
240+
mdc-layout-grid__cell
241+
mdc-layout-grid__cell--span-8-desktop
242+
mdc-layout-grid__cell--span-8-tablet
243+
mdc-layout-grid__cell--span-4-phone
244+
">
245+
<AnalyticsDashboardWidgetTopAcquisitionSources />
246+
</div>
247+
</div>
252248
</div>
253-
</Fragment>
254-
) }
249+
</Layout>
250+
</div>
255251
<div className="
256252
mdc-layout-grid__cell
257253
mdc-layout-grid__cell--span-12

assets/js/modules/tagmanager/setup.js

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ class TagmanagerSetup extends Component {
133133
let errorMsg = '';
134134
const responseData = await data.get( TYPE_MODULES, 'tagmanager', 'accounts-containers', queryArgs );
135135

136+
if ( ! selectedAccount && 0 === responseData.accounts.length ) {
137+
errorCode = 'accountEmpty';
138+
errorMsg = __(
139+
'We didn’t find an associated Google Tag Manager account, would you like to set it up now? If you’ve just set up an account please re-fetch your account to sync it with Site Kit.',
140+
'google-site-kit'
141+
);
142+
}
143+
136144
// Verify if user has access to the selected account.
137145
if ( selectedAccount && ! responseData.accounts.find( ( account ) => account.accountId === selectedAccount ) ) {
138146
data.invalidateCacheGroup( TYPE_MODULES, 'tagmanager', 'accounts-containers' );
@@ -147,12 +155,15 @@ class TagmanagerSetup extends Component {
147155
responseData.containers.push( chooseContainer );
148156

149157
if ( this._isMounted ) {
158+
const accountId = responseData.accounts[ 0 ] ? responseData.accounts[ 0 ].accountId : null;
159+
const publicId = responseData.containers[ 0 ] ? responseData.containers[ 0 ].publicId : null;
160+
150161
this.setState( {
151162
isLoading: false,
152163
accounts: responseData.accounts,
153-
selectedAccount: ( selectedAccount ) ? selectedAccount : responseData.accounts[ 0 ].accountId,
164+
selectedAccount: ( selectedAccount ) ? selectedAccount : accountId,
154165
containers: responseData.containers,
155-
selectedContainer: ( selectedContainer ) ? selectedContainer : responseData.containers[ 0 ].publicId,
166+
selectedContainer: ( selectedContainer ) ? selectedContainer : publicId,
156167
refetch: false,
157168
errorCode,
158169
errorMsg,

includes/Modules/TagManager.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ protected function parse_data_response( $method, $datapoint, $response ) {
494494
'containers' => array(),
495495
);
496496
if ( 0 === count( $response['accounts'] ) ) {
497-
return new WP_Error( 'google_tagmanager_account_empty', __( 'We didn’t find an associated Google Tag Manager account, would you like to set it up now? If you’ve just set up an account please re-fetch your account to sync it with Site Kit.', 'google-site-kit' ), array( 'status' => 500 ) );
497+
return $response;
498498
}
499499
if ( is_array( $this->_list_accounts_data ) && isset( $this->_list_accounts_data['accountId'] ) ) {
500500
$account_id = $this->_list_accounts_data['accountId'];

0 commit comments

Comments
 (0)