seems to be working pretty well

This commit is contained in:
Anthony 2021-08-06 17:46:28 +02:00
parent 0b7a9dbf67
commit 2c115b2e76
No known key found for this signature in database
GPG key ID: C386D3C93D50E356
2 changed files with 22 additions and 12 deletions

View file

@ -98,12 +98,10 @@ function getDeviceType() {
return "web";
}
console.log('ANALYTICS RELOADED');
var durationInSeconds = 10;
var amountOfBufferEvents = 0;
var amountOfBufferTimeInMS = 0;
var videoType, userId, claimUrl, currentVideoPosition, playerPoweredBy, timeAtBuffer;
var videoType, userId, claimUrl, playerPoweredBy, timeAtBuffer;
var passedPlayer;
async function sendAndResetWatchmanData(){
@ -115,7 +113,7 @@ async function sendAndResetWatchmanData(){
protocol = 'stb';
}
var playerToUse = player || passedPlayer;
console.log(claimUrl)
timeAtBuffer = Math.round(player.currentTime()) * 1000;
@ -143,11 +141,14 @@ async function sendAndResetWatchmanData(){
var watchmanInterval;
function stopWatchmanInterval() {
console.log('turning off watchman interval')
clearInterval(watchmanInterval);
watchmanInterval = null;
}
function startWatchmanIntervalIfNotRunning() {
console.log('turning on watchman interval')
if (!watchmanInterval) {
console.log('watchman interval turned back on')
watchmanInterval = setInterval(sendAndResetWatchmanData, 1000 * durationInSeconds);
}
}
@ -184,13 +185,25 @@ const analytics: Analytics = {
stopWatchmanInterval();
// TODO: clear data here
},
videoIsPlaying: (isPlaying) => {
if(isPlaying){
startWatchmanIntervalIfNotRunning();
} else {
stopWatchmanInterval();
videoIsPlaying: (isPlaying, event) => {
console.log('event');
console.log(event);
console.log('is seeking');
console.log(player.seeking())
// have to use this because videojs pauses/unpauses during seek
var playerIsSeeking = player.seeking();
if(!playerIsSeeking){
if(isPlaying){
startWatchmanIntervalIfNotRunning();
} else {
stopWatchmanInterval();
}
}
},
videoStartEvent: (claimId, duration, poweredBy, passedUserId, canonicalUrl, playerFromView) => {

View file

@ -11,9 +11,6 @@ import { selectDaemonSettings, makeSelectClientSetting, selectHomepageData } fro
import { toggleVideoTheaterMode, doSetClientSetting } from 'redux/actions/settings';
import { selectUserVerifiedEmail, selectUser } from 'redux/selectors/user';
console.log('hereasdfasdf')
console.log(doAnalyticsBuffer)
const select = (state, props) => {
const { search } = props.location;
const urlParams = new URLSearchParams(search);