diff --git a/superset-frontend/src/dashboard/components/Dashboard.jsx b/superset-frontend/src/dashboard/components/Dashboard.jsx index e168b394a5bc8..0f107e596ce39 100644 --- a/superset-frontend/src/dashboard/components/Dashboard.jsx +++ b/superset-frontend/src/dashboard/components/Dashboard.jsx @@ -101,6 +101,7 @@ class Dashboard extends React.PureComponent { const bootstrapData = appContainer?.getAttribute('data-bootstrap') || ''; const { dashboardState, layout } = this.props; const eventData = { + is_soft_navigation: Logger.softNavigationStart > 0, is_edit_mode: dashboardState.editMode, mount_duration: Logger.getTimestamp(), is_empty: isDashboardEmpty(layout), diff --git a/superset-frontend/src/logger/LogUtils.ts b/superset-frontend/src/logger/LogUtils.ts index 68c3f9fde4ad4..9fe10dae494b5 100644 --- a/superset-frontend/src/logger/LogUtils.ts +++ b/superset-frontend/src/logger/LogUtils.ts @@ -65,7 +65,7 @@ export const Logger = { this.softNavigationStart = window.performance.now(); }, - // note that this returns ms since page load, NOT ms since epoch + // note that this returns ms since last navigation, NOT ms since epoch getTimestamp() { return Math.round(window.performance.now() - this.softNavigationStart); }, diff --git a/superset-frontend/src/views/App.tsx b/superset-frontend/src/views/App.tsx index 8e78ea02401d2..00ad0f2c1b3ef 100644 --- a/superset-frontend/src/views/App.tsx +++ b/superset-frontend/src/views/App.tsx @@ -39,7 +39,7 @@ import { theme } from 'src/preamble'; import ToastPresenter from 'src/messageToasts/containers/ToastPresenter'; import setupApp from 'src/setup/setupApp'; import { routes, isFrontendRoute } from 'src/views/routes'; -import { Logger } from '../logger/LogUtils'; +import { Logger } from 'src/logger/LogUtils'; import { store } from './store'; setupApp(); @@ -49,7 +49,7 @@ const bootstrap = JSON.parse(container?.getAttribute('data-bootstrap') ?? '{}'); const user = { ...bootstrap.user }; const menu = { ...bootstrap.common.menu_data }; const common = { ...bootstrap.common }; -let lastLocation: string; +let lastLocationPathname: string; initFeatureFlags(bootstrap.common.feature_flags); const RootContextProviders: React.FC = ({ children }) => { @@ -57,10 +57,10 @@ const RootContextProviders: React.FC = ({ children }) => { useEffect(() => { // reset performance logger timer start point to avoid soft navigation // cause dashboard perf measurement problem - if (lastLocation && lastLocation !== location.pathname) { + if (lastLocationPathname && lastLocationPathname !== location.pathname) { Logger.resetStartTime(); } - lastLocation = location.pathname; + lastLocationPathname = location.pathname; }, [location.pathname]); return (