Track HiveGrid Cloud planning reference

This commit is contained in:
david committed 2026-06-26 20:48:01 +02:00
1 parent b3d5ea6764
commit e341c5938a
5784 files changed
+1104929 -3

No files matched your search

@@ -0,0 +1,36 @@
import { useLocation, useMatches } from "react-router";
import { Fragment, ReactNode, useEffect } from "react";
import { useRootData } from "~/utils/data/useRootData";
import AnalyticsHelper from "~/utils/helpers/AnalyticsHelper";
interface Props {
flag: string;
children: ReactNode;
}
export default function FeatureFlagTracker({ flag, children }: Props) {
let location = useLocation();
const rootData = useRootData();
const matches = useMatches();
useEffect(() => {
async function track() {
const routeMatch = matches.find((m) => m.pathname == location.pathname);
AnalyticsHelper.addEvent({
url: location.pathname,
route: routeMatch?.id,
rootData,
action: flag,
category: "featureFlag",
label: "",
value: "",
});
}
if (rootData?.featureFlags.includes(flag)) {
track();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [flag]);
return <Fragment>{children}</Fragment>;
}