-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add the TrackEvent type struct Reference fixes Only require one flag Better function description go fmt Update components/gitpod-cli/cmd/git-track-command.go Co-authored-by: bigint <bigint@icloud.com> fixes Log the correct vars and correct error messages Set test data Remove more unused code go fmt More go fmt Mock `TrackEvent` Fix destination of `gitCommand` Fix function references Spawn the git command tracker automatically Correct the script name Don't expect any results Don't return on error with tracker Use new connection syntax `go fmt` Set the correct type for params, rename args `go fmt` Fix param type names Add resource scope Move process release to an `else` block Make `TrackEvent` types emulate the backend Format `go fmt` Only use the one required scope Close the client after returning Change description [changelog] updated changelog Setup IdentitiesOnly as yes in ssh config Fixes #7335 Handle "no data" by adding 'on() vector(0)' to each numerator Relies on new variable $datasource Also fixes legend for workspace startup panel When exporting from Grafana, disable "export for sharing externally" Helm is needed to support Observability [changelog] updated changelog add missing condition for ide-proxy heml chart Improve label colors on dashboard integrations for the dark theme Send headers when connecting to the supervisor Create the version file during build
- Loading branch information
1 parent
be64564
commit 917b0fb
Showing
15 changed files
with
232 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
chart/templates/ide-proxy-deny-all-allow-explicit-networkpolicy.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,86 @@ | ||
// Copyright (c) 2021 Gitpod GmbH. All rights reserved. | ||
// Licensed under the GNU Affero General Public License (AGPL). | ||
// See License-AGPL.txt in the project root for license information. | ||
|
||
package cmd | ||
|
||
import ( | ||
"context" | ||
"io" | ||
"os" | ||
"time" | ||
|
||
log "github.com/sirupsen/logrus" | ||
"github.com/spf13/cobra" | ||
|
||
gitpod "github.com/gitpod-io/gitpod/gitpod-cli/pkg/gitpod" | ||
serverapi "github.com/gitpod-io/gitpod/gitpod-protocol" | ||
) | ||
|
||
var gitTrackCommandOpts struct { | ||
GitCommand string | ||
} | ||
|
||
var gitTrackCommand = &cobra.Command{ | ||
Use: "git-track-command", | ||
Short: "Gitpod's Git command tracker", | ||
Long: "Sending anonymous statistics about the executed git commands inside a workspace", | ||
Args: cobra.ExactArgs(0), | ||
Hidden: true, | ||
Run: func(cmd *cobra.Command, args []string) { | ||
log.SetOutput(io.Discard) | ||
f, err := os.OpenFile(os.TempDir()+"/gitpod-git-credential-helper.log", os.O_WRONLY|os.O_CREATE|os.O_APPEND, 0644) | ||
if err == nil { | ||
defer f.Close() | ||
log.SetOutput(f) | ||
} | ||
|
||
log.Infof("gp git-track-command") | ||
|
||
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Minute) | ||
defer cancel() | ||
wsInfo, err := gitpod.GetWSInfo(ctx) | ||
if err != nil { | ||
fail(err.Error()) | ||
} | ||
|
||
client, err := gitpod.ConnectToServer(ctx, wsInfo, []string{"function:trackEvent"}) | ||
|
||
if err != nil { | ||
log.WithError(err).Fatal("error connecting to supervisor") | ||
} | ||
|
||
defer client.Close() | ||
|
||
type GitEventParams struct { | ||
Command string `json:"command,omitempty"` | ||
WorkspaceId string `json:"workspaceId,omitempty"` | ||
WorkspaceInstanceId string `json:"workspaceInstanceId,omitempty"` | ||
Timestamp int64 `json:"timestamp,omitempty"` | ||
} | ||
|
||
params := &GitEventParams{ | ||
Command: gitTrackCommandOpts.GitCommand, | ||
WorkspaceId: wsInfo.WorkspaceId, | ||
WorkspaceInstanceId: wsInfo.InstanceId, | ||
Timestamp: time.Now().Unix(), | ||
} | ||
event := &serverapi.RemoteTrackMessage{ | ||
Event: "git_command", | ||
Properties: *params, | ||
} | ||
log.WithField("command", gitTrackCommandOpts.GitCommand). | ||
Info("tracking the GitCommand event") | ||
|
||
err = client.TrackEvent(ctx, event) | ||
if err != nil { | ||
log.WithError(err).Fatal("error tracking git event") | ||
} | ||
}, | ||
} | ||
|
||
func init() { | ||
rootCmd.AddCommand(gitTrackCommand) | ||
gitTrackCommand.Flags().StringVarP(&gitTrackCommandOpts.GitCommand, "gitCommand", "c", "", "The Git command to be recorded") | ||
gitTrackCommand.MarkFlagRequired("gitCommand") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
set-during-build |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.