Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/client/application/diagnostics/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,12 @@ import { DiagnosticSeverity } from 'vscode';
import { IServiceContainer } from '../../ioc/types';
import { sendTelemetryEvent } from '../../telemetry';
import { EventName } from '../../telemetry/constants';
import { DiagnosticCodes } from './constants';
import { DiagnosticScope, IDiagnostic, IDiagnosticFilterService, IDiagnosticsService } from './types';

@injectable()
export abstract class BaseDiagnostic implements IDiagnostic {
constructor(public readonly code: string, public readonly message: string,
constructor(public readonly code: DiagnosticCodes, public readonly message: string,
public readonly severity: DiagnosticSeverity, public readonly scope: DiagnosticScope) { }
}

Expand Down
3 changes: 2 additions & 1 deletion src/client/application/diagnostics/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@
'use strict';

import { DiagnosticSeverity, Uri } from 'vscode';
import { DiagnosticCodes } from './constants';

export enum DiagnosticScope {
Global = 'Global',
WorkspaceFolder = 'WorkspaceFolder'
}

export interface IDiagnostic {
readonly code: string;
readonly code: DiagnosticCodes;
readonly message: string;
readonly severity: DiagnosticSeverity;
readonly scope: DiagnosticScope;
Expand Down
28 changes: 15 additions & 13 deletions src/client/common/logger.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// tslint:disable:no-console
// tslint:disable:no-console no-any

import { injectable } from 'inversify';
import { sendTelemetryEvent } from '../telemetry';
Expand Down Expand Up @@ -56,16 +56,18 @@ export enum LogOptions {
// tslint:disable-next-line:no-any
function argsToLogString(args: any[]): string {
try {
return (args || []).map((item, index) => {
try {
if (item.fsPath) {
return `Arg ${index + 1}: <Uri:${item.fsPath}>`;
return (args || [])
.map((item, index) => {
try {
if (item.fsPath) {
return `Arg ${index + 1}: <Uri:${item.fsPath}>`;
}
return `Arg ${index + 1}: ${JSON.stringify(item)}`;
} catch {
return `Arg ${index + 1}: UNABLE TO DETERMINE VALUE`;
}
return `Arg ${index + 1}: ${JSON.stringify(item)}`;
} catch {
return `Arg ${index + 1}: UNABLE TO DETERMINE VALUE`;
}
}).join(', ');
})
.join(', ');
} catch {
return '';
}
Expand Down Expand Up @@ -113,10 +115,10 @@ export namespace traceDecorators {
}
function trace(message: string, options: LogOptions = LogOptions.None, logLevel?: LogLevel) {
// tslint:disable-next-line:no-function-expression no-any
return function (_: Object, __: string, descriptor: TypedPropertyDescriptor<any>) {
return function(_: Object, __: string, descriptor: TypedPropertyDescriptor<any>) {
const originalMethod = descriptor.value;
// tslint:disable-next-line:no-function-expression no-any
descriptor.value = function (...args: any[]) {
descriptor.value = function(...args: any[]) {
const className = _ && _.constructor ? _.constructor.name : '';
// tslint:disable-next-line:no-any
function writeSuccess(returnValue?: any) {
Expand All @@ -140,7 +142,7 @@ function trace(message: string, options: LogOptions = LogOptions.None, logLevel?
}
if (ex) {
new Logger().logError(messagesToLog.join(', '), ex);
sendTelemetryEvent('ERROR', undefined, undefined, ex);
sendTelemetryEvent('ERROR' as any, undefined, undefined, ex);
Comment thread
DonJayamanne marked this conversation as resolved.
} else {
new Logger().logInformation(messagesToLog.join(', '));
}
Expand Down
2 changes: 1 addition & 1 deletion src/client/common/terminal/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ export class TerminalHelper implements ITerminalHelper {
return promise;
}
@traceDecorators.error('Failed to capture telemetry')
protected async sendTelemetry(resource: Resource, terminalShellType: TerminalShellType, eventName: string, promise: Promise<string[] | undefined>): Promise<void> {
protected async sendTelemetry(resource: Resource, terminalShellType: TerminalShellType, eventName: EventName, promise: Promise<string[] | undefined>): Promise<void> {
let hasCommands = false;
const interpreter = await this.interpreterService.getActiveInterpreter(resource);
let failed = false;
Expand Down
54 changes: 27 additions & 27 deletions src/client/datascience/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,33 +59,33 @@ export namespace HistoryMessages {
export const UpdateSettings = 'update_settings';
}

export namespace Telemetry {
export const ImportNotebook = 'DATASCIENCE.IMPORT_NOTEBOOK';
export const RunCell = 'DATASCIENCE.RUN_CELL';
export const RunCurrentCell = 'DATASCIENCE.RUN_CURRENT_CELL';
export const RunCurrentCellAndAdvance = 'DATASCIENCE.RUN_CURRENT_CELL_AND_ADVANCE';
export const RunAllCells = 'DATASCIENCE.RUN_ALL_CELLS';
export const DeleteAllCells = 'DATASCIENCE.DELETE_ALL_CELLS';
export const DeleteCell = 'DATASCIENCE.DELETE_CELL';
export const GotoSourceCode = 'DATASCIENCE.GOTO_SOURCE';
export const RestartKernel = 'DATASCIENCE.RESTART_KERNEL';
export const ExportNotebook = 'DATASCIENCE.EXPORT_NOTEBOOK';
export const Undo = 'DATASCIENCE.UNDO';
export const Redo = 'DATASCIENCE.REDO';
export const ShowHistoryPane = 'DATASCIENCE.SHOW_HISTORY_PANE';
export const ExpandAll = 'DATASCIENCE.EXPAND_ALL';
export const CollapseAll = 'DATASCIENCE.COLLAPSE_ALL';
export const SelectJupyterURI = 'DATASCIENCE.SELECT_JUPYTER_URI';
export const SetJupyterURIToLocal = 'DATASCIENCE.SET_JUPYTER_URI_LOCAL';
export const SetJupyterURIToUserSpecified = 'DATASCIENCE.SET_JUPYTER_URI_USER_SPECIFIED';
export const Interrupt = 'DATASCIENCE.INTERRUPT';
export const ExportPythonFile = 'DATASCIENCE.EXPORT_PYTHON_FILE';
export const ExportPythonFileAndOutput = 'DATASCIENCE.EXPORT_PYTHON_FILE_AND_OUTPUT';
export const StartJupyter = 'DATASCIENCE.JUPYTERSTARTUPCOST';
export const SubmitCellThroughInput = 'DATASCIENCE.SUBMITCELLFROMREPL';
export const ConnectLocalJupyter = 'DATASCIENCE.CONNECTLOCALJUPYTER';
export const ConnectRemoteJupyter = 'DATASCIENCE.CONNECTREMOTEJUPYTER';
export const ConnectFailedJupyter = 'DATASCIENCE.CONNECTFAILEDJUPYTER';
export enum Telemetry {
ImportNotebook = 'DATASCIENCE.IMPORT_NOTEBOOK',
RunCell = 'DATASCIENCE.RUN_CELL',
RunCurrentCell = 'DATASCIENCE.RUN_CURRENT_CELL',
RunCurrentCellAndAdvance = 'DATASCIENCE.RUN_CURRENT_CELL_AND_ADVANCE',
RunAllCells = 'DATASCIENCE.RUN_ALL_CELLS',
DeleteAllCells = 'DATASCIENCE.DELETE_ALL_CELLS',
DeleteCell = 'DATASCIENCE.DELETE_CELL',
GotoSourceCode = 'DATASCIENCE.GOTO_SOURCE',
RestartKernel = 'DATASCIENCE.RESTART_KERNEL',
ExportNotebook = 'DATASCIENCE.EXPORT_NOTEBOOK',
Undo = 'DATASCIENCE.UNDO',
Redo = 'DATASCIENCE.REDO',
ShowHistoryPane = 'DATASCIENCE.SHOW_HISTORY_PANE',
ExpandAll = 'DATASCIENCE.EXPAND_ALL',
CollapseAll = 'DATASCIENCE.COLLAPSE_ALL',
SelectJupyterURI = 'DATASCIENCE.SELECT_JUPYTER_URI',
SetJupyterURIToLocal = 'DATASCIENCE.SET_JUPYTER_URI_LOCAL',
SetJupyterURIToUserSpecified = 'DATASCIENCE.SET_JUPYTER_URI_USER_SPECIFIED',
Interrupt = 'DATASCIENCE.INTERRUPT',
ExportPythonFile = 'DATASCIENCE.EXPORT_PYTHON_FILE',
ExportPythonFileAndOutput = 'DATASCIENCE.EXPORT_PYTHON_FILE_AND_OUTPUT',
StartJupyter = 'DATASCIENCE.JUPYTERSTARTUPCOST',
SubmitCellThroughInput = 'DATASCIENCE.SUBMITCELLFROMREPL',
ConnectLocalJupyter = 'DATASCIENCE.CONNECTLOCALJUPYTER',
ConnectRemoteJupyter = 'DATASCIENCE.CONNECTREMOTEJUPYTER',
ConnectFailedJupyter = 'DATASCIENCE.CONNECTFAILEDJUPYTER'
}

export namespace HelpLinks {
Expand Down
8 changes: 4 additions & 4 deletions src/client/datascience/history.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@ export class History implements IWebPanelMessageListener, IHistory {
}
}

@captureTelemetry(Telemetry.SubmitCellThroughInput, {}, false)
@captureTelemetry(Telemetry.SubmitCellThroughInput, undefined, false)
// tslint:disable-next-line:no-any
private submitNewCell(payload?: any) {
// If there's any payload, it's the code
Expand All @@ -422,7 +422,7 @@ export class History implements IWebPanelMessageListener, IHistory {
return result;
}

private logTelemetry = (event : string) => {
private logTelemetry = (event : Telemetry) => {
sendTelemetryEvent(event);
}

Expand Down Expand Up @@ -503,7 +503,7 @@ export class History implements IWebPanelMessageListener, IHistory {
this.loadPromise = this.loadJupyterServer(true);
}

@captureTelemetry(Telemetry.GotoSourceCode, {}, false)
@captureTelemetry(Telemetry.GotoSourceCode, undefined, false)
private gotoCode(file: string, line: number) {
this.gotoCodeInternal(file, line).catch(err => {
this.applicationShell.showErrorMessage(err);
Expand All @@ -530,7 +530,7 @@ export class History implements IWebPanelMessageListener, IHistory {
}
}

@captureTelemetry(Telemetry.ExportNotebook, {}, false)
@captureTelemetry(Telemetry.ExportNotebook, undefined, false)
// tslint:disable-next-line: no-any no-empty
private export (payload: any) {
if (payload.contents) {
Expand Down
6 changes: 3 additions & 3 deletions src/client/datascience/historycommandlistener.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export class HistoryCommandListener implements IDataScienceCommandListener {
}
}

@captureTelemetry(Telemetry.ExportPythonFile, {}, false)
@captureTelemetry(Telemetry.ExportPythonFile, undefined, false)
private async exportFile(file: string): Promise<void> {
if (file && file.length > 0) {
// If the current file is the active editor, then generate cells from the document.
Expand Down Expand Up @@ -154,7 +154,7 @@ export class HistoryCommandListener implements IDataScienceCommandListener {
}
}

@captureTelemetry(Telemetry.ExportPythonFileAndOutput, {}, false)
@captureTelemetry(Telemetry.ExportPythonFileAndOutput, undefined, false)
private async exportFileAndOutput(file: string): Promise<void> {
if (file && file.length > 0 && this.jupyterExecution.isNotebookSupported()) {
// If the current file is the active editor, then generate cells from the document.
Expand Down Expand Up @@ -333,7 +333,7 @@ export class HistoryCommandListener implements IDataScienceCommandListener {

}

@captureTelemetry(Telemetry.ShowHistoryPane, {}, false)
@captureTelemetry(Telemetry.ShowHistoryPane, undefined, false)
private showHistoryPane() : Promise<void>{
const active = this.historyProvider.getOrCreateActive();
return active.show();
Expand Down
Loading