Recsys: fix resumed-send missing totalPlayTime

Ticket: 1751

## Issue
The `totalPlayTime` resides in the videojs plugin and is only sent to the recsys object in `onPlayerDispose`, so it missed the redux rehydration in the browser close/refresh scenario.

## Change
Update the recsys value for `totalPlayTime` immediately so that it'll be part of the redux stashing (and later, rehydration).

Note that recsys data is currently being saved to redux in a 15s interval. Will change that in the next commit.
This commit is contained in:
infinite-persistence 2022-06-24 14:57:25 +08:00
parent 6b3e03cca4
commit 8aa831fe49
No known key found for this signature in database
GPG key ID: B9C3252EDC3D0AA0
3 changed files with 9 additions and 0 deletions

View file

@ -156,6 +156,13 @@ const recsys: Recsys = {
recsys.log('createRecsysEntry', claimId);
},
updateRecsysEntry: function (claimId, key, value) {
const entry = recsys.entries[claimId];
if (entry) {
entry[key] = value;
}
},
/**
* Send event for claimId
* @param claimId

View file

@ -6,6 +6,7 @@ declare type Recsys = {
onClickedRecommended: (parentClaimId: ClaimId, newClaimId: ClaimId) => void,
onRecsLoaded: (claimId: ClaimId, uris: Array<string>, uuid: string) => void,
createRecsysEntry: (claimId: ClaimId, parentUuid?: ?string, uuid?: string) => void,
updateRecsysEntry: (claimId: ClaimId, key: string, value: string) => void,
sendRecsysEntry: (claimId: ClaimId, isTentative?: boolean) => ?Promise<?Response>,
sendEntries: (entries: ?{ [ClaimId]: RecsysEntry }, isResumedSend: boolean) => void,
onRecsysPlayerEvent: (claimId: ClaimId, event: RecsysPlaybackEvent, isEmbedded: boolean) => void,

View file

@ -129,6 +129,7 @@ class RecsysPlugin extends Component {
if (this.watchedDuration.lastTimestamp !== curTimeSec && !this.inPause) {
this.watchedDuration.total += 1;
this.watchedDuration.lastTimestamp = curTimeSec;
RecSys.updateRecsysEntry(this.options_.videoId, 'totalPlayTime', this.watchedDuration.total);
}
}