telemetry icon indicating copy to clipboard operation
telemetry copied to clipboard

Type Error when setting `telemetry: false` in `nuxt.config.ts` within Monorepo

Open samydoesit opened this issue 1 year ago • 3 comments

We are encountering a type error in our monorepo setup when setting telemetry: false in the nuxt.config.ts file.

Error Details:

When telemetry: false is added to the configuration, we see the following error:

Type 'false' has no properties in common with type 'Partial<TelemetryOptions>'.(2559)
schema.d.ts(21, 5): The expected type comes from property 'telemetry' which is declared here on type 'InputConfig<NuxtConfig, ConfigLayerMeta>'
(property) NuxtConfig["telemetry"]?: Partial<TelemetryOptions> | undefined

This issue persists in our monorepo even after running nuxt prepare. However, I was able to reproduce this with a fresh Nuxt project on Stackblitz, but the error appears only on the first run. Once the nuxt prepare step is ran a second time in Stackblitz, the error no longer occurs.

Steps to Reproduce:

  1. Open a new Nuxt project on Stackblitz using this link: https://nuxt.new/s/v3
  2. Stop the dev server.
  3. In the nuxt.config.ts, add telemetry: false,.
  4. Observe the Nuxt error that appears.

Additional Notes:

In the monorepo, the error persists despite running nuxt prepare multiple times.

https://github.com/user-attachments/assets/e2c2943d-6ea5-4eec-803a-d228fc0f6f1b

samydoesit avatar Sep 18 '24 12:09 samydoesit

Looks like this was removed on the nuxt 3 migration https://github.com/nuxt/telemetry/commit/584b7fede5e7456222be729ebc66ca5d2a36e87e

Image

Although it still works (for compatibility i believe) it is not typed, the correct would be using the TelemetryOptions from types.d:

export interface TelemetryOptions {
  debug: boolean
  endpoint: string
  seed: string
  consent?: number
  enabled: boolean
}

So instead of telemetry: false in your nuxt.config use telemetry: { enabled: false } would fix this issue.

@danielroe @pi0 i believe this is just a documentation issue, it is okay for you guys for me to fix the mds or do you would want to work around having the telemetry: false to work with ts types?

schirrel avatar Jan 28 '25 11:01 schirrel

We have a few modules that take a boolean to enable/disable, including pages (which is an internal ad-hoc module).

I think we should think about how best to make this possible.

I think the key thing stopping this from being valid is:

https://github.com/nuxt/nuxt/blob/7e72e06603214f66bbc3a151c576d3dd1e18e836/packages/schema/src/types/module.ts#L28

danielroe avatar Jan 28 '25 22:01 danielroe

Looks like then that the boolean to enable/disable is more internal then external use and typed.... So i believe that instead of trying to change the inner code, the better solution is: on ts project use telemetry: { enabled: false }

them update the docs

schirrel avatar Jan 29 '25 14:01 schirrel

Per what @schirrel said, can the doc just be updated to say how to disable it in the "Opt out" section then?

KyleBrown-804 avatar Jul 26 '25 19:07 KyleBrown-804

It looks like this is adressed by https://github.com/nuxt/telemetry/pull/298.

samydoesit avatar Aug 08 '25 23:08 samydoesit