update to initial analytics url

This commit is contained in:
Dalton 2020-02-11 22:59:30 -06:00 committed by Sean Yesmunt
parent 64ed191a9d
commit 5e38108e3d
3 changed files with 15 additions and 8 deletions

View file

@ -6,6 +6,7 @@ import { history } from './store';
// @if TARGET='app'
import Native from 'native';
import ElectronCookies from '@exponent/electron-cookies';
import { generateInitialUrl } from 'util/url';
// @endif
const isProduction = process.env.NODE_ENV === 'production';
@ -253,7 +254,9 @@ analytics.pageView(window.location.pathname + window.location.search);
// @if TARGET='app'
ReactGA.set({ checkProtocolTask: null });
ReactGA.set({ location: 'https://lbry.tv' });
analytics.pageView(window.location.pathname.split('.html')[1] + window.location.search || '/');
analytics.pageView(
window.location.pathname.split('.html')[1] + window.location.search || generateInitialUrl(window.location.hash)
);
// @endif;
// Listen for url changes and report

View file

@ -14,6 +14,7 @@ import { buildSharedStateMiddleware, ACTIONS as LBRY_REDUX_ACTIONS } from 'lbry-
import { doGetSync, selectUserVerifiedEmail } from 'lbryinc';
import { getSavedPassword } from 'util/saved-passwords';
import { makeSelectClientSetting } from 'redux/selectors/settings';
import { generateInitialUrl } from 'util/url';
function isFunction(object) {
return typeof object === 'function';
@ -96,14 +97,8 @@ const persistOptions = {
let history;
// @if TARGET='app'
let initialEntry = '/';
let hash = window.location.hash;
if (hash) {
hash = hash.replace('#', '');
initialEntry = hash.startsWith('/') ? hash : '/' + hash;
}
history = createMemoryHistory({
initialEntries: [initialEntry],
initialEntries: [generateInitialUrl(window.location.hash)],
initialIndex: 0,
});
// @endif

View file

@ -61,3 +61,12 @@ exports.formatWebUrlIntoLbryUrl = (pathname, search) => {
return appLink;
};
exports.generateInitialUrl = hash => {
let url = '/';
if (hash) {
hash = hash.replace('#', '');
url = hash.startsWith('/') ? hash : '/' + hash;
}
return url;
};