From ba1cdd3882739f3aab6ea8c19bdb1ca7b456c035 Mon Sep 17 00:00:00 2001 From: Alex Grintsvayg Date: Mon, 23 Mar 2020 17:16:28 -0400 Subject: [PATCH] update metrics url --- ui/analytics.js | 4 ++-- ui/index.jsx | 14 +++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/ui/analytics.js b/ui/analytics.js index e53cbcbc6..8903badb6 100644 --- a/ui/analytics.js +++ b/ui/analytics.js @@ -3,7 +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'; +import { SDK_API_PATH } from './index'; // @if TARGET='app' import Native from 'native'; 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) { 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() : '' }; url.search = new URLSearchParams(params).toString(); return fetch(url); diff --git a/ui/index.jsx b/ui/index.jsx index e28a5870a..23df45a73 100644 --- a/ui/index.jsx +++ b/ui/index.jsx @@ -52,11 +52,15 @@ if (process.env.NODE_ENV === 'production') { }); } -const PROXY_PATH = 'api/v1/proxy'; -export const SDK_HOST = `${process.env.SDK_API_URL}` || `https://api.lbry.tv`; -export const SDK_API_URL = `${SDK_HOST}/${PROXY_PATH}`; +if (process.env.SDK_API_URL) { + console.warn('SDK_API_URL env var is deprecated. Use sdkAPIHost instead'); +} -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( 'publish', @@ -64,7 +68,7 @@ Lbry.setOverride( new Promise((resolve, reject) => { apiPublishCallViaWeb( apiCall, - SDK_API_URL, + proxyURL, Lbry.getApiRequestHeaders() && Object.keys(Lbry.getApiRequestHeaders()).includes(X_LBRY_AUTH_TOKEN) ? Lbry.getApiRequestHeaders()[X_LBRY_AUTH_TOKEN] : '',