Skip to content

Commit

Permalink
Merge pull request #9984 from google/enhancement/9604-hide-not-set-au…
Browse files Browse the repository at this point in the history
…dience-segmentation
  • Loading branch information
aaemnnosttv authored Jan 24, 2025
2 parents c2e2533 + e69555a commit 37b72fa
Show file tree
Hide file tree
Showing 34 changed files with 30 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ import { isInvalidCustomDimensionError } from '../../../../utils/custom-dimensio
import useViewContext from '../../../../../../hooks/useViewContext';
import useViewOnly from '../../../../../../hooks/useViewOnly';
import { trackEvent } from '../../../../../../util';
import { reportRowsWithSetValues } from '../../../../utils/report-rows-with-set-values';

const hasZeroDataForAudience = ( report, dimensionName ) => {
const audienceData = report?.rows?.find(
Expand Down Expand Up @@ -566,6 +567,11 @@ export default function AudienceTiles( { Widget, widgetLoading } ) {
isPartialData,
} = getAudienceTileData( audienceResourceName, index );

// Filter (not set) value from the top countries report if present.
const filteredTopCitiesRows = topCities?.rows
? reportRowsWithSetValues( topCities.rows )
: [];

// Return loading tile if data is not yet loaded.
if (
loading ||
Expand Down Expand Up @@ -632,19 +638,19 @@ export default function AudienceTiles( { Widget, widgetLoading } ) {
}
topCities={ {
dimensionValues: [
topCities?.rows?.[ 0 ]
filteredTopCitiesRows?.[ 0 ]
?.dimensionValues?.[ 0 ],
topCities?.rows?.[ 1 ]
filteredTopCitiesRows?.[ 1 ]
?.dimensionValues?.[ 0 ],
topCities?.rows?.[ 2 ]
filteredTopCitiesRows?.[ 2 ]
?.dimensionValues?.[ 0 ],
],
metricValues: [
topCities?.rows?.[ 0 ]
filteredTopCitiesRows?.[ 0 ]
?.metricValues?.[ 0 ],
topCities?.rows?.[ 1 ]
filteredTopCitiesRows?.[ 1 ]
?.metricValues?.[ 0 ],
topCities?.rows?.[ 2 ]
filteredTopCitiesRows?.[ 2 ]
?.metricValues?.[ 0 ],
],
total: visitors,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,12 +224,12 @@ exports[`AudienceTilesWidget should not render audiences that are not available
<div
class="googlesitekit-audience-segmentation-tile-metric__cities-metric-name"
>
(not set)
New York
</div>
<div
class="googlesitekit-audience-segmentation-tile-metric__cities-metric-value"
>
99%
71.1%
</div>
</div>
<div
Expand Down Expand Up @@ -640,12 +640,12 @@ exports[`AudienceTilesWidget should render correctly when there is partial data
<div
class="googlesitekit-audience-segmentation-tile-metric__cities-metric-name"
>
(not set)
New York
</div>
<div
class="googlesitekit-audience-segmentation-tile-metric__cities-metric-value"
>
78.6%
392.9%
</div>
</div>
</div>
Expand Down Expand Up @@ -1153,12 +1153,12 @@ exports[`AudienceTilesWidget should render when all configured audiences are mat
<div
class="googlesitekit-audience-segmentation-tile-metric__cities-metric-name"
>
(not set)
New York
</div>
<div
class="googlesitekit-audience-segmentation-tile-metric__cities-metric-value"
>
106.7%
76.7%
</div>
</div>
<div
Expand Down Expand Up @@ -1513,12 +1513,12 @@ exports[`AudienceTilesWidget should render when configured audience is matching
<div
class="googlesitekit-audience-segmentation-tile-metric__cities-metric-name"
>
(not set)
New York
</div>
<div
class="googlesitekit-audience-segmentation-tile-metric__cities-metric-value"
>
145.5%
104.5%
</div>
</div>
<div
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ const topCitiesReportOptions = {
desc: true,
},
],
limit: 3,
limit: 4,
};

const topContentReportOptions = {
Expand Down Expand Up @@ -127,9 +127,7 @@ Default.args = {
'properties/12345/audiences/4', // Returning visitors
],
};
Default.scenario = {
label: 'Modules/Analytics4/Components/AudienceSegmentation/Dashboard/AudienceTilesWidget/Default',
};
Default.scenario = {};

export const DefaultWithMissingCustomDimension = Template.bind( {} );
DefaultWithMissingCustomDimension.storyName =
Expand All @@ -146,9 +144,7 @@ DefaultWithMissingCustomDimension.args = {
} );
},
};
DefaultWithMissingCustomDimension.scenario = {
label: 'Modules/Analytics4/Components/AudienceSegmentation/Dashboard/AudienceTilesWidget/DefaultWithMissingCustomDimension',
};
DefaultWithMissingCustomDimension.scenario = {};

export const DefaultViewOnlyWithCustomDimensionError = Template.bind( {} );
DefaultViewOnlyWithCustomDimensionError.storyName =
Expand Down Expand Up @@ -245,9 +241,7 @@ DefaultWithZeroTile.args = {
} );
},
};
DefaultWithZeroTile.scenario = {
label: 'Modules/Analytics4/Components/AudienceSegmentation/Dashboard/AudienceTilesWidget/DefaultWithZeroTile',
};
DefaultWithZeroTile.scenario = {};

export const TwoTiles = Template.bind( {} );
TwoTiles.storyName = 'Two Tiles';
Expand All @@ -257,9 +251,7 @@ TwoTiles.args = {
'properties/12345/audiences/3', // New visitors
],
};
TwoTiles.scenario = {
label: 'Modules/Analytics4/Components/AudienceSegmentation/Dashboard/AudienceTilesWidget/TwoTiles',
};
TwoTiles.scenario = {};

export const TwoTilesWithMissingCustomDimension = Template.bind( {} );
TwoTilesWithMissingCustomDimension.storyName =
Expand Down Expand Up @@ -367,9 +359,7 @@ TwoTilesWithZeroTile.args = {
} );
},
};
TwoTilesWithZeroTile.scenario = {
label: 'Modules/Analytics4/Components/AudienceSegmentation/Dashboard/AudienceTilesWidget/TwoTilesWithZeroTile',
};
TwoTilesWithZeroTile.scenario = {};

export const ZeroTileWithPlaceholder = Template.bind( {} );
ZeroTileWithPlaceholder.storyName = 'ZeroTileWithPlaceholder';
Expand Down Expand Up @@ -426,9 +416,7 @@ ZeroTileWithPlaceholder.args = {
} );
},
};
ZeroTileWithPlaceholder.scenario = {
label: 'Modules/Analytics4/Components/AudienceSegmentation/Dashboard/AudienceTilesWidget/ZeroTileWithPlaceholder',
};
ZeroTileWithPlaceholder.scenario = {};

export const DefaultAudiencesPartialData = Template.bind( {} );
DefaultAudiencesPartialData.storyName = 'DefaultAudiencesPartialData';
Expand Down Expand Up @@ -625,7 +613,7 @@ SingleTileErrored.args = {
desc: true,
},
],
limit: 3,
limit: 4,
};

const errorReport = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function provideAudienceTilesMockReport(
desc: true,
},
],
limit: 3,
limit: 4,
};

const topContentReportOptions = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ export default function useAudienceTilesReports( {
desc: true,
},
],
limit: 3,
limit: 4, // Limit is set to 4 so that (not set) can be filtered out and 3 cities remain to display.
};

const topCitiesReport = useInViewSelect( ( select ) =>
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 37b72fa

Please sign in to comment.