Skip to content

Commit

Permalink
Merge pull request #96523 from maryliag/backport22.2-96513
Browse files Browse the repository at this point in the history
release-22.2: analytics: send info of events from the console
  • Loading branch information
maryliag authored Feb 6, 2023
2 parents 30cd22e + 8490c67 commit ecaab51
Show file tree
Hide file tree
Showing 13 changed files with 227 additions and 57 deletions.
2 changes: 1 addition & 1 deletion pkg/ui/workspaces/cluster-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@cockroachlabs/cluster-ui",
"version": "22.2.2",
"version": "22.2.3",
"description": "Cluster UI is a library of large features shared between CockroachDB and CockroachCloud",
"repository": {
"type": "git",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import { connect } from "react-redux";
import { actions as indexStatsActions } from "src/store/indexStats/indexStats.reducer";
import { cockroach } from "@cockroachlabs/crdb-protobuf-client";
import { actions as nodesActions } from "../store/nodes";
import { actions as analyticsActions } from "../store/analytics";

const mapStateToProps = (state: AppState, props: RouteComponentProps) => {
return selectIndexDetails(state, props);
Expand All @@ -40,6 +41,12 @@ const mapDispatchToProps = (dispatch: Dispatch): IndexDetailPageActions => ({
table,
}),
);
dispatch(
analyticsActions.track({
name: "Reset Index Usage",
page: "Index Details",
}),
);
},
refreshNodes: () => dispatch(nodesActions.refresh()),
refreshUserSQLRoles: () => dispatch(uiConfigActions.refreshUserSQLRoles()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { SortSetting } from "src/sortedtable";
import { actions as localStorageActions } from "../../store/localStorage";
import { Dispatch } from "redux";
import { selectHasAdminRole } from "../../store/uiConfig";
import { actions as analyticsActions } from "../../store/analytics";

const mapStateToProps = (
state: AppState,
Expand All @@ -54,6 +55,14 @@ const mapDispatchToProps = (
value: filters,
}),
);
dispatch(
analyticsActions.track({
name: "Filter Clicked",
page: "Schema Insights",
filterName: "filters",
value: filters.toString(),
}),
);
},
onSortChange: (ss: SortSetting) => {
dispatch(
Expand All @@ -62,6 +71,14 @@ const mapDispatchToProps = (
value: ss,
}),
);
dispatch(
analyticsActions.track({
name: "Column Sorted",
page: "Schema Insights",
tableName: "Schema Insights Table",
columnName: ss.columnTitle,
}),
);
},
refreshSchemaInsights: () => {
dispatch(actions.refresh());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
import { selectHasAdminRole, selectIsTenant } from "src/store/uiConfig";
import { TimeScale } from "../../timeScaleDropdown";
import { actions as sqlStatsActions } from "../../store/sqlStats";
import { actions as analyticsActions } from "../../store/analytics";

const mapStateToProps = (
state: AppState,
Expand Down Expand Up @@ -51,6 +52,13 @@ const mapDispatchToProps = (
ts: ts,
}),
);
dispatch(
analyticsActions.track({
name: "TimeScale changed",
page: "Statement Insight Details",
value: ts.key,
}),
);
},
refreshUserSQLRoles: () => dispatch(uiConfigActions.refreshUserSQLRoles()),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { actions as sqlStatsActions } from "../../store/sqlStats";
import { Dispatch } from "redux";
import { TransactionInsightEventDetailsRequest } from "src/api";
import { selectHasAdminRole } from "src/store/uiConfig";
import { actions as analyticsActions } from "../../store/analytics";

const mapStateToProps = (
state: AppState,
Expand Down Expand Up @@ -53,6 +54,13 @@ const mapDispatchToProps = (
ts: ts,
}),
);
dispatch(
analyticsActions.track({
name: "TimeScale changed",
page: "Transaction Insight Details",
value: ts.key,
}),
);
},
refreshUserSQLRoles: () => dispatch(uiConfigActions.refreshUserSQLRoles()),
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,10 @@ import {
selectFilters,
selectSortSetting,
} from "src/store/insights/transactionInsights";
import { bindActionCreators, Dispatch } from "redux";
import { Dispatch } from "redux";
import { TimeScale } from "../../timeScaleDropdown";
import { actions as sqlStatsActions } from "../../store/sqlStats";
import {
StatementInsightDetails,
StatementInsightDetailsDispatchProps,
StatementInsightDetailsStateProps,
} from "../workloadInsightDetails";
import { actions as analyticsActions } from "../../store/analytics";

