Skip to content

Commit 1b1720b

Browse files
authored
chore: disable telemetry (#39137)
* chore: remove telemetry from create-gatsby * fix: make gatsby-telemetry no-op * chore: remove gatsby-telemetry usage
1 parent 41d8aef commit 1b1720b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+138
-1432
lines changed

integration-tests/gatsby-cli/__tests__/options.js

+3-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,11 @@ jest.setTimeout(MAX_TIMEOUT)
55

66
describe(`gatsby options`, () => {
77
it(`Prints the options`, () => {
8-
const [status, logs] = GatsbyCLI.from(`gatsby-sites/gatsby-build`).invoke(`options`)
8+
const [status, logs] = GatsbyCLI.from(`gatsby-sites/gatsby-build`).invoke(
9+
`options`
10+
)
911

1012
logs.should.contain(`Package Manager`)
11-
logs.should.contain(`Telemetry enabled`)
1213
expect(status).toBe(0)
1314
})
1415
})

packages/create-gatsby/src/__tests__/run.ts

-41
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@ import path from "path"
22
import { reporter } from "../utils/reporter"
33
import { initStarter } from "../init-starter"
44
import { setSiteMetadata } from "../utils/site-metadata"
5-
import { trackCli } from "../tracking"
65
import { run, DEFAULT_STARTERS } from "../index"
76

87
jest.mock(`../utils/parse-args`)
@@ -35,11 +34,6 @@ jest.mock(`enquirer`, () => {
3534
return MockedEnquirer
3635
})
3736
jest.mock(`../utils/reporter`)
38-
jest.mock(`../tracking`, () => {
39-
return {
40-
trackCli: jest.fn(),
41-
}
42-
})
4337
jest.mock(`../init-starter`, () => {
4438
return {
4539
initStarter: jest.fn(),
@@ -57,12 +51,6 @@ jest.mock(`../utils/site-metadata`, () => {
5751
setSiteMetadata: jest.fn(),
5852
}
5953
})
60-
jest.mock(`../utils/hash`, () => {
61-
return {
62-
sha256: jest.fn(args => args),
63-
md5: jest.fn(args => args),
64-
}
65-
})
6654

6755
jest.mock(`../utils/question-helpers`, () => {
6856
const originalQuestionHelpers = jest.requireActual(
@@ -185,13 +173,6 @@ describe(`run`, () => {
185173
dirName
186174
)
187175
})
188-
it(`should track JS was selected as language`, async () => {
189-
await run()
190-
expect(trackCli).toHaveBeenCalledWith(`CREATE_GATSBY_SELECT_OPTION`, {
191-
name: `LANGUAGE`,
192-
valueString: `js`,
193-
})
194-
})
195176
})
196177

197178
describe(`no ts flag`, () => {
@@ -211,13 +192,6 @@ describe(`run`, () => {
211192
siteName
212193
)
213194
})
214-
it(`should track JS was selected as language`, async () => {
215-
await run()
216-
expect(trackCli).toHaveBeenCalledWith(`CREATE_GATSBY_SELECT_OPTION`, {
217-
name: `LANGUAGE`,
218-
valueString: `js`,
219-
})
220-
})
221195
})
222196

223197
describe(`ts flag`, () => {
@@ -237,14 +211,6 @@ describe(`run`, () => {
237211
siteName
238212
)
239213
})
240-
241-
it(`should track TS was selected as language`, async () => {
242-
await run()
243-
expect(trackCli).toHaveBeenCalledWith(`CREATE_GATSBY_SELECT_OPTION`, {
244-
name: `LANGUAGE`,
245-
valueString: `ts`,
246-
})
247-
})
248214
})
249215
})
250216

@@ -265,11 +231,4 @@ describe(`skip and ts flag`, () => {
265231
dirName
266232
)
267233
})
268-
it(`should track TS was selected as language`, async () => {
269-
await run()
270-
expect(trackCli).toHaveBeenCalledWith(`CREATE_GATSBY_SELECT_OPTION`, {
271-
name: `LANGUAGE`,
272-
valueString: `ts`,
273-
})
274-
})
275234
})

packages/create-gatsby/src/__tests__/tracking.ts

-61
This file was deleted.

