Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🔨 chore(analytics): add Product Hunt campaign tracking events (#11819)

Tsuki7914bef2e2e6
diff --git a/packages/const/src/analytics.ts b/packages/const/src/analytics.ts
index 93b0d4d052d..ff5923721cf 100644
--- a/packages/const/src/analytics.ts
+++ b/packages/const/src/analytics.ts
@@ -1,3 +1,3 @@
import { isDesktop } from './version';
-export const BUSINESS_LINE = isDesktop ? 'lobe-chat-desktop' : 'lobe-chat';
+export const BUSINESS_LINE = isDesktop ? 'lobehub-desktop' : 'lobehub';
diff --git a/src/app/[variants]/(main)/home/_layout/Footer/index.tsx b/src/app/[variants]/(main)/home/_layout/Footer/index.tsx
index 6ccbde11679..e08bb8430b4 100644
--- a/src/app/[variants]/(main)/home/_layout/Footer/index.tsx
+++ b/src/app/[variants]/(main)/home/_layout/Footer/index.tsx
@@ -14,7 +14,8 @@ import {
Mail,
Rocket,
} from 'lucide-react';
-import { memo, useEffect, useMemo, useState } from 'react';
+import { useAnalytics } from '@lobehub/analytics/react';
+import { memo, useCallback, useEffect, useMemo, useState } from 'react';
import { useTranslation } from 'react-i18next';
import ChangelogModal from '@/components/ChangelogModal';
@@ -37,6 +38,7 @@ const PRODUCT_HUNT_NOTIFICATION = {
const Footer = memo(() => {
const { t } = useTranslation('common');
+ const { analytics } = useAnalytics();
const { hideGitHub } = useServerConfigStore(featureFlagsSelectors);
const [isLabsModalOpen, setIsLabsModalOpen] = useState(false);
const [shouldLoadChangelog, setShouldLoadChangelog] = useState(false);
@@ -53,11 +55,26 @@ const Footer = memo(() => {
return now >= PRODUCT_HUNT_NOTIFICATION.startTime && now <= PRODUCT_HUNT_NOTIFICATION.endTime;
}, []);
+ const trackProductHuntEvent = useCallback(
+ (eventName: string, properties: Record<string, string>) => {
+ try {
+ analytics?.track({ name: eventName, properties });
+ } catch {
+ // silently ignore tracking errors to avoid affecting business logic
+ }
+ },
+ [analytics],
+ );
+
useEffect(() => {
if (isWithinTimeWindow && !isNotificationRead) {
setIsProductHuntCardOpen(true);
+ trackProductHuntEvent('product_hunt_card_viewed', {
+ spm: 'homepage.product_hunt.viewed',
+ trigger: 'auto',
+ });
}
- }, [isWithinTimeWindow, isNotificationRead]);
+ }, [isWithinTimeWindow, isNotificationRead, trackProductHuntEvent]);
const { open: openFeedbackModal } = useFeedbackModal();
@@ -84,6 +101,10 @@ const Footer = memo(() => {
const handleOpenProductHuntCard = () => {
setIsProductHuntCardOpen(true);
+ trackProductHuntEvent('product_hunt_card_viewed', {
+ spm: 'homepage.product_hunt.viewed',
+ trigger: 'menu_click',
+ });
};
const handleCloseProductHuntCard = () => {
@@ -94,6 +115,15 @@ const Footer = memo(() => {
readNotificationSlugs: [...currentSlugs, PRODUCT_HUNT_NOTIFICATION.slug],
});
}
+ trackProductHuntEvent('product_hunt_card_closed', {
+ spm: 'homepage.product_hunt.closed',
+ });
+ };
+
+ const handleProductHuntActionClick = () => {
+ trackProductHuntEvent('product_hunt_action_clicked', {
+ spm: 'homepage.product_hunt.action_clicked',
+ });
};
const helpMenuItems: MenuProps['items'] = useMemo(
@@ -186,6 +216,7 @@ const Footer = memo(() => {
actionLabel={t('productHunt.actionLabel')}
description={t('productHunt.description')}
image={PRODUCT_HUNT_NOTIFICATION.image}
+ onActionClick={handleProductHuntActionClick}
onClose={handleCloseProductHuntCard}
open={isProductHuntCardOpen}
title={t('productHunt.title')}
diff --git a/src/components/HighlightNotification/index.tsx b/src/components/HighlightNotification/index.tsx
index 7076fa040e8..3b7b309938d 100644
--- a/src/components/HighlightNotification/index.tsx
+++ b/src/components/HighlightNotification/index.tsx
@@ -12,6 +12,7 @@ export interface HighlightNotificationProps {
actionLabel?: ReactNode;
description?: ReactNode;
image?: string;
+ onActionClick?: () => void;
onClose?: () => void;
open?: boolean;
title?: ReactNode;
@@ -62,7 +63,7 @@ const styles = createStaticStyles(({ css }) => ({
}));
const HighlightNotification = memo<HighlightNotificationProps>(
- ({ open, onClose, image, title, description, actionLabel, actionHref }) => {
+ ({ open, onClose, onActionClick, image, title, description, actionLabel, actionHref }) => {
if (!open) return null;
return (
@@ -77,6 +78,7 @@ const HighlightNotification = memo<HighlightNotificationProps>(
<Link
className={styles.action}
href={actionHref || '/'}
+ onClick={onActionClick}
rel="noopener noreferrer"
target="_blank"
>