feat: enhance analytics component with configurable Vercel and Speed Insights options

This commit is contained in:
javayhu 2025-04-23 00:21:33 +08:00
parent d4b385f5a2
commit e298910b4b
3 changed files with 22 additions and 4 deletions

View File

@ -1,3 +1,4 @@
import { websiteConfig } from '@/config/website';
import DataFastAnalytics from './data-fast-analytics';
import GoogleAnalytics from './google-analytics';
import OpenPanelAnalytics from './open-panel-analytics';
@ -43,11 +44,15 @@ export function Analytics() {
{/* vercel analytics */}
{/* https://vercel.com/docs/analytics/quickstart */}
<VercelAnalytics />
{websiteConfig.analytics.enableVercelAnalytics && (
<VercelAnalytics />
)}
{/* speed insights */}
{/* https://vercel.com/docs/speed-insights/quickstart */}
<SpeedInsights />
{websiteConfig.analytics.enableSpeedInsights && (
<SpeedInsights />
)}
</>
);
}

View File

@ -29,6 +29,10 @@ export const websiteConfig: WebsiteConfig = {
youtube: 'https://www.youtube.com/@MkSaaS',
},
},
analytics: {
enableVercelAnalytics: true,
enableSpeedInsights: true,
},
i18n: {
defaultLocale: 'en',
locales: {

13
src/types/index.d.ts vendored
View File

@ -5,6 +5,7 @@ import type { ReactNode } from 'react';
*/
export type WebsiteConfig = {
metadata: MetadataConfig;
analytics: AnalyticsConfig;
i18n: I18nConfig;
blog: BlogConfig;
mail: MailConfig;
@ -55,12 +56,20 @@ export interface SocialConfig {
tiktok?: string;
}
/**
* Analytics configuration
*/
export interface AnalyticsConfig {
enableVercelAnalytics?: boolean; // Whether to enable vercel analytics
enableSpeedInsights?: boolean; // Whether to enable speed insights
}
/**
* I18n configuration
*/
export interface I18nConfig {
defaultLocale: string;
locales: Record<string, { flag?: string; name: string }>;
defaultLocale: string; // The default locale of the website
locales: Record<string, { flag?: string; name: string }>; // The locales of the website
}
/**