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
Apply the new upsell flow to interactive and embed js upsells (#63062)
Phoomparin Manocefa86ccea0a
diff --git a/e2e/test/scenarios/embedding/embedding-smoketests.cy.spec.js b/e2e/test/scenarios/embedding/embedding-smoketests.cy.spec.jsindex 1b96ec0d446..c0e263a91d4 100644--- a/e2e/test/scenarios/embedding/embedding-smoketests.cy.spec.js+++ b/e2e/test/scenarios/embedding/embedding-smoketests.cy.spec.js@@ -116,6 +116,19 @@ describe("scenarios > embedding > smoke tests", { tags: "@OSS" }, () => {});});+ it("should show the sdk upsell link in oss", () => {+ cy.visit("/admin/settings/embedding-in-other-applications/sdk");++ mainPage().within(() => {+ cy.findByRole("link", { name: "Try for free" })+ .should("have.attr", "href")+ .and(+ "eq",+ "https://www.metabase.com/product/embedded-analytics?utm_source=product&utm_medium=upsell&utm_campaign=embedded-analytics-js&utm_content=embedding-page&source_plan=oss",+ );+ });+ });+it("should not let you embed the question", () => {H.visitQuestion(ORDERS_QUESTION_ID);diff --git a/e2e/test/scenarios/embedding/embedding-upsells.cy.spec.ts b/e2e/test/scenarios/embedding/embedding-upsells.cy.spec.tsnew file mode 100644index 00000000000..f1f0ad1f73a--- /dev/null+++ b/e2e/test/scenarios/embedding/embedding-upsells.cy.spec.ts@@ -0,0 +1,72 @@+const { H } = cy;++describe("scenarios > embedding > upsells", { tags: "@EE" }, () => {+ beforeEach(() => {+ H.restore();+ cy.signInAsAdmin();+ H.updateSetting("show-sdk-embed-terms", false);+ });++ it("should show the sdk settings page with upsell button", () => {+ cy.on("window:before:load", (win) => {+ // prevent Cypress opening in a new window/tab and spy on this method+ cy.stub(win, "open").as("open");+ });++ cy.visit("/admin/settings/embedding-in-other-applications/sdk");++ mainPage().within(() => {+ cy.contains("SDK for React").should("be.visible");+ cy.contains("Embedded Analytics JS").should("be.visible");+ });++ cy.findByRole("button", { name: "Try for free" }).click();++ cy.get<sinon.SinonSpy>("@open").should((spy) => {+ const url = spy.getCall(0).args[0];++ expect(url).to.include(+ "https://test-store.metabase.com/checkout/upgrade/self-hosted",+ );++ expect(url).to.match(/utm_source=product/);+ expect(url).to.match(/utm_medium=upsell/);+ expect(url).to.match(/utm_campaign=embedded-analytics-js/);+ expect(url).to.match(/utm_content=embedding-page/);+ expect(url).to.match(/source_plan=oss/);+ });+ });++ it("should show the interactive embed card with upsell button", () => {+ cy.on("window:before:load", (win) => {+ // prevent Cypress opening in a new window/tab and spy on this method+ cy.stub(win, "open").as("open");+ });++ cy.visit("/admin/settings/embedding-in-other-applications");++ mainPage().within(() => {+ cy.contains("Interactive embedding").should("be.visible");+ });++ cy.findByRole("button", { name: "Try for free" }).click();++ cy.get<sinon.SinonSpy>("@open").should((spy) => {+ const url = spy.getCall(0).args[0];++ expect(url).to.include(+ "https://test-store.metabase.com/checkout/upgrade/self-hosted",+ );++ expect(url).to.match(/utm_source=product/);+ expect(url).to.match(/utm_medium=upsell/);+ expect(url).to.match(/utm_campaign=embedding-interactive/);+ expect(url).to.match(/utm_content=embedding-page/);+ expect(url).to.match(/source_plan=oss/);+ });+ });+});++function mainPage() {+ return cy.findByTestId("admin-layout-content");+}diff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingOption/InteractiveEmbeddingOptionCard/InteractiveEmbeddingOptionCard.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingOption/InteractiveEmbeddingOptionCard/InteractiveEmbeddingOptionCard.tsxindex 5610c255323..08edec9d3f9 100644--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingOption/InteractiveEmbeddingOptionCard/InteractiveEmbeddingOptionCard.tsx+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingOption/InteractiveEmbeddingOptionCard/InteractiveEmbeddingOptionCard.tsx@@ -85,7 +85,7 @@ export const InteractiveEmbeddingOptionCard = () => {url="https://www.metabase.com/product/embedded-analytics"campaign="embedding-interactive"location="embedding-page"- large+ size="large"/>)}<EmbeddingTogglediff --git a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/EmbeddingSdkSettings.tsx b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/EmbeddingSdkSettings.tsxindex cecdcd3d6f5..4ebe0fdaad5 100644--- a/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/EmbeddingSdkSettings.tsx+++ b/frontend/src/metabase/admin/settings/components/EmbeddingSettings/EmbeddingSdkSettings/EmbeddingSdkSettings.tsx@@ -218,6 +218,7 @@ export function EmbeddingSdkSettings() {url="https://www.metabase.com/product/embedded-analytics"campaign="embedded-analytics-js"location="embedding-page"+ size="default"/>)}</Group>diff --git a/frontend/src/metabase/admin/upsells/UpsellEmbeddingButton.tsx b/frontend/src/metabase/admin/upsells/UpsellEmbeddingButton.tsxindex 6d7f82999bb..ea3eb41a616 100644--- a/frontend/src/metabase/admin/upsells/UpsellEmbeddingButton.tsx+++ b/frontend/src/metabase/admin/upsells/UpsellEmbeddingButton.tsx@@ -1,21 +1,20 @@-import cx from "classnames";import { t } from "ttag";-import ExternalLink from "metabase/common/components/ExternalLink";+import { PLUGIN_ADMIN_SETTINGS } from "metabase/plugins";-import S from "./components/UpsellCta.module.css";+import { UpsellCta } from "./components/UpsellCta";import { useUpsellLink } from "./components/use-upsell-link";export const UpsellEmbeddingButton = ({url,campaign,location,- large = false,+ size = "default",}: {url: string;campaign: string;location: string;- large?: boolean;+ size?: "default" | "large";}) => {const upsellLink = useUpsellLink({url,@@ -23,12 +22,19 @@ export const UpsellEmbeddingButton = ({location,});+ const { triggerUpsellFlow } = PLUGIN_ADMIN_SETTINGS.useUpsellFlow({+ campaign,+ location,+ });+return (- <ExternalLink- href={upsellLink}- className={cx(S.UpsellCTALink, large && S.Large)}- >- {t`Try for free`}- </ExternalLink>+ <UpsellCta+ onClick={triggerUpsellFlow}+ buttonText={t`Try for free`}+ url={upsellLink}+ internalLink={undefined}+ onClickCapture={() => {}}+ size={size}+ />);};