Package io.sentry

Class Session

All Implemented Interfaces:
JsonSerializable, JsonUnknown

public final class Session extends Object implements JsonUnknown, JsonSerializable
  • Constructor Details

    • Session

      public Session(@NotNull @NotNull Session.State status, @NotNull @NotNull Date started, @Nullable @Nullable Date timestamp, int errorCount, @Nullable @Nullable String distinctId, @Nullable @Nullable UUID sessionId, @Nullable @Nullable Boolean init, @Nullable @Nullable Long sequence, @Nullable @Nullable Double duration, @Nullable @Nullable String ipAddress, @Nullable @Nullable String userAgent, @Nullable @Nullable String environment, @NotNull @NotNull String release, @Nullable @Nullable String abnormalMechanism)
    • Session

      public Session(@Nullable @Nullable String distinctId, @Nullable @Nullable User user, @Nullable @Nullable String environment, @NotNull @NotNull String release)
  • Method Details

    • isTerminated

      public boolean isTerminated()
    • getStarted

      @Nullable public @Nullable Date getStarted()
    • getDistinctId

      @Nullable public @Nullable String getDistinctId()
    • getSessionId

      @Nullable public @Nullable UUID getSessionId()
    • getIpAddress

      @Nullable public @Nullable String getIpAddress()
    • getUserAgent

      @Nullable public @Nullable String getUserAgent()
    • getEnvironment

      @Nullable public @Nullable String getEnvironment()
    • getRelease

      @NotNull public @NotNull String getRelease()
    • getInit

      @Nullable public @Nullable Boolean getInit()
    • setInitAsTrue

      @Internal public void setInitAsTrue()
      Used for migrating the init flag when an session is gonna be deleted.
    • errorCount

      public int errorCount()
    • getStatus

      @NotNull public @NotNull Session.State getStatus()
    • getSequence

      @Nullable public @Nullable Long getSequence()
    • getDuration

      @Nullable public @Nullable Double getDuration()
    • getAbnormalMechanism

      @Nullable public @Nullable String getAbnormalMechanism()
    • getTimestamp

      @Nullable public @Nullable Date getTimestamp()
    • end

      public void end()
      Ends a session and update its values
    • end

      public void end(@Nullable @Nullable Date timestamp)
      Ends a session and update its values
      timestamp - the timestamp or null
    • update

      public boolean update(@Nullable @Nullable Session.State status, @Nullable @Nullable String userAgent, boolean addErrorsCount)
    • update

      public boolean update(@Nullable @Nullable Session.State status, @Nullable @Nullable String userAgent, boolean addErrorsCount, @Nullable @Nullable String abnormalMechanism)
      Updates the current session and set its values
      status - the status
      userAgent - the userAgent
      addErrorsCount - true if should increase error count or not
      abnormalMechanism - the mechanism which caused the session to be abnormal
      if the session has been updated
    • clone

      @NotNull public @NotNull Session clone()
      Ctor copy of the Session
      clone in class Object
      a copy of the Session
    • serialize

      public void serialize(@NotNull @NotNull ObjectWriter writer, @NotNull @NotNull ILogger logger) throws IOException
      Specified by:
      serialize in interface JsonSerializable
    • 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