feat(analytics): implement advanced tracking with script-less smart proxy
Build & Deploy / 🔍 Prepare (push) Successful in 9s
Build & Deploy / 🧪 QA (push) Failing after 1m18s
Build & Deploy / 🏗️ Build (push) Failing after 2m58s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🩺 Health Check (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
Build & Deploy / 🔍 Prepare (push) Successful in 9s
Build & Deploy / 🧪 QA (push) Failing after 1m18s
Build & Deploy / 🏗️ Build (push) Failing after 2m58s
Build & Deploy / 🚀 Deploy (push) Has been skipped
Build & Deploy / 🩺 Health Check (push) Has been skipped
Build & Deploy / 🔔 Notify (push) Successful in 2s
- Added Umami Smart Proxy route handler - Refactored Umami adapter to use proxy-based fetch - Implemented TrackedButton, TrackedLink, and ScrollDepthTracker - Integrated event tracking into ContactForm - Enhanced Analytics component with manual pageview and performance tracking
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
"use client";
|
||||
|
||||
import { useCallback } from "react";
|
||||
import { getDefaultAnalytics } from "../../utils/analytics";
|
||||
import type { AnalyticsEventName } from "./analytics-events";
|
||||
|
||||
/**
|
||||
* Custom hook for tracking analytics events.
|
||||
* Wraps the analytics service for easy use in components.
|
||||
*/
|
||||
export function useAnalytics() {
|
||||
const trackEvent = useCallback(
|
||||
(
|
||||
eventName: string | AnalyticsEventName,
|
||||
properties?: Record<string, any>,
|
||||
) => {
|
||||
const analytics = getDefaultAnalytics();
|
||||
analytics.trackEvent(eventName, properties);
|
||||
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
console.debug("[Analytics] Tracked event:", eventName, properties);
|
||||
}
|
||||
},
|
||||
[],
|
||||
);
|
||||
|
||||
const trackPageview = useCallback((url?: string) => {
|
||||
const analytics = getDefaultAnalytics();
|
||||
analytics.page(url || window.location.pathname);
|
||||
|
||||
if (process.env.NODE_ENV === "development") {
|
||||
console.debug("[Analytics] Tracked pageview:", url ?? "current location");
|
||||
}
|
||||
}, []);
|
||||
|
||||
return {
|
||||
trackEvent,
|
||||
trackPageview,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user