Anthony watchman integration #6799

Merged
mayeaux merged 20 commits from anthony-watchman-integration into master 2021-08-10 22:42:50 +02:00
2 changed files with 9 additions and 23 deletions
Showing only changes of commit 5b2c808f78 - Show all commits

View file

@ -103,14 +103,11 @@ console.log('ANALYTICS RELOADED');
var durationInSeconds = 10; var durationInSeconds = 10;
var amountOfBufferEvents = 0; var amountOfBufferEvents = 0;
var amountOfBufferTimeInMS = 0; var amountOfBufferTimeInMS = 0;
var videoType, userId, claimUrl, totalDurationInSeconds, currentVideoPosition, playerPoweredBy, timeAtBuffer; var videoType, userId, claimUrl, currentVideoPosition, playerPoweredBy, timeAtBuffer;
async function sendAndResetWatchmanData(){ async function sendAndResetWatchmanData(){
// console.log('running!')
// console.log(player);
var protocol; var protocol;
if (videoType === 'application/x-mpegURL'){ if (videoType === 'application/x-mpegURL'){
protocol = 'hls'; protocol = 'hls';
@ -118,36 +115,27 @@ async function sendAndResetWatchmanData(){
protocol = 'stb'; protocol = 'stb';
} }
if(!totalDurationInSeconds){ if(!timeAtBuffer){
totalDurationInSeconds = player.currentTime(); timeAtBuffer = Math.round(player.currentTime()) * 1000;
} }
if(!timeAtBuffer){ var totalDurationInSeconds = Math.round(player.duration());
timeAtBuffer = player.duration();
}
//
// console.log('time at buffer');
// console.log(timeAtBuffer);
// console.log(totalDurationInSeconds);
const objectToSend = { const objectToSend = {
rebuf_count: amountOfBufferEvents, rebuf_count: amountOfBufferEvents,
rebuf_duration: amountOfBufferTimeInMS, rebuf_duration: amountOfBufferTimeInMS,
url: claimUrl, url: claimUrl,
jessopb commented 2021-08-09 23:09:01 +02:00 (Migrated from github.com)
Review

This sort of thing, if tested elsewhere should use a constant, make a new file in constants if necessary.

This sort of thing, if tested elsewhere should use a constant, make a new file in constants if necessary.
device: getDeviceType(), device: getDeviceType(),
duration: durationInSeconds * 1000, duration: Math.round(durationInSeconds) * 1000,
protocol, protocol,
player: playerPoweredBy, player: playerPoweredBy,
user_id: Number(userId), user_id: Number(userId),
position: Math.round(timeAtBuffer) , position: Math.round(timeAtBuffer) ,
rel_position: Math.round((timeAtBuffer / (totalDurationInSeconds * 1000)) * 100), rel_position: Math.round((timeAtBuffer / (totalDurationInSeconds * 1000)) * 100),
} };
console.log('About to send the data!');
await sendWatchmanData(objectToSend); await sendWatchmanData(objectToSend);
// TODO: send here
amountOfBufferEvents = 0; amountOfBufferEvents = 0;
amountOfBufferTimeInMS = 0; amountOfBufferTimeInMS = 0;
timeAtBuffer = null; timeAtBuffer = null;
@ -195,8 +183,6 @@ const analytics: Analytics = {
timeAtBuffer = data.timeAtBuffer; timeAtBuffer = data.timeAtBuffer;
totalDurationInSeconds = data.duration;
// console.log('RUNNING HERE'); // console.log('RUNNING HERE');
// //
// console.log(claim); // console.log(claim);

View file

@ -127,9 +127,9 @@ function VideoViewer(props: Props) {
}, [embedded, videoPlaybackRate]); }, [embedded, videoPlaybackRate]);
function doTrackingBuffered(e: Event, data: any) { function doTrackingBuffered(e: Event, data: any) {
console.log('BUFFER'); // console.log('BUFFER');
console.log(this); // console.log(this);
console.log('BUFFER'); // console.log('BUFFER');
// this.pause() // this.pause()
// //
// doAnalyticsBuffer(uri, data); // doAnalyticsBuffer(uri, data);