
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@vscode/extension-telemetry
Advanced tools
A module for Visual Studio Code extensions to report consistent telemetry.
@vscode/extension-telemetry is an npm package designed to help developers collect telemetry data from their Visual Studio Code extensions. This data can include events, errors, and performance metrics, which can be used to improve the extension's functionality and user experience.
Initialize Telemetry Reporter
This feature allows you to initialize a telemetry reporter with your extension's ID, version, and an Application Insights key. This setup is necessary to start collecting telemetry data.
const TelemetryReporter = require('@vscode/extension-telemetry');
const reporter = new TelemetryReporter(extensionId, extensionVersion, aiKey);
Send Telemetry Event
This feature allows you to send a telemetry event with optional properties and measurements. It helps track specific actions or occurrences within your extension.
reporter.sendTelemetryEvent('eventName', { property1: 'value1' }, { metric1: 100 });
Send Telemetry Error
This feature allows you to send error events, which can include additional properties and metrics. It is useful for tracking and diagnosing errors that occur in your extension.
reporter.sendTelemetryErrorEvent('errorName', { errorProperty: 'value' }, { errorMetric: 1 });
Dispose Telemetry Reporter
This feature ensures that all pending telemetry data is sent before the reporter is disposed of. It is important to call this method when your extension is deactivated to ensure no data is lost.
reporter.dispose();
The 'applicationinsights' package is a Node.js SDK for Azure Application Insights, which provides a broader set of features for monitoring and diagnosing applications. While @vscode/extension-telemetry is specifically tailored for VS Code extensions, 'applicationinsights' can be used for a wider range of applications, offering more comprehensive telemetry capabilities.
Raven.js is a JavaScript client for Sentry, a popular error tracking and monitoring platform. It provides similar error tracking capabilities as @vscode/extension-telemetry but is more focused on capturing and reporting errors across web applications rather than being specific to VS Code extensions.
Winston is a versatile logging library for Node.js that can be used to log events and errors. While it does not provide telemetry in the same way as @vscode/extension-telemetry, it can be used to log and manage logs in a structured way, which can be useful for debugging and monitoring applications.
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.
With npm:
npm install @vscode/extension-telemetry
With yarn:
yarn add @vscode/extension-telemetry
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);
}
Use this method for sending general events to App Insights.
// send event any time after activation
reporter.sendTelemetryEvent('sampleEvent', { 'stringProp': 'some string' }, { 'numericMeasure': 123 });
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.extname
- The extension namecommon.extversion
- The extension versioncommon.vscodemachineid
- A common machine identifier generated by VS Codecommon.vscodesessionid
- A session identifier generated by VS Codecommon.vscodecommithash
- A VS Code commit hashcommon.vscodeversion
- The version of VS Code running the extensioncommon.os
- The OS running VS Codecommon.platformversion
- The version of the OS/Platformcommon.product
- What Vs code is hosted in, i.e. desktop, github.dev, codespaces.common.uikind
- Web or Desktop indicating where VS Code is runningcommon.remotename
- A name to identify the type of remote connection. other
indicates a remote connection not from the 3 main extensions (ssh, docker, wsl).common.nodeArch
- What architecture of node is running. i.e. arm or x86. On the web it will just say web
.FAQs
A module for Visual Studio Code extensions to report consistent telemetry.
The npm package @vscode/extension-telemetry receives a total of 172,833 weekly downloads. As such, @vscode/extension-telemetry popularity was classified as popular.
We found that @vscode/extension-telemetry demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 8 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.