Skip to content

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

Remove the embedding homepage feedback form (#83930)

Nicolò Prettoe8f64d922153
diff --git a/frontend/src/metabase/home/api/product-feedback.ts b/frontend/src/metabase/home/api/product-feedback.ts
deleted file mode 100644
index bc96e349c6b..00000000000
--- a/frontend/src/metabase/home/api/product-feedback.ts
+++ /dev/null
@@ -1,24 +0,0 @@
-import { Api } from "metabase/api";
-
-const productFeedbackApi = Api.injectEndpoints({
- endpoints: (builder) => ({
- sendProductFeedback: builder.mutation<
- void,
- { comment?: string; email?: string; source: string }
- >({
- query: ({ comment, email, source }) => ({
- method: "POST",
- url: `/api/product-feedback`,
- body: {
- // harbormaster expects the field `comments`, we use `comment` because it
- // reflects better what it's shown in the UI
- comments: comment,
- email,
- source,
- },
- }),
- }),
- }),
-});
-
-export const { useSendProductFeedbackMutation } = productFeedbackApi;
diff --git a/frontend/src/metabase/home/components/EmbedHomepage/EmbedHomepage.tsx b/frontend/src/metabase/home/components/EmbedHomepage/EmbedHomepage.tsx
index 233797f4ed2..ce0a5f17274 100644
--- a/frontend/src/metabase/home/components/EmbedHomepage/EmbedHomepage.tsx
+++ b/frontend/src/metabase/home/components/EmbedHomepage/EmbedHomepage.tsx
@@ -1,25 +1,16 @@
-import { useState } from "react";
-import { t } from "ttag";
-
import { useHasTokenFeature } from "metabase/common/hooks";
import { PLUGIN_IS_EE_BUILD } from "metabase/plugins";
import { useDispatch, useSelector } from "metabase/redux";
-import { addUndo } from "metabase/redux/undo";
import { getDocsUrl } from "metabase/selectors/settings";
import { getPlan, getSetting, useSetting } from "metabase/settings";
import type { EmbeddingHomepageDismissReason } from "metabase-types/api";
-import { useSendProductFeedbackMutation } from "../../api/product-feedback";
-
import { EmbedHomepageView } from "./EmbedHomepageView";
-import { FeedbackModal } from "./FeedbackModal";
import { dismissEmbeddingHomepage } from "./actions";
export const EmbedHomepage = () => {
- const [feedbackModalOpened, setFeedbackModalOpened] = useState(false);
const dispatch = useDispatch();
const exampleDashboardId = useSetting("example-dashboard-id");
- const [sendProductFeedback] = useSendProductFeedbackMutation();
const hasEmbeddingFeature = useHasTokenFeature("embedding");
const embeddingDocsUrl = useSelector((state) =>
@@ -49,60 +40,27 @@ export const EmbedHomepage = () => {
const utmTags = `?utm_source=product&source_plan=${plan}&utm_content=embedding-homepage`;
const onDismiss = (reason: EmbeddingHomepageDismissReason) => {
- if (reason === "dismissed-run-into-issues") {
- setFeedbackModalOpened(true);
- } else {
- dispatch(dismissEmbeddingHomepage(reason));
- }
- };
-
- const onFeedbackSubmit = ({
- comment,
- email,
- }: {
- comment?: string;
- email?: string;
- }) => {
- dispatch(dismissEmbeddingHomepage("dismissed-run-into-issues"));
-
- setFeedbackModalOpened(false);
- if (comment || email) {
- sendProductFeedback({
- comment,
- email: email,
- source: "embedding-homepage-dismiss",
- });
- dispatch(
- addUndo({ message: t`Your feedback was submitted, thank you.` }),
- );
- }
+ dispatch(dismissEmbeddingHomepage(reason));
};
const variant = PLUGIN_IS_EE_BUILD.isEEBuild() ? "ee" : "oss";
return (
- <>
- <EmbedHomepageView
- onDismiss={onDismiss}
- exampleDashboardId={exampleDashboardId}
- embedJsDocsUrl={embedJsDocsUrl + utmTags}
- variant={variant}
- hasEmbeddingFeature={hasEmbeddingFeature}
- embeddingDocsUrl={embeddingDocsUrl + utmTags}
- analyticsDocsUrl={
- // eslint-disable-next-line metabase/no-unconditional-metabase-links-render -- only visible to admins
- "https://www.metabase.com/learn/customer-facing-analytics/" + utmTags
- }
- learnMoreInteractiveEmbedUrl={learnMoreInteractiveEmbedding + utmTags}
- learnMoreStaticEmbedUrl={learnMoreStaticEmbedding + utmTags}
- sdkQuickstartUrl={"https://metaba.se/sdk-quick-start" + utmTags}
- sdkDocsUrl={"https://metaba.se/sdk-docs" + utmTags}
- />
- <FeedbackModal
- opened={feedbackModalOpened}
- onClose={() => setFeedbackModalOpened(false)}
- onSubmit={onFeedbackSubmit}
- />
- </>
+ <EmbedHomepageView
+ onDismiss={onDismiss}
+ exampleDashboardId={exampleDashboardId}
+ embedJsDocsUrl={embedJsDocsUrl + utmTags}
+ variant={variant}
+ hasEmbeddingFeature={hasEmbeddingFeature}
+ embeddingDocsUrl={embeddingDocsUrl + utmTags}
+ analyticsDocsUrl={
+ // eslint-disable-next-line metabase/no-unconditional-metabase-links-render -- only visible to admins
+ "https://www.metabase.com/learn/customer-facing-analytics/" + utmTags
+ }
+ learnMoreInteractiveEmbedUrl={learnMoreInteractiveEmbedding + utmTags}
+ learnMoreStaticEmbedUrl={learnMoreStaticEmbedding + utmTags}
+ sdkQuickstartUrl={"https://metaba.se/sdk-quick-start" + utmTags}
+ sdkDocsUrl={"https://metaba.se/sdk-docs" + utmTags}
+ />
);
};
diff --git a/frontend/src/metabase/home/components/EmbedHomepage/FeedbackModal.tsx b/frontend/src/metabase/home/components/EmbedHomepage/FeedbackModal.tsx
deleted file mode 100644
index 503b457ddda..00000000000
--- a/frontend/src/metabase/home/components/EmbedHomepage/FeedbackModal.tsx
+++ /dev/null
@@ -1,75 +0,0 @@
-import { useState } from "react";
-import { t } from "ttag";
-
-import {
- Button,
- Group,
- Modal,
- Stack,
- Text,
- TextInput,
- Textarea,
- Title,
- rem,
-} from "metabase/ui";
-
-type FeedbackModalProps = {
- opened: boolean;
- onClose: () => void;
- onSubmit: (feedback: { comment?: string; email?: string }) => void;
-};
-
-export const FeedbackModal = ({
- opened,
- onClose,
- onSubmit,
-}: FeedbackModalProps) => {
- const [comment, setComment] = useState("");
- const [email, setEmail] = useState("");
- const handleSubmit = () =>
- onSubmit({
- comment: comment.trim() || undefined,
- email: email.trim() || undefined,
- });
-
- return (
- <Modal
- size={rem(530)}
- padding="xxl"
- opened={opened}
- withCloseButton={false}
- onClose={onClose}
- >
- <Title pb="sm" order={2}>{t`How can we improve embedding?`}</Title>
- <Stack gap="xl">
- {/* eslint-disable-next-line metabase/no-literal-metabase-strings -- only admins can see this component */}
- <Text>{t`Please let us know what happened. We’re always looking for ways to improve Metabase.`}</Text>
-
- <Textarea
- label={t`Feedback`}
- name="comment"
- placeholder={t`Tell us what happened`}
- onChange={(e) => setComment(e.currentTarget.value)}
- minRows={3}
- />
-
- <TextInput
- label={t`Email`}
- type="email"
- name="email"
- placeholder={t`Leave your email if you want us to follow up with you`}
- onChange={(e) => setEmail(e.currentTarget.value)}
- />
-
- <Group justify="flex-end">
- <Button onClick={onClose}>{t`Cancel`}</Button>
- <Button variant="filled" onClick={handleSubmit}>
- {comment.trim().length + email.trim().length > 0
- ? t`Send`
- : t`Skip`}
- </Button>
- </Group>
- </Stack>
- </Modal>
- );
-};
diff --git a/frontend/src/metabase/home/components/EmbedHomepage/tests/EmbedHomepage.unit.spec.tsx b/frontend/src/metabase/home/components/EmbedHomepage/tests/EmbedHomepage.unit.spec.tsx
index b805723522d..1a8e236261c 100644
--- a/frontend/src/metabase/home/components/EmbedHomepage/tests/EmbedHomepage.unit.spec.tsx
+++ b/frontend/src/metabase/home/components/EmbedHomepage/tests/EmbedHomepage.unit.spec.tsx
@@ -2,12 +2,7 @@ import userEvent from "@testing-library/user-event";
import { screen, within } from "__support__/ui";
-import {
- getLastFeedbackCall,
- getLastHomepageSettingSettingCall,
- queryFeedbackModal,
- setup,
-} from "./setup";
+import { getLastHomepageSettingSettingCall, setup } from "./setup";
describe("EmbedHomepage (OSS)", () => {
it("should link to the docs for static embedding", () => {
@@ -101,105 +96,16 @@ describe("EmbedHomepage (OSS)", () => {
expect(body).toEqual({ value: "dismissed-not-interested-now" });
});
- describe("Feedback modal", () => {
- const setupForFeedbackModal = async () => {
- setup();
- await userEvent.hover(screen.getByText("Hide these"));
-
- await userEvent.click(screen.getByText("I ran into issues"));
- };
-
- it("should ask for feedback when dismissing because of issues", async () => {
- await setupForFeedbackModal();
-
- expect(
- screen.getByText("How can we improve embedding?"),
- ).toBeInTheDocument();
- });
-
- it("should display 'Skip' in the button when inputs are empty, 'Send' if any input has content", async () => {
- await setupForFeedbackModal();
-
- expect(screen.getByText("Skip")).toBeInTheDocument();
-
- await userEvent.type(
- screen.getByLabelText("Feedback"),
- "I had an issue with X",
- );
-
- expect(screen.queryByText("Skip")).not.toBeInTheDocument();
- expect(screen.getByText("Send")).toBeInTheDocument();
-
- await userEvent.clear(screen.getByLabelText("Feedback"));
- await userEvent.type(screen.getByLabelText("Feedback"), " ");
- expect(screen.getByText("Skip")).toBeInTheDocument();
-
- await userEvent.type(
- screen.getByLabelText("Email"),
- );
-
- expect(screen.queryByText("Skip")).not.toBeInTheDocument();
- expect(screen.getByText("Send")).toBeInTheDocument();
- });
-
- it("should not dismiss the homepage when the user cancels the feedback modal", async () => {
- await setupForFeedbackModal();
-
- await userEvent.click(screen.getByText("Cancel"));
-
- expect(getLastHomepageSettingSettingCall()).toBeUndefined();
- });
-
- it("should dismiss when submitting feedback - even if empty, should not actually send the feedback", async () => {
- await setupForFeedbackModal();
-
- await userEvent.click(screen.getByText("Skip"));
-
- const lastCall = getLastHomepageSettingSettingCall();
-
- const body = await lastCall?.request?.json();
- expect(body).toEqual({ value: "dismissed-run-into-issues" });
-
- expect(queryFeedbackModal()).not.toBeInTheDocument();
-
- // when both fields are empty, the button says "Skip" and
- // we should not make the http call
- expect(getLastFeedbackCall()).toBeUndefined();
-
- expect(
- screen.queryByText("Your feedback was submitted, thank you."),
- ).not.toBeInTheDocument();
- });
-
- it("should send feedback when submitting the modal", async () => {
- await setupForFeedbackModal();
-
- await userEvent.type(
- screen.getByLabelText("Feedback"),
- "I had an issue with X",
- );
-
- await userEvent.type(screen.getByLabelText("Email"), "[email protected]");
-
- await userEvent.click(screen.getByText("Send"));
-
- const lastCall = getLastHomepageSettingSettingCall();
- const body = await lastCall?.request?.json();
- expect(body).toEqual({ value: "dismissed-run-into-issues" });
+ it("should set 'embedding-homepage' to 'dismissed-run-into-issues' when dismissing because of issues", async () => {
+ setup();
+ await userEvent.hover(screen.getByText("Hide these"));
- const feedbackBody = await getLastFeedbackCall()?.request?.json();
+ await userEvent.click(screen.getByText("I ran into issues"));
- expect(feedbackBody).toEqual({
- comments: "I had an issue with X",
- email: "[email protected]",
- source: "embedding-homepage-dismiss",
- });
+ const lastCall = getLastHomepageSettingSettingCall();
- expect(
- await screen.findByText("Your feedback was submitted, thank you."),
- ).toBeInTheDocument();
- });
+ const body = await lastCall?.request?.json();
+ expect(body).toEqual({ value: "dismissed-run-into-issues" });
});
it("should show the advanced embeds upsell for OSS users", () => {
diff --git a/frontend/src/metabase/home/components/EmbedHomepage/tests/setup.tsx b/frontend/src/metabase/home/components/EmbedHomepage/tests/setup.tsx
index 02485d21640..36a79a09a7d 100644
--- a/frontend/src/metabase/home/components/EmbedHomepage/tests/setup.tsx
+++ b/frontend/src/metabase/home/components/EmbedHomepage/tests/setup.tsx
@@ -6,7 +6,7 @@ import {
setupSettingsEndpoints,
} from "__support__/server-mocks";
import { createMockSettingsState, createMockState } from "__support__/state";
-import { renderWithProviders, screen } from "__support__/ui";
+import { renderWithProviders } from "__support__/ui";
import { Route } from "metabase/router";
import type { Settings, TokenFeatures } from "metabase-types/api";
import {
@@ -33,7 +33,6 @@ export async function setup({
jest.clearAllMocks();
fetchMock.put("path:/api/setting/embedding-homepage", 200);
- fetchMock.post("path:/api/product-feedback", 200);
setupSettingsEndpoints([]);
setupPropertiesEndpoints(createMockSettings());
@@ -57,7 +56,6 @@ export async function setup({
{
storeInitialState: state,
withRouter: true,
- withUndos: true,
},
);
}
@@ -66,11 +64,3 @@ export const getLastHomepageSettingSettingCall = () =>
fetchMock.callHistory.lastCall("path:/api/setting/embedding-homepage", {
method: "PUT",
});
-
-export const getLastFeedbackCall = () =>
- fetchMock.callHistory.lastCall("path:/api/product-feedback", {
- method: "POST",
- });
-
-export const queryFeedbackModal = () =>
- screen.queryByText("How can we improve embedding?");