mirror of
https://github.com/DeveloLongScript/MHSF.git
synced 2026-05-09 07:55:00 -05:00
Compare commits
7 Commits
229eec112d
...
3f3fad39d0
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3f3fad39d0 | ||
|
|
68e46b8eea | ||
|
|
d51bef8da0 | ||
|
|
981f106acc | ||
|
|
b003f08fe5 | ||
|
|
f2e9c9c5e2 | ||
|
|
c784f965cd |
BIN
.github/github-banner.png
vendored
Normal file
BIN
.github/github-banner.png
vendored
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 430 KiB |
@ -45,6 +45,22 @@ const nextConfig = {
|
||||
},
|
||||
];
|
||||
},
|
||||
async rewrites() {
|
||||
return [
|
||||
{
|
||||
source: "/ingest/static/:path*",
|
||||
destination: "https://us-assets.i.posthog.com/static/:path*",
|
||||
},
|
||||
{
|
||||
source: "/ingest/:path*",
|
||||
destination: "https://us.i.posthog.com/:path*",
|
||||
},
|
||||
{
|
||||
source: "/ingest/decide",
|
||||
destination: "https://us.i.posthog.com/decide",
|
||||
},
|
||||
];
|
||||
},
|
||||
eslint: {
|
||||
ignoreDuringBuilds: true,
|
||||
},
|
||||
|
||||
@ -56,6 +56,7 @@
|
||||
"nextjs-toploader": "^1.6.12",
|
||||
"nprogress": "^0.2.0",
|
||||
"postcss-obfuscator": "^1.6.1",
|
||||
"posthog-js": "^1.230.2",
|
||||
"prettier": "^3.3.1",
|
||||
"react": "^19.0.0",
|
||||
"react-dom": "^19.0.0",
|
||||
@ -116,7 +117,7 @@
|
||||
"react-hook-form": "^7.52.2",
|
||||
"react-hotkeys-hook": "^4.5.0",
|
||||
"react-infinite-scroll-component": "^6.1.0",
|
||||
"react-markdown": "^9.0.1",
|
||||
"react-markdown": "^10.1.0",
|
||||
"react-resizable-panels": "^2.0.23",
|
||||
"recharts": "^2.12.7",
|
||||
"shiki": "^1.23.0",
|
||||
|
||||
@ -26,7 +26,6 @@
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
import { Analytics } from "@vercel/analytics/react";
|
||||
import { SpeedInsights } from "@vercel/speed-insights/next";
|
||||
import { GeistSans } from "geist/font/sans";
|
||||
import "../globals.css";
|
||||
@ -41,6 +40,7 @@ import { Inter as interFont } from "next/font/google";
|
||||
import LayoutPart from "@/components/feat/LayoutPart";
|
||||
import AllBanners from "@/components/feat/AllBanners";
|
||||
import Footer from "@/components/misc/Footer";
|
||||
import { PostHogProvider } from "@/components/misc/PosthogProvider";
|
||||
|
||||
export const viewport: Viewport = {
|
||||
themeColor: "black",
|
||||
@ -57,14 +57,15 @@ export default async function RootLayout({
|
||||
<ClerkThemeProvider className={GeistSans.className}>
|
||||
<ThemeProvider attribute="class" defaultTheme="system" enableSystem>
|
||||
<TooltipProvider>
|
||||
<PostHogProvider>
|
||||
<AllBanners />
|
||||
<LayoutPart>{children}</LayoutPart>
|
||||
<ThemedToaster />
|
||||
<CommandBarer />
|
||||
<SpeedInsights />
|
||||
<Analytics />
|
||||
<NewDomainDialog />
|
||||
<Footer />
|
||||
</PostHogProvider>
|
||||
</TooltipProvider>
|
||||
</ThemeProvider>
|
||||
</ClerkThemeProvider>
|
||||
|
||||
86
apps/www/src/components/misc/PosthogProvider.tsx
Normal file
86
apps/www/src/components/misc/PosthogProvider.tsx
Normal file
@ -0,0 +1,86 @@
|
||||
/*
|
||||
* MHSF, Minehut Server List
|
||||
* All external content is rather licensed under the ECA Agreement
|
||||
* located here: https://mhsf.app/docs/legal/external-content-agreement
|
||||
*
|
||||
* All code under MHSF is licensed under the MIT License
|
||||
* by open source contributors
|
||||
*
|
||||
* Copyright (c) 2025 dvelo
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to
|
||||
* deal in the Software without restriction, including without limitation the
|
||||
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
||||
* sell copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
"use client";
|
||||
|
||||
import { usePathname, useSearchParams } from "next/navigation";
|
||||
import { useEffect, Suspense } from "react";
|
||||
import { usePostHog } from "posthog-js/react";
|
||||
|
||||
import posthog from "posthog-js";
|
||||
import { PostHogProvider as PHProvider } from "posthog-js/react";
|
||||
|
||||
export function PostHogProvider({ children }: { children: React.ReactNode }) {
|
||||
useEffect(() => {
|
||||
posthog.init(process.env.NEXT_PUBLIC_POSTHOG_KEY as string, {
|
||||
api_host: "/ingest",
|
||||
ui_host: "https://us.posthog.com",
|
||||
person_profiles: "identified_only", // or 'always' to create profiles for anonymous users as well
|
||||
capture_pageview: false, // Disable automatic pageview capture, as we capture manually
|
||||
});
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<PHProvider client={posthog}>
|
||||
<SuspendedPostHogPageView />
|
||||
{children}
|
||||
</PHProvider>
|
||||
);
|
||||
}
|
||||
|
||||
function PostHogPageView() {
|
||||
const pathname = usePathname();
|
||||
const searchParams = useSearchParams();
|
||||
const posthog = usePostHog();
|
||||
|
||||
// Track pageviews
|
||||
useEffect(() => {
|
||||
if (pathname && posthog) {
|
||||
let url = window.origin + pathname;
|
||||
if (searchParams?.toString()) {
|
||||
url = `${url}?${searchParams?.toString()}`;
|
||||
}
|
||||
|
||||
posthog.capture("$pageview", { $current_url: url });
|
||||
}
|
||||
}, [pathname, searchParams, posthog]);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
// Wrap PostHogPageView in Suspense to avoid the useSearchParams usage above
|
||||
// from de-opting the whole app into client-side rendering
|
||||
// See: https://nextjs.org/docs/messages/deopted-into-client-rendering
|
||||
function SuspendedPostHogPageView() {
|
||||
return (
|
||||
<Suspense fallback={null}>
|
||||
<PostHogPageView />
|
||||
</Suspense>
|
||||
);
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user