Skip to content

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

UXW-2404 Remove toggle to disable anonymous analytics on cloud (#66469)

Gabriel Morenof6a25e57ceb1
diff --git a/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.tsx b/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.tsx
index db29109c892..b721e11d931 100644
--- a/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.tsx
+++ b/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.tsx
@@ -6,7 +6,7 @@ import {
} from "metabase/admin/components/SettingsSection";
import { UpsellDevInstances } from "metabase/admin/upsells";
import ExternalLink from "metabase/common/components/ExternalLink";
-import { useDocsUrl } from "metabase/common/hooks";
+import { useDocsUrl, useHasTokenFeature } from "metabase/common/hooks";
import { PLUGIN_LANDING_PAGE, PLUGIN_SEMANTIC_SEARCH } from "metabase/plugins";
import { DevInstanceBanner } from "../GeneralSettings/DevInstanceBanner";
@@ -20,6 +20,8 @@ export function GeneralSettingsPage() {
const { url: iframeDocsUrl } = useDocsUrl("configuring-metabase/settings", {
anchor: "allowed-domains-for-iframes-in-dashboards",
});
+ const hasHostingFeature = useHasTokenFeature("hosting");
+ const enableAnonymousTracking = !hasHostingFeature;
return (
<SettingsPageWrapper title={t`General`}>
@@ -43,14 +45,16 @@ export function GeneralSettingsPage() {
<PLUGIN_LANDING_PAGE.LandingPageWidget />
</SettingsSection>
- <SettingsSection title={t`Email and tracking`}>
+ <SettingsSection
+ title={enableAnonymousTracking ? t`Email and tracking` : t`Email`}
+ >
<AdminSettingInput
name="admin-email"
title={t`Email address for help requests`}
inputType="text"
/>
- <AnonymousTrackingInput />
+ {enableAnonymousTracking && <AnonymousTrackingInput />}
</SettingsSection>
<SettingsSection title={t`Tables, X-Rays and domains`}>
diff --git a/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.unit.spec.tsx
index 6e3f25c69af..b7a12c6a53d 100644
--- a/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.unit.spec.tsx
@@ -16,6 +16,7 @@ import {
createMockDashboard,
createMockSettingDefinition,
createMockSettings,
+ createMockTokenFeatures,
} from "metabase-types/api/mocks";
import { GeneralSettingsPage } from "./GeneralSettingsPage";
@@ -35,8 +36,15 @@ const generalSettings = {
"search-engine": "appdb",
} as const;
-const setup = async () => {
- const settings = createMockSettings(generalSettings);
+const setup = async (
+ { isCloudPlan }: { isCloudPlan: boolean } = { isCloudPlan: false },
+) => {
+ const settings = createMockSettings({
+ ...generalSettings,
+ "token-features": createMockTokenFeatures({
+ hosting: isCloudPlan,
+ }),
+ });
fetchMock.get("https://mysite.biz/api/health", { status: 200 });
@@ -69,7 +77,7 @@ const setup = async () => {
</>,
);
- await screen.findByText("Redirect to HTTPS");
+ await screen.findByText("Site name");
};
describe("GeneralSettingsPage", () => {
@@ -155,4 +163,16 @@ describe("GeneralSettingsPage", () => {
expect(toasts).toHaveLength(2);
});
});
+
+ it("should show Anonymous Tracking input for non-cloud plans", async () => {
+ await setup({ isCloudPlan: false });
+
+ expect(screen.getByText("Anonymous tracking")).toBeInTheDocument();
+ });
+
+ it("should not show Anonymous Tracking input if the plan is cloud", async () => {
+ await setup({ isCloudPlan: true });
+
+ expect(screen.queryByText("Anonymous tracking")).not.toBeInTheDocument();
+ });
});