2019-09-06 11:40:00 +00:00
|
|
|
import FontFaceObserver from 'fontfaceobserver'
|
2019-08-30 10:33:49 +00:00
|
|
|
import { ReduxAction } from "../constants/ActionConstants"
|
|
|
|
|
import { SENTRY_PROD_CONFIG, SENTRY_STAGE_CONFIG, HOTJAR_PROD_HJID, HOTJAR_PROD_HJSV } from "../constants/ThirdPartyConstants";
|
|
|
|
|
import * as Sentry from '@sentry/browser';
|
2019-08-30 11:23:42 +00:00
|
|
|
import AnalyticsUtil from "./AnalyticsUtil"
|
2019-09-02 15:36:24 +00:00
|
|
|
import netlifyIdentity from 'netlify-identity-widget';
|
2019-08-30 10:33:49 +00:00
|
|
|
|
|
|
|
|
export const createReducer = (
|
|
|
|
|
initialState: any,
|
|
|
|
|
handlers: { [type: string]: Function }
|
|
|
|
|
) => {
|
|
|
|
|
return function reducer(state = initialState, action: ReduxAction<any>) {
|
|
|
|
|
if (handlers.hasOwnProperty(action.type)) {
|
|
|
|
|
return handlers[action.type](state, action)
|
|
|
|
|
} else {
|
|
|
|
|
return state
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
export const appInitializer = () => {
|
2019-09-02 15:36:24 +00:00
|
|
|
netlifyIdentity.init();
|
2019-08-30 10:33:49 +00:00
|
|
|
switch (process.env.REACT_APP_ENVIRONMENT) {
|
|
|
|
|
case "PRODUCTION":
|
|
|
|
|
Sentry.init(SENTRY_PROD_CONFIG);
|
2019-08-30 11:23:42 +00:00
|
|
|
AnalyticsUtil.initializeHotjar(HOTJAR_PROD_HJID, HOTJAR_PROD_HJSV);
|
|
|
|
|
AnalyticsUtil.initializeSegment();
|
2019-08-30 10:33:49 +00:00
|
|
|
break;
|
|
|
|
|
case "STAGING":
|
|
|
|
|
Sentry.init(SENTRY_STAGE_CONFIG);
|
|
|
|
|
break
|
|
|
|
|
case "LOCAL":
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-06 11:40:00 +00:00
|
|
|
const textFont = new FontFaceObserver("DM Sans");
|
|
|
|
|
textFont.load().then(()=> {
|
|
|
|
|
document.body.className += "fontLoaded";
|
|
|
|
|
}).catch(err => {
|
|
|
|
|
console.log(err);
|
|
|
|
|
});
|
|
|
|
|
}
|