Skip to content

Commit 1f2d121

Browse files
authored
feat: include target architecture of compiled builds in logstash events (#126)
1 parent 41cf0f5 commit 1f2d121

3 files changed

Lines changed: 11 additions & 0 deletions

File tree

internal/tracking/logstash_event.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ type EventData struct {
4848

4949
// EventContext contains information / metadata about the CLI session
5050
type EventContext struct {
51+
Arch string `json:"arch"`
5152
Binary string `json:"bin"`
5253
CLIVersion string `json:"cli_version"`
5354
Command string `json:"command,omitempty"`

internal/tracking/tracking.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -193,6 +193,7 @@ func (e *EventTracker) FlushToLogstash(ctx context.Context, cfg *config.Config,
193193
CLIVersion: versionString,
194194
Host: ioutils.GetHostname(),
195195
OS: runtime.GOOS,
196+
Arch: runtime.GOARCH,
196197
SessionID: sessionID,
197198
SystemID: cfg.SystemID,
198199
ProjectID: cfg.ProjectID,

internal/tracking/tracking_test.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import (
1919
"io"
2020
"net/http"
2121
"net/http/httptest"
22+
"runtime"
2223
"testing"
2324

2425
"github.com/slackapi/slack-cli/internal/config"
@@ -136,6 +137,14 @@ func Test_Tracking_FlushToLogstash(t *testing.T) {
136137
require.Contains(t, string(payload), fmt.Sprintf("\"cli_version\":\"%s\"", "4.2.0"))
137138
},
138139
},
140+
"should include os and arch build information": {
141+
assertOnRequest: func(t *testing.T, req *http.Request) {
142+
payload, err := io.ReadAll(req.Body)
143+
require.NoError(t, err)
144+
require.Contains(t, string(payload), fmt.Sprintf("\"arch\":\"%s\"", runtime.GOARCH))
145+
require.Contains(t, string(payload), fmt.Sprintf("\"os\":\"%s\"", runtime.GOOS))
146+
},
147+
},
139148
}
140149

141150
for name, tt := range tests {

0 commit comments

Comments
 (0)