Node module to help VS Code extensions send telemetry using application insights
Перейти к файлу
Logan Ramos 6ae3c8a857
Bump version for release (#218)
2024-11-20 11:37:38 -08:00
.github/workflows Drop support for node 12 in CI 2023-07-06 10:14:25 -04:00
.vscode Initial scaffolding for a web version of the module 2021-07-16 16:00:34 -04:00
build/azure-pipelines Remove Node 14, and 16 from test matrix. Add Node 18 and Node 20 (#189) 2023-11-01 19:40:18 +01:00
dist Update readme + support connection string (#211) 2024-07-30 09:35:15 -07:00
src accept instrumentation and connection string (#216) 2024-11-19 11:17:31 -08:00
test Allow undefined for measurements (#203) 2024-03-20 09:16:50 -07:00
.editorconfig Initial scaffolding for a web version of the module 2021-07-16 16:00:34 -04:00
.eslintignore Initial scaffolding for a web version of the module 2021-07-16 16:00:34 -04:00
.eslintrc.json Initial scaffolding for a web version of the module 2021-07-16 16:00:34 -04:00
.gitignore Update typings entry 2022-08-31 17:20:17 -04:00
.npmignore Ignore a few more unnecessary files in the bundle 2022-11-15 11:34:56 -05:00
LICENSE initial commit 2016-02-05 15:46:35 -08:00
README.md Update readme + support connection string (#211) 2024-07-30 09:35:15 -07:00
SECURITY.md Microsoft mandatory file 2022-05-16 22:00:48 +00:00
injectVersion.js Update to using latesst telemetry API 2022-12-15 09:49:25 -05:00
package-lock.json Bump version for release (#218) 2024-11-20 11:37:38 -08:00
package.json Bump version for release (#218) 2024-11-20 11:37:38 -08:00
tsconfig.json Don't use json module 2022-08-31 16:12:23 -04:00
tsfmt.json upgrade appinsights; respect config setting 2017-02-20 18:02:34 -08:00

README.md

@vscode/extension-telemetry

This module provides a consistent way for extensions to report telemetry over Application Insights. The module respects the user's decision about whether or not to send telemetry data. See telemetry extension guidelines for more information on using telemetry in your extension.

Follow guide to set up Application Insights in Azure and get your connection string. Don't worry about hardcoding it, it is not sensitive.

Install

With npm: npm install @vscode/extension-telemetry

With yarn: yarn add @vscode/extension-telemetry

Usage

Setup

import * as vscode from 'vscode';
import TelemetryReporter from '@vscode/extension-telemetry';

// the connection string
const connectionString = '<your connection string>';

// telemetry reporter
let reporter;

function activate(context: vscode.ExtensionContext) {
   // create telemetry reporter on extension activation
   reporter = new TelemetryReporter(connectionString);
   // ensure it gets properly disposed. Upon disposal the events will be flushed
   context.subscriptions.push(reporter);
}

Sending Events

Use this method for sending general events to App Insights.

// send event any time after activation
reporter.sendTelemetryEvent('sampleEvent', { 'stringProp': 'some string' }, { 'numericMeasure': 123 });

Sending Errors as Events

Use this method for sending error telemetry as traditional events to App Insights. This method will automatically drop error properties in certain environments for first party extensions. The last parameter is an optional list of case-sensitive properties that should be dropped. If no array is passed, we will drop all properties but still send the event.

// send an error event any time after activation
reporter.sendTelemetryErrorEvent('sampleErrorEvent', { 'stringProp': 'some string', 'stackProp': 'some user stack trace' }, { 'numericMeasure': 123 }, [ 'stackProp' ]);

Common Properties

  • Extension Name common.extname - The extension name
  • Extension Version common.extversion - The extension version
  • Machine Identifier common.vscodemachineid - A common machine identifier generated by VS Code
  • Session Identifier common.vscodesessionid - A session identifier generated by VS Code
  • VS Code Version common.vscodeversion - The version of VS Code running the extension
  • OS common.os - The OS running VS Code
  • Platform Version common.platformversion - The version of the OS/Platform
  • Product common.product - What Vs code is hosted in, i.e. desktop, github.dev, codespaces.
  • UI Kind common.uikind - Web or Desktop indicating where VS Code is running
  • Remote Name common.remotename - A name to identify the type of remote connection. other indicates a remote connection not from the 3 main extensions (ssh, docker, wsl).
  • Architecture common.nodeArch - What architecture of node is running. i.e. arm or x86. On the web it will just say web.

License

MIT