Skip to content

Commit

Permalink
MVP
Browse files Browse the repository at this point in the history
  • Loading branch information
gebner committed Jul 17, 2024
1 parent 0c63f43 commit 9b9f670
Show file tree
Hide file tree
Showing 5 changed files with 294 additions and 6 deletions.
252 changes: 252 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"compile": "esbuild --bundle src/extension.ts --outfile=out/extension.js --tsconfig=tsconfig.json --platform=node --external:vscode --sourcemap --preserve-symlinks --sources-content=false"
},
"dependencies": {
"@vscode/extension-telemetry": "^0.9.6",
"vscode-languageclient": "^9.0.1"
},
"devDependencies": {
Expand Down
12 changes: 11 additions & 1 deletion client/src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ import {
Range,
Position
} from 'vscode-languageclient/node';
import { StatusNotificationParams, killAllNotification, killAndRestartSolverNotification, restartNotification, statusNotification, verifyToPositionNotification } from './fstarLspExtensions';
import { StatusNotificationParams, killAllNotification, killAndRestartSolverNotification, restartNotification, statusNotification, telemetryNotification, verifyToPositionNotification } from './fstarLspExtensions';
import TelemetryReporter from '@vscode/extension-telemetry';

let client: LanguageClient;

Expand Down Expand Up @@ -132,6 +133,12 @@ function updateDecorations() {
}

export async function activate(context: ExtensionContext) {
const telemetry = new TelemetryReporter(
// '160d3440-45e8-47c1-9cf1-ccd46149ff89'
'InstrumentationKey=160d3440-45e8-47c1-9cf1-ccd46149ff89;IngestionEndpoint=https://eastus-8.in.applicationinsights.azure.com/;LiveEndpoint=https://eastus.livediagnostics.monitor.azure.com/;ApplicationId=a4e6ffa7-4f8c-47c3-8d7f-0f4dbcf57019'
);
telemetry.sendTelemetryEvent('test', {test:'test'});

// The server is implemented in node
const serverModule = context.asAbsolutePath(
path.join('server', 'out', 'main.js')
Expand Down Expand Up @@ -165,6 +172,9 @@ export async function activate(context: ExtensionContext) {
client.onNotification(statusNotification, status => handleStatus(status));
vscode.window.onDidChangeVisibleTextEditors(() => updateDecorations());

client.onNotification(telemetryNotification, params =>
telemetry.sendTelemetryEvent(params.eventName, params.properties, params.measurements));

// register a command for Ctrl+.
context.subscriptions.push(vscode.commands.registerTextEditorCommand('fstar-vscode-assistant/verify-to-position', textEditor =>
client.sendNotification(verifyToPositionNotification, {
Expand Down
17 changes: 16 additions & 1 deletion server/src/fstarLspExtensions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,19 @@ export interface VerifyToPositionParams {
export const verifyToPositionNotification =
new ProtocolNotificationType<VerifyToPositionParams, RegistrationParams>('$/fstar/verifyToPosition');

interface RegistrationParams {}
interface RegistrationParams {}

export interface TelemetryEventProperties {
readonly [key: string]: string | undefined
| any; //apparently we need the safe type here??
}
export interface TelemetryEventMeasurements {
readonly [key: string]: number | undefined;
}
export interface TelemetryNotificationParams {
eventName: string;
properties?: TelemetryEventProperties;
measurements?: TelemetryEventMeasurements;
}
export const telemetryNotification =
new ProtocolNotificationType<TelemetryNotificationParams, RegistrationParams>('$/fstar/telemetry');
Loading

0 comments on commit 9b9f670

Please sign in to comment.