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

chore: side by side analytics #998

Merged
merged 2 commits into from
Jun 20, 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
2 changes: 1 addition & 1 deletion .infra/rdev/values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
services:
explorer:
image:
tag: sha-6a4bee02
tag: sha-a5b576b2
replicaCount: 1
7 changes: 7 additions & 0 deletions client/src/actions/embedding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import type { AppDispatch, GetState, RootState } from "../reducers";
import { _setEmbeddingSubset } from "../util/stateManager/viewStackHelpers";
import { Field } from "../common/types/schema";
import * as globals from "../globals";
import { track } from "../analytics";
import { EVENTS } from "../analytics/events";

// eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types --- FIXME: disabled temporarily on migrate to TS.
async function _switchEmbedding(
Expand Down Expand Up @@ -109,6 +111,11 @@ export const swapLayoutChoicesAction: ActionCreator<
const mainLayoutChoice = layoutChoice.current;
const sideLayoutChoice = panelEmbedding.layoutChoice.current;

track(EVENTS.EXPLORER_SBS_SWAPPED, {
main_embedding: mainLayoutChoice,
window_embedding: sideLayoutChoice,
});

await dispatch(layoutChoiceAction(mainLayoutChoice, true));
await dispatch(layoutChoiceAction(sideLayoutChoice, false));
};
4 changes: 4 additions & 0 deletions client/src/analytics/events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ export enum EVENTS {
EXPLORER_RE_CENTER_EMBEDDING = "EXPLORER_RE_CENTER_EMBEDDING",
EXPLORER_ZOOMED = "EXPLORER_ZOOMED",
EXPLORER_PANNED = "EXPLORER_PANNED",
EXPLORER_SBS_SELECTED = "EXPLORER_SBS_SELECTED",
EXPLORER_SBS_SWAPPED = "EXPLORER_SBS_SWAPPED",
EXPLORER_SBS_SIDE_WINDOW_EMBEDDING_CLICKED = "EXPLORER_SBS_SIDE_WINDOW_EMBEDDING_CLICKED",
EXPLORER_SBS_SIDE_WINDOW_EMBEDDING_SELECTED = "EXPLORER_SBS_SIDE_WINDOW_EMBEDDING_SELECTED",

WMG_CLICK_NAV = "WMG_CLICK_NAV",
COLLECTIONS_CLICK_NAV = "COLLECTIONS_CLICK_NAV",
Expand Down
27 changes: 23 additions & 4 deletions client/src/components/embedding/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,24 @@ const Embedding = (props: Props) => {
const isSpatial = getFeatureFlag(FEATURES.SPATIAL);

const handleLayoutChoiceClick = (): void => {
track(EVENTS.EXPLORER_EMBEDDING_CLICKED);
track(
isSidePanel
? EVENTS.EXPLORER_SBS_SIDE_WINDOW_EMBEDDING_CLICKED
: EVENTS.EXPLORER_EMBEDDING_CLICKED
);
};

const handleLayoutChoiceChange = async (
e: FormEvent<HTMLInputElement>
): Promise<void> => {
track(EVENTS.EXPLORER_EMBEDDING_SELECTED, {
embedding: e.currentTarget.value,
});
track(
isSidePanel
? EVENTS.EXPLORER_SBS_SIDE_WINDOW_EMBEDDING_SELECTED
: EVENTS.EXPLORER_EMBEDDING_SELECTED,
{
embedding: e.currentTarget.value,
}
);

await dispatch(
actions.layoutChoiceAction(e.currentTarget.value, isSidePanel)
Expand All @@ -85,6 +94,16 @@ const Embedding = (props: Props) => {
dispatch({
type: "toggle panel embedding",
});

/**
* (thuang): Product requirement to only track when the side panel goes from
* closed to open.
*/
if (!sideIsOpen) {
track(EVENTS.EXPLORER_SBS_SELECTED, {
embedding: layoutChoice.current,
});
}
};

return (
Expand Down
27 changes: 22 additions & 5 deletions client/src/components/graph/graph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ const mapStateToProps = (state: RootState, ownProps: OwnProps): StateProps => ({
mountCapture: state.controls.mountCapture,
imageUnderlay: state.controls.imageUnderlay,
config: state.config,
isSidePanelOpen: state.panelEmbedding.open,
sidePanelLayoutChoice: state.panelEmbedding.layoutChoice,
});

class Graph extends React.Component<GraphProps, GraphState> {
Expand Down Expand Up @@ -550,8 +552,15 @@ class Graph extends React.Component<GraphProps, GraphState> {
}

async handleImageDownload(regl: GraphState["regl"]) {
const { dispatch, screenCap, mountCapture, layoutChoice, colors } =
this.props;
const {
dispatch,
screenCap,
mountCapture,
layoutChoice,
colors,
isSidePanelOpen,
sidePanelLayoutChoice,
} = this.props;

if (!this.reglCanvas || !screenCap || !regl || this.isDownloadingImage) {
return;
Expand Down Expand Up @@ -638,9 +647,17 @@ class Graph extends React.Component<GraphProps, GraphState> {
if (categoricalLegendImageURI) {
downloadImage(categoricalLegendImageURI);
}
track(EVENTS.EXPLORER_DOWNLOAD_COMPLETE, {
embedding: layoutChoice.current,
});

track(
EVENTS.EXPLORER_DOWNLOAD_COMPLETE,
isSidePanelOpen
? {
embedding: layoutChoice.current,
side_by_side: sidePanelLayoutChoice?.current,
}
: { embedding: layoutChoice.current }
);

dispatch({ type: "graph: screencap end" });
}

Expand Down
2 changes: 2 additions & 0 deletions client/src/components/graph/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,8 @@ export interface StateProps {
mountCapture: RootState["controls"]["mountCapture"];
imageUnderlay: RootState["controls"]["imageUnderlay"];
config: RootState["config"];
isSidePanelOpen: RootState["panelEmbedding"]["open"];
sidePanelLayoutChoice: RootState["panelEmbedding"]["layoutChoice"];
}

export interface OwnProps {
Expand Down
Loading