const transactionMapStateToProps = (
state: AppState,
Expand All @@ -72,26 +68,51 @@ const statementMapStateToProps = (
const TransactionDispatchProps = (
dispatch: Dispatch,
): TransactionInsightsViewDispatchProps => ({
onFiltersChange: (filters: WorkloadInsightEventFilters) =>
onFiltersChange: (filters: WorkloadInsightEventFilters) => {
dispatch(
localStorageActions.update({
key: "filters/InsightsPage",
value: filters,
}),
),
onSortChange: (ss: SortSetting) =>
);
dispatch(
analyticsActions.track({
name: "Filter Clicked",
page: "Workload Insights - Transaction",
filterName: "filters",
value: filters.toString(),
}),
);
},
onSortChange: (ss: SortSetting) => {
dispatch(
localStorageActions.update({
key: "sortSetting/InsightsPage",
value: ss,
}),
),
);
dispatch(
analyticsActions.track({
name: "Column Sorted",
page: "Workload Insights - Transaction",
tableName: "Workload Transaction Insights Table",
columnName: ss.columnTitle,
}),
);
},
setTimeScale: (ts: TimeScale) => {
dispatch(
sqlStatsActions.updateTimeScale({
ts: ts,
}),
);
dispatch(
analyticsActions.track({
name: "TimeScale changed",
page: "Workload Insights - Transaction",
value: ts.key,
}),
);
},
refreshTransactionInsights: () => {
dispatch(transactionInsights.refresh());
Expand All @@ -101,37 +122,71 @@ const TransactionDispatchProps = (
const StatementDispatchProps = (
dispatch: Dispatch,
): StatementInsightsViewDispatchProps => ({
onFiltersChange: (filters: WorkloadInsightEventFilters) =>
onFiltersChange: (filters: WorkloadInsightEventFilters) => {
dispatch(
localStorageActions.update({
key: "filters/InsightsPage",
value: filters,
}),
),
onSortChange: (ss: SortSetting) =>
);
dispatch(
analyticsActions.track({
name: "Filter Clicked",
page: "Workload Insights - Statement",
filterName: "filters",
value: filters.toString(),
}),
);
},
onSortChange: (ss: SortSetting) => {
dispatch(
localStorageActions.update({
key: "sortSetting/InsightsPage",
value: ss,
}),
),
);
dispatch(
analyticsActions.track({
name: "Column Sorted",
page: "Workload Insights - Statement",
tableName: "Workload Statement Insights Table",
columnName: ss.columnTitle,
}),
);
},
// We use `null` when the value was never set and it will show all columns.
// If the user modifies the selection and no columns are selected,
// the function will save the value as a blank space, otherwise
// it gets saved as `null`.
onColumnsChange: (value: string[]) =>
onColumnsChange: (value: string[]) => {
const columns = value.length === 0 ? " " : value.join(",");
dispatch(
localStorageActions.update({
key: "showColumns/StatementInsightsPage",
value: value.length === 0 ? " " : value.join(","),
value: columns,
}),
),
);
dispatch(
analyticsActions.track({
name: "Columns Selected change",
page: "Workload Insights - Statement",
value: columns,
}),
);
},
setTimeScale: (ts: TimeScale) => {
dispatch(
sqlStatsActions.updateTimeScale({
ts: ts,
}),
);
dispatch(
analyticsActions.track({
name: "TimeScale changed",
page: "Workload Insights - Statement",
value: ts.key,
}),
);
},
refreshStatementInsights: () => {
dispatch(statementInsights.refresh());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
selectTypeSetting,
selectStatusSetting,
selectColumns,
} from "../../store/jobs/jobs.selectors";
} from "../../store/jobs";
import {
JobsPageStateProps,
JobsPageDispatchProps,
Expand All @@ -30,6 +30,7 @@ import { actions as jobsActions } from "src/store/jobs";
import { actions as localStorageActions } from "../../store/localStorage";
import { Dispatch } from "redux";
import { SortSetting } from "../../sortedtable";
import { actions as analyticsActions } from "../../store/analytics";

const mapStateToProps = (
state: AppState,
Expand Down Expand Up @@ -72,6 +73,14 @@ const mapDispatchToProps = (dispatch: Dispatch): JobsPageDispatchProps => ({
value: ss,
}),
);
dispatch(
analyticsActions.track({
name: "Column Sorted",
page: "Jobs",
tableName: "Jobs Table",
columnName: ss.columnTitle,
}),
);
},
setStatus: (statusValue: string) => {
dispatch(
Expand All @@ -88,14 +97,31 @@ const mapDispatchToProps = (dispatch: Dispatch): JobsPageDispatchProps => ({
value: jobValue,
}),
);
dispatch(
analyticsActions.track({
name: "Job Type Selected",
page: "Jobs",
value: jobValue.toString(),
}),
);
},
onColumnsChange: (selectedColumns: string[]) =>
onColumnsChange: (selectedColumns: string[]) => {
const columns =
selectedColumns.length === 0 ? " " : selectedColumns.join(",");
dispatch(
localStorageActions.update({
key: "showColumns/JobsPage",
value: selectedColumns.length === 0 ? " " : selectedColumns.join(","),
value: columns,
}),
),
);
dispatch(
analyticsActions.track({
name: "Columns Selected change",
page: "Jobs",
value: columns,
}),
);
},
refreshJobs: (req: JobsRequest) => dispatch(jobsActions.refresh(req)),
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export const SessionsPageConnected = withRouter(
analyticsActions.track({
name: "Filter Clicked",
page: "Sessions",
filterName: "app",
filterName: "filters",
value: value.toString(),
}),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ const mapDispatchToProps = (
ts: ts,
}),
);
dispatch(
analyticsActions.track({
name: "TimeScale changed",
page: "Statement Details",
value: ts.key,
}),
);
},
dismissStatementDiagnosticsAlertMessage: () =>
dispatch(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ export const ConnectedStatementsPage = withRouter(
analyticsActions.track({
name: "Filter Clicked",
page: "Statements",
filterName: "app",
filterName: "filters",
value: value.toString(),
}),
);
Expand Down
Loading

0 comments on commit ecaab51

Please sign in to comment.