diff --git a/datahub-web-react/src/app/analytics/event.ts b/datahub-web-react/src/app/analytics/event.ts index ff6f76d0f4459f..4f6faa7ddda39d 100644 --- a/datahub-web-react/src/app/analytics/event.ts +++ b/datahub-web-react/src/app/analytics/event.ts @@ -5,19 +5,23 @@ import { EntityType, RecommendationRenderType, ScenarioType } from '../../types. */ export enum EventType { PageViewEvent, + HomePageViewEvent, LogInEvent, LogOutEvent, SearchEvent, + HomePageSearchEvent, SearchResultsViewEvent, SearchResultClickEvent, EntitySearchResultClickEvent, BrowseResultClickEvent, + HomePageBrowseResultClickEvent, EntityViewEvent, EntitySectionViewEvent, EntityActionEvent, BatchEntityActionEvent, RecommendationImpressionEvent, RecommendationClickEvent, + HomePageRecommendationClickEvent, SearchAcrossLineageEvent, SearchAcrossLineageResultsViewEvent, DownloadAsCsvEvent, @@ -41,6 +45,14 @@ interface BaseEvent { */ export interface PageViewEvent extends BaseEvent { type: EventType.PageViewEvent; + originPath: string; +} + +/** + * Viewed the Home Page on the UI. + */ +export interface HomePageViewEvent extends BaseEvent { + type: EventType.HomePageViewEvent; } /** @@ -83,6 +95,16 @@ export interface SearchEvent extends BaseEvent { originPath: string; } +/** + * Logged on user successful search query from the home page. + */ +export interface HomePageSearchEvent extends BaseEvent { + type: EventType.HomePageSearchEvent; + query: string; + entityTypeFilter?: EntityType; + pageNumber: number; +} + /** * Logged on user search result click. */ @@ -119,6 +141,14 @@ export interface BrowseResultClickEvent extends BaseEvent { groupName?: string; } +/** + * Logged on user browse result click from the home page. + */ +export interface HomePageBrowseResultClickEvent extends BaseEvent { + type: EventType.HomePageBrowseResultClickEvent; + entityType: EntityType; +} + /** * Logged when user views an entity profile. */ @@ -185,6 +215,15 @@ export interface RecommendationClickEvent extends BaseEvent { index?: number; } +export interface HomePageRecommendationClickEvent extends BaseEvent { + type: EventType.HomePageRecommendationClickEvent; + renderId: string; // TODO : Determine whether we need a render id to join with click event. + moduleId: string; + renderType: RecommendationRenderType; + scenarioType: ScenarioType; + index?: number; +} + export interface SearchAcrossLineageEvent extends BaseEvent { type: EventType.SearchAcrossLineageEvent; query: string; @@ -213,14 +252,17 @@ export interface DownloadAsCsvEvent extends BaseEvent { */ export type Event = | PageViewEvent + | HomePageViewEvent | SignUpEvent | LogInEvent | LogOutEvent | ResetCredentialsEvent | SearchEvent + | HomePageSearchEvent | SearchResultsViewEvent | SearchResultClickEvent | BrowseResultClickEvent + | HomePageBrowseResultClickEvent | EntityViewEvent | EntitySectionViewEvent | EntityActionEvent @@ -229,4 +271,5 @@ export type Event = | SearchAcrossLineageResultsViewEvent | DownloadAsCsvEvent | RecommendationClickEvent + | HomePageRecommendationClickEvent | BatchEntityActionEvent; diff --git a/datahub-web-react/src/app/home/HomePage.tsx b/datahub-web-react/src/app/home/HomePage.tsx index 3ee292b4022046..2bb2981566285a 100644 --- a/datahub-web-react/src/app/home/HomePage.tsx +++ b/datahub-web-react/src/app/home/HomePage.tsx @@ -1,8 +1,10 @@ import React from 'react'; import { HomePageHeader } from './HomePageHeader'; import { HomePageBody } from './HomePageBody'; +import analytics, { EventType } from '../analytics'; export const HomePage = () => { + analytics.event({ type: EventType.HomePageViewEvent }); return ( <> diff --git a/datahub-web-react/src/app/home/HomePageHeader.tsx b/datahub-web-react/src/app/home/HomePageHeader.tsx index 4abbe0ebbf4353..daf7c305bb67dd 100644 --- a/datahub-web-react/src/app/home/HomePageHeader.tsx +++ b/datahub-web-react/src/app/home/HomePageHeader.tsx @@ -133,10 +133,9 @@ export const HomePageHeader = () => { return; } analytics.event({ - type: EventType.SearchEvent, + type: EventType.HomePageSearchEvent, query, pageNumber: 1, - originPath: window.location.pathname, }); navigateToSearchUrl({ type, diff --git a/datahub-web-react/src/app/search/BrowseEntityCard.tsx b/datahub-web-react/src/app/search/BrowseEntityCard.tsx index 03bc5aa1af1e9f..75cac886f42600 100644 --- a/datahub-web-react/src/app/search/BrowseEntityCard.tsx +++ b/datahub-web-react/src/app/search/BrowseEntityCard.tsx @@ -5,13 +5,20 @@ import { PageRoutes } from '../../conf/Global'; import { IconStyleType } from '../entity/Entity'; import { EntityType } from '../../types.generated'; import { LogoCountCard } from '../shared/LogoCountCard'; +import { EventType } from '../analytics/event'; +import analytics from '../analytics'; export const BrowseEntityCard = ({ entityType, count }: { entityType: EntityType; count: number }) => { const entityRegistry = useEntityRegistry(); - const url = - entityType === EntityType.GlossaryTerm - ? PageRoutes.GLOSSARY - : `${PageRoutes.BROWSE}/${entityRegistry.getPathName(entityType)}`; + const isGlossaryEntityCard = entityType === EntityType.GlossaryTerm; + const entityPathName = entityRegistry.getPathName(entityType); + const url = isGlossaryEntityCard ? PageRoutes.GLOSSARY : `${PageRoutes.BROWSE}/${entityPathName}`; + const onBrowseEntityCardClick = () => { + analytics.event({ + type: EventType.HomePageBrowseResultClickEvent, + entityType, + }); + }; return ( @@ -19,6 +26,7 @@ export const BrowseEntityCard = ({ entityType, count }: { entityType: EntityType logoComponent={entityRegistry.getIcon(entityType, 18, IconStyleType.HIGHLIGHT)} name={entityRegistry.getCollectionName(entityType)} count={count} + onClick={onBrowseEntityCardClick} /> );