diff --git a/src/Explorer/Notebook/NotebookComponent/actions.ts b/src/Explorer/Notebook/NotebookComponent/actions.ts index 5812a1833..cfc1c763f 100644 --- a/src/Explorer/Notebook/NotebookComponent/actions.ts +++ b/src/Explorer/Notebook/NotebookComponent/actions.ts @@ -1,5 +1,6 @@ -import { ContentRef } from "@nteract/core"; import { CellId } from "@nteract/commutable"; +import { ContentRef } from "@nteract/core"; +import { Action } from "../../../Shared/Telemetry/TelemetryConstants"; export const CLOSE_NOTEBOOK = "CLOSE_NOTEBOOK"; export interface CloseNotebookAction { @@ -81,3 +82,24 @@ export const setHoveredCell = (payload: { cellId: CellId }): SetHoveredCellActio payload }; }; + +export const TRACE_NOTEBOOK_TELEMETRY = "TRACE_NOTEBOOK_TELEMETRY"; +export interface TraceNotebookTelemetryAction { + type: "TRACE_NOTEBOOK_TELEMETRY"; + payload: { + action: Action; + actionModifier?: string; + data?: any; + }; +} + +export const traceNotebookTelemetry = (payload: { + action: Action; + actionModifier?: string; + data?: any; +}): TraceNotebookTelemetryAction => { + return { + type: TRACE_NOTEBOOK_TELEMETRY, + payload + }; +}; diff --git a/src/Explorer/Notebook/NotebookComponent/reducers.ts b/src/Explorer/Notebook/NotebookComponent/reducers.ts index 89e0ad0a5..0feb63b42 100644 --- a/src/Explorer/Notebook/NotebookComponent/reducers.ts +++ b/src/Explorer/Notebook/NotebookComponent/reducers.ts @@ -1,9 +1,10 @@ +import { actions, CoreRecord, reducers as nteractReducers } from "@nteract/core"; +import { Action } from "redux"; +import { Areas } from "../../../Common/Constants"; +import TelemetryProcessor from "../../../Shared/Telemetry/TelemetryProcessor"; import * as cdbActions from "./actions"; import { CdbRecord } from "./types"; -import { Action } from "redux"; -import { actions, CoreRecord, reducers as nteractReducers } from "@nteract/core"; - export const coreReducer = (state: CoreRecord, action: Action) => { let typedAction; switch (action.type) { @@ -75,6 +76,17 @@ export const cdbReducer = (state: CdbRecord, action: Action) => { const typedAction = action as cdbActions.SetHoveredCellAction; return state.set("hoveredCellId", typedAction.payload.cellId); } + + case cdbActions.TRACE_NOTEBOOK_TELEMETRY: { + const typedAction = action as cdbActions.TraceNotebookTelemetryAction; + TelemetryProcessor.trace(typedAction.payload.action, typedAction.payload.actionModifier, { + ...typedAction.payload.data, + databaseAccountName: state.databaseAccountName, + defaultExperience: state.defaultExperience, + dataExplorerArea: Areas.Notebook + }); + return state; + } } return state; }; diff --git a/src/Explorer/Notebook/NotebookRenderer/Prompt.tsx b/src/Explorer/Notebook/NotebookRenderer/Prompt.tsx index 988c1f770..733957079 100644 --- a/src/Explorer/Notebook/NotebookRenderer/Prompt.tsx +++ b/src/Explorer/Notebook/NotebookRenderer/Prompt.tsx @@ -1,8 +1,9 @@ +import { actions, ContentRef, selectors } from "@nteract/core"; import React from "react"; import { connect } from "react-redux"; import { Dispatch } from "redux"; - -import { ContentRef, selectors, actions } from "@nteract/core"; +import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants"; +import * as cdbActions from "../NotebookComponent/actions"; import { CdbAppState } from "../NotebookComponent/types"; export interface PassedPromptProps { @@ -83,7 +84,15 @@ const mapDispatchToProps = ( dispatch: Dispatch, { id, contentRef }: { id: string; contentRef: ContentRef } ): DispatchProps => ({ - executeCell: () => dispatch(actions.executeCell({ id, contentRef })), + executeCell: () => { + dispatch(actions.executeCell({ id, contentRef })); + dispatch( + cdbActions.traceNotebookTelemetry({ + action: Action.ExecuteCellPromptBtn, + actionModifier: ActionModifiers.Mark + }) + ); + }, stopExecution: () => dispatch(actions.interruptKernel({})) }); diff --git a/src/Shared/Telemetry/TelemetryConstants.ts b/src/Shared/Telemetry/TelemetryConstants.ts index f0509c80d..43fc07707 100644 --- a/src/Shared/Telemetry/TelemetryConstants.ts +++ b/src/Shared/Telemetry/TelemetryConstants.ts @@ -86,6 +86,7 @@ export enum Action { CreateNewNotebook, OpenSampleNotebook, ExecuteCell, + ExecuteCellPromptBtn, ExecuteAllCells, NotebookEnabled, NotebooksGitHubConnect,