From f7a7c22f93ba6f437298f0bcb9abfb5d496b1b5b Mon Sep 17 00:00:00 2001 From: jkrumm Date: Mon, 22 Jan 2024 19:23:14 +0100 Subject: [PATCH] feat(analytics): behaviour in analytics --- package-lock.json | 7 ++++++ package.json | 1 + src/pages/analytics.tsx | 28 +++++++++++++++++----- src/server/api/routers/analytics.router.ts | 5 ++-- tailwind.config.ts | 2 +- 5 files changed, 34 insertions(+), 9 deletions(-) diff --git a/package-lock.json b/package-lock.json index 884f450..bee2a63 100644 --- a/package-lock.json +++ b/package-lock.json @@ -70,6 +70,7 @@ "prettier": "^3.2.4", "prettier-plugin-tailwindcss": "^0.5.11", "release-it": "^17.0.1", + "tailwind-scrollbar-hide": "^1.1.7", "tailwindcss": "^3.4.1", "typescript": "^5.3.3" } @@ -14105,6 +14106,12 @@ "resolved": "https://registry.npmjs.org/tabbable/-/tabbable-6.2.0.tgz", "integrity": "sha512-Cat63mxsVJlzYvN51JmVXIgNoUokrIaT2zLclCXjRd8boZ0004U4KCs/sToJ75C6sdlByWxpYnb5Boif1VSFew==" }, + "node_modules/tailwind-scrollbar-hide": { + "version": "1.1.7", + "resolved": "https://registry.npmjs.org/tailwind-scrollbar-hide/-/tailwind-scrollbar-hide-1.1.7.tgz", + "integrity": "sha512-X324n9OtpTmOMqEgDUEA/RgLrNfBF/jwJdctaPZDzB3mppxJk7TLIDmOreEDm1Bq4R9LSPu4Epf8VSdovNU+iA==", + "dev": true + }, "node_modules/tailwindcss": { "version": "3.4.1", "resolved": "https://registry.npmjs.org/tailwindcss/-/tailwindcss-3.4.1.tgz", diff --git a/package.json b/package.json index e10e290..fa9f90f 100644 --- a/package.json +++ b/package.json @@ -86,6 +86,7 @@ "prettier": "^3.2.4", "prettier-plugin-tailwindcss": "^0.5.11", "release-it": "^17.0.1", + "tailwind-scrollbar-hide": "^1.1.7", "tailwindcss": "^3.4.1", "typescript": "^5.3.3" }, diff --git a/src/pages/analytics.tsx b/src/pages/analytics.tsx index e3e6175..1080dd1 100644 --- a/src/pages/analytics.tsx +++ b/src/pages/analytics.tsx @@ -64,7 +64,7 @@ const Analytics = () => {
-

Site Traffic

+

Traffic

{ valueAppend="%" /> -

Vote analytics

+

Votes

{ value={votes.avg_duration_per_vote} /> -

Historical data

+

Historical

-

Location data

+

Behaviour

+ + + + +

Location

+ { data={location_and_user_agent.city} /> -

User Agent data

+

User Agent

{ const sortedData = Object.entries(data) .sort((a, b) => b[1] - a[1]) // Sort by value in descending order + .slice(0, 30) // Get the first 30 entries .map(([name, value]) => ({ name, value })); // Map to objects with name and value const highestValue = sortedData[0]?.value ?? 0; // Get the highest value @@ -189,7 +205,7 @@ export const AnalyticsCard = ({ {headline} - + {sortedData.map((item, index) => (
= {}; Object.entries(analytics.location_and_user_agent.country).forEach( ([country, count]) => { - const countryName = + const countryName = `${country} - ${ countryRegions.find((c) => c.countryShortCode === country) - ?.countryName ?? country; + ?.countryName ?? country + }`; countryCounts[countryName] = count; }, ); diff --git a/tailwind.config.ts b/tailwind.config.ts index f6e0dde..19527c9 100644 --- a/tailwind.config.ts +++ b/tailwind.config.ts @@ -6,5 +6,5 @@ export default { theme: { extend: {}, }, - plugins: [], + plugins: [require('tailwind-scrollbar-hide')], } satisfies Config;