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 { CellId } from "@nteract/commutable";
|
||||||
|
import { ContentRef } from "@nteract/core";
|
||||||
|
import { Action } from "../../../Shared/Telemetry/TelemetryConstants";
|
||||||
|
|
||||||
export const CLOSE_NOTEBOOK = "CLOSE_NOTEBOOK";
|
export const CLOSE_NOTEBOOK = "CLOSE_NOTEBOOK";
|
||||||
export interface CloseNotebookAction {
|
export interface CloseNotebookAction {
|
||||||
|
@ -81,3 +82,24 @@ export const setHoveredCell = (payload: { cellId: CellId }): SetHoveredCellActio
|
||||||
payload
|
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 * as cdbActions from "./actions";
|
||||||
import { CdbRecord } from "./types";
|
import { CdbRecord } from "./types";
|
||||||
|
|
||||||
import { Action } from "redux";
|
|
||||||
import { actions, CoreRecord, reducers as nteractReducers } from "@nteract/core";
|
|
||||||
|
|
||||||
export const coreReducer = (state: CoreRecord, action: Action) => {
|
export const coreReducer = (state: CoreRecord, action: Action) => {
|
||||||
let typedAction;
|
let typedAction;
|
||||||
switch (action.type) {
|
switch (action.type) {
|
||||||
|
@ -75,6 +76,17 @@ export const cdbReducer = (state: CdbRecord, action: Action) => {
|
||||||
const typedAction = action as cdbActions.SetHoveredCellAction;
|
const typedAction = action as cdbActions.SetHoveredCellAction;
|
||||||
return state.set("hoveredCellId", typedAction.payload.cellId);
|
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;
|
return state;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
|
import { actions, ContentRef, selectors } from "@nteract/core";
|
||||||
import React from "react";
|
import React from "react";
|
||||||
import { connect } from "react-redux";
|
import { connect } from "react-redux";
|
||||||
import { Dispatch } from "redux";
|
import { Dispatch } from "redux";
|
||||||
|
import { Action, ActionModifiers } from "../../../Shared/Telemetry/TelemetryConstants";
|
||||||
import { ContentRef, selectors, actions } from "@nteract/core";
|
import * as cdbActions from "../NotebookComponent/actions";
|
||||||
import { CdbAppState } from "../NotebookComponent/types";
|
import { CdbAppState } from "../NotebookComponent/types";
|
||||||
|
|
||||||
export interface PassedPromptProps {
|
export interface PassedPromptProps {
|
||||||
|
@ -83,7 +84,15 @@ const mapDispatchToProps = (
|
||||||
dispatch: Dispatch,
|
dispatch: Dispatch,
|
||||||
{ id, contentRef }: { id: string; contentRef: ContentRef }
|
{ id, contentRef }: { id: string; contentRef: ContentRef }
|
||||||
): DispatchProps => ({
|
): 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({}))
|
stopExecution: () => dispatch(actions.interruptKernel({}))
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -86,6 +86,7 @@ export enum Action {
|
||||||
CreateNewNotebook,
|
CreateNewNotebook,
|
||||||
OpenSampleNotebook,
|
OpenSampleNotebook,
|
||||||
ExecuteCell,
|
ExecuteCell,
|
||||||
|
ExecuteCellPromptBtn,
|
||||||
ExecuteAllCells,
|
ExecuteAllCells,
|
||||||
NotebookEnabled,
|
NotebookEnabled,
|
||||||
NotebooksGitHubConnect,
|
NotebooksGitHubConnect,
|
||||||
|
|
Loading…
Reference in New Issue