trying to get working
This commit is contained in:
parent
4dbb506e77
commit
fa0e635d54
2 changed files with 18 additions and 4 deletions
|
@ -2,7 +2,7 @@
|
||||||
import videojs from 'video.js';
|
import videojs from 'video.js';
|
||||||
const VERSION = '0.0.1';
|
const VERSION = '0.0.1';
|
||||||
|
|
||||||
const watchmanEndpoint = 'https://watchman.na-backend.dev.odysee.com';
|
const watchmanEndpoint = 'https://watchman.na-backend.odysee.com/reports/playback';
|
||||||
|
|
||||||
let previousEventTime = Date.now();
|
let previousEventTime = Date.now();
|
||||||
|
|
||||||
|
@ -35,7 +35,7 @@ function createWatchmanData(
|
||||||
function sendWatchmanData(watchmanData) {
|
function sendWatchmanData(watchmanData) {
|
||||||
const requestOptions = {
|
const requestOptions = {
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
headers: { 'Content-Type': 'text/plain' }, // application/json
|
headers: { 'Content-Type': 'application/json' }, // application/json
|
||||||
body: JSON.stringify(watchmanData),
|
body: JSON.stringify(watchmanData),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -43,9 +43,11 @@ function sendWatchmanData(watchmanData) {
|
||||||
fetch(watchmanEndpoint, requestOptions)
|
fetch(watchmanEndpoint, requestOptions)
|
||||||
.then((response) => response.json())
|
.then((response) => response.json())
|
||||||
.then((data) => {
|
.then((data) => {
|
||||||
|
console.log('it worked')
|
||||||
// Response data
|
// Response data
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log('was an error');
|
||||||
// Response error
|
// Response error
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -82,11 +84,19 @@ class WatchmanPlugin extends Component {
|
||||||
player.on('tracking:firstplay', (event, data) => this.onTrackingFirstPlay(event, data));
|
player.on('tracking:firstplay', (event, data) => this.onTrackingFirstPlay(event, data));
|
||||||
player.on('tracking:buffered', (event, data) => this.onTrackingBuffered(event, data));
|
player.on('tracking:buffered', (event, data) => this.onTrackingBuffered(event, data));
|
||||||
|
|
||||||
|
// player.on('tracking:buffered', function(event, data){
|
||||||
|
// console.log('here!');
|
||||||
|
// console.log(event);
|
||||||
|
// console.log(data);
|
||||||
|
// })
|
||||||
|
|
||||||
// Event trigger to send recsys event
|
// Event trigger to send recsys event
|
||||||
player.on('dispose', (event) => this.onDispose(event));
|
player.on('dispose', (event) => this.onDispose(event));
|
||||||
}
|
}
|
||||||
|
|
||||||
sendWatchmanData() {
|
sendWatchmanData() {
|
||||||
|
console.log('running once here');
|
||||||
|
|
||||||
const processedData = this.bufferEventData.reduce(
|
const processedData = this.bufferEventData.reduce(
|
||||||
(accumulator, current) => {
|
(accumulator, current) => {
|
||||||
// Always update with the most current player x-powered-by header
|
// Always update with the most current player x-powered-by header
|
||||||
|
@ -158,6 +168,10 @@ class WatchmanPlugin extends Component {
|
||||||
}
|
}
|
||||||
|
|
||||||
onWatchmanInterval() {
|
onWatchmanInterval() {
|
||||||
|
|
||||||
|
console.log('player paused');
|
||||||
|
console.log(this.player.paused())
|
||||||
|
|
||||||
// don't report while player is paused
|
// don't report while player is paused
|
||||||
if (this.player.paused()) return;
|
if (this.player.paused()) return;
|
||||||
|
|
||||||
|
@ -166,7 +180,7 @@ class WatchmanPlugin extends Component {
|
||||||
console.log('[watchman] interval', this.bufferEventData);
|
console.log('[watchman] interval', this.bufferEventData);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.sendWatchmanData();
|
// this.sendWatchmanData();
|
||||||
|
|
||||||
// clear processed data
|
// clear processed data
|
||||||
this.bufferEventData = [];
|
this.bufferEventData = [];
|
||||||
|
|
|
@ -572,7 +572,7 @@ export default React.memo<Props>(function VideoJs(props: Props) {
|
||||||
});
|
});
|
||||||
|
|
||||||
player.watchman({
|
player.watchman({
|
||||||
reportRate: 15,
|
reportRate: 25,
|
||||||
videoUrl: claimId,
|
videoUrl: claimId,
|
||||||
userId: userId,
|
userId: userId,
|
||||||
debug: true,
|
debug: true,
|
||||||
|
|
Loading…
Reference in a new issue