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
Correct interactive embed query execution count (#65336)
Mahatthana (Kelvin) Nomsawadicbf7579c4c0f
diff --git a/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js b/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.jsindex 331a838b953..82a3a6ff29f 100644--- a/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js+++ b/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js@@ -774,6 +774,15 @@ describe("scenarios > embedding > dashboard appearance", () => {cy.findByRole("tab", { name: "Look and Feel" }).click();cy.get("@previewEmbedSpy").should("have.callCount", 1);+ cy.log(+ 'Embed preview requests should not have "X-Metabase-Client: embedding-iframe" header (EMB-930)',+ );+ cy.get("@previewEmbed").then(({ request }) => {+ expect(request?.headers?.["x-metabase-client"]).to.not.equal(+ "embedding-iframe",+ );+ });+cy.log("Assert dashboard theme");H.getIframeBody().findByTestId("embed-frame")diff --git a/frontend/src/metabase/lib/api.js b/frontend/src/metabase/lib/api.jsindex 0a03d8813ec..5d36d7938d5 100644--- a/frontend/src/metabase/lib/api.js+++ b/frontend/src/metabase/lib/api.js@@ -5,6 +5,8 @@ import { isTest } from "metabase/env";import { isWithinIframe } from "metabase/lib/dom";import { delay } from "metabase/lib/promise";+import { IS_EMBED_PREVIEW } from "./embed";+const ONE_SECOND = 1000;const MAX_RETRIES = 10;@@ -70,16 +72,18 @@ export class Api extends EventEmitter {headers["X-Metabase-Session"] = self.sessionToken;}- // For simple embedding, we use "embedding-simple" instead of "embedding-iframe"- const isSimpleEmbedHeader =- typeof self.requestClient === "object" &&- self.requestClient.name === "embedding-simple";-- if (isWithinIframe() && !isSimpleEmbedHeader) {+ if (isWithinIframe() && !self.requestClient) {// eslint-disable-next-line no-literal-metabase-strings -- Not a user facing stringheaders["X-Metabase-Embedded"] = "true";- // eslint-disable-next-line no-literal-metabase-strings -- Not a user facing string- headers["X-Metabase-Client"] = "embedding-iframe";+ /**+ * We counted static embed preview query executions which led to wrong embedding stats (EMB-930)+ * This header is only used for analytics and for checking if we want to disable some features in the+ * embedding iframe (only for Documents at the time of this comment)+ */+ if (!IS_EMBED_PREVIEW) {+ // eslint-disable-next-line no-literal-metabase-strings -- Not a user facing string+ headers["X-Metabase-Client"] = "embedding-iframe";+ }}if (self.requestClient) {