SPWeb.GetUsageData has been desperate since SharePoint 2013:
As a workaround is to directly query SharePoint WSS_logging DataBase to get the data:
View data in the logging database in SharePoint Server
And here is a similar issue with yours for reference
is SPWeb.GetUsageData still available
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.