Skip to content

Commit

Permalink
fix: notify plugins of internal sessionId changes
Browse files Browse the repository at this point in the history
  • Loading branch information
crleona committed Sep 10, 2024
1 parent 5987d39 commit cf3702d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 1 deletion.
1 change: 0 additions & 1 deletion Sources/Amplitude/Amplitude.swift
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,6 @@ public class Amplitude {
} else {
sessionEvents = self.sessions.endCurrentSession()
}
self.timeline.onSessionIdChanged(sessionId)
self.sessions.assignEventId(events: sessionEvents).forEach { e in
self.timeline.processEvent(event: e)
}
Expand Down
3 changes: 3 additions & 0 deletions Sources/Amplitude/Sessions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ public class Sessions {
private let configuration: Configuration
private let storage: Storage
private let logger: (any Logger)?
private let timeline: Timeline
private var _sessionId: Int64 = -1
private(set) var sessionId: Int64 {
get { _sessionId }
Expand All @@ -14,6 +15,7 @@ public class Sessions {
} catch {
logger?.warn(message: "Can't write PREVIOUS_SESSION_ID to storage: \(error)")
}
timeline.onSessionIdChanged(_sessionId)
}
}

Expand Down Expand Up @@ -47,6 +49,7 @@ public class Sessions {
configuration = amplitude.configuration
storage = amplitude.storage
logger = amplitude.logger
timeline = amplitude.timeline
self._sessionId = amplitude.storage.read(key: .PREVIOUS_SESSION_ID) ?? -1
self._lastEventId = amplitude.storage.read(key: .LAST_EVENT_ID) ?? 0
self._lastEventTime = amplitude.storage.read(key: .LAST_EVENT_TIME) ?? -1
Expand Down

0 comments on commit cf3702d

Please sign in to comment.