Skip to content

Commit 1c6bd4f

Browse files
committed
start implementing an analytics command
1 parent 744d600 commit 1c6bd4f

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

lib/commands/analytics/index.js

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import { outputFlags, validationFlags } from '../../flags/index.js'
77
// import { handleApiCall, handleUnsuccessfulApiResponse } from '../../utils/api-helpers.js'
88
import { InputError } from '../../utils/errors.js'
99
import { printFlagList } from '../../utils/formatting.js'
10-
import { FREE_API_KEY, getDefaultKey, setupSdk } from '../../utils/sdk.js'
10+
// import { FREE_API_KEY, getDefaultKey, setupSdk } from '../../utils/sdk.js'
1111

1212
/** @type {import('../../utils/meow-with-subcommands').CliSubcommand} */
1313
export const analytics = {
@@ -17,9 +17,9 @@ export const analytics = {
1717

1818
const input = setupCommand(name, analytics.description, argv, importMeta)
1919
if (input) {
20-
const spinner = ora("Fetching analytics data").start()
20+
const spinner = ora('Fetching analytics data').start()
2121
console.log(input)
22-
if(input.scope === 'org'){
22+
if (input.scope === 'org') {
2323
await fetchOrgAnalyticsData(input.time, spinner)
2424
} else {
2525
// await fetchRepoAnalyticsData(input.time, spinner)
@@ -32,8 +32,8 @@ export const analytics = {
3232

3333
/**
3434
* @typedef CommandContext
35-
* @property {string} scope
36-
* @property {string} time
35+
* @property {string} scope
36+
* @property {string} time
3737
*/
3838

3939
/**
@@ -68,24 +68,24 @@ function setupCommand (name, description, argv, importMeta) {
6868

6969
const scope = cli.input[0]
7070

71-
if(!scope){
72-
throw new InputError("Please provide a scope to get analytics data")
71+
if (!scope) {
72+
throw new InputError('Please provide a scope to get analytics data')
7373
}
7474

75-
if(!cli.input.length){
76-
throw new InputError("Please provide a scope and a time to get analytics data")
75+
if (!cli.input.length) {
76+
throw new InputError('Please provide a scope and a time to get analytics data')
7777
}
7878

79-
if(scope && !['org', 'repo'].includes(scope)){
79+
if (scope && !['org', 'repo'].includes(scope)) {
8080
throw new InputError("The scope must either be 'scope' or 'repo'")
8181
}
8282
const time = cli.input[1]
8383

84-
if(!time){
85-
throw new InputError("Please provide a time to get analytics data")
84+
if (!time) {
85+
throw new InputError('Please provide a time to get analytics data')
8686
}
8787

88-
if (time && !['7','30','60'].includes(time)) {
88+
if (time && !['7', '30', '60'].includes(time)) {
8989
throw new InputError('The time filter must either be 7, 30 or 60')
9090
}
9191

@@ -106,16 +106,17 @@ function setupCommand (name, description, argv, importMeta) {
106106
*/
107107
// * @returns {Promise<void|AnalyticsData>}
108108
async function fetchOrgAnalyticsData (time, spinner) {
109-
const socketSdk = await setupSdk(getDefaultKey() || FREE_API_KEY)
109+
// const socketSdk = await setupSdk(getDefaultKey() || FREE_API_KEY)
110110
console.table(time)
111+
console.log(spinner)
111112

112113
// const result = await handleApiCall(socketSdk.getOrgAnalytics(time), 'fetching analytics data')
113-
114+
114115
// if (result.success === false) {
115116
// return handleUnsuccessfulApiResponse('getOrgAnalytics', result, spinner)
116117
// }
117118

118119
// return {
119-
120+
120121
// }
121122
}

0 commit comments

Comments
 (0)