Skip to content

Commit

Permalink
chore: added send metrics prompt when installing and user has not see…
Browse files Browse the repository at this point in the history
…n it yet
  • Loading branch information
jsalaber committed Aug 2, 2023
1 parent d248c82 commit 1917993
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
1 change: 0 additions & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
},
"plugins": ["@typescript-eslint"],
"rules": {
"@typescript-eslint/naming-convention": "warn",
"@typescript-eslint/semi": "off",
"curly": "warn",
"eqeqeq": "warn",
Expand Down
1 change: 1 addition & 0 deletions src/SecretStateManager.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as vscode from 'vscode'
import { StateManager } from './StateManager'

export const enum CLIENT_KEYS {
CLIENT_ID = 'client_id',
Expand Down
1 change: 1 addition & 0 deletions src/StateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 1 addition & 4 deletions src/cli/baseCLIController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -145,6 +141,7 @@ export async function status(): Promise<DevCycleStatus> {
export async function usages(): Promise<JSONMatch[]> {
showBusyMessage('Finding Devcycle code usages')
const { output } = await execDvc('usages --format=json')

const matches = JSON.parse(output) as JSONMatch[]
hideBusyMessage()
return matches
Expand Down
1 change: 0 additions & 1 deletion src/components/SidebarProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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}`),
)
Expand Down
13 changes: 12 additions & 1 deletion src/extension.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 1917993

Please sign in to comment.