Skip to content

Commit 5dee723

Browse files
authored
Fixed paid data shown on Growth / Sources tab (#24565)
ref https://linear.app/ghost/issue/PROD-2377/analytics-growth-top-content-sources-shows-paid-related-columns - Under Analytics > Growth, paid membership related columns were displayed in the Top Content / Sources tab even though paid membership is turned off for the publication.
1 parent 986056e commit 5dee723

File tree

1 file changed

+26
-17
lines changed

1 file changed

+26
-17
lines changed

apps/stats/src/views/Stats/Growth/components/GrowthSources.tsx

Lines changed: 26 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ interface GrowthSourcesTableProps {
2929
const GrowthSourcesTableBody: React.FC<GrowthSourcesTableProps> = ({data, currencySymbol, limit, defaultSourceIconUrl}) => {
3030
// Data is already sorted by the backend, so we just need to apply limit if specified
3131
const displayData = limit ? data.slice(0, limit) : data;
32+
const {appSettings} = useAppContext();
3233

3334
return (
3435
<TableBody>
@@ -61,12 +62,16 @@ const GrowthSourcesTableBody: React.FC<GrowthSourcesTableProps> = ({data, curren
6162
<TableCell className='text-right font-mono text-sm'>
6263
+{formatNumber(row.free_members)}
6364
</TableCell>
64-
<TableCell className='text-right font-mono text-sm'>
65+
{appSettings?.paidMembersEnabled &&
66+
<>
67+
<TableCell className='text-right font-mono text-sm'>
6568
+{formatNumber(row.paid_members)}
66-
</TableCell>
67-
<TableCell className='text-right font-mono text-sm'>
69+
</TableCell>
70+
<TableCell className='text-right font-mono text-sm'>
6871
+{currencySymbol}{centsToDollars(row.mrr)}
69-
</TableCell>
72+
</TableCell>
73+
</>
74+
}
7075
</TableRow>
7176
))}
7277
</TableBody>
@@ -242,23 +247,27 @@ export const GrowthSources: React.FC<GrowthSourcesProps> = ({
242247
<TableHeader>
243248
<TableRow>
244249
<TableHead>
245-
Source
250+
Source
246251
</TableHead>
247252
<TableHead className='w-[110px] text-right'>
248253
<SortButton activeSortBy={sortBy} setSortBy={setSortBy} sortBy='free_members desc'>
249-
Free members
250-
</SortButton>
251-
</TableHead>
252-
<TableHead className='w-[110px] text-right'>
253-
<SortButton activeSortBy={sortBy} setSortBy={setSortBy} sortBy='paid_members desc'>
254-
Paid members
255-
</SortButton>
256-
</TableHead>
257-
<TableHead className='w-[110px] text-right'>
258-
<SortButton activeSortBy={sortBy} setSortBy={setSortBy} sortBy='mrr desc'>
259-
MRR impact
254+
Free members
260255
</SortButton>
261256
</TableHead>
257+
{appSettings?.paidMembersEnabled &&
258+
<>
259+
<TableHead className='w-[110px] text-right'>
260+
<SortButton activeSortBy={sortBy} setSortBy={setSortBy} sortBy='paid_members desc'>
261+
Paid members
262+
</SortButton>
263+
</TableHead>
264+
<TableHead className='w-[110px] text-right'>
265+
<SortButton activeSortBy={sortBy} setSortBy={setSortBy} sortBy='mrr desc'>
266+
MRR impact
267+
</SortButton>
268+
</TableHead>
269+
</>
270+
}
262271
</TableRow>
263272
</TableHeader>
264273
<GrowthSourcesTableBody
@@ -278,4 +287,4 @@ export const GrowthSources: React.FC<GrowthSourcesProps> = ({
278287
);
279288
};
280289

281-
export default GrowthSources;
290+
export default GrowthSources;

0 commit comments

Comments
 (0)