Skip to content

Commit

Permalink
feat: disable telemetry by option (#345)
Browse files Browse the repository at this point in the history
* feat(disable-telemetry): add `--disable-telemetry` option

* chore: bump to 1.16.0
  • Loading branch information
aliemir authored Jun 1, 2023
1 parent fa1386f commit 9a41f1d
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 40 deletions.
1 change: 1 addition & 0 deletions @types/sao.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,7 @@ interface IExtras {
paths: IPaths;
projectType: string;
presetAnswers?: Record<string, string | undefined>;
disableTelemetry?: boolean;
}
interface Options$1 {
appName?: string;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "superplate-cli",
"version": "1.15.5",
"version": "1.16.0",
"description": "The frontend boilerplate with superpowers",
"license": "MIT",
"repository": {
Expand Down
1 change: 0 additions & 1 deletion src/Helper/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ export {
is_multi_type,
prompt_project_types,
} from "./source";
export { prompt_telemetry } from "./telemetry";
export { tips } from "./tips";
export { UrlHelper } from "./url";
21 changes: 0 additions & 21 deletions src/Helper/telemetry/index.ts

This file was deleted.

2 changes: 2 additions & 0 deletions src/cli.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ const cli = async (): Promise<void> => {
)
.option("-p, --project <project-name>", "specify a project type to use")
.option("-d, --debug", "print additional logs and skip install script")
.option("--disable-telemetry", "disable anonymous telemetry")
.on("--help", () => {
console.log();
console.log(
Expand Down Expand Up @@ -193,6 +194,7 @@ const cli = async (): Promise<void> => {
extras: {
apiMode: false,
debug: !!program.debug,
disableTelemetry: !!program.disableTelemetry,
projectType,
paths: {
sourcePath,
Expand Down
29 changes: 12 additions & 17 deletions src/saofile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import {
mergeJSONFiles,
mergePackages,
mergePluginData,
prompt_telemetry,
tips,
} from "@Helper";
import { ProjectPrompt } from "@Helper/lucky";
Expand Down Expand Up @@ -325,22 +324,18 @@ const saoConfig: GeneratorConfig = {
},
});

if (!sao.opts.extras.apiMode) {
const { telemetry } = await prompt_telemetry();

if (telemetry === "yes") {
try {
analytics.track({
event: "generate",
properties: {
...sao.answers,
type: sao.opts.extras.projectType,
},
anonymousId: uuidv4(),
});
} catch (error) {
//
}
if (!sao.opts.extras.apiMode && !sao.opts.extras.disableTelemetry) {
try {
analytics.track({
event: "generate",
properties: {
...sao.answers,
type: sao.opts.extras.projectType,
},
anonymousId: uuidv4(),
});
} catch (error) {
//
}
}

Expand Down

0 comments on commit 9a41f1d

Please sign in to comment.