Skip to content

Commit e510fe2

Browse files
TeoSlayerteovlclaude
authored
fix: inject nodeID into telemetry events and add catalogue_viewed payload (#281)
- pkg/telemetry/client.go: Send() now injects c.nodeID into events that don't supply their own NodeID, so telemetry events carry the correct node identity instead of always being 0 - cmd/pilotctl/appstore_catalogue.go: catalogue_viewed event now sends payload {"surface":"catalogue"} instead of empty {} Co-authored-by: Teodor Calin <teodor@vulturelabs.io> Co-authored-by: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 8458f47 commit e510fe2

2 files changed

Lines changed: 13 additions & 2 deletions

File tree

cmd/pilotctl/appstore_catalogue.go

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -248,8 +248,9 @@ func cmdAppStoreCatalogue(_ []string) {
248248
identityPath := configDir() + "/identity.json"
249249
client := telemetry.NewClientFromIdentity(url, identityPath, 0)
250250
err := client.Send(telemetry.Event{
251-
Kind: "catalogue_viewed",
252-
TS: time.Now().UTC().Format(time.RFC3339),
251+
Kind: "catalogue_viewed",
252+
TS: time.Now().UTC().Format(time.RFC3339),
253+
Payload: json.RawMessage(`{"surface":"catalogue"}`),
253254
})
254255
if err != nil {
255256
slog.Warn("telemetry send failed, catalogue still rendered", "err", err)

pkg/telemetry/client.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ func (c *Client) Send(events ...Event) error {
9898
url := c.url
9999
sign := c.sign
100100
pubKeyB := c.pubKeyB
101+
nodeID := c.nodeID
101102
c.mu.Unlock()
102103

103104
if disabled || url == "" {
@@ -113,6 +114,15 @@ func (c *Client) Send(events ...Event) error {
113114
return nil
114115
}
115116

117+
// Inject node ID into events that don't supply their own.
118+
if nodeID != 0 {
119+
for i := range events {
120+
if events[i].NodeID == 0 {
121+
events[i].NodeID = nodeID
122+
}
123+
}
124+
}
125+
116126
body, err := json.Marshal(events)
117127
if err != nil {
118128
return fmt.Errorf("telemetry marshal: %w", err)

0 commit comments

Comments
 (0)