Skip to content

Commit

Permalink
Remove all analytics from the dataform CLI (#1683)
Browse files Browse the repository at this point in the history
* Remove all analytics from the dataform CLI

* Remove all analytics from the dataform CLI
  • Loading branch information
GJMcGowan authored Mar 7, 2024
1 parent 50c6c14 commit 86b1a6e
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 260 deletions.
5 changes: 0 additions & 5 deletions cli/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ package(default_visibility = ["//visibility:public"])
ts_library(
name = "cli",
srcs = [
"analytics.ts",
"config.ts",
"console.ts",
"credentials.ts",
"index.ts",
Expand All @@ -25,19 +23,16 @@ ts_library(
"//core",
"//protos:ts",
"//sqlx:format",
"@npm//@segment/analytics-node",
"@npm//@types/glob",
"@npm//@types/long",
"@npm//@types/node",
"@npm//@types/readline-sync",
"@npm//@types/uuid",
"@npm//@types/yargs",
"@npm//chokidar",
"@npm//glob",
"@npm//parse-duration",
"@npm//readline-sync",
"@npm//untildify",
"@npm//uuid",
"@npm//yargs",
],
)
Expand Down
102 changes: 0 additions & 102 deletions cli/analytics.ts

This file was deleted.

49 changes: 0 additions & 49 deletions cli/config.ts

This file was deleted.

24 changes: 8 additions & 16 deletions cli/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import * as path from "path";
import yargs from "yargs";

import * as chokidar from "chokidar";
import { trackError, trackOption } from "df/cli/analytics";
import { build, compile, credentials, init, install, run, test } from "df/cli/api";
import { CREDENTIALS_FILENAME } from "df/cli/api/commands/credentials";
import { BigQueryDbAdapter } from "df/cli/api/dbadapters/bigquery";
Expand Down Expand Up @@ -34,7 +33,6 @@ const RECOMPILE_DELAY = 500;

process.on("unhandledRejection", async (reason: any) => {
printError(`Unhandled promise rejection: ${reason?.stack || reason}`);
await trackError();
});

// TODO: Since yargs launched an actually well typed API in version 12, let's use it as this file is currently not type checked.
Expand All @@ -59,8 +57,7 @@ const projectDirMustExistOption = {
);
if (!fs.existsSync(dataformJsonPath) && !fs.existsSync(workflowSettingsYamlPath)) {
throw new Error(
`${
argv[projectDirOption.name]
`${argv[projectDirOption.name]
} does not appear to be a dataform directory (missing workflow_settings.yaml file).`
);
}
Expand Down Expand Up @@ -208,7 +205,7 @@ export function runCli() {
if (!argv[ProjectConfigOptions.defaultDatabase.name]) {
throw new Error(
`The ${ProjectConfigOptions.defaultDatabase.name} positional argument is ` +
`required. Use "dataform help init" for more info.`
`required. Use "dataform help init" for more info.`
);
}
}
Expand All @@ -224,13 +221,13 @@ export function runCli() {
if (!argv[ProjectConfigOptions.defaultLocation.name]) {
throw new Error(
`The ${ProjectConfigOptions.defaultLocation.name} positional argument is ` +
`required. Use "dataform help init" for more info.`
`required. Use "dataform help init" for more info.`
);
}
}
}
],
options: [trackOption],
options: [],
processFn: async argv => {
print("Writing project files...\n");
const initResult = await init(argv[projectDirOption.name], {
Expand All @@ -245,7 +242,7 @@ export function runCli() {
format: `install [${projectDirMustExistOption.name}]`,
description: "Install a project's NPM dependencies.",
positionalOptions: [projectDirMustExistOption],
options: [trackOption],
options: [],
processFn: async argv => {
print("Installing NPM dependencies...\n");
await install(argv[projectDirMustExistOption.name]);
Expand All @@ -260,7 +257,6 @@ export function runCli() {
`accessing BigQuery.`,
positionalOptions: [projectDirMustExistOption],
options: [
trackOption,
{
name: testConnectionOptionName,
option: {
Expand All @@ -287,7 +283,7 @@ export function runCli() {
case credentials.TestResultStatus.OTHER_ERROR: {
throw new Error(
`Credentials test query failed: ${testResult.error.stack ||
testResult.error.message}`
testResult.error.message}`
);
}
}
Expand Down Expand Up @@ -319,7 +315,6 @@ export function runCli() {
},
jsonOutputOption,
timeoutOption,
trackOption,
...ProjectConfigOptions.allYargsOptions
],
processFn: async argv => {
Expand Down Expand Up @@ -411,7 +406,6 @@ export function runCli() {
credentialsOption,
timeoutOption,
...ProjectConfigOptions.allYargsOptions,
trackOption
],
processFn: async argv => {
print("Compiling...\n");
Expand Down Expand Up @@ -478,7 +472,6 @@ export function runCli() {
jsonOutputOption,
timeoutOption,
...ProjectConfigOptions.allYargsOptions,
trackOption
],
processFn: async argv => {
if (!argv[jsonOutputOption.name]) {
Expand Down Expand Up @@ -581,7 +574,7 @@ export function runCli() {
format: `format [${projectDirMustExistOption.name}]`,
description: "Format the dataform project's files.",
positionalOptions: [projectDirMustExistOption],
options: [trackOption],
options: [],
processFn: async argv => {
const filenames = glob.sync("{definitions,includes}/**/*.{js,sqlx}", {
cwd: argv[projectDirMustExistOption.name]
Expand Down Expand Up @@ -619,7 +612,6 @@ export function runCli() {
} else {
const message = err?.message ? err.message.split("\n")[0] : msg;
printError(`Dataform encountered an error: ${message}`);
await trackError();
if (err?.stack) {
printError(err.stack);
}
Expand Down Expand Up @@ -709,7 +701,7 @@ class ProjectConfigOptions {
) {
throw new Error(
`--${ProjectConfigOptions.schemaSuffix.name} should contain only ` +
`alphanumeric characters and/or underscores.`
`alphanumeric characters and/or underscores.`
);
}
}
Expand Down
11 changes: 0 additions & 11 deletions cli/yargswrapper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import yargs from "yargs";

import {maybeConfigureAnalytics, trackCommand, trackOption} from "df/cli/analytics";

export interface ICli {
commands: ICommand[];
}
Expand All @@ -28,16 +26,7 @@ export function createYargsCli(cli: ICli) {
command.description,
(yargsChainer: yargs.Argv) => createOptionsChain(yargsChainer, command),
async (argv: { [argumentName: string]: any }) => {
await maybeConfigureAnalytics(argv[trackOption.name]);
const analyticsTrack = trackCommand(command.format.split(" ")[0]);
const exitCode = await command.processFn(argv);
let timer: NodeJS.Timer;
// Analytics tracking can take a while, so wait up to 2 seconds for them to finish.
await Promise.race([
analyticsTrack,
new Promise(resolve => (timer = setTimeout(resolve, 2000)))
]);
clearTimeout(timer);
process.exit(exitCode);
}
);
Expand Down
3 changes: 0 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
"@nivo/line": "^0.61.1",
"@octokit/rest": "^16.35.0",
"@rollup/plugin-node-resolve": "^7.1.3",
"@segment/analytics-node": "^1.1.3",
"@types/bunyan": "^1.8.6",
"@types/chai": "^4.1.7",
"@types/diff": "^4.0.2",
Expand All @@ -43,7 +42,6 @@
"@types/stack-trace": "^0.0.29",
"@types/swagger-schema-official": "^2.0.20",
"@types/tmp": "^0.2.0",
"@types/uuid": "^7.0.2",
"@types/validator": "^13.1.0",
"@types/vscode": "^1.45.1",
"@types/yargs": "^15.0.5",
Expand Down Expand Up @@ -124,7 +122,6 @@
"uglify-js": "^3.7.7",
"untildify": "^4.0.0",
"url": "^0.11.0",
"uuid": "^7.0.2",
"validator": "^13.7.0",
"vm2": "3.9.19",
"vsce": "^1.79.5",
Expand Down
2 changes: 0 additions & 2 deletions packages/@dataform/cli/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ nodejs_binary(

externals = [
"@google-cloud/bigquery",
"@segment/analytics-node",
"chokidar",
"deepmerge",
"fs-extra",
Expand All @@ -44,7 +43,6 @@ externals = [
"tarjan-graph",
"tmp",
"typeid-js",
"uuid",
"untildify",
"vm2",
"yargs",
Expand Down
Loading

0 comments on commit 86b1a6e

Please sign in to comment.