Skip to content

Commit

Permalink
feat(spatial): analytics (#974)
Browse files Browse the repository at this point in the history
  • Loading branch information
kaloster authored Jun 12, 2024
1 parent b50ccbf commit 9986a37
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
9 changes: 7 additions & 2 deletions client/src/analytics/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,9 @@ export enum EVENTS {
EXPLORER_VISUALIZATION_SETTINGS_BUTTON_CLICKED = "EXPLORER_VISUALIZATION_SETTINGS_BUTTON_CLICKED",
EXPLORER_UNDO_BUTTON_CLICKED = "EXPLORER_UNDO_BUTTON_CLICKED",
EXPLORER_REDO_BUTTON_CLICKED = "EXPLORER_REDO_BUTTON_CLICKED",
EXPLORER_LAYOUT_CHOICE_BUTTON_CLICKED = "EXPLORER_LAYOUT_CHOICE_BUTTON_CLICKED",
EXPLORER_LAYOUT_CHOICE_CHANGE_ITEM_CLICKED = "EXPLORER_LAYOUT_CHOICE_CHANGE_ITEM_CLICKED",
EXPLORER_DOWNLOAD_COMPLETE = "EXPLORER_DOWNLOAD_COMPLETE",
EXPLORER_EMBEDDING_CLICKED = "EXPLORER_EMBEDDING_CLICKED",
EXPLORER_EMBEDDING_SELECTED = "EXPLORER_EMBEDDING_SELECTED",
EXPLORER_FLOATING_BUTTON_CLICKED = "EXPLORER_FLOATING_BUTTON_CLICKED",
EXPLORER_COLORBY_CATEGORIES_BUTTON_CLICKED = "EXPLORER_COLORBY_CATEGORIES_BUTTON_CLICKED",
EXPLORER_COLORBY_HISTOGRAM_CONTINUOUS_BUTTON_CLICKED = "EXPLORER_COLORBY_HISTOGRAM_CONTINUOUS_BUTTON_CLICKED",
Expand Down Expand Up @@ -50,6 +51,10 @@ export enum EVENTS {
EXPLORER_ADD_GENE_AND_SELECT_HISTOGRAM = "EXPLORER_ADD_GENE_AND_SELECT_HISTOGRAM",
EXPLORER_SELECT_HISTOGRAM = "EXPLORER_SELECT_HISTOGRAM",
EXPLORER_GENE_INFO_BUTTON_CLICKED = "EXPLORER_GENE_INFO_BUTTON_CLICKED",
EXPLORER_IMAGE_SELECT = "EXPLORER_IMAGE_SELECT",
EXPLORER_IMAGE_DESELECT = "EXPLORER_IMAGE_DESELECT",
EXPLORER_RE_CENTER_EMBEDDING = "EXPLORER_RE_CENTER_EMBEDDING",

WMG_CLICK_NAV = "WMG_CLICK_NAV",
COLLECTIONS_CLICK_NAV = "COLLECTIONS_CLICK_NAV",
CENSUS_DOCUMENTATION_CLICK_NAV = "CENSUS_DOCUMENTATION_CLICK_NAV",
Expand Down
6 changes: 4 additions & 2 deletions client/src/components/embedding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,15 @@ type Props = RootState;
}))
class Embedding extends React.PureComponent<Props> {
handleLayoutChoiceClick = (): void => {
track(EVENTS.EXPLORER_LAYOUT_CHOICE_BUTTON_CLICKED);
track(EVENTS.EXPLORER_EMBEDDING_CLICKED);
};

handleLayoutChoiceChange = (e: React.ChangeEvent<HTMLInputElement>) => {
const { dispatch, imageUnderlay } = this.props;

track(EVENTS.EXPLORER_LAYOUT_CHOICE_CHANGE_ITEM_CLICKED);
track(EVENTS.EXPLORER_EMBEDDING_SELECTED, {
embedding: e.currentTarget.value,
});

dispatch(actions.layoutChoiceAction(e.currentTarget.value));
if (
Expand Down
7 changes: 6 additions & 1 deletion client/src/components/graph/graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ import { THROTTLE_MS } from "../../util/constants";
import { GraphProps, GraphState } from "./types";
import { isSpatialMode, shouldShowOpenseadragon } from "../../common/selectors";
import { fetchDeepZoomImageFailed } from "../../actions/config";
import { track } from "../../analytics";
import { EVENTS } from "../../analytics/events";

interface GraphAsyncProps {
positions: Float32Array;
Expand Down Expand Up @@ -387,6 +389,7 @@ class Graph extends React.Component<GraphProps, GraphState> {
};

handleGoHome = () => {
track(EVENTS.EXPLORER_RE_CENTER_EMBEDDING);
const { camera } = this.state;

camera?.goHome(this.openseadragon);
Expand Down Expand Up @@ -621,7 +624,9 @@ class Graph extends React.Component<GraphProps, GraphState> {
if (categoricalLegendImageURI) {
downloadImage(categoricalLegendImageURI);
}

track(EVENTS.EXPLORER_DOWNLOAD_COMPLETE, {
embedding: layoutChoice.current,
});
dispatch({ type: "graph: screencap end" });
}

Expand Down
5 changes: 5 additions & 0 deletions client/src/components/menubar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -435,6 +435,11 @@ class MenuBar extends React.PureComponent<{}, State> {
intent={imageUnderlay ? "primary" : "none"}
active={imageUnderlay}
onClick={() => {
track(
imageUnderlay
? EVENTS.EXPLORER_IMAGE_SELECT
: EVENTS.EXPLORER_IMAGE_DESELECT
);
dispatch({
type: "toggle image underlay",
toggle: !imageUnderlay,
Expand Down

0 comments on commit 9986a37

Please sign in to comment.