From 6e08bc2045591cc5495caa99e6baf29a74389c76 Mon Sep 17 00:00:00 2001 From: ivanThePleasant Date: Wed, 30 Mar 2022 10:19:28 +0300 Subject: [PATCH] Revert "Added telemetry disable logic to the admin panel events" This reverts commit c6307ece6357737a5c7afdc60169672b6122c617. --- .../core/admin/admin/src/pages/App/index.js | 47 +++++++++---------- .../core/admin/server/controllers/admin.js | 3 +- .../lib/src/hooks/useTracking/index.js | 24 +++++----- 3 files changed, 33 insertions(+), 41 deletions(-) diff --git a/packages/core/admin/admin/src/pages/App/index.js b/packages/core/admin/admin/src/pages/App/index.js index fc25e76844..cd2cb5194b 100644 --- a/packages/core/admin/admin/src/pages/App/index.js +++ b/packages/core/admin/admin/src/pages/App/index.js @@ -30,10 +30,7 @@ const AuthenticatedApp = lazy(() => function App() { const toggleNotification = useNotification(); const { formatMessage } = useIntl(); - const [{ isLoading, hasAdmin, uuid, telemetryDisabled }, setState] = useState({ - isLoading: true, - hasAdmin: false, - }); + const [{ isLoading, hasAdmin, uuid }, setState] = useState({ isLoading: true, hasAdmin: false }); const authRoutes = useMemo(() => { return makeUniqueRoutes( @@ -69,32 +66,30 @@ function App() { const getData = async () => { try { const { - data: { hasAdmin, uuid, telemetryDisabled }, + data: { hasAdmin, uuid }, } = await request('/admin/init', { method: 'GET' }); - setState({ isLoading: false, hasAdmin, uuid, telemetryDisabled }); + if (uuid) { + try { + const deviceId = await getUID(); - if (telemetryDisabled || !uuid) { - return; + fetch('https://analytics.strapi.io/track', { + method: 'POST', + body: JSON.stringify({ + event: 'didInitializeAdministration', + uuid, + deviceId, + }), + headers: { + 'Content-Type': 'application/json', + }, + }); + } catch (e) { + // Silent. + } } - try { - const deviceId = await getUID(); - - fetch('https://analytics.strapi.io/track', { - method: 'POST', - body: JSON.stringify({ - event: 'didInitializeAdministration', - uuid, - deviceId, - }), - headers: { - 'Content-Type': 'application/json', - }, - }); - } catch (e) { - // Silent. - } + setState({ isLoading: false, hasAdmin, uuid }); } catch (err) { toggleNotification({ type: 'warning', @@ -115,7 +110,7 @@ function App() { return ( }> {formatMessage({ id: 'skipToContent' })} - + {authRoutes} { const trackRef = useRef(); - const { uuid, telemetryDisabled } = useContext(TrackingContext); + const uuid = useContext(TrackingContext); trackRef.current = (event, properties) => { - if (telemetryDisabled || !uuid) { - return; - } - - try { - axios.post('https://analytics.strapi.io/track', { - event, - properties: { ...properties, projectType: strapi.projectType }, - uuid, - }); - } catch (err) { - // Silent + if (uuid) { + try { + axios.post('https://analytics.strapi.io/track', { + event, + properties: { ...properties, projectType: strapi.projectType }, + uuid, + }); + } catch (err) { + // Silent + } } };