From 9be270e13d4888fe3319711bc24b279735ec5afc Mon Sep 17 00:00:00 2001 From: Gary Holtz Date: Tue, 13 May 2025 16:02:09 -0500 Subject: [PATCH 1/5] feat(usage-ping): Add configuration option to opt out of usage data --- README.md | 1 + internal/config/config.yaml.lock | 4 ++++ internal/config/config_mapping.go | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/README.md b/README.md index 44cb46fd0..c90476af5 100644 --- a/README.md +++ b/README.md @@ -298,6 +298,7 @@ self-signed certificate authorities by making either of these changes: | `GLAB_CONFIG_DIR` | - | `~/.config/glab-cli/` | Directory where the `glab` global configuration file is located. Can be set in the config with `glab config set remote_alias origin`. | | `BROWSER` | `browser` | system default | The web browser to use for opening links. Can be set in the configuration with `glab config set browser mybrowser`. | | `FORCE_HYPERLINKS` | `display_hyperlinks` | `false` | Set to `1` to force hyperlinks to be output, even when not outputting to a TTY. | +| `GLAB_DONT_SEND_USAGE_DATA` | `dont_send_usage_data` | `false` | Set to `1` to prevent command usage data from being sent to your GitLab instance. | | `GLAMOUR_STYLE` | `glamour_style` | `dark` | Environment variable to set your desired Markdown renderer style. Available options are (`dark`, `light`, `notty`) or set a [custom style](https://github.com/charmbracelet/glamour#styles). | | `NO_COLOR` | - | `true` | Set to any value to avoid printing ANSI escape sequences for color output. | | `VISUAL`, `EDITOR` | `editor` | `nano` | (in order of precedence) The editor tool to use for authoring text. Can be set in the config with `glab config set editor vim`. | diff --git a/internal/config/config.yaml.lock b/internal/config/config.yaml.lock index f79467995..88ce83033 100644 --- a/internal/config/config.yaml.lock +++ b/internal/config/config.yaml.lock @@ -16,6 +16,10 @@ display_hyperlinks: false host: gitlab.com # Set to true (1) to disable prompts, or false (0) to enable them. no_prompt: false +# Set to true (1) to disable sending usage data to GitLab or false (0) to enable. +# See https://docs.gitlab.com/administration/settings/usage_statistics/ +# for more information +dont_send_usage_data: false # Configuration specific for GitLab instances. hosts: gitlab.com: diff --git a/internal/config/config_mapping.go b/internal/config/config_mapping.go index 98a0750a3..d7eec7516 100644 --- a/internal/config/config_mapping.go +++ b/internal/config/config_mapping.go @@ -17,6 +17,8 @@ func ConfigKeyEquivalence(key string) string { return "token" case "no_prompt", "prompt_disabled": return "no_prompt" + case "dont_send_usage_data": + return "dont_send_usage_data" case "git_remote_url_var", "git_remote_alias", "remote_alias", "remote_nickname", "git_remote_nickname": return "remote_alias" case "editor", "visual", "glab_editor": @@ -41,6 +43,8 @@ func EnvKeyEquivalence(key string) []string { return []string{"GITLAB_TOKEN", "GITLAB_ACCESS_TOKEN", "OAUTH_TOKEN"} case "no_prompt": return []string{"NO_PROMPT", "PROMPT_DISABLED"} + case "dont_send_usage_data": + return []string{"GLAB_DONT_SEND_USAGE_DATA"} case "editor", "visual", "glab_editor": return []string{"GLAB_EDITOR", "VISUAL", "EDITOR"} case "remote_alias": -- GitLab From 3bafe0538d0c5b6705cf80593394ef3337692796 Mon Sep 17 00:00:00 2001 From: Gary Holtz Date: Wed, 14 May 2025 15:20:21 -0500 Subject: [PATCH 2/5] Update telemetry name/defaults --- README.md | 2 +- commands/root.go | 4 ++++ internal/config/config.yaml.lock | 4 ++-- internal/config/config_mapping.go | 8 ++++---- 4 files changed, 11 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index c90476af5..e07fdc033 100644 --- a/README.md +++ b/README.md @@ -298,7 +298,7 @@ self-signed certificate authorities by making either of these changes: | `GLAB_CONFIG_DIR` | - | `~/.config/glab-cli/` | Directory where the `glab` global configuration file is located. Can be set in the config with `glab config set remote_alias origin`. | | `BROWSER` | `browser` | system default | The web browser to use for opening links. Can be set in the configuration with `glab config set browser mybrowser`. | | `FORCE_HYPERLINKS` | `display_hyperlinks` | `false` | Set to `1` to force hyperlinks to be output, even when not outputting to a TTY. | -| `GLAB_DONT_SEND_USAGE_DATA` | `dont_send_usage_data` | `false` | Set to `1` to prevent command usage data from being sent to your GitLab instance. | +| `GLAB_SEND_TELEMETRY` | `telemetry` | `true` | Set to `0` to prevent command usage data from being sent to your GitLab instance. | | `GLAMOUR_STYLE` | `glamour_style` | `dark` | Environment variable to set your desired Markdown renderer style. Available options are (`dark`, `light`, `notty`) or set a [custom style](https://github.com/charmbracelet/glamour#styles). | | `NO_COLOR` | - | `true` | Set to any value to avoid printing ANSI escape sequences for color output. | | `VISUAL`, `EDITOR` | `editor` | `nano` | (in order of precedence) The editor tool to use for authoring text. Can be set in the config with `glab config set editor vim`. | diff --git a/commands/root.go b/commands/root.go index f2396c814..f11d0b2f4 100644 --- a/commands/root.go +++ b/commands/root.go @@ -70,6 +70,10 @@ func NewCmdRoot(f *cmdutils.Factory, version, commit string) *cobra.Command { GLAB_CHECK_UPDATE: Set to 1 or true to force an update check. By default the cli tool checks for updates once a day. + GLAB_SEND_TELEMETRY: Set to 0 or false to disable telemetry being sent to your GitLab instance. + Can be set in the config with 'glab config set telemetry false'. + See https://docs.gitlab.com/administration/settings/usage_statistics/ for more information + GLAB_CONFIG_DIR: Set to a directory path to override the global configuration location. GLAMOUR_STYLE: The environment variable to set your desired Markdown renderer style. diff --git a/internal/config/config.yaml.lock b/internal/config/config.yaml.lock index 88ce83033..4bef28ca5 100644 --- a/internal/config/config.yaml.lock +++ b/internal/config/config.yaml.lock @@ -16,10 +16,10 @@ display_hyperlinks: false host: gitlab.com # Set to true (1) to disable prompts, or false (0) to enable them. no_prompt: false -# Set to true (1) to disable sending usage data to GitLab or false (0) to enable. +# Set to false (0) to disable sending usage data to GitLab or true (1) to enable. # See https://docs.gitlab.com/administration/settings/usage_statistics/ # for more information -dont_send_usage_data: false +telemetry: true # Configuration specific for GitLab instances. hosts: gitlab.com: diff --git a/internal/config/config_mapping.go b/internal/config/config_mapping.go index d7eec7516..ee26cc6ef 100644 --- a/internal/config/config_mapping.go +++ b/internal/config/config_mapping.go @@ -17,8 +17,8 @@ func ConfigKeyEquivalence(key string) string { return "token" case "no_prompt", "prompt_disabled": return "no_prompt" - case "dont_send_usage_data": - return "dont_send_usage_data" + case "telemetry": + return "telemetry" case "git_remote_url_var", "git_remote_alias", "remote_alias", "remote_nickname", "git_remote_nickname": return "remote_alias" case "editor", "visual", "glab_editor": @@ -43,8 +43,8 @@ func EnvKeyEquivalence(key string) []string { return []string{"GITLAB_TOKEN", "GITLAB_ACCESS_TOKEN", "OAUTH_TOKEN"} case "no_prompt": return []string{"NO_PROMPT", "PROMPT_DISABLED"} - case "dont_send_usage_data": - return []string{"GLAB_DONT_SEND_USAGE_DATA"} + case "telemetry": + return []string{"GLAB_SEND_TELEMETRY"} case "editor", "visual", "glab_editor": return []string{"GLAB_EDITOR", "VISUAL", "EDITOR"} case "remote_alias": -- GitLab From bbae06fe3a4aefde7a71bf33d82ca644ae4cb8b1 Mon Sep 17 00:00:00 2001 From: Gary Holtz Date: Thu, 15 May 2025 15:31:32 -0500 Subject: [PATCH 3/5] Updating stub test --- internal/config/config_stub.go | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/internal/config/config_stub.go b/internal/config/config_stub.go index a430df68e..97351254c 100644 --- a/internal/config/config_stub.go +++ b/internal/config/config_stub.go @@ -95,6 +95,15 @@ func rootConfig() *yaml.Node { Kind: yaml.ScalarNode, Value: "false", }, + { + HeadComment: "# Set to false (0) to disable sending usage data to GitLab or true (1) to enable.\n# See https://docs.gitlab.com/administration/settings/usage_statistics/\n# for more information", + Kind: yaml.ScalarNode, + Value: "telemetry", + }, + { + Kind: yaml.ScalarNode, + Value: "true", + }, { HeadComment: "# Configuration specific for GitLab instances.", Kind: yaml.ScalarNode, -- GitLab From 5506580fcbf84660f9e01be3312f4ee4b9812454 Mon Sep 17 00:00:00 2001 From: Gary Holtz Date: Thu, 22 May 2025 09:10:00 -0500 Subject: [PATCH 4/5] chore: Apply 1 suggestion(s) to 1 file(s) Co-authored-by: Jay McCure --- internal/config/config.yaml.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/config/config.yaml.lock b/internal/config/config.yaml.lock index 4bef28ca5..fec79f59d 100644 --- a/internal/config/config.yaml.lock +++ b/internal/config/config.yaml.lock @@ -16,7 +16,7 @@ display_hyperlinks: false host: gitlab.com # Set to true (1) to disable prompts, or false (0) to enable them. no_prompt: false -# Set to false (0) to disable sending usage data to GitLab or true (1) to enable. +# Set to false (0) to disable sending usage data to your GitLab instance or true (1) to enable. # See https://docs.gitlab.com/administration/settings/usage_statistics/ # for more information telemetry: true -- GitLab From a9ba0e96907af701e3bc602204d423357105715f Mon Sep 17 00:00:00 2001 From: Gary Holtz Date: Thu, 22 May 2025 16:08:00 -0500 Subject: [PATCH 5/5] Correcting test stub as well --- internal/config/config_stub.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/config/config_stub.go b/internal/config/config_stub.go index 97351254c..7f8d48476 100644 --- a/internal/config/config_stub.go +++ b/internal/config/config_stub.go @@ -96,7 +96,7 @@ func rootConfig() *yaml.Node { Value: "false", }, { - HeadComment: "# Set to false (0) to disable sending usage data to GitLab or true (1) to enable.\n# See https://docs.gitlab.com/administration/settings/usage_statistics/\n# for more information", + HeadComment: "# Set to false (0) to disable sending usage data to your GitLab instance or true (1) to enable.\n# See https://docs.gitlab.com/administration/settings/usage_statistics/\n# for more information", Kind: yaml.ScalarNode, Value: "telemetry", }, -- GitLab