Skip to content

Commit

Permalink
feat: Remove user segment (#928)
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Hoffmann <[email protected]>
  • Loading branch information
AbhiPrasad and cleptric authored Dec 12, 2024
1 parent a59bd69 commit 77bd21b
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 19 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
### Breaking Changes

- Remove all code related to Sentry's previous Metrics product. Read more about the end of the Metrics beta ([here](https://sentry.zendesk.com/hc/en-us/articles/26369339769883-Metrics-Beta-Ended-on-October-7th)) ([#914](https://github.com/getsentry/sentry-go/pull/914))
- Remove `Segment` field from the `User` struct. This field is no longer used in the Sentry product. ([#928](https://github.com/getsentry/sentry-go/pull/928))

## 0.30.0

Expand Down
3 changes: 0 additions & 3 deletions dynamic_sampling_context_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,6 @@ func TestDynamicSamplingContextFromTransaction(t *testing.T) {
Release: "1.0.0",
Environment: "test",
})
hubFromContext(ctx).ConfigureScope(func(scope *Scope) {
scope.SetUser(User{Segment: "user_segment"})
})
txn := StartTransaction(ctx, "name", WithTransactionSource(SourceCustom))
txn.TraceID = TraceIDFromHex("d49d9bf66f13450b81f65bc51cf49c03")
return txn
Expand Down
5 changes: 0 additions & 5 deletions interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@ type User struct {
IPAddress string `json:"ip_address,omitempty"`
Username string `json:"username,omitempty"`
Name string `json:"name,omitempty"`
Segment string `json:"segment,omitempty"`
Data map[string]string `json:"data,omitempty"`
}

Expand All @@ -137,10 +136,6 @@ func (u User) IsEmpty() bool {
return false
}

if u.Segment != "" {
return false
}

if len(u.Data) > 0 {
return false
}
Expand Down
4 changes: 1 addition & 3 deletions interfaces_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ func TestUserIsEmpty(t *testing.T) {
{input: User{IPAddress: "127.0.0.1"}, want: false},
{input: User{Username: "My Username"}, want: false},
{input: User{Name: "My Name"}, want: false},
{input: User{Segment: "My Segment"}, want: false},
{input: User{Data: map[string]string{"foo": "bar"}}, want: false},
{input: User{ID: "foo", Email: "[email protected]", IPAddress: "127.0.0.1", Username: "My Username", Name: "My Name", Segment: "My Segment", Data: map[string]string{"foo": "bar"}}, want: false},
{input: User{ID: "foo", Email: "[email protected]", IPAddress: "127.0.0.1", Username: "My Username", Name: "My Name", Data: map[string]string{"foo": "bar"}}, want: false},
}

for _, test := range tests {
Expand All @@ -52,7 +51,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: 2 additions & 2 deletions scope_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,9 @@ func fillEventWithData(event *Event) *Event {

func TestScopeSetUser(t *testing.T) {
scope := NewScope()
scope.SetUser(User{ID: "foo", Email: "[email protected]", IPAddress: "127.0.0.1", Username: "My Username", Name: "My Name", Segment: "My Segment", Data: map[string]string{"foo": "bar"}})
scope.SetUser(User{ID: "foo", Email: "[email protected]", IPAddress: "127.0.0.1", Username: "My Username", Name: "My Name", Data: map[string]string{"foo": "bar"}})

assertEqual(t, User{ID: "foo", Email: "[email protected]", IPAddress: "127.0.0.1", Username: "My Username", Name: "My Name", Segment: "My Segment", Data: map[string]string{"foo": "bar"}}, scope.user)
assertEqual(t, User{ID: "foo", Email: "[email protected]", IPAddress: "127.0.0.1", Username: "My Username", Name: "My Name", Data: map[string]string{"foo": "bar"}}, scope.user)
}

func TestScopeSetUserOverrides(t *testing.T) {
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
2 changes: 0 additions & 2 deletions 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 All @@ -109,7 +108,6 @@ func TestAttrToSentryEvent(t *testing.T) {
IPAddress: "user_ip_address",
Username: "user_username",
Name: "user_name",
Segment: "user_segment",
Data: map[string]string{},
},
},
Expand Down

0 comments on commit 77bd21b

Please sign in to comment.