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 'Metric key' property

Blue Mousefacfc6eb5989
diff --git a/app/pages/Project/View/components/AddAViewModal.tsx b/app/pages/Project/View/components/AddAViewModal.tsx
index 4055525f7..2da1b9608 100644
--- a/app/pages/Project/View/components/AddAViewModal.tsx
+++ b/app/pages/Project/View/components/AddAViewModal.tsx
@@ -107,34 +107,46 @@ const EditMetric = ({ metric, onChange, onDelete }: IEditMetric) => {
/>
<div className='mt-2 flex items-center justify-between'>
<Input
- label={t('project.metamapping.ev.key')}
+ className='w-[48%]'
+ label={t('project.metrics.optinalEventKey')}
value={metric.metaKey}
onChange={({ target }) => {
onChange('metaKey', target.value)
}}
/>
<Input
- label={t('project.metamapping.ev.value')}
+ className='w-[48%]'
+ label={t('project.metrics.optinalEventValue')}
value={metric.metaValue}
onChange={({ target }) => {
onChange('metaValue', target.value)
}}
/>
</div>
- <div className='mt-2'>
- <Select
- items={customEventTypes}
- keyExtractor={(item) => item.key}
- labelExtractor={(item) => item.label}
- onSelect={(selectedLabel) => {
- const key = _find(customEventTypes, ({ label }) => label === selectedLabel)?.key
-
- onChange('metaValueType', key)
+ <div className='mt-2 flex items-center justify-between'>
+ <Input
+ className='w-[48%]'
+ label={t('project.metrics.metricKey')}
+ value={metric.metricKey}
+ onChange={({ target }) => {
+ onChange('metricKey', target.value)
}}
- label={t('project.customMetricType')}
- title={activeCustomEventType}
- capitalise
/>
+ <div className='w-[48%]'>
+ <Select
+ items={customEventTypes}
+ keyExtractor={(item) => item.key}
+ labelExtractor={(item) => item.label}
+ onSelect={(selectedLabel) => {
+ const key = _find(customEventTypes, ({ label }) => label === selectedLabel)?.key
+
+ onChange('metaValueType', key)
+ }}
+ label={t('project.metrics.metricType')}
+ title={activeCustomEventType}
+ capitalise
+ />
+ </div>
</div>
</div>
)
diff --git a/app/pages/Project/View/interfaces/traffic.tsx b/app/pages/Project/View/interfaces/traffic.tsx
index 6c2fcd0bd..f275736fe 100644
--- a/app/pages/Project/View/interfaces/traffic.tsx
+++ b/app/pages/Project/View/interfaces/traffic.tsx
@@ -13,8 +13,9 @@ export enum ProjectViewCustomEventMetaValueType {
export interface IProjectViewCustomEvent {
id: string
customEventName: string
- metaKey: string
- metaValue: string
+ metaKey?: string
+ metaValue?: string
+ metricKey: string
metaValueType: ProjectViewCustomEventMetaValueType
}
@@ -42,6 +43,12 @@ export interface IProperties {
[key: string]: number
}
+export interface IMetric {
+ key: string
+ sum: number
+ avg: number
+}
+
export interface ITrafficLogResponse {
params?: IParams
chart?: {
@@ -54,4 +61,5 @@ export interface ITrafficLogResponse {
properties: IProperties
appliedFilters?: IFilter[]
timeBucket?: string[]
+ meta?: IMetric[]
}
diff --git a/public/locales/en.json b/public/locales/en.json
index d7fc47490..9ab749d13 100644
--- a/public/locales/en.json
+++ b/public/locales/en.json
@@ -784,7 +784,14 @@
"customEventsAndMetrics": "Custom events and metrics (optional)",
"addAMetric": "Add a metric",
"customEvent": "Custom event",
- "customMetricType": "Custom metric type",
+ "metrics": {
+ "xAvg": "\"{{x}}\" average",
+ "xTotal": "\"{{x}}\" total",
+ "metricKey": "Custom metric key",
+ "metricType": "Custom metric type",
+ "optinalEventKey": "Event key (optional)",
+ "optinalEventValue": "Event value (optional)"
+ },
"metaValueType": {
"decimal": "Decimal",
"integer": "Integer",