Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: disable countly analytics and hide unused UI #2216

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading