Merge pull request #871 from cywio/remove-realtime-metrics

Remove comparison metrics from realtime header
This commit is contained in:
Mike Cao 2021-12-03 20:03:04 -08:00 committed by GitHub
commit e572049cc4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 695 additions and 175 deletions

View File

@ -4,7 +4,7 @@
"es2020": true, "es2020": true,
"node": true "node": true
}, },
"extends": ["eslint:recommended", "plugin:react/recommended", "prettier"], "extends": ["eslint:recommended", "plugin:react/recommended", "prettier", "next"],
"parserOptions": { "parserOptions": {
"ecmaFeatures": { "ecmaFeatures": {
"jsx": true "jsx": true

2
.gitignore vendored
View File

@ -25,7 +25,7 @@
.idea .idea
*.iml *.iml
*.log *.log
.vscode/* /.vscode/
# debug # debug
npm-debug.log* npm-debug.log*

4
.husky/pre-commit Executable file
View File

@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"
npx lint-staged

View File

@ -24,7 +24,7 @@ RUN yarn next telemetry disable
RUN yarn build RUN yarn build
# Production image # Production image
FROM node:12.18-alpine AS production FROM node:12.22-alpine AS production
WORKDIR /app WORKDIR /app
# Copy cached dependencies # Copy cached dependencies

View File

@ -18,7 +18,7 @@ import Bars from 'assets/bars.svg';
export default function Header() { export default function Header() {
const user = useSelector(state => state.user); const user = useSelector(state => state.user);
const [active, setActive] = useState(false); const [active, setActive] = useState(false);
const { locale, dir } = useLocale(); const { dir } = useLocale();
function handleClick() { function handleClick() {
setActive(state => !state); setActive(state => !state);

View File

@ -15,7 +15,7 @@ export default function FilterTags({ params, onClick }) {
return null; return null;
} }
return ( return (
<div className={styles.tag}> <div key={key} className={styles.tag}>
<Button icon={<Times />} onClick={() => onClick(key)} variant="action" iconRight> <Button icon={<Times />} onClick={() => onClick(key)} variant="action" iconRight>
{`${key}: ${params[key]}`} {`${key}: ${params[key]}`}
</Button> </Button>

View File

@ -9,6 +9,7 @@ const MetricCard = ({
label, label,
reverseColors = false, reverseColors = false,
format = formatNumber, format = formatNumber,
hideComparison = false,
}) => { }) => {
const props = useSpring({ x: Number(value) || 0, from: { x: 0 } }); const props = useSpring({ x: Number(value) || 0, from: { x: 0 } });
const changeProps = useSpring({ x: Number(change) || 0, from: { x: 0 } }); const changeProps = useSpring({ x: Number(change) || 0, from: { x: 0 } });
@ -18,8 +19,8 @@ const MetricCard = ({
<animated.div className={styles.value}>{props.x.interpolate(x => format(x))}</animated.div> <animated.div className={styles.value}>{props.x.interpolate(x => format(x))}</animated.div>
<div className={styles.label}> <div className={styles.label}>
{label} {label}
{~~change === 0 && <span className={styles.change}>{format(0)}</span>} {~~change === 0 && !hideComparison && <span className={styles.change}>{format(0)}</span>}
{~~change !== 0 && ( {~~change !== 0 && !hideComparison && (
<animated.span <animated.span
className={`${styles.change} ${ className={`${styles.change} ${
change >= 0 change >= 0

View File

@ -30,18 +30,22 @@ export default function RealtimeHeader({ websites, data, websiteId, onSelect })
<MetricCard <MetricCard
label={<FormattedMessage id="metrics.views" defaultMessage="Views" />} label={<FormattedMessage id="metrics.views" defaultMessage="Views" />}
value={pageviews.length} value={pageviews.length}
hideComparison
/> />
<MetricCard <MetricCard
label={<FormattedMessage id="metrics.visitors" defaultMessage="Visitors" />} label={<FormattedMessage id="metrics.visitors" defaultMessage="Visitors" />}
value={sessions.length} value={sessions.length}
hideComparison
/> />
<MetricCard <MetricCard
label={<FormattedMessage id="metrics.events" defaultMessage="Events" />} label={<FormattedMessage id="metrics.events" defaultMessage="Events" />}
value={events.length} value={events.length}
hideComparison
/> />
<MetricCard <MetricCard
label={<FormattedMessage id="metrics.countries" defaultMessage="Countries" />} label={<FormattedMessage id="metrics.countries" defaultMessage="Countries" />}
value={countries.length} value={countries.length}
hideComparison
/> />
</div> </div>
</> </>

View File

@ -427,7 +427,7 @@ export function getSessionMetrics(website_id, start_at, end_at, field, filters =
export function getPageviewMetrics(website_id, start_at, end_at, field, table, filters = {}) { export function getPageviewMetrics(website_id, start_at, end_at, field, table, filters = {}) {
const params = [website_id, start_at, end_at]; const params = [website_id, start_at, end_at];
const { domain, url, ref } = filters; const { domain, url } = filters;
let domainFilter = ''; let domainFilter = '';
let urlFilter = ''; let urlFilter = '';

View File

@ -7,6 +7,9 @@ module.exports = {
FORCE_SSL: !!process.env.FORCE_SSL, FORCE_SSL: !!process.env.FORCE_SSL,
}, },
basePath: process.env.BASE_PATH, basePath: process.env.BASE_PATH,
eslint: {
ignoreDuringBuilds: true,
},
webpack(config) { webpack(config) {
config.module.rules.push({ config.module.rules.push({
test: /\.svg$/, test: /\.svg$/,

View File

@ -1,6 +1,6 @@
{ {
"name": "umami", "name": "umami",
"version": "1.24.0", "version": "1.24.1",
"description": "A simple, fast, website analytics alternative to Google Analytics. ", "description": "A simple, fast, website analytics alternative to Google Analytics. ",
"author": "Mike Cao <mike@mikecao.com>", "author": "Mike Cao <mike@mikecao.com>",
"license": "MIT", "license": "MIT",
@ -35,7 +35,9 @@
"download-country-names": "node scripts/download-country-names.js", "download-country-names": "node scripts/download-country-names.js",
"loadtest": "node scripts/loadtest.js", "loadtest": "node scripts/loadtest.js",
"loadtest:medium": "node scripts/loadtest.js --weight=medium", "loadtest:medium": "node scripts/loadtest.js --weight=medium",
"loadtest:heavy": "node scripts/loadtest.js --weight=heavy --verbose" "loadtest:heavy": "node scripts/loadtest.js --weight=heavy --verbose",
"lint": "next lint --quiet",
"prepare": "husky install"
}, },
"lint-staged": { "lint-staged": {
"**/*.js": [ "**/*.js": [
@ -50,11 +52,6 @@
"prettier --write" "prettier --write"
] ]
}, },
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"dependencies": { "dependencies": {
"@fontsource/inter": "4.5.0", "@fontsource/inter": "4.5.0",
"@prisma/client": "2.29.1", "@prisma/client": "2.29.1",
@ -107,14 +104,14 @@
"cross-env": "^7.0.3", "cross-env": "^7.0.3",
"del": "^6.0.0", "del": "^6.0.0",
"dotenv-cli": "^4.0.0", "dotenv-cli": "^4.0.0",
"eslint": "^8.1.0", "eslint": "^7.32.0",
"eslint-config-next": "^12.0.1", "eslint-config-next": "^12.0.1",
"eslint-config-prettier": "^8.3.0", "eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0", "eslint-plugin-prettier": "^4.0.0",
"eslint-plugin-react": "^7.24.0", "eslint-plugin-react": "^7.24.0",
"eslint-plugin-react-hooks": "^4.2.0", "eslint-plugin-react-hooks": "^4.2.0",
"extract-react-intl-messages": "^4.1.1", "extract-react-intl-messages": "^4.1.1",
"husky": "^7.0.4", "husky": "^7.0.0",
"lint-staged": "^11.0.0", "lint-staged": "^11.0.0",
"loadtest": "5.1.2", "loadtest": "5.1.2",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
@ -129,7 +126,7 @@
"rollup": "^2.48.0", "rollup": "^2.48.0",
"rollup-plugin-hashbang": "^2.2.2", "rollup-plugin-hashbang": "^2.2.2",
"rollup-plugin-terser": "^7.0.2", "rollup-plugin-terser": "^7.0.2",
"stylelint": "^14.0.1", "stylelint": "^13.13.0",
"stylelint-config-css-modules": "^2.2.0", "stylelint-config-css-modules": "^2.2.0",
"stylelint-config-prettier": "^9.0.3", "stylelint-config-prettier": "^9.0.3",
"stylelint-config-recommended": "^5.0.0", "stylelint-config-recommended": "^5.0.0",

825
yarn.lock

File diff suppressed because it is too large Load Diff