Skip to content

Commit

Permalink
Merge pull request #7648 from google/enhance/#7278-dismiss-ga4-cta-tile
Browse files Browse the repository at this point in the history
Enhance/#7278 - Dismiss GA4 tile banner.
  • Loading branch information
techanvil authored Oct 2, 2023
2 parents 92fedb0 + 07cf51f commit 336065e
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,13 @@ export default function ConnectGA4CTAWidget( { Widget, WidgetNull } ) {
isNavigatingToGA4URL,
] );

if ( ga4DependantKeyMetrics.length < 4 ) {
const isDismissed = useSelect( ( select ) =>
select( CORE_USER ).isItemDismissed(
KM_CONNECT_GA4_CTA_WIDGET_DISMISSED_ITEM_KEY
)
);

if ( isDismissed !== false || ga4DependantKeyMetrics.length < 4 ) {
return <WidgetNull />;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import {
KM_ANALYTICS_TOP_TRAFFIC_SOURCE,
KM_SEARCH_CONSOLE_POPULAR_KEYWORDS,
KM_ANALYTICS_ADSENSE_TOP_EARNING_CONTENT,
CORE_USER,
} from '../../../../googlesitekit/datastore/user/constants';
import { KM_CONNECT_GA4_CTA_WIDGET_DISMISSED_ITEM_KEY } from '../../constants';
import {
render,
createTestRegistry,
Expand Down Expand Up @@ -79,6 +81,11 @@ describe( 'ConnectGA4CTAWidget', () => {
} );

provideKeyMetricsWidgetRegistrations( registry, keyMetricWidgets );
registry
.dispatch( CORE_USER )
.receiveGetDismissedItems( [
KM_CONNECT_GA4_CTA_WIDGET_DISMISSED_ITEM_KEY,
] );

const { container, waitForRegistry } = render(
<WidgetWithComponentProps />,
Expand Down Expand Up @@ -113,6 +120,7 @@ describe( 'ConnectGA4CTAWidget', () => {
{}
)
);
registry.dispatch( CORE_USER ).receiveGetDismissedItems( [] );

const { container, getByRole, waitForRegistry } = render(
<WidgetWithComponentProps />,
Expand Down

0 comments on commit 336065e

Please sign in to comment.