mirror of
https://github.com/strapi/strapi.git
synced 2025-06-27 00:41:25 +00:00
Merge branch 'develop' into test/fix-cleanup-after-delete
This commit is contained in:
commit
98ac9121dd
@ -6,7 +6,6 @@ import { useInitQuery, useTelemetryPropertiesQuery } from '../services/admin';
|
|||||||
|
|
||||||
import { useAppInfo } from './AppInfo';
|
import { useAppInfo } from './AppInfo';
|
||||||
import { useAuth } from './Auth';
|
import { useAuth } from './Auth';
|
||||||
import { useStrapiApp } from './StrapiApp';
|
|
||||||
|
|
||||||
export interface TelemetryProperties {
|
export interface TelemetryProperties {
|
||||||
useTypescriptOnServer?: boolean;
|
useTypescriptOnServer?: boolean;
|
||||||
@ -40,42 +39,12 @@ export interface TrackingProviderProps {
|
|||||||
|
|
||||||
const TrackingProvider = ({ children }: TrackingProviderProps) => {
|
const TrackingProvider = ({ children }: TrackingProviderProps) => {
|
||||||
const token = useAuth('App', (state) => state.token);
|
const token = useAuth('App', (state) => state.token);
|
||||||
const getAllWidgets = useStrapiApp('TrackingProvider', (state) => state.widgets.getAll);
|
|
||||||
const { data: initData } = useInitQuery();
|
const { data: initData } = useInitQuery();
|
||||||
const { uuid } = initData ?? {};
|
const { uuid } = initData ?? {};
|
||||||
|
|
||||||
const { data } = useTelemetryPropertiesQuery(undefined, {
|
const { data } = useTelemetryPropertiesQuery(undefined, {
|
||||||
skip: !initData?.uuid || !token,
|
skip: !initData?.uuid || !token,
|
||||||
});
|
});
|
||||||
|
|
||||||
React.useEffect(() => {
|
|
||||||
if (uuid && data) {
|
|
||||||
const event = 'didInitializeAdministration';
|
|
||||||
try {
|
|
||||||
fetch('https://analytics.strapi.io/api/v2/track', {
|
|
||||||
method: 'POST',
|
|
||||||
body: JSON.stringify({
|
|
||||||
// This event is anonymous
|
|
||||||
event,
|
|
||||||
userId: '',
|
|
||||||
eventPropeties: {},
|
|
||||||
groupProperties: {
|
|
||||||
...data,
|
|
||||||
projectId: uuid,
|
|
||||||
registeredWidgets: getAllWidgets().map((widget) => widget.uid),
|
|
||||||
},
|
|
||||||
}),
|
|
||||||
headers: {
|
|
||||||
'Content-Type': 'application/json',
|
|
||||||
'X-Strapi-Event': event,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
} catch {
|
|
||||||
// silence is golden
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, [data, uuid, getAllWidgets]);
|
|
||||||
|
|
||||||
const value = React.useMemo(
|
const value = React.useMemo(
|
||||||
() => ({
|
() => ({
|
||||||
uuid,
|
uuid,
|
||||||
@ -101,7 +70,6 @@ const TrackingProvider = ({ children }: TrackingProviderProps) => {
|
|||||||
interface EventWithoutProperties {
|
interface EventWithoutProperties {
|
||||||
name:
|
name:
|
||||||
| 'changeComponentsOrder'
|
| 'changeComponentsOrder'
|
||||||
| 'didAccessAuthenticatedAdministration'
|
|
||||||
| 'didAddComponentToDynamicZone'
|
| 'didAddComponentToDynamicZone'
|
||||||
| 'didBulkDeleteEntries'
|
| 'didBulkDeleteEntries'
|
||||||
| 'didNotBulkDeleteEntries'
|
| 'didNotBulkDeleteEntries'
|
||||||
@ -197,6 +165,14 @@ interface EventWithoutProperties {
|
|||||||
properties?: never;
|
properties?: never;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
interface DidAccessAuthenticatedAdministrationEvent {
|
||||||
|
name: 'didAccessAuthenticatedAdministration';
|
||||||
|
properties: {
|
||||||
|
registeredWidgets: string[];
|
||||||
|
projectId: string;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
interface DidFilterMediaLibraryElementsEvent {
|
interface DidFilterMediaLibraryElementsEvent {
|
||||||
name: 'didFilterMediaLibraryElements';
|
name: 'didFilterMediaLibraryElements';
|
||||||
properties: MediaEvents['properties'] & {
|
properties: MediaEvents['properties'] & {
|
||||||
@ -384,6 +360,7 @@ interface DidUpdateCTBSchema {
|
|||||||
type EventsWithProperties =
|
type EventsWithProperties =
|
||||||
| CreateEntryEvents
|
| CreateEntryEvents
|
||||||
| PublishEntryEvents
|
| PublishEntryEvents
|
||||||
|
| DidAccessAuthenticatedAdministrationEvent
|
||||||
| DidAccessTokenListEvent
|
| DidAccessTokenListEvent
|
||||||
| DidChangeModeEvent
|
| DidChangeModeEvent
|
||||||
| DidCropFileEvent
|
| DidCropFileEvent
|
||||||
|
@ -20,6 +20,7 @@ import { UpsellBanner } from '../components/UpsellBanner';
|
|||||||
import { AppInfoProvider } from '../features/AppInfo';
|
import { AppInfoProvider } from '../features/AppInfo';
|
||||||
import { useAuth } from '../features/Auth';
|
import { useAuth } from '../features/Auth';
|
||||||
import { useConfiguration } from '../features/Configuration';
|
import { useConfiguration } from '../features/Configuration';
|
||||||
|
import { useStrapiApp } from '../features/StrapiApp';
|
||||||
import { useTracking } from '../features/Tracking';
|
import { useTracking } from '../features/Tracking';
|
||||||
import { useMenu } from '../hooks/useMenu';
|
import { useMenu } from '../hooks/useMenu';
|
||||||
import { useOnce } from '../hooks/useOnce';
|
import { useOnce } from '../hooks/useOnce';
|
||||||
@ -93,14 +94,16 @@ const AdminLayout = () => {
|
|||||||
pluginsSectionLinks,
|
pluginsSectionLinks,
|
||||||
} = useMenu(checkLatestStrapiVersion(strapiVersion, tagName));
|
} = useMenu(checkLatestStrapiVersion(strapiVersion, tagName));
|
||||||
|
|
||||||
/**
|
const getAllWidgets = useStrapiApp('TrackingProvider', (state) => state.widgets.getAll);
|
||||||
* Make sure the event is only send once after accessing the admin panel
|
const projectId = appInfo?.projectId;
|
||||||
* and not at runtime for example when regenerating the permissions with the ctb
|
React.useEffect(() => {
|
||||||
* or with i18n
|
if (projectId) {
|
||||||
*/
|
trackUsage('didAccessAuthenticatedAdministration', {
|
||||||
useOnce(() => {
|
registeredWidgets: getAllWidgets().map((widget) => widget.uid),
|
||||||
trackUsage('didAccessAuthenticatedAdministration');
|
projectId,
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
}, [projectId, getAllWidgets, trackUsage]);
|
||||||
|
|
||||||
// We don't need to wait for the release query to be fetched before rendering the plugins
|
// We don't need to wait for the release query to be fetched before rendering the plugins
|
||||||
// however, we need the appInfos and the permissions
|
// however, we need the appInfos and the permissions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user