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