Unverified Commit df9956a8 authored by Manoj Pandian Sakthivel's avatar Manoj Pandian Sakthivel Committed by GitHub
Browse files

Add tracking and stop bumping links to top after revisiting (#201)

* Add tracking and stop bumping links to top after revisiting

* Use correct position

* Use separate position relative to links within the drawer

* Update category
parent 7c2f2af5
Pipeline #45437 passed with stages
in 5 minutes and 11 seconds
......@@ -9,6 +9,7 @@ import { PreviouslyViewedObject } from 'src/content/app/browser/track-panel/trac
import { closeTrackPanelModal } from 'src/content/app/browser/track-panel/trackPanelActions';
import { closeDrawer } from 'src/content/app/browser/drawer/drawerActions';
import { getActiveGenomePreviouslyViewedObjects } from 'src/content/app/browser/track-panel/trackPanelSelectors';
import analyticsTracking from 'src/services/analytics-service';
import styles from './DrawerBookmarks.scss';
......@@ -24,7 +25,14 @@ const DrawerBookmarks = (props: DrawerBookmarksProps) => {
props.previouslyViewedObjects.length - 20
);
const onClickHandler = () => {
const onClickHandler = (objectType: string, index: number) => {
analyticsTracking.trackEvent({
category: 'recent_bookmark_link',
label: objectType,
action: 'clicked',
value: index + 1
});
props.closeTrackPanelModal();
props.closeDrawer();
};
......@@ -44,7 +52,12 @@ const DrawerBookmarks = (props: DrawerBookmarksProps) => {
return (
<span key={index} className={styles.linkHolder}>
<Link to={path} onClick={onClickHandler}>
<Link
to={path}
onClick={() =>
onClickHandler(previouslyViewedObject.object_type, index)
}
>
{previouslyViewedObject.label}
</Link>
<span className={styles.previouslyViewedType}>
......
......@@ -17,6 +17,7 @@ import ImageButton from 'src/shared/components/image-button/ImageButton';
import { ReactComponent as EllipsisIcon } from 'static/img/track-panel/ellipsis.svg';
import { changeDrawerViewAndOpen } from 'src/content/app/browser/drawer/drawerActions';
import { PreviouslyViewedObject } from 'src/content/app/browser/track-panel/trackPanelState';
import analyticsTracking from 'src/services/analytics-service';
import { Status } from 'src/shared/types/status';
......@@ -68,6 +69,17 @@ type PreviouslyViewedLinksProps = Pick<
>;
export const PreviouslyViewedLinks = (props: PreviouslyViewedLinksProps) => {
const onLinkClick = (objectType: string, index: number) => {
analyticsTracking.trackEvent({
category: 'recent_bookmark_link',
label: objectType,
action: 'clicked',
value: index + 1
});
props.closeTrackPanelModal();
};
return (
<div>
{[...props.previouslyViewedObjects]
......@@ -80,7 +92,12 @@ export const PreviouslyViewedLinks = (props: PreviouslyViewedLinksProps) => {
return (
<div key={index} className={styles.linkHolder}>
<Link to={path} onClick={props.closeTrackPanelModal}>
<Link
to={path}
onClick={() =>
onLinkClick(previouslyViewedObject.object_type, index)
}
>
{previouslyViewedObject.label}
</Link>
<span className={styles.previouslyViewedType}>
......@@ -104,6 +121,17 @@ export const TrackPanelBookmarks = (props: TrackPanelBookmarksProps) => {
const limitedPreviouslyViewedObjects = previouslyViewedObjects.slice(-20);
const onEllipsisClick = () => {
analyticsTracking.trackEvent({
category: 'drawer_open',
label: 'recent_bookmarks',
action: 'clicked',
value: previouslyViewedObjects.length
});
props.changeDrawerViewAndOpen('bookmarks');
};
return (
<section className="trackPanelBookmarks">
<h3>Bookmarks</h3>
......@@ -127,7 +155,7 @@ export const TrackPanelBookmarks = (props: TrackPanelBookmarksProps) => {
buttonStatus={Status.ACTIVE}
description={'View all'}
image={EllipsisIcon}
onClick={() => props.changeDrawerViewAndOpen('bookmarks')}
onClick={onEllipsisClick}
/>
</span>
)}
......
......@@ -131,13 +131,6 @@ export const updatePreviouslyViewedObjectsAndSave: ActionCreator<
object_type: activeEnsObject.object_type,
label: activeEnsObject.label
});
} else {
// If it is already present, bump it to the end
const [previouslyViewedObject] = previouslyViewedObjects.splice(
existingIndex,
1
);
previouslyViewedObjects.push({ ...previouslyViewedObject });
}
// Limit the total number of previously viewed objects to 250
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment