Replace recsys beacon with regular network call (#1090)
Ticket: 1080 Reason: unreliable; often blocked. Additional: add auth-token, per suggestion in FYP PR.
This commit is contained in:
parent
69a9245324
commit
63f19b278d
1 changed files with 16 additions and 7 deletions
|
@ -3,7 +3,9 @@ import { selectUser } from 'redux/selectors/user';
|
|||
import { makeSelectRecommendedRecsysIdForClaimId } from 'redux/selectors/search';
|
||||
import { v4 as Uuidv4 } from 'uuid';
|
||||
import { parseURI } from 'util/lbryURI';
|
||||
import { getAuthToken } from 'util/saved-passwords';
|
||||
import * as SETTINGS from 'constants/settings';
|
||||
import { X_LBRY_AUTH_TOKEN } from 'constants/token';
|
||||
import { makeSelectClaimForUri } from 'redux/selectors/claims';
|
||||
import { selectPlayingUri, selectPrimaryUri } from 'redux/selectors/content';
|
||||
import { selectClientSetting, selectDaemonSettings } from 'redux/selectors/settings';
|
||||
|
@ -136,14 +138,21 @@ const recsys = {
|
|||
|
||||
if (recsys.entries[claimId] && shareTelemetry) {
|
||||
const data = JSON.stringify(recsys.entries[claimId]);
|
||||
try {
|
||||
navigator.sendBeacon(recsysEndpoint, data);
|
||||
|
||||
if (!isTentative) {
|
||||
delete recsys.entries[claimId];
|
||||
}
|
||||
} catch (error) {
|
||||
console.log('no beacon for you', error);
|
||||
}
|
||||
|
||||
return fetch(recsysEndpoint, {
|
||||
method: 'POST',
|
||||
headers: {
|
||||
[X_LBRY_AUTH_TOKEN]: getAuthToken(),
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
body: data,
|
||||
}).catch((err) => {
|
||||
console.log('RECSYS: failed to send entry', err);
|
||||
});
|
||||
}
|
||||
recsys.log('sendRecsysEntry', claimId);
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue