0
votes

I have enabled application insights version 1.1.0 on a Windows 8.1 app. While debugging about 1 month ago everything worked fine, I could see my session and my user. A couple of days ago I published my app but users and sessions are not tracked (always zero) while trackevent and trackmetrics are recorded correctly. To track user and session I'm using this code in app constructor

tc = new TelemetryClient();

On the get started page it says to use this code but it doesn't exist on 1.1.0.

WindowsAppInitializer.InitializeAsync();

Here are my referenced versions:

 <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">

Update: the package was installed and enabled for the project but the reference was missing. Removing and installing the package again fixed the problem.
I checked the portal and sessions are being tracked again. Thanks John!

2
see my answer: you're missing Microsoft.ApplicationInsights.WindowsApps nuget package, which references the ones you do have, and has the windows store specific code in it.John Gardner

2 Answers

0
votes

The method exists in the assembly Microsoft.ApplicationInsights.Extensibility.Windows which was installed by the Microsoft.ApplicationInsights.WindowsApps nuget package.

from Object browser on that assembly:

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

are you missing using Microsoft.ApplicationInsights; in your code?

0
votes

In our case, we have a reusable component for logging to Application Insights. We do have a reference to Microsoft.ApplicationInsights in our reusable component.

Additionally, we have multiple environments that we use and we have separate instrumentation keys that we get during app launch by setting a value to Microsoft.ApplicationInsights.Extensibility.TelemetryConfiguration.Active.InstrumentationKey.

The Users and Sessions data is logged fine when using 0.17 package, however upon upgrading to 1.0 or 1.1, the issue still remains.