Skip to content

Commit

Permalink
feat: Completely remove user segment and all it's logic
Browse files Browse the repository at this point in the history
  • Loading branch information
AbhiPrasad committed Dec 11, 2024
1 parent fa08033 commit d66770f
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 17 deletions.
17 changes: 6 additions & 11 deletions interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,12 @@ type Attachment struct {
// User describes the user associated with an Event. If this is used, at least
// an ID or an IP address should be provided.
type User struct {
ID string `json:"id,omitempty"`
Email string `json:"email,omitempty"`
IPAddress string `json:"ip_address,omitempty"`
Username string `json:"username,omitempty"`
Name string `json:"name,omitempty"`
// Segment is a string representing the user segment that the user belongs to.
//
// Deprecated: Segment is deprecated and will be removed in the next major
// of the Sentry Go SDK.
Segment string `json:"segment,omitempty"`
Data map[string]string `json:"data,omitempty"`
ID string `json:"id,omitempty"`
Email string `json:"email,omitempty"`
IPAddress string `json:"ip_address,omitempty"`
Username string `json:"username,omitempty"`
Name string `json:"name,omitempty"`
Data map[string]string `json:"data,omitempty"`
}

func (u User) IsEmpty() bool {
Expand Down
1 change: 0 additions & 1 deletion interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ func TestUserMarshalJson(t *testing.T) {
{input: User{IPAddress: "127.0.0.1"}, want: `{"ip_address":"127.0.0.1"}`},
{input: User{Username: "My Username"}, want: `{"username":"My Username"}`},
{input: User{Name: "My Name"}, want: `{"name":"My Name"}`},
{input: User{Segment: "My Segment"}, want: `{"segment":"My Segment"}`},
{input: User{Data: map[string]string{"foo": "bar"}}, want: `{"data":{"foo":"bar"}}`},
}

Expand Down
4 changes: 0 additions & 4 deletions slog/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -102,10 +102,6 @@ func handleUserAttributes(v slog.Value, event *sentry.Event) {
event.User.Name = name
delete(data, "name")
}
if segment, ok := data["segment"]; ok {
event.User.Segment = segment
delete(data, "segment")
}
event.User.Data = data
}

Expand Down
1 change: 0 additions & 1 deletion slog/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ func TestAttrToSentryEvent(t *testing.T) {
slog.Attr{Key: "email", Value: slog.StringValue("user_email")},
slog.Attr{Key: "ip_address", Value: slog.StringValue("user_ip_address")},
slog.Attr{Key: "username", Value: slog.StringValue("user_username")},
slog.Attr{Key: "segment", Value: slog.StringValue("user_segment")},
slog.Attr{Key: "name", Value: slog.StringValue("user_name")},
)},
expected: &sentry.Event{
Expand Down

0 comments on commit d66770f

Please sign in to comment.