endSession static method
Implementation
static Future<void> endSession(String reason) async {
try {
Event sessionEndEvent = await Event.create('session_end');
int sessionDuration = getSessionDuration();
// Add session_id to session_end event
final sessionId = getCurrentSessionId();
sessionEndEvent.addEventParams(Map.of({
'session_id': sessionId,
'session_duration': sessionDuration,
'session_end_reason': reason,
}));
await Prefs.remove(_currentSessionStartKey);
await Prefs.remove(_sessionDurationKey);
DatabucketsEventTracker.addEvent(sessionEndEvent);
} catch (e, st) {
dbLogger.severe('Send Session End failed:', e, st);
}
}