npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

nuxt-optout

v0.0.3

Published

Forcibly disable sending Nuxt.js telemetry

Downloads

5

Readme

Nuxt Optout

Forcibly opt-out of sending any telemetry about your Nuxt.js project

Why this package?

Since v2.13 Nuxt.js includes a telemetry module which reports anonymized data about your usage.

You can have multiple reasons why you want to make sure you dont share any info, for example

  • You are bound to a NDA and don't want to test if the data that is sent by Nuxt.js is considered a breach of that NDA or not
  • You don't want to share the crazy stuff you do in your Nuxt.js project
  • You just really like your privacy

Whatever reason you have, if you want to make as sure as possible that you are not sending any telemetry then you can use this module

Should I use this package?

Probably not.

The Nuxt.js core-team takes privacy already very seriously, this is shown because f.e. we ask users to explicitly opt-in instead of requiring users to opt-out. We explicitly choose to make it as easy as possible for users to opt-out of sending telemetry.

We are fully aware of any privacy issues that may arise from embedding telemetry. Including telemetry is somewhat of a necessary evil, we simply can't deny that to spent our time most efficiently we need to know how people are using Nuxt.js. Otherwise we risk spending weeks of our time developping a new feature which will then only be used by a small fraction of all Nuxt.js users.

So we kindly ask you to enable telemetry whenever possible. Having you send us anonymous telemetry helps us greatly with knowing which parts of Nuxt.js deserves the most attention. Also because it gives us some assurance that we are also collecting feedback from people who are not active on Github or Discord.

See the @nuxt/telemetry readme for more information

Why this package when I can also just opt-out of telemetry in my nuxt.config?

Bugs exists, also in Nuxt.js. Although every bug can be fixed, that could still mean that telemetry have been sent in the mean time.

This package could be used (and should only be used) in cases were that is a concern

How does this package work?

Do not trust this package to work flawlessly. Also make sure to set telemetry: false in your nuxt.config to tell nuxt/telemetry you want to opt-out

Using a Yarn resolution

Only works when you are using yarn as package manager and could still sent telemetry if you use npm by mistake

If you only use yarn you can add a resolution entry in your package.json. The default export of this package is a noop function that does nothing:

// package.json
  resolutions: {
    "@nuxt/telemetry": "npm:nuxt-optout"
  }

Patching the installed @nuxt/telemetry package

The telemetry in Nuxt.js are injected into your project as a nuxt module.

Due to how modules work in Nuxt, this package should preferably be run before Nuxt.js is started. You can do this by either:

  • export an async function in your nuxt.config.js and call this package in it
// nuxt.config.js
import nuxtOptout from 'nuxt-optout'

export default async function() {
  await nuxtOptout()

  return {
    mode: 'universal',
    ...
  }
}
  • adding pre lifecycle events to your package.json
// package.json
...
  scripts: {
    "predev": "nuxt-optout",
    "prebuild": "nuxt-optout",
    "prestart": "nuxt-optout",
    "dev": "nuxt src",
    "build": "nuxt build src",
    "start": "nuxt start src",
  }
  • executing nuxt(-ts)?-optout instead of nuxt(-ts)?
// package.json
...
  scripts: {
    "dev": "nuxt-optout src",
    "build": "nuxt-optout build src",
    "start": "nuxt-optout start src",
    // or
    "dev": "nuxt-ts-optout src",
  }

This package then does three things:

  • it moves @nuxt/telemetry/package.json to @nuxt/telemetry/package.disabled.json so getPKG will return false
  • it overwrites the main entrypoint of the @nuxt/telemetry module with a noop function
    • This means there could still be a @nuxt/telemetry module loaded in your project, it just wouldn't do anything
  • when used as alternative Nuxt.js executable, it runs the real nuxt executable but always adds two environment variables which are used by @nuxt/telemetry
    • Disable telemetry by setting: NUXT_TELEMETRY_DISABLED=true
    • Set the telemetry endpoint to localhost: NUXT_TELEMETRY_ENDPOINT='http://127.0.0.1'

How can you guarantee that this package will always opt-out of telemetry?

To be totally honest, I can't as also this package could contain bugs.

As mentioned, despite using this package you should still tell nuxt/telemetry you want to opt-out by setting telemetry: false in your nuxt.config

What can I do to be even more sure?

Note that this solution is often not portable between computers and/or networks

The telemetry are send to https://telemetry.nuxtjs.com. You can add this domain to eg your host file or PiHole blocklist and have it point to localhost instead.