![Oracle Drags Its Feet in the JavaScript Trademark Dispute](https://cdn.sanity.io/images/cgdhsj6q/production/919c3b22c24f93884c548d60cbb338e819ff2435-1024x1024.webp?w=400&fit=max&auto=format)
Security News
Oracle Drags Its Feet in the JavaScript Trademark Dispute
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
vscode-telemetry
Advanced tools
A helper package for VS Code developers to send telemetry events from the extension host and any webview.
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.
With NPM:
npm install --save-dev vscode-telemetry
With Yarn
yarn add --dev vscode-telemetry
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.
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 () {
// ...
}
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(...)
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' })
// ...
}
}
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')
You have an idea on how to improve the package, please send us a pull request! Have a look into our contributing guidelines.
Running into issues or are you missing a specific usecase? Feel free to file an issue or join our Discord.
Copyright 2022 © Stateful – Apache 2.0 License
FAQs
A helper package for VS Code developers to send telemetry events from the extension host and any webview.
The npm package vscode-telemetry receives a total of 80 weekly downloads. As such, vscode-telemetry popularity was classified as not popular.
We found that vscode-telemetry demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 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
Oracle seeks to dismiss fraud claims in the JavaScript trademark dispute, delaying the case and avoiding questions about its right to the name.
Security News
The Linux Foundation is warning open source developers that compliance with global sanctions is mandatory, highlighting legal risks and restrictions on contributions.
Security News
Maven Central now validates Sigstore signatures, making it easier for developers to verify the provenance of Java packages.