本文整理汇总了TypeScript中vscode-extension-telemetry.sendTelemetryEvent函数的典型用法代码示例。如果您正苦于以下问题:TypeScript sendTelemetryEvent函数的具体用法?TypeScript sendTelemetryEvent怎么用?TypeScript sendTelemetryEvent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sendTelemetryEvent函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: clone
@command('git.clone')
async clone(): Promise<void> {
const url = await window.showInputBox({
prompt: localize('repourl', "Repository URL"),
ignoreFocusOut: true
});
if (!url) {
this.telemetryReporter.sendTelemetryEvent('clone', { outcome: 'no_URL' });
return;
}
const config = workspace.getConfiguration('git');
const value = config.get<string>('defaultCloneDirectory') || os.homedir();
const parentPath = await window.showInputBox({
prompt: localize('parent', "Parent Directory"),
value,
ignoreFocusOut: true
});
if (!parentPath) {
this.telemetryReporter.sendTelemetryEvent('clone', { outcome: 'no_directory' });
return;
}
const clonePromise = this.git.clone(url, parentPath);
try {
window.withProgress({ location: ProgressLocation.SourceControl, title: localize('cloning', "Cloning git repository...") }, () => clonePromise);
window.withProgress({ location: ProgressLocation.Window, title: localize('cloning', "Cloning git repository...") }, () => clonePromise);
const repositoryPath = await clonePromise;
const open = localize('openrepo', "Open Repository");
const result = await window.showInformationMessage(localize('proposeopen', "Would you like to open the cloned repository?"), open);
const openFolder = result === open;
this.telemetryReporter.sendTelemetryEvent('clone', { outcome: 'success' }, { openFolder: openFolder ? 1 : 0 });
if (openFolder) {
commands.executeCommand('vscode.openFolder', Uri.file(repositoryPath));
}
} catch (err) {
if (/already exists and is not an empty directory/.test(err && err.stderr || '')) {
this.telemetryReporter.sendTelemetryEvent('clone', { outcome: 'directory_not_empty' });
} else {
this.telemetryReporter.sendTelemetryEvent('clone', { outcome: 'error' });
}
throw err;
}
}
示例2:
Promise.all([this.getUserId(), this.getPlatformInformation()]).then(() => {
properties['userId'] = this.userId;
properties['distribution'] = (this.platformInformation && this.platformInformation.distribution) ?
`${this.platformInformation.distribution.name}, ${this.platformInformation.distribution.version}` : '';
this.reporter.sendTelemetryEvent(eventName, properties, measures);
});
示例3: sendEvent
function sendEvent(event: TelemetryEvent) {
if (!reporter) {
return;
}
const dimensions: { [key: string]: string } = {};
for (const key of DimensionEntries) {
const value = (event as any)[key];
if (value !== undefined) {
dimensions[key] = String(value);
}
}
const measurements: { [key: string]: number } = {};
for (const key of MeasurementEntries) {
const value = (event as any)[key];
if (value !== undefined) {
measurements[key] = value;
}
}
reporter.sendTelemetryEvent(event.eventName, dimensions, measurements);
if (isDebug) {
// tslint:disable-next-line:no-console
console.log(event.eventName, { eventName: event.eventName, dimensions, measurements });
}
}
示例4: showPreview
function showPreview(uri?: vscode.Uri, sideBySide: boolean = false) {
let resource = uri;
if (!(resource instanceof vscode.Uri)) {
if (vscode.window.activeTextEditor) {
// we are relaxed and don't check for markdown files
resource = vscode.window.activeTextEditor.document.uri;
}
}
if (!(resource instanceof vscode.Uri)) {
if (!vscode.window.activeTextEditor) {
// this is most likely toggling the preview
return vscode.commands.executeCommand('markdown.showSource');
}
// nothing found that could be shown or toggled
return;
}
const thenable = vscode.commands.executeCommand('vscode.previewHtml',
getMarkdownUri(resource),
getViewColumn(sideBySide),
`Preview '${path.basename(resource.fsPath)}'`);
if (telemetryReporter) {
telemetryReporter.sendTelemetryEvent('openPreview', {
where: sideBySide ? 'sideBySide' : 'inPlace',
how: (uri instanceof vscode.Uri) ? 'action' : 'pallete'
});
}
return thenable;
}
示例5: sendEvent
public static sendEvent(eventName: string, properties?: { [key: string]: string; }): void {
if (!this._client) {
return;
}
this._client.sendTelemetryEvent(eventName, properties);
}
示例6: localize
const result = (...args) => {
if (!skipModelCheck && !this.model) {
window.showInformationMessage(localize('disabled', "Git is either disabled or not supported in this workspace"));
return;
}
this.telemetryReporter.sendTelemetryEvent('git.command', { command: id });
const result = Promise.resolve(method.apply(this, args));
return result.catch(async err => {
let message: string;
switch (err.gitErrorCode) {
case GitErrorCodes.DirtyWorkTree:
message = localize('clean repo', "Please clean your repository working tree before checkout.");
break;
case GitErrorCodes.PushRejected:
message = localize('cant push', "Can't push refs to remote. Run 'Pull' first to integrate your changes.");
break;
default:
const hint = (err.stderr || err.message || String(err))
.replace(/^error: /mi, '')
.replace(/^> husky.*$/mi, '')
.split(/[\r\n]/)
.filter(line => !!line)
[0];
message = hint
? localize('git error details', "Git: {0}", hint)
: localize('git error', "Git error");
break;
}
if (!message) {
console.error(err);
return;
}
const outputChannel = this.outputChannel as OutputChannel;
const openOutputChannelChoice = localize('open git log', "Open Git Log");
const choice = await window.showErrorMessage(message, openOutputChannelChoice);
if (choice === openOutputChannelChoice) {
outputChannel.show();
}
});
};
示例7:
.then(() => {
telemetryProps['installStage'] = installationStage;
telemetryProps['platform.architecture'] = platformInfo.architecture;
telemetryProps['platform.platform'] = platformInfo.platform;
telemetryProps['platform.runtimeId'] = platformInfo.runtimeId;
if (platformInfo.distribution) {
telemetryProps['platform.distribution'] = platformInfo.distribution.toString();
}
reporter.sendTelemetryEvent('Acquisition', telemetryProps);
logger.appendLine();
installationStage = '';
logger.appendLine('Finished');
statusItem.dispose();
})
示例8: sum
.then(workspaceInfo => {
if (workspaceInfo.DotNet && workspaceInfo.DotNet.Projects.length > 0) {
measures['projectjson.projectcount'] = workspaceInfo.DotNet.Projects.length;
measures['projectjson.filecount'] = sum(workspaceInfo.DotNet.Projects, p => safeLength(p.SourceFiles));
}
if (workspaceInfo.MsBuild && workspaceInfo.MsBuild.Projects.length > 0) {
measures['msbuild.projectcount'] = workspaceInfo.MsBuild.Projects.length;
measures['msbuild.filecount'] = sum(workspaceInfo.MsBuild.Projects, p => safeLength(p.SourceFiles));
measures['msbuild.unityprojectcount'] = sum(workspaceInfo.MsBuild.Projects, p => p.IsUnityProject ? 1 : 0);
measures['msbuild.netcoreprojectcount'] = sum(workspaceInfo.MsBuild.Projects, p => utils.isNetCoreProject(p) ? 1 : 0);
}
// TODO: Add measurements for script.
reporter.sendTelemetryEvent('OmniSharp.Start', null, measures);
});
示例9: showPreview
function showPreview(cspArbiter: ExtensionContentSecurityPolicyArbiter, uri?: vscode.Uri, sideBySide: boolean = false) {
let resource = uri;
if (!(resource instanceof vscode.Uri)) {
if (vscode.window.activeTextEditor) {
// we are relaxed and don't check for markdown files
resource = vscode.window.activeTextEditor.document.uri;
}
}
if (!(resource instanceof vscode.Uri)) {
if (!vscode.window.activeTextEditor) {
// this is most likely toggling the preview
return vscode.commands.executeCommand('markdown.showSource');
}
// nothing found that could be shown or toggled
return;
}
const thenable = vscode.commands.executeCommand('vscode.previewHtml',
getMarkdownUri(resource),
getViewColumn(sideBySide),
localize('previewTitle', 'Preview {0}', path.basename(resource.fsPath)),
{
allowScripts: true,
allowSvgs: cspArbiter.shouldAllowSvgsForResource(resource)
});
if (telemetryReporter) {
/* __GDPR__
"openPreview" : {
"where" : { "classification": "SystemMetaData", "purpose": "FeatureInsight" },
"how": { "classification": "SystemMetaData", "purpose": "FeatureInsight" }
}
*/
telemetryReporter.sendTelemetryEvent('openPreview', {
where: sideBySide ? 'sideBySide' : 'inPlace',
how: (uri instanceof vscode.Uri) ? 'action' : 'pallete'
});
}
return thenable;
}
示例10: return
return (...args) => {
if (!this.model) {
window.showInformationMessage(localize('disabled', "Git is either disabled or not supported in this workspace"));
return;
}
this.telemetryReporter.sendTelemetryEvent('git.command', { command: id });
const result = Promise.resolve(method.apply(this, args));
return result.catch(async err => {
let message: string;
switch (err.gitErrorCode) {
case 'DirtyWorkTree':
message = localize('clean repo', "Please clean your repository working tree before checkout.");
break;
default:
const lines = (err.stderr || err.message || String(err))
.replace(/^error: /, '')
.split(/[\r\n]/)
.filter(line => !!line);
message = lines[0] || 'Git error';
break;
}
if (!message) {
console.error(err);
return;
}
const outputChannel = this.outputChannel as OutputChannel;
const openOutputChannelChoice = localize('open git log', "Open Git Log");
const choice = await window.showErrorMessage(message, openOutputChannelChoice);
if (choice === openOutputChannelChoice) {
outputChannel.show();
}
});
};