How to use vscode-extension-telemetry - 10 common examples

To help you get started, we’ve selected a few vscode-extension-telemetry examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github microsoft / vscode-azuretools / ui / src / createTelemetryReporter.ts View on Github external
export function createTelemetryReporter(ctx: vscode.ExtensionContext): ITelemetryReporter {
    const { extensionName, extensionVersion, aiKey } = getPackageInfo(ctx);

    let newReporter: ITelemetryReporter;

    if (debugTelemetryEnabled) {
        console.warn(`${extensionName}: DEBUGTELEMETRY mode enabled (${debugTelemetryVerbose ? 'verbose' : 'quiet'}) - not sending telemetry`);
        newReporter = new DebugReporter(extensionName, extensionVersion, debugTelemetryVerbose);
    } else {
        const reporter: TelemetryReporter = new TelemetryReporter(extensionName, extensionVersion, aiKey);
        ctx.subscriptions.push(reporter);
        newReporter = reporter;
    }

    // Send an event with some general info
    newReporter.sendTelemetryEvent('info', {
        isActivationEvent: 'true',
        product: vscode.env.appName,
        language: vscode.env.language
    });

    return newReporter;
}
github PowerShell / vscode-powershell / src / main.ts View on Github external
export function activate(context: vscode.ExtensionContext): void {
    // create telemetry reporter on extension activation
    telemetryReporter = new TelemetryReporter(PackageJSON.name, PackageJSON.version, AI_KEY);

    // If both extensions are enabled, this will cause unexpected behavior since both register the same commands
    if (PackageJSON.name.toLowerCase() === "powershell-preview"
        && vscode.extensions.getExtension("ms-vscode.powershell")) {
        vscode.window.showWarningMessage(
            "'PowerShell' and 'PowerShell Preview' are both enabled. Please disable one for best performance.");
    }

    checkForUpdatedVersion(context, PackageJSON.version);

    vscode.languages.setLanguageConfiguration(
        PowerShellLanguageId,
        {
            wordPattern: /(-?\d*\.\d\w*)|([^\`\~\!\@\#\%\^\&\*\(\)\=\+\[\{\]\}\\\|\;\'\"\,\.\<\>\/\?\s]+)/g,

            indentationRules: {
github DonJayamanne / vscodeJupyter / src / telemetry / main.ts View on Github external
export function sendTelemetryEvent(eventName: string, properties?: {
    [key: string]: string;
}, measures?: {
    [key: string]: number;
}) {
    // Check out later (no idea why default import isn't being picked up)
    try {
        reporter = reporter ? reporter : new TelemetryReporter(extensionId, extensionVersion, aiKey);
    }
    catch (ex) {
        reporter = reporter ? reporter : new TelemetryReporter.default(extensionId, extensionVersion, aiKey);
    }

    try {
        reporter.sendTelemetryEvent.apply(reporter, arguments);
    }
    catch (ex) {

    }
}
github microsoft / vscode-iot-workbench / src / telemetry.ts View on Github external
static initialize(context: vscode.ExtensionContext): void {
    const packageInfo = getPackageInfo(context);
    if (!packageInfo) {
      console.log('Unable to initialize telemetry');
      return;
    }
    if (!packageInfo.aiKey) {
      console.log(
          'Unable to initialize telemetry, please make sure AIKey is set in package.json');
      return;
    }
    this._reporter = new TelemetryReporter(
        packageInfo.name, packageInfo.version, packageInfo.aiKey);
  }
}
github microsoft / vscode-arduino / src / logger / telemetry-transport.ts View on Github external
constructor(options: any) {
        super({ ...options, context: null });
        this.name = "telemetry";
        if (!options.context) {
            winston.error("Failed to initialize telemetry, please set the vscode context in options.");
            return;
        }
        const packageInfo = getPackageInfo(options.context);
        if (!packageInfo.aiKey) {
            winston.error("Failed to initialize telemetry due to no aiKey in package.json.");
            return;
        }
        this.reporter = new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
    }
github microsoft / qsharp-compiler / src / VSCodeExtension / src / telemetry.ts View on Github external
constructor(ctx: vscode.ExtensionContext) {
        super(() => reporter.dispose());
        let packageInfo = getPackageInfo(ctx);
        if (packageInfo !== undefined && packageInfo.enableTelemetry) {
            reporter = new TelemetryReporter(packageInfo.name, packageInfo.version, packageInfo.aiKey);
        }
    }
}
github IBM-Blockchain / blockchain-vscode-extension / client / src / util / Reporter.ts View on Github external
private constructor() {
        this.telemetryReporter = new TelemetryReporter('IBMBlockchain.ibm-blockchain-platform', this.getVersion(), this.key);
    }
github microsoft / vscode-go / src / util.ts View on Github external
export function sendTelemetryEvent(eventName: string, properties?: {
	[key: string]: string;
}, measures?: {
	[key: string]: number;
}): void {

	let temp = vscode.extensions.getExtension(extensionId).packageJSON.contributes;
	telemtryReporter = telemtryReporter ? telemtryReporter : new TelemetryReporter(extensionId, extensionVersion, aiKey);
	telemtryReporter.sendTelemetryEvent(eventName, properties, measures);
}
github OmniSharp / omnisharp-vscode / src / main.ts View on Github external
export async function activate(context: vscode.ExtensionContext): Promise {

    const extensionId = CSharpExtensionId;
    const extension = vscode.extensions.getExtension(extensionId);
    const extensionVersion = extension.packageJSON.version;
    const aiKey = extension.packageJSON.contributes.debuggers[0].aiKey;
    const reporter = new TelemetryReporter(extensionId, extensionVersion, aiKey);

    util.setExtensionPath(extension.extensionPath);

    const eventStream = new EventStream();
    const optionStream = createOptionStream(vscode);
    let optionProvider = new OptionProvider(optionStream);

    let dotnetChannel = vscode.window.createOutputChannel('.NET');
    let dotnetChannelObserver = new DotNetChannelObserver(dotnetChannel);
    let dotnetLoggerObserver = new DotnetLoggerObserver(dotnetChannel);
    eventStream.subscribe(dotnetChannelObserver.post);
    eventStream.subscribe(dotnetLoggerObserver.post);

    let dotnetTestChannel = vscode.window.createOutputChannel(".NET Test Log");
    let dotnetTestChannelObserver = new DotNetTestChannelObserver(dotnetTestChannel);
    let dotnetTestLoggerObserver = new DotNetTestLoggerObserver(dotnetTestChannel);
github dzsquared / query-editor-boost / src / telemetryHelper.ts View on Github external
constructor(context:vscode.ExtensionContext) {
        this.reporter = new TelemetryReporter(extensionId, extensionVersion, key);
        context.subscriptions.push(this.reporter);
    }

vscode-extension-telemetry

A module for first party microsoft extensions to report consistent telemetry.

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis

Popular vscode-extension-telemetry functions

Similar packages