github.com/tilt-dev/tilt@v0.33.15-0.20240515162809-0a22ed45d8a0/internal/analytics/env.go (about)

     1  package analytics
     2  
     3  import (
     4  	"fmt"
     5  	"os"
     6  )
     7  
     8  var disableAnalyticsEnvVars = []string{
     9  	// Tilt-only analytics disabling
    10  	"TILT_DISABLE_ANALYTICS",
    11  
    12  	// https://consoledonottrack.com/
    13  	"DO_NOT_TRACK",
    14  
    15  	// We care about the number of humans using Tilt, not the number of CI machines
    16  	"CI",
    17  }
    18  
    19  // If analytics is disabled, return a string representing a human-readable reason.
    20  func IsAnalyticsDisabledFromEnv() (bool, string) {
    21  	for _, key := range disableAnalyticsEnvVars {
    22  		val := os.Getenv(key)
    23  		if val != "" {
    24  			return true, fmt.Sprintf("Environment variable %s=%s", key, val)
    25  		}
    26  	}
    27  	return false, ""
    28  }