Skip to content

Full Toolkit for Next-Level Domain Analysis

Make Plausible Analytics configurable through env 🔧

Felix Wotschofskyecab2c32f520
diff --git a/.env.example b/.env.example
index fbe1fa2..16c6149 100644
--- a/.env.example
+++ b/.env.example
@@ -2,6 +2,11 @@
INTERNAL_API_SECRET=secret
+# Plausible Analytics Configuration
+NEXT_PUBLIC_PLAUSIBLE_DOMAIN=example.com
+NEXT_PUBLIC_PLAUSIBLE_HOST=https://customplausible.io # Optional if using plausible.io
+
+
# Credentials for Upstash Redis database
UPSTASH_REDIS_REST_URL=https://xyz.upstash.io
UPSTASH_REDIS_REST_TOKEN=secret
diff --git a/app/providers.tsx b/app/providers.tsx
index 8fecd53..ba25d18 100644
--- a/app/providers.tsx
+++ b/app/providers.tsx
@@ -5,6 +5,28 @@ import { ThemeProvider } from 'next-themes';
import { type FC, type ReactNode } from 'react';
import { SWRConfig } from 'swr';
+type CustomizedPlausibleProviderProps = {
+ children: ReactNode;
+};
+
+const CustomizedPlausibleProvider: FC<CustomizedPlausibleProviderProps> = ({
+ children,
+}) => {
+ if (!process.env.NEXT_PUBLIC_PLAUSIBLE_DOMAIN) {
+ return children;
+ }
+
+ return (
+ <PlausibleProvider
+ customDomain={process.env.NEXT_PUBLIC_PLAUSIBLE_HOST}
+ trackOutboundLinks
+ domain={process.env.NEXT_PUBLIC_PLAUSIBLE_DOMAIN}
+ >
+ {children}
+ </PlausibleProvider>
+ );
+};
+
type ProvidersProps = {
children: ReactNode;
};
@@ -14,13 +36,7 @@ export const Providers: FC<ProvidersProps> = ({ children }) => (
<SWRConfig
value={{ fetcher: (url) => fetch(url).then((res) => res.json()) }}
>
- <PlausibleProvider
- customDomain="https://insights.wsky.dev"
- trackOutboundLinks
- domain="digger.tools"
- >
- {children}
- </PlausibleProvider>
+ <CustomizedPlausibleProvider>{children}</CustomizedPlausibleProvider>
</SWRConfig>
</ThemeProvider>
);