Skip to content

Commit

Permalink
Merge branch 'feature/singular-analytics-module' into enhancement/808…
Browse files Browse the repository at this point in the history
…2-analytics-db-migration.
  • Loading branch information
nfmohit committed Mar 8, 2024
2 parents 9045116 + d8ecb31 commit fd6c67e
Show file tree
Hide file tree
Showing 426 changed files with 5,918 additions and 5,546 deletions.
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/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 { useMonitorInternetConnection } from '../hooks/useMonitorInternetConnection';
const { useSelect, useDispatch } = Data;
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 {
EDIT_SCOPE as ANALYTICS_EDIT_SCOPE,
MODULES_ANALYTICS_4,
} 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
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 as ANALYTICS_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
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
50 changes: 29 additions & 21 deletions assets/js/components/ReportError.stories.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ import {
import WithRegistrySetup from '../../../tests/js/WithRegistrySetup';
import { Provider as ViewContextProvider } from './Root/ViewContextContext';
import { ERROR_REASON_INSUFFICIENT_PERMISSIONS } from '../util/errors';
import { MODULES_ANALYTICS } from '../modules/analytics/datastore/constants';
import { MODULES_ANALYTICS_4 } from '../modules/analytics-4/datastore/constants';
import {
VIEW_CONTEXT_MAIN_DASHBOARD,
VIEW_CONTEXT_MAIN_DASHBOARD_VIEW_ONLY,
Expand All @@ -40,7 +40,7 @@ const { useSelect } = Data;

function ReportErrorWrapper( { ...args } ) {
const error = useSelect( ( select ) =>
select( MODULES_ANALYTICS ).getErrors()
select( MODULES_ANALYTICS_4 ).getErrors()
);

return <ReportError error={ error } { ...args } />;
Expand All @@ -50,7 +50,7 @@ function Template( { setupRegistry = async () => {}, viewContext, ...args } ) {
const setupRegistryCallback = async ( registry ) => {
provideModules( registry );
provideModuleRegistrations( registry );
await registry.dispatch( MODULES_ANALYTICS ).receiveGetSettings( {} );
await registry.dispatch( MODULES_ANALYTICS_4 ).receiveGetSettings( {} );
await setupRegistry( registry );
};
return (
Expand All @@ -72,7 +72,7 @@ export const DefaultReportError = Template.bind( {} );
DefaultReportError.storyName = 'Default ReportError';
DefaultReportError.args = {
setupRegistry: async ( registry ) => {
await registry.dispatch( MODULES_ANALYTICS ).receiveError(
await registry.dispatch( MODULES_ANALYTICS_4 ).receiveError(
{
code: 'test-error-code',
message: 'Test error message',
Expand All @@ -87,7 +87,7 @@ export const ReportErrorWithHTMLTags = Template.bind( {} );
ReportErrorWithHTMLTags.storyName = 'ReportError with HTML tags';
ReportErrorWithHTMLTags.args = {
setupRegistry: async ( registry ) => {
await registry.dispatch( MODULES_ANALYTICS ).receiveError(
await registry.dispatch( MODULES_ANALYTICS_4 ).receiveError(
{
code: 'test-error-code',
message:
Expand All @@ -104,7 +104,7 @@ ReportErrorWithInsufficientPermissions.storyName =
'ReportError with insufficient permissions';
ReportErrorWithInsufficientPermissions.args = {
setupRegistry: async ( registry ) => {
await registry.dispatch( MODULES_ANALYTICS ).receiveError(
await registry.dispatch( MODULES_ANALYTICS_4 ).receiveError(
{
code: 'test-error-code',
message: 'Test error message',
Expand All @@ -122,28 +122,36 @@ export const ReportErrorWithInsufficientPermissionsWithRequestAccess =
ReportErrorWithInsufficientPermissionsWithRequestAccess.storyName =
'ReportError with insufficient permissions with request access';
ReportErrorWithInsufficientPermissionsWithRequestAccess.args = {
moduleSlug: 'analytics',
moduleSlug: 'analytics-4',
setupRegistry: async ( registry ) => {
provideModules( registry, [
{
active: true,
connected: true,
slug: 'analytics',
slug: 'analytics-4',
},
] );

const [ accountID, internalWebPropertyID, profileID ] = [
const [ accountID, propertyID, measurementID, webDataStreamID ] = [
'12345',
'34567',
'56789',
'78901',
];

await registry.dispatch( MODULES_ANALYTICS ).setAccountID( accountID );
await registry
.dispatch( MODULES_ANALYTICS )
.setInternalWebPropertyID( internalWebPropertyID );
await registry.dispatch( MODULES_ANALYTICS ).setProfileID( profileID );
await registry.dispatch( MODULES_ANALYTICS ).receiveError(
.dispatch( MODULES_ANALYTICS_4 )
.setAccountID( accountID );
await registry
.dispatch( MODULES_ANALYTICS_4 )
.setPropertyID( propertyID );
await registry
.dispatch( MODULES_ANALYTICS_4 )
.setMeasurementID( measurementID );
await registry
.dispatch( MODULES_ANALYTICS_4 )
.setWebDataStreamID( webDataStreamID );
await registry.dispatch( MODULES_ANALYTICS_4 ).receiveError(
{
code: 'test-error-code',
message: 'Test error message',
Expand All @@ -162,7 +170,7 @@ ReportErrorWithInsufficientPermissionsForViewOnlyUser.storyName =
'ReportError with insufficient permissions for view-only user';
ReportErrorWithInsufficientPermissionsForViewOnlyUser.args = {
setupRegistry: async ( registry ) => {
await registry.dispatch( MODULES_ANALYTICS ).receiveError(
await registry.dispatch( MODULES_ANALYTICS_4 ).receiveError(
{
code: 'test-error-code',
message: 'Test error message',
Expand All @@ -180,7 +188,7 @@ export const ReportErrorWithRetryButton = Template.bind( {} );
ReportErrorWithRetryButton.storyName = 'ReportError with Retry Button';
ReportErrorWithRetryButton.args = {
setupRegistry: async ( registry ) => {
await registry.dispatch( MODULES_ANALYTICS ).receiveError(
await registry.dispatch( MODULES_ANALYTICS_4 ).receiveError(
{
code: 'test-error-code',
message: 'Test error message',
Expand All @@ -207,7 +215,7 @@ MultipleReportErrorsWithRetryButton.storyName =
'Multiple Report Errors with Retry Button';
MultipleReportErrorsWithRetryButton.args = {
setupRegistry: async ( registry ) => {
await registry.dispatch( MODULES_ANALYTICS ).receiveError(
await registry.dispatch( MODULES_ANALYTICS_4 ).receiveError(
{
code: 'test-error-code',
message: 'Test error message one',
Expand All @@ -225,7 +233,7 @@ MultipleReportErrorsWithRetryButton.args = {
},
]
);
await registry.dispatch( MODULES_ANALYTICS ).receiveError(
await registry.dispatch( MODULES_ANALYTICS_4 ).receiveError(
{
code: 'test-error-code',
message: 'Test error message two',
Expand All @@ -243,7 +251,7 @@ MultipleReportErrorsWithRetryButton.args = {
},
]
);
await registry.dispatch( MODULES_ANALYTICS ).receiveError(
await registry.dispatch( MODULES_ANALYTICS_4 ).receiveError(
{
code: 'test-error-code',
message: 'Test error message three',
Expand Down Expand Up @@ -271,7 +279,7 @@ MultipleUniqueReportErrorsWithRetryButtonWith.storyName =
'Multiple Unique Report Errors with Retry Button';
MultipleUniqueReportErrorsWithRetryButtonWith.args = {
setupRegistry: async ( registry ) => {
await registry.dispatch( MODULES_ANALYTICS ).receiveError(
await registry.dispatch( MODULES_ANALYTICS_4 ).receiveError(
{
code: 'test-error-code',
message: 'Test error message',
Expand All @@ -289,7 +297,7 @@ MultipleUniqueReportErrorsWithRetryButtonWith.args = {
},
]
);
await registry.dispatch( MODULES_ANALYTICS ).receiveError(
await registry.dispatch( MODULES_ANALYTICS_4 ).receiveError(
{
code: 'test-error-code',
message: 'Test error message',
Expand Down
Loading

0 comments on commit fd6c67e

Please sign in to comment.