Skip to content

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

Improve Instance Analytics Upsell (#73933)

Benoit Vinayf7a0f6919055
diff --git a/.loki/reference/chrome_laptop_Patterns_Upsells_Card_Large_Full_Width_Variant.png b/.loki/reference/chrome_laptop_Patterns_Upsells_Card_Large_Full_Width_Variant.png
index 4e197d5bc0e..3daab9ed779 100644
Binary files a/.loki/reference/chrome_laptop_Patterns_Upsells_Card_Large_Full_Width_Variant.png and b/.loki/reference/chrome_laptop_Patterns_Upsells_Card_Large_Full_Width_Variant.png differ
diff --git a/.loki/reference/chrome_laptop_Patterns_Upsells_Card_Large_Variant.png b/.loki/reference/chrome_laptop_Patterns_Upsells_Card_Large_Variant.png
index 20aa75de3b7..122c09ee745 100644
Binary files a/.loki/reference/chrome_laptop_Patterns_Upsells_Card_Large_Variant.png and b/.loki/reference/chrome_laptop_Patterns_Upsells_Card_Large_Variant.png differ
diff --git a/frontend/src/metabase/common/components/Sidesheet/components/InsightsTab/InsightsTab.tsx b/frontend/src/metabase/common/components/Sidesheet/components/InsightsTab/InsightsTab.tsx
index 301fc9cb002..7f713ed467a 100644
--- a/frontend/src/metabase/common/components/Sidesheet/components/InsightsTab/InsightsTab.tsx
+++ b/frontend/src/metabase/common/components/Sidesheet/components/InsightsTab/InsightsTab.tsx
@@ -1,11 +1,22 @@
import { t } from "ttag";
+import { UpsellGem } from "metabase/common/components/upsells/components/UpsellGem";
import { UpsellWrapper } from "metabase/common/components/upsells/components/UpsellWrapper";
-import { Tabs } from "metabase/ui";
+import { useHasTokenFeature } from "metabase/common/hooks";
+import { Flex, Tabs } from "metabase/ui";
/** This tab just shows the Insights upsell */
-const _InsightsTab = () => {
- return <Tabs.Tab value="insights">{t`Insights`}</Tabs.Tab>;
+const InsightsTabComponent = () => {
+ const shouldShowGem = !useHasTokenFeature("audit_app");
+
+ return (
+ <Tabs.Tab value="insights">
+ <Flex align="center" gap="xs">
+ {t`Insights`}
+ {shouldShowGem && <UpsellGem size={14} />}
+ </Flex>
+ </Tabs.Tab>
+ );
};
-export const InsightsTab = UpsellWrapper(_InsightsTab);
+export const InsightsTab = UpsellWrapper(InsightsTabComponent);
diff --git a/frontend/src/metabase/common/components/Sidesheet/components/InsightsTabOrLink/tests/common.unit.spec.tsx b/frontend/src/metabase/common/components/Sidesheet/components/InsightsTabOrLink/tests/common.unit.spec.tsx
index 2efd7929910..d69d87b1ca1 100644
--- a/frontend/src/metabase/common/components/Sidesheet/components/InsightsTabOrLink/tests/common.unit.spec.tsx
+++ b/frontend/src/metabase/common/components/Sidesheet/components/InsightsTabOrLink/tests/common.unit.spec.tsx
@@ -9,6 +9,7 @@ describe("InsightsTabOrLink (OSS)", () => {
});
const tab = await screen.findByRole("tab");
expect(tab).toBeInTheDocument();
+ expect(screen.getByTestId("upsell-gem")).toBeInTheDocument();
expect(screen.queryByRole("link")).not.toBeInTheDocument();
});
diff --git a/frontend/src/metabase/common/components/Sidesheet/components/InsightsTabOrLink/tests/premium.unit.spec.tsx b/frontend/src/metabase/common/components/Sidesheet/components/InsightsTabOrLink/tests/premium.unit.spec.tsx
index 6c1f0d093db..df0bf3025f5 100644
--- a/frontend/src/metabase/common/components/Sidesheet/components/InsightsTabOrLink/tests/premium.unit.spec.tsx
+++ b/frontend/src/metabase/common/components/Sidesheet/components/InsightsTabOrLink/tests/premium.unit.spec.tsx
@@ -19,6 +19,7 @@ describe("InsightsTabOrLink (EE with token)", () => {
isUserAdmin: true,
});
expect(screen.queryByRole("tab")).not.toBeInTheDocument();
+ expect(screen.queryByTestId("upsell-gem")).not.toBeInTheDocument();
const routerLink = await screen.findByText("Insights");
await userEvent.click(routerLink);
expect(history?.getCurrentLocation().pathname).toBe("/dashboard/201");
@@ -36,6 +37,7 @@ describe("InsightsTabOrLink (EE with token)", () => {
isUserAdmin: true,
});
expect(screen.queryByRole("tab")).not.toBeInTheDocument();
+ expect(screen.queryByTestId("upsell-gem")).not.toBeInTheDocument();
const routerLink = await screen.findByText("Insights");
await userEvent.click(routerLink);
expect(history?.getCurrentLocation().pathname).toBe("/dashboard/202");
diff --git a/frontend/src/metabase/common/components/upsells/UpsellCard.module.css b/frontend/src/metabase/common/components/upsells/UpsellCard.module.css
index 8b8384d3f08..9b16bec22dc 100644
--- a/frontend/src/metabase/common/components/upsells/UpsellCard.module.css
+++ b/frontend/src/metabase/common/components/upsells/UpsellCard.module.css
@@ -6,6 +6,10 @@
border: 1px solid var(--mb-color-upsell-secondary);
background-color: var(--mb-color-background-primary);
+ .MainStack {
+ padding-bottom: 1.5rem;
+ }
+
&.Large {
.MainStack {
padding-top: 2rem;
diff --git a/frontend/src/metabase/common/components/upsells/UpsellCard.tsx b/frontend/src/metabase/common/components/upsells/UpsellCard.tsx
index fb095842614..f96b7395284 100644
--- a/frontend/src/metabase/common/components/upsells/UpsellCard.tsx
+++ b/frontend/src/metabase/common/components/upsells/UpsellCard.tsx
@@ -111,7 +111,7 @@ export const UpsellCardInner: React.FC<UpsellCardProps> = ({
<Text lh="1rem" px="1rem">
{children}
</Text>
- <Box mx="md" mb="lg">
+ <Box mx="md">
<UpsellCta
style={buttonStyle}
onClick={handleClick}
diff --git a/frontend/src/metabase/common/components/upsells/UpsellUsageAnalytics.tsx b/frontend/src/metabase/common/components/upsells/UpsellUsageAnalytics.tsx
index ff6d0252168..8f24c405652 100644
--- a/frontend/src/metabase/common/components/upsells/UpsellUsageAnalytics.tsx
+++ b/frontend/src/metabase/common/components/upsells/UpsellUsageAnalytics.tsx
@@ -42,13 +42,16 @@ export const UpsellUsageAnalytics = (
lh="1.5rem"
onClick={triggerUpsellFlow}
buttonStyle={{
- marginInlineStart: "2rem",
+ marginInlineStart: "var(--mantine-spacing-xl)",
width: "10rem",
maxWidth: "100%",
}}
{...props}
>
- <Text lh="1.5rem" style={{ paddingInlineStart: "2rem" }}>
+ <Text
+ lh="1.5rem"
+ styles={{ root: { paddingInlineStart: "var(--mantine-spacing-xl)" } }}
+ >
{/* eslint-disable-next-line metabase/no-literal-metabase-strings -- Upsell for Metabase Pro, only visible to admins */}
{t`Get detailed reports for tracking Metabase content usage, performance, and configuration changes.`}{" "}
<ExternalLink href={usageAnalyticsUrl}>{t`Learn more`}</ExternalLink>
diff --git a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/common.unit.spec.tsx b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/common.unit.spec.tsx
index c395e35ab7b..6bf39d2f8a1 100644
--- a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/common.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/common.unit.spec.tsx
@@ -10,6 +10,8 @@ import {
createMockCard,
createMockCollection,
createMockModerationReview,
+ createMockSettings,
+ createMockTokenFeatures,
createMockUserInfo,
} from "metabase-types/api/mocks";
import { ORDERS_ID, PRODUCTS_ID } from "metabase-types/api/mocks/presets";
@@ -75,7 +77,14 @@ describe("QuestionInfoSidebar", () => {
describe("for admins", () => {
it("should show tabs for Overview, Relationships, History, and Insights", async () => {
- setup({ user: { is_superuser: true } });
+ setup({
+ user: { is_superuser: true },
+ settings: createMockSettings({
+ "token-features": createMockTokenFeatures({
+ audit_app: false,
+ }),
+ }),
+ });
const tabs = await screen.findAllByRole("tab");
expect(tabs).toHaveLength(4);
expect(tabs.map((tab) => tab.textContent)).toEqual([
@@ -84,9 +93,8 @@ describe("QuestionInfoSidebar", () => {
"Relationships",
"Insights",
]);
- const insightsTab = await screen.findByRole("tab", {
- name: "Insights",
- });
+
+ const insightsTab = screen.getByText("Insights");
await userEvent.click(insightsTab);
expect(
await screen.findByText(/See who.s doing what, when/),
diff --git a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/enterprise.unit.spec.tsx b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/enterprise.unit.spec.tsx
index 99bf86d9fbd..1cdc5771513 100644
--- a/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/enterprise.unit.spec.tsx
+++ b/frontend/src/metabase/query_builder/components/view/sidebars/QuestionInfoSidebar/tests/enterprise.unit.spec.tsx
@@ -5,6 +5,8 @@ import type { Card } from "metabase-types/api";
import {
createMockCard,
createMockModerationReview,
+ createMockSettings,
+ createMockTokenFeatures,
} from "metabase-types/api/mocks";
import type { SetupOpts } from "./setup";
@@ -57,7 +59,14 @@ describe("QuestionInfoSidebar > enterprise", () => {
describe("for admins", () => {
it("should show tabs for Overview, History, Relationships, and Insights", async () => {
- setup({ user: { is_superuser: true } });
+ setup({
+ user: { is_superuser: true },
+ settings: createMockSettings({
+ "token-features": createMockTokenFeatures({
+ audit_app: false,
+ }),
+ }),
+ });
const tabs = await screen.findAllByRole("tab");
expect(tabs).toHaveLength(4);
expect(tabs.map((tab) => tab.textContent)).toEqual([
@@ -66,9 +75,8 @@ describe("QuestionInfoSidebar > enterprise", () => {
"Relationships",
"Insights",
]);
- const insightsTab = await screen.findByRole("tab", {
- name: "Insights",
- });
+
+ const insightsTab = screen.getByText("Insights");
await userEvent.click(insightsTab);
expect(
await screen.findByText(/See who.s doing what, when/),