update metrics url

This commit is contained in:
Alex Grintsvayg 2020-03-23 17:16:28 -04:00
parent 6e953c098c
commit ba1cdd3882
No known key found for this signature in database
GPG key ID: AEB3F089F86A22B5
2 changed files with 11 additions and 7 deletions

View file

@ -3,7 +3,7 @@ import { Lbryio } from 'lbryinc';
import ReactGA from 'react-ga'; import ReactGA from 'react-ga';
import * as Sentry from '@sentry/browser'; import * as Sentry from '@sentry/browser';
import { history } from './store'; import { history } from './store';
import { SDK_HOST } from './index'; import { SDK_API_PATH } from './index';
// @if TARGET='app' // @if TARGET='app'
import Native from 'native'; import Native from 'native';
import ElectronCookies from '@exponent/electron-cookies'; import ElectronCookies from '@exponent/electron-cookies';
@ -247,7 +247,7 @@ function sendGaTimingEvent(category: string, action: string, timeInMs: number, l
function sendPromMetric(name: string, value?: number) { function sendPromMetric(name: string, value?: number) {
if (IS_WEB) { if (IS_WEB) {
let url = new URL(SDK_HOST + '/internal/ui_metric'); let url = new URL(SDK_API_PATH + '/metric/ui');
const params = { name: name, value: value ? value.toString() : '' }; const params = { name: name, value: value ? value.toString() : '' };
url.search = new URLSearchParams(params).toString(); url.search = new URLSearchParams(params).toString();
return fetch(url); return fetch(url);

View file

@ -52,11 +52,15 @@ if (process.env.NODE_ENV === 'production') {
}); });
} }
const PROXY_PATH = 'api/v1/proxy'; if (process.env.SDK_API_URL) {
export const SDK_HOST = `${process.env.SDK_API_URL}` || `https://api.lbry.tv`; console.warn('SDK_API_URL env var is deprecated. Use sdkAPIHost instead');
export const SDK_API_URL = `${SDK_HOST}/${PROXY_PATH}`; }
Lbry.setDaemonConnectionString(SDK_API_URL); const sdkAPIHost = `${process.env.SDK_API_HOST}` || `${process.env.SDK_API_URL}` || `https://api.lbry.tv`;
export const SDK_API_PATH = `${sdkAPIHost}/api/v1`;
const proxyURL = `${SDK_API_PATH}/proxy`;
Lbry.setDaemonConnectionString(proxyURL);
Lbry.setOverride( Lbry.setOverride(
'publish', 'publish',
@ -64,7 +68,7 @@ Lbry.setOverride(
new Promise((resolve, reject) => { new Promise((resolve, reject) => {
apiPublishCallViaWeb( apiPublishCallViaWeb(
apiCall, apiCall,
SDK_API_URL, proxyURL,
Lbry.getApiRequestHeaders() && Object.keys(Lbry.getApiRequestHeaders()).includes(X_LBRY_AUTH_TOKEN) Lbry.getApiRequestHeaders() && Object.keys(Lbry.getApiRequestHeaders()).includes(X_LBRY_AUTH_TOKEN)
? Lbry.getApiRequestHeaders()[X_LBRY_AUTH_TOKEN] ? Lbry.getApiRequestHeaders()[X_LBRY_AUTH_TOKEN]
: '', : '',