【问题标题】:How To Get Unique Users In Application Insights Monitoring SharePoint Sites?如何在 Application Insights 监控 SharePoint 站点中获取唯一用户?
【发布时间】:2019-08-31 01:59:52
【问题描述】:

我们正在使用 Application Insights 监控 SharePoint Online 和 SharePoint On-Premises 网站。我们可以在 Metrics 中看到有一个显示唯一用户的报告。但是来自 SharePoint Online 的数据是匿名的(即 user_Id 不可见)。所以这些是点击而不是唯一用户。

我们如何从来自 SharePoint Online 和 SharePoint On-premises 监控网站的 Application Insights 中记录的数据中发现唯一用户?

【问题讨论】:

    标签: sharepoint azure-application-insights sharepoint-online


    【解决方案1】:

    确保首先捕获 UserId,您可以尝试将以下脚本嵌入 SharePoint 应用程序中,而不是从门户获取的 sn-p。

    <SharePoint:ScriptLink ID="ScriptLink1" name="SP.js" runat="server" localizable="false" loadafterui="true" /> 
    <SharePoint:ScriptLink ID="ScriptLink2" name="SP.UserProfiles.js" runat="server" localizable="false" loadafterui="true" /> 
    
    <script type="text/javascript"> 
    var personProperties; 
    
    // Ensure that the SP.UserProfiles.js file is loaded before the custom code runs. 
    SP.SOD.executeOrDelayUntilScriptLoaded(getUserProperties, 'SP.UserProfiles.js'); 
    
    function getUserProperties() { 
        // Get the current client context and PeopleManager instance. 
        var clientContext = new SP.ClientContext.get_current(); 
        var peopleManager = new SP.UserProfiles.PeopleManager(clientContext); 
    
        // Get user properties for the target user. 
        // To get the PersonProperties object for the current user, use the 
        // getMyProperties method. 
    
        personProperties = peopleManager.getMyProperties(); 
    
        // Load the PersonProperties object and send the request. 
        clientContext.load(personProperties); 
        clientContext.executeQueryAsync(onRequestSuccess, onRequestFail); 
    } 
    
    // This function runs if the executeQueryAsync call succeeds. 
    function onRequestSuccess() { 
    var appInsights=window.appInsights||function(config){
    function s(config){t[config]=function(){var i=arguments;t.queue.push(function(){t[config].apply(t,i)})}}var t={config:config},r=document,f=window,e="script",o=r.createElement(e),i,u;for(o.src=config.url||"//az416426.vo.msecnd.net/scripts/a/ai.0.js",r.getElementsByTagName(e)[0].parentNode.appendChild(o),t.cookie=r.cookie,t.queue=[],i=["Event","Exception","Metric","PageView","Trace"];i.length;)s("track"+i.pop());return config.disableExceptionTracking||(i="onerror",s("_"+i),u=f[i],f[i]=function(config,r,f,e,o){var s=u&&u(config,r,f,e,o);return s!==!0&&t["_"+i](config,r,f,e,o),s}),t
        }({
            instrumentationKey:"XXXX"
        });
        window.appInsights=appInsights;
        appInsights.trackPageView(document.title,window.location.href, {User: personProperties.get_displayName()});
    } 
    
    // This function runs if the executeQueryAsync call fails. 
    function onRequestFail(sender, args) { 
    } 
    </script> 

    更多详情请参阅documentation

    希望信息有所帮助。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-01-16
      • 1970-01-01
      • 2019-01-15
      • 1970-01-01
      • 2022-08-20
      • 1970-01-01
      • 2010-11-27
      • 1970-01-01
      相关资源
      最近更新 更多