Skip to content

Commit

Permalink
chore: disable countly analytics and hide unused UI (#2216)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
lidel authored Apr 8, 2024
1 parent 51b2952 commit d137048
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
14 changes: 13 additions & 1 deletion src/bundles/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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'])
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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: []
}

Expand Down
12 changes: 12 additions & 0 deletions src/bundles/analytics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,25 @@ 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()
expect(global.Countly.opt_in.mock.calls.length).toBe(1)
// 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(),
Expand Down
14 changes: 9 additions & 5 deletions src/settings/SettingsPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
}) => (
<div data-id='SettingsPage' className='mw9 center'>
Expand Down Expand Up @@ -92,15 +93,17 @@ export const SettingsPage = ({
</Box>

<Box className='mb3 pa4-l pa2'>
<div className='mb4 joyride-settings-language'>
<div className='joyride-settings-language'>
<Title>{t('language')}</Title>
<LanguageSelector t={t} />
</div>

<div className='joyride-settings-analytics'>
<Title>{t('analytics')}</Title>
<AnalyticsToggle t={t} doToggleAnalytics={doToggleAnalytics} analyticsEnabled={analyticsEnabled} />
</div>
{ showAnalyticsComponents
? <div className='mt4 joyride-settings-analytics'>
<Title>{t('analytics')}</Title>
<AnalyticsToggle t={t} doToggleAnalytics={doToggleAnalytics} analyticsEnabled={analyticsEnabled} />
</div>
: null }
</Box>

<Experiments t={t} />
Expand Down Expand Up @@ -376,6 +379,7 @@ export default connect(
'selectConfigSaveLastError',
'selectIsIpfsDesktop',
'selectToursEnabled',
'selectShowAnalyticsComponents',
'selectAnalyticsEnabled',
'selectArePinningServicesSupported',
'doToggleAnalytics',
Expand Down
4 changes: 3 additions & 1 deletion src/status/StatusPage.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import withTour from '../components/tour/withTour.js'
const StatusPage = ({
t,
ipfsConnected,
showAnalyticsComponents,
showAnalyticsBanner,
doEnableAnalytics,
doDisableAnalytics,
Expand Down Expand Up @@ -53,7 +54,7 @@ const StatusPage = ({
</div>
</div>
</Box>
{ ipfsConnected && showAnalyticsBanner &&
{ ipfsConnected && showAnalyticsComponents && showAnalyticsBanner &&
<AnalyticsBanner
className='mt3'
label={t('AnalyticsBanner.label')}
Expand Down Expand Up @@ -92,6 +93,7 @@ export default connect(
'selectIpfsConnected',
'selectNodeBandwidthEnabled',
'selectShowAnalyticsBanner',
'selectShowAnalyticsComponents',
'selectToursEnabled',
'doEnableAnalytics',
'doDisableAnalytics',
Expand Down

0 comments on commit d137048

Please sign in to comment.