Skip to content

Commit

Permalink
feat(tracking): add additional home page telemetry (#6018)
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya-radhakrishnan authored Sep 23, 2022
1 parent 011421d commit f57f398
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 6 deletions.
43 changes: 43 additions & 0 deletions datahub-web-react/src/app/analytics/event.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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;
}

/**
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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.
*/
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand All @@ -229,4 +271,5 @@ export type Event =
| SearchAcrossLineageResultsViewEvent
| DownloadAsCsvEvent
| RecommendationClickEvent
| HomePageRecommendationClickEvent
| BatchEntityActionEvent;
2 changes: 2 additions & 0 deletions datahub-web-react/src/app/home/HomePage.tsx
Original file line number Diff line number Diff line change
@@ -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 (
<>
<HomePageHeader />
Expand Down
3 changes: 1 addition & 2 deletions datahub-web-react/src/app/home/HomePageHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 12 additions & 4 deletions datahub-web-react/src/app/search/BrowseEntityCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,28 @@ 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 (
<Link to={url} data-testid={`entity-type-browse-card-${entityType}`}>
<LogoCountCard
logoComponent={entityRegistry.getIcon(entityType, 18, IconStyleType.HIGHLIGHT)}
name={entityRegistry.getCollectionName(entityType)}
count={count}
onClick={onBrowseEntityCardClick}
/>
</Link>
);
Expand Down

0 comments on commit f57f398

Please sign in to comment.