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
Change embed flow tracking to track step completions for funnel analysis (#63973)
Phoomparin Mano8cb9ca883d58
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-parameters.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-parameters.cy.spec.tsindex d7ac0656e68..24ec3b70c06 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-parameters.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/embed-parameters.cy.spec.ts@@ -104,14 +104,6 @@ H.describeWithSnowplow(suiteTitle, () => {.findByLabelText("Product ID").should("contain", "456");- H.expectUnstructuredSnowplowEvent(- {- event: "embed_wizard_option_changed",- event_detail: "initialParameters",- },- 2,- );-cy.log("both default values should be in the code snippet");getEmbedSidebar().within(() => {cy.findByText("Get Code").click();@@ -147,14 +139,6 @@ H.describeWithSnowplow(suiteTitle, () => {.findByTestId("dashboard-parameters-widget-container").should("not.exist");- H.expectUnstructuredSnowplowEvent(- {- event: "embed_wizard_option_changed",- event_detail: "hiddenParameters",- },- 2,- );-cy.log("code snippet should contain the hidden parameters");getEmbedSidebar().within(() => {cy.findByText("Get Code").click();@@ -218,11 +202,6 @@ H.describeWithSnowplow(suiteTitle, () => {cy.findAllByText("75.41").first().should("be.visible");});- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_option_changed",- event_detail: "initialSqlParameters",- });-getEmbedSidebar().within(() => {cy.findByText("Get Code").click();codeBlock().should("contain", "initial-sql-parameters=");diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/get-code.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/get-code.cy.spec.tsindex 069039e53a0..65573659aa4 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/get-code.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/get-code.cy.spec.ts@@ -115,6 +115,32 @@ H.describeWithSnowplow(suiteTitle, () => {getEmbedSidebar().within(() => {cy.findByLabelText("Existing Metabase session").should("be.checked");codeBlock().should("contain", '"useExistingUserSession": true');++ cy.findByText(/Copy Code/).click();++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_code_copied",+ event_detail: "user_session",+ });+ });+ });++ it("should track embed_wizard_code_copied when copy event triggers", () => {+ navigateToGetCodeStep({+ experience: "dashboard",+ resourceName: DASHBOARD_NAME,+ });++ getEmbedSidebar().within(() => {+ cy.findByLabelText("Existing Metabase session").should("be.checked");++ codeBlock().should("contain", '"useExistingUserSession": true');+ codeBlock().trigger("copy");++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_code_copied",+ event_detail: "user_session",+ });});});@@ -127,13 +153,14 @@ H.describeWithSnowplow(suiteTitle, () => {getEmbedSidebar().within(() => {cy.findByLabelText("Single sign-on (SSO)").click();+ codeBlock().should("not.contain", "useExistingUserSession");++ cy.findByText(/Copy Code/).click();H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_auth_selected",+ event: "embed_wizard_code_copied",event_detail: "sso",});-- codeBlock().should("not.contain", "useExistingUserSession");});});diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-entity.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-entity.cy.spec.tsindex bdaee43ac06..3f94ba18622 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-entity.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-entity.cy.spec.ts@@ -41,7 +41,25 @@ H.describeWithSnowplow(suiteTitle, () => {H.expectNoBadSnowplowEvents();});- it("can select a recent dashboard to embed", () => {+ it("tracks 'default' when keeping the default dashboard selection", () => {+ visitNewEmbedPage();++ getEmbedSidebar().within(() => {+ cy.findByText("Next").click();+ cy.findByText("Select a dashboard to embed").should("be.visible");++ cy.log("first dashboard should be selected by default");+ getRecentItemCards().first().should("have.attr", "data-selected", "true");+ cy.findByText("Next").click();+ });++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_resource_selection_completed",+ event_detail: "default",+ });+ });++ it("tracks 'custom' when selecting a different dashboard", () => {cy.log("add two dashboards to activity log");H.createDashboard({ name: SECOND_DASHBOARD_NAME }).then(@@ -70,14 +88,6 @@ H.describeWithSnowplow(suiteTitle, () => {cy.log("second dashboard can be selected");cy.findByText(SECOND_DASHBOARD_NAME).click();- cy.get("@secondDashboardId").then((secondDashboardId) => {- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_resource_selected",- target_id: secondDashboardId,- event_detail: "dashboard",- });- });-getRecentItemCards().eq(1).should("have.attr", "data-selected", "true");});@@ -87,22 +97,11 @@ H.describeWithSnowplow(suiteTitle, () => {cy.findByText(SECOND_DASHBOARD_NAME).should("be.visible");});- cy.log("select the same the dashboard again");- getEmbedSidebar().within(() => {- cy.findByText(SECOND_DASHBOARD_NAME).click();- cy.findByText(SECOND_DASHBOARD_NAME).click();- });+ getEmbedSidebar().findByText("Next").click();- cy.get("@secondDashboardId").then((secondDashboardId) => {- cy.log("only a single snowplow event should be sent");- H.expectUnstructuredSnowplowEvent(- {- event: "embed_wizard_resource_selected",- target_id: secondDashboardId,- event_detail: "dashboard",- },- 1,- );+ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_resource_selection_completed",+ event_detail: "custom",});});@@ -131,13 +130,14 @@ H.describeWithSnowplow(suiteTitle, () => {cy.log("second question can be selected");cy.findByText(SECOND_QUESTION_NAME).click();+ getRecentItemCards().eq(1).should("have.attr", "data-selected", "true");++ cy.findByText("Next").click();+H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_resource_selected",- target_id: ORDERS_BY_YEAR_QUESTION_ID,- event_detail: "chart",+ event: "embed_wizard_resource_selection_completed",+ event_detail: "custom",});-- getRecentItemCards().eq(1).should("have.attr", "data-selected", "true");});cy.log("selected question should be shown in the preview");@@ -166,14 +166,6 @@ H.describeWithSnowplow(suiteTitle, () => {cy.findByText(SECOND_DASHBOARD_NAME).click();});- cy.get("@secondDashboardId").then((secondDashboardId) => {- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_resource_selected",- target_id: secondDashboardId,- event_detail: "dashboard",- });- });-cy.log("dashboard is added to the top of recents list and selected");getEmbedSidebar().within(() => {getRecentItemCards()@@ -204,12 +196,6 @@ H.describeWithSnowplow(suiteTitle, () => {cy.findByText(FIRST_QUESTION_NAME).click();});- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_resource_selected",- target_id: ORDERS_COUNT_QUESTION_ID,- event_detail: "chart",- });-cy.log("question is added to the top of recents list and selected");getEmbedSidebar().within(() => {getRecentItemCards()@@ -217,6 +203,13 @@ H.describeWithSnowplow(suiteTitle, () => {.first().should("contain", FIRST_QUESTION_NAME).should("have.attr", "data-selected", "true");++ cy.findByText("Next").click();+ });++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_resource_selection_completed",+ event_detail: "custom",});cy.wait("@cardQuery");diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-experience.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-experience.cy.spec.tsindex 1756dfbf469..461b69a15c2 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-experience.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-experience.cy.spec.ts@@ -39,8 +39,18 @@ H.describeWithSnowplow(suiteTitle, () => {visitNewEmbedPage();assertRecentItemName("dashboard", dashboardName);+ H.expectUnstructuredSnowplowEvent({ event: "embed_wizard_opened" });H.waitForSimpleEmbedIframesToLoad();+ getEmbedSidebar().within(() => {+ cy.findByText("Next").click();+ });++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_experience_completed",+ event_detail: "default",+ });+H.getSimpleEmbedIframeContent().within(() => {cy.log("dashboard title is visible");cy.findByText(dashboardName).should("be.visible");@@ -59,12 +69,16 @@ H.describeWithSnowplow(suiteTitle, () => {visitNewEmbedPage();assertRecentItemName("card", questionName);+ H.expectUnstructuredSnowplowEvent({ event: "embed_wizard_opened" });- getEmbedSidebar().findByText("Chart").click();+ getEmbedSidebar().within(() => {+ cy.findByText("Chart").click();+ cy.findByText("Next").click();+ });H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_experience_selected",- event_detail: "chart",+ event: "embed_wizard_experience_completed",+ event_detail: "custom=chart",});cy.wait("@cardQuery");@@ -77,11 +91,15 @@ H.describeWithSnowplow(suiteTitle, () => {it("shows exploration template when selected", { tags: "@skip" }, () => {visitNewEmbedPage();- getEmbedSidebar().findByText("Exploration").click();++ getEmbedSidebar().within(() => {+ cy.findByText("Exploration").click();+ cy.findByText("Next").click();+ });H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_experience_selected",- event_detail: "exploration",+ event: "embed_wizard_experience_completed",+ event_detail: "custom=exploration",});H.waitForSimpleEmbedIframesToLoad();@@ -94,11 +112,15 @@ H.describeWithSnowplow(suiteTitle, () => {it("shows browser template when selected", () => {visitNewEmbedPage();- getEmbedSidebar().findByText("Browser").click();++ getEmbedSidebar().within(() => {+ cy.findByText("Browser").click();+ cy.findByText("Next").click();+ });H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_experience_selected",- event_detail: "browser",+ event: "embed_wizard_experience_completed",+ event_detail: "custom=browser",});H.getSimpleEmbedIframeContent().within(() => {@@ -144,11 +166,14 @@ H.describeWithSnowplow(suiteTitle, () => {visitNewEmbedPage();cy.wait("@emptyRecentItems");- getEmbedSidebar().findByText("Chart").click();+ getEmbedSidebar().within(() => {+ cy.findByText("Chart").click();+ cy.findByText("Next").click();+ });H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_experience_selected",- event_detail: "chart",+ event: "embed_wizard_experience_completed",+ event_detail: "custom=chart",});H.waitForSimpleEmbedIframesToLoad();diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-options.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-options.cy.spec.tsindex cf5e83fb254..8e562c856a7 100644--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-options.cy.spec.ts+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding-setup/select-embed-options.cy.spec.ts@@ -55,11 +55,6 @@ H.describeWithSnowplow(suiteTitle, () => {.click().should("not.be.checked");- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_option_changed",- event_detail: "drills",- });-cy.log("drill-through should be disabled in the preview");H.getSimpleEmbedIframeContent().within(() => {cy.findByText("110.93").click();@@ -68,6 +63,13 @@ H.describeWithSnowplow(suiteTitle, () => {cy.log("snippet should be updated");getEmbedSidebar().findByText("Get Code").click();++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_options_completed",+ event_detail:+ "settings=custom,theme=default,auth=user_session,drills=false,withDownloads=false,withTitle=true",+ });+codeBlock().should("contain", 'drills="false"');});@@ -91,17 +93,19 @@ H.describeWithSnowplow(suiteTitle, () => {.click().should("be.checked");- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_option_changed",- event_detail: "withDownloads",- });-H.getSimpleEmbedIframeContent().findByTestId("export-as-pdf-button").should("be.visible");cy.log("snippet should be updated");getEmbedSidebar().findByText("Get Code").click();++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_options_completed",+ event_detail:+ "settings=custom,theme=default,auth=user_session,drills=true,withDownloads=true,withTitle=true",+ });+codeBlock().should("contain", 'with-downloads="true"');});@@ -125,17 +129,19 @@ H.describeWithSnowplow(suiteTitle, () => {.click().should("not.be.checked");- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_option_changed",- event_detail: "withTitle",- });-H.getSimpleEmbedIframeContent().findByText("Orders in a dashboard").should("not.exist");cy.log("snippet should be updated");getEmbedSidebar().findByText("Get Code").click();++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_options_completed",+ event_detail:+ "settings=custom,theme=default,auth=user_session,drills=true,withDownloads=false,withTitle=false",+ });+codeBlock().should("contain", 'with-title="false"');});@@ -161,11 +167,6 @@ H.describeWithSnowplow(suiteTitle, () => {.click().should("not.be.checked");- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_option_changed",- event_detail: "drills",- });-cy.log("drill-through should be disabled in chart preview");H.getSimpleEmbedIframeContent().within(() => {cy.findByText("18,760").click();@@ -200,17 +201,19 @@ H.describeWithSnowplow(suiteTitle, () => {.click().should("be.checked");- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_option_changed",- event_detail: "withDownloads",- });-H.getSimpleEmbedIframeContent().findByTestId("question-download-widget-button").should("be.visible");cy.log("snippet should be updated");getEmbedSidebar().findByText("Get Code").click();++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_options_completed",+ event_detail:+ "settings=custom,theme=default,auth=user_session,drills=true,withDownloads=true,withTitle=true,isSaveEnabled=false",+ });+codeBlock().should("contain", 'with-downloads="true"');});@@ -233,11 +236,6 @@ H.describeWithSnowplow(suiteTitle, () => {.click().should("not.be.checked");- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_option_changed",- event_detail: "withTitle",- });-H.getSimpleEmbedIframeContent().findByText("Orders, Count").should("not.exist");@@ -277,22 +275,15 @@ H.describeWithSnowplow(suiteTitle, () => {H.getSimpleEmbedIframeContent().findByText("Orders, Count").should("be.visible");-- H.expectUnstructuredSnowplowEvent(- {- event: "embed_wizard_option_changed",- event_detail: "withTitle",- },- 2,- );});["exploration", "chart"].forEach((experience) => {it(`toggles save button for ${experience}`, () => {- navigateToEmbedOptionsStep({- experience,- ...(experience === "chart" && { resourceName: QUESTION_NAME }),- });+ navigateToEmbedOptionsStep(+ experience === "chart"+ ? { experience: "chart", resourceName: QUESTION_NAME }+ : { experience: "exploration" },+ );if (experience === "exploration") {cy.log("visualize a question to enable the save button");@@ -315,11 +306,6 @@ H.describeWithSnowplow(suiteTitle, () => {.click().should("be.checked");- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_option_changed",- event_detail: "isSaveEnabled",- });-if (experience === "chart") {cy.log("select a different visualization to enable the save button");H.getSimpleEmbedIframeContent().within(() => {@@ -334,6 +320,15 @@ H.describeWithSnowplow(suiteTitle, () => {cy.log("snippet should be updated");getEmbedSidebar().findByText("Get Code").click();++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_options_completed",+ event_detail:+ experience === "chart"+ ? "settings=custom,theme=default,auth=user_session,drills=true,withDownloads=false,withTitle=true,isSaveEnabled=true"+ : "settings=custom,theme=default,auth=user_session,isSaveEnabled=true",+ });+codeBlock().should("contain", 'is-save-enabled="true"');});});@@ -358,17 +353,19 @@ H.describeWithSnowplow(suiteTitle, () => {.click().should("be.checked");- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_option_changed",- event_detail: "readOnly",- });-H.getSimpleEmbedIframeContent().within(() => {cy.findByText("New dashboard").should("be.visible");});cy.log("snippet should be updated");getEmbedSidebar().findByText("Get Code").click();++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_options_completed",+ event_detail:+ "settings=custom,theme=default,auth=user_session,readOnly=false",+ });+codeBlock().should("contain", 'read-only="false"');});@@ -397,11 +394,6 @@ H.describeWithSnowplow(suiteTitle, () => {.type("rgb(255, 0, 0)");});- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_option_changed",- event_detail: "theme",- });-cy.log("table header cell should now be red");H.getSimpleEmbedIframeContent().findAllByTestId("cell-data")@@ -414,6 +406,12 @@ H.describeWithSnowplow(suiteTitle, () => {cy.log("snippet should be updated");getEmbedSidebar().findByText("Get Code").click();+ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_options_completed",+ event_detail:+ "settings=custom,theme=custom,auth=user_session,drills=true,withDownloads=false,withTitle=true",+ });+codeBlock().should("contain", '"theme": {');codeBlock().should("contain", '"colors": {');codeBlock().should("contain", '"brand": "#FF0000"');@@ -424,11 +422,6 @@ H.describeWithSnowplow(suiteTitle, () => {cy.log("click reset button");getEmbedSidebar().findByLabelText("Reset colors").click();- H.expectUnstructuredSnowplowEvent({- event: "embed_wizard_option_changed",- event_detail: "theme",- });-cy.log("table header should be back to default blue");H.getSimpleEmbedIframeContent().findAllByTestId("cell-data")@@ -441,6 +434,11 @@ H.describeWithSnowplow(suiteTitle, () => {cy.log("snippet should not contain theme colors");getEmbedSidebar().findByText("Get Code").click();codeBlock().should("not.contain", '"theme": {');++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_options_completed",+ event_detail: "settings=default",+ });});it("derives colors for dark theme palette", () => {@@ -475,6 +473,12 @@ H.describeWithSnowplow(suiteTitle, () => {cy.log("check that derived colors are applied to snippet");getEmbedSidebar().findByText("Get Code").click();+ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_options_completed",+ event_detail:+ "settings=custom,theme=custom,auth=user_session,drills=true,withDownloads=false,withTitle=true",+ });+// derived-colors-for-embed-flow.unit.spec.ts contains the tests for other derived colors.cy.log("dark mode colors should be derived");codeBlock().should("contain", '"background-hover": "rgb(27, 27, 27)"');diff --git a/e2e/test/scenarios/sharing/public-sharing-embed-flow.cy.spec.ts b/e2e/test/scenarios/sharing/public-sharing-embed-flow.cy.spec.tsindex bd94921259f..f67ca711d44 100644--- a/e2e/test/scenarios/sharing/public-sharing-embed-flow.cy.spec.ts+++ b/e2e/test/scenarios/sharing/public-sharing-embed-flow.cy.spec.ts@@ -7,14 +7,22 @@ import { getEmbedSidebar } from "../embedding/sdk-iframe-embedding-setup/helpersconst { H } = cy;-describe("embed flow pre-selection from sharing modal", () => {+const suiteTitle = "scenarios > sharing > embed flow pre-selection";++H.describeWithSnowplow(suiteTitle, () => {beforeEach(() => {H.restore();+ H.resetSnowplow();cy.signInAsAdmin();- H.activateToken("pro-self-hosted");+ H.activateToken("bleeding-edge");+ H.enableTracking();H.updateSetting("enable-embedding-simple", true);});+ afterEach(() => {+ H.expectNoBadSnowplowEvents();+ });+it("pre-selects dashboard in embed flow when opened from dashboard sharing modal", () => {H.visitDashboard(ORDERS_DASHBOARD_ID);H.openSharingMenu("Embed");@@ -23,6 +31,8 @@ describe("embed flow pre-selection from sharing modal", () => {cy.findByRole("link", { name: "Embedded Analytics JS" }).click();});+ H.expectUnstructuredSnowplowEvent({ event: "embed_wizard_opened" });+cy.location("search").should((search) => {const params = new URLSearchParams(search);@@ -30,7 +40,6 @@ describe("embed flow pre-selection from sharing modal", () => {expect(params.get("resource_id")).to.equal(String(ORDERS_DASHBOARD_ID));});- cy.log("should navigate to embed options step");getEmbedSidebar().within(() => {cy.findByText("Behavior").should("be.visible");cy.findByText("Appearance").should("be.visible");@@ -41,15 +50,24 @@ describe("embed flow pre-selection from sharing modal", () => {H.getSimpleEmbedIframeContent().findByText("Orders in a dashboard", { timeout: 10_000 }).should("be.visible");++ getEmbedSidebar().findByText("Get Code").click();++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_options_completed",+ event_detail: "settings=default",+ });});it("pre-selects question in embed flow when opened from question sharing modal", () => {H.visitQuestion(ORDERS_QUESTION_ID);H.openSharingMenu("Embed");- H.getEmbedModalSharingPane().within(() => {- cy.findByRole("link", { name: "Embedded Analytics JS" }).click();- });+ H.getEmbedModalSharingPane()+ .findByRole("link", { name: "Embedded Analytics JS" })+ .click();++ H.expectUnstructuredSnowplowEvent({ event: "embed_wizard_opened" });cy.location("search").should((search) => {const params = new URLSearchParams(search);@@ -58,7 +76,6 @@ describe("embed flow pre-selection from sharing modal", () => {expect(params.get("resource_id")).to.equal(String(ORDERS_QUESTION_ID));});- cy.log("should navigate to embed options step");getEmbedSidebar().within(() => {cy.findByText("Behavior").should("be.visible");cy.findByText("Appearance").should("be.visible");@@ -69,5 +86,58 @@ describe("embed flow pre-selection from sharing modal", () => {H.getSimpleEmbedIframeContent().findByText("Orders", { timeout: 10_000 }).should("be.visible");++ getEmbedSidebar().findByText("Get Code").click();++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_options_completed",+ event_detail: "settings=default",+ });+ });++ it("tracks default resources for pre-selected dashboard", () => {+ H.visitDashboard(ORDERS_DASHBOARD_ID);+ H.openSharingMenu("Embed");++ H.getEmbedModalSharingPane().within(() => {+ cy.findByRole("link", { name: "Embedded Analytics JS" }).click();+ });++ H.expectUnstructuredSnowplowEvent({ event: "embed_wizard_opened" });++ cy.log("go back to resource selection step");+ getEmbedSidebar().within(() => {+ cy.findByText("Back").click();+ cy.findByText("Select a dashboard to embed").should("be.visible");+ cy.findByText("Next").click();+ });++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_resource_selection_completed",+ event_detail: "default",+ });+ });++ it("tracks default resources for pre-selected question", () => {+ H.visitQuestion(ORDERS_QUESTION_ID);+ H.openSharingMenu("Embed");++ H.getEmbedModalSharingPane().within(() => {+ cy.findByRole("link", { name: "Embedded Analytics JS" }).click();+ });++ H.expectUnstructuredSnowplowEvent({ event: "embed_wizard_opened" });++ cy.log("go back to resource selection step");+ getEmbedSidebar().within(() => {+ cy.findByText("Back").click();+ cy.findByText("Select a chart to embed").should("be.visible");+ cy.findByText("Next").click();+ });++ H.expectUnstructuredSnowplowEvent({+ event: "embed_wizard_resource_selection_completed",+ event_detail: "default",+ });});});diff --git a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/analytics.ts b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/analytics.tsindex 45c7f00ea00..b041a3eec7d 100644--- a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/analytics.ts+++ b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/analytics.ts@@ -1,70 +1,124 @@+import _ from "underscore";+import { trackSimpleEvent } from "metabase/lib/analytics";import type {SdkIframeEmbedSettingKey,SdkIframeEmbedSettings,} from "metabase-enterprise/embedding_iframe_sdk/types/embed";-import type { SdkIframeEmbedSetupExperience } from "./types";-import { filterEmptySettings } from "./utils/filter-empty-settings";+import type {+ SdkIframeEmbedSetupExperience,+ SdkIframeEmbedSetupSettings,+} from "./types";+import {+ getDefaultSdkIframeEmbedSettings,+ getResourceIdFromSettings,+} from "./utils/default-embed-setting";-export const trackEmbedWizardExperienceSelected = (- experience: SdkIframeEmbedSetupExperience,-) =>- trackSimpleEvent({- event: "embed_wizard_experience_selected",- event_detail: experience,- });+/**+ * Tracking every embed settings would bloat Snowplow, so we only track+ * the most relevant options that reveal usage patterns.+ */+const EMBED_SETTINGS_TO_TRACK: SdkIframeEmbedSettingKey[] = [+ "drills",+ "withTitle",+ "withDownloads",+ "isSaveEnabled",+ "readOnly",+];++/**+ * When comparing settings to defaults, we ignore these options as they are already tracked in another step.+ */+const EMBED_SETTINGS_TO_IGNORE: SdkIframeEmbedSettingKey[] = [+ "componentName",+ "dashboardId",+ "questionId",+ "targetCollection",+];-export const trackEmbedWizardResourceSelected = (- resourceId: number,+export const trackEmbedWizardOpened = () =>+ trackSimpleEvent({ event: "embed_wizard_opened" });++export const trackEmbedWizardExperienceCompleted = (experience: SdkIframeEmbedSetupExperience,+ defaultExperience: SdkIframeEmbedSetupExperience,) =>trackSimpleEvent({- event: "embed_wizard_resource_selected",- target_id: resourceId,- event_detail: experience,+ event: "embed_wizard_experience_completed",+ event_detail:+ experience === defaultExperience ? "default" : `custom=${experience}`,});-export const trackEmbedWizardCodeCopied = () =>+export const trackEmbedWizardResourceSelectionCompleted = (+ currentSettings: SdkIframeEmbedSetupSettings,+ defaultResourceId: string | number,+) => {+ const currentResourceId = getResourceIdFromSettings(currentSettings) ?? "";+ const isDefault = currentResourceId === defaultResourceId;+trackSimpleEvent({- event: "embed_wizard_code_copied",+ event: "embed_wizard_resource_selection_completed",+ event_detail: isDefault ? "default" : "custom",});+};++const getEmbedSettingsToCompare = (settings: Partial<SdkIframeEmbedSettings>) =>+ _.omit(_.omit(settings, ...EMBED_SETTINGS_TO_IGNORE), _.isUndefined);-export const trackEmbedWizardSettingsUpdated = (+export const trackEmbedWizardOptionsCompleted = (settings: Partial<SdkIframeEmbedSettings>,+ experience: SdkIframeEmbedSetupExperience,) => {- const filteredSettings = filterEmptySettings(settings);-- const settingKeys = Object.keys(- filteredSettings,- ) as SdkIframeEmbedSettingKey[];+ // Get defaults for this experience type (with a dummy resource ID)+ const defaultSettings = getDefaultSdkIframeEmbedSettings(experience, 0);- const untrackedKeys: SdkIframeEmbedSettingKey[] = [- // These keys are not tracked as user settings.- "instanceUrl",+ // Does the embed settings diverge from the experience defaults?+ const hasCustomOptions = !_.isEqual(+ getEmbedSettingsToCompare(settings),+ getEmbedSettingsToCompare(defaultSettings),+ );- // These are tracked via trackEmbedWizardExperienceSelected and trackEmbedWizardResourceSelected- "questionId",- "dashboardId",+ let options: string[] = [+ `settings=${hasCustomOptions ? "custom" : "default"}`,];- settingKeys.forEach((settingKey) => {- if (untrackedKeys.includes(settingKey)) {- return;- }+ if (hasCustomOptions) {+ const hasCustomTheme = settings.theme?.colors !== undefined;++ options = [+ ...options,+ `theme=${hasCustomTheme ? "custom" : "default"}`,+ `auth=${settings.useExistingUserSession ? "user_session" : "sso"}`,+ ];++ for (const _optionKey in settings) {+ const optionKey = _optionKey as keyof SdkIframeEmbedSettings;++ if (!EMBED_SETTINGS_TO_TRACK.includes(optionKey)) {+ continue;+ }++ const value = settings[optionKey];- if (settingKey === "useExistingUserSession") {- trackSimpleEvent({- event: "embed_wizard_auth_selected",- event_detail: settings.useExistingUserSession ? "user-session" : "sso",- });+ if (value === undefined) {+ continue;+ }- return;+ options.push(`${optionKey}=${value.toString()}`);}+ }- trackSimpleEvent({- event: "embed_wizard_option_changed",- event_detail: settingKey,- });+ trackSimpleEvent({+ event: "embed_wizard_options_completed",+ event_detail: options.join(","),});};++export const trackEmbedWizardCodeCopied = (+ authMethod: "sso" | "user_session",+) =>+ trackSimpleEvent({+ event: "embed_wizard_code_copied",+ event_detail: authMethod,+ });diff --git a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/GetCodeStep.tsx b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/GetCodeStep.tsxindex 6bb46b0dc5b..2e93a1e2e60 100644--- a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/GetCodeStep.tsx+++ b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/GetCodeStep.tsx@@ -36,6 +36,20 @@ export const GetCodeStep = () => {const authType = settings.useExistingUserSession ? "user-session" : "sso";+ const handleCodeSnippetCopied = () => {+ // Embed Flow: track code copied+ trackEmbedWizardCodeCopied(+ settings.useExistingUserSession ? "user_session" : "sso",+ );++ // Embedding Hub: track step completion+ const settingKey: SettingKey = settings.useExistingUserSession+ ? "embedding-hub-test-embed-snippet-created"+ : "embedding-hub-production-embed-snippet-created";++ updateInstanceSettings({ [settingKey]: true });+ };+return (<Stack gap="md"><Card p="md">@@ -105,12 +119,14 @@ export const GetCodeStep = () => {</Text><Stack gap="sm">- <CodeEditor- language="html"- value={snippet}- readOnly- lineNumbers={false}- />+ <div onCopy={handleCodeSnippetCopied}>+ <CodeEditor+ language="html"+ value={snippet}+ readOnly+ lineNumbers={false}+ />+ </div><CopyButton value={snippet}>{({ copied, copy }: { copied: boolean; copy: () => void }) => (@@ -118,14 +134,7 @@ export const GetCodeStep = () => {leftSection={<Icon name="copy" size={16} />}onClick={() => {copy();- trackEmbedWizardCodeCopied();-- // Embedding Hub: track step completion- const settingKey: SettingKey = settings.useExistingUserSession- ? "embedding-hub-test-embed-snippet-created"- : "embedding-hub-production-embed-snippet-created";-- updateInstanceSettings({ [settingKey]: true });+ handleCodeSnippetCopied();}}>{copied ? t`Copied!` : t`Copy Code`}diff --git a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SdkIframeEmbedSetupProvider.tsx b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SdkIframeEmbedSetupProvider.tsxindex b0a2f11b40c..61ca24d083e 100644--- a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SdkIframeEmbedSetupProvider.tsx+++ b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SdkIframeEmbedSetupProvider.tsx@@ -12,7 +12,7 @@ import _ from "underscore";import { useSearchQuery } from "metabase/api";import { useUserSetting } from "metabase/common/hooks";-import { trackEmbedWizardSettingsUpdated } from "../analytics";+import { trackEmbedWizardOpened } from "../analytics";import {EMBED_FALLBACK_DASHBOARD_ID,USER_SETTINGS_DEBOUNCE_MS,@@ -23,11 +23,14 @@ import {} from "../context";import { useParameterList, useRecentItems } from "../hooks";import type {- SdkIframeEmbedSetupExperience,SdkIframeEmbedSetupSettings,SdkIframeEmbedSetupStep,} from "../types";-import { getDefaultSdkIframeEmbedSettings } from "../utils/default-embed-setting";+import {+ getDefaultSdkIframeEmbedSettings,+ getExperienceFromSettings,+ getResourceIdFromSettings,+} from "../utils/default-embed-setting";interface SdkIframeEmbedSetupProviderProps {children: ReactNode;@@ -123,15 +126,7 @@ export const SdkIframeEmbedSetupProvider = ({// Which embed experience are we setting up?const experience = useMemo(- () =>- match<SdkIframeEmbedSetupSettings, SdkIframeEmbedSetupExperience>(- settings,- )- .with({ template: "exploration" }, () => "exploration")- .with({ componentName: "metabase-question" }, () => "chart")- .with({ componentName: "metabase-browser" }, () => "browser")- .with({ componentName: "metabase-dashboard" }, () => "dashboard")- .exhaustive(),+ () => getExperienceFromSettings(settings),[settings],);@@ -152,8 +147,6 @@ export const SdkIframeEmbedSetupProvider = ({const updateSettings = useCallback((nextSettings: Partial<SdkIframeEmbedSetupSettings>) =>setRawSettings((prev) => {- trackEmbedWizardSettingsUpdated(nextSettings);-// Merging with a partial setting requires us to cast the typeconst mergedSettings = {...(prev ?? defaultSettings),@@ -180,6 +173,10 @@ export const SdkIframeEmbedSetupProvider = ({setCurrentStep,experience,settings,+ defaultSettings: {+ resourceId: getResourceIdFromSettings(defaultSettings) ?? "",+ experience: getExperienceFromSettings(defaultSettings),+ },replaceSettings,updateSettings,recentDashboards,@@ -207,6 +204,8 @@ export const SdkIframeEmbedSetupProvider = ({});setEmbedSettingsLoaded(true);++ trackEmbedWizardOpened();}}, [persistedSettings,diff --git a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SelectEmbedExperienceStep.tsx b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SelectEmbedExperienceStep.tsxindex 01773a00539..f8ddc1a10f0 100644--- a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SelectEmbedExperienceStep.tsx+++ b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SelectEmbedExperienceStep.tsx@@ -8,7 +8,6 @@ import CS from "metabase/css/core/index.css";import { Card, Radio, Stack, Text } from "metabase/ui";import { ALLOWED_EMBED_SETTING_KEYS_MAP } from "metabase-enterprise/embedding_iframe_sdk/constants";-import { trackEmbedWizardExperienceSelected } from "../analytics";import {EMBED_FALLBACK_DASHBOARD_ID,EMBED_FALLBACK_QUESTION_ID,@@ -34,8 +33,6 @@ export const SelectEmbedExperienceStep = () => {const handleEmbedExperienceChange = (experience: SdkIframeEmbedSetupExperience,) => {- trackEmbedWizardExperienceSelected(experience);-const persistedSettings = _.pick(settings,ALLOWED_EMBED_SETTING_KEYS_MAP.base,diff --git a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SelectEmbedResourceStep.tsx b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SelectEmbedResourceStep.tsxindex f9f732d4bfc..1ed556fcd9f 100644--- a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SelectEmbedResourceStep.tsx+++ b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/components/SelectEmbedResourceStep.tsx@@ -1,5 +1,5 @@import { useDisclosure } from "@mantine/hooks";-import { P, match } from "ts-pattern";+import { match } from "ts-pattern";import { t } from "ttag";import { CollectionPickerModal } from "metabase/common/components/Pickers/CollectionPicker";@@ -8,13 +8,13 @@ import { QuestionPickerModal } from "metabase/common/components/Pickers/Questionimport { ActionIcon, Card, Group, Icon, Stack, Text } from "metabase/ui";import type { CollectionId } from "metabase-types/api";-import { trackEmbedWizardResourceSelected } from "../analytics";import { useSdkIframeEmbedSetupContext } from "../context";import type {SdkIframeEmbedSetupExperience,SdkIframeEmbedSetupRecentItem,SdkIframeEmbedSetupRecentItemType,} from "../types";+import { getResourceIdFromSettings } from "../utils/default-embed-setting";import { SelectEmbedResourceMissingRecents } from "./SelectEmbedResourceMissingRecents";import { SelectEmbedResourceRecentItemCard } from "./SelectEmbedResourceRecentItemCard";@@ -44,11 +44,7 @@ export const SelectEmbedResourceStep = () => {.with("chart", () => recentQuestions).exhaustive();- const selectedItemId = match(settings)- .with({ initialCollection: P.nonNullable }, (s) => s.initialCollection)- .with({ dashboardId: P.nonNullable }, (s) => s.dashboardId)- .with({ questionId: P.nonNullable }, (s) => s.questionId)- .otherwise(() => undefined);+ const selectedItemId = getResourceIdFromSettings(settings);const updateEmbedSettings = (experience: SdkIframeEmbedSetupExperience,@@ -64,13 +60,6 @@ export const SelectEmbedResourceStep = () => {return;}- const numericResourceId = typeof id === "string" ? parseInt(id) : id;-- // Only track the resource id if it is a valid numeric id.- if (!isNaN(numericResourceId)) {- trackEmbedWizardResourceSelected(numericResourceId, experience);- }-if (experience === "dashboard") {updateSettings({dashboardId: id,diff --git a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/context.ts b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/context.tsindex 3fc66da8e4d..24e7d81b686 100644--- a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/context.ts+++ b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/context.ts@@ -19,6 +19,10 @@ export interface SdkIframeEmbedSetupContextType {// Embed settingssettings: SdkIframeEmbedSetupSettings;+ defaultSettings: {+ resourceId: string | number;+ experience: SdkIframeEmbedSetupExperience;+ };updateSettings: (nextSettings: Partial<SdkIframeEmbedSetupSettings>) => void;replaceSettings: (settings: SdkIframeEmbedSetupSettings) => void;diff --git a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/hooks/use-sdk-iframe-embed-navigation.ts b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/hooks/use-sdk-iframe-embed-navigation.tsindex 53ba2c2ed6c..706f596083f 100644--- a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/hooks/use-sdk-iframe-embed-navigation.ts+++ b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/hooks/use-sdk-iframe-embed-navigation.ts@@ -1,10 +1,16 @@import { useMemo } from "react";+import { match } from "ts-pattern";+import {+ trackEmbedWizardExperienceCompleted,+ trackEmbedWizardOptionsCompleted,+ trackEmbedWizardResourceSelectionCompleted,+} from "../analytics";import { EMBED_STEPS } from "../constants";import { useSdkIframeEmbedSetupContext } from "../context";export function useSdkIframeEmbedNavigation() {- const { experience, currentStep, setCurrentStep } =+ const { experience, currentStep, setCurrentStep, settings, defaultSettings } =useSdkIframeEmbedSetupContext();const availableSteps = useMemo(() => {@@ -19,6 +25,23 @@ export function useSdkIframeEmbedNavigation() {const nextStep = availableSteps[currentIndex + 1];+ match(currentStep)+ .with("select-embed-experience", () => {+ trackEmbedWizardExperienceCompleted(+ experience,+ defaultSettings.experience,+ );+ })+ .with("select-embed-resource", () => {+ trackEmbedWizardResourceSelectionCompleted(+ settings,+ defaultSettings.resourceId,+ );+ })+ .with("select-embed-options", () => {+ trackEmbedWizardOptionsCompleted(settings, experience);+ });+if (nextStep) {setCurrentStep(nextStep.id);}diff --git a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/utils/default-embed-setting.ts b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/utils/default-embed-setting.tsindex 1407f79fbb3..33905e19b68 100644--- a/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/utils/default-embed-setting.ts+++ b/enterprise/frontend/src/metabase-enterprise/embedding_iframe_sdk_setup/utils/default-embed-setting.ts@@ -1,4 +1,4 @@-import { match } from "ts-pattern";+import { P, match } from "ts-pattern";import type {BrowserEmbedOptions,@@ -61,3 +61,22 @@ export const getDefaultSdkIframeEmbedSettings = (useExistingUserSession: true,};};++export const getResourceIdFromSettings = (+ settings: SdkIframeEmbedSetupSettings,+): string | number | undefined =>+ match(settings)+ .with({ initialCollection: P.nonNullable }, (s) => s.initialCollection)+ .with({ dashboardId: P.nonNullable }, (s) => s.dashboardId)+ .with({ questionId: P.nonNullable }, (s) => s.questionId)+ .otherwise(() => undefined);++export const getExperienceFromSettings = (+ settings: SdkIframeEmbedSetupSettings,+): SdkIframeEmbedSetupExperience =>+ match<SdkIframeEmbedSetupSettings, SdkIframeEmbedSetupExperience>(settings)+ .with({ template: "exploration" }, () => "exploration")+ .with({ componentName: "metabase-question" }, () => "chart")+ .with({ componentName: "metabase-browser" }, () => "browser")+ .with({ componentName: "metabase-dashboard" }, () => "dashboard")+ .exhaustive();diff --git a/frontend/src/metabase-types/analytics/event.ts b/frontend/src/metabase-types/analytics/event.tsindex 136f17be399..905124b678d 100644--- a/frontend/src/metabase-types/analytics/event.ts+++ b/frontend/src/metabase-types/analytics/event.ts@@ -226,29 +226,28 @@ export type SdkIframeEmbedSetupExperience =| "exploration"| "browser";-export type EmbedWizardExperienceSelectedEvent = ValidateEvent<{- event: "embed_wizard_experience_selected";- event_detail: SdkIframeEmbedSetupExperience;+export type EmbedWizardOpenedEvent = ValidateEvent<{+ event: "embed_wizard_opened";}>;-export type EmbedWizardResourceSelectedEvent = ValidateEvent<{- event: "embed_wizard_resource_selected";- event_detail: SdkIframeEmbedSetupExperience;- target_id: number;+export type EmbedWizardExperienceCompletedEvent = ValidateEvent<{+ event: "embed_wizard_experience_completed";+ event_detail: "default" | `custom=${SdkIframeEmbedSetupExperience}`;}>;-export type EmbedWizardOptionChangedEvent = ValidateEvent<{- event: "embed_wizard_option_changed";- event_detail: string;+export type EmbedWizardResourceSelectionCompletedEvent = ValidateEvent<{+ event: "embed_wizard_resource_selection_completed";+ event_detail: "default" | "custom";}>;-export type EmbedWizardAuthSelectedEvent = ValidateEvent<{- event: "embed_wizard_auth_selected";- event_detail: "sso" | "user-session";+export type EmbedWizardOptionsCompletedEvent = ValidateEvent<{+ event: "embed_wizard_options_completed";+ event_detail: string;}>;export type EmbedWizardCodeCopiedEvent = ValidateEvent<{event: "embed_wizard_code_copied";+ event_detail: "sso" | "user_session";}>;export type TableEditingSettingsToggledEvent = ValidateEvent<{@@ -381,10 +380,10 @@ export type XRaySavedEvent = ValidateEvent<{export type XRayEvent = XRayClickedEvent | XRaySavedEvent;export type EmbedWizardEvent =- | EmbedWizardExperienceSelectedEvent- | EmbedWizardResourceSelectedEvent- | EmbedWizardOptionChangedEvent- | EmbedWizardAuthSelectedEvent+ | EmbedWizardOpenedEvent+ | EmbedWizardExperienceCompletedEvent+ | EmbedWizardResourceSelectionCompletedEvent+ | EmbedWizardOptionsCompletedEvent| EmbedWizardCodeCopiedEvent;export type TableEditingEvent =