Skip to content

Commit

Permalink
Merge branch 'develop' into enhance/#8176-rest-ds-for-audience-settings.
Browse files Browse the repository at this point in the history
  • Loading branch information
hussain-t committed Mar 20, 2024
2 parents 97ca77d + c501134 commit e5c381f
Show file tree
Hide file tree
Showing 655 changed files with 1,793 additions and 40,078 deletions.
2 changes: 1 addition & 1 deletion .storybook/fetch-mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function fetchMockCatchAll() {
'/google-site-kit/v1/modules/search-console/data/searchanalytics'
) ||
url.startsWith(
'/google-site-kit/v1/modules/analytics/data/report'
'/google-site-kit/v1/modules/analytics-4/data/report'
)
) {
return {
Expand Down
15 changes: 8 additions & 7 deletions assets/js/components/ActivateAnalyticsCTA.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,23 @@ import { __ } from '@wordpress/i18n';
import { SpinnerButton } from 'googlesitekit-components';
import Data from 'googlesitekit-data';
import { CORE_MODULES } from '../googlesitekit/modules/datastore/constants';
import { MODULES_ANALYTICS } from '../../js/modules/analytics/datastore/constants';
import { MODULES_ANALYTICS_4 } from '../modules/analytics-4/datastore/constants';
import { CORE_LOCATION } from '../../js/googlesitekit/datastore/location/constants';
import useActivateModuleCallback from '../hooks/useActivateModuleCallback';
import useCompleteModuleActivationCallback from '../hooks/useCompleteModuleActivationCallback';
import { useDebounce } from '../hooks/useDebounce';
const { useSelect } = Data;

export default function ActivateAnalyticsCTA( { children } ) {
const activateModuleCallback = useActivateModuleCallback( 'analytics' );
const activateModuleCallback = useActivateModuleCallback( 'analytics-4' );
const completeModuleActivationCallback =
useCompleteModuleActivationCallback( 'analytics' );
useCompleteModuleActivationCallback( 'analytics-4' );
const analyticsModuleActive = useSelect( ( select ) =>
select( CORE_MODULES ).isModuleActive( 'analytics' )
select( CORE_MODULES ).isModuleActive( 'analytics-4' )
);

const analyticsModuleAvailable = useSelect( ( select ) =>
select( CORE_MODULES ).isModuleAvailable( 'analytics' )
select( CORE_MODULES ).isModuleAvailable( 'analytics-4' )
);
const [ inProgress, setInProgress ] = useState( false );

Expand All @@ -58,7 +58,8 @@ export default function ActivateAnalyticsCTA( { children } ) {
return false;
}

const adminReauthURL = select( MODULES_ANALYTICS ).getAdminReauthURL();
const adminReauthURL =
select( MODULES_ANALYTICS_4 ).getAdminReauthURL();

if ( ! adminReauthURL ) {
return false;
Expand All @@ -73,7 +74,7 @@ export default function ActivateAnalyticsCTA( { children } ) {
}

return select( CORE_MODULES ).isFetchingSetModuleActivation(
'analytics',
'analytics-4',
true
);
} );
Expand Down
2 changes: 1 addition & 1 deletion assets/js/components/DashboardEntryPoint.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe( 'DashboardEntryPoint', () => {

it( 'should render the module setup component when the setupModuleSlug prop is passed', () => {
const { container } = render(
<DashboardEntryPoint setupModuleSlug="analytics" />,
<DashboardEntryPoint setupModuleSlug="analytics-4" />,
{ setupRegistry }
);
expect( container ).toMatchSnapshot();
Expand Down
2 changes: 1 addition & 1 deletion assets/js/components/DashboardMainApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,10 @@ import { CORE_FORMS } from '../googlesitekit/datastore/forms/constants';
import { CORE_MODULES } from '../googlesitekit/modules/datastore/constants';
import { CORE_SITE } from '../googlesitekit/datastore/site/constants';
import {
EDIT_SCOPE,
FORM_CUSTOM_DIMENSIONS_CREATE,
MODULES_ANALYTICS_4,
} from '../modules/analytics-4/datastore/constants';
import { EDIT_SCOPE } from '../modules/analytics/datastore/constants';
import OfflineNotification from './notifications/OfflineNotification';
import OverlayNotificationsRenderer from './OverlayNotification/OverlayNotificationsRenderer';
import { useMonitorInternetConnection } from '../hooks/useMonitorInternetConnection';
Expand Down
6 changes: 3 additions & 3 deletions assets/js/components/DashboardNavigation/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ describe( 'Dashboard Navigation', () => {
googlesitekit_manage_options: true,
'googlesitekit_manage_module_sharing_options::["search-console"]': true,
'googlesitekit_read_shared_module_data::["search-console"]': true,
'googlesitekit_read_shared_module_data::["analytics"]': false,
'googlesitekit_read_shared_module_data::["analytics-4"]': false,
} );

registry.dispatch( CORE_MODULES ).receiveGetModules( [
Expand Down Expand Up @@ -134,7 +134,7 @@ describe( 'Dashboard Navigation', () => {
googlesitekit_manage_options: true,
'googlesitekit_manage_module_sharing_options::["search-console"]': true,
'googlesitekit_read_shared_module_data::["search-console"]': true,
'googlesitekit_read_shared_module_data::["analytics"]': false,
'googlesitekit_read_shared_module_data::["analytics-4"]': false,
} );

registry.dispatch( CORE_MODULES ).receiveGetModules( [
Expand Down Expand Up @@ -173,7 +173,7 @@ describe( 'Dashboard Navigation', () => {
googlesitekit_manage_options: true,
'googlesitekit_manage_module_sharing_options::["search-console"]': false,
'googlesitekit_read_shared_module_data::["search-console"]': false,
'googlesitekit_read_shared_module_data::["analytics"]': false,
'googlesitekit_read_shared_module_data::["analytics-4"]': false,
'googlesitekit_read_shared_module_data::["pagespeed-insights"]': true,
} );

Expand Down
4 changes: 2 additions & 2 deletions assets/js/components/Header.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ HeaderViewOnly.args = {
},
},
{
slug: 'analytics',
slug: 'analytics-4',
owner: {
id: '3',
login: 'Admin 3',
Expand All @@ -265,7 +265,7 @@ HeaderViewOnly.args = {
) ]: true,
[ getMetaCapabilityPropertyName(
PERMISSION_READ_SHARED_MODULE_DATA,
'analytics'
'analytics-4'
) ]: true,
} );

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,12 @@ import { useEffect, useRef } from '@wordpress/element';
import Data from 'googlesitekit-data';
import { CORE_FORMS } from '../../../googlesitekit/datastore/forms/constants';
import { CORE_USER } from '../../../googlesitekit/datastore/user/constants';
import { MODULES_ANALYTICS_4 } from '../../../modules/analytics-4/datastore/constants';
import {
MODULES_ANALYTICS_4,
EDIT_SCOPE,
} from '../../../modules/analytics-4/datastore/constants';
import { KEY_METRICS_SELECTED, KEY_METRICS_SELECTION_FORM } from '../constants';
import { KEY_METRICS_WIDGETS } from '../key-metrics-widgets';
import { EDIT_SCOPE as ANALYTICS_EDIT_SCOPE } from '../../../modules/analytics/datastore/constants';
import { elementsOverlap } from '../../../util/geometry';
import whenActive from '../../../util/when-active';
const { useSelect } = Data;
Expand Down Expand Up @@ -60,7 +62,7 @@ function CustomDimensionsNotice() {
);
} );
const hasAnalytics4EditScope = useSelect( ( select ) =>
select( CORE_USER ).hasScope( ANALYTICS_EDIT_SCOPE )
select( CORE_USER ).hasScope( EDIT_SCOPE )
);

// This is called here to ensure that the list of available custom dimensions is
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,11 @@ import {
MAX_SELECTED_METRICS_COUNT,
} from '../constants';
import {
EDIT_SCOPE,
FORM_CUSTOM_DIMENSIONS_CREATE,
MODULES_ANALYTICS_4,
} from '../../../modules/analytics-4/datastore/constants';
import { KEY_METRICS_WIDGETS } from '../key-metrics-widgets';
import { EDIT_SCOPE as ANALYTICS_EDIT_SCOPE } from '../../../modules/analytics/datastore/constants';
import { ERROR_CODE_MISSING_REQUIRED_SCOPE } from '../../../util/errors';
import ErrorNotice from '../../ErrorNotice';
import { safelySort } from './utils';
Expand Down Expand Up @@ -111,7 +111,7 @@ export default function Footer( {
} );

const hasAnalytics4EditScope = useSelect( ( select ) =>
select( CORE_USER ).hasScope( ANALYTICS_EDIT_SCOPE )
select( CORE_USER ).hasScope( EDIT_SCOPE )
);

const isGA4Connected = useSelect( ( select ) =>
Expand All @@ -136,7 +136,7 @@ export default function Footer( {

const isNavigatingToOAuthURL = useSelect( ( select ) => {
const OAuthURL = select( CORE_USER ).getConnectURL( {
additionalScopes: [ ANALYTICS_EDIT_SCOPE ],
additionalScopes: [ EDIT_SCOPE ],
redirectURL,
} );

Expand Down Expand Up @@ -194,7 +194,7 @@ export default function Footer( {
),
data: {
status: 403,
scopes: [ ANALYTICS_EDIT_SCOPE ],
scopes: [ EDIT_SCOPE ],
skipModal: true,
redirectURL,
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,7 @@ import { VIEW_CONTEXT_MAIN_DASHBOARD_VIEW_ONLY } from '../../../googlesitekit/co
import { provideKeyMetricsWidgetRegistrations } from '../test-utils';
import * as analytics4Fixtures from '../../../modules/analytics-4/datastore/__fixtures__';
import {
MODULES_ANALYTICS,
EDIT_SCOPE,
} from '../../../modules/analytics/datastore/constants';
import {
FORM_CUSTOM_DIMENSIONS_CREATE,
MODULES_ANALYTICS_4,
} from '../../../modules/analytics-4/datastore/constants';
Expand Down Expand Up @@ -273,7 +270,7 @@ describe( 'MetricsSelectionPanel', () => {
'.googlesitekit-km-selection-panel-metrics'
)
).toHaveTextContent(
'Analytics 4 and Search Console are disconnected, no data to show'
'Analytics and Search Console are disconnected, no data to show'
);
} );

Expand Down Expand Up @@ -477,7 +474,7 @@ describe( 'MetricsSelectionPanel', () => {
} );

registry
.dispatch( MODULES_ANALYTICS )
.dispatch( MODULES_ANALYTICS_4 )
.receiveGetSettings( analytics4Fixtures.defaultSettings );

const { waitForRegistry } = render( <MetricsSelectionPanel />, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ import AnalyticsAdsenseConnectGraphic from '../../../svg/graphics/analytics-adse
import OverlayNotification from './OverlayNotification';
import useViewOnly from '../../hooks/useViewOnly';
import { useFeature } from '../../hooks/useFeature';
import useDashboardType, {
DASHBOARD_TYPE_MAIN,
} from '../../hooks/useDashboardType';

const { useSelect, useDispatch } = Data;

Expand All @@ -48,6 +51,8 @@ export default function LinkAnalyticsAndAdSenseAccountsOverlayNotification() {
);

const isViewOnly = useViewOnly();
const dashboardType = useDashboardType();
const isMainDashboard = dashboardType === DASHBOARD_TYPE_MAIN;

const isShowingNotification = useSelect( ( select ) =>
select( CORE_UI ).isShowingOverlayNotification(
Expand Down Expand Up @@ -77,23 +82,23 @@ export default function LinkAnalyticsAndAdSenseAccountsOverlayNotification() {
);

const analyticsModuleConnected = useSelect( ( select ) => {
if ( isViewOnly || isDismissed ) {
if ( isViewOnly || ! isMainDashboard || isDismissed ) {
return null;
}

return select( CORE_MODULES ).isModuleConnected( 'analytics-4' );
} );

const adSenseModuleConnected = useSelect( ( select ) => {
if ( isViewOnly || isDismissed ) {
if ( isViewOnly || ! isMainDashboard || isDismissed ) {
return null;
}

return select( CORE_MODULES ).isModuleConnected( 'adsense' );
} );

const isAdSenseLinked = useSelect( ( select ) => {
if ( isViewOnly || isDismissed ) {
if ( isViewOnly || ! isMainDashboard || isDismissed ) {
return null;
}

Expand All @@ -106,6 +111,7 @@ export default function LinkAnalyticsAndAdSenseAccountsOverlayNotification() {
const shouldShowNotification =
isGA4AdSenseIntegrationEnabled &&
! isViewOnly &&
isMainDashboard &&
analyticsAndAdSenseAreConnected &&
isAdSenseLinked === false &&
isDismissed === false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ import {
provideModules,
provideUserAuthentication,
} from '../../../../tests/js/utils';
import { VIEW_CONTEXT_MAIN_DASHBOARD } from '../../googlesitekit/constants';
import { MODULES_ANALYTICS_4 } from '../../modules/analytics-4/datastore/constants';
import { Provider as ViewContextProvider } from '../Root/ViewContextContext';
import LinkAnalyticsAndAdSenseAccountsOverlayNotification from './LinkAnalyticsAndAdSenseAccountsOverlayNotification';

function Template() {
Expand All @@ -40,9 +42,14 @@ Default.scenario = {
export default {
title: 'Components/LinkAnalyticsAndAdSenseAccountsOverlayNotification',
component: LinkAnalyticsAndAdSenseAccountsOverlayNotification,
parameters: { features: [ 'ga4AdSenseIntegration' ] },
parameters: {
features: [ 'ga4AdSenseIntegration' ],
viewContext: VIEW_CONTEXT_MAIN_DASHBOARD,
},
decorators: [
( Story ) => {
( Story, { parameters } ) => {
const { viewContext } = parameters;

const setupRegistry = ( registry ) => {
provideUserAuthentication( registry );

Expand All @@ -66,7 +73,9 @@ export default {

return (
<WithRegistrySetup func={ setupRegistry }>
<Story />
<ViewContextProvider value={ viewContext }>
<Story />
</ViewContextProvider>
</WithRegistrySetup>
);
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ import { CORE_USER } from '../../googlesitekit/datastore/user/constants';
import { CORE_SITE } from '../../googlesitekit/datastore/site/constants';
import { MODULES_ANALYTICS_4 } from '../../modules/analytics-4/datastore/constants';
import { CORE_UI } from '../../googlesitekit/datastore/ui/constants';
import { VIEW_CONTEXT_MAIN_DASHBOARD_VIEW_ONLY } from '../../googlesitekit/constants';
import {
VIEW_CONTEXT_MAIN_DASHBOARD,
VIEW_CONTEXT_MAIN_DASHBOARD_VIEW_ONLY,
} from '../../googlesitekit/constants';

describe( 'LinkAnalyticsAndAdSenseAccountsOverlayNotification', () => {
let registry;
Expand Down Expand Up @@ -218,6 +221,7 @@ describe( 'LinkAnalyticsAndAdSenseAccountsOverlayNotification', () => {
<LinkAnalyticsAndAdSenseAccountsOverlayNotification />,
{
registry,
viewContext: VIEW_CONTEXT_MAIN_DASHBOARD,
}
);
expect( container ).not.toHaveTextContent(
Expand All @@ -231,6 +235,7 @@ describe( 'LinkAnalyticsAndAdSenseAccountsOverlayNotification', () => {
{
registry,
features: [ 'ga4AdSenseIntegration' ],
viewContext: VIEW_CONTEXT_MAIN_DASHBOARD,
}
);

Expand All @@ -248,6 +253,7 @@ describe( 'LinkAnalyticsAndAdSenseAccountsOverlayNotification', () => {
<LinkAnalyticsAndAdSenseAccountsOverlayNotification />,
{
registry,
viewContext: VIEW_CONTEXT_MAIN_DASHBOARD,
features: [ 'ga4AdSenseIntegration' ],
}
);
Expand All @@ -271,6 +277,7 @@ describe( 'LinkAnalyticsAndAdSenseAccountsOverlayNotification', () => {
{
registry,
features: [ 'ga4AdSenseIntegration' ],
viewContext: VIEW_CONTEXT_MAIN_DASHBOARD,
}
);

Expand Down Expand Up @@ -302,6 +309,7 @@ describe( 'LinkAnalyticsAndAdSenseAccountsOverlayNotification', () => {
{
registry,
features: [ 'ga4AdSenseIntegration' ],
viewContext: VIEW_CONTEXT_MAIN_DASHBOARD,
}
);

Expand Down

0 comments on commit e5c381f

Please sign in to comment.