diff options
author | 2023-09-20 19:13:31 +0200 | |
---|---|---|
committer | 2023-09-20 10:13:31 -0700 | |
commit | aa3355dc823b9166c162094bad55c90bf15d144c (patch) | |
tree | 4de695e6966a439ef0736795b15408b1e452c157 | |
parent | 8c612adcdb04cdc71a464c9a8df4bd871eaffc7d (diff) | |
download | bun-aa3355dc823b9166c162094bad55c90bf15d144c.tar.gz bun-aa3355dc823b9166c162094bad55c90bf15d144c.tar.zst bun-aa3355dc823b9166c162094bad55c90bf15d144c.zip |
feat: switch disableTelemetry to bunfig (#5690)
* feat: switch disableTelemetry to bunfig
* feat: zig fmt
* revert: the env variable and invert the logic of telemetry
---------
Co-authored-by: MrPalixir <73360179+MrPalixir@users.noreply.github.com>
-rw-r--r-- | docs/runtime/bunfig.md | 8 | ||||
-rw-r--r-- | docs/runtime/env.md | 2 | ||||
-rw-r--r-- | src/bunfig.zig | 5 |
3 files changed, 14 insertions, 1 deletions
diff --git a/docs/runtime/bunfig.md b/docs/runtime/bunfig.md index 3db6965f5..52ffcec11 100644 --- a/docs/runtime/bunfig.md +++ b/docs/runtime/bunfig.md @@ -100,6 +100,14 @@ Bun supports the following loaders: - `dataurl` - `text` +### `telemetry` + +The `telemetry` field permit to enable/disable the analytics records. Bun records bundle timings (so we can answer with data, "is Bun getting faster?") and feature usage (e.g., "are people actually using macros?"). The request body size is about 60 bytes, so it's not a lot of data. By default the telemetry is enabled. Equivalent of `DO_NOT_TRACK` env variable. + +```toml +telemetry = false +``` + ## Test runner The test runner is configured under the `[test]` section of your bunfig.toml. diff --git a/docs/runtime/env.md b/docs/runtime/env.md index 2e9205544..fe4cc357d 100644 --- a/docs/runtime/env.md +++ b/docs/runtime/env.md @@ -79,6 +79,6 @@ These environment variables are read by Bun and configure aspects of its behavio --- - `DO_NOT_TRACK` -- If `DO_NOT_TRACK=1`, then analytics are [disabled](https://do-not-track.dev/). Bun records bundle timings (so we can answer with data, "is Bun getting faster?") and feature usage (e.g., "are people actually using macros?"). The request body size is about 60 bytes, so it's not a lot of data. +- If `DO_NOT_TRACK=1`, then analytics are [disabled](https://do-not-track.dev/). Bun records bundle timings (so we can answer with data, "is Bun getting faster?") and feature usage (e.g., "are people actually using macros?"). The request body size is about 60 bytes, so it's not a lot of data. Equivalent of `telemetry=false` in bunfig. {% /table %} diff --git a/src/bunfig.zig b/src/bunfig.zig index 63a6c389d..a777475da 100644 --- a/src/bunfig.zig +++ b/src/bunfig.zig @@ -216,6 +216,11 @@ pub const Bunfig = struct { if (json.get("preload")) |expr| { try this.loadPreload(allocator, expr); } + + if (json.get("telemetry")) |expr| { + try this.expect(expr, .e_boolean); + Analytics.disabled = !expr.data.e_boolean.value; + } } if (comptime cmd == .RunCommand or cmd == .AutoCommand) { |