The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Add analytics to x-rays (#63498)
Nemanja Glumaca58c63a74f77
diff --git a/e2e/test/scenarios/admin/datamodel/segments.cy.spec.ts b/e2e/test/scenarios/admin/datamodel/segments.cy.spec.tsindex 8b721614fe3..f99512d68d2 100644--- a/e2e/test/scenarios/admin/datamodel/segments.cy.spec.ts+++ b/e2e/test/scenarios/admin/datamodel/segments.cy.spec.ts@@ -278,4 +278,59 @@ describe("scenarios > admin > datamodel > segments", () => {}});});++ H.describeWithSnowplow("x-ray", () => {+ afterEach(() => {+ H.expectNoBadSnowplowEvents();+ });++ it("should track x-raying a segment", () => {+ cy.intercept("GET", "/api/automagic-dashboards/**").as(+ "getXrayDashboard",+ );++ H.resetSnowplow();+ H.restore();+ cy.signInAsAdmin();+ H.enableTracking();++ H.createSegment({+ name: "Foo",+ description: "All orders with a total under $100.",+ table_id: ORDERS_ID,+ definition: {+ "source-table": ORDERS_ID,+ aggregation: [["count"]],+ filter: ["<", ["field", ORDERS.TOTAL, null], 100],+ },+ }).then(({ body: { id } }) => {+ cy.visit(`/reference/segments/${id}`);+ cy.findAllByRole("listitem")+ .filter(":contains(X-ray this segment)")+ .click();+ cy.wait("@getXrayDashboard");+ });++ H.expectUnstructuredSnowplowEvent({+ event: "x-ray_clicked",+ event_detail: "segment",+ triggered_from: "data_reference",+ });++ cy.findByRole("complementary").within(() => {+ cy.findByRole("heading", { name: "More X-rays" }).should("be.visible");+ cy.findByRole("heading", { name: "Compare" })+ .parent()+ .findByText("Compare with entire dataset")+ .click();+ cy.wait("@getXrayDashboard");+ });++ H.expectUnstructuredSnowplowEvent({+ event: "x-ray_clicked",+ event_detail: "compare",+ triggered_from: "suggestion_sidebar",+ });+ });+ });});diff --git a/e2e/test/scenarios/onboarding/home/browse.cy.spec.ts b/e2e/test/scenarios/onboarding/home/browse.cy.spec.tsindex a82675e041c..ff0ba2ea2d1 100644--- a/e2e/test/scenarios/onboarding/home/browse.cy.spec.ts+++ b/e2e/test/scenarios/onboarding/home/browse.cy.spec.ts@@ -102,6 +102,25 @@ H.describeWithSnowplow("scenarios > browse", () => {});});+ it("can generate x-ray dashboard from a browse page", () => {+ cy.visit(`/browse/databases/${SAMPLE_DB_ID}`);++ cy.findByTestId("browse-schemas").within(() => {+ cy.findAllByRole("link")+ .filter(":contains(People)")+ .should("be.visible")+ .realHover();+ cy.findAllByLabelText("X-ray this table").filter(":visible").click();+ });++ H.expectNoBadSnowplowEvents();+ H.expectUnstructuredSnowplowEvent({+ event: "x-ray_clicked",+ event_detail: "table",+ triggered_from: "browse_database",+ });+ });+it("tracks when a new model creation is initiated", () => {cy.visit("/browse/models");cy.findByTestId("browse-models-header")diff --git a/e2e/test/scenarios/onboarding/home/homepage.cy.spec.js b/e2e/test/scenarios/onboarding/home/homepage.cy.spec.jsindex 3380aa76d56..f62895fa22b 100644--- a/e2e/test/scenarios/onboarding/home/homepage.cy.spec.js+++ b/e2e/test/scenarios/onboarding/home/homepage.cy.spec.js@@ -19,28 +19,90 @@ describe("scenarios > home > homepage", () => {cy.intercept("POST", "/api/card/*/query").as("getQuestionQuery");});- describe("after setup", () => {- beforeEach(() => {- H.restore("setup");+ H.describeWithSnowplow("after setup", () => {+ afterEach(() => {+ H.expectNoBadSnowplowEvents();});- it("should display x-rays for the sample database", () => {+ beforeEach(() => {+ H.resetSnowplow();+ H.restore("setup");cy.signInAsAdmin();+ H.enableTracking();+ });+ it("should display x-rays for the Sample Database", () => {cy.visit("/");cy.wait("@getXrayCandidates");- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage- cy.findByText("Try out these sample x-rays to see what Metabase can do.");- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage- cy.findByText("Orders").click();+ cy.findByTestId("home-page").within(() => {+ cy.findByText(+ "Try out these sample x-rays to see what Metabase can do.",+ );+ cy.findAllByRole("link").contains("Orders").click();+ cy.wait("@getXrayDashboard");+ });- cy.wait("@getXrayDashboard");- // eslint-disable-next-line no-unscoped-text-selectors -- deprecated usage- cy.findByText("More X-rays");+ H.expectUnstructuredSnowplowEvent({+ event: "x-ray_clicked",+ event_detail: "table",+ triggered_from: "homepage",+ });++ cy.findByRole("complementary").within(() => {+ cy.findByRole("heading", { name: "More X-rays" }).should("be.visible");+ cy.findByRole("heading", { name: "Zoom in" })+ .parent()+ .findByText("Source fields")+ .click();+ cy.wait("@getXrayDashboard");+ });++ H.expectUnstructuredSnowplowEvent({+ event: "x-ray_clicked",+ event_detail: "zoom-in",+ triggered_from: "suggestion_sidebar",+ });++ cy.findByRole("complementary").within(() => {+ cy.findByRole("heading", { name: "More X-rays" }).should("be.visible");+ cy.findByRole("heading", { name: "Zoom out" })+ .parent()+ .findByText("People")+ .click();+ cy.wait("@getXrayDashboard");+ });++ H.expectUnstructuredSnowplowEvent({+ event: "x-ray_clicked",+ event_detail: "zoom-out",+ triggered_from: "suggestion_sidebar",+ });++ cy.findByRole("complementary").within(() => {+ cy.findByRole("heading", { name: "More X-rays" }).should("be.visible");+ cy.findByRole("heading", { name: "Related" })+ .parent()+ .findByText("Orders")+ .click();+ cy.wait("@getXrayDashboard");+ });++ H.expectUnstructuredSnowplowEvent({+ event: "x-ray_clicked",+ event_detail: "related",+ triggered_from: "suggestion_sidebar",+ });++ cy.intercept("POST", "/api/dashboard/save").as("saveDashboard");+ cy.findByTestId("automatic-dashboard-header").button("Save this").click();+ cy.wait("@saveDashboard");++ H.expectUnstructuredSnowplowEvent({+ event: "x-ray_saved",+ });});it("should display x-rays for a user database", () => {- cy.signInAsAdmin();H.addSqliteDatabase();cy.get("@sqliteID").then((dbId) => {@@ -68,7 +130,6 @@ describe("scenarios > home > homepage", () => {});it("homepage should not flicker when syncing databases and showing xrays", () => {- cy.signInAsAdmin();cy.addSQLiteDatabase();cy.intercept("/api/database", (req) => {@@ -103,7 +164,6 @@ describe("scenarios > home > homepage", () => {});it("should allow switching between multiple schemas for x-rays", () => {- cy.signInAsAdmin();cy.addSQLiteDatabase({ name: "sqlite" });cy.intercept("/api/automagic-*/database/**", getXrayCandidates());diff --git a/e2e/test/scenarios/onboarding/reference/databases.cy.spec.js b/e2e/test/scenarios/onboarding/reference/databases.cy.spec.jsindex 93f220df478..bf2eaf0b977 100644--- a/e2e/test/scenarios/onboarding/reference/databases.cy.spec.js+++ b/e2e/test/scenarios/onboarding/reference/databases.cy.spec.js@@ -1,4 +1,8 @@const { H } = cy;+import { SAMPLE_DB_ID } from "e2e/support/cypress_data";+import { SAMPLE_DATABASE } from "e2e/support/cypress_sample_database";++const { PEOPLE, PEOPLE_ID } = SAMPLE_DATABASE;describe("scenarios > reference > databases", () => {beforeEach(() => {@@ -103,6 +107,52 @@ describe("scenarios > reference > databases", () => {},);});++ H.describeWithSnowplow("x-ray", () => {+ beforeEach(() => {+ cy.intercept("GET", "/api/automagic-dashboards/**").as(+ "getXrayDashboard",+ );+ H.resetSnowplow();+ H.restore();+ cy.signInAsAdmin();+ H.enableTracking();+ });++ afterEach(() => {+ H.expectNoBadSnowplowEvents();+ });++ it("should x-ray a table in a data reference page", () => {+ cy.visit(`/reference/databases/${SAMPLE_DB_ID}/tables/${PEOPLE_ID}`);+ cy.findAllByRole("listitem")+ .filter(":contains(X-ray this table)")+ .click();+ cy.wait("@getXrayDashboard");++ H.expectUnstructuredSnowplowEvent({+ event: "x-ray_clicked",+ event_detail: "table",+ triggered_from: "data_reference",+ });+ });++ it("should x-ray a field in a data reference page", () => {+ cy.visit(+ `/reference/databases/${SAMPLE_DB_ID}/tables/${PEOPLE_ID}/fields/${PEOPLE.EMAIL}`,+ );+ cy.findAllByRole("listitem")+ .filter(":contains(X-ray this field)")+ .click();+ cy.wait("@getXrayDashboard");++ H.expectUnstructuredSnowplowEvent({+ event: "x-ray_clicked",+ event_detail: "field",+ triggered_from: "data_reference",+ });+ });+ });});function checkReferenceDatabasesOrder() {diff --git a/frontend/src/metabase-types/analytics/event.ts b/frontend/src/metabase-types/analytics/event.tsindex 99f1a5504c1..bdd1faa2b23 100644--- a/frontend/src/metabase-types/analytics/event.ts+++ b/frontend/src/metabase-types/analytics/event.ts@@ -6,6 +6,7 @@ import type {import type { KeyboardShortcutId } from "metabase/palette/shortcuts";import type {Engine,+ RelatedDashboardXRays,TransformId,VisualizationDisplay,} from "metabase-types/api";@@ -342,6 +343,35 @@ export type DatabaseHelpClickedEvent = ValidateEvent<{triggered_from: "admin" | "setup";}>;+export type XRayTableClickedEvent = ValidateEvent<{+ event: "x-ray_clicked";+ event_detail: "table";+ triggered_from: "homepage" | "browse_database";+}>;++export type XRayDataReferenceClickedEvent = ValidateEvent<{+ event: "x-ray_clicked";+ event_detail: "table" | "field" | "segment";+ triggered_from: "data_reference";+}>;++export type XRaySuggestionClickedEvent = ValidateEvent<{+ event: "x-ray_clicked";+ event_detail: keyof RelatedDashboardXRays;+ triggered_from: "suggestion_sidebar";+}>;++export type XRayClickedEvent =+ | XRayTableClickedEvent+ | XRayDataReferenceClickedEvent+ | XRaySuggestionClickedEvent;++export type XRaySavedEvent = ValidateEvent<{+ event: "x-ray_saved";+}>;++export type XRayEvent = XRayClickedEvent | XRaySavedEvent;+export type EmbedWizardEvent =| EmbedWizardExperienceSelectedEvent| EmbedWizardResourceSelectedEvent@@ -398,4 +428,5 @@ export type SimpleEvent =| DocumentReplaceCardEvent| DocumentUpdatedEvent| DocumentPrintEvent- | DatabaseHelpClickedEvent;+ | DatabaseHelpClickedEvent+ | XRayEvent;diff --git a/frontend/src/metabase/browse/tables/TableBrowser/TableBrowser.jsx b/frontend/src/metabase/browse/tables/TableBrowser/TableBrowser.jsxindex edd155c24e9..729c2afa00b 100644--- a/frontend/src/metabase/browse/tables/TableBrowser/TableBrowser.jsx+++ b/frontend/src/metabase/browse/tables/TableBrowser/TableBrowser.jsx@@ -17,7 +17,7 @@ import { ActionIcon, Group, Icon, Loader, Paper } from "metabase/ui";import { isVirtualCardId } from "metabase-lib/v1/metadata/utils/saved-questions";import { BrowseHeaderContent } from "../../components/BrowseHeader.styled";-import { trackTableClick } from "../analytics";+import { trackBrowseXRayClicked, trackTableClick } from "../analytics";import S from "./TableBrowser.module.css";import { useDatabaseCrumb } from "./useDatabaseCrumb";@@ -157,6 +157,7 @@ const TableBrowserItemButtons = ({tooltip={t`X-ray this table`}color="warning"aria-label={t`X-ray this table`}+ onClick={trackBrowseXRayClicked}><Icon name="bolt" /></ActionIcon>diff --git a/frontend/src/metabase/browse/tables/analytics.ts b/frontend/src/metabase/browse/tables/analytics.tsindex 0e2fb444b7f..d6500af82e7 100644--- a/frontend/src/metabase/browse/tables/analytics.ts+++ b/frontend/src/metabase/browse/tables/analytics.ts@@ -1,4 +1,4 @@-import { trackSchemaEvent } from "metabase/lib/analytics";+import { trackSchemaEvent, trackSimpleEvent } from "metabase/lib/analytics";import type { ConcreteTableId } from "metabase-types/api";export const trackTableClick = (tableId: ConcreteTableId) =>@@ -6,3 +6,11 @@ export const trackTableClick = (tableId: ConcreteTableId) =>event: "browse_data_table_clicked",table_id: tableId,});++export const trackBrowseXRayClicked = () => {+ trackSimpleEvent({+ event: "x-ray_clicked",+ event_detail: "table",+ triggered_from: "browse_database",+ });+};diff --git a/frontend/src/metabase/common/components/SidebarItem/SidebarItem.jsx b/frontend/src/metabase/common/components/SidebarItem/SidebarItem.jsxdeleted file mode 100644index 96b8dd108ce..00000000000--- a/frontend/src/metabase/common/components/SidebarItem/SidebarItem.jsx+++ /dev/null@@ -1,25 +0,0 @@-/* eslint "react/prop-types": "warn" */-import PropTypes from "prop-types";-import { memo } from "react";-import { Link } from "react-router";--import LabelIcon from "../LabelIcon";-import S from "../Sidebar.module.css";--const SidebarItem = ({ name, sidebar, icon, href }) => (- <li>- <Link to={href} className={S.item} activeClassName={S.selected}>- <LabelIcon className={S.icon} icon={icon} />- <span className={S.name}>{sidebar || name}</span>- </Link>- </li>-);--SidebarItem.propTypes = {- name: PropTypes.string.isRequired,- sidebar: PropTypes.string,- icon: PropTypes.string.isRequired,- href: PropTypes.string.isRequired,-};--export default memo(SidebarItem);diff --git a/frontend/src/metabase/common/components/SidebarItem/SidebarItem.tsx b/frontend/src/metabase/common/components/SidebarItem/SidebarItem.tsxnew file mode 100644index 00000000000..430368ddbb7--- /dev/null+++ b/frontend/src/metabase/common/components/SidebarItem/SidebarItem.tsx@@ -0,0 +1,36 @@+import { memo } from "react";+import { Link } from "react-router";++import LabelIcon from "../LabelIcon";+import S from "../Sidebar.module.css";++type SidebarItemProps = {+ name: string;+ sidebar?: string;+ icon: string;+ href: string;+ onClick?: () => void;+};++const SidebarItem = ({+ name,+ sidebar,+ icon,+ href,+ onClick,+}: SidebarItemProps) => (+ <li>+ <Link+ to={href}+ className={S.item}+ activeClassName={S.selected}+ onClick={onClick}+ >+ <LabelIcon className={S.icon} icon={icon} />+ <span className={S.name}>{sidebar || name}</span>+ </Link>+ </li>+);++// eslint-disable-next-line import/no-default-export+export default memo(SidebarItem);diff --git a/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/AutomaticDashboardApp.tsx b/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/AutomaticDashboardApp.tsxindex 33b1de78b99..346ebb90598 100644--- a/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/AutomaticDashboardApp.tsx+++ b/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/AutomaticDashboardApp.tsx@@ -30,6 +30,7 @@ import { XrayIcon } from "../XrayIcon";import S from "./AutomaticDashboardApp.module.css";import { SuggestionsSidebar } from "./SuggestionsSidebar";+import { trackXRaySaved } from "./analytics";const SIDEBAR_W = 346;@@ -132,7 +133,10 @@ const AutomaticDashboardAppInner = () => {className={cx(CS.mlAuto, CS.textNoWrap)}successborderless- actionFn={save}+ actionFn={() => {+ trackXRaySaved();+ return save();+ }}>{t`Save this`}</ActionButton>diff --git a/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/SuggestionsSidebar.tsx b/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/SuggestionsSidebar.tsxindex 37fc620ec74..d9fc48d4931 100644--- a/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/SuggestionsSidebar.tsx+++ b/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/SuggestionsSidebar.tsx@@ -11,6 +11,7 @@ import { Box, Flex, Icon, type IconName, Title, Tooltip } from "metabase/ui";import type { RelatedDashboardXRays } from "metabase-types/api";import S from "./AutomaticDashboardApp.module.css";+import { trackSuggestedXRayClicked } from "./analytics";const RELATED_CONTENT: Record<keyof RelatedDashboardXRays,@@ -64,6 +65,7 @@ const SuggestionsList = ({key={itemIndex}to={item.url}className={cx(CS.hoverParent, CS.hoverVisibility, S.ItemLink)}+ onClick={() => trackSuggestedXRayClicked(suggestionKey)}><Card className={CS.p2} hoverable><Flex align="center">@@ -106,7 +108,7 @@ export const SuggestionsSidebar = ({}: {related: RelatedDashboardXRays;}) => (- <Flex direction="column" py="md" px="xl">+ <Flex direction="column" py="md" px="xl" role="complementary"><Title py="sm" px={0} order={2}>{t`More X-rays`}</Title><SuggestionsList suggestions={related} /></Flex>diff --git a/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/analytics.ts b/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/analytics.tsnew file mode 100644index 00000000000..566ffb92ee1--- /dev/null+++ b/frontend/src/metabase/dashboard/containers/AutomaticDashboardApp/analytics.ts@@ -0,0 +1,18 @@+import { trackSimpleEvent } from "metabase/lib/analytics";+import type { RelatedDashboardXRays } from "metabase-types/api";++export const trackSuggestedXRayClicked = (+ action: keyof RelatedDashboardXRays,+) => {+ trackSimpleEvent({+ event: "x-ray_clicked",+ event_detail: action,+ triggered_from: "suggestion_sidebar",+ });+};++export const trackXRaySaved = () => {+ trackSimpleEvent({+ event: "x-ray_saved",+ });+};diff --git a/frontend/src/metabase/home/components/HomeCard/HomeCard.tsx b/frontend/src/metabase/home/components/HomeCard/HomeCard.tsxindex 757623f5ba6..530da2eff18 100644--- a/frontend/src/metabase/home/components/HomeCard/HomeCard.tsx+++ b/frontend/src/metabase/home/components/HomeCard/HomeCard.tsx@@ -7,15 +7,17 @@ interface HomeCardProps {url?: string;external?: boolean;children?: ReactNode;+ onClick?: () => void;}export const HomeCard = ({className,url = "",children,+ onClick,}: HomeCardProps): JSX.Element => {return (- <CardRoot className={className} to={url}>+ <CardRoot className={className} to={url} onClick={onClick}>{children}</CardRoot>);diff --git a/frontend/src/metabase/home/components/HomeXrayCard/HomeXrayCard.tsx b/frontend/src/metabase/home/components/HomeXrayCard/HomeXrayCard.tsxindex 6bde515ae4a..994fce4515e 100644--- a/frontend/src/metabase/home/components/HomeXrayCard/HomeXrayCard.tsx+++ b/frontend/src/metabase/home/components/HomeXrayCard/HomeXrayCard.tsx@@ -6,6 +6,7 @@ import {CardTitlePrimary,CardTitleSecondary,} from "./HomeXrayCard.styled";+import { trackHomeXRayClicked } from "./analytics";interface HomeXrayCardProps {title: string;@@ -19,7 +20,7 @@ export const HomeXrayCard = ({message,}: HomeXrayCardProps): JSX.Element => {return (- <HomeCard url={url}>+ <HomeCard url={url} onClick={trackHomeXRayClicked}><CardIcon name="bolt_filled" /><CardTitle><CardTitleSecondary>{message}</CardTitleSecondary>{" "}diff --git a/frontend/src/metabase/home/components/HomeXrayCard/analytics.ts b/frontend/src/metabase/home/components/HomeXrayCard/analytics.tsnew file mode 100644index 00000000000..ad58e933c65--- /dev/null+++ b/frontend/src/metabase/home/components/HomeXrayCard/analytics.ts@@ -0,0 +1,9 @@+import { trackSimpleEvent } from "metabase/lib/analytics";++export const trackHomeXRayClicked = () => {+ trackSimpleEvent({+ event: "x-ray_clicked",+ event_detail: "table",+ triggered_from: "homepage",+ });+};diff --git a/frontend/src/metabase/reference/analytics.ts b/frontend/src/metabase/reference/analytics.tsnew file mode 100644index 00000000000..a3769d14b37--- /dev/null+++ b/frontend/src/metabase/reference/analytics.ts@@ -0,0 +1,11 @@+import { trackSimpleEvent } from "metabase/lib/analytics";++export const trackReferenceXRayClicked = (+ source: "table" | "field" | "segment",+) => {+ trackSimpleEvent({+ event: "x-ray_clicked",+ event_detail: source,+ triggered_from: "data_reference",+ });+};diff --git a/frontend/src/metabase/reference/databases/FieldSidebar.jsx b/frontend/src/metabase/reference/databases/FieldSidebar.jsxindex f900a716627..ed2ebe5b005 100644--- a/frontend/src/metabase/reference/databases/FieldSidebar.jsx+++ b/frontend/src/metabase/reference/databases/FieldSidebar.jsx@@ -10,6 +10,8 @@ import SidebarItem from "metabase/common/components/SidebarItem";import CS from "metabase/css/core/index.css";import MetabaseSettings from "metabase/lib/settings";+import { trackReferenceXRayClicked } from "../analytics";+const FieldSidebar = ({ database, table, field, style, className }) => (<div className={cx(S.sidebar, className)} style={style}><ul>@@ -42,6 +44,7 @@ const FieldSidebar = ({ database, table, field, style, className }) => (href={`/auto/dashboard/field/${field.id}`}icon="bolt"name={t`X-ray this field`}+ onClick={() => trackReferenceXRayClicked("field")}/>)}</ol>diff --git a/frontend/src/metabase/reference/databases/TableSidebar.jsx b/frontend/src/metabase/reference/databases/TableSidebar.jsxindex 6d359307141..dc5099fcdcd 100644--- a/frontend/src/metabase/reference/databases/TableSidebar.jsx+++ b/frontend/src/metabase/reference/databases/TableSidebar.jsx@@ -10,6 +10,8 @@ import SidebarItem from "metabase/common/components/SidebarItem";import CS from "metabase/css/core/index.css";import MetabaseSettings from "metabase/lib/settings";+import { trackReferenceXRayClicked } from "../analytics";+const TableSidebar = ({ database, table, style, className }) => (<div className={cx(S.sidebar, className)} style={style}><div>@@ -49,6 +51,7 @@ const TableSidebar = ({ database, table, style, className }) => (href={`/auto/dashboard/table/${table.id}`}icon="bolt"name={t`X-ray this table`}+ onClick={() => trackReferenceXRayClicked("table")}/>)}</ol>diff --git a/frontend/src/metabase/reference/segments/SegmentSidebar.jsx b/frontend/src/metabase/reference/segments/SegmentSidebar.jsxindex 99228e5984f..aae4be6e991 100644--- a/frontend/src/metabase/reference/segments/SegmentSidebar.jsx+++ b/frontend/src/metabase/reference/segments/SegmentSidebar.jsx@@ -10,6 +10,8 @@ import SidebarItem from "metabase/common/components/SidebarItem";import CS from "metabase/css/core/index.css";import MetabaseSettings from "metabase/lib/settings";+import { trackReferenceXRayClicked } from "../analytics";+const SegmentSidebar = ({ segment, user, style, className }) => (<div className={cx(S.sidebar, className)} style={style}><ul>@@ -46,6 +48,7 @@ const SegmentSidebar = ({ segment, user, style, className }) => (href={`/auto/dashboard/segment/${segment.id}`}icon="bolt"name={t`X-ray this segment`}+ onClick={() => trackReferenceXRayClicked("segment")}/>)}{user && user.is_superuser && (