Skip to content

Commit

Permalink
Fix activation bug with ddSocket
Browse files Browse the repository at this point in the history
  • Loading branch information
ColinMcNeil committed Sep 27, 2024
1 parent 66fdcc3 commit 306d049
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
2 changes: 2 additions & 0 deletions src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { nativeClient } from './utils/lsp';
import { spawnSync } from 'child_process';
import semver from 'semver';
import commands from './commands';
import { setDefaultProperties } from './utils/ddSocket';

export let ctx: vscode.ExtensionContext;

Expand Down Expand Up @@ -72,6 +73,7 @@ const checkOutdatedVersionInstalled = async () => {
export async function activate(context: vscode.ExtensionContext) {
checkOutdatedVersionInstalled();
checkVersion();
setDefaultProperties(context);
ctx = context;
let setOpenAIKeyCommand = vscode.commands.registerCommand('docker.labs-ai-tools-vscode.set-openai-api-key', () => {
setOpenAIKey(context.secrets);
Expand Down
21 changes: 15 additions & 6 deletions src/utils/ddSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import os from 'os';
import path from 'path';
import http from 'http';
import { ctx } from '../extension';
import { ExtensionContext } from 'vscode';
const getDevhomePrefix = () => {
return process.env['DEVHOME'] ? path.basename(process.env['DEVHOME']) : '';
}
Expand Down Expand Up @@ -54,14 +55,22 @@ type TrackEvent = {
properties?: Record<string, string>
}

const defaultProperties = {
version: ctx.extension.packageJSON.version,
platform: os.platform(),
arch: os.arch(),
nodeVersion: process.version,
vscodeVersion: ctx.extension.packageJSON.version,
let defaultProperties = {

}

export const setDefaultProperties = (ctx: ExtensionContext) => {
defaultProperties = {
version: ctx.extension.packageJSON.version,
platform: os.platform(),
arch: os.arch(),
nodeVersion: process.version,
vscodeVersion: ctx.extension.packageJSON.version,
}
}



export const postToBackendSocket = (event: TrackEvent) => {
event.properties = { ...event.properties, ...defaultProperties }
const postData = JSON.stringify(event);
Expand Down

0 comments on commit 306d049

Please sign in to comment.