mirror of
https://github.com/omnivore-app/omnivore.git
synced 2026-03-11 08:54:26 +00:00
Add audio session events
This commit is contained in:
parent
eae715820d
commit
89fd9b9f0c
2 changed files with 28 additions and 0 deletions
|
|
@ -231,9 +231,16 @@ public class AudioController: NSObject, ObservableObject, AVAudioPlayerDelegate
|
|||
|
||||
self.itemAudioProperties = itemAudioProperties
|
||||
startAudio()
|
||||
|
||||
EventTracker.track(
|
||||
.audioSessionStart(linkID: itemAudioProperties.itemID)
|
||||
)
|
||||
}
|
||||
|
||||
public func stop() {
|
||||
let stoppedId = itemAudioProperties?.itemID
|
||||
let stoppedTimeElapsed = timeElapsed
|
||||
|
||||
player?.pause()
|
||||
timer?.invalidate()
|
||||
|
||||
|
|
@ -251,6 +258,12 @@ public class AudioController: NSObject, ObservableObject, AVAudioPlayerDelegate
|
|||
timeElapsed = 0
|
||||
duration = 1
|
||||
durations = nil
|
||||
|
||||
if let stoppedId = stoppedId {
|
||||
EventTracker.track(
|
||||
.audioSessionEnd(linkID: stoppedId, timeElapsed: stoppedTimeElapsed ?? 0.0)
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
public func generateVoiceList() -> [(name: String, key: String, selected: Bool)] {
|
||||
|
|
|
|||
|
|
@ -4,6 +4,8 @@ public enum TrackableEvent {
|
|||
case linkRead(linkID: String, slug: String, originalArticleURL: String)
|
||||
case debugMessage(message: String)
|
||||
case backgroundFetch(jobStatus: BackgroundFetchJobStatus, itemCount: Int, secondsElapsed: Int)
|
||||
case audioSessionStart(linkID: String)
|
||||
case audioSessionEnd(linkID: String, timeElapsed: Double)
|
||||
}
|
||||
|
||||
public enum BackgroundFetchJobStatus: String {
|
||||
|
|
@ -22,6 +24,10 @@ public extension TrackableEvent {
|
|||
return "debug_message"
|
||||
case .backgroundFetch:
|
||||
return "background_fetch"
|
||||
case .audioSessionStart:
|
||||
return "audio_session_start"
|
||||
case .audioSessionEnd:
|
||||
return "audio_session_end"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -41,6 +47,15 @@ public extension TrackableEvent {
|
|||
"seconds_elapsed": String(secondsElapsed),
|
||||
"fetched_item_count": String(itemCount)
|
||||
]
|
||||
case let .audioSessionStart(linkID: linkID):
|
||||
return [
|
||||
"link": linkID
|
||||
]
|
||||
case let .audioSessionEnd(linkID: linkID, timeElapsed: timeElapsed):
|
||||
return [
|
||||
"link": linkID,
|
||||
"timeElapsed": String(timeElapsed)
|
||||
]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue