             url: URL(string: "http://example.com")!.appendingPathComponent(action.joined(separator: "/")),
             actionName: action,
             language: Locale.httpAcceptLanguage,
-            isNewSession: false, // set this to true once we can start a new session
+            isNewSession: nextEventStartsANewSession,
             referer: nil,
             eventCategory: nil,
             eventAction: nil,

    private(set) var isDispatching = false
    
    
    /// Manually start the dispatching process.
    public func dispatch() {
        guard !isDispatching else { return }
        guard queue.eventCount > 0 else {

    
    internal var visitor = Visitor.current()
    internal var session = Session.current()
    internal var nextEventStartsANewSession = true
}

extension Tracker {
    /// Starts a new Session
    ///
    /// Use this function to manually start a new Session. A new Session will be automatically created only on app start.
    /// You can use the AppDelegates `applicationWillEnterForeground` to start a new visit whenever the app enters foreground.
    public func startNewSession() {
        PiwikUserDefaults.standard.previousVisit = PiwikUserDefaults.standard.currentVisit
        PiwikUserDefaults.standard.currentVisit = Date()
        PiwikUserDefaults.standard.totalNumberOfVisits += 1
        self.session = Session.current()
    }
}

// shared instance
