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

How to disable nextjs telemetry? #8851

Closed
popuguytheparrot opened this issue Sep 25, 2019 · 16 comments
Closed

How to disable nextjs telemetry? #8851

popuguytheparrot opened this issue Sep 25, 2019 · 16 comments

Comments

@popuguytheparrot
Copy link
Contributor

How to disable nextjs telemetry ? I dont want it in my apps

@sorleone
Copy link

npx next telemetry --disable

@popuguytheparrot
Copy link
Contributor Author

https://nextjs.org/telemetry

I just now find this page

@quyse
Copy link

quyse commented Jan 15, 2020

npx next telemetry --disable

Apparently this only disables telemetry on the current machine (by writing config to ~/.config/nextjs-nodejs/config.json).

@nlevchuk
Copy link

nlevchuk commented Feb 8, 2020

According to https://nextjs.org/telemetry I have the following options to disable telemetry:

  1. Runnpx next telemetry disable every time in production which is not convenient
  2. Set NEXT_TELEMETRY_DISABLED=1 variable (seems it doesn't work for me)

Why wouldn't put something like telemetry: false line to next.config.json file? It's better place for the option

@Paratron
Copy link

This whole telemetry thing is pretty twisted to be honest.

For starters: its crazy opaque. You should definitely ask for consent beforehands. Upon the first dev or build execution of a project, just ASK if its fine to collect that data. Its crazy that I even need to suggest such a behaviour.

Second: Its absolutely against all conventions how this needs to be disabled. I never encountered a project that would need a dev to run an npx command which does unknown voodoo on my machine to disable something in my current project. The command does not run when react has not been installed in the current project. Whut?!

The recently added ENV var option seems to work for me, but its only mentioned in a single line at the very bottom of a long page trying to sell telemetry to me and then telling me how to use that npx stuff to disable it.

The ENV var way should be communicated FIRST, since its project related. The npx way may be communicated afterwards since its a global setting.

Also, I agree with nlevchuk - this should definitely go to next.config - otherwise you just spill possible options across several places, some are in the config file, some need to be passed as env vars - thats just confusing.

@timneutkens
Copy link
Member

Telemetry has been discussed in-depth on the RFC and there is a lot of prior art: #8442

@MatthewHerbst
Copy link

MatthewHerbst commented Feb 28, 2020

@timneutkens I don't see any mention of including a telemetry: false type flag in the config file in the prior discussions. Do you know if that has been discussed somewhere?

@xaphod
Copy link

xaphod commented Mar 13, 2020

Neither the npx nor the environment variable routes seem to work for disabling telemetry on Firebase (firebase functions). How to disable telemetry on firebase?

@exbotanical
Copy link

exbotanical commented Jun 12, 2020

Has a feature request been submitted for disabling telemetry via the next config file? I feel this is the most straightforward and sensible solution; preceding comments seem to support this sentiment. I don't mind writing up an RFC if this hasn't been addressed.

@dwidc
Copy link

dwidc commented Jul 17, 2020

Other than user's config.json and environment variable, you can also disable telemetry by either:

  • Block telemetry in firewall.
    Just block telemetry.nextjs.org in your hosts or iptables.

  • Use patch-package to disable nextjs telemetry postPayload() method.


If you want to use patch-package:

  • Open /node_modules/next/dist/telemetry/post-payload.js.
    Note that this is a compiled js. It's one concatenated long line.

  • Replace:

exports._postPayload=_postPayload;

with

exports._postPayload=function(){};
  • Run npx patch-package next. It will create a patch file in /patches folder.

In my case it creates next+9.4.4.patch with the following content:

diff --git a/node_modules/next/dist/telemetry/post-payload.js b/node_modules/next/dist/telemetry/post-payload.js
index 6b3e5d1..fc2e15c 100644
--- a/node_modules/next/dist/telemetry/post-payload.js
+++ b/node_modules/next/dist/telemetry/post-payload.js
@@ -1,4 +1,4 @@
-"use strict";exports.__esModule=true;exports._postPayload=_postPayload;var _asyncRetry=_interopRequireDefault(require("next/dist/compiled/async-retry"));var _nodeFetch=_interopRequireDefault(require("next/dist/compiled/node-fetch"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _postPayload(endpoint,body){return(0,_asyncRetry.default)(()=>(0,_nodeFetch.default)(endpoint,{method:'POST',body:JSON.stringify(body),headers:{'content-type':'application/json'},timeout:5000}).then(res=>{if(!res.ok){const err=new Error(res.statusText);err.response=res;throw err;}}),{minTimeout:500,retries:1,factor:1}).catch(()=>{// We swallow errors when telemetry cannot be sent
+"use strict";exports.__esModule=true;exports._postPayload=function(){};var _asyncRetry=_interopRequireDefault(require("next/dist/compiled/async-retry"));var _nodeFetch=_interopRequireDefault(require("next/dist/compiled/node-fetch"));function _interopRequireDefault(obj){return obj&&obj.__esModule?obj:{default:obj};}function _postPayload(endpoint,body){return(0,_asyncRetry.default)(()=>(0,_nodeFetch.default)(endpoint,{method:'POST',body:JSON.stringify(body),headers:{'content-type':'application/json'},timeout:5000}).then(res=>{if(!res.ok){const err=new Error(res.statusText);err.response=res;throw err;}}),{minTimeout:500,retries:1,factor:1}).catch(()=>{// We swallow errors when telemetry cannot be sent
 })// Ensure promise is voided
 .then(()=>{},()=>{});}
 //# sourceMappingURL=post-payload.js.map
\ No newline at end of file

The patch-package solution only disable sending telemetry. The telemetry itself is still created and stored somewhere in your machine.
It's just temporary solution until we can disable telemetry by project's local next.config.json or something.

@Aeolun
Copy link

Aeolun commented Oct 16, 2020

@timneutkens I dunno, but the time frame from RFC to 'merged' in #8442 was literally 7 days. I don't really think any comments were taken into consideration.

I didn't know that next.js was sending anything out until I randomly saw these messages in the build logs. This should be more prominent and very likely OPT-IN instead of opt out.

@isaachinman
Copy link
Contributor

While I do understand there being a good argument to be made for opt-out-by-default, I strongly feel as though the current procedure of disabling per machine via npx is fundamentally disrespectful to Next's users.

This should be a boolean in next.config.js.

For anyone seeking an actual way to disable telemetry per project, something along these lines is as good as it's going to get for now:

"postinstall": "npx next telemetry disable"

@Zion-AppDev
Copy link

This reflects very badly on Vercel. I would be very skeptical about trying their other products. As others mentioned it should be opt-out rather than opt-in. I had to search online for solutions to disable it. And yet, I can only disable this per project?

Which ever genius thought about this is shady as f*ck!

I will be looking for other solutions. Whats next after "NextJS"?

@mercuriete
Copy link

in my case I did: (using yarn)

package.json

    "prepare": "next telemetry disable"

thanks @isaachinman

Please reopen this issue
tememetry SHOULD be and opt IN not an opt OUT.

@opiation
Copy link

I requested the feature of disabling telemetry via a version-controllable next.config.json in #31360 which was closed shortly thereafter and moved to discussion #31400. Sharing this in case interested parties in this thread want voice their concerns there or upvote.

@balazsorban44
Copy link
Member

This issue has been automatically locked due to no recent activity. If you are running into a similar issue, please create a new issue with the steps to reproduce. Thank you.

@vercel vercel locked as resolved and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests