Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
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
Prev Previous commit
Next Next commit
Factor out sendStartupTelemetryInBackground().
  • Loading branch information
ericsnowcurrently committed Mar 9, 2020
commit 5b3d57d44581b1fad9004f95224b94585228e97d
14 changes: 7 additions & 7 deletions src/client/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ import { registerTypes as providersRegisterTypes } from './providers/serviceRegi
import { activateSimplePythonRefactorProvider } from './providers/simpleRefactorProvider';
import { TerminalProvider } from './providers/terminalProvider';
import { ISortImportsEditingProvider } from './providers/types';
import { sendErrorTelemetry, sendStartupTelemetry } from './startupTelemetry';
import { sendErrorTelemetry, sendStartupTelemetryInBackground } from './startupTelemetry';
import { registerTypes as commonRegisterTerminalTypes } from './terminals/serviceRegistry';
import { ICodeExecutionManager, ITerminalAutoActivation } from './terminals/types';
import { TEST_OUTPUT_CHANNEL } from './testing/common/constants';
Expand All @@ -118,7 +118,9 @@ export async function activate(context: ExtensionContext): Promise<IExtensionApi
try {
return await activateUnsafe(context);
} catch (ex) {
handleError(ex);
// We want to completely handle the error
// before notifying VS Code.
await handleError(ex);
throw ex; // re-raise
}
}
Expand Down Expand Up @@ -156,9 +158,7 @@ async function activateUnsafe(context: ExtensionContext): Promise<IExtensionApi>
durations.endActivateTime = stopWatch.elapsedTime;
activationDeferred.resolve();

sendStartupTelemetry(activationPromise, durations, stopWatch, serviceContainer)
// It will run in the background.
.ignoreErrors();
sendStartupTelemetryInBackground(activationPromise, durations, stopWatch, serviceContainer);
Comment thread
kimadeline marked this conversation as resolved.
Resolved

return buildApi(activationPromise, serviceManager, serviceContainer);
}
Expand Down Expand Up @@ -360,12 +360,12 @@ async function initializeServices(
/////////////////////////////
// error handling

function handleError(ex: Error) {
async function handleError(ex: Error) {
notifyUser(
"Extension activation failed, run the 'Developer: Toggle Developer Tools' command for more information."
);
traceError('extension activation failed', ex);
sendErrorTelemetry(ex, durations, activatedServiceContainer).ignoreErrors();
await sendErrorTelemetry(ex, durations, activatedServiceContainer);
}

interface IAppShell {
Expand Down
12 changes: 11 additions & 1 deletion src/client/startupTelemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,17 @@ interface IStopWatch {
elapsedTime: number;
}

export async function sendStartupTelemetry(
export function sendStartupTelemetryInBackground(
Comment thread
ericsnowcurrently marked this conversation as resolved.
Resolved
// tslint:disable-next-line:no-any
activatedPromise: Promise<any>,
durations: Record<string, number>,
stopWatch: IStopWatch,
serviceContainer: IServiceContainer
) {
sendStartupTelemetry(activatedPromise, durations, stopWatch, serviceContainer).ignoreErrors();
}

async function sendStartupTelemetry(
// tslint:disable-next-line:no-any
activatedPromise: Promise<any>,
durations: Record<string, number>,
Expand Down