Skip to content

📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!

Added support for custom events

Blue Mouseba90b8fd2aac
diff --git a/src/pages/Project/View/Panels.jsx b/src/pages/Project/View/Panels.jsx
index 4441c7d24..4c8dda128 100644
--- a/src/pages/Project/View/Panels.jsx
+++ b/src/pages/Project/View/Panels.jsx
@@ -132,6 +132,41 @@ const Overview = ({
)
}
+const CustomEvents = ({
+ customs, chartData,
+}) => {
+ const keys = _keys(customs)
+ const uniques = _sum(chartData.uniques)
+
+ // TODO: Fix col layout
+ return (
+ <PanelContainer name='Custom events'>
+ <div className='flex justify-between'>
+ <span className='font-semibold text-lg w-4/6'>Event</span>
+ <div className='flex justify-between w-2/6'>
+ <span className='font-semibold text-lg'>Quantity</span>
+ <span className='font-semibold text-lg'>Conversion</span>
+ </div>
+ </div>
+ {_map(keys, (ev) => (
+ <div key={ev} className='flex justify-between'>
+ <span className='text-lg w-4/6'>{ev}</span>
+ <div className='flex justify-between w-2/6'>
+ <div className='text-right w-1/2'>
+ <span className='text-gray-900 text-xl'>{customs[ev]}</span>
+ </div>
+ <span className='text-gray-900 text-xl'>{(customs[ev] / uniques) * 100}%</span>
+ </div>
+ </div>
+ ))}
+ </PanelContainer>
+ )
+}
+
+CustomEvents.propTypes = {
+ customs: PropTypes.objectOf(PropTypes.number).isRequired,
+}
+
const Panel = ({
name, data, rowMapper, capitalize, linkContent,
}) => {
@@ -232,8 +267,10 @@ Panel.defaultProps = {
const PanelMemo = memo(Panel)
const OverviewMemo = memo(Overview)
+const CustomEventsMemo = memo(CustomEvents)
export {
PanelMemo as Panel,
OverviewMemo as Overview,
+ CustomEventsMemo as CustomEvents,
}
\ No newline at end of file
diff --git a/src/pages/Project/View/ViewProject.jsx b/src/pages/Project/View/ViewProject.jsx
index 32a603d8a..1b160fc03 100644
--- a/src/pages/Project/View/ViewProject.jsx
+++ b/src/pages/Project/View/ViewProject.jsx
@@ -26,7 +26,9 @@ import Button from 'ui/Button'
import Loader from 'ui/Loader'
import Dropdown from 'ui/Dropdown'
import Checkbox from 'ui/Checkbox'
-import { Panel, Overview } from './Panels'
+import {
+ Panel, Overview, CustomEvents,
+} from './Panels'
import routes from 'routes'
import { getProjectData } from 'api'
@@ -163,12 +165,13 @@ const ViewProject = ({
return
}
- const { chart, params } = data
+ const { chart, params, customs } = data
setChartData(chart)
setPanelsData({
types: _keys(params),
data: params,
+ customs,
})
const bbSettings = getSettings(chart, timeBucket, showTotal)
@@ -326,6 +329,9 @@ const ViewProject = ({
<Panel key={type} name={typeNameMapping[type]} data={panelsData.data[type]} />
)
})}
+ {!_isEmpty(panelsData.customs) && (
+ <CustomEvents customs={panelsData.customs} chartData={chartData} />
+ )}
</div>
</div>
</div>