diff --git a/components/metrics/OSTable.js b/components/metrics/OSTable.js index 0577b419..2b9b4500 100644 --- a/components/metrics/OSTable.js +++ b/components/metrics/OSTable.js @@ -1,5 +1,6 @@ import React from 'react'; import MetricsTable from './MetricsTable'; +import { osFilter } from 'lib/filters'; export default function OSTable({ websiteId, startDate, endDate, limit, onExpand }) { return ( @@ -11,6 +12,7 @@ export default function OSTable({ websiteId, startDate, endDate, limit, onExpand startDate={startDate} endDate={endDate} limit={limit} + dataFilter={osFilter} onExpand={onExpand} /> ); diff --git a/lib/filters.js b/lib/filters.js index dac64312..6c5a0294 100644 --- a/lib/filters.js +++ b/lib/filters.js @@ -2,9 +2,6 @@ import firstBy from 'thenby'; import { BROWSERS, ISO_COUNTRIES, DEVICES } from './constants'; import { removeTrailingSlash } from './format'; -export const browserFilter = data => - data.map(({ x, ...props }) => ({ x: BROWSERS[x] || x, ...props })); - export const urlFilter = (data, { domain, raw }) => { const isValidUrl = url => { return url !== '' && !url.startsWith('#'); @@ -114,11 +111,16 @@ export const refFilter = (data, { domain, domainOnly, raw }) => { .sort(firstBy('y', -1).thenBy('x')); }; +export const browserFilter = data => + data.map(({ x, y }) => ({ x: BROWSERS[x], y })).filter(({ x }) => x); + +export const osFilter = data => data.filter(({ x }) => x); + export const deviceFilter = data => - data.map(({ x, ...props }) => ({ x: DEVICES[x] || x, ...props })); + data.map(({ x, y }) => ({ x: DEVICES[x], y })).filter(({ x }) => x); export const countryFilter = data => - data.map(({ x, ...props }) => ({ x: ISO_COUNTRIES[x] || x, ...props })); + data.map(({ x, y }) => ({ x: ISO_COUNTRIES[x], y })).filter(({ x }) => x); export const percentFilter = data => { const total = data.reduce((n, { y }) => n + y, 0);