Skip to content

Commit fd3e2ea

Browse files
authored
Add flush events function
1 parent a7259cc commit fd3e2ea

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

Cloudinary/Classes/ios/Video/CLDVideoPlayer.swift

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,22 @@ import AVKit
128128
}
129129
}
130130

131+
public func flushEvents() {
132+
guard analytics else { return }
133+
eventsManager.sendEvents()
134+
}
135+
136+
public func flushEventsAndCloseSession() {
137+
guard analytics else { return }
138+
eventsManager.sendViewEndEvent(providedData: providedData)
139+
flushEvents()
140+
}
141+
131142
deinit {
132-
if analytics {
133-
removeObserver(self, forKeyPath: PlayerKeyPath.status.rawValue)
134-
removeObserver(self, forKeyPath: PlayerKeyPath.timeControlStatus.rawValue)
135-
eventsManager.sendViewEndEvent(providedData: providedData)
136-
eventsManager.sendEvents()
137-
}
143+
guard analytics else { return }
144+
removeObserver(self, forKeyPath: PlayerKeyPath.status.rawValue)
145+
removeObserver(self, forKeyPath: PlayerKeyPath.timeControlStatus.rawValue)
146+
flushEventsAndCloseSession()
138147
}
139148

140149
func setAnalyticsObservers() {

0 commit comments

Comments
 (0)