Skip to content

Commit

Permalink
chore: disable telemetry (#39137)
Browse files Browse the repository at this point in the history
* chore: remove telemetry from create-gatsby

* fix: make gatsby-telemetry no-op

* chore: remove gatsby-telemetry usage
  • Loading branch information
pieh authored Oct 23, 2024
1 parent 41d8aef commit 1b1720b
Show file tree
Hide file tree
Showing 64 changed files with 138 additions and 1,432 deletions.
5 changes: 3 additions & 2 deletions integration-tests/gatsby-cli/__tests__/options.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ jest.setTimeout(MAX_TIMEOUT)

describe(`gatsby options`, () => {
it(`Prints the options`, () => {
const [status, logs] = GatsbyCLI.from(`gatsby-sites/gatsby-build`).invoke(`options`)
const [status, logs] = GatsbyCLI.from(`gatsby-sites/gatsby-build`).invoke(
`options`
)

logs.should.contain(`Package Manager`)
logs.should.contain(`Telemetry enabled`)
expect(status).toBe(0)
})
})
41 changes: 0 additions & 41 deletions packages/create-gatsby/src/__tests__/run.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import path from "path"
import { reporter } from "../utils/reporter"
import { initStarter } from "../init-starter"
import { setSiteMetadata } from "../utils/site-metadata"
import { trackCli } from "../tracking"
import { run, DEFAULT_STARTERS } from "../index"

jest.mock(`../utils/parse-args`)
Expand Down Expand Up @@ -35,11 +34,6 @@ jest.mock(`enquirer`, () => {
return MockedEnquirer
})
jest.mock(`../utils/reporter`)
jest.mock(`../tracking`, () => {
return {
trackCli: jest.fn(),
}
})
jest.mock(`../init-starter`, () => {
return {
initStarter: jest.fn(),
Expand All @@ -57,12 +51,6 @@ jest.mock(`../utils/site-metadata`, () => {
setSiteMetadata: jest.fn(),
}
})
jest.mock(`../utils/hash`, () => {
return {
sha256: jest.fn(args => args),
md5: jest.fn(args => args),
}
})

jest.mock(`../utils/question-helpers`, () => {
const originalQuestionHelpers = jest.requireActual(
Expand Down Expand Up @@ -185,13 +173,6 @@ describe(`run`, () => {
dirName
)
})
it(`should track JS was selected as language`, async () => {
await run()
expect(trackCli).toHaveBeenCalledWith(`CREATE_GATSBY_SELECT_OPTION`, {
name: `LANGUAGE`,
valueString: `js`,
})
})
})

describe(`no ts flag`, () => {
Expand All @@ -211,13 +192,6 @@ describe(`run`, () => {
siteName
)
})
it(`should track JS was selected as language`, async () => {
await run()
expect(trackCli).toHaveBeenCalledWith(`CREATE_GATSBY_SELECT_OPTION`, {
name: `LANGUAGE`,
valueString: `js`,
})
})
})

describe(`ts flag`, () => {
Expand All @@ -237,14 +211,6 @@ describe(`run`, () => {
siteName
)
})

it(`should track TS was selected as language`, async () => {
await run()
expect(trackCli).toHaveBeenCalledWith(`CREATE_GATSBY_SELECT_OPTION`, {
name: `LANGUAGE`,
valueString: `ts`,
})
})
})
})

Expand All @@ -265,11 +231,4 @@ describe(`skip and ts flag`, () => {
dirName
)
})
it(`should track TS was selected as language`, async () => {
await run()
expect(trackCli).toHaveBeenCalledWith(`CREATE_GATSBY_SELECT_OPTION`, {
name: `LANGUAGE`,
valueString: `ts`,
})
})
})
61 changes: 0 additions & 61 deletions packages/create-gatsby/src/__tests__/tracking.ts

This file was deleted.

