chore: track registered widgets (#23412)

This commit is contained in:
Rémi de Juvigny 2025-04-24 10:46:44 +02:00 committed by GitHub
parent 0abebb3869
commit f345ada2ce
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,6 +6,7 @@ import { useInitQuery, useTelemetryPropertiesQuery } from '../services/admin';
import { useAppInfo } from './AppInfo';
import { useAuth } from './Auth';
import { useStrapiApp } from './StrapiApp';
export interface TelemetryProperties {
useTypescriptOnServer?: boolean;
@ -39,6 +40,7 @@ export interface TrackingProviderProps {
const TrackingProvider = ({ children }: TrackingProviderProps) => {
const token = useAuth('App', (state) => state.token);
const getAllWidgets = useStrapiApp('TrackingProvider', (state) => state.widgets.getAll);
const { data: initData } = useInitQuery();
const { uuid } = initData ?? {};
@ -57,7 +59,11 @@ const TrackingProvider = ({ children }: TrackingProviderProps) => {
event,
userId: '',
eventPropeties: {},
groupProperties: { ...data, projectId: uuid },
groupProperties: {
...data,
projectId: uuid,
registeredWidgets: getAllWidgets().map((widget) => widget.uid),
},
}),
headers: {
'Content-Type': 'application/json',
@ -68,7 +74,7 @@ const TrackingProvider = ({ children }: TrackingProviderProps) => {
// silence is golden
}
}
}, [data, uuid]);
}, [data, uuid, getAllWidgets]);
const value = React.useMemo(
() => ({