This file contains hidden or 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
export function trackable(action, event, properties = {}) { | |
const analytics = { | |
eventType: event, | |
eventPayload: properties | |
}; | |
return { ...action, meta: { analytics } }; | |
} |
This file contains hidden or 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
import constants from '../../constants'; | |
export function loadedDashboardState(website, status, news, revenues) { | |
return trackable({ | |
type: constants.DASHBOARD_STATE_LOADED, | |
payload: { website, status, news, revenues } | |
}, | |
'Dashboard opened', // <- event name | |
{ name: website.name } // <- additional event data | |
); |
This file contains hidden or 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
import { createStore, applyMiddleware } from 'redux'; | |
import { createAnalytics } from '../middleware'; | |
const middlewares = [ | |
thunk, | |
createLogger(), | |
createAnalytics({ host: 'ANALYTICS_HOST', token: 'ANALYTICS_TOKEN' }) | |
]; | |
const enchancer = applyMiddleware(...middlewares); |
This file contains hidden or 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
import { client } from '../analytics'; | |
const handleAction = (store, next, action, options) => { | |
if (!action.meta || !action.meta.analytics) { | |
return next(action); | |
} | |
const { eventType, eventPayload } = action.meta.analytics; | |
client(options).track(eventType, eventPayload); |
This file contains hidden or 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
import { createConstants } from '../utils'; | |
const constants = createConstants( | |
// account actions | |
'ACCOUNT_FORM_RESET', | |
'ACCOUNT_FORM_CHANGE', | |
'ACCOUNT_FORM_ERRORS', | |
'ACCOUNT_FORM_ERRORS_CLEAN', | |
'ACCOUNT_ACCESS_TOKEN_FETCHING', | |
'ACCOUNT_ACCESS_TOKEN_FETCHED', |
This file contains hidden or 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
export function composeComponents(component, wrappers = []) { | |
return wrappers.reduce((c, wrapper) => wrapper(c), component); | |
} |
This file contains hidden or 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
const CheckedWelcome = composeComponents( | |
Welcome, | |
[ | |
(c) => checkBoarded(c, { withValue: true, redirectTo: '/app/dashboard' }), | |
(c) => requiresAuth(c) | |
] | |
); | |
const CheckApp = composeComponents( | |
App, |
This file contains hidden or 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
const routes = ( | |
<Route path=""> | |
<Route path="/signup" component={SignUp} /> | |
<Route path="/signin" component={SignIn} /> | |
// applied here.. | |
<Route path="/welcome-on-board" component={checkBoarded(Welcome, { withValue: true, redirectTo: '/app/dashboard'}) } /> | |
<Route path="/forgot-password" component={ForgotPassword} /> | |
<Route path="/signout" component={SignOut} /> |
This file contains hidden or 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
export default function websiteContext(Component) { | |
class WebsiteContextComponent extends React.Component { | |
static propTypes = { | |
dispatch: PropTypes.func.isRequired, | |
state: PropTypes.object.isRequire, | |
params: PropTypes.shape({ | |
websiteId: PropTypes.string.isRequired | |
}) | |
}; |
This file contains hidden or 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
const routes = ( | |
<Route path=""> | |
<Route path="/signup" component={SignUp} /> | |
<Route path="/signin" component={SignIn} /> | |
// applied here.. | |
<Route path="/welcome-on-board" component={checkBoarded(Welcome, { withValue: true, redirectTo: '/app/dashboard'}) } /> | |
<Route path="/forgot-password" component={ForgotPassword} /> | |
<Route path="/signout" component={SignOut} /> |