send a few metrics to lbrytv api
This commit is contained in:
parent
b6dff10037
commit
1875c37ed3
2 changed files with 14 additions and 1 deletions
|
@ -3,6 +3,7 @@ import { Lbryio } from 'lbryinc';
|
|||
import ReactGA from 'react-ga';
|
||||
import * as Sentry from '@sentry/browser';
|
||||
import { history } from './store';
|
||||
import { SDK_HOST } from './index';
|
||||
// @if TARGET='app'
|
||||
import Native from 'native';
|
||||
import ElectronCookies from '@exponent/electron-cookies';
|
||||
|
@ -180,9 +181,11 @@ const analytics: Analytics = {
|
|||
},
|
||||
videoStartEvent: (claimId, duration) => {
|
||||
sendGaTimingEvent('Media', 'TimeToStart', Number((duration * 1000).toFixed(0)), claimId);
|
||||
sendPromMetric('time_to_start', duration);
|
||||
},
|
||||
videoBufferEvent: (claimId, currentTime) => {
|
||||
sendGaTimingEvent('Media', 'BufferTimestamp', currentTime * 1000, claimId);
|
||||
sendPromMetric('buffer');
|
||||
},
|
||||
tagFollowEvent: (tag, following, location) => {
|
||||
sendGaEvent(following ? 'Tag-Follow' : 'Tag-Unfollow', tag);
|
||||
|
@ -242,6 +245,15 @@ function sendGaTimingEvent(category: string, action: string, timeInMs: number, l
|
|||
}
|
||||
}
|
||||
|
||||
function sendPromMetric(name: string, value?: number) {
|
||||
if (IS_WEB) {
|
||||
let url = new URL(SDK_HOST + '/internal/ui_metric');
|
||||
const params = { name: name, value: value ? value.toString() : '' };
|
||||
url.search = new URLSearchParams(params).toString();
|
||||
return fetch(url);
|
||||
}
|
||||
}
|
||||
|
||||
let gaTrackers = [];
|
||||
|
||||
if (!IS_WEB) {
|
||||
|
|
|
@ -53,7 +53,8 @@ if (process.env.NODE_ENV === 'production') {
|
|||
}
|
||||
|
||||
const PROXY_PATH = 'api/v1/proxy';
|
||||
export const SDK_API_URL = `${process.env.SDK_API_URL}/${PROXY_PATH}` || `https://api.lbry.tv/${PROXY_PATH}`;
|
||||
export const SDK_HOST = `${process.env.SDK_API_URL}` || `https://api.lbry.tv`;
|
||||
export const SDK_API_URL = `${SDK_HOST}/${PROXY_PATH}`;
|
||||
|
||||
Lbry.setDaemonConnectionString(SDK_API_URL);
|
||||
|
||||
|
|
Loading…
Reference in a new issue