is SPWeb.GetUsageData still available
-
29-12-2020 - |
Question
SPWeb.GetUsageData
has been around since Windows SharePoint Services 3. In 2010 SPWeb.GetUsageData
still yielded results. However, I have not found a single SharePoint installation either 2013 or 2016 in which SPWeb.GetUsageData
returned anything other than null
.
I know that "Web Analytics in SharePoint Server 2010" is discontinued.
However it is my understanding that SPWeb.GetUsageData
relies on the "Usage and Health Data Collection service application" - which is configured and available in all the farms I checked. The needed TimerJobs ("Microsoft SharePoint Foundation Usage Data Import" and "Microsoft SharePoint Foundation Usage Data Processing") are disabled on most farms I check, but even enabling them will not make usage-data available.
On one side the SPWeb.GetUsageData
help page says "gets a table that contains information about the usage of a website..." it says nothing about it being no longer supported.. But on the other side in the ...\15\template\layouts\usagedetails.aspx
(the page that would show the contents of SPWeb.GetUsageData
) the table called UsageReportGridView
is wrapped inside a <SharePoint:UIVersionedContent UIVersion="4" runat="server">
so it will never show in SharePoint 2013/2016..
So my question is this: Are the "old" (i.e. pre-2010) usage-data informations still supported in 2013/2016?
Solution 2
After having discussed this with Microsoft this is the not-so-offical answer:
The 2010 method SPWeb.GetUsageData() is deprecated in SharePoint 2013.
As a workaround the customer could get the data by directly going to SQL: https://technet.microsoft.com/en-us/library/jj715694(v=office.15).aspx
OTHER TIPS
As per MSDN its supported in SP2013 on-premise, there is no mention of SP2016 (so i assume its not available in SP2016).
the code that i have used to get this done
SPWeb oWeb = new SPSite("http://sername/sites/test").RootWeb;
//SPWeb oWeb = SPContext.Current.Web;
DataTable dt = oWeb.GetUsageData(Microsoft.SharePoint.Administration.SPUsageReportType.user, Microsoft.SharePoint.Administration.SPUsagePeriodType.day);
datagrid1.DataSource = dt;
datagrid1.DataBind();