From 944c7a4f88674343a7f9d2d622bf54d530684a4f Mon Sep 17 00:00:00 2001 From: Scott Cooper Date: Tue, 19 Oct 2021 14:23:25 -0700 Subject: [PATCH] feat(workflow): Add team insights analytics --- .../app/utils/analytics/trackAdvancedAnalyticsEvent.tsx | 5 ++++- static/app/utils/analytics/workflowAnalyticsEvents.tsx | 9 +++++++++ .../views/organizationStats/teamInsights/overview.tsx | 9 ++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) create mode 100644 static/app/utils/analytics/workflowAnalyticsEvents.tsx diff --git a/static/app/utils/analytics/trackAdvancedAnalyticsEvent.tsx b/static/app/utils/analytics/trackAdvancedAnalyticsEvent.tsx index 0d6566ea2a7fb3..c5b2eb021e5326 100644 --- a/static/app/utils/analytics/trackAdvancedAnalyticsEvent.tsx +++ b/static/app/utils/analytics/trackAdvancedAnalyticsEvent.tsx @@ -7,12 +7,14 @@ import { performanceEventMap, PerformanceEventParameters, } from './performanceAnalyticsEvents'; +import {TeamInsightsEventParameters, workflowEventMap} from './workflowAnalyticsEvents'; type EventParameters = GrowthEventParameters & IssueEventParameters & PerformanceEventParameters & DashboardsEventParameters & - DiscoverEventParameters; + DiscoverEventParameters & + TeamInsightsEventParameters; const allEventMap = { ...growthEventMap, @@ -20,6 +22,7 @@ const allEventMap = { ...performanceEventMap, ...dashboardsEventMap, ...discoverEventMap, + ...workflowEventMap, }; /** diff --git a/static/app/utils/analytics/workflowAnalyticsEvents.tsx b/static/app/utils/analytics/workflowAnalyticsEvents.tsx new file mode 100644 index 00000000000000..ee4eb7e249b55c --- /dev/null +++ b/static/app/utils/analytics/workflowAnalyticsEvents.tsx @@ -0,0 +1,9 @@ +export type TeamInsightsEventParameters = { + 'team_insights.viewed': {}; +}; + +export type TeamInsightsEventKey = keyof TeamInsightsEventParameters; + +export const workflowEventMap: Record = { + 'team_insights.viewed': 'Team Insights: Viewed', +}; diff --git a/static/app/views/organizationStats/teamInsights/overview.tsx b/static/app/views/organizationStats/teamInsights/overview.tsx index c690fb92a749ec..e34f7d227ccf45 100644 --- a/static/app/views/organizationStats/teamInsights/overview.tsx +++ b/static/app/views/organizationStats/teamInsights/overview.tsx @@ -1,4 +1,4 @@ -import {Fragment} from 'react'; +import {Fragment, useEffect} from 'react'; import {RouteComponentProps} from 'react-router'; import {useTheme} from '@emotion/react'; import styled from '@emotion/styled'; @@ -17,6 +17,7 @@ import PageTimeRangeSelector from 'app/components/pageTimeRangeSelector'; import {t} from 'app/locale'; import space from 'app/styles/space'; import {DateString, Organization, RelativePeriod, TeamWithProjects} from 'app/types'; +import trackAdvancedAnalyticsEvent from 'app/utils/analytics/trackAdvancedAnalyticsEvent'; import localStorage from 'app/utils/localStorage'; import withApi from 'app/utils/withApi'; import withOrganization from 'app/utils/withOrganization'; @@ -75,6 +76,12 @@ function TeamInsightsOverview({ const currentTeam = teams.find(team => team.id === currentTeamId); const projects = currentTeam?.projects ?? []; + useEffect(() => { + trackAdvancedAnalyticsEvent('team_insights.viewed', { + organization, + }); + }, []); + function handleChangeTeam(teamId: string) { localStorage.setItem(localStorageKey, teamId); setStateOnUrl({team: teamId});