packages/create-gatsby/src/index.ts

-43
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,13 @@ import { plugin } from "./components/plugin"
1212
import { makePluginConfigQuestions } from "./plugin-options-form"
1313
import { center, wrap } from "./components/utils"
1414
import { stripIndent } from "common-tags"
15-
import { trackCli } from "./tracking"
1615
import { reporter } from "./utils/reporter"
1716
import { setSiteMetadata } from "./utils/site-metadata"
1817
import { makeNpmSafe } from "./utils/make-npm-safe"
1918
import {
2019
generateQuestions,
2120
validateProjectName,
2221
} from "./utils/question-helpers"
23-
import { sha256, md5 } from "./utils/hash"
2422
import { maybeUseEmoji } from "./utils/emoji"
2523
import { parseArgs } from "./utils/parse-args"
2624

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

78-
trackCli(`CREATE_GATSBY_START`)
79-
8076
const { version } = require(`../package.json`)
8177

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

152-
// Telemetry
153-
trackCli(`CREATE_GATSBY_SELECT_OPTION`, {
154-
name: `project_name`,
155-
valueString: sha256(answers.project),
156-
})
157-
trackCli(`CREATE_GATSBY_SELECT_OPTION`, {
158-
name: `LANGUAGE`,
159-
valueString: answers.language,
160-
})
161-
trackCli(`CREATE_GATSBY_SELECT_OPTION`, {
162-
name: `CMS`,
163-
valueString: answers.cms || `none`,
164-
})
165-
trackCli(`CREATE_GATSBY_SELECT_OPTION`, {
166-
name: `CSS_TOOLS`,
167-
valueString: answers.styling || `none`,
168-
})
169-
trackCli(`CREATE_GATSBY_SELECT_OPTION`, {
170-
name: `PLUGIN`,
171-
valueStringArray: answers.features || [],
172-
})
173-
174148
// Collect a report of things we will do to present to the user once the questions are complete
175149
const messages: Array<string> = [
176150
`${maybeUseEmoji(
@@ -263,14 +237,10 @@ ${center(colors.blueBright.bold.underline(`Welcome to Gatsby!`))}
263237
`\nGreat! A few of the selections you made need to be configured. Please fill in the options for each plugin now:\n`
264238
)
265239

266-
trackCli(`CREATE_GATSBY_SET_PLUGINS_START`)
267-
268240
const enquirer = new Enquirer<Record<string, Record<string, unknown>>>()
269241
enquirer.use(plugin)
270242

271243
pluginConfig = { ...pluginConfig, ...(await enquirer.prompt(config)) }
272-
273-
trackCli(`CREATE_GATSBY_SET_PLUGINS_STOP`)
274244
}
275245

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

293263
if (!confirm) {
294-
trackCli(`CREATE_GATSBY_CANCEL`)
295-
296264
reporter.info(`OK, bye!`)
297265
return
298266
}
@@ -349,15 +317,4 @@ ${colors.bold(`Thanks! Here's what we'll now do:`)}
349317
reporter.info(`See all commands at\n
350318
${colors.blueBright(`https://www.gatsbyjs.com/docs/reference/gatsby-cli/`)}
351319
`)
352-
353-
const siteHash = md5(fullPath)
354-
trackCli(`CREATE_GATSBY_SUCCESS`, { siteHash })
355320
}
356-
357-
process.on(`exit`, exitCode => {
358-
trackCli(`CREATE_GATSBY_END`, { exitCode })
359-
360-
if (exitCode === -1) {
361-
trackCli(`CREATE_GATSBY_ERROR`)
362-
}
363-
})

packages/create-gatsby/src/tracking.ts

-81
This file was deleted.

packages/create-gatsby/src/utils/hash.ts

-6
This file was deleted.

packages/gatsby-cli/package.json

-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
"fs-exists-cached": "^1.0.0",
3333
"fs-extra": "^11.2.0",
3434
"gatsby-core-utils": "^4.14.0-next.2",
35-
"gatsby-telemetry": "^4.14.0-next.2",
3635
"hosted-git-info": "^3.0.8",
3736
"is-valid-path": "^0.1.1",
3837
"joi": "^17.9.2",

0 commit comments

Comments
 (0)