Revert "Added telemetry disable logic to the admin panel events"

This reverts commit c6307ece6357737a5c7afdc60169672b6122c617.
This commit is contained in:
ivanThePleasant 2022-03-30 10:19:28 +03:00
parent ab69f2bde1
commit 6e08bc2045
3 changed files with 33 additions and 41 deletions

View File

@ -30,10 +30,7 @@ const AuthenticatedApp = lazy(() =>
function App() { function App() {
const toggleNotification = useNotification(); const toggleNotification = useNotification();
const { formatMessage } = useIntl(); const { formatMessage } = useIntl();
const [{ isLoading, hasAdmin, uuid, telemetryDisabled }, setState] = useState({ const [{ isLoading, hasAdmin, uuid }, setState] = useState({ isLoading: true, hasAdmin: false });
isLoading: true,
hasAdmin: false,
});
const authRoutes = useMemo(() => { const authRoutes = useMemo(() => {
return makeUniqueRoutes( return makeUniqueRoutes(
@ -69,15 +66,10 @@ function App() {
const getData = async () => { const getData = async () => {
try { try {
const { const {
data: { hasAdmin, uuid, telemetryDisabled }, data: { hasAdmin, uuid },
} = await request('/admin/init', { method: 'GET' }); } = await request('/admin/init', { method: 'GET' });
setState({ isLoading: false, hasAdmin, uuid, telemetryDisabled }); if (uuid) {
if (telemetryDisabled || !uuid) {
return;
}
try { try {
const deviceId = await getUID(); const deviceId = await getUID();
@ -95,6 +87,9 @@ function App() {
} catch (e) { } catch (e) {
// Silent. // Silent.
} }
}
setState({ isLoading: false, hasAdmin, uuid });
} catch (err) { } catch (err) {
toggleNotification({ toggleNotification({
type: 'warning', type: 'warning',
@ -115,7 +110,7 @@ function App() {
return ( return (
<Suspense fallback={<LoadingIndicatorPage />}> <Suspense fallback={<LoadingIndicatorPage />}>
<SkipToContent>{formatMessage({ id: 'skipToContent' })}</SkipToContent> <SkipToContent>{formatMessage({ id: 'skipToContent' })}</SkipToContent>
<TrackingContext.Provider value={{ uuid, telemetryDisabled }}> <TrackingContext.Provider value={uuid}>
<Switch> <Switch>
{authRoutes} {authRoutes}
<Route <Route

View File

@ -38,10 +38,9 @@ module.exports = {
async init() { async init() {
const uuid = strapi.config.get('uuid', false); const uuid = strapi.config.get('uuid', false);
const telemetryDisabled = strapi.config.get('packageJsonStrapi.telemetryDisabled', false);
const hasAdmin = await getService('user').exists(); const hasAdmin = await getService('user').exists();
return { data: { uuid, telemetryDisabled, hasAdmin } }; return { data: { uuid, hasAdmin } };
}, },
async information() { async information() {

View File

@ -4,13 +4,10 @@ import TrackingContext from '../../contexts/TrackingContext';
const useTracking = () => { const useTracking = () => {
const trackRef = useRef(); const trackRef = useRef();
const { uuid, telemetryDisabled } = useContext(TrackingContext); const uuid = useContext(TrackingContext);
trackRef.current = (event, properties) => { trackRef.current = (event, properties) => {
if (telemetryDisabled || !uuid) { if (uuid) {
return;
}
try { try {
axios.post('https://analytics.strapi.io/track', { axios.post('https://analytics.strapi.io/track', {
event, event,
@ -20,6 +17,7 @@ const useTracking = () => {
} catch (err) { } catch (err) {
// Silent // Silent
} }
}
}; };
return { trackUsage: trackRef.current }; return { trackUsage: trackRef.current };