-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* handle state * handle onboarding flow * tests * fix timing to save erase event * dah * typo * events * events
- Loading branch information
1 parent
653b1e4
commit 46aae2b
Showing
8 changed files
with
197 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
/** | ||
* Saves an onboarding analytics event in state | ||
* | ||
* @param {object} event - Event object | ||
*/ | ||
export function saveOnboardingEvent(event) { | ||
return { | ||
type: 'SAVE_EVENT', | ||
event | ||
}; | ||
} | ||
|
||
/** | ||
* Erases any event stored in state | ||
*/ | ||
export function clearOnboardingEvents() { | ||
return { | ||
type: 'CLEAR_EVENTS' | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { REHYDRATE } from 'redux-persist'; | ||
|
||
const initialState = { | ||
events: [] | ||
}; | ||
|
||
/** | ||
* Reducer to keep track of user oboarding actions to send it to analytics if the user | ||
* decides to optin after finishing onboarding flow | ||
*/ | ||
const onboardingReducer = (state = initialState, action) => { | ||
switch (action.type) { | ||
case REHYDRATE: | ||
if (action.payload && action.payload.onboarding) { | ||
return { ...state, ...action.payload.onboarding }; | ||
} | ||
return state; | ||
case 'SAVE_EVENT': | ||
state.events.push(action.event); | ||
return state; | ||
case 'CLEAR_EVENTS': | ||
return { | ||
...state, | ||
events: [] | ||
}; | ||
default: | ||
return state; | ||
} | ||
}; | ||
|
||
export default onboardingReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters