public class SessionImpl extends OpenKitComposite implements Session
Session interface.| Modifier and Type | Field and Description |
|---|---|
static int |
MAX_NEW_SESSION_REQUESTS
The maximum number of "new session requests" to send per session.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
canSendNewSessionRequest()
Indicates whether new session requests can be sent or not.
|
void |
clearCapturedData()
Clears data that has been captured so far.
|
void |
close() |
void |
decreaseNumRemainingSessionRequests()
Decreases the number of remaining new session requests.
|
void |
disableCapture()
Disables capturing for this session.
|
void |
enableCapture()
Enables capturing for this session.
|
void |
end()
Ends this Session and marks it as ready for immediate sending.
|
void |
end(boolean sendSessionEndEvent) |
RootAction |
enterAction(java.lang.String actionName)
Enters an Action with a specified name in this Session.
|
long |
getSplitByEventsGracePeriodEndTimeInMillis()
Returns the time when the session is to be ended (after it was not possible to end the session after splitting
events e.g.
|
SessionState |
getState() |
void |
identifyUser(java.lang.String userTag)
Tags a session with the provided
userTag. |
void |
initializeServerConfiguration(ServerConfiguration initialServerConfig)
Initializes the
Beacon with the given ServerConfiguration |
boolean |
isDataSendingAllowed()
Indicates whether sending data for this session is allowed or not.
|
boolean |
isEmpty()
Test if this Session is empty or not.
|
void |
reportCrash(java.lang.String errorName,
java.lang.String reason,
java.lang.String stacktrace)
Reports a crash with a specified error name, crash reason and a stacktrace.
|
StatusResponse |
sendBeacon(HTTPClientProvider clientProvider,
AdditionalQueryParameters additionalParameters)
Sends the current beacon state.
|
void |
setSplitByEventsGracePeriodEndTimeInMillis(long endTime)
Sets the end time when the session is to be actually ended after a session split by event count.
|
java.lang.String |
toString() |
WebRequestTracer |
traceWebRequest(java.lang.String url)
Allows tracing and timing of a web request handled by any 3rd party HTTP Client (e.g.
|
WebRequestTracer |
traceWebRequest(java.net.URLConnection connection)
Traces a web request - which is provided as a URLConnection - and allows adding timing information to this request.
|
boolean |
tryEnd()
Tries to end the current session by checking if there are no more child objects (actions / web request tracers)
open.
|
void |
updateServerConfiguration(ServerConfiguration serverConfiguration)
Update the
Beacon with the given ServerConfiguration |
getActionIDpublic static final int MAX_NEW_SESSION_REQUESTS
public void close()
close in interface java.io.Closeableclose in interface java.lang.AutoCloseablepublic RootAction enterAction(java.lang.String actionName)
Session
If the given actionName is null or an empty string,
no reporting will happen on that RootAction.
enterAction in interface SessionactionName - name of the Actionpublic void identifyUser(java.lang.String userTag)
SessionuserTag.
If the given userTag is null or an empty string,
no user identification will be reported to the server.
identifyUser in interface SessionuserTag - id of the userpublic void reportCrash(java.lang.String errorName,
java.lang.String reason,
java.lang.String stacktrace)
Session
If the given errorName is null or an empty string,
no crash report will be sent to the server.
reportCrash in interface SessionerrorName - name of the error leading to the crash (e.g. Exception class)reason - reason or description of that errorstacktrace - stacktrace leading to that crashpublic WebRequestTracer traceWebRequest(java.net.URLConnection connection)
SessiontraceWebRequest in interface Sessionconnection - the URLConnection of the HTTP request to be tagged and timedpublic WebRequestTracer traceWebRequest(java.lang.String url)
SessionOpenKitConstants.WEBREQUEST_TAG_HEADER) has to be set manually to the
tag value of this WebRequestTracer. traceWebRequest in interface Sessionurl - the URL of the web request to be tagged and timedpublic void end()
Sessionpublic void end(boolean sendSessionEndEvent)
public boolean tryEnd()
true if the session was successfully ended (or was already ended before). false in case
there are / were still open child objects (actions / web request tracers).public void setSplitByEventsGracePeriodEndTimeInMillis(long endTime)
SessionWatchdog thread.endTime - the time when the session is to be closed for good.public long getSplitByEventsGracePeriodEndTimeInMillis()
public StatusResponse sendBeacon(HTTPClientProvider clientProvider, AdditionalQueryParameters additionalParameters)
clientProvider - Provider class providing the client for data transmission.additionalParameters - additional parameters that will be appended to the beacon request (can be null).public void clearCapturedData()
This is called, when capturing is turned off to avoid having too much data.
public boolean isEmpty()
A session is considered to be empty, if it does not contain any action or event data.
true if the session is empty, false otherwise.public void initializeServerConfiguration(ServerConfiguration initialServerConfig)
Beacon with the given ServerConfigurationpublic void updateServerConfiguration(ServerConfiguration serverConfiguration)
Beacon with the given ServerConfigurationpublic SessionState getState()
public boolean isDataSendingAllowed()
public void enableCapture()
Will implicitly also set the session state to configured.
public void disableCapture()
Will implicitly also set the session state to configured.
public boolean canSendNewSessionRequest()
This is directly related to decreaseNumRemainingSessionRequests().
public void decreaseNumRemainingSessionRequests()
In case no more new session requests remain, canSendNewSessionRequest() will return false
public java.lang.String toString()
toString in class java.lang.Object