Search code examples
azurewindows-store-appsazure-application-insights

Application Insights not tracking users and sessions


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!


Solution

  • 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?