diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index d7e4de4e..49105bdc 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,10 +22,6 @@ jobs: registry-url: "https://registry.npmjs.org" - name: Install dependencies and build run: npm ci && npm run build - - name: Create .env-public-analytics file - run: | - echo "RUDDER_STACK_KEY=${{ secrets.RUDDER_STACK_KEY }}" > .env-public-analytics - echo "RUDDER_STACK_DATAPLANE_URL=${{ secrets.RUDDER_STACK_DATAPLANE_URL }}" >> .env-public-analytics - name: Release env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.npmignore b/.npmignore index 973f63fe..5fd346fd 100644 --- a/.npmignore +++ b/.npmignore @@ -3,7 +3,6 @@ # Include specific files !bin/**/* -!.env-public-analytics !package.json !package-lock.json !LICENSE-MIT diff --git a/package-lock.json b/package-lock.json index 206f98eb..6c96f343 100644 --- a/package-lock.json +++ b/package-lock.json @@ -9,17 +9,13 @@ "version": "0.0.0-development", "license": "MIT", "dependencies": { - "@rudderstack/rudder-sdk-node": "^2.0.5", "chalk": "4.1.2", "commander": "^11.0.0", "compare-versions": "^6.1.0", "cross-env": "^7.0.3", "dotenv": "^16.3.1", - "eslint-import-resolver-typescript": "^3.6.1", "ethers": "5.7.2", "inquirer": "^8.1.4", - "node-machine-id": "^1.1.12", - "ofetch": "^1.3.3", "winston": "^3.10.0", "zkcli-dockerized-node": "^1.0.2", "zkcli-in-memory-node": "^1.0.3", diff --git a/package.json b/package.json index e701a914..cdedfc86 100644 --- a/package.json +++ b/package.json @@ -34,17 +34,13 @@ "**/*.ts": "tsc-files --noEmit" }, "dependencies": { - "@rudderstack/rudder-sdk-node": "^2.0.5", "chalk": "4.1.2", "commander": "^11.0.0", "compare-versions": "^6.1.0", "cross-env": "^7.0.3", "dotenv": "^16.3.1", - "eslint-import-resolver-typescript": "^3.6.1", "ethers": "5.7.2", "inquirer": "^8.1.4", - "node-machine-id": "^1.1.12", - "ofetch": "^1.3.3", "winston": "^3.10.0", "zkcli-dockerized-node": "^1.0.2", "zkcli-in-memory-node": "^1.0.3", diff --git a/src/commands/bridge/deposit.ts b/src/commands/bridge/deposit.ts index 89212876..ebe168e9 100644 --- a/src/commands/bridge/deposit.ts +++ b/src/commands/bridge/deposit.ts @@ -11,7 +11,6 @@ import { zeekOption, } from "../../common/options.js"; import { l2Chains } from "../../data/chains.js"; -import { track } from "../../utils/analytics.js"; import { ETH_TOKEN } from "../../utils/constants.js"; import { bigNumberToDecimal, decimalToBigNumber } from "../../utils/formatters.js"; import { @@ -119,8 +118,6 @@ export const handler = async (options: DepositOptions) => { Logger.info(` Transaction link: ${fromChain.explorerUrl}/tx/${depositHandle.hash}`); } - track("deposit", { network: toChain?.network ?? "Unknown chain", zeek: options.zeek }); - const senderBalance = await l1Provider.getBalance(senderWallet.address); Logger.info(`\nSender L1 balance after transaction: ${bigNumberToDecimal(senderBalance)} ETH`); @@ -130,7 +127,6 @@ export const handler = async (options: DepositOptions) => { } catch (error) { Logger.error("There was an error while depositing funds:"); Logger.error(error); - track("error", { error }); } }; diff --git a/src/commands/bridge/withdraw-finalize.ts b/src/commands/bridge/withdraw-finalize.ts index eaf7dc4f..e945afde 100644 --- a/src/commands/bridge/withdraw-finalize.ts +++ b/src/commands/bridge/withdraw-finalize.ts @@ -4,7 +4,6 @@ import inquirer from "inquirer"; import Program from "./command.js"; import { chainOption, l1RpcUrlOption, l2RpcUrlOption, privateKeyOption, zeekOption } from "../../common/options.js"; import { l2Chains } from "../../data/chains.js"; -import { track } from "../../utils/analytics.js"; import { bigNumberToDecimal } from "../../utils/formatters.js"; import { getAddressFromPrivateKey, @@ -117,8 +116,6 @@ export const handler = async (options: WithdrawFinalizeOptions) => { const receipt = await finalizationHandle.wait(); Logger.info(` Finalization transaction was mined in block ${receipt.blockNumber}`); - track("confirm-withdraw", { network: toChain?.network ?? "Unknown chain", zeek: options.zeek }); - const senderBalance = await l1Provider.getBalance(senderWallet.address); Logger.info(`\nSender L1 balance after transaction: ${bigNumberToDecimal(senderBalance)} ETH`); @@ -128,7 +125,6 @@ export const handler = async (options: WithdrawFinalizeOptions) => { } catch (error) { Logger.error("There was an error while finalizing withdrawal:"); Logger.error(error); - track("error", { error }); } }; diff --git a/src/commands/bridge/withdraw.ts b/src/commands/bridge/withdraw.ts index 5e48742b..57a25cf7 100644 --- a/src/commands/bridge/withdraw.ts +++ b/src/commands/bridge/withdraw.ts @@ -11,7 +11,6 @@ import { zeekOption, } from "../../common/options.js"; import { l2Chains } from "../../data/chains.js"; -import { track } from "../../utils/analytics.js"; import { ETH_TOKEN } from "../../utils/constants.js"; import { bigNumberToDecimal, decimalToBigNumber } from "../../utils/formatters.js"; import { @@ -119,8 +118,6 @@ export const handler = async (options: WithdrawOptions) => { Logger.info(` Transaction link: ${fromChain.explorerUrl}/tx/${withdrawHandle.hash}`); } - track("withdraw", { network: toChain?.network ?? "Unknown chain", zeek: options.zeek }); - const senderBalance = await l2Provider.getBalance(senderWallet.address); Logger.info(`\nSender L2 balance after transaction: ${bigNumberToDecimal(senderBalance)} ETH`); @@ -130,7 +127,6 @@ export const handler = async (options: WithdrawOptions) => { } catch (error) { Logger.error("There was an error while withdrawing funds:"); Logger.error(error); - track("error", { error }); } }; diff --git a/src/commands/create/create.ts b/src/commands/create/create.ts index 4baeb4b5..42732a72 100644 --- a/src/commands/create/create.ts +++ b/src/commands/create/create.ts @@ -6,7 +6,6 @@ import path from "path"; import Program from "./command.js"; import { zeekOption } from "../../common/options.js"; -import { track } from "../../utils/analytics.js"; import { fileOrDirExists } from "../../utils/files.js"; import { cloneRepo } from "../../utils/git.js"; import { optionNameToParam, executeCommand } from "../../utils/helpers.js"; @@ -111,15 +110,12 @@ ${chalk.magentaBright("Further Reading:")} Check out the README file for more details: ${path.join(folderLocation, "README.md")} `); - track("create", { template: options.template, zeek: options.zeek }); - if (options.zeek) { zeek(); } } catch (error) { Logger.error("There was an error while creating new project:"); Logger.error(error); - track("error", { error }); } }; diff --git a/src/commands/dev/clean.ts b/src/commands/dev/clean.ts index 8cee763a..abbfd841 100644 --- a/src/commands/dev/clean.ts +++ b/src/commands/dev/clean.ts @@ -1,6 +1,5 @@ import Program from "./command.js"; import configHandler from "./ConfigHandler.js"; -import { track } from "../../utils/analytics.js"; import Logger from "../../utils/logger.js"; import type Module from "./modules/Module.js"; @@ -27,7 +26,6 @@ export const handler = async () => { } catch (error) { Logger.error("There was an error while cleaning the testing environment:"); Logger.error(error); - track("error", { error }); } }; diff --git a/src/commands/dev/config.ts b/src/commands/dev/config.ts index 3829e529..4d2c9a7a 100644 --- a/src/commands/dev/config.ts +++ b/src/commands/dev/config.ts @@ -4,7 +4,6 @@ import inquirer from "inquirer"; import Program from "./command.js"; import configHandler from "./ConfigHandler.js"; import { ModuleCategory } from "./modules/Module.js"; -import { track } from "../../utils/analytics.js"; import Logger from "../../utils/logger.js"; import type { ModuleNode } from "./modules/Module.js"; @@ -125,7 +124,6 @@ export const handler = async (options: LocalConfigOptions = {}) => { } catch (error) { Logger.error("There was an error while configuring the testing environment:"); Logger.error(error); - track("error", { error }); } }; diff --git a/src/commands/dev/install.ts b/src/commands/dev/install.ts index a632fb16..cbd67b8b 100644 --- a/src/commands/dev/install.ts +++ b/src/commands/dev/install.ts @@ -3,7 +3,6 @@ import { Option } from "commander"; import Program from "./command.js"; import { modulesPath } from "./modules/Module.js"; -import { track } from "../../utils/analytics.js"; import { executeCommand } from "../../utils/helpers.js"; import Logger from "../../utils/logger.js"; @@ -25,7 +24,6 @@ export const handler = async (moduleNames: string[], options: { link: boolean }) } catch (error) { Logger.error("There was an error while installing module:"); Logger.error(error); - track("error", { error }); } }; diff --git a/src/commands/dev/logs.ts b/src/commands/dev/logs.ts index 0396fefd..644533b9 100644 --- a/src/commands/dev/logs.ts +++ b/src/commands/dev/logs.ts @@ -2,7 +2,6 @@ import chalk from "chalk"; import Program from "./command.js"; import configHandler from "./ConfigHandler.js"; -import { track } from "../../utils/analytics.js"; import Logger from "../../utils/logger.js"; export const handler = async () => { @@ -34,7 +33,6 @@ export const handler = async () => { } catch (error) { Logger.error("There was an error displaying logs:"); Logger.error(error); - track("error", { error }); } }; diff --git a/src/commands/dev/modules/index.ts b/src/commands/dev/modules/index.ts index 4f0dc030..f4f02b56 100644 --- a/src/commands/dev/modules/index.ts +++ b/src/commands/dev/modules/index.ts @@ -1,6 +1,5 @@ import chalk from "chalk"; -import { track } from "../../../utils/analytics.js"; import Logger from "../../../utils/logger.js"; import Program from "../command.js"; import configHandler from "../ConfigHandler.js"; @@ -30,7 +29,6 @@ export const handler = async () => { } catch (error) { Logger.error("There was an error displaying installed modules:"); Logger.error(error); - track("error", { error }); } }; diff --git a/src/commands/dev/restart.ts b/src/commands/dev/restart.ts index 57f8b347..4c401fd8 100644 --- a/src/commands/dev/restart.ts +++ b/src/commands/dev/restart.ts @@ -1,7 +1,6 @@ import Program from "./command.js"; import { handler as start } from "./start.js"; import { handler as stop } from "./stop.js"; -import { track } from "../../utils/analytics.js"; import Logger from "../../utils/logger.js"; export const handler = async () => { @@ -11,7 +10,6 @@ export const handler = async () => { } catch (error) { Logger.error("There was an error while restarting the testing environment:"); Logger.error(error); - track("error", { error }); } }; diff --git a/src/commands/dev/start.ts b/src/commands/dev/start.ts index 2eefccf4..e89bc06b 100644 --- a/src/commands/dev/start.ts +++ b/src/commands/dev/start.ts @@ -5,7 +5,6 @@ import { setupConfig } from "./config.js"; import configHandler from "./ConfigHandler.js"; import { ModuleCategory } from "./modules/Module.js"; import { getModulesRequiringUpdates } from "./modules/utils/updates.js"; -import { track } from "../../utils/analytics.js"; import { formatLogs } from "../../utils/formatters.js"; import Logger from "../../utils/logger.js"; @@ -111,7 +110,6 @@ export const handler = async () => { } catch (error) { Logger.error("There was an error while starting the testing environment:"); Logger.error(error); - track("error", { error }); } }; diff --git a/src/commands/dev/stop.ts b/src/commands/dev/stop.ts index a946fbc4..aad5f211 100644 --- a/src/commands/dev/stop.ts +++ b/src/commands/dev/stop.ts @@ -1,6 +1,5 @@ import Program from "./command.js"; import configHandler from "./ConfigHandler.js"; -import { track } from "../../utils/analytics.js"; import Logger from "../../utils/logger.js"; export const handler = async () => { @@ -11,7 +10,6 @@ export const handler = async () => { } catch (error) { Logger.error("There was an error while stopping the testing environment:"); Logger.error(error); - track("error", { error }); } }; diff --git a/src/commands/dev/uninstall.ts b/src/commands/dev/uninstall.ts index 8068b56d..0da6d404 100644 --- a/src/commands/dev/uninstall.ts +++ b/src/commands/dev/uninstall.ts @@ -5,7 +5,6 @@ import Program from "./command.js"; import configHandler from "./ConfigHandler.js"; import { modulesPath } from "./modules/Module.js"; import { findDefaultModules } from "./modules/utils/packages.js"; -import { track } from "../../utils/analytics.js"; import { executeCommand } from "../../utils/helpers.js"; import Logger from "../../utils/logger.js"; @@ -34,7 +33,6 @@ export const handler = async (moduleNames: string[], options: { unlink: boolean } catch (error) { Logger.error("There was an error while uninstalling module:"); Logger.error(error); - track("error", { error }); } }; diff --git a/src/commands/dev/update.ts b/src/commands/dev/update.ts index 5f997b8b..9dd4c243 100644 --- a/src/commands/dev/update.ts +++ b/src/commands/dev/update.ts @@ -4,7 +4,6 @@ import { Option } from "commander"; import Program from "./command.js"; import configHandler from "./ConfigHandler.js"; import { modulesPath } from "./modules/Module.js"; -import { track } from "../../utils/analytics.js"; import { executeCommand } from "../../utils/helpers.js"; import Logger from "../../utils/logger.js"; @@ -67,7 +66,6 @@ export const handler = async (moduleNames: string[], options: ModuleUpdateOption } catch (error) { Logger.error("There was an error while updating module:"); Logger.error(error); - track("error", { error }); } }; diff --git a/src/utils/analytics.ts b/src/utils/analytics.ts deleted file mode 100644 index 2459282f..00000000 --- a/src/utils/analytics.ts +++ /dev/null @@ -1,50 +0,0 @@ -import RudderAnalytics from "@rudderstack/rudder-sdk-node"; -import { config } from "dotenv"; -import machine from "node-machine-id"; -import path from "path"; - -import { getDirPath } from "./files.js"; - -import type { apiObject } from "@rudderstack/rudder-sdk-node"; - -const envPath = path.join(getDirPath(import.meta.url), "../../", ".env-public-analytics"); -config({ path: envPath }); - -let client: RudderAnalytics.default | undefined; - -const getClient = () => { - if (!client) { - try { - client = new RudderAnalytics.default(process.env.RUDDER_STACK_KEY!, { - dataPlaneUrl: process.env.RUDDER_STACK_DATAPLANE_URL!, - logLevel: "error", - }); - } catch { - // ignore or handle the error appropriately - } - } - return client!; -}; - -export const track = async (event: string, properties?: unknown) => { - const clientInstance = getClient(); - if (!clientInstance || process.env.NO_TRACKING) return; - - // eslint-disable-next-line no-async-promise-executor - return new Promise(async (resolve) => { - const raceFunction = setTimeout(() => { - resolve(); - }, 1000); - clientInstance!.track( - { - userId: await machine.machineId(), - event, - properties: properties as apiObject, - }, - () => { - clearTimeout(raceFunction); - resolve(); - } - ); - }); -}; diff --git a/src/utils/zeek.ts b/src/utils/zeek.ts index 6c932171..43a738f8 100644 --- a/src/utils/zeek.ts +++ b/src/utils/zeek.ts @@ -1,24 +1,11 @@ import chalk from "chalk"; -import { $fetch } from "ofetch"; import Logger from "./logger.js"; -export default async () => { - const api_url = "https://zenquotes.io/api/random/"; - let quote = ""; - try { - const response = await $fetch(api_url); - const data: { q: string; a: string; h: string }[] = response.data; - quote = data[0]["q"] + " - " + data[0]["a"]; - } catch (e) { - quote = "No inspirational quote for you now."; - } - - // eslint-disable-next-line no-console - console.log( - chalk.white( - "\n\n\ - -██-- --▓▓- \n\ +const API_URL = "https://zenquotes.io/api/random/"; +const ASCII_ART = + "\n\n\ + -██-- --▓▓- \n\ -█▓---▓▓██▓ -▓██▓▓--█▓ \n\ ▓█--▓▓▓---▓██- ▓██▓---▓▓--██ \n\ ██-██-▓█▓▓---▓█▓- -▓█▓---▓▓█▓██-▓█-\n\ @@ -51,9 +38,29 @@ export default async () => { -▓█▓- -▓█▓- \n\ -▓██▓-- --▓██▓- \n\ --▓▓█▓▓▓▓▓▓--------▓▓▓▓▓▓█▓▓-- \n\ -" - ) - ); +"; + +const fetchAndFormatQuote = async (): Promise => { + try { + const response = await fetch(API_URL); + if (!response.ok) { + throw new Error(`Network response was not ok: ${response.statusText}`); + } + + const data: { + q: string; + a: string; + h: string; + }[] = await response.json(); + return `${data[0].q} - ${data[0].a}`; + } catch { + return "No inspirational quote for you now."; + } +}; + +export default async () => { + const quote = await fetchAndFormatQuote(); - Logger.info(`zeek would like to tell you "${quote}"\n\n`); + Logger.info(chalk.white(ASCII_ART)); + Logger.info(`\nzeek would like to tell you: "${quote}"\n\n`); };