public class SessionImpl extends java.lang.Object implements Session, Storable, ly.count.sdk.java.internal.EventImpl.EventRecorder
| Modifier and Type | Field and Description |
|---|---|
protected java.lang.Long |
began
|
protected CtxCore |
ctx |
protected View |
currentView
Current view event, that is started, but not ended yet
|
protected java.lang.Long |
ended
|
protected java.util.List<Event> |
events
List of events still not added to request
|
protected java.lang.Long |
id
System.nanoTime() of time when Session object is created. |
protected Params |
params
Additional parameters to send with next request
|
protected boolean |
startView
Whether
currentView will be start view. |
protected java.lang.Long |
updated
|
| Modifier | Constructor and Description |
|---|---|
protected |
SessionImpl(CtxCore ctx)
Create session with current time as id.
|
|
SessionImpl(CtxCore ctx,
java.lang.Long id)
Deserialization constructor (use existing id).
|
| Modifier and Type | Method and Description |
|---|---|
Session |
addCrashReport(java.lang.Throwable t,
boolean fatal)
Send Crash Report to the server.
|
Session |
addCrashReport(java.lang.Throwable t,
boolean fatal,
java.lang.String name,
java.util.Map<java.lang.String,java.lang.String> segments,
java.lang.String... logs)
Send Crash Report to the server.
|
Session |
addLocation(double latitude,
double longitude)
Send location information to the server.
|
Session |
addParam(java.lang.String key,
java.lang.Object value)
Add parameter to this session which will be sent along with next request.
|
Session |
begin()
Start this session, add corresponding request to queue.
|
Usage |
changeDeviceIdWithMerge(java.lang.String id)
Change device id with merging profiles on server, just set device id to new one.
|
Usage |
changeDeviceIdWithoutMerge(java.lang.String id)
Change device id without merging profiles on server, just set device id to new one.
|
void |
end()
End this session, add corresponding request to queue.
|
boolean |
equals(java.lang.Object obj) |
Event |
event(java.lang.String key)
Create event object, don't record it yet.
|
java.lang.Long |
getBegan()
System.currentTimeMillis() of Session.begin() call. |
java.lang.String |
getDeviceId()
This method returns the Device ID that is currently used by the SDK.
|
java.lang.Long |
getEnded()
System.currentTimeMillis() of Session.end() call. |
java.lang.Long |
getId()
System.nanoTime() of this instance creation. |
static java.lang.String |
getStoragePrefix() |
int |
hashCode() |
boolean |
isActive()
Whether this session was started and haven't been ended yet.
|
Usage |
login(java.lang.String id)
Login function to set device (user) id on Countly server to the string specified here.
|
Usage |
logout()
Logout function to make current user anonymous (that is with random id according to
ConfigCore.deviceIdStrategy and such). |
void |
recordEvent(Event event) |
Usage |
resetDeviceId(java.lang.String id) |
boolean |
restore(byte[] data) |
java.lang.Long |
storageId() |
java.lang.String |
storagePrefix() |
byte[] |
store() |
Event |
timedEvent(java.lang.String key)
Get existing or create new timed event object, don't record it.
|
protected ly.count.sdk.java.internal.TimedEvents |
timedEvents() |
Session |
update()
Send update request to the server saying that user is still using the app.
|
User |
user()
Get current User Profile.
|
View |
view(java.lang.String name)
Identical to
Usage.view(String, boolean), but without start parameter which
is determined automatically based on whether this view is first in this session. |
View |
view(java.lang.String name,
boolean start)
Start new view.
|
protected final java.lang.Long id
System.nanoTime() of time when Session object is created.protected final CtxCore ctx
protected java.lang.Long began
protected java.lang.Long updated
protected java.lang.Long ended
protected final java.util.List<Event> events
protected final Params params
protected View currentView
protected boolean startView
currentView will be start view.protected SessionImpl(CtxCore ctx)
public SessionImpl(CtxCore ctx, java.lang.Long id)
public Session begin()
Sessionpublic Session update()
Sessionpublic void end()
Sessionpublic boolean isActive()
SessionisActive in interface Sessiontrue if session was started and haven't been ended yet, false otherwiseSession.begin(),
Session.end()public Event event(java.lang.String key)
Usageevent in interface Usagekey - key for this event, cannot be null or emptyEvent.record()public Event timedEvent(java.lang.String key)
UsagetimedEvent in interface Usagekey - key for this event, cannot be null or emptyto end timed eventprotected ly.count.sdk.java.internal.TimedEvents timedEvents()
public void recordEvent(Event event)
recordEvent in interface ly.count.sdk.java.internal.EventImpl.EventRecorderpublic User user()
UsageUser object.
Note that even when the CoreFeature.UserProfiles is disabled,
this method still returns an object, yet any modifications to it won't result in any data stored
or sent to the server/
//@ee Feature is not available in Countly Community Editionpublic Session addCrashReport(java.lang.Throwable t, boolean fatal)
UsageaddCrashReport in interface Usaget - Throwable to logfatal - whether this crash report should be displayed as fatal in dashboard or notpublic Session addCrashReport(java.lang.Throwable t, boolean fatal, java.lang.String name, java.util.Map<java.lang.String,java.lang.String> segments, java.lang.String... logs)
UsageaddCrashReport in interface Usaget - Throwable to logfatal - whether this crash report should be displayed as fatal in dashboard or notname - (optional, can be null) name of the report, falls back to first line of stack trace by defaultsegments - (optional, can be null) additional crash segments maplogs - (optional, can be null) additional log lines (separated by \n) or comment about this crash reportpublic Session addLocation(double latitude, double longitude)
UsageaddLocation in interface Usagelatitude - geographical latitude of the userlongitude - geographical longitude of the userpublic View view(java.lang.String name, boolean start)
Usageview in interface Usagename - String representing name of this Viewstart - whether this view is first in current application launchView, you're responsible for its ending by calling View.stop(boolean)public View view(java.lang.String name)
UsageUsage.view(String, boolean), but without start parameter which
is determined automatically based on whether this view is first in this session.
Creates begin request if this session hasn't yet been began.view in interface Usagename - String representing name of this ViewView, you're responsible for its ending by calling View.stop(boolean)public Usage login(java.lang.String id)
UsageConfigCore.autoSessionsTracking is on, acquires device id.public Usage logout()
UsageConfigCore.deviceIdStrategy and such). Obviously makes sense only after a call to Usage.login(String),
so it throws error or does nothing (depending on ConfigCore.testMode) if current id wasn't set using Usage.login(String).
Closes current session.public java.lang.String getDeviceId()
UsagegetDeviceId in interface Usagepublic Usage resetDeviceId(java.lang.String id)
resetDeviceId in interface Usagepublic Usage changeDeviceIdWithMerge(java.lang.String id)
UsagechangeDeviceIdWithMerge in interface Usageid - new user / device id string, cannot be emptypublic Usage changeDeviceIdWithoutMerge(java.lang.String id)
UsagechangeDeviceIdWithoutMerge in interface Usageid - new user / device id string, cannot be emptypublic Session addParam(java.lang.String key, java.lang.Object value)
Usagepublic java.lang.Long getId()
SessionSystem.nanoTime() of this instance creation.public java.lang.Long getBegan()
SessionSystem.currentTimeMillis() of Session.begin() call.public java.lang.Long getEnded()
SessionSystem.currentTimeMillis() of Session.end() call.public java.lang.String storagePrefix()
storagePrefix in interface Storablepublic static java.lang.String getStoragePrefix()
public boolean equals(java.lang.Object obj)
equals in class java.lang.Objectpublic int hashCode()
hashCode in class java.lang.Object