If your goal is getting the popular content and page views, I would suggest checking first the usage data feature instead of building a new customized SPFx.
In Usage Data, you can find the Popular content that shows the most popular content on the site sorted by site pages, news posts, and documents sorted by unique viewers, total views, or time spent for site pages and news posts.
Note: the Site Usage feature can only show data for the last 7 days.
Also, you can check SharePoint site usage in Microsoft 365 admin center that has The Pages chart that shows the number of pages viewed across all sites and more.
Read more at