npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

vscode-telemetry

v2.0.0

Published

A helper package for VS Code developers to send telemetry events from the extension host and any webview.

Downloads

352

Readme

VS Code Telemetry Test Changes

A helper package for VS Code developers to send telemetry events from the extension host and any webview.

While @vscode/extension-telemetry is recommended to be used for sending telemetry events within VS Code extensions (for VS Code v1.70.0 and upwards), it requires some configuration to allow sending them across extension host and webviews. This package uses @vscode/extension-telemetry under the hood and helps to overcome that issue.

Install

With NPM:

npm install --save-dev vscode-telemetry

With Yarn

yarn add --dev vscode-telemetry

Usage

The interface of the telemetry reporter is identical to @vscode/extension-telemetry as it is being used under the hood. Setup and usage differ a bit though.

Setup

In order to register the reporter you need to call the configure method and pass in the extension context as well as the instrumentation key that you can receive from your Azure project.

import vscode from "vscode";
import { TelemetryReporter } from 'vscode-telemetry';

export async function activate(context: vscode.ExtensionContext) {
    TelemetryReporter.configure(process.env.INSTRUMENTATION_KEY!);
    // ...
}

export deactivate () {
    // ...
}

Setup Webviews

Webviews in VS Code can be registered using the WebviewViewProvider or calling vscode.window.createWebviewPanel(...). For both methods there are slight adjustment necessary to connect the reporter between both environments.

If you use a WebviewViewProvider rather than calling resolveWebviewView you have to call resolveWebviewTelemetryView, e.g.:

import { TelemetryViewProvider } from 'vscode-telemetry';
import type { WebviewView, WebviewViewProvider } from 'vscode';

export default class TodoAppPanel extends TelemetryViewProvider implements WebviewViewProvider {
    async resolveWebviewTelemetryView(webviewView: WebviewView): Promise<void> {
        webviewView.webview.html = await getHtmlForWebview(webviewView.webview, this._context);
        // ...
    }
}

If you create a webview via vscode.window.createWebviewPanel(...) just import the replacement method from this package, e.g.:

import { createWebviewTelemetryPanel } from 'vscode-telemetry';

const panel = createWebviewTelemetryPanel(...)

Usage in Extension Host

Now everywhere within your VS Code extension you can send events by importing TelemetryReporter and call its methods, e.g.:

import { TelemetryReporter } from 'vscode-telemetry';

export class SomeController {
    private someMethod () {
        TelemetryReporter.sendTelemetryEvent('eventName', { some: 'property' })
        // ...
    }
}

Usage in WebView

When using the reporter in the webview, just import it from the vscode-telemetry/webview package and confgure it as follows:

import { TelemetryReporter } from 'vscode-telemetry/webview';

const vscode = acquireVsCodeApi()
const reporter = TelemetryReporter.configure(vscode)

reporter.sendTelemetryEvent('Hello World')

Contribute

You have an idea on how to improve the package, please send us a pull request! Have a look into our contributing guidelines.

Getting Help

Running into issues or are you missing a specific usecase? Feel free to file an issue or join our Discord.