Skip to content

Commit

Permalink
fix(analytics): opt-out and hide ui components
Browse files Browse the repository at this point in the history
  • Loading branch information
lidel committed Apr 8, 2024
1 parent 77fcafb commit 6f36572
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/bundles/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -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: []
}

Expand Down
11 changes: 11 additions & 0 deletions src/bundles/analytics.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,24 @@ 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.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

0 comments on commit 6f36572

Please sign in to comment.