Analytics: track call start and call end
This commit is contained in:
parent
69a9643894
commit
c4046990f0
@ -270,6 +270,10 @@ class WebRtcCall(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun durationMillis(): Int {
|
||||||
|
return timer.elapsedTime().toInt()
|
||||||
|
}
|
||||||
|
|
||||||
fun formattedDuration(): String {
|
fun formattedDuration(): String {
|
||||||
return formatDuration(
|
return formatDuration(
|
||||||
Duration.ofMillis(timer.elapsedTime())
|
Duration.ofMillis(timer.elapsedTime())
|
||||||
|
@ -22,6 +22,9 @@ import androidx.lifecycle.LifecycleOwner
|
|||||||
import im.vector.app.ActiveSessionDataSource
|
import im.vector.app.ActiveSessionDataSource
|
||||||
import im.vector.app.BuildConfig
|
import im.vector.app.BuildConfig
|
||||||
import im.vector.app.core.services.CallService
|
import im.vector.app.core.services.CallService
|
||||||
|
import im.vector.app.features.analytics.AnalyticsTracker
|
||||||
|
import im.vector.app.features.analytics.plan.CallEnded
|
||||||
|
import im.vector.app.features.analytics.plan.CallStarted
|
||||||
import im.vector.app.features.call.VectorCallActivity
|
import im.vector.app.features.call.VectorCallActivity
|
||||||
import im.vector.app.features.call.audio.CallAudioManager
|
import im.vector.app.features.call.audio.CallAudioManager
|
||||||
import im.vector.app.features.call.lookup.CallProtocolsChecker
|
import im.vector.app.features.call.lookup.CallProtocolsChecker
|
||||||
@ -68,7 +71,8 @@ private val loggerTag = LoggerTag("WebRtcCallManager", LoggerTag.VOIP)
|
|||||||
@Singleton
|
@Singleton
|
||||||
class WebRtcCallManager @Inject constructor(
|
class WebRtcCallManager @Inject constructor(
|
||||||
private val context: Context,
|
private val context: Context,
|
||||||
private val activeSessionDataSource: ActiveSessionDataSource
|
private val activeSessionDataSource: ActiveSessionDataSource,
|
||||||
|
private val analyticsTracker: AnalyticsTracker
|
||||||
) : CallListener,
|
) : CallListener,
|
||||||
DefaultLifecycleObserver {
|
DefaultLifecycleObserver {
|
||||||
|
|
||||||
@ -237,6 +241,7 @@ class WebRtcCallManager @Inject constructor(
|
|||||||
val currentCall = getCurrentCall().takeIf { it != call }
|
val currentCall = getCurrentCall().takeIf { it != call }
|
||||||
currentCall?.updateRemoteOnHold(onHold = true)
|
currentCall?.updateRemoteOnHold(onHold = true)
|
||||||
audioManager.setMode(if (call.mxCall.isVideoCall) CallAudioManager.Mode.VIDEO_CALL else CallAudioManager.Mode.AUDIO_CALL)
|
audioManager.setMode(if (call.mxCall.isVideoCall) CallAudioManager.Mode.VIDEO_CALL else CallAudioManager.Mode.AUDIO_CALL)
|
||||||
|
call.trackCallStarted()
|
||||||
this.currentCall.setAndNotify(call)
|
this.currentCall.setAndNotify(call)
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,6 +250,7 @@ class WebRtcCallManager @Inject constructor(
|
|||||||
val webRtcCall = callsByCallId.remove(callId) ?: return Unit.also {
|
val webRtcCall = callsByCallId.remove(callId) ?: return Unit.also {
|
||||||
Timber.tag(loggerTag.value).v("On call ended for unknown call $callId")
|
Timber.tag(loggerTag.value).v("On call ended for unknown call $callId")
|
||||||
}
|
}
|
||||||
|
webRtcCall.trackCallEnded()
|
||||||
CallService.onCallTerminated(context, callId, endCallReason, rejected)
|
CallService.onCallTerminated(context, callId, endCallReason, rejected)
|
||||||
callsByRoomId[webRtcCall.signalingRoomId]?.remove(webRtcCall)
|
callsByRoomId[webRtcCall.signalingRoomId]?.remove(webRtcCall)
|
||||||
callsByRoomId[webRtcCall.nativeRoomId]?.remove(webRtcCall)
|
callsByRoomId[webRtcCall.nativeRoomId]?.remove(webRtcCall)
|
||||||
@ -443,4 +449,28 @@ class WebRtcCallManager @Inject constructor(
|
|||||||
}
|
}
|
||||||
call.onCallAssertedIdentityReceived(callAssertedIdentityContent)
|
call.onCallAssertedIdentityReceived(callAssertedIdentityContent)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Analytics
|
||||||
|
*/
|
||||||
|
private fun WebRtcCall.trackCallStarted() {
|
||||||
|
analyticsTracker.capture(
|
||||||
|
CallStarted(
|
||||||
|
isVideo = mxCall.isVideoCall,
|
||||||
|
numParticipants = 2,
|
||||||
|
placed = mxCall.isOutgoing
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun WebRtcCall.trackCallEnded() {
|
||||||
|
analyticsTracker.capture(
|
||||||
|
CallEnded(
|
||||||
|
durationMs = durationMillis(),
|
||||||
|
isVideo = mxCall.isVideoCall,
|
||||||
|
numParticipants = 2,
|
||||||
|
placed = mxCall.isOutgoing
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user