Skip to content

Commit

Permalink
enable analytics for EXPERIMENTS_TOGGLE
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Henrique Dias <hacdias@gmail.com>
  • Loading branch information
hacdias committed Jun 6, 2019
1 parent b97601a commit cbbf1c7
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
3 changes: 2 additions & 1 deletion src/bundles/analytics.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ const ASYNC_ACTIONS_TO_RECORD = [
'FILES_ADDBYPATH',
'FILES_MOVE',
'FILES_DELETE',
'FILES_DOWNLOADLINK'
'FILES_DOWNLOADLINK',
'EXPERIMENTS_TOGGLE'
]

const ASYNC_ACTION_RE = new RegExp(`^${ASYNC_ACTIONS_TO_RECORD.join('_|')}`)
Expand Down
18 changes: 9 additions & 9 deletions src/bundles/experiments.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { createSelector } from 'redux-bundler'

export const ACTIONS = {
EXP_TOGGLE: 'EXPERIMENTS_TOGGLE',
EXP_TOGGLE_SUCCESS: 'EXPERIMENTS_TOGGLE_SUCCESS',
EXP_TOGGLE_FAIL: 'EXPERIMENTS_TOGGLE_FAIL',
EXP_TOGGLE_STARTED: 'EXPERIMENTS_TOGGLE_STARTED',
EXP_TOGGLE_FINISH: 'EXPERIMENTS_TOGGLE_FINISH',
EXP_TOGGLE_FAILED: 'EXPERIMENTS_TOGGLE_FAILED',
EXP_UPDATE_STATE: 'EXPERIMENTS_UPDATE_STATE'
}

Expand Down Expand Up @@ -73,25 +73,25 @@ export default {
name: 'experiments',

persistActions: [
'EXPERIMENTS_TOGGLE_SUCCESS',
'EXPERIMENTS_TOGGLE_FAIL',
'EXPERIMENTS_UPDATE_STATE'
ACTIONS.EXP_TOGGLE_FINISH,
ACTIONS.EXP_TOGGLE_FAILED,
ACTIONS.EXP_UPDATE_STATE
],

reducer: (state = {}, action) => {
if (action.type === ACTIONS.EXP_TOGGLE) {
if (action.type === ACTIONS.EXP_TOGGLE_STARTED) {
return block(state, action.payload.key)
}

if (action.type === ACTIONS.EXP_UPDATE_STATE) {
return mergeState(state, action.payload)
}

if (action.type === ACTIONS.EXP_TOGGLE_SUCCESS) {
if (action.type === ACTIONS.EXP_TOGGLE_FINISH) {
return toggleEnabled(state, action.payload.key)
}

if (action.type === ACTIONS.EXP_TOGGLE_FAIL) {
if (action.type === ACTIONS.EXP_TOGGLE_FAILED) {
return unblock(state, action.payload.key)
}

Expand Down
6 changes: 3 additions & 3 deletions src/bundles/ipfs-desktop.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ if (window.ipfsDesktop) {
bundle = {
...bundle,
reducer: (state = {}, action) => {
if (action.type === ACTIONS.EXP_TOGGLE) {
if (action.type === ACTIONS.EXP_TOGGLE_STARTED) {
window.ipfsDesktop.toggleSetting(`experiments.${action.payload.key}`)
}

Expand Down Expand Up @@ -52,9 +52,9 @@ if (window.ipfsDesktop) {
const key = changed.replace('experiments.', '')

if (success) {
dispatch({ type: ACTIONS.EXP_TOGGLE_SUCCESS, payload: { key } })
dispatch({ type: ACTIONS.EXP_TOGGLE_FINISH, payload: { key } })
} else {
dispatch({ type: ACTIONS.EXP_TOGGLE_FAIL, payload: { key } })
dispatch({ type: ACTIONS.EXP_TOGGLE_FAILED, payload: { key } })
}
}

Expand Down
3 changes: 2 additions & 1 deletion src/bundles/notify.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { createSelector } from 'redux-bundler'
import { ACTIONS as EXP_ACTIONS } from './experiments'

/*
# Notify
Expand Down Expand Up @@ -59,7 +60,7 @@ const notify = {
}
}

if (action.type === 'EXPERIMENTS_TOGGLE_FAIL') {
if (action.type === EXP_ACTIONS.EXP_TOGGLE_FAILED) {
return {
...state,
show: true,
Expand Down

0 comments on commit cbbf1c7

Please sign in to comment.