UI tweaks to Properties and Conversions (#3226)
* fix conversions fetchData limit to the right number * make Goal Conversions metric column width match Properties * add more top-margin to Details links in ListReport * add special handling for url prop in Conversions * change 'Details' button to 'More' when no additional details * fix CI * breakdown by 'path' prop instead for 404 pages * change the 'MORE' button back to 'DETAILS' But keep the option of not showing the button when there are less than 9 list entries. * capture special props in an object instead (review suggestion) * Add cloaked link to special goals list --------- Co-authored-by: Vinicius Brasil <vini@hey.com>pull/3230/head r2023.08.03-161
parent
59a82288e1
commit
373b8e8201
@ -0,0 +1,56 @@
|
||||
import React from "react"
|
||||
import Conversions from './conversions'
|
||||
import ListReport from "../reports/list"
|
||||
import { CR_METRIC } from "../reports/metrics"
|
||||
import * as url from "../../util/url"
|
||||
import * as api from "../../api"
|
||||
|
||||
const SPECIAL_GOALS = {
|
||||
'404': {title: '404 Pages', prop: 'path'},
|
||||
'Outbound Link: Click': {title: 'Outbound Links', prop: 'url'},
|
||||
'Cloaked Link: Click': {title: 'Cloaked Links', prop: 'url'},
|
||||
'File Download': {title: 'File Downloads', prop: 'url'}
|
||||
}
|
||||
|
||||
export function specialTitleWhenGoalFilter(query, defaultTitle) {
|
||||
return SPECIAL_GOALS[query.filters.goal]?.title || defaultTitle
|
||||
}
|
||||
|
||||
function SpecialPropBreakdown(props) {
|
||||
const { site, query } = props
|
||||
const prop = SPECIAL_GOALS[query.filters.goal].prop
|
||||
|
||||
function fetchData() {
|
||||
return api.get(url.apiPath(site, `/custom-prop-values/${prop}`), query)
|
||||
}
|
||||
|
||||
const getFilterFor = (listItem) => { return {'props': JSON.stringify({[prop]: listItem['name']})} }
|
||||
|
||||
return (
|
||||
<ListReport
|
||||
fetchData={fetchData}
|
||||
getFilterFor={getFilterFor}
|
||||
keyLabel={prop}
|
||||
metrics={[
|
||||
{name: 'visitors', label: 'Visitors', plot: true},
|
||||
{name: 'events', label: 'Events', hiddenOnMobile: true},
|
||||
CR_METRIC
|
||||
]}
|
||||
detailsLink={url.sitePath(site, `/custom-prop-values/${prop}`)}
|
||||
maybeHideDetails={true}
|
||||
query={query}
|
||||
color="bg-red-50"
|
||||
colMinWidth={90}
|
||||
/>
|
||||
)
|
||||
}
|
||||
|
||||
export default function GoalConversions(props) {
|
||||
const {site, query} = props
|
||||
|
||||
if (SPECIAL_GOALS[query.filters.goal]) {
|
||||
return <SpecialPropBreakdown site={site} query={props.query} />
|
||||
} else {
|
||||
return <Conversions site={site} query={props.query} />
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue