Skip to content

Full Toolkit for Next-Level Domain Analysis

Rework star reminder 🌟

Felix Wotschofsky736dd3747556
diff --git a/app/_components/feedback-prompt.tsx b/app/_components/feedback-prompt.tsx
deleted file mode 100644
index 3d59d13..0000000
--- a/app/_components/feedback-prompt.tsx
+++ /dev/null
@@ -1,150 +0,0 @@
-'use client';
-
-import { useLocalStorage } from '@uidotdev/usehooks';
-import { XIcon } from 'lucide-react';
-import ms from 'ms';
-import { type FC, useCallback, useState } from 'react';
-
-import { Button } from '@/components/ui/button';
-import { Card } from '@/components/ui/card';
-import {
- Dialog,
- DialogContent,
- DialogDescription,
- DialogHeader,
- DialogTitle,
-} from '@/components/ui/dialog';
-
-import { useAnalytics } from '@/lib/analytics';
-
-const INITIAL_DELAY = ms('10m');
-const TIMEOUT_PERIOD = ms('7d');
-
-export const FeedbackPrompt: FC = () => {
- const { reportEvent } = useAnalytics();
-
- const [lastDismissed, setLastDismissed] = useLocalStorage(
- 'feedback-prompt.last-dismissed',
- Date.now() - TIMEOUT_PERIOD + INITIAL_DELAY,
- );
- const visible = Date.now() - lastDismissed > TIMEOUT_PERIOD;
- const [dialogOpen, setDialogOpen] = useState(false);
-
- const handleDismiss = useCallback(() => {
- setLastDismissed(Date.now());
- }, [setLastDismissed]);
-
- const handleNegative = useCallback(() => {
- window.open('https://wotschofsky.com/#contact', '_blank');
- handleDismiss();
- reportEvent('Feedback: Negative', {});
- }, [handleDismiss, reportEvent]);
-
- const handleNeutral = useCallback(() => {
- handleDismiss();
- reportEvent('Feedback: Neutral', {});
- }, [handleDismiss, reportEvent]);
-
- const handlePositive = useCallback(() => {
- setDialogOpen(true);
- handleDismiss();
- reportEvent('Feedback: Positive', {});
- }, [setDialogOpen, handleDismiss, reportEvent]);
-
- return (
- <>
- {visible && (
- <aside className="fixed bottom-6 right-6 max-w-[calc(100vw-3rem)]">
- <Card className="relative p-8 shadow-lg">
- <XIcon
- role="button"
- onClick={handleDismiss}
- className="absolute !left-[unset] !top-2 right-2 h-5 w-5 text-zinc-500 dark:text-zinc-400"
- />
-
- <p className="!pl-0 font-semibold">
- How do you feel about Domain Digger?
- </p>
- <div className="mt-1 flex select-none justify-evenly !pl-0">
- <span
- className="block cursor-pointer p-2 text-4xl"
- role="button"
- onClick={handleNegative}
- >
- 😒
- </span>
- <span
- className="block cursor-pointer p-2 text-4xl"
- role="button"
- onClick={handleNeutral}
- >
- 😐
- </span>
- <span
- className="block cursor-pointer p-2 text-4xl"
- role="button"
- onClick={handlePositive}
- >
- 😍
- </span>
- </div>
- </Card>
- </aside>
- )}
-
- <Dialog open={dialogOpen} onOpenChange={setDialogOpen}>
- <DialogContent>
- <DialogHeader>
- <DialogTitle>Thanks for your feedback!</DialogTitle>
- <DialogDescription className="space-y-2">
- <p>
- Domain Digger is on a mission to offer the best multi-tool for
- anything domain-related. All 100% free, open-source and without
- ads.
- </p>
- <p>
- As you seem to enjoy using Domain Digger, please consider
- supporting us!
- </p>
-
- <div className="!mt-4 grid grid-cols-2 gap-4">
- <Button variant="ghost" className="font-semibold" asChild>
- <a
- href="https://github.com/sponsors/wotschofsky"
- target="_blank"
- >
- ❀️ Sponsor
- </a>
- </Button>
- <Button variant="ghost" className="font-semibold" asChild>
- <a
- href="https://x.com/intent/post?text=Check%20this%20out!&url=https%3A%2F%2Fdigger.tools"
- target="_blank"
- >
- 🐦 Tweet
- </a>
- </Button>
- <Button variant="ghost" className="font-semibold" asChild>
- <a
- href="https://buymeacoffee.com/wotschofsky"
- target="_blank"
- >
- β˜•οΈ Buy a Coffee
- </a>
- </Button>
- <Button variant="ghost" className="font-semibold" asChild>
- <a
- href="https://github.com/wotschofsky/domain-digger"
- target="_blank"
- >
- ⭐️ Star
- </a>
- </Button>
- </div>
- </DialogDescription>
- </DialogHeader>
- </DialogContent>
- </Dialog>
- </>
- );
-};
diff --git a/app/_components/star-reminder.tsx b/app/_components/star-reminder.tsx
new file mode 100644
index 0000000..576a6f4
--- /dev/null
+++ b/app/_components/star-reminder.tsx
@@ -0,0 +1,89 @@
+'use client';
+
+import { useLocalStorage } from '@uidotdev/usehooks';
+import { XIcon } from 'lucide-react';
+import ms from 'ms';
+import { type FC, useCallback, useEffect, useState } from 'react';
+import { FaGithub } from 'react-icons/fa';
+
+import { Button } from '@/components/ui/button';
+import { Card } from '@/components/ui/card';
+
+import { useAnalytics } from '@/lib/analytics';
+
+const INITIAL_DELAY = ms('2m');
+const TIMEOUT_PERIOD = ms('7d');
+
+export const StarReminder: FC = () => {
+ const { reportEvent } = useAnalytics();
+ const [_, setForceUpdate] = useState(0);
+
+ const [isStarred, setIsStarred] = useLocalStorage(
+ 'star-reminder.starred',
+ false,
+ );
+ const [lastDismissed, setLastDismissed] = useLocalStorage(
+ 'star-reminder.last-dismissed',
+ Date.now() - TIMEOUT_PERIOD + INITIAL_DELAY,
+ );
+
+ const timeUntilVisible = TIMEOUT_PERIOD - (Date.now() - lastDismissed);
+ const visible = timeUntilVisible <= 0 && !isStarred;
+
+ useEffect(() => {
+ if (timeUntilVisible > 0) {
+ const timeout = setTimeout(() => {
+ setForceUpdate((prev) => prev + 1);
+ }, timeUntilVisible + 100);
+ return () => clearTimeout(timeout);
+ }
+ }, [timeUntilVisible]);
+
+ const handleDismiss = useCallback(() => {
+ setLastDismissed(Date.now());
+ reportEvent('Star Reminder: Suppress', {});
+ }, [setLastDismissed, reportEvent]);
+
+ const handleClick = useCallback(() => {
+ setIsStarred(true);
+ reportEvent('Star Reminder: Click', {});
+ }, [setIsStarred, reportEvent]);
+
+ if (!visible) {
+ return null;
+ }
+
+ return (
+ <aside className="fixed bottom-6 left-6 max-w-[calc(100vw-3rem)]">
+ <Card className="relative p-6 shadow-lg">
+ <p className="!pl-0 font-semibold">
+ Enjoying Domain Digger?{' '}
+ <XIcon
+ role="button"
+ onClick={handleDismiss}
+ className="ml-3 inline-block h-5 w-5 text-zinc-500 dark:text-zinc-400"
+ />
+ </p>
+ <div className="mt-4 flex select-none justify-evenly !pl-0">
+ <Button
+ variant="ghost"
+ asChild
+ className="px-2"
+ onClick={handleClick}
+ >
+ <a
+ href="https://github.com/wotschofsky/domain-digger"
+ target="_blank"
+ rel="noopener"
+ >
+ <FaGithub className="mr-1 h-6 w-4" />
+ <span className="hidden md:inline">
+ Star <span className="sr-only">on GitHub</span>
+ </span>
+ </a>
+ </Button>
+ </div>
+ </Card>
+ </aside>
+ );
+};
diff --git a/app/layout.tsx b/app/layout.tsx
index 432235b..b948c2c 100644
--- a/app/layout.tsx
+++ b/app/layout.tsx
@@ -11,9 +11,9 @@ import { env } from '@/env';
import './globals.css';
import { Providers } from './providers';
-const FeedbackPrompt = dynamic(() =>
- import('./_components/feedback-prompt').then((m) => ({
- default: m.FeedbackPrompt,
+const StarReminder = dynamic(() =>
+ import('./_components/star-reminder').then((m) => ({
+ default: m.StarReminder,
})),
);
@@ -59,7 +59,7 @@ const RootLayout: FC<RootLayoutProps> = ({ children }) => {
</Providers>
<ClientOnly>
- <FeedbackPrompt />
+ <StarReminder />
</ClientOnly>
<Toaster />
<SpeedInsights />
diff --git a/lib/analytics.ts b/lib/analytics.ts
index c58b503..08b752e 100644
--- a/lib/analytics.ts
+++ b/lib/analytics.ts
@@ -6,9 +6,6 @@ type EmptyEvent = Record<string, never>;
type Events = {
'Copy Button: Click': { value: string };
- 'Feedback: Negative': EmptyEvent;
- 'Feedback: Neutral': EmptyEvent;
- 'Feedback: Positive': EmptyEvent;
'IP Details: Open': { ip: string };
'Location Selector: Change': { location: string };
'Outbound Link: Click': { url: string };
@@ -17,7 +14,6 @@ type Events = {
'Search Form: Submit': { domain: string };
'Share: Click': { url: string };
'Star Reminder: Click': EmptyEvent;
- 'Star Reminder: Show': EmptyEvent;
'Star Reminder: Suppress': EmptyEvent;
'Trace: Click': { type: string; domain: string };
};
@@ -27,6 +23,7 @@ export const useAnalytics = () => {
const reportEvent = useCallback(
<T extends keyof Events>(event: T, props: Events[T]) => {
+ console.info('Reporting event', { event, props });
plausible(event, { props });
posthog.capture(event, props);
},