Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/tracking/logstash_event.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ type EventData struct {

// EventContext contains information / metadata about the CLI session
type EventContext struct {
Arch string `json:"arch"`
Binary string `json:"bin"`
CLIVersion string `json:"cli_version"`
Command string `json:"command,omitempty"`
Expand Down
1 change: 1 addition & 0 deletions internal/tracking/tracking.go
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ func (e *EventTracker) FlushToLogstash(ctx context.Context, cfg *config.Config,
CLIVersion: versionString,
Host: ioutils.GetHostname(),
OS: runtime.GOOS,
Arch: runtime.GOARCH,
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📣 TIL that GOARCH is set at compile time and not runtime, so this matches the installed build:

🔗 https://pkg.go.dev/runtime

GOARCH, GOOS, and GOROOT are recorded at compile time and made available by constants or functions in this package, but they do not influence the execution of the run-time system.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow! I was about to point that this is may report the user's system architecture instead of the binary's architecture. Thanks for digging into it and finding out that it uses the binary's arch!

SessionID: sessionID,
SystemID: cfg.SystemID,
ProjectID: cfg.ProjectID,
Expand Down
9 changes: 9 additions & 0 deletions internal/tracking/tracking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import (
"io"
"net/http"
"net/http/httptest"
"runtime"
"testing"

"github.com/slackapi/slack-cli/internal/config"
Expand Down Expand Up @@ -136,6 +137,14 @@ func Test_Tracking_FlushToLogstash(t *testing.T) {
require.Contains(t, string(payload), fmt.Sprintf("\"cli_version\":\"%s\"", "4.2.0"))
},
},
"should include os and arch build information": {
assertOnRequest: func(t *testing.T, req *http.Request) {
payload, err := io.ReadAll(req.Body)
require.NoError(t, err)
require.Contains(t, string(payload), fmt.Sprintf("\"arch\":\"%s\"", runtime.GOARCH))
require.Contains(t, string(payload), fmt.Sprintf("\"os\":\"%s\"", runtime.GOOS))
},
},
}

for name, tt := range tests {
Expand Down
Loading