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

feat: add configuration option to disable CLI telemetry #12128

Open
wants to merge 1 commit into
base: next
Choose a base branch
from

Conversation

ascorbic
Copy link
Contributor

@ascorbic ascorbic commented Oct 4, 2024

Changes

This change adds a new configuration option to disable telemetry for the project.

Fixes #11820

Testing

Adds tests

Docs

Adds a config option

Copy link

changeset-bot bot commented Oct 4, 2024

🦋 Changeset detected

Latest commit: f690a58

The changes in this PR will be included in the next version bump.

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@github-actions github-actions bot added pkg: astro Related to the core `astro` package (scope) docs pr semver: minor Change triggers a `minor` release labels Oct 4, 2024
Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR is blocked because it contains a minor changeset. A reviewer will merge this at the next release if approved.

@bluwy
Copy link
Member

bluwy commented Oct 5, 2024

Wouldn't this config option still has the caveat mentioned at #11820 (comment) (and the telemetry is disabled later than the process.env.ASTRO_TELEMETRY_DISABLED = '1' solution)?

The absolute solution would be what Matthew suggested or a new CLI flag (which isn't exactly the cleanest either). I can't think of a cleaner way around this 🤔

@ascorbic
Copy link
Contributor Author

ascorbic commented Oct 5, 2024

From what I can see, the only problem is the notification that it prints about use of telemetry. There's nothing that logs before the config is loaded. Perhaps if we immediately printed that telemetry is disabled for this site that would be ok.

import { defineConfig } from 'astro/config';

export default defineConfig({
disableTelemetry: true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be nicer to have telemetry: boolean, defaulting to true

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I didn;t go with that is because it might imply that it overrides the global setting

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because telemetry starts before the config?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I mean that naming it like that might make users thing that true would override their global values, but actually true would mean "true unless there's a global override or environment variable to disable it".

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mmm i see. I think I'd still prefer telemetry: boolean but log a warning if there's a mismatch with a global override

@bluwy
Copy link
Member

bluwy commented Oct 7, 2024

From what I can see, the only problem is the notification that it prints about use of telemetry. There's nothing that logs before the config is loaded. Perhaps if we immediately printed that telemetry is disabled for this site that would be ok.

I think you're right. Looks like the places where we call telemetry.record() often happens after the config has been loaded, so maybe we should only print out the telemetry notice on the first record?

However there's an edge case here where we possibly can't based on the config to determine that:

telemetryPromise = telemetry.record(eventError({ cmd, err: errorWithMetadata, isFatal: true }));

If we can figure out how to log the telemetry state correctly, and always respect the config, then that would be the best I think.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs pr pkg: astro Related to the core `astro` package (scope) semver: minor Change triggers a `minor` release
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants