Filter domain from referrers.

This commit is contained in:
Mike Cao 2020-08-07 02:46:21 -07:00
parent 00e232fee8
commit 0a411a9ad6
6 changed files with 15 additions and 8 deletions

View File

@ -77,7 +77,7 @@ export default function WebsiteDetails({ websiteId, defaultDateRange = '7day' })
websiteId={websiteId}
startDate={startDate}
endDate={endDate}
dataFilter={refFilter}
dataFilter={refFilter(data.domain)}
/>
</div>
</div>

View File

@ -47,7 +47,7 @@ export default function UserButton() {
return (
<div ref={ref} className={styles.container}>
<div onClick={() => setShowMenu(state => !state)}>
<Icon icon={<User />} size="L" className={styles.icon} />
<Icon icon={<User />} size="L" />
<Icon icon={<Chevron />} size="S" />
</div>
{showMenu && <Menu options={menuOptions} onSelect={handleSelect} align="right" />}

View File

@ -4,10 +4,6 @@
cursor: pointer;
}
.icon {
margin-right: 8px;
}
.username {
border-bottom: 1px solid var(--gray500);
}

View File

@ -1,3 +1,4 @@
import escape from 'escape-string-regexp';
import { BROWSERS, ISO_COUNTRIES, DEVICES } from './constants';
export const browserFilter = data =>
@ -5,8 +6,12 @@ export const browserFilter = data =>
export const urlFilter = data => data.filter(({ x }) => x !== '' && !x.startsWith('#'));
export const refFilter = data =>
data.filter(({ x }) => x !== '' && !x.startsWith('/') && !x.startsWith('#'));
export const refFilter = domain => data => {
const regex = new RegExp(escape(domain));
return data.filter(
({ x }) => x !== '' && !x.startsWith('/') && !x.startsWith('#') && !regex.test(x),
);
};
export const deviceFilter = data =>
data.map(({ x, ...props }) => ({ x: DEVICES[x] || x, ...props }));

View File

@ -50,6 +50,7 @@
"date-fns-tz": "^1.0.10",
"detect-browser": "^5.1.1",
"dotenv": "^8.2.0",
"escape-string-regexp": "^4.0.0",
"formik": "^2.1.5",
"geolite2-redist": "^1.0.7",
"is-localhost-ip": "^1.4.0",

View File

@ -3605,6 +3605,11 @@ escape-string-regexp@^1.0.2, escape-string-regexp@^1.0.5:
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz#1b61c0562190a8dff6ae3bb2cf0200ca130b86d4"
integrity sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=
escape-string-regexp@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
eslint-config-prettier@^6.11.0:
version "6.11.0"
resolved "https://registry.yarnpkg.com/eslint-config-prettier/-/eslint-config-prettier-6.11.0.tgz#f6d2238c1290d01c859a8b5c1f7d352a0b0da8b1"