Skip to content

Commit

Permalink
Merge pull request #7667 from google/fix/7577-visits-per-visitor-kmw-…
Browse files Browse the repository at this point in the history
…metric-change

Fix / 7577 Visits Per Visitor KMW Metric Change
  • Loading branch information
nfmohit authored Oct 5, 2023
2 parents 0e58d82 + 8e743aa commit e713eb5
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ function VisitsPerVisitorWidget( { Widget } ) {

const reportOptions = {
...dates,
metrics: [ { name: 'sessionsPerUser' }, { name: 'activeUsers' } ],
metrics: [ { name: 'sessionsPerUser' }, { name: 'sessions' } ],
};

const report = useInViewSelect( ( select ) =>
Expand All @@ -74,7 +74,7 @@ function VisitsPerVisitorWidget( { Widget } ) {
)
);

const { rows = [], totals = [] } = report || {};
const { rows = [] } = report || {};

const makeFind = ( dateRange ) => ( row ) =>
get( row, 'dimensionValues.0.value' ) === dateRange;
Expand All @@ -87,8 +87,10 @@ function VisitsPerVisitorWidget( { Widget } ) {
rows.find( makeFind( 'date_range_1' ) )?.metricValues?.[ 0 ]?.value ||
0;

const currentTotalVisitors =
Number( totals[ 0 ]?.metricValues?.[ 1 ]?.value ) || 0;
const currentTotalSessions =
Number(
rows.find( makeFind( 'date_range_0' ) )?.metricValues?.[ 1 ]?.value
) || 0;

return (
<MetricTileNumeric
Expand All @@ -98,7 +100,7 @@ function VisitsPerVisitorWidget( { Widget } ) {
subText={ sprintf(
/* translators: %d: Number of total visits to the site. */
__( '%s total visits', 'google-site-kit' ),
numFmt( currentTotalVisitors, { style: 'decimal' } )
numFmt( currentTotalSessions, { style: 'decimal' } )
) }
previousValue={ Number( previousVisitsPerVisitor ) }
currentValue={ Number( currentVisitsPerVisitor ) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ const reportOptions = {
name: 'sessionsPerUser',
},
{
name: 'activeUsers',
name: 'sessions',
},
],
};
Expand Down

0 comments on commit e713eb5

Please sign in to comment.