Skip to content

Commit d09784f

Browse files
NikschavanCopilot
andauthored
STATS-77 - Show correct backlink to the insights page (#103539)
Co-authored-by: Copilot <[email protected]>
1 parent 197f59d commit d09784f

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

client/my-sites/stats/hooks/use-stats-navigation-history.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ const possibleBackLinks: { [ key: string ]: string | null } = {
1717
subscribers: '/stats/subscribers/{period}/',
1818
posts: '/stats/{period}/posts/',
1919
authors: '/stats/{period}/authors/',
20+
annualstats: '/stats/day/annualstats/',
2021
postDetails: null, // Last item in the history, the text is not displayed anywhere but this is used to track the item in history stack.
2122
};
2223

@@ -53,6 +54,7 @@ export const useStatsNavigationHistory = (): { text: string; url: string | null
5354
subscribers: translate( 'Subscribers' ),
5455
posts: translate( 'Posts & pages' ),
5556
authors: translate( 'Authors' ),
57+
annualstats: translate( 'Annual insights' ),
5658
postDetails: null,
5759
} ),
5860
[]

client/my-sites/stats/pages/insights/controller.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,11 @@ setTimeout( () => import( 'calypso/my-sites/stats/pages/insights' ), 3000 );
66

77
function insights( context: Context, next: () => void ) {
88
context.primary = (
9-
<AsyncLoad require="calypso/my-sites/stats/pages/insights" placeholder={ PageLoading } />
9+
<AsyncLoad
10+
require="calypso/my-sites/stats/pages/insights"
11+
placeholder={ PageLoading }
12+
context={ context }
13+
/>
1014
);
1115
next();
1216
}

client/my-sites/stats/pages/insights/index.jsx

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import StatShares from 'calypso/my-sites/stats/features/modules/stats-shares';
1616
import StatsModuleTags from 'calypso/my-sites/stats/features/modules/stats-tags';
1717
import usePlanUsageQuery from 'calypso/my-sites/stats/hooks/use-plan-usage-query';
1818
import { useShouldGateStats } from 'calypso/my-sites/stats/hooks/use-should-gate-stats';
19+
import { recordCurrentScreen } from 'calypso/my-sites/stats/hooks/use-stats-navigation-history';
1920
import { useSelector } from 'calypso/state';
2021
import { STATS_PLAN_USAGE_RECEIVE } from 'calypso/state/action-types';
2122
import { isJetpackSite } from 'calypso/state/sites/selectors';
@@ -29,7 +30,7 @@ import statsStrings from '../../stats-strings';
2930
import StatsUpsell from '../../stats-upsell/insights-upsell';
3031
import StatsModuleListing from '../shared/stats-module-listing';
3132

32-
function StatsInsights() {
33+
function StatsInsights( { context } ) {
3334
const siteId = useSelector( ( state ) => getSelectedSiteId( state ) );
3435
const siteSlug = useSelector( ( state ) => getSelectedSiteSlug( state, siteId ) );
3536
const isJetpack = useSelector( ( state ) => isJetpackSite( state, siteId ) );
@@ -60,6 +61,18 @@ function StatsInsights() {
6061
[]
6162
); // Track the last viewed tab.
6263

64+
useEffect( () => {
65+
const query = context.query;
66+
recordCurrentScreen(
67+
'insights',
68+
{
69+
queryParams: query,
70+
period: null,
71+
},
72+
true
73+
);
74+
}, [ context.query ] );
75+
6376
const isWPAdmin = config.isEnabled( 'is_odyssey' );
6477
const insightsPageClasses = clsx( 'stats', { 'is-odyssey-stats': isWPAdmin } );
6578

0 commit comments

Comments
 (0)