Object SessionManager
-
- All Implemented Interfaces:
public class SessionManagerThis class is responsible for managing session level signals i.e. session count, user retention, session depth, appSessionStartTimeStamp. It also provides the sessionId for the session.
Supports two modes selected by SignalsConfig.SessionConfig.fgBgModelEnabled: a legacy one-shot start (startSessionLegacy) and a foreground/background model that tracks foreground duration and expires the session after a configurable idle timeout.
-
-
Field Summary
Fields Modifier and Type Field Description private final KeyValueStoredefaultKVStoreprivate final <Error class: unknown class><String, String>sessionIdMappublic final static SessionManagerINSTANCE
-
Method Summary
Modifier and Type Method Description final UnitstartSession()Foreground entry point. final UnitonAppBackground()Called when the app is backgrounded (fg/bg model only). final UnitsetIsSessionTrackingEnabled(Boolean isSessionTrackingEnabled)final UnitupdateSessionDepth(String adtype, Boolean isRewarded)final JSONObjectgetSessionDataMap()Builds the session signal payload. final UnitupdateSessionCount()final UnitupdateUserRetention()The user retention timestamp is the time when the user first started using the app. final UnitresetSessionState()final IntegergetCalculatedUserRetention()final KeyValueStoregetDefaultKVStore()final <Error class: unknown class><String, String>getSessionIdMap()-
-
Method Detail
-
startSession
final Unit startSession()
Foreground entry point. Routes to the legacy one-shot start or the foreground/background model based on config.
-
onAppBackground
final Unit onAppBackground()
Called when the app is backgrounded (fg/bg model only). Banks the elapsed foreground duration and records the background-entry timestamp. No timer is armed — expiry is detected lazily on the next foreground by comparing lastBackgroundTimeMillis against the configured timeout.
-
setIsSessionTrackingEnabled
final Unit setIsSessionTrackingEnabled(Boolean isSessionTrackingEnabled)
-
updateSessionDepth
final Unit updateSessionDepth(String adtype, Boolean isRewarded)
-
getSessionDataMap
final JSONObject getSessionDataMap()
Builds the session signal payload. Emits foreground duration (
f-dur) only in the fg/bg model.
-
updateSessionCount
final Unit updateSessionCount()
-
updateUserRetention
final Unit updateUserRetention()
The user retention timestamp is the time when the user first started using the app. If the user retention timestamp is not already set (i.e., it is 0), this function will set it to the current time.
-
resetSessionState
final Unit resetSessionState()
-
getCalculatedUserRetention
final Integer getCalculatedUserRetention()
- Returns:
The user retention in days, or 0 if the application context is null.
-
getDefaultKVStore
final KeyValueStore getDefaultKVStore()
-
getSessionIdMap
final <Error class: unknown class><String, String> getSessionIdMap()
-
-
-
-