Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Impossible to disable telemetry for the CLI #34486

Closed
2 tasks done
dhoko opened this issue Jan 13, 2022 · 1 comment · Fixed by #34495
Closed
2 tasks done

Impossible to disable telemetry for the CLI #34486

dhoko opened this issue Jan 13, 2022 · 1 comment · Fixed by #34495
Assignees
Labels
topic: cli Related to the Gatsby CLI type: bug An issue or pull request relating to a bug in Gatsby

Comments

@dhoko
Copy link
Contributor

dhoko commented Jan 13, 2022

Preliminary Checks

Description

👋

If we follow the documentation here https://www.gatsbyjs.com/docs/telemetry/ we can expect to disable the telemetry, isn't it?
It turns out, we don't.

HTTP 1524465: createConnection analytics.gatsbyjs.com:443::::::::::::::::::::: [Object: null prototype] {   
  protocol: 'https:',                                                                                       
  slashes: true,                                                                                            
  auth: null,                                                                                               
  host: 'analytics.gatsbyjs.com',                                                                           
  port: 443,                                                                                                
  hostname: 'analytics.gatsbyjs.com',                                                                       
  hash: null,                                                                                               
  search: null,                                                                                             
  query: null,                                                                                              
  pathname: '/events',                                                                                      
  path: null,                                                                                               
  href: 'https://analytics.gatsbyjs.com/events',                                                            
  method: 'POST',                                                                                           
  headers: [Object: null prototype] {                                                                       
    'content-type': [ 'application/json' ],                                                                 
    'user-agent': [ 'create-gatsby:1.11.0' ],                                                               
    Accept: [ '*/*' ],                                                                                      
    'Content-Length': [ '261' ],                                                                            
    'Accept-Encoding': [ 'gzip,deflate' ],                                                                  
    Connection: [ 'close' ]                                                                                 

Here it's an old version of the CLI, but for the latest one I may be wrong but I don't see a change based on:

edit: Post tests, we have the same issue with the latest gatsy.
Ho, what do we have here, yet another call 😁

  $ npx gatsby --version
Gatsby CLI version: 4.5.1

HTTP 1533501: call onSocket 0 0
HTTP 1533501: createConnection analytics.gatsbyjs.com:443::::::::::::::::::::: [Object: null prototype] {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'analytics.gatsbyjs.com',
  port: 443,
  hostname: 'analytics.gatsbyjs.com',
  hash: null,
  search: null,
  query: null,
  pathname: '/events',
  path: null,
  href: 'https://analytics.gatsbyjs.com/events',
  method: 'POST',
  headers: [Object: null prototype] {
    'content-type': [ 'application/json' ],
    'user-agent': [ 'create-gatsby:2.5.0' ],
    Accept: [ '*/*' ],
    'Content-Length': [ '260' ],
    'Accept-Encoding': [ 'gzip,deflate' ],
    Connection: [ 'close' ]
  },
  agent: undefined,
  _defaultAgent: Agent {
    _events: [Object: null prototype] {
      free: [Function (anonymous)],
      newListener: [Function: maybeEnableKeylog]
    },
    _eventsCount: 2,
    _maxListeners: undefined,
    defaultPort: 443,
    protocol: 'https:',
    options: [Object: null prototype] { path: null },
    requests: [Object: null prototype] {},
    sockets: [Object: null prototype] {
      'analytics.gatsbyjs.com:443:::::::::::::::::::::': []
    },
    freeSockets: [Object: null prototype] {},
    keepAliveMsecs: 1000,
    keepAlive: false,
    maxSockets: Infinity,
    maxFreeSockets: 256,
    scheduling: 'lifo',
    maxTotalSockets: Infinity,
    totalSocketCount: 0,
    maxCachedSessions: 100,
    _sessionCache: { map: {}, list: [] },
    [Symbol(kCapture)]: false
  },
  servername: 'analytics.gatsbyjs.com',
  _agentKey: 'analytics.gatsbyjs.com:443:::::::::::::::::::::'
}
HTTP 1533501: sockets analytics.gatsbyjs.com:443::::::::::::::::::::: 1 1
HTTP 1533501: write ret = true
HTTP 1533501: outgoing message end.

Reproduction Link

https://github.com/gatsbyjs/gatsby/blob/master/packages/create-gatsby/src/tracking.ts

Steps to Reproduce

  1. Follow the steps https://github.com/gatsbyjs/gatsby#-get-up-and-running-in-5-minutes
  2. export NODE_DEBUG=http
  3. npx gatsby telemetry --disable it works by adding to the env export GATSBY_TELEMETRY_DISABLED=1 then ex: gatsby develop

Expected Result

No call to the telemetry API.

The CLI should use this code instead of its own:

trackCli(
type: string | Array<string> = ``,
tags: ITelemetryTagsPayload = {},
opts: ITelemetryOptsPayload = { debounce: false }
): void {
if (!this.isTrackingEnabled()) {
return
}
if (typeof tags.siteHash === `undefined`) {
tags.siteHash = this.siteHash
}
this.captureEvent(type, tags, opts)
}

Actual Result

It's quite funny to see this

$ npx gatsby telemetry --disable

Telemetry collection disabled

HTTP 1532457: call onSocket 0 0
HTTP 1532457: createConnection analytics.gatsbyjs.com:443::::::::::::::::::::: [Object: null prototype] {
  protocol: 'https:',
  slashes: true,
  auth: null,
  host: 'analytics.gatsbyjs.com',
  port: 443,
  hostname: 'analytics.gatsbyjs.com',
  hash: null,
  search: null,
  query: null,
  pathname: '/events',
  path: null,
  href: 'https://analytics.gatsbyjs.com/events',
  method: 'POST',
  headers: [Object: null prototype] {
    'content-type': [ 'application/json' ],
    'user-agent': [ 'create-gatsby:2.5.0' ],
    Accept: [ '*/*' ],
    'Content-Length': [ '260' ],
    'Accept-Encoding': [ 'gzip,deflate' ],
    Connection: [ 'close' ]
  },
  agent: undefined,
  _defaultAgent: Agent {
    _events: [Object: null prototype] {
      free: [Function (anonymous)],
      newListener: [Function: maybeEnableKeylog]
    },
    _eventsCount: 2,
    _maxListeners: undefined,
    defaultPort: 443,
    protocol: 'https:',
    options: [Object: null prototype] { path: null },
    requests: [Object: null prototype] {},
    sockets: [Object: null prototype] {
      'analytics.gatsbyjs.com:443:::::::::::::::::::::': []
    },
    freeSockets: [Object: null prototype] {},
    keepAliveMsecs: 1000,
    keepAlive: false,
    maxSockets: Infinity,
    maxFreeSockets: 256,
    scheduling: 'lifo',
    maxTotalSockets: Infinity,
    totalSocketCount: 0,
    maxCachedSessions: 100,
    _sessionCache: { map: {}, list: [] },
    [Symbol(kCapture)]: false
  },
  servername: 'analytics.gatsbyjs.com',
  _agentKey: 'analytics.gatsbyjs.com:443:::::::::::::::::::::'
}
HTTP 1532457: sockets analytics.gatsbyjs.com:443::::::::::::::::::::: 1 1
HTTP 1532457: write ret = true
HTTP 1532457: outgoing message end.

Environment

System: Ubuntu 20.04LTS
Node 16 + npm 8

Config Flags

NODE_DEBUG=http
GATSBY_TELEMETRY_DISABLED=1

@dhoko dhoko added the type: bug An issue or pull request relating to a bug in Gatsby label Jan 13, 2022
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Jan 13, 2022
@LekoArts LekoArts added topic: cli Related to the Gatsby CLI and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Jan 14, 2022
@LekoArts
Copy link
Contributor

LekoArts commented Jan 14, 2022

Thanks for the report, we'll get it fixed! :)

This was certainly not intentional, sorry for that. We didn't add gatsby-telemetry to create-gatsby to keep it lightweight but missed this portion when reimplementing it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: cli Related to the Gatsby CLI type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants