| 1 | /** |
| 2 | * This is the entry point for the extension. |
| 3 | */ |
| 4 | |
| 5 | import { setupCa } from "core/util/ca"; |
| 6 | import { extractMinimalStackTraceInfo } from "core/util/extractMinimalStackTraceInfo"; |
| 7 | import { Telemetry } from "core/util/posthog"; |
| 8 | import * as vscode from "vscode"; |
| 9 | |
| 10 | import { getExtensionVersion } from "./util/util"; |
| 11 | export { default as buildTimestamp } from "./.buildTimestamp"; |
| 12 | |
| 13 | async function dynamicImportAndActivate(context: vscode.ExtensionContext) { |
| 14 | await setupCa(); |
| 15 | const { activateExtension } = await import("./activation/activate"); |
| 16 | return await activateExtension(context); |
| 17 | } |
| 18 | |
| 19 | export function activate(context: vscode.ExtensionContext) { |
| 20 | return dynamicImportAndActivate(context).catch((e) => { |
| 21 | console.log("Error activating extension: ", e); |
| 22 | Telemetry.capture( |
| 23 | "vscode_extension_activation_error", |
| 24 | { |
| 25 | stack: extractMinimalStackTraceInfo(e.stack), |
| 26 | message: e.message, |
| 27 | }, |
| 28 | false, |
| 29 | true, |
| 30 | ); |
| 31 | vscode.window |
| 32 | .showWarningMessage( |
| 33 | "Error activating the Continue extension.", |
| 34 | "View Logs", |
| 35 | "Retry", |
| 36 | ) |
| 37 | .then((selection) => { |
| 38 | if (selection === "View Logs") { |
| 39 | vscode.commands.executeCommand("continue.viewLogs"); |
| 40 | } else if (selection === "Retry") { |
| 41 | // Reload VS Code window |
| 42 | vscode.commands.executeCommand("workbench.action.reloadWindow"); |
| 43 | } |
| 44 | }); |
| 45 | }); |
| 46 | } |
| 47 | |
| 48 | export function deactivate() { |
| 49 | Telemetry.capture( |
| 50 | "deactivate", |
| 51 | { |
| 52 | extensionVersion: getExtensionVersion(), |
| 53 | }, |
| 54 | true, |
| 55 | ); |
| 56 | |
| 57 | Telemetry.shutdownPosthogClient(); |
| 58 | } |