Skip to content

The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:

Track table freeze rows and columns enablement events (#73436)

Oleh K2f99f97d14e6
diff --git a/e2e/test/scenarios/visualizations-tabular/table.cy.spec.js b/e2e/test/scenarios/visualizations-tabular/table.cy.spec.js
index 85da6e7a81e..06c5e0a878d 100644
--- a/e2e/test/scenarios/visualizations-tabular/table.cy.spec.js
+++ b/e2e/test/scenarios/visualizations-tabular/table.cy.spec.js
@@ -1176,6 +1176,55 @@ describe("scenarios > visualizations > table > conditional formatting", () => {
});
});
+describe("scenarios > visualizations > table > with tracking", () => {
+ beforeEach(() => {
+ H.restore();
+ cy.signInAsAdmin();
+ H.resetSnowplow();
+ H.enableTracking();
+ });
+
+ afterEach(() => {
+ H.expectNoBadSnowplowEvents();
+ });
+
+ it("should track when freeze columns is enabled from viz settings", () => {
+ H.openOrdersTable();
+ H.openVizSettingsSidebar();
+ H.sidebar().findByText("Display").click();
+
+ H.sidebar().findByText("Freeze columns").click();
+
+ // Toggling off should not emit the enabled event again
+ H.sidebar().findByText("Freeze columns").click();
+ H.expectUnstructuredSnowplowEvent(
+ {
+ event: "table_freeze_columns_enabled",
+ triggered_from: "viz_settings",
+ },
+ 1,
+ );
+ });
+
+ it("should track when freeze rows is enabled from viz settings", () => {
+ H.openOrdersTable();
+ H.openVizSettingsSidebar();
+ H.sidebar().findByText("Display").click();
+
+ H.sidebar().findByText("Freeze rows").click();
+
+ // Toggling off should not emit the enabled event again
+ H.sidebar().findByText("Freeze rows").click();
+ H.expectUnstructuredSnowplowEvent(
+ {
+ event: "table_freeze_rows_enabled",
+ triggered_from: "viz_settings",
+ },
+ 1,
+ );
+ });
+});
+
describe("scenarios > visualizations > table > time formatting (#11398)", () => {
const singleTimeQuery = `
WITH t1 AS (SELECT TIMESTAMP '2023-01-01 18:34:00' AS time_value),
diff --git a/frontend/src/metabase/visualizations/analytics.ts b/frontend/src/metabase/visualizations/analytics.ts
index 1afe49c374c..1438258b27c 100644
--- a/frontend/src/metabase/visualizations/analytics.ts
+++ b/frontend/src/metabase/visualizations/analytics.ts
@@ -29,3 +29,17 @@ export const trackStackedSeriesEnabled = () => {
triggered_from: "viz_settings",
});
};
+
+export const trackTableFreezeColumnsEnabled = () => {
+ trackSimpleEvent({
+ event: "table_freeze_columns_enabled",
+ triggered_from: "viz_settings",
+ });
+};
+
+export const trackTableFreezeRowsEnabled = () => {
+ trackSimpleEvent({
+ event: "table_freeze_rows_enabled",
+ triggered_from: "viz_settings",
+ });
+};
diff --git a/frontend/src/metabase/visualizations/visualizations/Table/Table.tsx b/frontend/src/metabase/visualizations/visualizations/Table/Table.tsx
index 34cb1b83ee4..1716593a3d9 100644
--- a/frontend/src/metabase/visualizations/visualizations/Table/Table.tsx
+++ b/frontend/src/metabase/visualizations/visualizations/Table/Table.tsx
@@ -8,6 +8,10 @@ import CS from "metabase/css/core/index.css";
import { getSubpathSafeUrl } from "metabase/urls";
import { displayNameForColumn } from "metabase/utils/formatting";
import type { OptionsType } from "metabase/utils/formatting/types";
+import {
+ trackTableFreezeColumnsEnabled,
+ trackTableFreezeRowsEnabled,
+} from "metabase/visualizations/analytics";
import ChartSettingLinkUrlInput from "metabase/visualizations/components/settings/ChartSettingLinkUrlInput";
import { ChartSettingNumberInput } from "metabase/visualizations/components/settings/ChartSettingNumberInput";
import {
@@ -129,6 +133,11 @@ export class Table extends Component<TableProps, TableState> {
getHidden: (series: Series, settings: ComputedVisualizationSettings) =>
_isPivoted(series, settings),
readDependencies: ["table.pivot"],
+ onUpdate: (value: boolean) => {
+ if (value) {
+ trackTableFreezeColumnsEnabled();
+ }
+ },
},
"table.freeze_columns_count": {
get section() {
@@ -159,6 +168,11 @@ export class Table extends Component<TableProps, TableState> {
getHidden: (series: Series, settings: ComputedVisualizationSettings) =>
_isPivoted(series, settings),
readDependencies: ["table.pivot"],
+ onUpdate: (value: boolean) => {
+ if (value) {
+ trackTableFreezeRowsEnabled();
+ }
+ },
},
"table.freeze_rows_count": {
get section() {