1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
|
/**
* This is the entry point for the extension.
*/
import * as vscode from "vscode";
import { getExtensionVersion } from "./activation/environmentSetup";
import { PostHog } from "posthog-node";
const client = new PostHog(
"phc_JS6XFROuNbhJtVCEdTSYk6gl5ArRrTNMpCcguAXlSPs",
{ host: "https://app.posthog.com" }
);
async function dynamicImportAndActivate(context: vscode.ExtensionContext) {
if (!context.globalState.get("hasBeenInstalled")) {
context.globalState.update("hasBeenInstalled", true);
client.capture({
distinctId: vscode.env.machineId,
event: "install",
properties: {
extensionVersion: getExtensionVersion(),
},
});
}
const { activateExtension } = await import("./activation/activate");
try {
await activateExtension(context);
} catch (e) {
console.log("Error activating extension: ", e);
vscode.window
.showInformationMessage(
"Error activating the Continue extension.",
"View Logs",
"Retry"
)
.then((selection) => {
if (selection === "View Logs") {
vscode.commands.executeCommand("continue.viewLogs");
} else if (selection === "Retry") {
// Reload VS Code window
vscode.commands.executeCommand("workbench.action.reloadWindow");
}
});
}
}
export function activate(context: vscode.ExtensionContext) {
dynamicImportAndActivate(context);
}
export function deactivate() {
client.capture({
distinctId: vscode.env.machineId,
event: "deactivate",
properties: {
extensionVersion: getExtensionVersion(),
},
});
client.shutdown();
}
|