Browse Source

feat(crons): Cron monitor detail page view analytics (#42847)

https://github.com/getsentry/reload/pull/302

Closes: https://github.com/getsentry/team-crons/issues/11
David Wang 2 years ago
parent
commit
1199530ce0
1 changed files with 15 additions and 1 deletions
  1. 15 1
      static/app/views/monitors/details.tsx

+ 15 - 1
static/app/views/monitors/details.tsx

@@ -9,6 +9,9 @@ import {Panel, PanelHeader} from 'sentry/components/panels';
 import {t} from 'sentry/locale';
 import space from 'sentry/styles/space';
 import {Organization} from 'sentry/types';
+import withRouteAnalytics, {
+  WithRouteAnalyticsProps,
+} from 'sentry/utils/routeAnalytics/withRouteAnalytics';
 import withOrganization from 'sentry/utils/withOrganization';
 import AsyncView from 'sentry/views/asyncView';
 
@@ -20,6 +23,7 @@ import MonitorOnboarding from './onboarding';
 import {Monitor} from './types';
 
 type Props = AsyncView['props'] &
+  WithRouteAnalyticsProps &
   RouteComponentProps<{monitorId: string; orgId: string}, {}> & {
     organization: Organization;
   };
@@ -48,6 +52,16 @@ class MonitorDetails extends AsyncView<Props, State> {
   onUpdate = (data: Monitor) =>
     this.setState(state => ({monitor: {...state.monitor, ...data}}));
 
+  onRequestSuccess(response) {
+    this.props.setEventNames(
+      'monitors.details_page_viewed',
+      'Monitors: Details Page Viewed'
+    );
+    this.props.setRouteAnalyticsParams({
+      empty_state: !response.data?.lastCheckIn,
+    });
+  }
+
   renderBody() {
     const {monitor} = this.state;
 
@@ -90,4 +104,4 @@ const StyledPageFilterBar = styled(PageFilterBar)`
   margin-bottom: ${space(2)};
 `;
 
-export default withOrganization(MonitorDetails);
+export default withRouteAnalytics(withOrganization(MonitorDetails));