From 032ada28ecebe7018bfc126255c409e3f51ebc77 Mon Sep 17 00:00:00 2001 From: Fabrizio-rar Date: Fri, 21 Nov 2025 10:15:33 -0300 Subject: [PATCH 1/2] network change events --- src/mux-analytics.brs | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/src/mux-analytics.brs b/src/mux-analytics.brs index fc05112..1ed76d4 100644 --- a/src/mux-analytics.brs +++ b/src/mux-analytics.brs @@ -328,7 +328,7 @@ function _getConnectionType(deviceInfo as Object) return "wifi" end if if connectionType = "WiredConnection" - return "ethernet" + return "wired" end if return "other" @@ -487,6 +487,9 @@ function muxAnalytics() as Object ' Flag to track heartbeat timer state to avoid rendezvous m._Flag_heartbeatTimerRunning = false + ' Network monitoring + m._lastConnectionType = Invalid + ' kick off analytics date = m._getDateTime() m._startTimestamp = 0# + date.AsSeconds() * 1000.0# + date.GetMilliseconds() @@ -497,15 +500,27 @@ function muxAnalytics() as Object prototype.beaconIntervalHandler = sub(beaconIntervalEvent) data = beaconIntervalEvent.getData() - m.updateSessionPropertiesConnectionType() + m._checkNetworkChange() m.LIGHT_THE_BEACONS() end sub - prototype.updateSessionPropertiesConnectionType = sub() - connectionType = _getConnectionType(m.deviceInfo) - if connectionType <> Invalid - m._sessionProperties.viewer_connection_type = connectionType + prototype._checkNetworkChange = sub() + currentConnectionType = _getConnectionType(m.deviceInfo) + ' Check if connection type has changed + if currentConnectionType <> m._lastConnectionType + m._fireNetworkChangeEvent(currentConnectionType) + m._lastConnectionType = currentConnectionType + end if + end sub + + prototype._fireNetworkChangeEvent = sub(connectionType as Dynamic) + props = {} + if connectionType = Invalid + props.viewer_connection_type = Invalid + else + props.viewer_connection_type = connectionType end if + m._addEventToQueue(m._createEvent("networkchange", props)) end sub prototype.heartbeatIntervalHandler = sub(heartbeatIntervalEvent) @@ -1219,6 +1234,9 @@ function muxAnalytics() as Object ' m._playerPlayheadTime = m.video.position ' end if + ' Check for network changes as a backup polling mechanism + m._checkNetworkChange() + m._setBufferingMetrics() m._updateContentPlaybackTime() @@ -1441,6 +1459,11 @@ function muxAnalytics() as Object props.ad_playing_time_ms_cumulative = m._totalAdWatchTime m._addEventToQueue(m._createEvent("playbackmodechange", props)) + ' Fire initial networkchange event + initialConnectionType = _getConnectionType(m.deviceInfo) + m._lastConnectionType = initialConnectionType + m._fireNetworkChangeEvent(initialConnectionType) + m._addEventToQueue(m._createEvent("viewstart")) m._inView = true @@ -1498,6 +1521,7 @@ function muxAnalytics() as Object m._viewAverageRequestThroughput = Invalid m._viewRequestCount = Invalid m._segmentRequestFailedCount = Invalid + m._lastConnectionType = Invalid end if end sub From 01139b5a59cadecf1330a601a131d06c43e29d6c Mon Sep 17 00:00:00 2001 From: Fabrizio-rar Date: Fri, 21 Nov 2025 10:18:21 -0300 Subject: [PATCH 2/2] updating session props --- src/mux-analytics.brs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/mux-analytics.brs b/src/mux-analytics.brs index 1ed76d4..16f2a3a 100644 --- a/src/mux-analytics.brs +++ b/src/mux-analytics.brs @@ -510,6 +510,10 @@ function muxAnalytics() as Object if currentConnectionType <> m._lastConnectionType m._fireNetworkChangeEvent(currentConnectionType) m._lastConnectionType = currentConnectionType + ' Update session properties with new connection type + if m._sessionProperties <> Invalid + m._sessionProperties.viewer_connection_type = currentConnectionType + end if end if end sub