allow showing pageview custom data on website detail page

This commit is contained in:
Ewen Le Bihan 2023-12-17 03:01:39 +01:00
parent 46dd16260a
commit 996c02ef1a
5 changed files with 77 additions and 4 deletions

View file

@ -0,0 +1,29 @@
import useMessages from 'components/hooks/useMessages';
import MetricsTable, { MetricsTableProps } from 'components/metrics/MetricsTable';
export function PageviewCustomDataTable(props: MetricsTableProps) {
const { formatMessage, labels } = useMessages();
function renderLink({ x: field }) {
return <>{field}</>;
}
function titleize(fieldName: string) {
return fieldName
.split(/[_-]/)
.map((word, i) => (i === 0 ? word[0].toUpperCase() + word.slice(1) : word))
.join(' ');
}
return (
<MetricsTable
{...props}
title={titleize(props.fieldName)}
type="custom"
metric={formatMessage(labels.visitors)}
renderLabel={renderLink}
/>
);
}
export default PageviewCustomDataTable;