Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RHOAIENG-6314] Add tracking for new Homepage. #2781

Merged
merged 1 commit into from
May 21, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion frontend/src/pages/home/projects/ProjectCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
getProjectDisplayName,
getProjectOwner,
} from '~/concepts/projects/utils';
import { fireTrackingEventRaw } from '~/utilities/segmentIOUtils';

interface ProjectCardProps {
project: ProjectKind;
Expand All @@ -38,7 +39,13 @@ const ProjectCard: React.FC<ProjectCardProps> = ({ project }) => {
data-testid={`project-link-${project.metadata.name}`}
variant="link"
isInline
onClick={() => navigate(`/projects/${project.metadata.name}`)}
onClick={() => {
navigate(`/projects/${project.metadata.name}`);
fireTrackingEventRaw('HomeCardClicked', {
to: `/projects/${project.metadata.name}`,
type: 'project',
});
}}
style={{ fontSize: 'var(--pf-v5-global--FontSize--md)' }}
>
<Truncate content={getProjectDisplayName(project)} />
Expand Down
18 changes: 14 additions & 4 deletions frontend/src/pages/home/useEnableTeamSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import InfoGalleryItem from '~/concepts/design/InfoGalleryItem';
import { useBrowserStorage } from '~/components/browserStorage';
import { SupportedArea } from '~/concepts/areas';
import useIsAreaAvailable from '~/concepts/areas/useIsAreaAvailable';
import { fireTrackingEventRaw } from '~/utilities/segmentIOUtils';

export const useEnableTeamSection = (): React.ReactNode => {
const navigate = useNavigate();
Expand All @@ -32,6 +33,15 @@ export const useEnableTeamSection = (): React.ReactNode => {
return null;
}

const trackAndNavigate = (section: string, to: string): void => {
fireTrackingEventRaw('HomeCardClicked', {
to: `${to}`,
type: 'enableTeam',
section: `${section}`,
});
navigate(to);
};

const infoItems = [];

if (notebooksAvailable) {
Expand All @@ -41,7 +51,7 @@ export const useEnableTeamSection = (): React.ReactNode => {
testId="landing-page-admin--notebook-images"
isOpen={resourcesOpen}
title="Notebook images"
onClick={() => navigate('/notebookImages')}
onClick={() => trackAndNavigate('notebook-images', '/notebookImages')}
imgSrc={notebookImagesImage}
sectionType={SectionType.setup}
description={
Expand All @@ -62,7 +72,7 @@ export const useEnableTeamSection = (): React.ReactNode => {
testId="landing-page-admin--serving-runtimes"
isOpen={resourcesOpen}
title="Serving runtimes"
onClick={() => navigate('/servingRuntimes')}
onClick={() => trackAndNavigate('serving-runtimes', '/servingRuntimes')}
imgSrc={servingRuntimesImage}
sectionType={SectionType.setup}
description={
Expand All @@ -84,7 +94,7 @@ export const useEnableTeamSection = (): React.ReactNode => {
testId="landing-page-admin--cluster-settings"
isOpen={resourcesOpen}
title="Cluster settings"
onClick={() => navigate('/clusterSettings')}
onClick={() => trackAndNavigate('cluster-settings', '/clusterSettings')}
imgSrc={clusterSettingsImage}
sectionType={SectionType.setup}
description={
Expand All @@ -105,7 +115,7 @@ export const useEnableTeamSection = (): React.ReactNode => {
testId="landing-page-admin--user-management"
isOpen={resourcesOpen}
title="User management"
onClick={() => navigate('/groupSettings')}
onClick={() => trackAndNavigate('user-management', '/groupSettings')}
imgSrc={userImage}
sectionType={SectionType.setup}
description={
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { isValidK8sName } from '~/concepts/k8s/utils';
import NameDescriptionField from '~/concepts/k8s/NameDescriptionField';
import { NameDescType } from '~/pages/projects/types';
import { ProjectsContext } from '~/concepts/projects/ProjectsContext';
import { fireTrackingEventRaw } from '~/utilities/segmentIOUtils';
import { TrackingOutcome } from '~/types';

type ManageProjectModalProps = {
editProjectData?: ProjectKind;
Expand Down Expand Up @@ -46,11 +48,24 @@ const ManageProjectModal: React.FC<ManageProjectModalProps> = ({

const onBeforeClose = (newProjectName?: string) => {
onClose(newProjectName);
if (newProjectName) {
fireTrackingEventRaw(editProjectData ? 'Project Edited' : 'NewProject Created', {
outcome: TrackingOutcome.submit,
success: true,
projectName: newProjectName,
});
}
setFetching(false);
setError(undefined);
setNameDesc({ name: '', k8sName: undefined, description: '' });
};
const handleError = (e: Error) => {
fireTrackingEventRaw(editProjectData ? 'Project Edited' : 'NewProject Created', {
outcome: TrackingOutcome.submit,
success: false,
projectName: '',
error: e.message,
});
setError(e);
setFetching(false);
};
Expand Down Expand Up @@ -85,7 +100,16 @@ const ManageProjectModal: React.FC<ManageProjectModalProps> = ({
>
{editProjectData ? 'Update' : 'Create'}
</Button>,
<Button key="cancel" variant="link" onClick={() => onBeforeClose()}>
<Button
key="cancel"
variant="link"
onClick={() => {
onBeforeClose();
fireTrackingEventRaw(editProjectData ? 'Project Edited' : 'NewProject Created', {
outcome: TrackingOutcome.cancel,
});
}}
>
Cancel
</Button>,
]}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import * as React from 'react';
import { Button } from '@patternfly/react-core';
import { fireTrackingEvent } from '~/utilities/segmentIOUtils';
import { TrackingOutcome } from '~/types';
import ManageProjectModal from './ManageProjectModal';

type NewProjectButtonProps = {
Expand All @@ -24,11 +22,6 @@ const NewProjectButton: React.FC<NewProjectButtonProps> = ({ closeOnCreate, onPr
<ManageProjectModal
open={open}
onClose={(newProjectName) => {
fireTrackingEvent('NewProject Created', {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did you drop this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is now handled inside the ManageProjectModal at https://github.com/opendatahub-io/odh-dashboard/pull/2781/files#diff-8827454ead4ff8421767576741c1ec341bf780e07671a2c37a34fd2677fbb7caR51 , because the Modal is called from multiple places.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@pilhuhn there are 5 use cases of NewProjectButton -- you point at solving 1. What about the other 4?

Copy link
Member

@andrewballantyne andrewballantyne May 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I only ask because we sound like we are losing overall tracking, to get tracking for the home page

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll have a look in a minute (once the tranisition to the new laptop is kind of finished). Moving the tracking code inside ManagedProjectModal should catch them all. Before there was this button and also the new NewProject link on the new home page.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andrewballantyne I am not sure I understand your question. The tracking code has moved from NewProjectButton into ManageProjectModal, which is part of the internal implementation of the NewProjectButton.
I did that because the ProjectsSection is using the modal directly and not via NewProjectButton.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I misunderstood it when I briefly was looking at it earlier. Thanks for the clarification.

outcome: newProjectName ? TrackingOutcome.submit : TrackingOutcome.cancel,
success: onProjectCreated != null,
projectName: newProjectName || '',
});
if (newProjectName) {
if (onProjectCreated) {
onProjectCreated(newProjectName);
Expand Down
Loading