diff --git a/src/bundles/analytics.js b/src/bundles/analytics.js index 0af2438ee..eb1544636 100644 --- a/src/bundles/analytics.js +++ b/src/bundles/analytics.js @@ -65,12 +65,18 @@ import { onlyOnceAfter } from '../lib/hofs/functions.js' * @property {number} lastDisabledAt * @property {string[]} consent * @property {boolean?} showAnalyticsBanner + * @property {boolean?} showAnalyticsComponents * @property {boolean?} optedOut * * @typedef {Object} State * @property {Model} analytics */ +// 2024-Q2: +// All analytics are disabled since we no longer use Countly instance. +// See https://github.com/ipfs/ipfs-webui/issues/2198 +const DISABLE_ALL_ANALYTICS = true + // Unknown actions (can't seem to see anything // dispatching those). const DESKTOP = Enum.from(['DESKTOP_SETTING_TOGGLE']) @@ -213,6 +219,11 @@ const selectors = { * @param {State} state */ selectAnalyticsOptedOut: (state) => state.analytics.optedOut, + /** + * Show or hide all UI compontent related to analytics. + * @param {State} state + */ + selectShowAnalyticsComponents: (state) => state.analytics.showAnalyticsComponents, /** * Show or hide the analytics banner. * @param {State} state @@ -442,8 +453,9 @@ const createAnalyticsBundle = ({ state = state || { lastEnabledAt: 0, lastDisabledAt: 0, + showAnalyticsComponents: !DISABLE_ALL_ANALYTICS, // hide related UI for now, see https://github.com/ipfs/ipfs-webui/issues/2198 showAnalyticsBanner: false, - optedOut: false, + optedOut: DISABLE_ALL_ANALYTICS, // disable analytics by default for now, see https://github.com/ipfs/ipfs-webui/issues/2198 consent: [] } diff --git a/src/bundles/analytics.test.js b/src/bundles/analytics.test.js index a5e9a61c9..7f81a15a8 100644 --- a/src/bundles/analytics.test.js +++ b/src/bundles/analytics.test.js @@ -35,6 +35,17 @@ function createStore (analyticsOpts = {}, mockAnalyticsCachedState) { } describe('new/returning user default behavior', () => { + // 2024-Q2: disabling and hiding all metrics for now + // https://github.com/ipfs/ipfs-webui/pull/2216 + it('should disable analytics by default and hide all UI compontents', () => { + const store = createStore() + expect(store.selectAnalyticsEnabled()).toBe(false) + expect(store.selectShowAnalyticsComponents()).toBe(false) + expect(store.selectAnalyticsConsent()).toEqual([]) + expect(global.Countly.opt_in).not.toHaveBeenCalled() + expect(global.Countly.opt_out).not.toHaveBeenCalled() + }) + /* it('should enable analytics by default for new user who has not opted in or out', () => { const store = createStore() expect(global.Countly.opt_in).toHaveBeenCalled() @@ -42,6 +53,7 @@ describe('new/returning user default behavior', () => { // events will be sent as consents have been given by default expect(store.selectAnalyticsConsent()).toEqual(['sessions', 'events', 'views', 'location']) }) + */ it('should enable existing analytics by default for returning user who was opted_in', () => { const mockDefaultState = { lastEnabledAt: (new Date('2022-01-02')).getTime(), diff --git a/src/settings/SettingsPage.js b/src/settings/SettingsPage.js index b1ccab602..e795e3391 100644 --- a/src/settings/SettingsPage.js +++ b/src/settings/SettingsPage.js @@ -33,6 +33,7 @@ export const SettingsPage = ({ isLoading, isSaving, arePinningServicesSupported, hasSaveFailed, hasSaveSucceded, hasErrors, hasLocalChanges, hasExternalChanges, config, onChange, onReset, onSave, editorKey, analyticsEnabled, doToggleAnalytics, + showAnalyticsComponents, toursEnabled, handleJoyrideCallback, isCliTutorModeEnabled, doToggleCliTutorMode, command }) => (
@@ -92,15 +93,17 @@ export const SettingsPage = ({ -
+
{t('language')}
-
- {t('analytics')} - -
+ { showAnalyticsComponents + ?
+ {t('analytics')} + +
+ : null } @@ -376,6 +379,7 @@ export default connect( 'selectConfigSaveLastError', 'selectIsIpfsDesktop', 'selectToursEnabled', + 'selectShowAnalyticsComponents', 'selectAnalyticsEnabled', 'selectArePinningServicesSupported', 'doToggleAnalytics', diff --git a/src/status/StatusPage.js b/src/status/StatusPage.js index 960626687..ae8c969ec 100644 --- a/src/status/StatusPage.js +++ b/src/status/StatusPage.js @@ -19,6 +19,7 @@ import withTour from '../components/tour/withTour.js' const StatusPage = ({ t, ipfsConnected, + showAnalyticsComponents, showAnalyticsBanner, doEnableAnalytics, doDisableAnalytics, @@ -53,7 +54,7 @@ const StatusPage = ({
- { ipfsConnected && showAnalyticsBanner && + { ipfsConnected && showAnalyticsComponents && showAnalyticsBanner &&