Skip to content

Commit

Permalink
Merge pull request #10028 from google/bug/9967-custom-dimensions-error
Browse files Browse the repository at this point in the history
Fix loading state.
  • Loading branch information
eugene-manuilov authored Jan 17, 2025
2 parents 3b4df98 + cdd3333 commit 390cbd5
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
5 changes: 4 additions & 1 deletion assets/js/modules/analytics-4/datastore/custom-dimensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,10 @@ const baseSelectors = {
const availableCustomDimensions =
select( MODULES_ANALYTICS_4 ).getAvailableCustomDimensions();

if ( availableCustomDimensions === undefined ) {
if (
availableCustomDimensions === undefined ||
availableCustomDimensions === null
) {
return undefined;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ describe( 'modules/analytics-4 custom-dimensions', () => {
expect( hasCustomDimensions ).toBe( undefined );
} );

it( 'returns false when available custom dimensions are null or not set', () => {
it( 'returns undefined when available custom dimensions are null', () => {
provideUserAuthentication( registry, { authenticated: false } );
registry.dispatch( CORE_USER ).receiveCapabilities( {
googlesitekit_manage_options: false,
Expand All @@ -481,6 +481,22 @@ describe( 'modules/analytics-4 custom-dimensions', () => {
availableCustomDimensions: null,
} );

const hasCustomDimensions = registry
.select( MODULES_ANALYTICS_4 )
.hasCustomDimensions( [ 'googlesitekit_post_author' ] );

expect( hasCustomDimensions ).toBe( undefined );
} );

it( 'returns false when available custom dimensions are empty or not set', () => {
provideUserAuthentication( registry, { authenticated: false } );
registry.dispatch( CORE_USER ).receiveCapabilities( {
googlesitekit_manage_options: false,
} );
registry.dispatch( MODULES_ANALYTICS_4 ).setSettings( {
availableCustomDimensions: [],
} );

const hasCustomDimensions = registry
.select( MODULES_ANALYTICS_4 )
.hasCustomDimensions( [ 'googlesitekit_post_author' ] );
Expand Down

0 comments on commit 390cbd5

Please sign in to comment.