|
|
|
@ -1,15 +1,6 @@ |
|
|
|
const Command = require("../structures/Command") |
|
|
|
const { CommandWords, InitTypes, BUDIBASE_POSTHOG_URL } = require("../constants") |
|
|
|
const { lookpath } = require("lookpath") |
|
|
|
const { |
|
|
|
success, |
|
|
|
error, |
|
|
|
info, |
|
|
|
parseEnv, |
|
|
|
} = require("../utils") |
|
|
|
const { confirmation } = require("../questions") |
|
|
|
const fs = require("fs") |
|
|
|
const axios = require("axios") |
|
|
|
const { CommandWords } = require("../constants") |
|
|
|
const { success, error } = require("../utils") |
|
|
|
const AnalyticsClient = require("./Client") |
|
|
|
|
|
|
|
const client = new AnalyticsClient() |
|
|
|
@ -18,9 +9,18 @@ async function optOut() { |
|
|
|
try { |
|
|
|
// opt them out
|
|
|
|
client.disable() |
|
|
|
console.log(success("Successfully opted out of budibase analytics. You can opt in at any time by running 'budi analytics opt-in'")) |
|
|
|
} catch (err) { |
|
|
|
console.log(error("Error opting out of budibase analytics. Please try again later.", err)) |
|
|
|
console.log( |
|
|
|
success( |
|
|
|
"Successfully opted out of budibase analytics. You can opt in at any time by running 'budi analytics opt-in'" |
|
|
|
) |
|
|
|
) |
|
|
|
} catch (err) { |
|
|
|
console.log( |
|
|
|
error( |
|
|
|
"Error opting out of budibase analytics. Please try again later.", |
|
|
|
err |
|
|
|
) |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -28,9 +28,15 @@ async function optIn() { |
|
|
|
try { |
|
|
|
// opt them in
|
|
|
|
client.enable() |
|
|
|
console.log(success("Successfully opted in to budibase analytics. Thank you for helping us make budibase better!")) |
|
|
|
} catch (err) { |
|
|
|
console.log(error("Error opting in to budibase analytics. Please try again later.")) |
|
|
|
console.log( |
|
|
|
success( |
|
|
|
"Successfully opted in to budibase analytics. Thank you for helping us make budibase better!" |
|
|
|
) |
|
|
|
) |
|
|
|
} catch (err) { |
|
|
|
console.log( |
|
|
|
error("Error opting in to budibase analytics. Please try again later.") |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
@ -38,23 +44,16 @@ async function status() { |
|
|
|
try { |
|
|
|
console.log(success(`Budibase analytics ${client.status()}`)) |
|
|
|
} catch (err) { |
|
|
|
console.log(error("Error fetching analytics status. Please try again later.")) |
|
|
|
console.log( |
|
|
|
error("Error fetching analytics status. Please try again later.") |
|
|
|
) |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const command = new Command(`${CommandWords.ANALYTICS}`) |
|
|
|
.addHelp("Control the analytics you send to budibase.") |
|
|
|
.addSubOption( |
|
|
|
"--optin", |
|
|
|
"Opt in to sending analytics to budibase", |
|
|
|
optIn |
|
|
|
) |
|
|
|
.addSubOption( |
|
|
|
"--optout", |
|
|
|
"Opt out of sending analytics to budibase.", |
|
|
|
optOut |
|
|
|
) |
|
|
|
.addSubOption("--optin", "Opt in to sending analytics to budibase", optIn) |
|
|
|
.addSubOption("--optout", "Opt out of sending analytics to budibase.", optOut) |
|
|
|
.addSubOption( |
|
|
|
"--status", |
|
|
|
"Check whether you are currently opted in to budibase analytics.", |
|
|
|
|