Application Insights 不跟踪用户和会话

Application Insights not tracking users and sessions

我在 Windows 8.1 应用程序上启用了应用程序洞察版本 1.1.0。大约 1 个月前调试时一切正常,我可以看到我的会话和我的用户。几天前,我发布了我的应用程序,但未跟踪用户和会话(始终为零),同时正确记录了 trackevent 和 trackmetrics。 为了跟踪用户和会话,我在应用程序构造函数中使用此代码

tc = new TelemetryClient();

get started page 上说要使用此代码,但它在 1.1.0 上不存在。

WindowsAppInitializer.InitializeAsync();

这是我参考的版本:

 <Reference Include="Microsoft.ApplicationInsights, Version=1.1.0.1899, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
 <Reference Include="Microsoft.ApplicationInsights.PersistenceChannel, Version=1.1.0.1903, Culture=neutral, PublicKeyToken=31bf3856ad364e35, processorArchitecture=MSIL">
 <Reference Include="Microsoft.Diagnostics.Tracing.EventSource, Version=1.1.25.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a, processorArchitecture=MSIL">

更新: 该包已安装并为项目启用,但缺少引用。再次删除并安装软件包解决了问题。
我检查了门户,再次跟踪会话。谢谢约翰!

该方法存在于由 Microsoft.ApplicationInsights.WindowsApps nuget 包安装的程序集 Microsoft.ApplicationInsights.Extensibility.Windows 中。

来自该程序集上的对象浏览器:

public static System.Threading.Tasks.Task InitializeAsync(string 
     instrumentationKey, [Microsoft.ApplicationInsights.WindowsCollectors 
     collectors = 29])
        Member of Microsoft.ApplicationInsights.WindowsAppInitializer

您的代码中缺少 using Microsoft.ApplicationInsights; 吗?

在我们的例子中,我们有一个可重用的组件用于记录到 Application Insights。我们在可重用组件中确实有对 Microsoft.ApplicationInsights 的引用。

此外,我们有多个使用的环境,并且我们有单独的检测密钥,我们在应用程序启动期间通过将值设置为 Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey.

获得这些密钥

使用 0.17 包时,用户和会话数据记录正常,但是升级到 1.0 或 1.1 后,问题仍然存在。