Next.js: Telemetry needs to be disabled without voodoo

Created on 27 Feb 2020  路  5Comments  路  Source: vercel/next.js

Bug report

We do not want to have telemetry enabled when performing a next build inside a docker container in our build pipeline. It seems like the npx command described in the documentation does not work here. Also its very opaque _what_ that command actually does and where the information that no telemetry is desired is actually stored.

It should be possible to disable telemetry by passing a flag to npm run build instead of executing a npx command beforehand.

Describe the bug

Inside our dockerfile, we try to disable telemetry, then performing the build:

...
# We do not want to be tracked
RUN npx next telemetry disable

# Building app
RUN npm run build
...

According to our pipeline logs, telemetry seems to be re-enabled when the actual build is performed:

Step 13/25 : RUN npx next telemetry disable
 ---> Running in 3cee707075fa
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry

Your preference has been saved.

Status: Disabled

You have opted-out of Next.js' anonymous telemetry program.
No data will be collected from your machine.
Learn more: https://nextjs.org/telemetry

Removing intermediate container 3cee707075fa
 ---> f765f98e92b1
Step 14/25 : RUN npm run build
 ---> Running in 0c0c4f9963b2

> [email protected] build /app
> cross-env NODE_ICU_DATA=node_modules/full-icu next build

Creating an optimized production build...
Attention: Next.js now collects completely anonymous telemetry regarding usage.
This information is used to shape Next.js' roadmap and prioritize features.
You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
https://nextjs.org/telemetry

To Reproduce

Try disabling telemetry and then build inside a docker container.

Expected behavior

I expected telemetry to be disabled.

System information

Most helpful comment

According to the doc:

You may also opt-out by setting an environment variable: NEXT_TELEMETRY_DISABLED=1.

Personally I'd prefer there to be a property in next.config.js.

All 5 comments

Also related to this issue is my comment from another issue:

https://github.com/zeit/next.js/issues/8851#issuecomment-591710955

According to the doc:

You may also opt-out by setting an environment variable: NEXT_TELEMETRY_DISABLED=1.

Personally I'd prefer there to be a property in next.config.js.

You can add the environment variable NEXT_TELEMETRY_DISABLED=1 as per the documentation.

The command writes a file into the home directory, I guess in docker that's not preserved in between steps 馃

Try to add the env var in your Dockerfile: ENV NEXT_TELEMETRY_DISABLED 1

Closing this as the npx next telemetry disable command is to disable collection system-wide, meaning for all Next.js projects a user works on.
Viewing your docker logs, you are throwing away the intermediate container which is why the setting is being lost.


To disable this in your Dockerfile, you can add the following line for each of your build stages:

ENV NEXT_TELEMETRY_DISABLED 1
Was this page helpful?
0 / 5 - 0 ratings

Related issues

timneutkens picture timneutkens  路  3Comments

lixiaoyan picture lixiaoyan  路  3Comments

havefive picture havefive  路  3Comments

olifante picture olifante  路  3Comments

ghost picture ghost  路  3Comments