File tree Expand file tree Collapse file tree 8 files changed +896
-0
lines changed Expand file tree Collapse file tree 8 files changed +896
-0
lines changed Original file line number Diff line number Diff line change
1
+ packages :
2
+ - name : telemetry
3
+ type : go
4
+ srcs :
5
+ - go.mod
6
+ - go.sum
7
+ - " **/*.go"
8
+ env :
9
+ - CGO_ENABLED=0
10
+ config :
11
+ packaging : app
12
+ buildCommand : [
13
+ " go" ,
14
+ " build" ,
15
+ " -trimpath" ,
16
+ " -ldflags" ,
17
+ # todo(sje): change "commit-${__git_commit}" for the segment token
18
+ " -buildid= -w -s -X 'github.com/gitpod-io/gitpod/telemetry/cmd.segmentIOToken=commit-${__git_commit}'" ,
19
+ ]
Original file line number Diff line number Diff line change
1
+
2
+ options:
3
+ no_parent_owners: true
4
+
5
+ approvers:
6
+ - engineering-self-hosted
7
+
8
+ labels:
9
+ - "team: self-hosted"
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2
+ // Licensed under the GNU Affero General Public License (AGPL).
3
+ // See License-AGPL.txt in the project root for license information.
4
+
5
+ package cmd
6
+
7
+ import "github.com/spf13/cobra"
8
+
9
+ // rootCmd represents the base command when called without any subcommands
10
+ var rootCmd = & cobra.Command {
11
+ Use : "telemetry" ,
12
+ Short : "This service sends telemetry information back to Gitpod" ,
13
+ }
14
+
15
+ func Execute () {
16
+ cobra .CheckErr (rootCmd .Execute ())
17
+ }
18
+
19
+ func init () {
20
+ rootCmd .AddCommand (runCmd )
21
+ }
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2
+ // Licensed under the GNU Affero General Public License (AGPL).
3
+ // See License-AGPL.txt in the project root for license information.
4
+
5
+ package cmd
6
+
7
+ import (
8
+ "fmt"
9
+ "os"
10
+
11
+ "github.com/spf13/cobra"
12
+ "gopkg.in/segmentio/analytics-go.v3"
13
+ )
14
+
15
+ var segmentIOToken string
16
+
17
+ var runCmd = & cobra.Command {
18
+ Use : "run" ,
19
+ Short : "Sends telemetry data" ,
20
+ RunE : func (cmd * cobra.Command , args []string ) (err error ) {
21
+ if segmentIOToken == "" {
22
+ return fmt .Errorf ("segmentIOToken build variable not set" )
23
+ }
24
+
25
+ userId := os .Getenv ("GITPOD_INSTALLATION_ID" )
26
+ if userId == "" {
27
+ return fmt .Errorf ("GITPOD_INSTALLATION_ID envvar not set" )
28
+ }
29
+
30
+ versionId := os .Getenv ("GITPOD_INSTALLATION_VERSION" )
31
+ if versionId == "" {
32
+ return fmt .Errorf ("GITPOD_INSTALLATION_VERSION envvar not set" )
33
+ }
34
+
35
+ client , err := analytics .NewWithConfig (segmentIOToken , analytics.Config {})
36
+ defer func () {
37
+ err = client .Close ()
38
+ }()
39
+
40
+ client .Enqueue (analytics.Track {
41
+ UserId : userId ,
42
+ Event : "Installation telemetry" ,
43
+ Properties : analytics .NewProperties ().
44
+ Set ("version" , versionId ),
45
+ })
46
+
47
+ return err
48
+ },
49
+ }
Original file line number Diff line number Diff line change
1
+ module github.com/gitpod-io/gitpod/telemetry
2
+
3
+ go 1.17
4
+
5
+ require (
6
+ github.com/spf13/cobra v1.3.0
7
+ gopkg.in/segmentio/analytics-go.v3 v3.1.0
8
+ )
9
+
10
+ require (
11
+ github.com/inconshreveable/mousetrap v1.0.0 // indirect
12
+ github.com/segmentio/backo-go v1.0.0 // indirect
13
+ github.com/spf13/pflag v1.0.5 // indirect
14
+ github.com/xtgo/uuid v0.0.0-20140804021211-a0b114877d4c // indirect
15
+ )
Load Diff Large diffs are not rendered by default.
Original file line number Diff line number Diff line change
1
+ # Copyright (c) 2021 Gitpod GmbH. All rights reserved.
2
+ # Licensed under the GNU Affero General Public License (AGPL).
3
+ # See License-AGPL.txt in the project root for license information.
4
+
5
+ FROM alpine:3.15
6
+ COPY telemetry--app/telemetry telemetry--app/provenance-bundle.jsonl /app/
7
+ ENTRYPOINT [ "/app/telemetry" ]
8
+ CMD [ "help" ]
Original file line number Diff line number Diff line change
1
+ // Copyright (c) 2022 Gitpod GmbH. All rights reserved.
2
+ // Licensed under the GNU Affero General Public License (AGPL).
3
+ // See License-AGPL.txt in the project root for license information.
4
+
5
+ package main
6
+
7
+ import "github.com/gitpod-io/gitpod/telemetry/cmd"
8
+
9
+ func main () {
10
+ cmd .Execute ()
11
+ }
You can’t perform that action at this time.
0 commit comments