Skip to content

armgit / dub

Public Imported from GitHub
0

The modern link attribution platform. Loved by world-class engineering teams at Twilio, Zillow, Jobber, Vercel, Raycast, and more.

Added locations panel :smile:

Steven Tey2253825731fb
diff --git a/components/shared/badge-select.tsx b/components/shared/badge-select.tsx
new file mode 100644
index 0000000000..c8f90e3372
--- /dev/null
+++ b/components/shared/badge-select.tsx
@@ -0,0 +1,29 @@
+import { LocationType } from "@/lib/stats";
+
+export default function BadgeSelect({
+ options,
+ selected,
+ selectAction,
+}: {
+ options: string[];
+ selected: string;
+ selectAction: (option: string) => void;
+}) {
+ return (
+ <div className="relative inline-flex items-center space-x-3">
+ {options.map((option) => (
+ <button
+ key={option}
+ className={`${
+ option === selected
+ ? "bg-gray-200 dark:bg-gray-700 text-gray-800 dark:text-gray-200"
+ : "bg-gray-50 dark:bg-gray-900 hover:bg-gray-100 dark:hover:bg-gray-800 text-gray-600 dark:text-gray-400"
+ } px-3 py-1 rounded-md text-sm font-medium capitalize active:scale-90 transition-all duration-75`}
+ onClick={() => selectAction(option)}
+ >
+ {option}
+ </button>
+ ))}
+ </div>
+ );
+}
diff --git a/components/stats/charts/bar.tsx b/components/stats/charts/bar.tsx
index 3f7a9f8c42..77a6d316ca 100644
--- a/components/stats/charts/bar.tsx
+++ b/components/stats/charts/bar.tsx
@@ -52,7 +52,7 @@ const BarChart = ({
}, [screenWidth, screenHeight]);
const router = useRouter();
- const interval = (router.query.interval as IntervalProps) || "24h";
+ const interval = (router.query.interval as IntervalProps) || "7d";
const xScale = useMemo(() => {
return scaleBand({
diff --git a/components/stats/charts/pie.tsx b/components/stats/charts/pie.tsx
index 6a19360033..86c33d0383 100644
--- a/components/stats/charts/pie.tsx
+++ b/components/stats/charts/pie.tsx
@@ -1,3 +1,40 @@
+import { useState } from "react";
+import Pie, { ProvidedProps, PieArcDatum } from "@visx/shape/lib/shapes/Pie";
+
export default function PieChart() {
- return <div></div>;
+ const [width, height] = [350, 350];
+
+ const [selectedBrowser, setSelectedBrowser] = useState<string | null>(null);
+
+ const donutThickness = 50;
+
+ return (
+ <figure>
+ <svg width={width} height={height}>
+ {/* <Pie
+ data={
+ selectedBrowser ? browsers.filter(({ label }) => label === selectedBrowser) : browsers
+ }
+ pieValue={usage}
+ outerRadius={radius}
+ innerRadius={radius - donutThickness}
+ cornerRadius={3}
+ padAngle={0.005}
+ >
+ {(pie) => (
+ <AnimatedPie<BrowserUsage>
+ {...pie}
+ animate={animate}
+ getKey={(arc) => arc.data.label}
+ onClickDatum={({ data: { label } }) =>
+ animate &&
+ setSelectedBrowser(selectedBrowser && selectedBrowser === label ? null : label)
+ }
+ getColor={(arc) => getBrowserColor(arc.data.label)}
+ />
+ )}
+ </Pie> */}
+ </svg>
+ </figure>
+ );
}
diff --git a/components/stats/devices.tsx b/components/stats/devices.tsx
index b752db7ada..a36e397b63 100644
--- a/components/stats/devices.tsx
+++ b/components/stats/devices.tsx
@@ -1,47 +1,12 @@
-import { useState } from "react";
-import Pie, { ProvidedProps, PieArcDatum } from "@visx/shape/lib/shapes/Pie";
+import PieChart from "@/components/stats/charts/pie";
export default function Devices() {
- const [width, height] = [350, 350];
-
- const [selectedBrowser, setSelectedBrowser] = useState<string | null>(null);
-
- if (width < 10) return null;
-
- const donutThickness = 50;
-
return (
<div className="bg-white dark:bg-black px-7 py-5 shadow-lg dark:shadow-none rounded-lg border border-gray-100 dark:border-gray-600">
<div className="mb-5 text-left">
<h1 className="text-2xl dark:text-white font-semibold">Devices</h1>
+ <PieChart />
</div>
- <figure>
- <svg width={width} height={height}>
- {/* <Pie
- data={
- selectedBrowser ? browsers.filter(({ label }) => label === selectedBrowser) : browsers
- }
- pieValue={usage}
- outerRadius={radius}
- innerRadius={radius - donutThickness}
- cornerRadius={3}
- padAngle={0.005}
- >
- {(pie) => (
- <AnimatedPie<BrowserUsage>
- {...pie}
- animate={animate}
- getKey={(arc) => arc.data.label}
- onClickDatum={({ data: { label } }) =>
- animate &&
- setSelectedBrowser(selectedBrowser && selectedBrowser === label ? null : label)
- }
- getColor={(arc) => getBrowserColor(arc.data.label)}
- />
- )}
- </Pie> */}
- </svg>
- </figure>
</div>
);
}
diff --git a/components/stats/index.tsx b/components/stats/index.tsx
index 287d38713d..c4b6dad0af 100644
--- a/components/stats/index.tsx
+++ b/components/stats/index.tsx
@@ -2,6 +2,7 @@ import { StatsProps, dummyData } from "@/lib/stats";
import Clicks from "@/components/stats/clicks";
import Toggle from "@/components/stats/toggle";
import Devices from "@/components/stats/devices";
+import Locations from "@/components/stats/locations";
import useSWR from "swr";
import { fetcher } from "@/lib/utils";
import { useRouter } from "next/router";
@@ -27,7 +28,7 @@ export default function Stats() {
<div className="max-w-4xl mx-auto grid gap-5">
<Clicks data={data!} isValidating={isValidating} />
<div className="grid grid-cols-1 sm:grid-cols-2 gap-5">
- <Devices />
+ <Locations data={data!} />
<Devices />
</div>
</div>
diff --git a/components/stats/locations.tsx b/components/stats/locations.tsx
new file mode 100644
index 0000000000..83690b61f9
--- /dev/null
+++ b/components/stats/locations.tsx
@@ -0,0 +1,61 @@
+import { StatsProps, processLocationData, LocationType } from "@/lib/stats";
+import BadgeSelect from "@/components/shared/badge-select";
+import { nFormatter } from "@/lib/utils";
+import { useState } from "react";
+import { motion } from "framer-motion";
+import { LoadingDots } from "../shared/icons";
+
+export default function Locations({ data }: { data: StatsProps }) {
+ const [type, setType] = useState<LocationType>("country");
+
+ return (
+ <div className="bg-white dark:bg-black px-7 py-5 shadow-lg dark:shadow-none rounded-lg border border-gray-100 dark:border-gray-600">
+ <div className="mb-5 flex justify-between">
+ <h1 className="text-xl dark:text-white font-semibold">Locations</h1>
+ <BadgeSelect
+ options={["country", "city"]}
+ selected={type}
+ // @ts-ignore
+ selectAction={setType}
+ />
+ </div>
+ <div className="grid gap-4">
+ {data.locationData ? (
+ processLocationData(data.locationData, type).map(
+ ({ display, code, count }) => (
+ <div className="flex justify-between items-center">
+ <div className="relative flex items-center z-10 w-full max-w-[calc(100%-3rem)]">
+ <span className="flex space-x-2 px-2 items-center z-10">
+ <img
+ src={`https://flag.vercel.app/l/${code}.svg`}
+ className="w-4 h-4"
+ />
+ <p className="text-gray-800 dark:text-gray-200 text-sm">
+ {display}
+ </p>
+ </span>
+ <motion.div
+ style={{
+ width: `${(count / data.totalClicks) * 100}%`,
+ }}
+ className="bg-orange-100 dark:bg-orange-900 absolute h-8 origin-left"
+ transition={{ ease: "easeOut", duration: 0.3 }}
+ initial={{ transform: "scaleX(0)" }}
+ animate={{ transform: "scaleX(1)" }}
+ />
+ </div>
+ <p className="text-gray-600 dark:text-gray-400 text-sm">
+ {nFormatter(count)}
+ </p>
+ </div>
+ )
+ )
+ ) : (
+ <div className="h-96 w-full flex justify-center items-center">
+ <LoadingDots color="#71717A" />
+ </div>
+ )}
+ </div>
+ </div>
+ );
+}
diff --git a/components/stats/toggle.tsx b/components/stats/toggle.tsx
index 386578d8c0..32649be94b 100644
--- a/components/stats/toggle.tsx
+++ b/components/stats/toggle.tsx
@@ -4,12 +4,13 @@ import { linkConstructor } from "@/lib/utils";
import useScroll from "@/lib/hooks/use-scroll";
import { useStatsContext } from "@/components/stats/context";
import { ExpandingArrow } from "@/components/shared/icons";
+import BadgeSelect from "@/components/shared/badge-select";
import { IntervalProps, StatsProps } from "@/lib/stats";
export default function Toggle({ data }: { data: StatsProps }) {
const router = useRouter();
const key = (router.query.key as string) || data?.key;
- const currentInterval = (router.query.interval as IntervalProps) || "24h";
+ const currentInterval = (router.query.interval as IntervalProps) || "7d";
const { atTop: atContextTop } = useStatsContext();
const atTop = useScroll(144) || atContextTop;
@@ -32,33 +33,26 @@ export default function Toggle({ data }: { data: StatsProps }) {
</a>
<ExpandingArrow className="w-5 h-5" />
</div>
- <div className="flex space-x-1 p-1 rounded-md shadow-md dark:shadow-none border bg-white dark:bg-black border-gray-100 dark:border-gray-600">
- {INTERVALS.map((interval) => (
- <button
- key={interval}
- className={`${
- currentInterval === interval
- ? "bg-blue-50 dark:bg-gray-600"
- : ""
- } w-14 py-1.5 text-sm dark:text-white rounded-md`}
- onClick={() => {
- router.push(
- {
- query: {
- ...router.query,
- interval,
- },
+ <div className="px-3 py-1 rounded-md shadow-md dark:shadow-none border bg-white dark:bg-black border-gray-100 dark:border-gray-600">
+ <BadgeSelect
+ options={INTERVALS}
+ selected={currentInterval}
+ // @ts-ignore
+ selectAction={(interval) => {
+ router.push(
+ {
+ query: {
+ ...router.query,
+ interval,
},
- `/stats/${encodeURI(
- router.query.key as string
- )}?interval=${interval}`,
- { shallow: true }
- );
- }}
- >
- {interval}
- </button>
- ))}
+ },
+ `/stats/${encodeURI(
+ router.query.key as string
+ )}?interval=${interval}`,
+ { shallow: true }
+ );
+ }}
+ />
</div>
</div>
</div>
diff --git a/lib/constants.ts b/lib/constants.ts
index d60bef528c..54c5e7a7c5 100644
--- a/lib/constants.ts
+++ b/lib/constants.ts
@@ -7,3 +7,256 @@ export const LOCALHOST_GEO_DATA = {
};
export const INTERVALS = ["1h", "24h", "7d", "30d"];
+
+export const COUNTRIES: { [key: string]: string } = {
+ AF: "Afghanistan",
+ AL: "Albania",
+ DZ: "Algeria",
+ AS: "American Samoa",
+ AD: "Andorra",
+ AO: "Angola",
+ AI: "Anguilla",
+ AQ: "Antarctica",
+ AG: "Antigua and Barbuda",
+ AR: "Argentina",
+ AM: "Armenia",
+ AW: "Aruba",
+ AU: "Australia",
+ AT: "Austria",
+ AZ: "Azerbaijan",
+ BS: "Bahamas",
+ BH: "Bahrain",
+ BD: "Bangladesh",
+ BB: "Barbados",
+ BY: "Belarus",
+ BE: "Belgium",
+ BZ: "Belize",
+ BJ: "Benin",
+ BM: "Bermuda",
+ BT: "Bhutan",
+ BO: "Bolivia",
+ BA: "Bosnia and Herzegovina",
+ BW: "Botswana",
+ BV: "Bouvet Island",
+ BR: "Brazil",
+ IO: "British Indian Ocean Territory",
+ BN: "Brunei Darussalam",
+ BG: "Bulgaria",
+ BF: "Burkina Faso",
+ BI: "Burundi",
+ KH: "Cambodia",
+ CM: "Cameroon",
+ CA: "Canada",
+ CV: "Cape Verde",
+ KY: "Cayman Islands",
+ CF: "Central African Republic",
+ TD: "Chad",
+ CL: "Chile",
+ CN: "China",
+ CX: "Christmas Island",
+ CC: "Cocos (Keeling) Islands",
+ CO: "Colombia",
+ KM: "Comoros",
+ CG: "Congo (Republic)",
+ CD: "Congo (Democratic Republic)",
+ CK: "Cook Islands",
+ CR: "Costa Rica",
+ CI: "Ivory Coast",
+ HR: "Croatia",
+ CU: "Cuba",
+ CY: "Cyprus",
+ CZ: "Czech Republic",
+ DK: "Denmark",
+ DJ: "Djibouti",
+ DM: "Dominica",
+ DO: "Dominican Republic",
+ EC: "Ecuador",
+ EG: "Egypt",
+ SV: "El Salvador",
+ GQ: "Equatorial Guinea",
+ ER: "Eritrea",
+ EE: "Estonia",
+ ET: "Ethiopia",
+ FK: "Falkland Islands",
+ FO: "Faroe Islands",
+ FJ: "Fiji",
+ FI: "Finland",
+ FR: "France",
+ GF: "French Guiana",
+ PF: "French Polynesia",
+ TF: "French Southern Territories",
+ GA: "Gabon",
+ GM: "Gambia",
+ GE: "Georgia",
+ DE: "Germany",
+ GH: "Ghana",
+ GI: "Gibraltar",
+ GR: "Greece",
+ GL: "Greenland",
+ GD: "Grenada",
+ GP: "Guadeloupe",
+ GU: "Guam",
+ GT: "Guatemala",
+ GN: "Guinea",
+ GW: "Guinea-Bissau",
+ GY: "Guyana",
+ HT: "Haiti",
+ HM: "Heard Island and McDonald Islands",
+ VA: "Vatican City",
+ HN: "Honduras",
+ HK: "Hong Kong",
+ HU: "Hungary",
+ IS: "Iceland",
+ IN: "India",
+ ID: "Indonesia",
+ IR: "Iran",
+ IQ: "Iraq",
+ IE: "Ireland",
+ IL: "Israel",
+ IT: "Italy",
+ JM: "Jamaica",
+ JP: "Japan",
+ JO: "Jordan",
+ KZ: "Kazakhstan",
+ KE: "Kenya",
+ KI: "Kiribati",
+ KP: "North Korea",
+ KR: "South Korea",
+ KW: "Kuwait",
+ KG: "Kyrgyzstan",
+ LA: "Laos",
+ LV: "Latvia",
+ LB: "Lebanon",
+ LS: "Lesotho",
+ LR: "Liberia",
+ LY: "Libya",
+ LI: "Liechtenstein",
+ LT: "Lithuania",
+ LU: "Luxembourg",
+ MO: "Macao",
+ MG: "Madagascar",
+ MW: "Malawi",
+ MY: "Malaysia",
+ MV: "Maldives",
+ ML: "Mali",
+ MT: "Malta",
+ MH: "Marshall Islands",
+ MQ: "Martinique",
+ MR: "Mauritania",
+ MU: "Mauritius",
+ YT: "Mayotte",
+ MX: "Mexico",
+ FM: "Micronesia",
+ MD: "Moldova",
+ MC: "Monaco",
+ MN: "Mongolia",
+ MS: "Montserrat",
+ MA: "Morocco",
+ MZ: "Mozambique",
+ MM: "Myanmar",
+ NA: "Namibia",
+ NR: "Nauru",
+ NP: "Nepal",
+ NL: "Netherlands",
+ NC: "New Caledonia",
+ NZ: "New Zealand",
+ NI: "Nicaragua",
+ NE: "Niger",
+ NG: "Nigeria",
+ NU: "Niue",
+ NF: "Norfolk Island",
+ MK: "Macedonia",
+ MP: "Northern Mariana Islands",
+ NO: "Norway",
+ OM: "Oman",
+ PK: "Pakistan",
+ PW: "Palau",
+ PS: "Palestine",
+ PA: "Panama",
+ PG: "Papua New Guinea",
+ PY: "Paraguay",
+ PE: "Peru",
+ PH: "Philippines",
+ PN: "Pitcairn",
+ PL: "Poland",
+ PT: "Portugal",
+ PR: "Puerto Rico",
+ QA: "Qatar",
+ RE: "Reunion",
+ RO: "Romania",
+ RU: "Russia",
+ RW: "Rwanda",
+ SH: "Saint Helena",
+ KN: "Saint Kitts and Nevis",
+ LC: "Saint Lucia",
+ PM: "Saint Pierre and Miquelon",
+ VC: "Saint Vincent and the Grenadines",
+ WS: "Samoa",
+ SM: "San Marino",
+ ST: "Sao Tome and Principe",
+ SA: "Saudi Arabia",
+ SN: "Senegal",
+ SC: "Seychelles",
+ SL: "Sierra Leone",
+ SG: "Singapore",
+ SK: "Slovakia",
+ SI: "Slovenia",
+ SB: "Solomon Islands",
+ SO: "Somalia",
+ ZA: "South Africa",
+ GS: "South Georgia and the South Sandwich Islands",
+ ES: "Spain",
+ LK: "Sri Lanka",
+ SD: "Sudan",
+ SR: "Suriname",
+ SJ: "Svalbard and Jan Mayen",
+ SZ: "Eswatini",
+ SE: "Sweden",
+ CH: "Switzerland",
+ SY: "Syrian Arab Republic",
+ TW: "Taiwan",
+ TJ: "Tajikistan",
+ TZ: "Tanzania",
+ TH: "Thailand",
+ TL: "Timor-Leste",
+ TG: "Togo",
+ TK: "Tokelau",
+ TO: "Tonga",
+ TT: "Trinidad and Tobago",
+ TN: "Tunisia",
+ TR: "Türkiye",
+ TM: "Turkmenistan",
+ TC: "Turks and Caicos Islands",
+ TV: "Tuvalu",
+ UG: "Uganda",
+ UA: "Ukraine",
+ AE: "United Arab Emirates",
+ GB: "United Kingdom",
+ US: "United States",
+ UM: "United States Minor Outlying Islands",
+ UY: "Uruguay",
+ UZ: "Uzbekistan",
+ VU: "Vanuatu",
+ VE: "Venezuela",
+ VN: "Vietnam",
+ VG: "Virgin Islands, British",
+ VI: "Virgin Islands, U.S.",
+ WF: "Wallis and Futuna",
+ EH: "Western Sahara",
+ YE: "Yemen",
+ ZM: "Zambia",
+ ZW: "Zimbabwe",
+ AX: "Åland Islands",
+ BQ: "Bonaire, Sint Eustatius and Saba",
+ CW: "Curaçao",
+ GG: "Guernsey",
+ IM: "Isle of Man",
+ JE: "Jersey",
+ ME: "Montenegro",
+ BL: "Saint Barthélemy",
+ MF: "Saint Martin (French part)",
+ RS: "Serbia",
+ SX: "Sint Maarten (Dutch part)",
+ SS: "South Sudan",
+ XK: "Kosovo",
+};
diff --git a/lib/stats.ts b/lib/stats.ts
index d1b0b79356..2338f442b4 100644
--- a/lib/stats.ts
+++ b/lib/stats.ts
@@ -1,4 +1,5 @@
import { NextRequest } from "next/server";
+import { COUNTRIES } from "@/lib/constants";
export interface RawStatsProps {
geo: NextRequest["geo"];
@@ -10,7 +11,14 @@ export interface StatsProps {
key: string;
totalClicks: number;
clicksData: { start: number; end: number; count: number }[];
- geoData: { country: string; count: number }[];
+ locationData:
+ | {
+ country: string;
+ countryCode: string;
+ city: string;
+ region: string;
+ }[]
+ | null;
browserData: { browser: string; count: number }[];
}
@@ -84,7 +92,7 @@ export const getTimeIntervals = (
export function processData(
key: string,
data: RawStatsProps[],
- interval?: IntervalProps // if undefined, 24h is used
+ interval?: IntervalProps // if undefined, 7d is used
): StatsProps {
const { timeIntervals } = getTimeIntervals(interval || "7d");
@@ -95,22 +103,19 @@ export function processData(
).length,
}));
- const geoData =
- data.length > 0
- ? data.reduce((acc, d) => {
- const country = d.geo?.country;
- // @ts-ignore
- const count = acc[country] || 0;
- // @ts-ignore
- acc[country] = count + 1;
- return acc;
- }, {})
- : {};
-
- const geoDataArray = Object.entries(geoData).map(([country, count]) => ({
- country,
- count,
- }));
+ const locationData = data.map(({ geo }) => {
+ const { country, city, region } = geo || {};
+ return {
+ country: country
+ ? COUNTRIES[country]
+ ? COUNTRIES[country]
+ : country
+ : "Unknown",
+ countryCode: country || "Unknown",
+ city: city || "Unknown",
+ region: region || "Unknown",
+ };
+ });
const browserData =
data.length > 0
@@ -135,13 +140,43 @@ export function processData(
key,
totalClicks: data.length,
clicksData,
- // @ts-ignore
- geoData: geoDataArray,
+ locationData,
// @ts-ignore
browserData: browserDataArray,
};
}
+export interface LocationStatsProps {
+ display: string;
+ code: string;
+ count: number;
+}
+
+export type LocationType = "country" | "city" | "region";
+
+export const processLocationData = (
+ data: StatsProps["locationData"],
+ type: LocationType
+): LocationStatsProps[] => {
+ const countryCodeMap: { [key: string]: string } = {};
+
+ const results =
+ data && data.length > 0
+ ? data.reduce<Record<string, number>>((acc, d) => {
+ const count = acc[d[type]] || 0;
+ acc[d[type]] = count + 1;
+ countryCodeMap[d[type]] = d.countryCode;
+ return acc;
+ }, {})
+ : {};
+
+ return Object.entries(results).map(([item, count]) => ({
+ display: item,
+ code: countryCodeMap[item],
+ count,
+ }));
+};
+
export const dummyData: StatsProps = {
key: "test",
totalClicks: 100,
@@ -149,13 +184,7 @@ export const dummyData: StatsProps = {
...interval,
count: 0,
})),
- geoData: [
- { country: "United States", count: 100 },
- { country: "Canada", count: 50 },
- { country: "United Kingdom", count: 25 },
- { country: "France", count: 10 },
- { country: "Germany", count: 5 },
- ],
+ locationData: null,
browserData: [
{ browser: "Chrome", count: 100 },
{ browser: "Firefox", count: 50 },
diff --git a/pages/api/links/[key]/stats.ts b/pages/api/links/[key]/stats.ts
index 1b555dbbf9..e7b15b9901 100644
--- a/pages/api/links/[key]/stats.ts
+++ b/pages/api/links/[key]/stats.ts
@@ -34,177 +34,3 @@ export default async function handler(req: NextRequest) {
return new Response(`Method ${req.method} Not Allowed`, { status: 405 });
}
}
-
-const mock = [
- {
- geo: {
- city: "San Francisco",
- region: "CA",
- country: "US",
- latitude: "37.7695",
- longitude: "-122.385",
- },
- ua: {
- ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
- browser: {},
- engine: {},
- os: {},
- device: {},
- cpu: {},
- isBot: false,
- },
- timestamp: 1661737363508,
- },
- {
- geo: {
- city: "San Francisco",
- region: "CA",
- country: "US",
- latitude: "37.7695",
- longitude: "-122.385",
- },
- ua: {
- ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
- browser: {},
- engine: {},
- os: {},
- device: {},
- cpu: {},
- isBot: false,
- },
- timestamp: 1661737363608,
- },
- {
- geo: {
- city: "San Francisco",
- region: "CA",
- country: "US",
- latitude: "37.7695",
- longitude: "-122.385",
- },
- ua: {
- ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
- browser: {},
- engine: {},
- os: {},
- device: {},
- cpu: {},
- isBot: false,
- },
- timestamp: 1661737363908,
- },
- {
- geo: {
- city: "Dallas",
- country: "US",
- latitude: "32.7889",
- longitude: "-96.8021",
- region: "TX",
- },
- ua: {
- ua: "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.0.0 Safari/537.36",
- browser: {},
- engine: {},
- os: {},
- device: {},
- cpu: {},
- isBot: false,
- },
- timestamp: 1661757572391,
- },
- {
- geo: {
- city: "Dallas",
- country: "US",
- latitude: "32.7889",
- longitude: "-96.8021",
- region: "TX",
- },
- ua: {
- ua: "curl/7.77.0",
- browser: {},
- engine: {},
- os: {},
- device: {},
- cpu: {},
- isBot: false,
- },
- timestamp: 1661757801308,
- },
- {
- geo: {
- city: "Dallas",
- country: "US",
- latitude: "32.7889",
- longitude: "-96.8021",
- region: "TX",
- },
- ua: {
- ua: "curl/7.77.0",
- browser: {},
- engine: {},
- os: {},
- device: {},
- cpu: {},
- isBot: false,
- },
- timestamp: 1661757805125,
- },
- {
- geo: {
- city: "Dallas",
- country: "US",
- latitude: "32.7889",
- longitude: "-96.8021",
- region: "TX",
- },
- ua: {
- ua: "curl/7.77.0",
- browser: {},
- engine: {},
- os: {},
- device: {},
- cpu: {},
- isBot: false,
- },
- timestamp: 1661757810830,
- },
- {
- geo: {
- city: "Dallas",
- country: "US",
- latitude: "32.7889",
- longitude: "-96.8021",
- region: "TX",
- },
- ua: {
- ua: "curl/7.77.0",
- browser: {},
- engine: {},
- os: {},
- device: {},
- cpu: {},
- isBot: false,
- },
- timestamp: 1661871209000,
- },
- {
- geo: {
- city: "Dallas",
- country: "US",
- latitude: "32.7889",
- longitude: "-96.8021",
- region: "TX",
- },
- ua: {
- ua: "curl/7.77.0",
- browser: {},
- engine: {},
- os: {},
- device: {},
- cpu: {},
- isBot: false,
- },
- timestamp: 1661871210000,
- },
-];
diff --git a/pages/stats/[key].tsx b/pages/stats/[key].tsx
index 80ff1dc2de..904bccbfa6 100644
--- a/pages/stats/[key].tsx
+++ b/pages/stats/[key].tsx
@@ -1,14 +1,8 @@
import Stats from "@/components/stats";
import { GetStaticPaths, GetStaticProps } from "next";
import { ParsedUrlQuery } from "querystring";
-import { RawStatsProps } from "@/lib/stats";
-interface StatsPageProps {
- _key: string;
- stats: RawStatsProps[];
-}
-
-export default function StatsPage(props: StatsPageProps) {
+export default function StatsPage() {
return (
<div>
<Stats />
@@ -30,6 +24,6 @@ interface Params extends ParsedUrlQuery {
export const getStaticProps: GetStaticProps = async (context) => {
const { key } = context.params as Params; // https://wallis.dev/blog/nextjs-getstaticprops-and-getstaticpaths-with-typescript
return {
- props: { key, _key: key },
+ props: { key },
};
};