Class User

java.lang.Object
io.sentry.protocol.User
All Implemented Interfaces:
JsonSerializable, JsonUnknown

public final class User extends Object implements JsonUnknown, JsonSerializable
Information about the user who triggered an event.

```json { "user": { "id": "unique_id", "username": "my_user", "email": "foo@example.com", "ip_address": "127.0.0.1", "subscription": "basic" } } ```

  • Constructor Details

    • User

      public User()
    • User

      public User(@NotNull @NotNull User user)
  • Method Details

    • fromMap

      public static User fromMap(@NotNull @NotNull Map<String,Object> map, @NotNull @NotNull SentryOptions options)
      Creates user from a map.

      The values `data` and `value` expect a Map<String, String> type. If other object types are in the map `toString()` will be called on them.

      Parameters:
      map - - The user data as map
      options - - the sentry options
      Returns:
      the user
    • getEmail

      @Nullable public @Nullable String getEmail()
      Gets the e-mail address of the user.
      Returns:
      the e-mail.
    • setEmail

      public void setEmail(@Nullable @Nullable String email)
      Gets the e-mail address of the user.
      Parameters:
      email - the e-mail.
    • getId

      @Nullable public @Nullable String getId()
      Gets the id of the user.
      Returns:
      the id.
    • setId

      public void setId(@Nullable @Nullable String id)
      Sets the id of the user.
      Parameters:
      id - the user id.
    • getUsername

      @Nullable public @Nullable String getUsername()
      Gets the username of the user.
      Returns:
      the username.
    • setUsername

      public void setUsername(@Nullable @Nullable String username)
      Sets the username of the user.
      Parameters:
      username - the username.
    • getSegment

      @Deprecated @Nullable public @Nullable String getSegment()
      Deprecated.
      has no effect and will be removed in the next major update.
      Gets the segment of the user.
      Returns:
      the user segment.
    • setSegment

      @Deprecated public void setSegment(@Nullable @Nullable String segment)
      Deprecated.
      has no effect and will be removed in the next major update.
      Sets the segment of the user.
      Parameters:
      segment - the segment.
    • getIpAddress

      @Nullable public @Nullable String getIpAddress()
      Gets the IP address of the user.
      Returns:
      the IP address of the user.
    • setIpAddress

      public void setIpAddress(@Nullable @Nullable String ipAddress)
      Sets the IP address of the user.
      Parameters:
      ipAddress - the IP address of the user.
    • getOthers

      @Deprecated @Nullable public @Nullable Map<String,@NotNull String> getOthers()
      Deprecated.
      use {getData()} instead
      Gets other user related data.
      Returns:
      the other user data.
    • setOthers

      @Deprecated public void setOthers(@Nullable @Nullable Map<String,@NotNull String> other)
      Deprecated.
      use {setData(Map)} instead
      Sets other user related data.
      Parameters:
      other - the other user related data.
    • getName

      @Nullable public @Nullable String getName()
      Get human readable name.
      Returns:
      Human readable name
    • setName

      public void setName(@Nullable @Nullable String name)
      Set human readable name.
      Parameters:
      name - Human readable name
    • getGeo

      @Nullable public @Nullable Geo getGeo()
      Get user geo location.
      Returns:
      User geo location
    • setGeo

      public void setGeo(@Nullable @Nullable Geo geo)
      Set user geo location.
      Parameters:
      geo - User geo location
    • getData

      @Nullable public @Nullable Map<String,@NotNull String> getData()
      Gets additional arbitrary fields of the user.
      Returns:
      the other user data.
    • setData

      public void setData(@Nullable @Nullable Map<String,@NotNull String> data)
      Sets additional arbitrary fields of the user.
      Parameters:
      data - the other user related data.
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • getUnknown

      @Nullable public @Nullable Map<String,Object> getUnknown()
      Specified by:
      getUnknown in interface JsonUnknown
    • setUnknown

      public void setUnknown(@Nullable @Nullable Map<String,Object> unknown)
      Specified by:
      setUnknown in interface JsonUnknown
    • serialize

      public void serialize(@NotNull @NotNull ObjectWriter writer, @NotNull @NotNull ILogger logger) throws IOException
      Specified by:
      serialize in interface JsonSerializable
      Throws:
      IOException