How to integrate Application Insights monitoring in your VSTS extension
Monitoring your team services extension is an important DevOps practice. In this article we’ll demonstrate how to integrate Application Insights telemetry in your extension by using our new Telemetry Client for Team Services extension.
Prerequisite – You need an Azure subscription and an Application Insights resource.
Step 1: Required modules
- telemetryclient-team-services-extension – Telemetry Client for Team Services extension
Step 2: Automatic import of SDK during package creation
The module files will be imported to the lib folder.
Step 4: Create the telemetry client settings
Create a TelemetryClientSettings.ts configuration file in your src folder.
|key||your Application Insights Instrumentation key||required|
|extensioncontext||the name of the context of your extension, e.g the name of the extension||required|
|disableTelemetry||true or false, default is false, to disable the telemetry tracking||optional|
|disableAjaxTracking||true or false, default is false, to not track ajax dependencies||optional|
|enableDebug||true or false, default is false, to enable debug mode of application insight||optional|
Step 5: Add telemetry code to your extension
Add code to your extension to send telemetry data to Application Insights.
Here’s an example:
 Import modules of the TelemetryClient and the telemetry client settings configuration
 Call the getClient method to send telemetry data.
Step 6: Build the TelemetryClient with your code
We need to import the code for the TelemetryClient and Settings class in our extension and construct a single file. See the How to create or upgrade your team services extension in 4 steps , step 2, for an overview of the minification process with webpack.
Notice the telemetryclient and telemetryClientSettings class at the end of the above code.
- How to create or upgrade your team services extension in 4 steps
- Telemetry Client for Team Services extension (sources, npm package)