Add telemetry to track execute cell from <Prompt/> (#15)
This commit is contained in:
parent
a6c44e0e69
commit
ab3486bd05
|
@ -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
|
||||
};
|
||||
};
|
||||
|
|
|
@ -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;
|
||||
};
|
||||
|
|
|
@ -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({}))
|
||||
});
|
||||
|
||||
|
|
|
@ -86,6 +86,7 @@ export enum Action {
|
|||
CreateNewNotebook,
|
||||
OpenSampleNotebook,
|
||||
ExecuteCell,
|
||||
ExecuteCellPromptBtn,
|
||||
ExecuteAllCells,
|
||||
NotebookEnabled,
|
||||
NotebooksGitHubConnect,
|
||||
|
|
Loading…
Reference in New Issue