2019-11-20 08:48:27 +03:00
|
|
|
import React, { useEffect } from 'react';
|
2021-11-23 12:39:09 +03:00
|
|
|
import {BrowserRouter, Switch, Route, useLocation} from "react-router-dom";
|
|
|
|
|
2019-11-19 07:30:42 +03:00
|
|
|
import Dash from './index'
|
2020-09-28 11:29:24 +03:00
|
|
|
import SourcesModal from './stats/modals/sources'
|
2019-11-19 07:30:42 +03:00
|
|
|
import ReferrersDrilldownModal from './stats/modals/referrer-drilldown'
|
|
|
|
import GoogleKeywordsModal from './stats/modals/google-keywords'
|
|
|
|
import PagesModal from './stats/modals/pages'
|
Adds entry and exit pages to Top Pages module (#712)
* Initial Pass
* Adds support for page visits counting by referrer
* Includes goal selection in entry and exit computation
* Adds goal-based entry and exit page stats, formatting, code cleanup
* Changelog
* Format
* Exit rate, visit duration, updated tests
* I keep forgetting to format :/
* Tests, last time
* Fixes double counting, exit rate >100%, relevant tests
* Fixes exit pages on filter and goal states
* Adds entry and exit filters, fixes various bugs
* Fixes discussed issues
* Format
* Fixes impossible case in tests
Originally, there were only 2 pageviews for `test-site.com`,`/` on `2019-01-01`, but that doesn't make sense when there were 3 sessions that exited on the same site/date.
* Format
* Removes boolean function parameter in favor of separate function
* Adds support for queries that use `page` filter as `entry-page`
* Format
* Makes loader/title interaction in sources report consistent
2021-02-26 12:02:37 +03:00
|
|
|
import EntryPagesModal from './stats/modals/entry-pages'
|
|
|
|
import ExitPagesModal from './stats/modals/exit-pages'
|
2021-11-23 12:39:09 +03:00
|
|
|
import ModalTable from './stats/modals/table'
|
2021-06-21 14:42:16 +03:00
|
|
|
import FilterModal from './stats/modals/filter'
|
2019-11-19 07:30:42 +03:00
|
|
|
|
2019-11-20 08:48:27 +03:00
|
|
|
function ScrollToTop() {
|
|
|
|
const location = useLocation();
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
if (location.state && location.state.scrollTop) {
|
|
|
|
window.scrollTo(0, 0);
|
|
|
|
}
|
|
|
|
}, [location]);
|
|
|
|
|
|
|
|
return null;
|
|
|
|
}
|
2019-11-19 07:30:42 +03:00
|
|
|
|
2021-06-16 15:00:07 +03:00
|
|
|
export default function Router({site, loggedIn, currentUserRole}) {
|
2019-11-19 07:30:42 +03:00
|
|
|
return (
|
|
|
|
<BrowserRouter>
|
|
|
|
<Route path="/:domain">
|
2019-11-20 08:48:27 +03:00
|
|
|
<ScrollToTop />
|
2021-06-16 15:00:07 +03:00
|
|
|
<Dash site={site} loggedIn={loggedIn} currentUserRole={currentUserRole} />
|
2019-11-19 07:30:42 +03:00
|
|
|
<Switch>
|
2021-12-20 17:10:39 +03:00
|
|
|
<Route exact path={["/:domain/sources", "/:domain/utm_mediums", "/:domain/utm_sources", "/:domain/utm_campaigns", "/:domain/utm_contents", "/:domain/utm_terms" ]}>
|
2020-09-28 11:29:24 +03:00
|
|
|
<SourcesModal site={site} />
|
2019-11-19 07:30:42 +03:00
|
|
|
</Route>
|
|
|
|
<Route exact path="/:domain/referrers/Google">
|
|
|
|
<GoogleKeywordsModal site={site} />
|
|
|
|
</Route>
|
|
|
|
<Route exact path="/:domain/referrers/:referrer">
|
|
|
|
<ReferrersDrilldownModal site={site} />
|
|
|
|
</Route>
|
|
|
|
<Route path="/:domain/pages">
|
|
|
|
<PagesModal site={site} />
|
|
|
|
</Route>
|
Adds entry and exit pages to Top Pages module (#712)
* Initial Pass
* Adds support for page visits counting by referrer
* Includes goal selection in entry and exit computation
* Adds goal-based entry and exit page stats, formatting, code cleanup
* Changelog
* Format
* Exit rate, visit duration, updated tests
* I keep forgetting to format :/
* Tests, last time
* Fixes double counting, exit rate >100%, relevant tests
* Fixes exit pages on filter and goal states
* Adds entry and exit filters, fixes various bugs
* Fixes discussed issues
* Format
* Fixes impossible case in tests
Originally, there were only 2 pageviews for `test-site.com`,`/` on `2019-01-01`, but that doesn't make sense when there were 3 sessions that exited on the same site/date.
* Format
* Removes boolean function parameter in favor of separate function
* Adds support for queries that use `page` filter as `entry-page`
* Format
* Makes loader/title interaction in sources report consistent
2021-02-26 12:02:37 +03:00
|
|
|
<Route path="/:domain/entry-pages">
|
|
|
|
<EntryPagesModal site={site} />
|
|
|
|
</Route>
|
|
|
|
<Route path="/:domain/exit-pages">
|
|
|
|
<ExitPagesModal site={site} />
|
|
|
|
</Route>
|
2019-11-19 07:30:42 +03:00
|
|
|
<Route path="/:domain/countries">
|
2021-12-31 13:16:25 +03:00
|
|
|
<ModalTable title="Top countries" site={site} endpoint={`/api/stats/${encodeURIComponent(site.domain)}/countries`} filter={{country: 'code', country_name: 'name'}} keyLabel="Country" renderIcon={renderCountryIcon} />
|
2019-11-19 07:30:42 +03:00
|
|
|
</Route>
|
2021-11-23 12:39:09 +03:00
|
|
|
<Route path="/:domain/regions">
|
2021-12-01 16:31:50 +03:00
|
|
|
<ModalTable title="Top regions" site={site} endpoint={`/api/stats/${encodeURIComponent(site.domain)}/regions`} filter={{region: 'code', region_name: 'name'}} keyLabel="Region" renderIcon={renderRegionIcon} />
|
2021-11-23 12:39:09 +03:00
|
|
|
</Route>
|
|
|
|
<Route path="/:domain/cities">
|
2021-12-09 15:21:26 +03:00
|
|
|
<ModalTable title="Top cities" site={site} endpoint={`/api/stats/${encodeURIComponent(site.domain)}/cities`} filter={{city: 'code', city_name: 'name'}} keyLabel="City" renderIcon={renderCityIcon} />
|
2021-11-23 12:39:09 +03:00
|
|
|
</Route>
|
2021-07-21 16:50:26 +03:00
|
|
|
<Route path={["/:domain/filter/:field"]}>
|
2021-06-21 14:42:16 +03:00
|
|
|
<FilterModal site={site} />
|
|
|
|
</Route>
|
2019-11-19 07:30:42 +03:00
|
|
|
</Switch>
|
|
|
|
</Route>
|
|
|
|
</BrowserRouter>
|
|
|
|
);
|
|
|
|
}
|
2021-12-01 16:31:50 +03:00
|
|
|
|
2021-12-09 15:21:26 +03:00
|
|
|
function renderCityIcon(city) {
|
|
|
|
return <span className="mr-1">{city.country_flag}</span>
|
|
|
|
}
|
|
|
|
|
2021-12-01 16:31:50 +03:00
|
|
|
function renderCountryIcon(country) {
|
|
|
|
return <span className="mr-1">{country.flag}</span>
|
|
|
|
}
|
|
|
|
|
|
|
|
function renderRegionIcon(region) {
|
|
|
|
return <span className="mr-1">{region.country_flag}</span>
|
|
|
|
}
|