Export (0) Print
Expand All

Start monitoring your live Windows device app

Visual Studio 2013

Application Insights is in preview.

To find out what users are doing on your Windows Phone or Windows Store app, add Application Insights to your app project. When people download and use your app, you’ll see statistical data in the Application Insights portal.

Caution note Caution

This is about the older version of Application Insights in Visual Studio Online. There’s a new version in Microsoft Azure.

How do I know which I’m using, and how do I choose?

You only have to do this once on each development machine. You must be using Visual Studio 2013. (If you’re using Visual Studio 2012, skip this step. You can still use Application Insights, but you'll have to do some configuration by hand.)

  1. Open Tools, Extensions and Updates.

  2. Select Installed. If there is a version 2.* of Application Insights Tools, delete it. (The 2.* versions send data to the Azure version of Application Insights.)

  3. Select Online.

  4. Search on "Application Insights".

  5. Install Application Insights Tools for Visual Studio version 1.*. (The 1.* versions send data to the Visual Studio Online portal.)

TOOLS, Extensions, Online, Application Insights

Every member of the team should install the tools.

If you already have a C# or Visual Basic Windows app on Visual Studio 2013: Add Application Insights to the project.

In project context menu, Add Application Insights

If you’re creating a new C# or Visual Basic Windows app on Visual Studio 2013: When you create your project, make sure Add Application Insights is checked.

In New Project, check Add Application Insights

If you haven’t yet set up a Visual Studio Online account, or if you haven’t connected to your account yet, you’ll see some extra dialogs that help you do that.

If you have a C++ or JavaScript Windows Store app, or you use Visual Studio 2012: Manually configure the project for Application Insights.

  • Set the build platform to x86, x64 or ARM.

    Choose Build, Configuration Manager Choose Build, Configuration Manager

You don't have to do any coding to get basic data such as session time, OS, screen resolution, app version.

  1. Press F5 and use your app.

  2. In Solution Explorer, in the context menu of the web project, choose Open Application Insights portal.

    Project menu: Open Application Insights in Portal

    Your browser will open on a dashboard that shows a tile like this:

    Data stream tile on the default dashboard

    Data from your application should show up within a few seconds. (If it doesn’t, take a look at Troubleshooting.)

  3. Click the tile for a more detailed view. Or at any time, you can go to DIAGNOSTICS / Streaming data and select your application.

    Debug data in DIAGNOSTICS, Streaming

    The Streaming page is used only in development, to verify that the right data is getting to Application Insights. Stream data is only shown when your active build configuration is set to Debug.

  4. After a few minutes, go to USAGE to see the first processed results. If you see a configuration page instead of data, wait a few minutes and refresh the page. Here’s an example page of first results:

    Choose USAGE, Environment

Upload your app to Windows Store in the usual way. When your customers download and use it, Application Insights will collect and aggregate their data. The reported data will build up over a period of days.

Choose USAGE, Users

Usually you set your solution’s build configuration to Release before publishing. That has some effect on the way Application Insights works. In Release mode, data will no longer appear on the Streaming page. Also, collected data is saved on the device and sent only when the app launches or resumes. At the end of each session, data is saved until the next resume. If you want to change these effects, you can edit the settings in ApplicationInsights.config.

If you build in release configuration, events are stored in the device and sent when the application resumes. Data is also sent on the application’s first use. If you build in debug mode, events are sent as soon as they are generated.

  • Creates an application component in Application Insights, in your Visual Studio Online account.

  • Adds a project reference to Microsoft.ApplicationInsights.Telemetry.WindowsStore or WindowsPhone

  • Adds ApplicationInsights.config to your project, inserting the componentId of your application component, so that the data sent from your application will appear under your component.

  1. [Windows apps] On the device, make sure that Advertising is enabled.

    Open the Settings charm, choose Change PC Settings, Privacy, and then enable Let apps use my Advertising Id.

  2. Watch the Raw event stream tile on the dashboard, or the Diagnostics, Streaming page. Data should appear there within a minute. It will take up to 15 minutes for data to appear in the Usage pages.

  3. Check you’re configured for streaming.

    1. In Visual Studio, on the Build menu, open Configuration Manager. Check that the Active Build Configuration is Debug.

    2. Open ApplicationInsights.config in the root folder of your app project and check the following elements:

    3. This element determines which profile that is active when you build in Debug mode:

      <DebugBuildProfile>Development</DebugBuildProfile>

    4. Inside <Profile name="Development">, check that you see these elements:

      <ClientAnalytics><SendToRawStream>true</SendToRawStream><CollectMachineName>true</CollectMachineName></ClientAnalytics>

  4. Watch the SDK

    To see runtime messages from the SDK in Visual Studio:

    1. Open the properties of your Windows Store or Phone app project.

      In the Debug page, change:

      • [Windows Phone] change UI Task to Native Only

      • [Windows Store] change Debugger Type to Native or Mixed (Managed and Native).

    2. Run your app in debug mode. To filter out all but the Application Insights messages, open the context menu of the Output window, and disable all types of messages except Program Output.

  5. [Windows Store app] Inspect the log files

    1. Run your app and then terminate it.

    2. You can find log files under %localappdata%\Packages\*\LocalState\MS.CA

      However, be aware that the log files are deleted as soon as they are sent. Logs are sent on startup or resume, and so it can be particularly difficult to see events that are generated on launch. If you want to see launch events, you might want to disable the device’s network.

  6. [Windows Phone] Inspect log files in the phone

    1. Install a tool that allows you to inspect the Windows Phone isolated storage, such as Windows Phone Power Tools, IsoStoreSpy, or Isolated Storage Explorer.

    2. Run your app and then terminate it using the back button.

    3. Use the tool to inspect the phone’s isolated storage.

      You should see log files under the Microsoft.ClientAnalytics folder.

      However, be aware that the log files are deleted as soon as they are sent. Logs are sent on startup or resume, and so it can be particularly difficult to see events that are generated on launch. You might want to disable the phone’s network to be able to see those events.

  7. Don’t call logging methods before InitializeComponent() in the App constructor.

It stopped updating? Refresh the page. If your app sends no data for 90 seconds, the polling interval of the raw event view gradually increases to 30 minutes. It will speed up again after a poll that sees new data, or when you refresh the page.

Old data vanished? The raw event stream keeps a limited number of events for no more than two hours, so you can’t scroll back to individual old events.

Usage telemetry isn’t designed for inspecting individual events. If you need to do that, take a look at Search your diagnostic logs in Application Insights.

  • If you see configuration instructions on the USAGE pages, wait a few minutes and refresh the page.

  • You should see data on the USAGE/Environment pages.

    To see data on the USAGE/Features pages, you have to insert some code to track events and metrics. See Track usage events and metrics in your Windows app.

  • Make sure the time range selector at the top right of the graph includes today. If you’re on one of the pages with a small selector chart, drag across the chart to make sure the selected time range goes right up to the present time.

If your app acts as the client to a web service, you might also want to monitor the performance of the web application. In that case, you will probably want to make the client app data appear under the same application component name as the server data, so that you can easily correlate events between the two.

To configure your client and server projects to send data to the same application component, edit ApplicationInsights.config in each project so that the ComponentID and ComponentName fields are the same.

  1. Add Application Insights to your server project, unless you’ve done that already.

  2. Edit ApplicationInsights.config in each project so that the ComponentID and ComponentName fields are the same.

    Redeploy both projects.

  3. If you need to transfer availability tests from one application component to another, edit the notification configuration files.

  4. Delete the old component name that you no longer use.

    In Overview, Components, use Remove

If your project is written in C++ or JavaScript, or you use Visual Studio 2012, use this method to configure your app for Application Insights.

  1. Add to your project the NuGet package Application Insights Telemetry SDK for Windows Store Apps or for Windows Phone apps.

    1. In Visual Studio, open the NuGet package manager on your project.

      In the project context menu, Manage NuGet Package

      Notice that you must open the NuGet manager on the project, not on the Tools menu.

    2. Search on "Application Insights". Include the quotation marks.

      Choose Online and search "Application Insights"

    This package installs a project reference to the Application Insights SDK assembly. The assembly might not appear under References until you restart Visual Studio, but you can still use it.

  2. Get the component ID for your Application Insights application component.

    1. In Application Insights, add an application component for Windows Store.

      Overview, Add Application, No, Windows Store

    2. Enter a name for your app. If you have already set up monitoring for a web service for this app, enter the same app component name if you want the usage data to appear along with the server availability and performance data.

      In Name your App, enter a name and click Create

    3. Copy the 32-character GUID from the code snippet. This is your component ID.

      Copy the 32-character GUID from a later step.

  3. In your application code, insert:

    //In default.js, in the initialization section of app.onActivated()
    // or the "activated" app.addEventListener function, depending on the project template.
    Microsoft.ApplicationInsights.Telemetry.WindowsStore.ClientAnalyticsSession.default
      .start("your component id");
    
  4. Run your app (F5).

  5. In Application Insights, open the Diagnostics/Streaming Data page and select your application name. Data appears in the page whenever you suspend and resume your app.

Publish your app and view the results.

Show:
© 2014 Microsoft