Skip to content
This repository has been archived by the owner on Oct 21, 2024. It is now read-only.

Commit

Permalink
feat: disable telemetry with env var from v2 (#1152)
Browse files Browse the repository at this point in the history
* feat: disable telemetry with env var from v2

* feat: disable telemetry with DO_NOT_TRACK
  • Loading branch information
sebws authored Oct 7, 2024
1 parent 896d019 commit da4a173
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
2 changes: 2 additions & 0 deletions cmd/sst/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -947,6 +947,8 @@ var root = &cli.Command{
"- General machine information, like the number of CPUs, OS, CI/CD environment, etc.",
"",
"This is completely optional and can be disabled at any time.",
"",
"You can also opt-out by setting an environment variable: `SST_TELEMETRY_DISABLED=1` or `DO_NOT_TRACK=1`.",
}, "\n"),
},
Children: []*cli.Command{
Expand Down
1 change: 1 addition & 0 deletions pkg/flag/flag.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,5 @@ var SST_PULUMI_PATH = os.Getenv("SST_PULUMI_PATH")
var SST_PRINT_LOGS = os.Getenv("SST_PRINT_LOGS") != ""
var SST_BUILD_CONCURRENCY = os.Getenv("SST_BUILD_CONCURRENCY")
var SST_SKIP_DEPENDENCY_CHECK = os.Getenv("SST_SKIP_DEPENDENCY_CHECK") != ""
var SST_TELEMETRY_DISABLED = os.Getenv("SST_TELEMETRY_DISABLED") == "1" || os.Getenv("DO_NOT_TRACK") == "1"
var NO_BUN = os.Getenv("NO_BUN") != ""
3 changes: 2 additions & 1 deletion pkg/telemetry/telemetry.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"github.com/posthog/posthog-go"
"github.com/sst/ion/internal/fs"
"github.com/sst/ion/internal/util"
"github.com/sst/ion/pkg/flag"
"github.com/sst/ion/pkg/global"
)

Expand All @@ -38,7 +39,7 @@ func Enable() error {
func IsEnabled() bool {
path := filepath.Join(global.ConfigDir(), TELEMETRY_DISABLED_KEY)
_, err := os.Stat(path)
return os.IsNotExist(err)
return os.IsNotExist(err) && !flag.SST_TELEMETRY_DISABLED
}

// detectCI attempts to detect the CI environment and returns its name if detected, empty string otherwise.
Expand Down

0 comments on commit da4a173

Please sign in to comment.