Skip to content

Commit d137048

Browse files
authored
chore: disable countly analytics and hide unused UI (#2216)
* 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 * fix(analytics): opt-out and hide ui components https://github.com/ipfs/ipfs-webui/pull/2216/files#r1556085374
1 parent 51b2952 commit d137048

File tree

4 files changed

+37
-7
lines changed

4 files changed

+37
-7
lines changed

src/bundles/analytics.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,12 +65,18 @@ import { onlyOnceAfter } from '../lib/hofs/functions.js'
6565
* @property {number} lastDisabledAt
6666
* @property {string[]} consent
6767
* @property {boolean?} showAnalyticsBanner
68+
* @property {boolean?} showAnalyticsComponents
6869
* @property {boolean?} optedOut
6970
*
7071
* @typedef {Object} State
7172
* @property {Model} analytics
7273
*/
7374

75+
// 2024-Q2:
76+
// All analytics are disabled since we no longer use Countly instance.
77+
// See https://github.com/ipfs/ipfs-webui/issues/2198
78+
const DISABLE_ALL_ANALYTICS = true
79+
7480
// Unknown actions (can't seem to see anything
7581
// dispatching those).
7682
const DESKTOP = Enum.from(['DESKTOP_SETTING_TOGGLE'])
@@ -213,6 +219,11 @@ const selectors = {
213219
* @param {State} state
214220
*/
215221
selectAnalyticsOptedOut: (state) => state.analytics.optedOut,
222+
/**
223+
* Show or hide all UI compontent related to analytics.
224+
* @param {State} state
225+
*/
226+
selectShowAnalyticsComponents: (state) => state.analytics.showAnalyticsComponents,
216227
/**
217228
* Show or hide the analytics banner.
218229
* @param {State} state
@@ -442,8 +453,9 @@ const createAnalyticsBundle = ({
442453
state = state || {
443454
lastEnabledAt: 0,
444455
lastDisabledAt: 0,
456+
showAnalyticsComponents: !DISABLE_ALL_ANALYTICS, // hide related UI for now, see https://github.com/ipfs/ipfs-webui/issues/2198
445457
showAnalyticsBanner: false,
446-
optedOut: false,
458+
optedOut: DISABLE_ALL_ANALYTICS, // disable analytics by default for now, see https://github.com/ipfs/ipfs-webui/issues/2198
447459
consent: []
448460
}
449461

src/bundles/analytics.test.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,25 @@ function createStore (analyticsOpts = {}, mockAnalyticsCachedState) {
3535
}
3636

3737
describe('new/returning user default behavior', () => {
38+
// 2024-Q2: disabling and hiding all metrics for now
39+
// https://github.com/ipfs/ipfs-webui/pull/2216
40+
it('should disable analytics by default and hide all UI compontents', () => {
41+
const store = createStore()
42+
expect(store.selectAnalyticsEnabled()).toBe(false)
43+
expect(store.selectShowAnalyticsComponents()).toBe(false)
44+
expect(store.selectAnalyticsConsent()).toEqual([])
45+
expect(global.Countly.opt_in).not.toHaveBeenCalled()
46+
expect(global.Countly.opt_out).not.toHaveBeenCalled()
47+
})
48+
/*
3849
it('should enable analytics by default for new user who has not opted in or out', () => {
3950
const store = createStore()
4051
expect(global.Countly.opt_in).toHaveBeenCalled()
4152
expect(global.Countly.opt_in.mock.calls.length).toBe(1)
4253
// events will be sent as consents have been given by default
4354
expect(store.selectAnalyticsConsent()).toEqual(['sessions', 'events', 'views', 'location'])
4455
})
56+
*/
4557
it('should enable existing analytics by default for returning user who was opted_in', () => {
4658
const mockDefaultState = {
4759
lastEnabledAt: (new Date('2022-01-02')).getTime(),

src/settings/SettingsPage.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export const SettingsPage = ({
3333
isLoading, isSaving, arePinningServicesSupported,
3434
hasSaveFailed, hasSaveSucceded, hasErrors, hasLocalChanges, hasExternalChanges,
3535
config, onChange, onReset, onSave, editorKey, analyticsEnabled, doToggleAnalytics,
36+
showAnalyticsComponents,
3637
toursEnabled, handleJoyrideCallback, isCliTutorModeEnabled, doToggleCliTutorMode, command
3738
}) => (
3839
<div data-id='SettingsPage' className='mw9 center'>
@@ -92,15 +93,17 @@ export const SettingsPage = ({
9293
</Box>
9394

9495
<Box className='mb3 pa4-l pa2'>
95-
<div className='mb4 joyride-settings-language'>
96+
<div className='joyride-settings-language'>
9697
<Title>{t('language')}</Title>
9798
<LanguageSelector t={t} />
9899
</div>
99100

100-
<div className='joyride-settings-analytics'>
101-
<Title>{t('analytics')}</Title>
102-
<AnalyticsToggle t={t} doToggleAnalytics={doToggleAnalytics} analyticsEnabled={analyticsEnabled} />
103-
</div>
101+
{ showAnalyticsComponents
102+
? <div className='mt4 joyride-settings-analytics'>
103+
<Title>{t('analytics')}</Title>
104+
<AnalyticsToggle t={t} doToggleAnalytics={doToggleAnalytics} analyticsEnabled={analyticsEnabled} />
105+
</div>
106+
: null }
104107
</Box>
105108

106109
<Experiments t={t} />
@@ -376,6 +379,7 @@ export default connect(
376379
'selectConfigSaveLastError',
377380
'selectIsIpfsDesktop',
378381
'selectToursEnabled',
382+
'selectShowAnalyticsComponents',
379383
'selectAnalyticsEnabled',
380384
'selectArePinningServicesSupported',
381385
'doToggleAnalytics',

src/status/StatusPage.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import withTour from '../components/tour/withTour.js'
1919
const StatusPage = ({
2020
t,
2121
ipfsConnected,
22+
showAnalyticsComponents,
2223
showAnalyticsBanner,
2324
doEnableAnalytics,
2425
doDisableAnalytics,
@@ -53,7 +54,7 @@ const StatusPage = ({
5354
</div>
5455
</div>
5556
</Box>
56-
{ ipfsConnected && showAnalyticsBanner &&
57+
{ ipfsConnected && showAnalyticsComponents && showAnalyticsBanner &&
5758
<AnalyticsBanner
5859
className='mt3'
5960
label={t('AnalyticsBanner.label')}
@@ -92,6 +93,7 @@ export default connect(
9293
'selectIpfsConnected',
9394
'selectNodeBandwidthEnabled',
9495
'selectShowAnalyticsBanner',
96+
'selectShowAnalyticsComponents',
9597
'selectToursEnabled',
9698
'doEnableAnalytics',
9799
'doDisableAnalytics',

0 commit comments

Comments
 (0)