2016-06-01 10:29:15 +05:30
|
|
|
import 'polyfills';
|
2019-11-09 22:56:46 +05:30
|
|
|
import 'react-hot-loader';
|
2016-01-03 01:54:07 +05:30
|
|
|
|
|
|
|
import React from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
2016-05-10 10:47:40 +05:30
|
|
|
import { factory as userFactory } from 'components/user/factory';
|
2017-05-26 00:41:57 +05:30
|
|
|
import authFlow from 'services/authFlow';
|
2016-06-18 20:30:45 +05:30
|
|
|
import storeFactory from 'storeFactory';
|
2016-07-30 00:59:27 +05:30
|
|
|
import bsodFactory from 'components/ui/bsod/factory';
|
2016-11-19 15:04:19 +05:30
|
|
|
import loader from 'services/loader';
|
2016-12-07 02:36:45 +05:30
|
|
|
import logger from 'services/logger';
|
2017-01-25 11:22:19 +05:30
|
|
|
import font from 'services/font';
|
2017-05-26 00:41:57 +05:30
|
|
|
import history, { browserHistory } from 'services/history';
|
2019-11-11 14:10:05 +05:30
|
|
|
import i18n from 'services/i18n';
|
2019-11-09 22:56:46 +05:30
|
|
|
import { loadScript, debounce } from 'functions';
|
|
|
|
|
|
|
|
import App from './App';
|
2017-01-29 21:06:21 +05:30
|
|
|
|
|
|
|
history.init();
|
2016-12-07 02:36:45 +05:30
|
|
|
|
|
|
|
logger.init({
|
2017-01-03 11:26:38 +05:30
|
|
|
sentryCdn: window.SENTRY_CDN
|
2016-12-07 02:36:45 +05:30
|
|
|
});
|
2016-01-03 01:54:07 +05:30
|
|
|
|
2016-06-18 20:30:45 +05:30
|
|
|
const store = storeFactory();
|
2016-01-03 01:54:07 +05:30
|
|
|
|
2017-05-26 00:41:57 +05:30
|
|
|
bsodFactory(store, () => loader.hide());
|
|
|
|
authFlow.setStore(store);
|
2016-07-30 00:59:27 +05:30
|
|
|
|
2016-10-11 09:37:09 +05:30
|
|
|
Promise.all([
|
|
|
|
userFactory(store),
|
2019-11-11 14:10:05 +05:30
|
|
|
font.load(['Roboto', 'Roboto Condensed']),
|
|
|
|
i18n.ensureIntl(), // ensure, that intl is polyfilled before any rendering
|
2019-11-09 22:56:46 +05:30
|
|
|
]).then(() => {
|
|
|
|
ReactDOM.render(
|
|
|
|
<App store={store} browserHistory={browserHistory} />,
|
|
|
|
document.getElementById('app')
|
|
|
|
);
|
2017-01-03 11:26:38 +05:30
|
|
|
|
2019-11-09 22:56:46 +05:30
|
|
|
initAnalytics();
|
|
|
|
});
|
2016-05-09 00:58:51 +05:30
|
|
|
|
2017-01-03 11:26:38 +05:30
|
|
|
const trackPageView = debounce(_trackPageView);
|
|
|
|
function initAnalytics() {
|
|
|
|
if (!window.ga) {
|
|
|
|
const ga = window.ga = function() {
|
|
|
|
(ga.q = ga.q || []).push(arguments); // eslint-disable-line
|
|
|
|
};
|
|
|
|
ga.l = Date.now(); // eslint-disable-line
|
|
|
|
|
|
|
|
if (window.GA_ID) {
|
|
|
|
// when GA is not available, we will continue to push into array
|
|
|
|
// for debug purposes
|
2018-03-26 00:53:10 +05:30
|
|
|
// Catch to prevent "unhandled rejection" error
|
|
|
|
loadScript('https://www.google-analytics.com/analytics.js').catch(() => {});
|
2017-01-03 11:26:38 +05:30
|
|
|
}
|
2016-11-20 17:31:57 +05:30
|
|
|
|
2017-01-03 11:26:38 +05:30
|
|
|
ga('create', window.GA_ID, 'auto');
|
|
|
|
trackPageView(location);
|
2016-11-20 17:31:57 +05:30
|
|
|
|
2017-01-03 11:26:38 +05:30
|
|
|
browserHistory.listen(trackPageView);
|
2016-11-20 17:31:57 +05:30
|
|
|
}
|
2017-01-03 11:26:38 +05:30
|
|
|
}
|
|
|
|
|
|
|
|
function _trackPageView(location) {
|
|
|
|
const ga = window.ga;
|
2016-11-20 17:31:57 +05:30
|
|
|
|
|
|
|
ga('set', 'page', location.pathname + location.search);
|
|
|
|
ga('send', 'pageview');
|
|
|
|
}
|
|
|
|
|
2016-06-04 14:47:06 +05:30
|
|
|
/* global process: false */
|
2016-04-12 09:19:58 +05:30
|
|
|
if (process.env.NODE_ENV !== 'production') {
|
|
|
|
// some shortcuts for testing on localhost
|
2016-11-19 20:11:15 +05:30
|
|
|
window.testOAuth = (loginHint = '') => location.href = `/oauth2/v1/ely?client_id=ely&redirect_uri=http%3A%2F%2Fely.by%2Fauthorization%2Foauth&response_type=code&scope=account_info%2Caccount_email&login_hint=${loginHint}`;
|
2017-10-17 23:20:34 +05:30
|
|
|
window.testOAuthPermissions = () => location.href = '/oauth2/v1/tlauncher?client_id=tlauncher&redirect_uri=http%3A%2F%2Flocalhost%3A8080&response_type=code&scope=account_info,account_email';
|
2016-11-19 20:11:15 +05:30
|
|
|
window.testOAuthPromptAccount = () => location.href = '/oauth2/v1/ely?client_id=ely&redirect_uri=http%3A%2F%2Fely.by%2Fauthorization%2Foauth&response_type=code&scope=account_info%2Caccount_email&prompt=select_account';
|
|
|
|
window.testOAuthPromptPermissions = (loginHint = '') => location.href = `/oauth2/v1/ely?client_id=ely&redirect_uri=http%3A%2F%2Fely.by%2Fauthorization%2Foauth&response_type=code&scope=account_info%2Caccount_email&prompt=consent&login_hint=${loginHint}`;
|
|
|
|
window.testOAuthPromptAll = () => location.href = '/oauth2/v1/ely?client_id=ely&redirect_uri=http%3A%2F%2Fely.by%2Fauthorization%2Foauth&response_type=code&scope=account_info%2Caccount_email&prompt=select_account,consent';
|
2016-10-25 12:02:50 +05:30
|
|
|
window.testOAuthStatic = () => location.href = '/oauth2/v1/ely?client_id=ely&redirect_uri=static_page_with_code&response_type=code&scope=account_info%2Caccount_email';
|
|
|
|
window.testOAuthStaticCode = () => location.href = '/oauth2/v1/ely?client_id=ely&redirect_uri=static_page&response_type=code&scope=account_info%2Caccount_email';
|
2016-04-12 09:19:58 +05:30
|
|
|
}
|