From 77fcafb921d4d38339ed04cc1d7161099081a338 Mon Sep 17 00:00:00 2001 From: Marcin Rataj Date: Fri, 5 Apr 2024 23:36:14 +0200 Subject: [PATCH 1/2] chore: disable countly analytics Minimal changes to hide analytics UI components and stop sending opt-out metrics to instance which no longer works. Close #2198 --- src/bundles/analytics.js | 14 +++++++++++++- src/settings/SettingsPage.js | 14 +++++++++----- src/status/StatusPage.js | 4 +++- 3 files changed, 25 insertions(+), 7 deletions(-) diff --git a/src/bundles/analytics.js b/src/bundles/analytics.js index 0af2438ee..1f13db2eb 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/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 && Date: Mon, 8 Apr 2024 20:07:37 +0200 Subject: [PATCH 2/2] fix(analytics): opt-out and hide ui components https://github.com/ipfs/ipfs-webui/pull/2216/files#r1556085374 --- src/bundles/analytics.js | 4 ++-- src/bundles/analytics.test.js | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/bundles/analytics.js b/src/bundles/analytics.js index 1f13db2eb..eb1544636 100644 --- a/src/bundles/analytics.js +++ b/src/bundles/analytics.js @@ -453,9 +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 + showAnalyticsComponents: !DISABLE_ALL_ANALYTICS, // hide related UI for now, see https://github.com/ipfs/ipfs-webui/issues/2198 showAnalyticsBanner: false, - optedOut: !DISABLE_ALL_ANALYTICS, // disable analytics by default for now, see https://github.com/ipfs/ipfs-webui/issues/2198 + 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(),