-
Notifications
You must be signed in to change notification settings - Fork 4
Cumulative Ad playing time #86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 6 commits
651fb04
8f76ce0
adbae52
bc4eda9
79f2011
d9b69fc
bb9fbff
464cce5
5775a8d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -412,6 +412,10 @@ function muxAnalytics() as Object | |
m._videoSourceDuration = Invalid | ||
m._videoCurrentCdn = Invalid | ||
m._viewPrerollPlayedCount = Invalid | ||
m._totalAdWatchTime = Invalid | ||
m._adWatchTime = Invalid | ||
m._cumulativePlayingTime = Invalid | ||
m._lastAdResumeTime = Invalid | ||
|
||
m._lastSourceWidth = Invalid | ||
m._lastSourceHeight = Invalid | ||
|
@@ -926,8 +930,17 @@ function muxAnalytics() as Object | |
end sub | ||
|
||
prototype._rafEventhandler = sub(eventType, ctx, adMetadata) | ||
date = m._getDateTime() | ||
now = 0# + date.AsSeconds() * 1000.0# + date.GetMilliseconds() | ||
|
||
if m._adWatchTime = Invalid | ||
m._adWatchTime = 0 | ||
end if | ||
|
||
m._Flag_isPaused = (eventType = "Pause") | ||
if eventType = "PodStart" | ||
m._adWatchTime = 0 | ||
m._lastAdResumeTime = now | ||
m._advertProperties = m._getAdvertProperties(adMetadata) | ||
m._addEventToQueue(m._createEvent("adbreakstart")) | ||
' In the case that this is SSAI, we need to signal an adplay and adplaying event | ||
|
@@ -936,6 +949,11 @@ function muxAnalytics() as Object | |
m._addEventToQueue(m._createEvent("adplaying")) | ||
end if | ||
else if eventType = "PodComplete" | ||
if m._lastAdResumeTime <> Invalid | ||
m._adWatchTime += now - m._lastAdResumeTime | ||
|
||
m._lastAdResumeTime = Invalid | ||
end if | ||
m._totalAdWatchTime += m._adWatchTime | ||
m._addEventToQueue(m._createEvent("adbreakend")) | ||
m._Flag_FailedAdsErrorSet = false | ||
' In the case that this is SSAI, we need to signal a play and playing event | ||
|
@@ -947,6 +965,10 @@ function muxAnalytics() as Object | |
else if eventType = "Impression" | ||
m._addEventToQueue(m._createEvent("adimpression")) | ||
else if eventType = "Pause" | ||
if m._lastAdResumeTime <> Invalid | ||
m._adWatchTime += now - m._lastAdResumeTime | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. should we make sure that this is not a negative value, and if it is, just throw it out? something like |
||
m._lastAdResumeTime = Invalid | ||
end if | ||
m._addEventToQueue(m._createEvent("adpause")) | ||
else if eventType = "Start" | ||
if m._viewTimeToFirstFrame = Invalid | ||
|
@@ -968,6 +990,7 @@ function muxAnalytics() as Object | |
m._addEventToQueue(m._createEvent("adplay")) | ||
m._addEventToQueue(m._createEvent("adplaying")) | ||
else if eventType = "Resume" | ||
m._lastAdResumeTime = now | ||
m._advertProperties = m._getAdvertProperties(ctx) | ||
m._addEventToQueue(m._createEvent("adplay")) | ||
m._addEventToQueue(m._createEvent("adplaying")) | ||
|
@@ -997,12 +1020,24 @@ function muxAnalytics() as Object | |
else if eventType = "ThirdQuartile" | ||
m._addEventToQueue(m._createEvent("adthirdquartile")) | ||
else if eventType = "Skip" | ||
if m._lastAdResumeTime <> Invalid | ||
m._adWatchTime += now - m._lastAdResumeTime | ||
m._lastAdResumeTime = Invalid | ||
end if | ||
m._totalAdWatchTime += m._adWatchTime | ||
m._addEventToQueue(m._createEvent("adskipped")) | ||
m._addEventToQueue(m._createEvent("adended")) | ||
end if | ||
end sub | ||
|
||
prototype._renderStitchedStreamRafEventHandler = sub(eventType, ctx, adMetadata) | ||
date = m._getDateTime() | ||
now = 0# + date.AsSeconds() * 1000.0# + date.GetMilliseconds() | ||
|
||
if m._adWatchTime = Invalid | ||
m._adWatchTime = 0 | ||
end if | ||
|
||
if eventType = "AdStateChange" | ||
state = ctx.state | ||
m._advertProperties = m._getAdvertProperties(adMetadata) | ||
|
@@ -1011,6 +1046,8 @@ function muxAnalytics() as Object | |
' our ad break here if we're not already in one | ||
if not m._Flag_rssInAdBreak | ||
m._Flag_rssInAdBreak = true | ||
m._adWatchTime = 0 | ||
m._lastAdResumeTime = now | ||
m._addEventToQueue(m._createEvent("adbreakstart")) | ||
end if | ||
|
||
|
@@ -1021,18 +1058,25 @@ function muxAnalytics() as Object | |
' in the playing state, if we either resuming, we need adplay first | ||
if m._Flag_isPaused | ||
m._Flag_isPaused = false | ||
m._lastAdResumeTime = now | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this isn't necessary - it will always be set again on line 1065 |
||
m._addEventToQueue(m._createEvent("adplay")) | ||
end if | ||
' and always emit adplaying | ||
m._addEventToQueue(m._createEvent("adplaying")) | ||
else if state = "paused" | ||
if m._lastAdResumeTime <> Invalid | ||
m._adWatchTime += now - m._lastAdResumeTime | ||
m._lastAdResumeTime = Invalid | ||
end if | ||
m._Flag_isPaused = true | ||
m._addEventToQueue(m._createEvent("adpause")) | ||
end if | ||
else if eventType = "PodStart" | ||
' Need to handle PodStart for non-pre-rolls | ||
if not m._Flag_rssInAdBreak | ||
m._Flag_rssInAdBreak = true | ||
m._adWatchTime = 0 | ||
m._lastAdResumeTime = now | ||
if not m._Flag_isPaused | ||
m._Flag_isPaused = true | ||
m._addEventToQueue(m._createEvent("pause")) | ||
|
@@ -1049,10 +1093,16 @@ function muxAnalytics() as Object | |
' event to know that a new ad was played | ||
if m._Flag_rssAdEnded | ||
m._Flag_rssAdEnded = false | ||
m._lastAdResumeTime = now | ||
m._addEventToQueue(m._createEvent("adplay")) | ||
m._addEventToQueue(m._createEvent("adplaying")) | ||
end if | ||
else if eventType = "PodComplete" | ||
if m._lastAdResumeTime <> Invalid | ||
m._adWatchTime += now - m._lastAdResumeTime | ||
m._lastAdResumeTime = Invalid | ||
end if | ||
m._totalAdWatchTime += m._adWatchTime | ||
m._Flag_rssInAdBreak = false | ||
m._Flag_isPaused = true | ||
m._addEventToQueue(m._createEvent("adbreakend")) | ||
|
@@ -1139,6 +1189,7 @@ function muxAnalytics() as Object | |
if m._contentPlaybackTime = Invalid then return | ||
|
||
m._viewWatchTime = m._viewTimeToFirstFrame + m._viewRebufferDuration + m._contentPlaybackTime | ||
m._cumulativePlayingTime = m._viewWatchTime + m._totalAdWatchTime | ||
end sub | ||
|
||
prototype._setBufferingMetrics = sub() | ||
|
@@ -1275,6 +1326,9 @@ function muxAnalytics() as Object | |
end if | ||
m._viewId = m._generateGUID() | ||
m._viewWatchTime = 0 | ||
m._adWatchTime = 0 | ||
m._totalAdWatchTime = 0 | ||
m._cumulativePlayingTime = 0 | ||
m._contentPlaybackTime = 0 | ||
m._viewRebufferCount = 0 | ||
m._viewRebufferDuration = 0 | ||
|
@@ -1329,6 +1383,10 @@ function muxAnalytics() as Object | |
m._playerTimeToFirstFrame = Invalid | ||
m._contentPlaybackTime = Invalid | ||
m._viewWatchTime = Invalid | ||
m._adWatchTime = Invalid | ||
m._lastAdResumeTime = Invalid | ||
m._totalAdWatchTime = Invalid | ||
m._cumulativePlayingTime = Invalid | ||
m._viewRebufferCount = Invalid | ||
m._viewRebufferDuration = Invalid | ||
m._viewRebufferFrequency! = Invalid | ||
|
@@ -1689,6 +1747,12 @@ function muxAnalytics() as Object | |
if m._viewRequestCount <> Invalid | ||
props.view_request_count = m._viewRequestCount | ||
end if | ||
if m._cumulativePlayingTime <> Invalid AND m._cumulativePlayingTime > 0 | ||
props.view_playing_time_ms_cumulative = m._cumulativePlayingTime | ||
end if | ||
if m._totalAdWatchTime <> Invalid AND m._totalAdWatchTime > 0 | ||
props.ad_playing_time_active_ms_cumulative = m._totalAdWatchTime | ||
end if | ||
if m._configProperties <> Invalid AND m._configProperties.player_init_time <> Invalid | ||
playerInitTime = Invalid | ||
if Type(m._configProperties.player_init_time) = "roString" | ||
|
@@ -2037,6 +2101,7 @@ function muxAnalytics() as Object | |
"asset": "as", | ||
"autoplay": "au", | ||
"average": "av", | ||
"active": "ac", | ||
"bitrate": "bi", | ||
"brand": "bn", | ||
"break": "br", | ||
|
@@ -2063,6 +2128,7 @@ function muxAnalytics() as Object | |
"current": "cu", | ||
"connection": "cx", | ||
"context": "cz", | ||
"cumulative": "cv", | ||
"downscaling": "dg", | ||
"domain": "dm", | ||
"cdn": "dn", | ||
|
@@ -2124,6 +2190,7 @@ function muxAnalytics() as Object | |
"manufacturer": "mn", | ||
"model": "mo", | ||
"mux": "mx", | ||
"ms": "ms", | ||
"newest": "ne", | ||
"name": "nm", | ||
"number": "no", | ||
|
Uh oh!
There was an error while loading. Please reload this page.