move to posthog

This commit is contained in:
Andrew Pareles 2024-11-17 19:39:15 -08:00
parent 0bf5278168
commit e56716c792
2 changed files with 19 additions and 29 deletions

View file

@ -13,25 +13,6 @@ import { AutocompleteProvider } from './AutcompleteProvider';
import { runTreeSitter } from '../common/LangaugeServer/createJsProgramGraph';
const buildEnv = 'development';
const buildNumber = '1.0.0';
const isMac = process.platform === 'darwin';
const commandKey = isMac ? '⌘' : 'Ctrl';
const userLabel = buildEnv === 'development' ? 'Developer' : 'Production User';
function sendMetrics(event: string) {
const metrics = {
isMac,
commandKey,
event,
buildNumber,
userLabel,
};
console.log('Metrics:', metrics);
}
// // this comes from vscode.proposed.editorInsets.d.ts
// declare module 'vscode' {
// export interface WebviewEditorInset {
@ -62,14 +43,6 @@ const getSelection = (editor: vscode.TextEditor) => {
export function activate(context: vscode.ExtensionContext) {
console.log(`Build Environment: ${buildEnv}`);
console.log(`Build Number: ${buildNumber}`)
console.log(`Use ${commandKey} for commands.`);
console.log(`User Label: ${userLabel}`);
sendMetrics('extensionActivated');
// 1. Mount the chat sidebar
const sidebarWebviewProvider = new SidebarWebviewProvider(context);
context.subscriptions.push(

View file

@ -1,12 +1,29 @@
import posthog from 'posthog-js'
const buildEnv = 'development';
const buildNumber = '1.0.0';
const isMac = process.platform === 'darwin';
// TODO use commandKey
const commandKey = isMac ? '⌘' : 'Ctrl';
const systemInfo = {
buildEnv,
buildNumber,
isMac,
}
export const identifyUser = (id: string) => {
posthog.identify(id)
}
export const captureEvent = (eventId: string, properties: object) => {
posthog.capture(eventId, properties)
posthog.capture(eventId, { ...properties, systemInfo })
}
export const initPosthog = () => {
@ -17,4 +34,4 @@ export const initPosthog = () => {
person_profiles: 'identified_only' // we only track events from identified users. We identify them in Sidebar
}
)
}
}