43 changes: 0 additions & 43 deletions packages/create-gatsby/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,13 @@ import { plugin } from "./components/plugin"
import { makePluginConfigQuestions } from "./plugin-options-form"
import { center, wrap } from "./components/utils"
import { stripIndent } from "common-tags"
import { trackCli } from "./tracking"
import { reporter } from "./utils/reporter"
import { setSiteMetadata } from "./utils/site-metadata"
import { makeNpmSafe } from "./utils/make-npm-safe"
import {
generateQuestions,
validateProjectName,
} from "./utils/question-helpers"
import { sha256, md5 } from "./utils/hash"
import { maybeUseEmoji } from "./utils/emoji"
import { parseArgs } from "./utils/parse-args"

Expand Down Expand Up @@ -75,8 +73,6 @@ export type PluginConfigMap = Record<string, Record<string, unknown>>
export async function run(): Promise<void> {
const { flags, dirName } = parseArgs(process.argv.slice(2))

trackCli(`CREATE_GATSBY_START`)

const { version } = require(`../package.json`)

reporter.info(colors.grey(`create-gatsby version ${version}`))
Expand Down Expand Up @@ -149,28 +145,6 @@ ${center(colors.blueBright.bold.underline(`Welcome to Gatsby!`))}
answers.language = `ts`
}

// Telemetry
trackCli(`CREATE_GATSBY_SELECT_OPTION`, {
name: `project_name`,
valueString: sha256(answers.project),
})
trackCli(`CREATE_GATSBY_SELECT_OPTION`, {
name: `LANGUAGE`,
valueString: answers.language,
})
trackCli(`CREATE_GATSBY_SELECT_OPTION`, {
name: `CMS`,
valueString: answers.cms || `none`,
})
trackCli(`CREATE_GATSBY_SELECT_OPTION`, {
name: `CSS_TOOLS`,
valueString: answers.styling || `none`,
})
trackCli(`CREATE_GATSBY_SELECT_OPTION`, {
name: `PLUGIN`,
valueStringArray: answers.features || [],
})

// Collect a report of things we will do to present to the user once the questions are complete
const messages: Array<string> = [
`${maybeUseEmoji(
Expand Down Expand Up @@ -263,14 +237,10 @@ ${center(colors.blueBright.bold.underline(`Welcome to Gatsby!`))}
`\nGreat! A few of the selections you made need to be configured. Please fill in the options for each plugin now:\n`
)

trackCli(`CREATE_GATSBY_SET_PLUGINS_START`)

const enquirer = new Enquirer<Record<string, Record<string, unknown>>>()
enquirer.use(plugin)

pluginConfig = { ...pluginConfig, ...(await enquirer.prompt(config)) }

trackCli(`CREATE_GATSBY_SET_PLUGINS_STOP`)
}

// If we're not skipping prompts, give the user a report of what we're about to do
Expand All @@ -291,8 +261,6 @@ ${colors.bold(`Thanks! Here's what we'll now do:`)}
})

if (!confirm) {
trackCli(`CREATE_GATSBY_CANCEL`)

reporter.info(`OK, bye!`)
return
}
Expand Down Expand Up @@ -349,15 +317,4 @@ ${colors.bold(`Thanks! Here's what we'll now do:`)}
reporter.info(`See all commands at\n
${colors.blueBright(`https://www.gatsbyjs.com/docs/reference/gatsby-cli/`)}
`)

const siteHash = md5(fullPath)
trackCli(`CREATE_GATSBY_SUCCESS`, { siteHash })
}

process.on(`exit`, exitCode => {
trackCli(`CREATE_GATSBY_END`, { exitCode })

if (exitCode === -1) {
trackCli(`CREATE_GATSBY_ERROR`)
}
})
81 changes: 0 additions & 81 deletions packages/create-gatsby/src/tracking.ts

This file was deleted.

6 changes: 0 additions & 6 deletions packages/create-gatsby/src/utils/hash.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/gatsby-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@
"fs-exists-cached": "^1.0.0",
"fs-extra": "^11.2.0",
"gatsby-core-utils": "^4.14.0-next.2",
"gatsby-telemetry": "^4.14.0-next.2",
"hosted-git-info": "^3.0.8",
"is-valid-path": "^0.1.1",
"joi": "^17.9.2",
Expand Down
Loading

0 comments on commit 1b1720b

Please sign in to comment.