mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-25 02:58:56 +01:00
GitHub - add push error handler telemetry to understand usage (#185573)
* GitHub - add push error handler telemetry to understand usage * Add yarn.lock file * Pull request feedback
This commit is contained in:
@@ -4,6 +4,7 @@
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { commands, Disposable, ExtensionContext, extensions, l10n, LogLevel, LogOutputChannel, window } from 'vscode';
|
||||
import TelemetryReporter from '@vscode/extension-telemetry';
|
||||
import { GithubRemoteSourceProvider } from './remoteSourceProvider';
|
||||
import { API, GitExtension } from './typings/git';
|
||||
import { registerCommands } from './commands';
|
||||
@@ -29,8 +30,12 @@ export function activate(context: ExtensionContext): void {
|
||||
disposables.push(logger.onDidChangeLogLevel(onDidChangeLogLevel));
|
||||
onDidChangeLogLevel(logger.logLevel);
|
||||
|
||||
const { aiKey } = require('../package.json') as { aiKey: string };
|
||||
const telemetryReporter = new TelemetryReporter(aiKey);
|
||||
disposables.push(telemetryReporter);
|
||||
|
||||
disposables.push(initializeGitBaseExtension());
|
||||
disposables.push(initializeGitExtension(context, logger));
|
||||
disposables.push(initializeGitExtension(context, telemetryReporter, logger));
|
||||
}
|
||||
|
||||
function initializeGitBaseExtension(): Disposable {
|
||||
@@ -78,7 +83,7 @@ function setGitHubContext(gitAPI: API, disposables: DisposableStore) {
|
||||
}
|
||||
}
|
||||
|
||||
function initializeGitExtension(context: ExtensionContext, logger: LogOutputChannel): Disposable {
|
||||
function initializeGitExtension(context: ExtensionContext, telemetryReporter: TelemetryReporter, logger: LogOutputChannel): Disposable {
|
||||
const disposables = new DisposableStore();
|
||||
|
||||
let gitExtension = extensions.getExtension<GitExtension>('vscode.git');
|
||||
@@ -93,7 +98,7 @@ function initializeGitExtension(context: ExtensionContext, logger: LogOutputChan
|
||||
disposables.add(registerCommands(gitAPI));
|
||||
disposables.add(new GithubCredentialProviderManager(gitAPI));
|
||||
disposables.add(new GithubBranchProtectionProviderManager(gitAPI, context.globalState, logger));
|
||||
disposables.add(gitAPI.registerPushErrorHandler(new GithubPushErrorHandler()));
|
||||
disposables.add(gitAPI.registerPushErrorHandler(new GithubPushErrorHandler(telemetryReporter)));
|
||||
disposables.add(gitAPI.registerRemoteSourcePublisher(new GithubRemoteSourcePublisher(gitAPI)));
|
||||
disposables.add(new GitHubCanonicalUriProvider(gitAPI));
|
||||
disposables.add(new VscodeDevShareProvider(gitAPI));
|
||||
|
||||
@@ -5,6 +5,7 @@
|
||||
|
||||
import { TextDecoder } from 'util';
|
||||
import { commands, env, ProgressLocation, Uri, window, workspace, QuickPickOptions, FileType, l10n, Disposable, TextDocumentContentProvider } from 'vscode';
|
||||
import TelemetryReporter from '@vscode/extension-telemetry';
|
||||
import { getOctokit } from './auth';
|
||||
import { GitErrorCodes, PushErrorHandler, Remote, Repository } from './typings/git';
|
||||
import * as path from 'path';
|
||||
@@ -99,7 +100,7 @@ export class GithubPushErrorHandler implements PushErrorHandler {
|
||||
private disposables: Disposable[] = [];
|
||||
private commandErrors = new CommandErrorOutputTextDocumentContentProvider();
|
||||
|
||||
constructor() {
|
||||
constructor(private readonly telemetryReporter: TelemetryReporter) {
|
||||
this.disposables.push(workspace.registerTextDocumentContentProvider('github-output', this.commandErrors));
|
||||
}
|
||||
|
||||
@@ -126,15 +127,41 @@ export class GithubPushErrorHandler implements PushErrorHandler {
|
||||
|
||||
if (error.gitErrorCode === GitErrorCodes.PermissionDenied) {
|
||||
await this.handlePermissionDeniedError(repository, remote, refspec, owner, repo);
|
||||
|
||||
/* __GDPR__
|
||||
"pushErrorHandler" : {
|
||||
"owner": "lszomoru",
|
||||
"handler": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this.telemetryReporter.sendTelemetryEvent('pushErrorHandler', { handler: 'PermissionDenied' });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Push protection
|
||||
if (/GH009: Secrets detected!/i.test(error.stderr)) {
|
||||
await this.handlePushProtectionError(owner, repo, error.stderr);
|
||||
|
||||
/* __GDPR__
|
||||
"pushErrorHandler" : {
|
||||
"owner": "lszomoru",
|
||||
"handler": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this.telemetryReporter.sendTelemetryEvent('pushErrorHandler', { handler: 'PushRejected.PushProtection' });
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/* __GDPR__
|
||||
"pushErrorHandler" : {
|
||||
"owner": "lszomoru",
|
||||
"handler": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
|
||||
}
|
||||
*/
|
||||
this.telemetryReporter.sendTelemetryEvent('pushErrorHandler', { handler: 'None' });
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user