diff --git a/.eslintrc.json b/.eslintrc.json index 88d8902..9ece440 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -7,7 +7,6 @@ }, "plugins": ["@typescript-eslint"], "rules": { - "@typescript-eslint/naming-convention": "warn", "@typescript-eslint/semi": "off", "curly": "warn", "eqeqeq": "warn", diff --git a/src/SecretStateManager.ts b/src/SecretStateManager.ts index 90511d0..2f00bc5 100644 --- a/src/SecretStateManager.ts +++ b/src/SecretStateManager.ts @@ -1,4 +1,5 @@ import * as vscode from 'vscode' +import { StateManager } from './StateManager' export const enum CLIENT_KEYS { CLIENT_ID = 'client_id', diff --git a/src/StateManager.ts b/src/StateManager.ts index 16c39f0..5d7af80 100644 --- a/src/StateManager.ts +++ b/src/StateManager.ts @@ -8,6 +8,7 @@ export const enum KEYS { FEATURE_CONFIGURATIONS = 'feature_configurations', ENVIRONMENTS = 'environments', ORGANIZATION_ID = 'organization_id', + SEND_METRICS_PROMPTED = 'send_metrics_prompted', } export class StateManager { diff --git a/src/cli/baseCLIController.ts b/src/cli/baseCLIController.ts index 28a7988..526f7d7 100644 --- a/src/cli/baseCLIController.ts +++ b/src/cli/baseCLIController.ts @@ -46,10 +46,6 @@ export type Range = { end: number } -const CACHE_TIME = 15000 - - - export async function init() { showBusyMessage('Initializing DevCycle') const { code, error, output } = await execDvc('repo init') @@ -145,6 +141,7 @@ export async function status(): Promise { export async function usages(): Promise { showBusyMessage('Finding Devcycle code usages') const { output } = await execDvc('usages --format=json') + const matches = JSON.parse(output) as JSONMatch[] hideBusyMessage() return matches diff --git a/src/components/SidebarProvider.ts b/src/components/SidebarProvider.ts index 948a81d..ce2b199 100644 --- a/src/components/SidebarProvider.ts +++ b/src/components/SidebarProvider.ts @@ -71,7 +71,6 @@ export class SidebarProvider implements vscode.WebviewViewProvider { if (view === VIEWS.DEFAULT) { script = 'sidebar.js' } - vscode.window.showInformationMessage(`script: ${this._extensionUri}`) return webview.asWebviewUri( vscode.Uri.joinPath(this._extensionUri, process.env.DEBUG_MODE === '1' ? 'src' : 'out', `scripts/${script}`), ) diff --git a/src/extension.ts b/src/extension.ts index 8057cf8..a6bf79f 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -21,6 +21,17 @@ export const activate = async (context: vscode.ExtensionContext) => { SecretStateManager.init(context) StateManager.globalState = context.globalState StateManager.workspaceState = context.workspaceState + + if (!StateManager.getState(KEYS.SEND_METRICS_PROMPTED)) { + const sendMetricsMessage = + `DevCycle collects usage metrics to gather information on feature adoption, usage, and frequency. + By clicking "Accept", you consent to the collection of this data. Would you like to opt-in?` + vscode.window.showInformationMessage(sendMetricsMessage, 'Accept', 'Decline').then((selection) => { + vscode.workspace.getConfiguration('devcycle-featureflags').update('sendMetrics', selection === 'Accept') + StateManager.setState(KEYS.SEND_METRICS_PROMPTED, true) + }) + } + const autoLogin = vscode.workspace .getConfiguration('devcycle-featureflags') .get('loginOnWorkspaceOpen') @@ -95,7 +106,7 @@ export const activate = async (context: vscode.ExtensionContext) => { const document = await vscode.workspace.openTextDocument(filePath) await vscode.window.showTextDocument(document) const editor = vscode.window.activeTextEditor - if (!editor) throw new Error('No active text editor') + if (!editor) { throw new Error('No active text editor') } editor.selection = new vscode.Selection(start - 1, 0, end, 0) editor.revealRange( editor.selection,