diff --git a/components/installation-telemetry/cmd/send.go b/components/installation-telemetry/cmd/send.go index 196085ef23ead3..50fe963a6c40ee 100644 --- a/components/installation-telemetry/cmd/send.go +++ b/components/installation-telemetry/cmd/send.go @@ -45,6 +45,11 @@ var sendCmd = &cobra.Command{ return fmt.Errorf("GITPOD_INSTALLATION_VERSION envvar not set") } + platform := os.Getenv("GITPOD_INSTALLATION_PLATFORM") + if platform == "" { + return fmt.Errorf("GITPOD_INSTALLATION_PLATFORM envvar not set") + } + client, err := analytics.NewWithConfig(segmentIOToken, analytics.Config{}) defer func() { err = client.Close() @@ -54,7 +59,8 @@ var sendCmd = &cobra.Command{ Set("version", versionId). Set("totalUsers", data.TotalUsers). Set("totalWorkspaces", data.TotalWorkspaces). - Set("totalInstances", data.TotalInstances) + Set("totalInstances", data.TotalInstances). + Set("platform", platform) if data.InstallationAdmin.Settings.SendCustomerID { properties.Set("customerID", data.CustomerID) diff --git a/gitpod-ws.code-workspace b/gitpod-ws.code-workspace index 6390b05f561833..59b7cdb2e45f09 100644 --- a/gitpod-ws.code-workspace +++ b/gitpod-ws.code-workspace @@ -24,7 +24,8 @@ { "path": "dev/changelog" }, { "path": "dev/gpctl" }, { "path": "dev/loadgen" }, - { "path": "install/installer" } + { "path": "install/installer" }, + { "path": "install/preview" } ], "settings": { "typescript.tsdk": "gitpod/node_modules/typescript/lib", diff --git a/install/installer/pkg/components/gitpod/cronjob.go b/install/installer/pkg/components/gitpod/cronjob.go index dcc5ca53885d69..048b6ea800ae42 100644 --- a/install/installer/pkg/components/gitpod/cronjob.go +++ b/install/installer/pkg/components/gitpod/cronjob.go @@ -9,6 +9,7 @@ import ( "github.com/gitpod-io/gitpod/installer/pkg/common" "github.com/gitpod-io/gitpod/installer/pkg/config/v1" + "github.com/gitpod-io/gitpod/installer/pkg/config/v1/experimental" batchv1 "k8s.io/api/batch/v1" v1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" @@ -21,6 +22,14 @@ func cronjob(ctx *common.RenderContext) ([]runtime.Object, error) { return []runtime.Object{}, nil } + platformTelemetryData := "unknown" + _ = ctx.WithExperimental(func(cfg *experimental.Config) error { + if cfg.Telemetry != nil && cfg.Telemetry.Data.Platform != "" { + platformTelemetryData = cfg.Telemetry.Data.Platform + } + return nil + }) + installationTelemetryComponent := fmt.Sprintf("%s-telemetry", Component) objectMeta := metav1.ObjectMeta{ @@ -63,6 +72,10 @@ func cronjob(ctx *common.RenderContext) ([]runtime.Object, error) { Name: "GITPOD_INSTALLATION_VERSION", Value: ctx.VersionManifest.Version, }, + { + Name: "GITPOD_INSTALLATION_PLATFORM", + Value: platformTelemetryData, + }, { Name: "SERVER_URL", Value: fmt.Sprintf("http://%s.%s.svc.cluster.local:%d", common.ServerComponent, ctx.Namespace, common.ServerInstallationAdminPort), diff --git a/install/installer/pkg/config/v1/experimental/experimental.go b/install/installer/pkg/config/v1/experimental/experimental.go index fd33c58aae921f..ddc1557f5cba46 100644 --- a/install/installer/pkg/config/v1/experimental/experimental.go +++ b/install/installer/pkg/config/v1/experimental/experimental.go @@ -21,6 +21,13 @@ type Config struct { WebApp *WebAppConfig `json:"webapp,omitempty"` IDE *IDEConfig `json:"ide,omitempty"` Common *CommonConfig `json:"common,omitempty"` + Telemetry *TelemetryConfig `json:"telemetry,omitempty"` +} + +type TelemetryConfig struct { + Data struct { + Platform string `json:"platform"` + } `json:"data"` } type CommonConfig struct { diff --git a/install/kots/manifests/gitpod-installer-job.yaml b/install/kots/manifests/gitpod-installer-job.yaml index effeafd3773f38..cf7b5a0397a595 100644 --- a/install/kots/manifests/gitpod-installer-job.yaml +++ b/install/kots/manifests/gitpod-installer-job.yaml @@ -273,6 +273,9 @@ spec: fi fi + echo "Gitpod: Update platform telemetry value" + yq eval-all --inplace '.experimental.telemetry.data.platform = "{{repl Distribution }}"' "${CONFIG_FILE}" + echo "Gitpod: Patch Gitpod config" base64 -d "${CONFIG_PATCH_FILE}" > /tmp/patch.yaml config_patch=$(cat /tmp/patch.yaml) diff --git a/install/preview/entrypoint.sh b/install/preview/entrypoint.sh index 7f173fb6727466..d62ae90e4ad87c 100755 --- a/install/preview/entrypoint.sh +++ b/install/preview/entrypoint.sh @@ -105,9 +105,10 @@ yq e -i '.customCACert.kind = "secret"' config.yaml yq e -i '.observability.logLevel = "debug"' config.yaml yq e -i '.workspace.runtime.containerdSocket = "/run/k3s/containerd/containerd.sock"' config.yaml yq e -i '.workspace.runtime.containerdRuntimeDir = "/var/lib/rancher/k3s/agent/containerd/io.containerd.runtime.v2.task/k8s.io/"' config.yaml +yq e -i '.experimental.telemetry.data.platform = "local-preview"' config.yaml echo "extracting images to download ahead..." -/gitpod-installer render --config config.yaml | grep 'image:' | sed 's/ *//g' | sed 's/image://g' | sed 's/\"//g' | sed 's/^-//g' | sort | uniq > /gitpod-images.txt +/gitpod-installer render --use-experimental-config --config config.yaml | grep 'image:' | sed 's/ *//g' | sed 's/image://g' | sed 's/\"//g' | sed 's/^-//g' | sort | uniq > /gitpod-images.txt echo "downloading images..." while read -r image "$(cat /gitpod-images.txt)"; do # shellcheck disable=SC2154 @@ -116,7 +117,7 @@ done ctr images pull "docker.io/gitpod/workspace-full:latest" >/dev/null & -/gitpod-installer render --config config.yaml --output-split-files /var/lib/rancher/k3s/server/manifests/gitpod +/gitpod-installer render --use-experimental-config --config config.yaml --output-split-files /var/lib/rancher/k3s/server/manifests/gitpod # store files in `gitpod.debug` for debugging purposes for f in /var/lib/rancher/k3s/server/manifests/gitpod/*.yaml; do (cat "$f"; echo) >> /var/lib/rancher/k3s/server/gitpod.debug; done