Skip to content

Commit e2ae6dc

Browse files
committed
Fix: Initialize tracker with default 'anonymous' userID to prevent silent event drops
The Tracker was initializing with an empty userID, causing Amplitude SDK to silently drop all events that didn't have a customer ID resolved (skipAuth commands, failed resolveCustomerID calls, and error events). Amplitude Go SDK requires at least 5 characters for UserID or DeviceID. Events with both empty are rejected during validation but the rejection is invisible in production due to silentLogger. This change ensures all events have a valid userID by defaulting to 'anonymous', which is overridden when SetUserID is called with the actual customer ID for authenticated commands.
1 parent 6d78161 commit e2ae6dc

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

‎tracking/tracking.go‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,12 +41,13 @@ func New(cfg Config) *Tracker {
4141
return &Tracker{
4242
client: amplitude.NewClient(ampConfig),
4343
version: cfg.CLIVersion,
44+
userID: "anonymous",
4445
enabled: true,
4546
}
4647
}
4748

4849
// SetUserID sets the real user identity (e.g. "user_123") for all subsequent events.
49-
// If not called, events are sent with an empty UserID.
50+
// If not called, events are sent with UserID "anonymous".
5051
func (t *Tracker) SetUserID(id string) {
5152
t.userID = id
5253
}

0 commit comments

Comments
 (0)