5 // Created by Cornelius Horstmann on 26.02.17.
6 // Copyright © 2017 PIWIK. All rights reserved.
12 /// The number of sessions of the current user.
14 let sessionsCount: Int
16 /// The timestamp of the previous visit.
17 /// Discussion: Should this be now for the first request?
21 /// The timestamp of the fist visit.
22 /// Discussion: Should this be now for the first request?
28 static func current(in matomoUserDefaults: MatomoUserDefaults) -> Session {
30 var matomoUserDefaults = matomoUserDefaults
31 if let existingFirstVisit = matomoUserDefaults.firstVisit {
32 firstVisit = existingFirstVisit
35 matomoUserDefaults.firstVisit = firstVisit
37 let sessionCount = matomoUserDefaults.totalNumberOfVisits
38 let lastVisit = matomoUserDefaults.previousVisit ?? Date()
39 return Session(sessionsCount: sessionCount, lastVisit: lastVisit, firstVisit: firstVisit)