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

There's no way to disable and persist telemetry per project #11820

Open
1 task
flaviovs opened this issue Aug 22, 2024 · 6 comments
Open
1 task

There's no way to disable and persist telemetry per project #11820

flaviovs opened this issue Aug 22, 2024 · 6 comments
Labels
- P2: nice to have Not breaking anything but nice to have (priority)

Comments

@flaviovs
Copy link

Astro Info

Astro                    v4.14.4
Node                     v18.19.0
System                   Linux (x64)
Package Manager          npm
Output                   static
Adapter                  none

If this issue only occurs in one browser, which browser is a problem?

n/a

Describe the Bug

According to https://astro.build/telemetry/:

You can always opt-out by running astro telemetry disable in the root of any Astro project directory. This will disable telemetry across your entire machine, not just the project directory that you run it in

Also:

You can also opt-out by setting the environment variable: ASTRO_TELEMETRY_DISABLED=1

The above requires every developer to change their local environment to disable telemetry before running the CLI, which is problematic for compliance and/or privacy reasons for some orgs in regulated sectors.

What's the expected result?

A setting in the SCM-managed config file to disable telemetry for that specific project, so new developers and/or scripts checking out the code don't break an org's regulations because they forgot to set up their local machines.

Link to Minimal Reproducible Example

n/a

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Aug 22, 2024
@matthewp
Copy link
Contributor

matthewp commented Aug 23, 2024

Can you not do this via npm scripts?

"scripts": {
  "dev": "ASTRO_TELEMETRY_DISABLED=1 astro dev",
  "build": "ASTRO_TELEMETRY_DISABLED=1 astro build",
}

@flaviovs
Copy link
Author

Yes, we can.

However NPM is not the CLI.

The documentation alone tells people to run astro (or npx astro) in many places.

@Fryuni
Copy link
Member

Fryuni commented Aug 23, 2024

You can set it on your config file:

// astro.config.mjs

process.env.ASTRO_TELEMETRY_DISABLED = '1';

export default defineConfig({ ... });

Running with debug shows:

astro:telemetry [record] telemetry has been disabled

@flaviovs
Copy link
Author

That's a great solution, thanks for the tip.

BTW, this is what the CLI shows here, even when telemetry has been disabled using env variables/config change:

$ DEBUG="astro:telemetry" npx astro build
▶ Astro collects anonymous usage data.
  This information helps us improve Astro.
  Run "astro telemetry disable" to opt-out.
  https://astro.build/telemetry

  astro:telemetry [notify] telemetry has been enabled +0ms
  astro:telemetry [record] telemetry has been disabled +1s

I'm okay with that, but just FYI this may still trigger compliance and audit issues in some orgs.

@Fryuni
Copy link
Member

Fryuni commented Aug 24, 2024

Yeah, technically, doing this leaves the telemetry enabled for tracking before the config file is loaded, that is what it notifies that it is enabled first.

But no telemetry is collected before the config is loaded (the relevant information comes from the config), so disabling it there disables all telemetry in Astro. Not a perfect solution, but it is a solution.

@ascorbic ascorbic added - P2: nice to have Not breaking anything but nice to have (priority) and removed needs triage Issue needs to be triaged labels Aug 29, 2024
@bluwy
Copy link
Member

bluwy commented Oct 7, 2024

Another option is to use the "postinstall" script:

"scripts": {
  "postinstall": "astro telemetry disable"
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
- P2: nice to have Not breaking anything but nice to have (priority)
Projects
None yet
Development

No branches or pull requests

5 participants