2019-11-19 07:30:42 +03:00
|
|
|
import React from 'react';
|
|
|
|
import ReactDOM from 'react-dom';
|
2019-11-20 08:48:27 +03:00
|
|
|
import 'url-search-params-polyfill';
|
2019-11-19 07:30:42 +03:00
|
|
|
|
|
|
|
import Router from './router'
|
2020-07-15 12:14:53 +03:00
|
|
|
import ErrorBoundary from './error-boundary'
|
2021-03-02 12:15:43 +03:00
|
|
|
import * as api from './api'
|
2023-01-02 18:42:57 +03:00
|
|
|
import * as timer from './util/realtime-update-timer'
|
|
|
|
|
|
|
|
timer.start()
|
2019-11-19 07:30:42 +03:00
|
|
|
|
|
|
|
const container = document.getElementById('stats-react-container')
|
|
|
|
|
|
|
|
if (container) {
|
|
|
|
const site = {
|
|
|
|
domain: container.dataset.domain,
|
|
|
|
offset: container.dataset.offset,
|
2020-12-16 12:52:47 +03:00
|
|
|
hasGoals: container.dataset.hasGoals === 'true',
|
2023-06-13 13:26:33 +03:00
|
|
|
conversionsEnabled: container.dataset.conversionsEnabled === 'true',
|
|
|
|
funnelsEnabled: container.dataset.funnelsEnabled === 'true',
|
|
|
|
propsEnabled: container.dataset.propsEnabled === 'true',
|
|
|
|
funnels: JSON.parse(container.dataset.funnels),
|
2022-03-22 17:09:45 +03:00
|
|
|
statsBegin: container.dataset.statsBegin,
|
2023-05-03 11:46:13 +03:00
|
|
|
nativeStatsBegin: container.dataset.nativeStatsBegin,
|
2021-03-16 11:40:25 +03:00
|
|
|
embedded: container.dataset.embedded,
|
2021-04-12 12:21:07 +03:00
|
|
|
background: container.dataset.background,
|
2022-05-03 10:38:59 +03:00
|
|
|
isDbip: container.dataset.isDbip === 'true',
|
2022-11-22 15:50:58 +03:00
|
|
|
flags: JSON.parse(container.dataset.flags),
|
|
|
|
validIntervalsByPeriod: JSON.parse(container.dataset.validIntervalsByPeriod)
|
2019-11-19 07:30:42 +03:00
|
|
|
}
|
|
|
|
|
2020-08-13 13:45:18 +03:00
|
|
|
const loggedIn = container.dataset.loggedIn === 'true'
|
2021-06-16 15:00:07 +03:00
|
|
|
const currentUserRole = container.dataset.currentUserRole
|
2021-03-02 12:15:43 +03:00
|
|
|
const sharedLinkAuth = container.dataset.sharedLinkAuth
|
|
|
|
if (sharedLinkAuth) {
|
|
|
|
api.setSharedLinkAuth(sharedLinkAuth)
|
|
|
|
}
|
2020-08-13 13:45:18 +03:00
|
|
|
|
2020-07-15 12:14:53 +03:00
|
|
|
const app = (
|
|
|
|
<ErrorBoundary>
|
2021-06-16 15:00:07 +03:00
|
|
|
<Router site={site} loggedIn={loggedIn} currentUserRole={currentUserRole} />
|
2020-07-15 12:14:53 +03:00
|
|
|
</ErrorBoundary>
|
|
|
|
)
|
|
|
|
|
|
|
|
ReactDOM.render(app, container);
|
2019-11-19 07:30:42 +03:00
|
|
|
}
|