useAnalyticsController
Hook to access the analytics controller. This controller allows you to listen to internal events in the CMS, such as navigation, entity creation, editing, etc.
You can use this to integrate with 3rd party analytics providers like Google Analytics, Mixpanel, or Segment.
import { useAnalyticsController } from "@firecms/core";import { useEffect } from "react";
export function MyAnalyticsComponent() { const analyticsController = useAnalyticsController();
useEffect(() => { // You would typically set this up in your main app entry point // This is just for demonstration console.log("Analytics controller available"); }, [analyticsController]);
return null;}Interface
Section titled “Interface”export type AnalyticsController = { /** * Callback used to get analytics events from the CMS */ onAnalyticsEvent?: (event: CMSAnalyticsEvent, data?: object) => void;}Events
Section titled “Events”The CMSAnalyticsEvent type defines all the possible events:
entity_click: User clicked on an entity in a collectionedit_entity_clicked: User clicked the edit buttonnew_entity_click: User clicked the “New” buttonnew_entity_saved: A new entity was successfully createdentity_edited: An entity was updatedentity_deleted: An entity was deleteddrawer_navigate_to_collection: User navigated to a collection from the drawerhome_navigate_to_collection: User navigated to a collection from the home page- … and more.