📈 Open source, privacy-first web analytics — a cookie-less Google Analytics alternative with built-in error tracking and performance monitoring. Self-host it or use our cloud. Get started for free!
TypeScript chartsclickhousedockergdprgoogle-analyticsmetricsmonitoringmysqlnestjsprivacyredisself-hostedselfhostedstatisticstailwindcssweb-analyticswebanalyticswebsite
Captcha view to ts
kruzhambusf5a419c2d04c
diff --git a/src/pages/Captcha/View/Panels.jsx b/src/pages/Captcha/View/Panels.tsxsimilarity index 95%rename from src/pages/Captcha/View/Panels.jsxrename to src/pages/Captcha/View/Panels.tsxindex 6ebaeba33..849da8faf 100644--- a/src/pages/Captcha/View/Panels.jsx+++ b/src/pages/Captcha/View/Panels.tsx@@ -33,14 +33,23 @@ const ENTRIES_PER_PANEL = 5const panelsWithBars = ['cc', 'ce', 'os', 'br', 'dv']-const checkIfBarsNeeded = (panelID) => {+const checkIfBarsNeeded = (panelID: string) => {return _includes(panelsWithBars, panelID)}// noSwitch - 'previous' and 'next' buttonsconst PanelContainer = ({name, children, noSwitch, icon, type, openModal, activeFragment, setActiveFragment,-}) => (+}: {+ name: string,+ children?: React.ReactNode,+ noSwitch?: boolean,+ icon?: React.ReactNode,+ type: string,+ openModal?: () => void,+ activeFragment: number | string,+ setActiveFragment: (arg: number) => void,+}): JSX.Element => (<divclassName={cx('relative bg-white dark:bg-gray-750 pt-5 px-4 min-h-72 sm:pt-6 sm:px-6 shadow rounded-lg overflow-hidden', {'pb-12': !noSwitch,@@ -112,6 +121,7 @@ PanelContainer.propTypes = {activeFragment: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),setActiveFragment: PropTypes.func,icon: PropTypes.node,+ openModal: PropTypes.func,}PanelContainer.defaultProps = {@@ -119,11 +129,20 @@ PanelContainer.defaultProps = {noSwitch: false,activeFragment: 0,setActiveFragment: () => { },+ openModal: () => { },}// First tab with statsconst Overview = ({overall, chartData, activePeriod, t, live, sessionDurationAVG, projectId,+}: {+ overall: any+ chartData: any+ activePeriod: any+ t: (arg: string) => string+ live: number+ sessionDurationAVG: number+ projectId: string}) => {const pageviewsDidGrowUp = overall.percChange >= 0const uniqueDidGrowUp = overall.percChangeUnique >= 0@@ -136,7 +155,7 @@ const Overview = ({}return (- <PanelContainer name={t('project.overview')} noSwitch>+ <PanelContainer name={t('project.overview')} noSwitch type='' openModal={() => {}}><div className='flex text-lg justify-between'><div className='flex items-center dark:text-gray-50'><PulsatingCircle className='mr-1.5' type='big' />@@ -275,7 +294,7 @@ const Overview = ({}// Options for circle chart showing the stats of data-const getPieOptions = (customs, uniques, t) => {+const getPieOptions = (customs: any, uniques: number, t: any) => {const tQuantity = t('project.quantity')const tConversion = t('project.conversion')const tRatio = t('project.ratio')@@ -319,11 +338,16 @@ const getPieOptions = (customs, uniques, t) => {// Tabs with custom events like submit form, press button, go to the link rate etc.const CustomEvents = ({customs, chartData, onFilter, t,+}: {+ customs: any+ chartData: any+ onFilter: any+ t: (arg0: string) => string}) => {const keys = _keys(customs)const uniques = _sum(chartData.uniques)- const [chartOptions, setChartOptions] = useState({})- const [activeFragment, setActiveFragment] = useState(0)+ const [chartOptions, setChartOptions] = useState<any>({})+ const [activeFragment, setActiveFragment] = useState<number>(0)useEffect(() => {if (!_isEmpty(chartData)) {@@ -411,7 +435,19 @@ CustomEvents.propTypes = {const Panel = ({name, data, rowMapper, valueMapper, capitalize, linkContent, t, icon, id, hideFilters, onFilter,-}) => {+}: {+ name: string+ data: any+ rowMapper: any+ valueMapper: any+ capitalize: boolean+ linkContent: boolean+ t: (arg0: string) => string+ icon: any+ id: string+ hideFilters: boolean+ onFilter: any+}): JSX.Element => {const [page, setPage] = useState(0)const currentIndex = page * ENTRIES_PER_PANELconst keys = useMemo(() => _keys(data).sort((a, b) => data[b] - data[a]), [data])diff --git a/src/pages/Captcha/View/ViewCaptcha.container.jsx b/src/pages/Captcha/View/ViewCaptcha.container.jsxdeleted file mode 100644index aa3f2a861..000000000--- a/src/pages/Captcha/View/ViewCaptcha.container.jsx+++ /dev/null@@ -1,33 +0,0 @@-import { connect } from 'react-redux'-import { errorsActions } from 'redux/reducers/errors'-import UIActions from 'redux/reducers/ui'--import ViewProject from './ViewCaptcha'--const mapStateToProps = (state) => ({- projects: state.ui.projects.captchaProjects,- isLoading: state.ui.projects.isLoadingCaptcha,- cache: state.ui.cache.captchaAnalytics,- projectViewPrefs: state.ui.cache.captchaProjectsViewPrefs,- authenticated: state.auth.authenticated,- timezone: state.auth.user.timezone,- isPaidTierUsed: state.auth.isPaidTierUsed,- user: state.auth.user,-})--const mapDispatchToProps = (dispatch) => ({- showError: (message) => {- dispatch(errorsActions.genericError(message))- },- setProjectCache: (pid, data, key) => {- dispatch(UIActions.setCaptchaProjectCache(pid, data, key))- },- setProjects: (project) => {- dispatch(UIActions.setCaptchaProjects(project))- },- setProjectViewPrefs: (pid, period, timeBucket, rangeDate) => {- dispatch(UIActions.setCaptchaProjectsViewPrefs(pid, period, timeBucket, rangeDate))- },-})--export default connect(mapStateToProps, mapDispatchToProps)(ViewProject)diff --git a/src/pages/Captcha/View/ViewCaptcha.container.tsx b/src/pages/Captcha/View/ViewCaptcha.container.tsxnew file mode 100644index 000000000..84e4ed094--- /dev/null+++ b/src/pages/Captcha/View/ViewCaptcha.container.tsx@@ -0,0 +1,46 @@+import { connect } from 'react-redux'+import { errorsActions } from 'redux/reducers/errors'+import UIActions from 'redux/reducers/ui'+import { StateType, AppDispatch } from 'redux/store'++import { ICaptchaProject } from 'redux/models/IProject'+import ViewCaptcha from './ViewCaptcha'++const mapStateToProps = (state: StateType) => ({+ projects: state.ui.projects.captchaProjects,+ isLoading: state.ui.projects.isLoadingCaptcha,+ cache: state.ui.cache.captchaAnalytics,+ projectViewPrefs: state.ui.cache.captchaProjectsViewPrefs,+ authenticated: state.auth.authenticated,+ timezone: state.auth.user.timezone,+ isPaidTierUsed: state.auth.isPaidTierUsed,+ user: state.auth.user,+})++const mapDispatchToProps = (dispatch: AppDispatch) => ({+ showError: (message: string) => {+ dispatch(errorsActions.genericError({+ message,+ }))+ },+ setProjectCache: (pid: string, data: any, key: string) => {+ dispatch(UIActions.setCaptchaProjectCache({+ pid,+ data,+ key,+ }))+ },+ setProjects: (project: ICaptchaProject[]) => {+ dispatch(UIActions.setCaptchaProjects(project))+ },+ setProjectViewPrefs: (pid: string, period: string, timeBucket: string, rangeDate?: Date[] | null) => {+ dispatch(UIActions.setCaptchaProjectViewPrefs({+ pid,+ period,+ timeBucket,+ rangeDate,+ }))+ },+})++export default connect(mapStateToProps, mapDispatchToProps)(ViewCaptcha)diff --git a/src/pages/Captcha/View/ViewCaptcha.helpers.jsx b/src/pages/Captcha/View/ViewCaptcha.helpers.tsxsimilarity index 85%rename from src/pages/Captcha/View/ViewCaptcha.helpers.jsxrename to src/pages/Captcha/View/ViewCaptcha.helpers.tsxindex b814740a3..92516f061 100644--- a/src/pages/Captcha/View/ViewCaptcha.helpers.jsx+++ b/src/pages/Captcha/View/ViewCaptcha.helpers.tsx@@ -1,8 +1,10 @@+// @ts-ignoreimport { saveAs } from 'file-saver'import {GlobeEuropeAfricaIcon, LanguageIcon, DocumentTextIcon, DeviceTabletIcon,ArrowRightCircleIcon, MagnifyingGlassIcon, ServerIcon,} from '@heroicons/react/24/outline'+// @ts-ignoreimport * as d3 from 'd3'import dayjs from 'dayjs'import {@@ -23,13 +25,13 @@ import {} from 'redux/constants'import countries from 'utils/isoCountries'-const getExportFilename = (prefix) => {+const getExportFilename = (prefix: string) => {// turn something like 2022-03-02T19:31:00.100Z into 2022-03-02const date = _split(_replace(_split(new Date().toISOString(), '.')[0], /:/g, '-'), 'T')[0]return `${prefix}-${date}.zip`}-const convertToCSV = (array) => {+const convertToCSV = (array: any[]) => {let str = 'name,value,perc\r\n'for (let i = 0; i < _size(array); ++i) {@@ -46,7 +48,12 @@ const convertToCSV = (array) => {return str}-const onCSVExportClick = (data, pid, tnMapping, language) => {+const onCSVExportClick = (data: {+ data: any,+ types: any,+}, pid: string, tnMapping: {+ [key: string]: string,+}, language: string) => {const { data: rowData, types } = dataconst zip = new JSZip()@@ -86,7 +93,12 @@ const CHART_METRICS_MAPPING = {}// function to filter the data for the chart-const getColumns = (chart, activeChartMetrics) => {+const getColumns = (chart: {+ x: string[],+ results: string[],+}, activeChartMetrics: {+ [key: string]: boolean,+}) => {const {results,} = activeChartMetrics@@ -106,9 +118,11 @@ const getColumns = (chart, activeChartMetrics) => {const noRegionPeriods = ['custom', 'yesterday']// function to get the settings and data for the chart(main diagram)-const getSettings = (chart, timeBucket, activeChartMetrics, applyRegions, timeFormat, rotateXAxias, chartType) => {+const getSettings = (chart: any, timeBucket: string, activeChartMetrics: {+ [key: string]: boolean,+}, applyRegions: boolean, timeFormat: string, rotateXAxias: boolean, chartType: string) => {const xAxisSize = _size(chart.x)- const lines = []+ const lines: any[] = []const modifiedChart = { ...chart }let regions@@ -156,7 +170,7 @@ const getSettings = (chart, timeBucket, activeChartMetrics, applyRegions, timeFotick: {fit: true,rotate: rotateXAxias ? 45 : 0,- format: timeFormat === TimeFormat['24-hour'] ? (x) => d3.timeFormat(tbsFormatMapper24h[timeBucket])(x) : null,+ format: timeFormat === TimeFormat['24-hour'] ? (x: any) => d3.timeFormat(tbsFormatMapper24h[timeBucket])(x) : null,},localtime: timeFormat === TimeFormat['24-hour'],type: 'timeseries',@@ -164,7 +178,7 @@ const getSettings = (chart, timeBucket, activeChartMetrics, applyRegions, timeFo},tooltip: {format: {- title: (x) => d3.timeFormat(tbsFormatMapper[timeBucket])(x),+ title: (x: any) => d3.timeFormat(tbsFormatMapper[timeBucket])(x),},contents: {template: `@@ -204,7 +218,7 @@ const getSettings = (chart, timeBucket, activeChartMetrics, applyRegions, timeFolinearGradient: true,},padding: {- right: (rotateXAxias && !(activeChartMetrics.bounce || activeChartMetrics.sessionDuration)) && 35,+ right: rotateXAxias && 35,left: 40,},bindto: '#dataChart',@@ -216,7 +230,7 @@ const validPeriods = ['custom', 'today', 'yesterday', '1d', '7d', '4w', '3M', '1const paidPeriods = ['12M', '24M']const validFilters = ['cc', 'pg', 'lc', 'ref', 'dv', 'br', 'os', 'so', 'me', 'ca', 'lt', 'ev']-const typeNameMapping = (t) => ({+const typeNameMapping = (t: (key: string) => string) => ({cc: t('project.mapping.cc'),pg: t('project.mapping.pg'),lc: t('project.mapping.lc'),@@ -243,10 +257,10 @@ const panelIconMapping = {}// This function return date using the same format as the backend-const getFormatDate = (date) => {+const getFormatDate = (date: Date) => {const yyyy = date.getFullYear()- let mm = date.getMonth() + 1- let dd = date.getDate()+ let mm: string | number = date.getMonth() + 1+ let dd: string | number = date.getDate()if (dd < 10) dd = `0${dd}`if (mm < 10) mm = `0${mm}`return `${yyyy}-${mm}-${dd}`diff --git a/src/pages/Captcha/View/ViewCaptcha.jsx b/src/pages/Captcha/View/ViewCaptcha.tsxsimilarity index 87%rename from src/pages/Captcha/View/ViewCaptcha.jsxrename to src/pages/Captcha/View/ViewCaptcha.tsxindex c4c131d5f..59eeaf5b5 100644--- a/src/pages/Captcha/View/ViewCaptcha.jsx+++ b/src/pages/Captcha/View/ViewCaptcha.tsx@@ -4,7 +4,9 @@ import React, {} from 'react'import useSize from 'hooks/useSize'import { useHistory, useParams, Link } from 'react-router-dom'+// @ts-ignoreimport domToImage from 'dom-to-image'+// @ts-ignoreimport { saveAs } from 'file-saver'import bb from 'billboard.js'import {@@ -35,6 +37,8 @@ import {tbPeriodPairs, getProjectCaptchaCacheKey, timeBucketToDays, getProjectCacheCustomKey, roleViewer,MAX_MONTHS_IN_PAST, MAX_MONTHS_IN_PAST_FREE, TimeFormat, chartTypes,} from 'redux/constants'+import { ICaptchaProject, IProject } from 'redux/models/IProject'+import { IUser } from 'redux/models/IUser'import Button from 'ui/Button'import Loader from 'ui/Loader'import Dropdown from 'ui/Dropdown'@@ -58,49 +62,83 @@ import NoEvents from './components/NoEvents'import Filters from './components/Filters'import './styles.css'+interface IProjectView extends ICaptchaProject {+ isPublicVisitors?: boolean,+}+const ViewProject = ({projects, isLoading: _isLoading, showError, cache, setProjectCache, projectViewPrefs, setProjectViewPrefs, authenticated, user, isPaidTierUsed, setProjects,-}) => {- const { t, i18n: { language } } = useTranslation('common')+}: {+ projects: IProjectView[],+ isLoading: boolean,+ showError: (message: string) => void,+ cache: any,+ setProjectCache: (pid: string, data: any, key: string) => void,+ projectViewPrefs: any,+ setProjectViewPrefs: (pid: string, period: string, timeBucket: string, rangeDate?: Date[] | null) => void,+ authenticated: boolean,+ user: IUser,+ isPaidTierUsed: boolean,+ // eslint-disable-next-line no-unused-vars, no-shadow+ setProjects: (projects: ICaptchaProject[]) => void,+}): JSX.Element => {+ const { t, i18n: { language } }: {+ t: (key: string, options?: {+ [key: string]: string | number | boolean | undefined | null,+ }) => string,+ i18n: { language: string },+ } = useTranslation('common')const [periodPairs, setPeriodPairs] = useState(tbPeriodPairs(t))const dashboardRef = useRef(null)- const { id } = useParams()+ const { id }: {+ id: string,+ } = useParams()const history = useHistory()- const project = useMemo(() => _find(projects, p => p.id === id) || {}, [projects, id])- const [areFiltersParsed, setAreFiltersParsed] = useState(false)- const [areTimeBucketParsed, setAreTimeBucketParsed] = useState(false)- const [arePeriodParsed, setArePeriodParsed] = useState(false)- const [panelsData, setPanelsData] = useState({})- const [isPanelsDataEmpty, setIsPanelsDataEmpty] = useState(false)- const [isPaidFeatureOpened, setIsPaidFeatureOpened] = useState(false)- const [analyticsLoading, setAnalyticsLoading] = useState(true)- const [period, setPeriod] = useState(projectViewPrefs[id]?.period || periodPairs[3].period)- const [timeBucket, setTimebucket] = useState(projectViewPrefs[id]?.timeBucket || periodPairs[3].tbs[1])- const activePeriod = useMemo(() => _find(periodPairs, p => p.period === period), [period, periodPairs])- const [chartData, setChartData] = useState({})- const [mainChart, setMainChart] = useState(null)- const [dataLoading, setDataLoading] = useState(false)- const [activeChartMetrics, setActiveChartMetrics] = useState({+ const project: IProjectView = useMemo(() => _find(projects, p => p.id === id) || {} as IProjectView, [projects, id])+ const [areFiltersParsed, setAreFiltersParsed] = useState<boolean>(false)+ const [areTimeBucketParsed, setAreTimeBucketParsed] = useState<boolean>(false)+ const [arePeriodParsed, setArePeriodParsed] = useState<boolean>(false)+ const [panelsData, setPanelsData] = useState<any>({})+ const [isPanelsDataEmpty, setIsPanelsDataEmpty] = useState<boolean>(false)+ const [isPaidFeatureOpened, setIsPaidFeatureOpened] = useState<boolean>(false)+ const [analyticsLoading, setAnalyticsLoading] = useState<boolean>(true)+ const [period, setPeriod] = useState<string>(projectViewPrefs[id]?.period || periodPairs[3].period)+ const [timeBucket, setTimebucket] = useState<string>(projectViewPrefs[id]?.timeBucket || periodPairs[3].tbs[1])+ const activePeriod: {+ period: string,+ label: string,+ tbs: string[],+ } = useMemo(() => _find(periodPairs, p => p.period === period) || {+ period: periodPairs[3].period,+ tbs: periodPairs[3].tbs,+ label: periodPairs[3].label,+ }, [period, periodPairs])+ const [chartData, setChartData] = useState<any>({})+ const [mainChart, setMainChart] = useState<any>(null)+ const [dataLoading, setDataLoading] = useState<boolean>(false)+ const [activeChartMetrics, setActiveChartMetrics] = useState<{+ [key: string]: boolean,+ }>({[CHART_METRICS_MAPPING.results]: true,})- const [sessionDurationAVG, setSessionDurationAVG] = useState(null)+ const [sessionDurationAVG, setSessionDurationAVG] = useState<any>(null)const checkIfAllMetricsAreDisabled = useMemo(() => !_some(activeChartMetrics, (value) => value), [activeChartMetrics])- const [filters, setFilters] = useState([])+ const [filters, setFilters] = useState<any[]>([])// That is needed when using 'Export as image' feature,// Because headless browser cannot do a request to the DDG API due to absense of The Same Origin Policy header- const [showIcons, setShowIcons] = useState(true)+ const [showIcons, setShowIcons] = useState<boolean>(true)const isLoading = authenticated ? _isLoading : falseconst tnMapping = typeNameMapping(t)const refCalendar = useRef(null)const localStorageDateRange = projectViewPrefs[id]?.rangeDate- const [dateRange, setDateRange] = useState(localStorageDateRange ? [new Date(localStorageDateRange[0]), new Date(localStorageDateRange[1])] : null)+ const [dateRange, setDateRange] = useState<Date[] | null>(localStorageDateRange ? [new Date(localStorageDateRange[0]), new Date(localStorageDateRange[1])] : null)const timeFormat = useMemo(() => user.timeFormat || TimeFormat['12-hour'], [user])- const [ref, size] = useSize()+ const [ref, size] = useSize() as anyconst rotateXAxias = useMemo(() => (size.width > 0 && size.width < 500), [size])const [chartType, setChartType] = useState(getItem('chartType') || chartTypes.line)- const { name } = project+ const { name } = project as IProjectconst sharedRoles = useMemo(() => _find(user.sharedProjects, p => p.project.id === id)?.role || {}, [user, id])@@ -131,7 +169,7 @@ const ViewProject = ({}// this function is used for requesting the data from the API- const loadAnalytics = async (forced = false, newFilters = null) => {+ const loadAnalytics = async (forced: boolean = false, newFilters: any = null) => {if (!forced && (isLoading || _isEmpty(project) || dataLoading)) {return}@@ -185,7 +223,7 @@ const ViewProject = ({setIsPanelsDataEmpty(true)} else {const applyRegions = !_includes(noRegionPeriods, activePeriod.period)- const bbSettings = getSettings(chart, timeBucket, activeChartMetrics, applyRegions, timeFormat, rotateXAxias, chartType)+ const bbSettings: any = getSettings(chart, timeBucket, activeChartMetrics, applyRegions, timeFormat, rotateXAxias, chartType)setChartData(chart)setPanelsData({@@ -223,7 +261,7 @@ const ViewProject = ({}, [chartType])// this funtion is used for requesting the data from the API when the filter is changed- const filterHandler = (column, filter, isExclusive = false) => {+ const filterHandler = (column: any, filter: any, isExclusive: boolean = false) => {let newFilters// eslint-disable-next-line no-lonely-if@@ -234,6 +272,7 @@ const ViewProject = ({setFilters(newFilters)// removing filter from the page URL+ // @ts-ignoreconst url = new URL(window.location)url.searchParams.delete(column)const { pathname, search } = url@@ -254,6 +293,7 @@ const ViewProject = ({setFilters(newFilters)// storing filter in the page URL+ // @ts-ignoreconst url = new URL(window.location)url.searchParams.append(column, filter)const { pathname, search } = url@@ -270,7 +310,7 @@ const ViewProject = ({}// this function is used for requesting the data from the API when the exclusive filter is changed- const onChangeExclusive = (column, filter, isExclusive) => {+ const onChangeExclusive = (column: any, filter: any, isExclusive: boolean) => {const newFilters = _map(filters, (f) => {if (f.column === column && f.filter === filter) {return {@@ -285,6 +325,7 @@ const ViewProject = ({loadAnalytics(true, newFilters)// storing exclusive filter in the page URL+ // @ts-ignoreconst url = new URL(window.location)url.searchParams.delete(column)@@ -310,9 +351,10 @@ const ViewProject = ({useEffect(() => {// using try/catch because new URL is not supported by browsers like IE, so at least analytics would work without parsing filterstry {+ // @ts-ignoreconst url = new URL(window.location)const { searchParams } = url- const initialFilters = []+ const initialFilters: any[] = []// eslint-disable-next-line lodash/prefer-lodash-methodsearchParams.forEach((value, key) => {if (!_includes(validFilters, key)) {@@ -335,14 +377,19 @@ const ViewProject = ({useEffect(() => {if (arePeriodParsed) {try {+ // @ts-ignoreconst url = new URL(window.location)const { searchParams } = url- const intialTimeBucket = searchParams.get('timeBucket')+ const intialTimeBucket: string = searchParams.get('timeBucket') || ''// eslint-disable-next-line lodash/prefer-lodash-methodif (!_includes(validTimeBacket, intialTimeBucket)) {return}- const newPeriodFull = _find(periodPairs, (el) => el.period === period)+ const newPeriodFull = _find(periodPairs, (el) => el.period === period) || {+ period: '',+ tbs: [],+ label: '',+ }if (!_includes(newPeriodFull.tbs, intialTimeBucket)) {return}@@ -354,8 +401,9 @@ const ViewProject = ({// eslint-disable-next-line react-hooks/exhaustive-deps}, [arePeriodParsed])- const onRangeDateChange = (dates, onRender) => {+ const onRangeDateChange = (dates: Date[], onRender?: any) => {const days = Math.ceil(Math.abs(dates[1].getTime() - dates[0].getTime()) / (1000 * 3600 * 24))+ // @ts-ignoreconst url = new URL(window.location)// setting allowed time buckets for the specified date range (period)@@ -398,7 +446,7 @@ const ViewProject = ({setPeriodPairs(tbPeriodPairs(t, timeBucketToDays[index].tb, dates))setPeriod('custom')- setProjectViewPrefs(id, 'custom', timeBucketToDays[index].tb[0], dates)+ setProjectViewPrefs(id, 'custom', timeBucketToDays[4].tb[0], dates)break}@@ -424,7 +472,7 @@ const ViewProject = ({if (!_isEmpty(projectRes)) {getOverallStats([id]).then(res => {- setProjects([...projects, {+ setProjects([...(projects as any[]), {...projectRes,overall: res[id],live: 'N/A',@@ -448,9 +496,10 @@ const ViewProject = ({}}, [isLoading, project, id]) // eslint-disable-line- const updatePeriod = (newPeriod) => {+ const updatePeriod = (newPeriod: any) => {const newPeriodFull = _find(periodPairs, (el) => el.period === newPeriod.period)- let tb = timeBucket+ let tb: any = timeBucket+ // @ts-ignoreconst url = new URL(window.location)if (_isEmpty(newPeriodFull)) return@@ -480,7 +529,8 @@ const ViewProject = ({})}- const updateTimebucket = (newTimebucket) => {+ const updateTimebucket = (newTimebucket: string) => {+ // @ts-ignoreconst url = new URL(window.location)url.searchParams.delete('timeBucket')url.searchParams.append('timeBucket', newTimebucket)@@ -516,6 +566,7 @@ const ViewProject = ({useEffect(() => {try {+ // @ts-ignoreconst url = new URL(window.location)const { searchParams } = urlconst intialPeriod = searchParams.get('period')@@ -524,7 +575,9 @@ const ViewProject = ({}if (intialPeriod === 'custom') {+ // @ts-ignoreconst from = new Date(searchParams.get('from'))+ // @ts-ignoreconst to = new Date(searchParams.get('to'))if (from.getDate() && to.getDate()) {onRangeDateChange([from, to], true)@@ -543,7 +596,8 @@ const ViewProject = ({}, [])const resetFilters = () => {- const url = new URL(window.location)+ // @ts-ignore+ const url: URL = new URL(window.location)const { searchParams } = url// eslint-disable-next-line lodash/prefer-lodash-methodsearchParams.forEach((value, key) => {@@ -575,7 +629,7 @@ const ViewProject = ({]// function set chart type and save to local storage- const setChartTypeOnClick = (type) => {+ const setChartTypeOnClick = (type: string) => {setItem('chartType', type)setChartType(type)}@@ -668,6 +722,7 @@ const ViewProject = ({if (pair.isCustomDate) {setTimeout(() => {+ // @ts-ignorerefCalendar.current.openCalendar()}, 100)} else {@@ -680,7 +735,7 @@ const ViewProject = ({<FlatPickerref={refCalendar}onChange={(date) => setDateRange(date)}- value={dateRange}+ value={dateRange || []}maxDateMonths={(isPaidTierUsed || id === SWETRIX_PID) ? MAX_MONTHS_IN_PAST : MAX_MONTHS_IN_PAST_FREE}/></div>@@ -730,8 +785,10 @@ const ViewProject = ({className='relative flex justify-center items-center py-2 !pr-3 !pl-1 md:pr-4 md:pl-2 ml-3 text-sm dark:text-gray-50 dark:border-gray-800 dark:bg-gray-700 dark:hover:bg-gray-600'secondary>- <Cog8ToothIcon className='w-5 h-5 mr-1' />- {t('common.settings')}+ <>+ <Cog8ToothIcon className='w-5 h-5 mr-1' />+ {t('common.settings')}+ </></Button>)}</div>@@ -743,11 +800,7 @@ const ViewProject = ({><div className='mt-14 xs:mt-0' /><div className='relative'>- <div className={cx('absolute right-0 z-10 -top-2', {- 'right-[90px]': activeChartMetrics[CHART_METRICS_MAPPING.sessionDuration],- 'right-[60px]': activeChartMetrics[CHART_METRICS_MAPPING.bounce],- })}- >+ <div className='absolute right-0 z-10 -top-2'><buttontype='button'onClick={() => setChartTypeOnClick(chartTypes.bar)}@@ -775,7 +828,7 @@ const ViewProject = ({<Loader />)}{(isPanelsDataEmpty) && (- <NoEvents filters={filters} resetFilters={resetFilters} pid={id} />+ <NoEvents filters={filters} resetFilters={resetFilters} />)}<div className={cx('pt-4 md:pt-0', { hidden: isPanelsDataEmpty || analyticsLoading })}><div@@ -807,12 +860,13 @@ const ViewProject = ({chartData={chartData}activePeriod={activePeriod}sessionDurationAVG={sessionDurationAVG}- live={project.live}+ live={project.live || 0}projectId={id}/>)}- {_map(panelsData.types, (type) => {+ {_map(panelsData.types, (type: keyof typeof tnMapping) => {const panelName = tnMapping[type]+ // @ts-ignoreconst panelIcon = panelIconMapping[type]if (type === 'cc') {diff --git a/src/redux/constants/index.ts b/src/redux/constants/index.tsindex e89b34f8f..c79b77f8f 100644--- a/src/redux/constants/index.ts+++ b/src/redux/constants/index.ts@@ -22,7 +22,14 @@ export const FORECAST_MAX_MAPPING: {month: 12,}-export const tbPeriodPairs = (t: Function, tbs: String[] | null, dates: Date[]) => [{+export const tbPeriodPairs = (t: Function, tbs?: string[] | null, dates?: Date[]): {+ label: string+ period: string+ tbs: string[]+ access: string+ dropdownLabel?: string+ isCustomDate?: boolean+}[] => [{label: t('project.today'),period: 'today',tbs: ['hour'],@@ -63,7 +70,7 @@ export const tbPeriodPairs = (t: Function, tbs: String[] | null, dates: Date[])tbs: ['month'],access: 'paid',}, {- label: getCustomLabel(dates, t),+ label: dates ? getCustomLabel(dates, t) : t('project.custom'),dropdownLabel: t('project.custom'),isCustomDate: true,period: 'custom',diff --git a/src/redux/models/IOverallStats.ts b/src/redux/models/IOverallStats.tsdeleted file mode 100644index e69de29bb..000000000diff --git a/src/redux/reducers/ui/cache.ts b/src/redux/reducers/ui/cache.tsindex cb8f6b605..8bd52a0f1 100644--- a/src/redux/reducers/ui/cache.ts+++ b/src/redux/reducers/ui/cache.ts@@ -96,7 +96,7 @@ const cacheSlice = createSlice({window.localStorage.setItem(LS_VIEW_PREFS_SETTING, JSON.stringify(viewPrefs))state.projectViewPrefs[pid] = viewPrefs},- setCaptchaProjectViewPrefs(state, { payload }: PayloadAction<{ pid: string, period: string, timeBucket: string, rangeDate: string }>) {+ setCaptchaProjectViewPrefs(state, { payload }: PayloadAction<{ pid: string, period: string, timeBucket: string, rangeDate?: Date[] | null }>) {const {pid, period, timeBucket, rangeDate,} = payloaddiff --git a/src/ui/Chart.tsx b/src/ui/Chart.tsxindex 1435cbd56..3d9a7e170 100644--- a/src/ui/Chart.tsx+++ b/src/ui/Chart.tsx@@ -3,9 +3,8 @@ import bb from 'billboard.js'import 'billboard.js/dist/theme/datalab.css'import 'billboard.js/dist/billboard.css'-const Chart = ({ current, children, options }: {+const Chart = ({ current, options }: {current: string,- children: React.ReactNode,options: any,}): JSX.Element => {let chartInstance: any = {}@@ -39,7 +38,6 @@ const Chart = ({ current, children, options }: {return (<div><div id={current} />- {children}</div>)}diff --git a/src/utils/generic.ts b/src/utils/generic.tsindex 8744c51b5..b608cfef5 100644--- a/src/utils/generic.ts+++ b/src/utils/generic.ts@@ -57,7 +57,7 @@ export const getTimeFromSeconds = (seconds: any) => {}}-export const getStringFromTime = (time: any, showMS: any) => {+export const getStringFromTime = (time: any, showMS?: boolean) => {const {h, m, s, ms,} = timediff --git a/tsconfig.json b/tsconfig.jsonindex 19800c92c..2274d512f 100644--- a/tsconfig.json+++ b/tsconfig.json@@ -5,7 +5,11 @@"lib": ["DOM","DOM.Iterable",- "ESNext"+ "ESNext",+ "es5",+ "es6",+ "dom",+ "dom.iterable"],"allowSyntheticDefaultImports": true,"module": "ESNext",