Skip to content

📈 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!

remove perfomence logic and alerts

kruzhambusbb267efb6d86
diff --git a/src/pages/Captcha/View/ViewCaptcha.jsx b/src/pages/Captcha/View/ViewCaptcha.jsx
index 79766ea04..608e580f5 100644
--- a/src/pages/Captcha/View/ViewCaptcha.jsx
+++ b/src/pages/Captcha/View/ViewCaptcha.jsx
@@ -35,7 +35,7 @@ import Title from 'components/Title'
import EventsRunningOutBanner from 'components/EventsRunningOutBanner'
import {
tbPeriodPairs, getProjectCacheKey, LIVE_VISITORS_UPDATE_INTERVAL, DEFAULT_TIMEZONE, CDN_URL, isDevelopment,
- timeBucketToDays, getProjectCacheCustomKey, roleViewer, MAX_MONTHS_IN_PAST, MAX_MONTHS_IN_PAST_FREE, PROJECT_TABS, TimeFormat, getProjectForcastCacheKey, chartTypes,
+ timeBucketToDays, getProjectCacheCustomKey, roleViewer, MAX_MONTHS_IN_PAST, MAX_MONTHS_IN_PAST_FREE, PROJECT_TABS, TimeFormat, chartTypes,
} from 'redux/constants'
import Button from 'ui/Button'
import Loader from 'ui/Loader'
@@ -43,35 +43,30 @@ import Dropdown from 'ui/Dropdown'
import Checkbox from 'ui/Checkbox'
import Select from 'ui/Select'
import FlatPicker from 'ui/Flatpicker'
-import Robot from 'ui/icons/Robot'
import PaidFeature from 'modals/PaidFeature'
-import Forecast from 'modals/Forecast'
import routes from 'routes'
import {
- getProjectData, getProject, getOverallStats, getLiveVisitors, getPerfData,
+ getProjectData, getProject, getOverallStats, getLiveVisitors,
} from 'api'
-import { getChartPrediction } from 'api/ai'
import {
Panel, Overview, CustomEvents,
} from './Panels'
import {
onCSVExportClick, getFormatDate, panelIconMapping, typeNameMapping, validFilters, validPeriods,
validTimeBacket, paidPeriods, noRegionPeriods, getSettings, getColumns, CHART_METRICS_MAPPING,
- CHART_METRICS_MAPPING_PERF, getSettingsPerf, transformAIChartData,
} from './ViewCaptcha.helpers'
import CCRow from './components/CCRow'
import RefRow from './components/RefRow'
import NoEvents from './components/NoEvents'
import Filters from './components/Filters'
-import ProjectAlertsView from '../Alerts/View'
import './styles.css'
const PROJECT_TABS_VALUES = _values(PROJECT_TABS)
const ViewProject = ({
- projects, isLoading: _isLoading, showError, cache, cachePerf, setProjectCache, projectViewPrefs, setProjectViewPrefs, setPublicProject,
- setLiveStatsForProject, authenticated, timezone, user, sharedProjects, isPaidTierUsed, extensions, generateAlert, setProjectCachePerf,
- projectTab, setProjectTab, setProjects, setProjectForcastCache,
+ projects, isLoading: _isLoading, showError, cache, setProjectCache, projectViewPrefs, setProjectViewPrefs, setPublicProject,
+ setLiveStatsForProject, authenticated, timezone, user, sharedProjects, isPaidTierUsed, extensions, generateAlert,
+ projectTab, setProjectTab, setProjects,
}) => {
const { t, i18n: { language } } = useTranslation('common')
const [periodPairs, setPeriodPairs] = useState(tbPeriodPairs(t))
@@ -87,13 +82,11 @@ const ViewProject = ({
return !_isEmpty(foundProject)
}, [id, sharedProjects])
const [areFiltersParsed, setAreFiltersParsed] = useState(false)
- const [areFiltersPerfParsed, setAreFiltersPerfParsed] = 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 [isForecastOpened, setIsForecastOpened] = 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])
@@ -109,11 +102,9 @@ const ViewProject = ({
[CHART_METRICS_MAPPING.viewsPerUnique]: false,
[CHART_METRICS_MAPPING.trendlines]: false,
})
- const [activeChartMetricsPerf, setActiveChartMetricsPerf] = useState(CHART_METRICS_MAPPING_PERF.timing)
const [sessionDurationAVG, setSessionDurationAVG] = useState(null)
const checkIfAllMetricsAreDisabled = useMemo(() => !_some(activeChartMetrics, (value) => value), [activeChartMetrics])
const [filters, setFilters] = useState([])
- const [filtersPerf, setFiltersPerf] = useState([])
// 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)
@@ -134,36 +125,11 @@ const ViewProject = ({
return projectTab || PROJECT_TABS.traffic
})
- const [chartDataPerf, setChartDataPerf] = useState({})
- const [isPanelsDataEmptyPerf, setIsPanelsDataEmptyPerf] = useState(false)
- const [panelsDataPerf, setPanelsDataPerf] = useState({})
const timeFormat = useMemo(() => user.timeFormat || TimeFormat['12-hour'], [user])
const [ref, size] = useSize()
const rotateXAxias = useMemo(() => (size.width > 0 && size.width < 500), [size])
const [chartType, setChartType] = useState(getItem('chartType') || chartTypes.line)
- const tabs = useMemo(() => {
- return [
- {
- id: PROJECT_TABS.traffic,
- label: t('dashboard.traffic'),
- icon: ChartBarIcon,
- },
- {
- id: PROJECT_TABS.performance,
- label: t('dashboard.performance'),
- icon: BoltIcon,
- },
- {
- id: PROJECT_TABS.alerts,
- label: t('dashboard.alerts'),
- icon: BellIcon,
- },
- ]
- }, [t])
-
- const activeTabLabel = useMemo(() => _find(tabs, tab => tab.id === activeTab)?.label, [tabs, activeTab])
-
const { name } = project
const sharedRoles = useMemo(() => _find(user.sharedProjects, p => p.project.id === id)?.role || {}, [user, id])
@@ -205,36 +171,6 @@ const ViewProject = ({
]
}, [t, activeChartMetrics])
- const chartMetricsPerf = useMemo(() => {
- return [
- {
- id: CHART_METRICS_MAPPING_PERF.full,
- label: t('dashboard.timingFull'),
- active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.full),
- },
- {
- id: CHART_METRICS_MAPPING_PERF.timing,
- label: t('dashboard.timing'),
- active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.timing),
- },
- {
- id: CHART_METRICS_MAPPING_PERF.network,
- label: t('dashboard.network'),
- active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.network),
- },
- {
- id: CHART_METRICS_MAPPING_PERF.frontend,
- label: t('dashboard.frontend'),
- active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.frontend),
- },
- {
- id: CHART_METRICS_MAPPING_PERF.backend,
- label: t('dashboard.backend'),
- active: _includes(activeChartMetricsPerf, CHART_METRICS_MAPPING_PERF.backend),
- },
- ]
- }, [t, activeChartMetricsPerf])
-
const dataNames = useMemo(() => {
return {
unique: t('project.unique'),
@@ -247,29 +183,9 @@ const ViewProject = ({
}
}, [t])
- const dataNamesPerf = useMemo(() => {
- return {
- full: t('dashboard.timing'),
- network: t('dashboard.network'),
- frontend: t('dashboard.frontend'),
- backend: t('dashboard.backend'),
- dns: t('dashboard.dns'),
- tls: t('dashboard.tls'),
- conn: t('dashboard.conn'),
- response: t('dashboard.response'),
- render: t('dashboard.render'),
- dom_load: t('dashboard.domLoad'),
- ttfb: t('dashboard.ttfb'),
- }
- }, [t])
-
// eslint-disable-next-line react-hooks/exhaustive-deps
const switchActiveChartMetric = useCallback(_debounce((pairID) => {
- if (activeTab === PROJECT_TABS.performance) {
- setActiveChartMetricsPerf(pairID)
- } else {
- setActiveChartMetrics(prev => ({ ...prev, [pairID]: !prev[pairID] }))
- }
+ setActiveChartMetrics(prev => ({ ...prev, [pairID]: !prev[pairID] }))
}, 0), [activeTab])
const onErrorLoading = () => {
@@ -378,221 +294,74 @@ const ViewProject = ({
}
}
- const loadAnalyticsPerf = async (forced = false, newFilters = null) => {
- if (!forced && (isLoading || _isEmpty(project) || dataLoading)) {
- return
- }
-
- setDataLoading(true)
- try {
- let dataPerf
- let key
- let from
- let to
-
- if (dateRange) {
- from = getFormatDate(dateRange[0])
- to = getFormatDate(dateRange[1])
- key = getProjectCacheCustomKey(from, to, timeBucket)
- } else {
- key = getProjectCacheKey(period, timeBucket)
- }
-
- if (!forced && !_isEmpty(cachePerf[id]) && !_isEmpty(cachePerf[id][key])) {
- dataPerf = cachePerf[id][key]
- } else {
- if (period === 'custom' && dateRange) {
- dataPerf = await getPerfData(id, timeBucket, '', newFilters || filtersPerf, from, to, timezone)
- } else {
- dataPerf = await getPerfData(id, timeBucket, period, newFilters || filtersPerf, '', '', timezone)
- }
-
- setProjectCachePerf(id, dataPerf || {}, key)
- }
-
- const {
- appliedFilters,
- } = dataPerf
-
- if (!_isEmpty(appliedFilters)) {
- setFilters(appliedFilters)
- }
-
- if (_isEmpty(dataPerf)) {
- setIsPanelsDataEmptyPerf(true)
- setDataLoading(false)
- setAnalyticsLoading(false)
- return
- }
-
- if (_isEmpty(dataPerf.params)) {
- setIsPanelsDataEmptyPerf(true)
- } else {
- const { chart: chartPerf } = dataPerf
- const bbSettings = getSettingsPerf(chartPerf, timeBucket, activeChartMetricsPerf, rotateXAxias, chartType)
- setChartDataPerf(chartPerf)
-
- setPanelsDataPerf({
- types: _keys(dataPerf.params),
- data: dataPerf.params,
- })
-
- if (activeTab === PROJECT_TABS.performance) {
- if (!_isEmpty(mainChart)) {
- mainChart.destroy()
- }
-
- setMainChart(() => {
- const generete = bb.generate(bbSettings)
- generete.data.names(dataNamesPerf)
- return generete
- })
- }
-
- setIsPanelsDataEmptyPerf(false)
- }
-
- setAnalyticsLoading(false)
- setDataLoading(false)
- } catch (e) {
- setAnalyticsLoading(false)
- setDataLoading(false)
- console.error('[ERROR](loadAnalytics) Loading analytics data failed')
- console.error(e)
- }
- }
-
// this funtion is used for requesting the data from the API when the filter is changed
const filterHandler = (column, filter, isExclusive = false) => {
let newFilters
- let newFiltersPerf
- const columnPerf = `${column}_perf`
- if (activeTab === PROJECT_TABS.performance) {
- if (_find(filtersPerf, (f) => f.column === column)) {
- newFiltersPerf = _filter(filtersPerf, (f) => f.column !== column)
-
- const url = new URL(window.location)
- url.searchParams.delete(columnPerf)
- const { pathname, search } = url
- history.push({
- pathname,
- search,
- state: {
- scrollToTopDisable: true,
- },
- })
- setFiltersPerf(newFiltersPerf)
- } else {
- newFiltersPerf = [
- ...filtersPerf,
- { column, filter, isExclusive },
- ]
+ // eslint-disable-next-line no-lonely-if
+ if (_find(filters, (f) => f.column === column) /* && f.filter === filter) */) {
+ // selected filter is already included into the filters array -> removing it
+ // removing filter from the state
+ newFilters = _filter(filters, (f) => f.column !== column)
+ setFilters(newFilters)
- const url = new URL(window.location)
- url.searchParams.append(columnPerf, filter)
- const { pathname, search } = url
- history.push({
- pathname,
- search,
- state: {
- scrollToTopDisable: true,
- },
- })
- setFiltersPerf(newFiltersPerf)
- }
+ // removing filter from the page URL
+ const url = new URL(window.location)
+ url.searchParams.delete(column)
+ const { pathname, search } = url
+ history.push({
+ pathname,
+ search,
+ state: {
+ scrollToTopDisable: true,
+ },
+ })
} else {
- // eslint-disable-next-line no-lonely-if
- if (_find(filters, (f) => f.column === column) /* && f.filter === filter) */) {
- // selected filter is already included into the filters array -> removing it
- // removing filter from the state
- newFilters = _filter(filters, (f) => f.column !== column)
- setFilters(newFilters)
-
- // removing filter from the page URL
- const url = new URL(window.location)
- url.searchParams.delete(column)
- const { pathname, search } = url
- history.push({
- pathname,
- search,
- state: {
- scrollToTopDisable: true,
- },
- })
- } else {
- // selected filter is not present in the filters array -> applying it
- // sroting filter in the state
- newFilters = [
- ...filters,
- { column, filter, isExclusive },
- ]
- setFilters(newFilters)
-
- // storing filter in the page URL
- const url = new URL(window.location)
- url.searchParams.append(column, filter)
- const { pathname, search } = url
- history.push({
- pathname,
- search,
- state: {
- scrollToTopDisable: true,
- },
- })
- }
+ // selected filter is not present in the filters array -> applying it
+ // sroting filter in the state
+ newFilters = [
+ ...filters,
+ { column, filter, isExclusive },
+ ]
+ setFilters(newFilters)
+
+ // storing filter in the page URL
+ const url = new URL(window.location)
+ url.searchParams.append(column, filter)
+ const { pathname, search } = url
+ history.push({
+ pathname,
+ search,
+ state: {
+ scrollToTopDisable: true,
+ },
+ })
}
sdkInstance?._emitEvent('filtersupdate', newFilters)
- if (activeTab === PROJECT_TABS.performance) {
- loadAnalyticsPerf(true, newFiltersPerf)
- } else {
- loadAnalytics(true, newFilters)
- }
+ loadAnalytics(true, newFilters)
}
// this function is used for requesting the data from the API when the exclusive filter is changed
const onChangeExclusive = (column, filter, isExclusive) => {
- let newFilters
- if (activeTab === PROJECT_TABS.performance) {
- newFilters = _map(filtersPerf, (f) => {
- if (f.column === column && f.filter === filter) {
- return {
- ...f,
- isExclusive,
- }
- }
-
- return f
- })
- setFiltersPerf(newFilters)
- loadAnalyticsPerf(true, newFilters)
- } else {
- newFilters = _map(filters, (f) => {
- if (f.column === column && f.filter === filter) {
- return {
- ...f,
- isExclusive,
- }
+ const newFilters = _map(filters, (f) => {
+ if (f.column === column && f.filter === filter) {
+ return {
+ ...f,
+ isExclusive,
}
+ }
- return f
- })
- setFilters(newFilters)
- loadAnalytics(true, newFilters)
- }
+ return f
+ })
+ setFilters(newFilters)
+ loadAnalytics(true, newFilters)
// storing exclusive filter in the page URL
const url = new URL(window.location)
- if (activeTab === PROJECT_TABS.performance) {
- const columnPerf = `${column}_perf`
- url.searchParams.delete(columnPerf)
- url.searchParams.append(columnPerf, filter)
- } else {
- url.searchParams.delete(column)
- url.searchParams.append(column, filter)
- }
+ url.searchParams.delete(column)
+ url.searchParams.append(column, filter)
const { pathname, search } = url
history.push({
@@ -607,11 +376,7 @@ const ViewProject = ({
const refreshStats = () => {
if (!isLoading && !dataLoading) {
- if (activeTab === PROJECT_TABS.performance) {
- loadAnalyticsPerf(true)
- } else {
- loadAnalytics(true)
- }
+ loadAnalytics(true)
}
}
@@ -632,76 +397,62 @@ const ViewProject = ({
}, [activeTab])
useEffect(() => {
- if (activeTab === PROJECT_TABS.traffic) {
- if (!isLoading && !_isEmpty(chartData) && !_isEmpty(mainChart)) {
- if (activeChartMetrics.views || activeChartMetrics.unique || activeChartMetrics.viewsPerUnique || activeChartMetrics.trendlines) {
- mainChart.load({
- columns: getColumns(chartData, activeChartMetrics),
- })
- }
-
- if (activeChartMetrics.bounce || activeChartMetrics.sessionDuration || activeChartMetrics.views || activeChartMetrics.unique) {
- const applyRegions = !_includes(noRegionPeriods, activePeriod.period)
- const bbSettings = getSettings(chartData, timeBucket, activeChartMetrics, applyRegions, timeFormat, rotateXAxias, chartType)
+ if (!isLoading && !_isEmpty(chartData) && !_isEmpty(mainChart)) {
+ if (activeChartMetrics.views || activeChartMetrics.unique || activeChartMetrics.viewsPerUnique || activeChartMetrics.trendlines) {
+ mainChart.load({
+ columns: getColumns(chartData, activeChartMetrics),
+ })
+ }
- if (!_isEmpty(mainChart)) {
- mainChart.destroy()
- }
+ if (activeChartMetrics.bounce || activeChartMetrics.sessionDuration || activeChartMetrics.views || activeChartMetrics.unique) {
+ const applyRegions = !_includes(noRegionPeriods, activePeriod.period)
+ const bbSettings = getSettings(chartData, timeBucket, activeChartMetrics, applyRegions, timeFormat, rotateXAxias, chartType)
- setMainChart(() => {
- const generete = bb.generate(bbSettings)
- generete.data.names(dataNames)
- return generete
- })
+ if (!_isEmpty(mainChart)) {
+ mainChart.destroy()
}
- if (!activeChartMetrics.bounce || !activeChartMetrics.sessionDuration || activeChartMetrics.views || activeChartMetrics.unique) {
- const applyRegions = !_includes(noRegionPeriods, activePeriod.period)
- const bbSettings = getSettings(chartData, timeBucket, activeChartMetrics, applyRegions, timeFormat, rotateXAxias, chartType)
-
- if (!_isEmpty(mainChart)) {
- mainChart.destroy()
- }
+ setMainChart(() => {
+ const generete = bb.generate(bbSettings)
+ generete.data.names(dataNames)
+ return generete
+ })
+ }
- setMainChart(() => {
- const generete = bb.generate(bbSettings)
- generete.data.names(dataNames)
- return generete
- })
- }
+ if (!activeChartMetrics.bounce || !activeChartMetrics.sessionDuration || activeChartMetrics.views || activeChartMetrics.unique) {
+ const applyRegions = !_includes(noRegionPeriods, activePeriod.period)
+ const bbSettings = getSettings(chartData, timeBucket, activeChartMetrics, applyRegions, timeFormat, rotateXAxias, chartType)
- if (!activeChartMetrics.views) {
- mainChart.unload({
- ids: 'total',
- })
+ if (!_isEmpty(mainChart)) {
+ mainChart.destroy()
}
- if (!activeChartMetrics.unique) {
- mainChart.unload({
- ids: 'unique',
- })
- }
+ setMainChart(() => {
+ const generete = bb.generate(bbSettings)
+ generete.data.names(dataNames)
+ return generete
+ })
+ }
- if (!activeChartMetrics.viewsPerUnique) {
- mainChart.unload({
- ids: 'viewsPerUnique',
- })
- }
+ if (!activeChartMetrics.views) {
+ mainChart.unload({
+ ids: 'total',
+ })
}
- } else if (!isLoading && !_isEmpty(chartDataPerf) && !_isEmpty(mainChart)) {
- const bbSettings = getSettingsPerf(chartDataPerf, timeBucket, activeChartMetricsPerf, rotateXAxias, chartType)
- if (!_isEmpty(mainChart)) {
- mainChart.destroy()
+ if (!activeChartMetrics.unique) {
+ mainChart.unload({
+ ids: 'unique',
+ })
}
- setMainChart(() => {
- const generete = bb.generate(bbSettings)
- generete.data.names(dataNamesPerf)
- return generete
- })
+ if (!activeChartMetrics.viewsPerUnique) {
+ mainChart.unload({
+ ids: 'viewsPerUnique',
+ })
+ }
}
- }, [isLoading, activeChartMetrics, chartData, chartDataPerf, activeChartMetricsPerf]) // eslint-disable-line
+ }, [isLoading, activeChartMetrics, chartData]) // eslint-disable-line
// Initialising Swetrix SDK instance
useEffect(() => {
@@ -786,57 +537,26 @@ const ViewProject = ({
// Parsing initial filters from the address bar
useEffect(() => {
// using try/catch because new URL is not supported by browsers like IE, so at least analytics would work without parsing filters
- if (activeTab === PROJECT_TABS.performance) {
- try {
- const url = new URL(window.location)
- const { searchParams } = url
- const initialFilters = []
- // eslint-disable-next-line lodash/prefer-lodash-method
- searchParams.forEach((value, key) => {
- if (!_includes(key, '_perf')) {
- return
- }
-
- const keyPerf = _replace(key, '_perf', '')
-
- if (!_includes(validFilters, keyPerf)) {
- return
- }
-
- const isExclusive = _startsWith(value, '!')
- initialFilters.push({
- column: keyPerf,
- filter: isExclusive ? value.substring(1) : value,
- isExclusive,
- })
- })
-
- setFiltersPerf(initialFilters)
- } finally {
- setAreFiltersPerfParsed(true)
- }
- } else {
- try {
- const url = new URL(window.location)
- const { searchParams } = url
- const initialFilters = []
- // eslint-disable-next-line lodash/prefer-lodash-method
- searchParams.forEach((value, key) => {
- if (!_includes(validFilters, key)) {
- return
- }
+ try {
+ const url = new URL(window.location)
+ const { searchParams } = url
+ const initialFilters = []
+ // eslint-disable-next-line lodash/prefer-lodash-method
+ searchParams.forEach((value, key) => {
+ if (!_includes(validFilters, key)) {
+ return
+ }
- const isExclusive = _startsWith(value, '!')
- initialFilters.push({
- column: key,
- filter: isExclusive ? value.substring(1) : value,
- isExclusive,
- })
+ const isExclusive = _startsWith(value, '!')
+ initialFilters.push({
+ column: key,
+ filter: isExclusive ? value.substring(1) : value,
+ isExclusive,
})
- setFilters(initialFilters)
- } finally {
- setAreFiltersParsed(true)
- }
+ })
+ setFilters(initialFilters)
+ } finally {
+ setAreFiltersParsed(true)
}
}, [activeTab])
@@ -925,12 +645,7 @@ const ViewProject = ({
loadAnalytics()
}
}
- if (areFiltersPerfParsed) {
- if (activeTab === PROJECT_TABS.performance) {
- loadAnalyticsPerf()
- }
- }
- }, [project, period, timeBucket, periodPairs, areFiltersParsed, areTimeBucketParsed, arePeriodParsed, t, activeTab, areFiltersPerfParsed]) // eslint-disable-line
+ }, [project, period, timeBucket, periodPairs, areFiltersParsed, areTimeBucketParsed, arePeriodParsed, t, activeTab]) // eslint-disable-line
useEffect(() => {
if (dateRange && arePeriodParsed) {
@@ -1042,7 +757,6 @@ const ViewProject = ({
timeBucket: tb,
dateRange: newPeriod.period === 'custom' ? dateRange : null,
})
- setForecasedChartData({})
}
const updateTimebucket = (newTimebucket) => {
@@ -1064,7 +778,6 @@ const ViewProject = ({
timeBucket: newTimebucket,
dateRange,
})
- setForecasedChartData({})
}
const openSettingsHandler = () => {
@@ -1090,12 +803,6 @@ const ViewProject = ({
const url = new URL(window.location)
const { searchParams } = url
const intialPeriod = searchParams.get('period')
- const tab = searchParams.get('tab')
-
- if (tab === PROJECT_TABS.performance) {
- setProjectTab(PROJECT_TABS.performance)
- }
-
if (!_includes(validPeriods, intialPeriod) || (!isSharedProject && id !== SWETRIX_PID && !isPaidTierUsed && _includes(paidPeriods, intialPeriod))) {
return
}
@@ -1146,12 +853,7 @@ const ViewProject = ({
},
})
setFilters([])
- setFiltersPerf([])
- if (activeTab === PROJECT_TABS.performance) {
- loadAnalyticsPerf(true, [])
- } else {
- loadAnalytics(true, [])
- }
+ loadAnalytics(true, [])
}
const exportTypes = [
@@ -1159,9 +861,6 @@ const ViewProject = ({
{
label: t('project.asCSV'),
onClick: () => {
- if (activeTab === PROJECT_TABS.performance) {
- return onCSVExportClick(panelsDataPerf, id, tnMapping, language)
- }
return onCSVExportClick(panelsData, id, tnMapping, language)
},
},
@@ -1175,11 +874,7 @@ const ViewProject = ({
// useEffect to change chart if we change chart type
useEffect(() => {
- if (activeTab === PROJECT_TABS.performance) {
- loadAnalyticsPerf()
- } else {
- loadAnalytics()
- }
+ loadAnalytics()
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [chartType])
@@ -1198,59 +893,6 @@ const ViewProject = ({
)}
ref={dashboardRef}
>
- {/* Tabs selector */}
- <div>
- <div className='sm:hidden'>
- <Select
- items={tabs}
- keyExtractor={(item) => item.id}
- labelExtractor={(item) => item.label}
- onSelect={(label) => {
- const selected = _find(tabs, (tab) => tab.label === label)
- setProjectTab(selected.id)
- setActiveTab(selected.id)
- }}
- title={activeTabLabel}
- />
- </div>
- <div className='hidden sm:block'>
- <div>
- <nav className='-mb-px flex space-x-4' aria-label='Tabs'>
- {_map(tabs, tab => {
- const isCurrent = tab.id === activeTab
-
- return (
- <div
- key={tab.id}
- onClick={() => {
- setProjectTab(tab.id)
- setActiveTab(tab.id)
- }}
- className={cx(
- isCurrent
- ? 'border-indigo-700 text-indigo-700 dark:text-indigo-500 dark:border-indigo-500'
- : 'border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300 dark:text-gray-400 dark:hover:border-gray-300 dark:hover:text-gray-300',
- 'group inline-flex items-center whitespace-nowrap py-2 px-1 border-b-2 font-bold text-md cursor-pointer',
- )}
- aria-current={isCurrent ? 'page' : undefined}
- >
- <tab.icon
- className={cx(
- isCurrent ? 'text-indigo-700 dark:text-indigo-500' : 'text-gray-500 group-hover:text-gray-500 dark:text-gray-400 dark:group-hover:text-gray-300',
- '-ml-0.5 mr-2 h-5 w-5',
- )}
- aria-hidden='true'
- />
- <span>
- {tab.label}
- </span>
- </div>
- )
- })}
- </nav>
- </div>
- </div>
- </div>
{activeTab !== PROJECT_TABS.alerts && (
<>
<div className='flex flex-col md:flex-row items-center md:items-start justify-between mt-2'>
@@ -1339,60 +981,36 @@ const ViewProject = ({
</div>
<div>
<div className='flex flex-row flex-wrap items-center justify-center md:justify-end h-10 mt-2 md:mt-5 mb-4'>
- {activeTab === PROJECT_TABS.traffic ? (
- !isPanelsDataEmpty && (
- <Dropdown
- items={chartMetrics}
- title={t('project.metricVis')}
- labelExtractor={(pair) => {
- const {
- label, id: pairID, active, conflicts,
- } = pair
-
- const conflicted = isConflicted(conflicts)
-
- return (
- <Checkbox
- className={cx({ hidden: isPanelsDataEmpty || analyticsLoading })}
- label={label}
- disabled={conflicted}
- id={pairID}
- checked={active}
- />
- )
- }}
- keyExtractor={(pair) => pair.id}
- onSelect={({ id: pairID, conflicts }) => {
- if (isConflicted(conflicts)) {
- generateAlert(t('project.conflictMetric'), 'error')
- return
- }
- switchActiveChartMetric(pairID)
- }}
- />
- )) : (
- !isPanelsDataEmptyPerf && (
- <Dropdown
- items={chartMetricsPerf}
- className='min-w-[170px] xs:min-w-0'
- title={(
- <p>
- {_find(chartMetricsPerf, ({ id: chartId }) => chartId === activeChartMetricsPerf)?.label}
- </p>
- )}
- labelExtractor={(pair) => {
- const {
- label,
- } = pair
-
- return label
- }}
- keyExtractor={(pair) => pair.id}
- onSelect={({ id: pairID }) => {
- switchActiveChartMetric(pairID)
- }}
- />
- )
+ {!isPanelsDataEmpty && (
+ <Dropdown
+ items={chartMetrics}
+ title={t('project.metricVis')}
+ labelExtractor={(pair) => {
+ const {
+ label, id: pairID, active, conflicts,
+ } = pair
+
+ const conflicted = isConflicted(conflicts)
+
+ return (
+ <Checkbox
+ className={cx({ hidden: isPanelsDataEmpty || analyticsLoading })}
+ label={label}
+ disabled={conflicted}
+ id={pairID}
+ checked={active}
+ />
+ )
+ }}
+ keyExtractor={(pair) => pair.id}
+ onSelect={({ id: pairID, conflicts }) => {
+ if (isConflicted(conflicts)) {
+ generateAlert(t('project.conflictMetric'), 'error')
+ return
+ }
+ switchActiveChartMetric(pairID)
+ }}
+ />
)}
<Dropdown
items={[...exportTypes, ...customExportTypes]}
@@ -1472,110 +1090,52 @@ const ViewProject = ({
</Link>
</div>
)}
- {(activeTab === PROJECT_TABS.alerts && !isSharedProject && !project?.isPublicVisitors && authenticated) && (
- <ProjectAlertsView projectId={id} />
- )}
{(analyticsLoading && activeTab !== PROJECT_TABS.alerts) && (
<Loader />
)}
{(isPanelsDataEmpty && activeTab === PROJECT_TABS.traffic) && (
<NoEvents filters={filters} resetFilters={resetFilters} pid={id} />
)}
- {(isPanelsDataEmptyPerf && activeTab === PROJECT_TABS.performance) && (
- <NoEvents filters={filters} resetFilters={resetFilters} pid={id} />
- )}
- {activeTab === PROJECT_TABS.traffic && (
- <div className={cx('pt-4 md:pt-0', { hidden: isPanelsDataEmpty || analyticsLoading })}>
- <div
- className={cx('h-80', {
- hidden: checkIfAllMetricsAreDisabled,
- })}
- >
- <div className='h-80' id='dataChart' />
+ <div className={cx('pt-4 md:pt-0', { hidden: isPanelsDataEmpty || analyticsLoading })}>
+ <div
+ className={cx('h-80', {
+ hidden: checkIfAllMetricsAreDisabled,
+ })}
+ >
+ <div className='h-80' id='dataChart' />
+ </div>
+ <Filters
+ filters={filters}
+ onRemoveFilter={filterHandler}
+ onChangeExclusive={onChangeExclusive}
+ tnMapping={tnMapping}
+ />
+ {dataLoading && (
+ <div className='loader bg-transparent static mt-4' id='loader'>
+ <div className='loader-head'>
+ <div className='first' />
+ <div className='second' />
</div>
- <Filters
- filters={filters}
- onRemoveFilter={filterHandler}
- onChangeExclusive={onChangeExclusive}
- tnMapping={tnMapping}
+ </div>
+ )}
+ <div className='mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3'>
+ {!_isEmpty(project.overall) && (
+ <Overview
+ t={t}
+ overall={project.overall}
+ chartData={chartData}
+ activePeriod={activePeriod}
+ sessionDurationAVG={sessionDurationAVG}
+ live={project.live}
+ projectId={id}
/>
- {dataLoading && (
- <div className='loader bg-transparent static mt-4' id='loader'>
- <div className='loader-head'>
- <div className='first' />
- <div className='second' />
- </div>
- </div>
)}
- <div className='mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3'>
- {!_isEmpty(project.overall) && (
- <Overview
- t={t}
- overall={project.overall}
- chartData={chartData}
- activePeriod={activePeriod}
- sessionDurationAVG={sessionDurationAVG}
- live={project.live}
- projectId={id}
- />
- )}
- {_map(panelsData.types, (type) => {
- const panelName = tnMapping[type]
- const panelIcon = panelIconMapping[type]
- const customTabs = _filter(customPanelTabs, tab => tab.panelID === type)
-
- if (type === 'cc') {
- return (
- <Panel
- t={t}
- key={type}
- icon={panelIcon}
- id={type}
- onFilter={filterHandler}
- name={panelName}
- data={panelsData.data[type]}
- customTabs={customTabs}
- rowMapper={(rowName) => (
- <CCRow rowName={rowName} language={language} />
- )}
- />
- )
- }
-
- if (type === 'dv') {
- return (
- <Panel
- t={t}
- key={type}
- icon={panelIcon}
- id={type}
- onFilter={filterHandler}
- name={panelName}
- data={panelsData.data[type]}
- customTabs={customTabs}
- capitalize
- />
- )
- }
-
- if (type === 'ref') {
- return (
- <Panel
- t={t}
- key={type}
- icon={panelIcon}
- id={type}
- onFilter={filterHandler}
- name={panelName}
- data={panelsData.data[type]}
- customTabs={customTabs}
- rowMapper={(rowName) => (
- <RefRow rowName={rowName} showIcons={showIcons} />
- )}
- />
- )
- }
+ {_map(panelsData.types, (type) => {
+ const panelName = tnMapping[type]
+ const panelIcon = panelIconMapping[type]
+ const customTabs = _filter(customPanelTabs, tab => tab.panelID === type)
+ if (type === 'cc') {
return (
<Panel
t={t}
@@ -1586,85 +1146,14 @@ const ViewProject = ({
name={panelName}
data={panelsData.data[type]}
customTabs={customTabs}
+ rowMapper={(rowName) => (
+ <CCRow rowName={rowName} language={language} />
+ )}
/>
)
- })}
- {!_isEmpty(panelsData.customs) && (
- <CustomEvents
- t={t}
- customs={panelsData.customs}
- onFilter={filterHandler}
- chartData={chartData}
- />
- )}
- </div>
- </div>
- )}
- {activeTab === PROJECT_TABS.performance && (
- <div className={cx('pt-4 md:pt-0', { hidden: isPanelsDataEmptyPerf || analyticsLoading })}>
- <div
- className={cx('h-80', {
- hidden: checkIfAllMetricsAreDisabled,
- })}
- >
- <div className='h-80' id='dataChart' />
- </div>
- <Filters
- filters={filtersPerf}
- onRemoveFilter={filterHandler}
- onChangeExclusive={onChangeExclusive}
- tnMapping={tnMapping}
- />
- {dataLoading && (
- <div className='loader bg-transparent static mt-4' id='loader'>
- <div className='loader-head'>
- <div className='first' />
- <div className='second' />
- </div>
- </div>
- )}
- <div className='mt-5 grid grid-cols-1 gap-5 sm:grid-cols-2 lg:grid-cols-3'>
- {_map(panelsDataPerf.types, (type) => {
- const panelName = tnMapping[type]
- const panelIcon = panelIconMapping[type]
- const customTabs = _filter(customPanelTabs, tab => tab.panelID === type)
-
- if (type === 'cc') {
- return (
- <Panel
- t={t}
- key={type}
- icon={panelIcon}
- id={type}
- onFilter={filterHandler}
- name={panelName}
- data={panelsDataPerf.data[type]}
- customTabs={customTabs}
- rowMapper={(rowName) => (
- <CCRow rowName={rowName} language={language} />
- )}
- valueMapper={(value) => getStringFromTime(getTimeFromSeconds(value), true)}
- />
- )
- }
-
- if (type === 'dv') {
- return (
- <Panel
- t={t}
- key={type}
- icon={panelIcon}
- id={type}
- onFilter={filterHandler}
- name={panelName}
- data={panelsDataPerf.data[type]}
- customTabs={customTabs}
- valueMapper={(value) => getStringFromTime(getTimeFromSeconds(value), true)}
- capitalize
- />
- )
- }
+ }
+ if (type === 'dv') {
return (
<Panel
t={t}
@@ -1673,18 +1162,57 @@ const ViewProject = ({
id={type}
onFilter={filterHandler}
name={panelName}
- data={panelsDataPerf.data[type]}
+ data={panelsData.data[type]}
customTabs={customTabs}
- valueMapper={(value) => getStringFromTime(getTimeFromSeconds(value), true)}
+ capitalize
/>
)
- })}
- </div>
+ }
+
+ if (type === 'ref') {
+ return (
+ <Panel
+ t={t}
+ key={type}
+ icon={panelIcon}
+ id={type}
+ onFilter={filterHandler}
+ name={panelName}
+ data={panelsData.data[type]}
+ customTabs={customTabs}
+ rowMapper={(rowName) => (
+ <RefRow rowName={rowName} showIcons={showIcons} />
+ )}
+ />
+ )
+ }
+
+ return (
+ <Panel
+ t={t}
+ key={type}
+ icon={panelIcon}
+ id={type}
+ onFilter={filterHandler}
+ name={panelName}
+ data={panelsData.data[type]}
+ customTabs={customTabs}
+ />
+ )
+ })}
+ {!_isEmpty(panelsData.customs) && (
+ <CustomEvents
+ t={t}
+ customs={panelsData.customs}
+ onFilter={filterHandler}
+ chartData={chartData}
+ />
+ )}
</div>
- )}
+ </div>
</div>
</div>
- {!authenticated && activeTab !== PROJECT_TABS.alerts && (
+ {!authenticated && (
<div className='bg-indigo-600'>
<div className='w-11/12 mx-auto pb-16 pt-12 px-4 sm:px-6 lg:px-8 lg:flex lg:items-center lg:justify-between'>
<h2 className='text-3xl sm:text-4xl font-bold tracking-tight text-gray-900'>
@@ -1715,13 +1243,6 @@ const ViewProject = ({
isOpened={isPaidFeatureOpened}
onClose={() => setIsPaidFeatureOpened(false)}
/>
- <Forecast
- isOpened={isForecastOpened}
- onClose={() => setIsForecastOpened(false)}
- onSubmit={onForecastSubmit}
- activeTB={t(`project.${timeBucket}`)}
- tb={timeBucket}
- />
</Title>
)
}