mirror of
https://github.com/strapi/strapi.git
synced 2025-11-02 10:55:37 +00:00
Add environment to the admin analytics calls the correct way
This commit is contained in:
parent
42261b8a0a
commit
cc4a3ba507
@ -13,6 +13,7 @@ import {
|
||||
useNotification,
|
||||
TrackingContext,
|
||||
prefixFileUrlWithBackendUrl,
|
||||
useAppInfos,
|
||||
} from '@strapi/helper-plugin';
|
||||
import { SkipToContent } from '@strapi/design-system/Main';
|
||||
import { useIntl } from 'react-intl';
|
||||
@ -34,6 +35,7 @@ function App() {
|
||||
const { updateProjectSettings } = useConfigurations();
|
||||
const { formatMessage } = useIntl();
|
||||
const [{ isLoading, hasAdmin, uuid }, setState] = useState({ isLoading: true, hasAdmin: false });
|
||||
const appInfo = useAppInfos();
|
||||
|
||||
const authRoutes = useMemo(() => {
|
||||
return makeUniqueRoutes(
|
||||
@ -85,8 +87,8 @@ function App() {
|
||||
uuid,
|
||||
deviceId,
|
||||
properties: {
|
||||
environment: process.env.NODE_ENV
|
||||
}
|
||||
environment: appInfo.currentEnvironment,
|
||||
},
|
||||
}),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
@ -107,6 +109,7 @@ function App() {
|
||||
};
|
||||
|
||||
getData();
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [toggleNotification, updateProjectSettings]);
|
||||
|
||||
const setHasAdmin = hasAdmin => setState(prev => ({ ...prev, hasAdmin }));
|
||||
|
||||
@ -1,17 +1,23 @@
|
||||
import { useContext, useRef } from 'react';
|
||||
import axios from 'axios';
|
||||
import TrackingContext from '../../contexts/TrackingContext';
|
||||
import useAppInfos from '../useAppInfos';
|
||||
|
||||
const useTracking = () => {
|
||||
const trackRef = useRef();
|
||||
const uuid = useContext(TrackingContext);
|
||||
const appInfo = useAppInfos();
|
||||
|
||||
trackRef.current = (event, properties) => {
|
||||
if (uuid) {
|
||||
try {
|
||||
axios.post('https://analytics.strapi.io/track', {
|
||||
event,
|
||||
properties: { ...properties, projectType: strapi.projectType, environment: process.env.NODE_ENV },
|
||||
properties: {
|
||||
...properties,
|
||||
projectType: strapi.projectType,
|
||||
environment: appInfo.currentEnvironment,
|
||||
},
|
||||
uuid,
|
||||
});
|
||||
} catch (err) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user