Comparing version 2.5.0 to 2.6.0
@@ -51,11 +51,3 @@ import { readFileSync } from 'node:fs'; | ||
event: 'CLI Started', | ||
properties: { | ||
version: pkg.version, | ||
command: args._.join(' '), | ||
flags: { | ||
output: args.output, | ||
}, | ||
ci: isCi(), | ||
githubEnvVars: getGithubEnvVars(process.env), | ||
}, | ||
properties: getAnalyticsEventProperties(args), | ||
context: { | ||
@@ -101,1 +93,10 @@ direct: true, | ||
}; | ||
export const getAnalyticsEventProperties = (args) => ({ | ||
version: pkg.version, | ||
command: args._.join(' '), | ||
flags: { | ||
output: args.output, | ||
}, | ||
ci: isCi(), | ||
githubEnvVars: getGithubEnvVars(process.env), | ||
}); |
@@ -39,2 +39,6 @@ import { EndpointType } from '@neondatabase/api-client'; | ||
.middleware(fillSingleProject) | ||
.middleware((args) => { | ||
// Provide alias for analytics | ||
args.branchId ?? (args.branchId = args.id); | ||
}) | ||
.command('list', 'List branches', (yargs) => yargs, (args) => list(args)) | ||
@@ -98,2 +102,3 @@ .command('create', 'Create a branch', (yargs) => yargs.options({ | ||
args.pointInTime = args['source@(timestamp']; | ||
args.branchId = args.id; // for analytics | ||
}) | ||
@@ -100,0 +105,0 @@ .usage('$0 branches restore <target-id|name> <source>[@(timestamp|lsn)]') |
@@ -29,2 +29,6 @@ import { log } from '../log.js'; | ||
.usage('$0 projects <sub-command> [options]') | ||
.middleware((args) => { | ||
// Provide alias for analytics | ||
args.projectId = args.id; | ||
}) | ||
.command('list', 'List projects', (yargs) => yargs.options({ | ||
@@ -31,0 +35,0 @@ 'org-id': { |
@@ -23,3 +23,3 @@ import { basename } from 'node:path'; | ||
import commands from './commands/index.js'; | ||
import { analyticsMiddleware, closeAnalytics, sendError } from './analytics.js'; | ||
import { analyticsMiddleware, closeAnalytics, getAnalyticsEventProperties, sendError, trackEvent, } from './analytics.js'; | ||
import { isAxiosError } from 'axios'; | ||
@@ -184,2 +184,7 @@ import { matchErrorCode } from './errors.js'; | ||
const args = await builder.argv; | ||
trackEvent('cli_command_success', { | ||
...getAnalyticsEventProperties(args), | ||
projectId: args.projectId, | ||
branchId: args.branchId, | ||
}); | ||
if (args._.length === 0 || args.help) { | ||
@@ -186,0 +191,0 @@ await showHelp(builder); |
@@ -8,3 +8,3 @@ { | ||
"type": "module", | ||
"version": "2.5.0", | ||
"version": "2.6.0", | ||
"description": "CLI tool for NeonDB Cloud management", | ||
@@ -11,0 +11,0 @@ "main": "index.js", |
@@ -18,3 +18,3 @@ import { looksLikeBranchId } from './formats.js'; | ||
}; | ||
export const branchIdFromProps = async (props) => { | ||
const getBranchIdFromProps = async (props) => { | ||
const branch = 'branch' in props && typeof props.branch === 'string' | ||
@@ -39,2 +39,6 @@ ? props.branch | ||
}; | ||
export const branchIdFromProps = async (props) => { | ||
props.branchId = await getBranchIdFromProps(props); | ||
return props.branchId; | ||
}; | ||
export const fillSingleProject = async (props) => { | ||
@@ -44,3 +48,3 @@ if (props.projectId) { | ||
} | ||
const { data } = await props.apiClient.listProjects({}); | ||
const { data } = await props.apiClient.listProjects({ limit: 2 }); | ||
if (data.projects.length === 0) { | ||
@@ -47,0 +51,0 @@ throw new Error('No projects found'); |
211348
5334