Skip to content

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

Enhance usage analytics for embedding (#71386)

bryanbfe71297dcc8
diff --git a/.clj-kondo/config/modules/config.edn b/.clj-kondo/config/modules/config.edn
index bd17345a57c..2115d88c8b7 100644
--- a/.clj-kondo/config/modules/config.edn
+++ b/.clj-kondo/config/modules/config.edn
@@ -181,6 +181,7 @@
:api #{metabase.analytics.api
metabase.analytics.core
metabase.analytics.init
+ metabase.analytics.settings
metabase.analytics.snowplow}
:uses #{analytics-interface
api
@@ -194,6 +195,7 @@
models
permissions
premium-features
+ request
session
settings
sso
@@ -1793,8 +1795,10 @@
request
{:team "UX West"
:api #{metabase.request.core
+ metabase.request.current
metabase.request.init
- metabase.request.schema}
+ metabase.request.schema
+ metabase.request.user-agent}
:uses #{analytics-interface
api
config
diff --git a/dev/src/dev/spy_handler_middleware.clj b/dev/src/dev/spy_handler_middleware.clj
new file mode 100644
index 00000000000..c7f28306f7a
--- /dev/null
+++ b/dev/src/dev/spy_handler_middleware.clj
@@ -0,0 +1,35 @@
+(ns dev.spy-handler-middleware)
+
+(def ^:private my-spy-atom (atom []))
+
+(defn- spy-mw
+ [context handler]
+ (fn
+ [request respond raise]
+ (swap! my-spy-atom conj [context request])
+ (handler request respond raise)))
+
+(defn apply-spy-middleware
+ "Given a middleware stack, return a new middleware stack that has a spy middleware at the start, end,
+ and interleaved between each middleware.
+
+ Call this on a middleware stack, e.g. [[metabase.server.handler/middleware]]. A new middleware stack
+ will be returned. Use that middleware stack to start your server, and each request step
+ will be recorded in [[my-spy-atom]]"
+ [original-middlewares]
+ (concat (interleave
+ (map (fn [mw]
+ (partial spy-mw (str "after-" (:name (meta mw)))))
+ original-middlewares)
+ original-middlewares)
+ [(partial spy-mw "initial-request")]))
+
+(comment
+ (require 'dev.spy-handler-middleware)
+ (mu/defn- apply-middleware :- ::api.macros/handler
+ [handler :- ::api.macros/handler]
+ (reduce
+ (fn [handler middleware-fn]
+ (middleware-fn handler))
+ handler
+ (dev.spy-handler-middleware/apply-spy-middleware middleware))))
diff --git a/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js b/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js
index 78940e2a3e8..c4d919de9fd 100644
--- a/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js
+++ b/e2e/test/scenarios/embedding/embedding-dashboard.cy.spec.js
@@ -641,7 +641,7 @@ describe("scenarios > embedding > dashboard parameters", () => {
cy.wait("@getEmbeddedDashboard").then(({ request }) => {
expect(request?.headers?.["x-metabase-client"]).to.equal(
- "embedding-iframe",
+ "embedding-iframe-static",
);
});
});
diff --git a/e2e/test/scenarios/embedding/interactive-embedding.cy.spec.js b/e2e/test/scenarios/embedding/interactive-embedding.cy.spec.js
index 10275a83791..28e585d87dd 100644
--- a/e2e/test/scenarios/embedding/interactive-embedding.cy.spec.js
+++ b/e2e/test/scenarios/embedding/interactive-embedding.cy.spec.js
@@ -226,7 +226,7 @@ describe("scenarios > embedding > full app", () => {
cy.wait("@getCardQuery").then(({ request }) => {
expect(request?.headers?.["x-metabase-client"]).to.equal(
- "embedding-iframe",
+ "embedding-iframe-full-app",
);
});
});
@@ -1767,7 +1767,7 @@ describe("scenarios > embedding > full app", () => {
cy.wait("@getDashboard").then(({ request }) => {
expect(request?.headers?.["x-metabase-client"]).to.equal(
- "embedding-iframe",
+ "embedding-iframe-full-app",
);
});
});
diff --git a/e2e/test/scenarios/embedding/sdk-iframe-embedding/authentication.cy.spec.ts b/e2e/test/scenarios/embedding/sdk-iframe-embedding/authentication.cy.spec.ts
index 46e2844fef1..4433b6cbdf4 100644
--- a/e2e/test/scenarios/embedding/sdk-iframe-embedding/authentication.cy.spec.ts
+++ b/e2e/test/scenarios/embedding/sdk-iframe-embedding/authentication.cy.spec.ts
@@ -41,7 +41,7 @@ describe("scenarios > embedding > sdk iframe embedding > authentication", () =>
"instanceUrl": "http://localhost:4000",
});
</script>
- <metabase-dashboard dashboard-id='9' />
+ <metabase-dashboard dashboard-id='${ORDERS_DASHBOARD_ID}' />
</body>
</html>
`);
@@ -75,7 +75,7 @@ describe("scenarios > embedding > sdk iframe embedding > authentication", () =>
"jwtProviderUri": "http://auth-provider/sso?response=json",
});
</script>
- <metabase-dashboard dashboard-id='9' />
+ <metabase-dashboard dashboard-id='${ORDERS_DASHBOARD_ID}' />
</body>
</html>
`);
diff --git a/e2e/test/scenarios/question/new.cy.spec.js b/e2e/test/scenarios/question/new.cy.spec.js
index 57a06117f83..08dfaec3b19 100644
--- a/e2e/test/scenarios/question/new.cy.spec.js
+++ b/e2e/test/scenarios/question/new.cy.spec.js
@@ -562,7 +562,7 @@ describe("scenarios > question > new", () => {
H.entityPickerModal()
.button(/Select/)
.click();
- cy.location("pathname").should("eq", "/dashboard/12-new-dashboard");
+ cy.location("pathname").should("eq", "/dashboard/13-new-dashboard");
});
it("when selecting a collection with no child dashboards (metabase#47000)", () => {
@@ -593,7 +593,7 @@ describe("scenarios > question > new", () => {
H.entityPickerModal()
.button(/Select/)
.click();
- cy.location("pathname").should("eq", "/dashboard/12-new-dashboard");
+ cy.location("pathname").should("eq", "/dashboard/13-new-dashboard");
});
it("when a dashboard is currently selected", () => {
@@ -618,7 +618,7 @@ describe("scenarios > question > new", () => {
H.entityPickerModal()
.button(/Select/)
.click();
- cy.location("pathname").should("eq", "/dashboard/12-new-dashboard");
+ cy.location("pathname").should("eq", "/dashboard/13-new-dashboard");
});
});
});
diff --git a/enterprise/backend/src/metabase_enterprise/audit_app/analytics_dev.clj b/enterprise/backend/src/metabase_enterprise/audit_app/analytics_dev.clj
index 6dace2ebd5a..29b1e4d9976 100644
--- a/enterprise/backend/src/metabase_enterprise/audit_app/analytics_dev.clj
+++ b/enterprise/backend/src/metabase_enterprise/audit_app/analytics_dev.clj
@@ -197,7 +197,8 @@
(log/info "Exporting dev collection" collection-id "to" temp-path)
(try
(let [opts {:targets (serialization/make-targets-of-type "Collection" [collection-id])
- :no-settings true :no-transforms true}
+ :no-settings true :no-transforms true
+ :include-field-values true}
report (serdes/with-cache (serialization/store! (serialization/extract opts)
(serialization/file-writer (.getPath temp-path))))]
(log/info "Export complete:" (count (:seen report)) "entities exported")
@@ -210,6 +211,21 @@
(.delete file))
(throw e)))))
+(defn- keep-only-remapped-pairs
+ "Filter a parsed FieldValues YAML to keep only (value, label) pairs where the label
+ is non-empty. Returns nil if there are no remapped pairs, so the caller can skip
+ writing the file. Prevents exporting raw sample data (IPs, IDs, etc.) for fields
+ that don't have human-readable remaps."
+ [yaml-data]
+ (let [values (:values yaml-data)
+ labels (:human_readable_values yaml-data)
+ pairs (map vector values labels)
+ remaps (filter (fn [[_ label]] (and (some? label) (not= "" label))) pairs)]
+ (when (seq remaps)
+ (assoc yaml-data
+ :values (mapv first remaps)
+ :human_readable_values (mapv second remaps)))))
+
(defn- transform-exported-yamls!
"Transform exported YAMLs from dev format back to canonical.
@@ -229,11 +245,15 @@
(let [relative-path (str/replace (.getPath file)
(str (.getPath (io/file export-dir)) "/")
"")
- target-file (io/file target-dir relative-path)]
- (.mkdirs (.getParentFile target-file))
- (let [yaml-data (yaml/parse-string (slurp file))
- transformed (yaml->canonical (.getName file) yaml-data user-email)]
- (spit target-file (yaml/generate-string transformed))))))
+ target-file (io/file target-dir relative-path)
+ yaml-data (yaml/parse-string (slurp file))
+ filtered (if (.endsWith (.getName file) "___fieldvalues.yaml")
+ (keep-only-remapped-pairs yaml-data)
+ yaml-data)]
+ (when filtered
+ (.mkdirs (.getParentFile target-file))
+ (let [transformed (yaml->canonical (.getName file) filtered user-email)]
+ (spit target-file (yaml/generate-string transformed)))))))
(defn export-analytics-content!
"Export dev collection and transform back to canonical format."
diff --git a/enterprise/backend/src/metabase_enterprise/audit_app/permissions.clj b/enterprise/backend/src/metabase_enterprise/audit_app/permissions.clj
index 8a2c2f22ace..8163a1dc736 100644
--- a/enterprise/backend/src/metabase_enterprise/audit_app/permissions.clj
+++ b/enterprise/backend/src/metabase_enterprise/audit_app/permissions.clj
@@ -26,6 +26,7 @@
"v_fields"
"v_query_log"
"v_tables"
+ "v_tenants"
"v_tasks"
"v_task_runs"
"v_view_log"})
diff --git a/enterprise/backend/src/metabase_enterprise/database_routing/middleware.clj b/enterprise/backend/src/metabase_enterprise/database_routing/middleware.clj
index bb4506fa873..9774971e597 100644
--- a/enterprise/backend/src/metabase_enterprise/database_routing/middleware.clj
+++ b/enterprise/backend/src/metabase_enterprise/database_routing/middleware.clj
@@ -15,6 +15,13 @@
[metabase.util :as u]
[metabase.util.i18n :refer [tru]]))
+(def ^:dynamic *destination-database-id*
+ "Bound to the destination database id during query execution when DB routing has swapped in a destination DB.
+ Mirrors the shape of [[metabase-enterprise.impersonation.driver/*impersonation-role*]]: analytics code reads it
+ from inside the postprocessing rff to record `is_db_routed` and the routed `database_id` on the
+ `query_execution` row."
+ nil)
+
(defenterprise swap-destination-db
"Must be the last middleware before we actually hit the database. If a Router Database is specified, swaps out the
Metadata Provider for one that has the appropriate destination database."
@@ -27,12 +34,25 @@
(binding [qp.store/*DANGER-allow-replacing-metadata-provider* true]
(qp.store/with-metadata-provider (u/id current-database)
(rff metadata))))]
- (binding [qp.store/*DANGER-allow-replacing-metadata-provider* true]
+ (binding [qp.store/*DANGER-allow-replacing-metadata-provider* true
+ *destination-database-id* destination-db-id]
(qp.store/with-metadata-provider destination-db-id
(with-database-routing-on
(qp query rff*)))))
(qp query rff))))
+(defenterprise currently-db-routed?
+ "True when DB routing has swapped in a destination DB for the current query."
+ :feature :none
+ []
+ (some? *destination-database-id*))
+
+(defenterprise currently-destination-database-id
+ "Destination DB id when DB routing has swapped one in for the current query, else nil."
+ :feature :none
+ []
+ *destination-database-id*)
+
(defenterprise attach-destination-db-middleware
"Pre-processing middleware. Calculates the destination database that should be used for this query, e.g. for caching
purposes. Does not make any changes to the query besides (possibly) adding a `:destination-database/id` key."
diff --git a/enterprise/backend/src/metabase_enterprise/impersonation/middleware.clj b/enterprise/backend/src/metabase_enterprise/impersonation/middleware.clj
index 8184b717f2f..aca331556a6 100644
--- a/enterprise/backend/src/metabase_enterprise/impersonation/middleware.clj
+++ b/enterprise/backend/src/metabase_enterprise/impersonation/middleware.clj
@@ -25,7 +25,7 @@
query))
(defenterprise apply-impersonation-postprocessing
- "Post-processing middleware. Binds the dynamic var"
+ "Post-processing middleware. Binds the impersonation role dynamic var for driver use."
;; run this even when the `:advanced-permissions` feature is not enabled, so that we can assert that it *is* enabled
;; if impersonation is configured. (Throwing here is better than silently ignoring the configured impersonation.)
:feature :none
@@ -37,3 +37,9 @@
(binding [impersonation.driver/*impersonation-role* role]
(qp query rff)))
(qp query rff))))
+
+(defenterprise currently-impersonated?
+ "True when a connection-impersonation role is bound for the current query."
+ :feature :none
+ []
+ (some? impersonation.driver/*impersonation-role*))
diff --git a/enterprise/backend/src/metabase_enterprise/tenants/api.clj b/enterprise/backend/src/metabase_enterprise/tenants/api.clj
index e281b3f56a4..3853b60b039 100644
--- a/enterprise/backend/src/metabase_enterprise/tenants/api.clj
+++ b/enterprise/backend/src/metabase_enterprise/tenants/api.clj
@@ -8,7 +8,6 @@
[metabase.collections.models.collection :as collection]
[metabase.events.core :as events]
[metabase.request.core :as request]
- [metabase.util :as u]
[metabase.util.i18n :refer [deferred-tru]]
[metabase.util.malli :as mu]
[metabase.util.malli.registry :as mr]
@@ -50,9 +49,9 @@
(api/check-403 api/*is-superuser?*)
(api/check-400 (not (tenant/tenant-exists? tenant))
"This tenant name or slug is already taken.")
- (u/prog1 (present-tenant
- (t2/insert-returning-instance! :model/Tenant tenant))
- (events/publish-event! :event/tenant-create {:object <>})))
+ (let [new-tenant (t2/insert-returning-instance! :model/Tenant tenant)]
+ (events/publish-event! :event/tenant-create {:object new-tenant})
+ (present-tenant new-tenant)))
(api.macros/defendpoint :post "/" :- Tenant
"Create a new Tenant"
diff --git a/enterprise/backend/src/metabase_enterprise/tenants/models.clj b/enterprise/backend/src/metabase_enterprise/tenants/models.clj
index 86d80eaddd6..27cda602553 100644
--- a/enterprise/backend/src/metabase_enterprise/tenants/models.clj
+++ b/enterprise/backend/src/metabase_enterprise/tenants/models.clj
@@ -16,7 +16,7 @@
(defmethod audit-app/model-details :model/Tenant
[entity _event-type]
- (select-keys entity [:name :slug :is_active]))
+ (select-keys entity [:name :slug :is_active :attributes]))
(t2/deftransforms :model/Tenant
{:attributes mi/transform-json-no-keywordization})
diff --git a/enterprise/backend/test/metabase_enterprise/audit_app/analytics_dev_test.clj b/enterprise/backend/test/metabase_enterprise/audit_app/analytics_dev_test.clj
index f03e02d9b3e..b62a83745f8 100644
--- a/enterprise/backend/test/metabase_enterprise/audit_app/analytics_dev_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/audit_app/analytics_dev_test.clj
@@ -1,14 +1,17 @@
(ns metabase-enterprise.audit-app.analytics-dev-test
(:require
[clojure.set :as set]
- [clojure.test :refer [deftest is testing]]
+ [clojure.test :refer [deftest is testing use-fixtures]]
[metabase-enterprise.audit-app.analytics-dev :as analytics-dev]
[metabase-enterprise.audit-app.audit :as ee-audit]
[metabase.app-db.core :as mdb]
[metabase.driver :as driver]
[metabase.test :as mt]
+ [metabase.test.fixtures :as fixtures]
[toucan2.core :as t2]))
+(use-fixtures :once (fixtures/initialize :db))
+
(deftest postgres-only-requirement-test
(testing "Analytics dev mode requires PostgreSQL"
(when-not (= :postgres (mdb/db-type))
@@ -140,7 +143,14 @@
"is_native" "query_source" "error" "user_id" "card_id"
"card_qualified_id" "dashboard_id" "dashboard_qualified_id"
"pulse_id" "database_id" "database_qualified_id" "cache_hit"
- "action_id" "action_qualified_id" "query"}
+ "action_id" "action_qualified_id"
+ "transform_id" "transform_qualified_id"
+ "lens_id" "lens_params" "query"
+ "embedding_client" "embedding_route" "embedding_sdk_version" "is_preview"
+ "auth_method" "is_sandboxed" "is_impersonated" "is_db_routed" "parameters"
+ "tenant_id" "embedding_hostname" "embedding_path"
+ "user_agent" "sanitized_user_agent" "ip_address"
+ "metabase_version"}
"v_subscriptions" #{"entity_id" "entity_qualified_id" "created_at" "updated_at"
"creator_id" "archived" "dashboard_qualified_id" "schedule_type"
@@ -159,12 +169,22 @@
"started_at" "ended_at" "duration_seconds" "status"
"process_uuid" "updated_at"}
+ "v_tenants" #{"tenant_id" "entity_qualified_id" "name" "slug" "is_active"
+ "attributes" "created_at" "updated_at"
+ "tenant_collection_id" "tenant_collection_qualified_id"}
+
"v_users" #{"user_id" "entity_qualified_id" "type" "email" "first_name"
"last_name" "full_name" "date_joined" "last_login" "updated_at"
- "is_admin" "is_active" "sso_source" "locale"}
+ "is_admin" "is_active" "sso_source" "locale"
+ "tenant_id" "tenant_qualified_id"}
"v_view_log" #{"id" "timestamp" "user_id" "entity_type" "entity_id"
- "entity_qualified_id"}})
+ "entity_qualified_id"
+ "has_access" "context"
+ "embedding_client" "embedding_route" "embedding_sdk_version" "is_preview"
+ "auth_method" "tenant_id"
+ "embedding_hostname" "embedding_path" "user_agent" "sanitized_user_agent" "ip_address"
+ "metabase_version"}})
(defn- get-synced-field-names
"Get the set of field names that Metabase has synced for a given table."
diff --git a/enterprise/backend/test/metabase_enterprise/database_routing/query_execution_test.clj b/enterprise/backend/test/metabase_enterprise/database_routing/query_execution_test.clj
new file mode 100644
index 00000000000..6b1c9f84837
--- /dev/null
+++ b/enterprise/backend/test/metabase_enterprise/database_routing/query_execution_test.clj
@@ -0,0 +1,51 @@
+(ns ^:mb/driver-tests metabase-enterprise.database-routing.query-execution-test
+ "Integration tests that verify `is_db_routed` is recorded on `:model/QueryExecution` rows when a query is routed
+ to a destination database via DB routing. Drives a full userland query through the QP and inspects the persisted
+ row."
+ (:require
+ [clojure.test :refer :all]
+ [metabase-enterprise.database-routing.e2e-test :as e2e]
+ [metabase-enterprise.test :as met]
+ [metabase.driver.settings :as driver.settings]
+ [metabase.query-processor :as qp]
+ [metabase.query-processor.util :as qp.util]
+ [metabase.sync.core :as sync]
+ [metabase.test :as mt]
+ [metabase.util :as u]
+ [toucan2.core :as t2]))
+
+(defn- latest-query-execution []
+ (t2/select-one :model/QueryExecution {:order-by [[:id :desc]]}))
+
+(deftest is-db-routed-true-when-routed-to-destination-test
+ (mt/with-premium-features #{:database-routing}
+ (binding [driver.settings/*allow-testing-h2-connections* true
+ qp.util/*execute-async?* false]
+ (met/with-user-attributes! :rasta {"db_name" "destination-db"}
+ (e2e/with-temp-dbs! [router-db destination-db]
+ (t2/update! :model/Database (u/the-id destination-db)
+ {:name "destination-db" :router_database_id (u/the-id router-db)})
+ (sync/sync-database! router-db)
+ (mt/with-temp [:model/DatabaseRouter _ {:database_id (u/the-id router-db)
+ :user_attribute "db_name"}]
+ (e2e/execute-statement! destination-db "INSERT INTO \"my_database_name\" (str) VALUES ('hi')")
+ (mt/with-model-cleanup [:model/QueryExecution]
+ (mt/with-test-user :rasta
+ (qp/process-query
+ (qp/userland-query
+ {:database (u/the-id router-db)
+ :type :query
+ :query {:source-table (t2/select-one-pk :model/Table :db_id (u/the-id router-db))}}
+ {:context :question})))
+ (let [qe (latest-query-execution)]
+ (is (true? (:is_db_routed qe))
+ "QueryExecution.is_db_routed should be true when query was routed to a destination DB")
+ (is (= (u/the-id destination-db) (:database_id qe))
+ "QueryExecution.database_id should be the destination DB id, not the router DB id")))))))))
+
+(deftest is-db-routed-false-without-routing-test
+ (mt/with-model-cleanup [:model/QueryExecution]
+ (binding [qp.util/*execute-async?* false]
+ (mt/with-test-user :rasta
+ (qp/process-query (qp/userland-query (mt/mbql-query venues {:limit 1}) {:context :question}))
+ (is (false? (:is_db_routed (latest-query-execution))))))))
diff --git a/enterprise/backend/test/metabase_enterprise/impersonation/query_execution_test.clj b/enterprise/backend/test/metabase_enterprise/impersonation/query_execution_test.clj
new file mode 100644
index 00000000000..9fd6b156af2
--- /dev/null
+++ b/enterprise/backend/test/metabase_enterprise/impersonation/query_execution_test.clj
@@ -0,0 +1,32 @@
+(ns metabase-enterprise.impersonation.query-execution-test
+ "Integration tests that verify `is_impersonated` is recorded on `:model/QueryExecution` rows when a query runs
+ under an active connection-impersonation policy. Distinct from [[metabase-enterprise.impersonation.driver-test]]
+ which tests role resolution; here we drive a full userland query through the QP and inspect the persisted row."
+ (:require
+ [clojure.test :refer :all]
+ [metabase-enterprise.impersonation.util-test :as impersonation.util-test]
+ [metabase.query-processor :as qp]
+ [metabase.query-processor.util :as qp.util]
+ [metabase.test :as mt]
+ [toucan2.core :as t2]))
+
+(defn- latest-query-execution []
+ (t2/select-one :model/QueryExecution {:order-by [[:id :desc]]}))
+
+(deftest is-impersonated-true-when-impersonation-policy-active-test
+ (mt/with-premium-features #{:advanced-permissions}
+ (mt/with-model-cleanup [:model/QueryExecution]
+ (binding [qp.util/*execute-async?* false]
+ (impersonation.util-test/with-impersonations!
+ {:impersonations [{:db-id (mt/id) :attribute "impersonation_attr"}]
+ :attributes {"impersonation_attr" "impersonation_role"}}
+ (qp/process-query (qp/userland-query (mt/mbql-query venues {:limit 1}) {:context :question}))
+ (is (true? (:is_impersonated (latest-query-execution)))
+ "QueryExecution row should record is_impersonated=true when the query ran under an impersonation policy"))))))
+
+(deftest is-impersonated-false-when-no-policy-test
+ (mt/with-model-cleanup [:model/QueryExecution]
+ (binding [qp.util/*execute-async?* false]
+ (mt/with-test-user :rasta
+ (qp/process-query (qp/userland-query (mt/mbql-query venues {:limit 1}) {:context :question}))
+ (is (false? (:is_impersonated (latest-query-execution))))))))
diff --git a/enterprise/backend/test/metabase_enterprise/tenants/api_test.clj b/enterprise/backend/test/metabase_enterprise/tenants/api_test.clj
index 1094320910d..b8d0f25b690 100644
--- a/enterprise/backend/test/metabase_enterprise/tenants/api_test.clj
+++ b/enterprise/backend/test/metabase_enterprise/tenants/api_test.clj
@@ -742,3 +742,23 @@
(is (false? (t2/select-one-fn :archived :model/Collection :id tenant-collection-id)))
(is (false? (t2/select-one-fn :archived :model/Collection :id child-id)))
(is (false? (t2/select-one-fn :archived :model/Collection :id grandchild-id)))))))))))
+
+(deftest create-tenant-audit-log-test
+ (testing "Creating a tenant records an audit log entry with correct model and details"
+ (mt/with-premium-features #{:tenants :advanced-permissions :audit-app}
+ (mt/with-model-cleanup [:model/Tenant]
+ (let [response (mt/user-http-request :crowberto :post 200 "ee/tenant/"
+ {:name "Audit Tenant"
+ :slug "audit-tenant"
+ :attributes {"department" "engineering"
+ "region" "us-west"}})
+ audit-entry (t2/select-one :model/AuditLog
+ :topic :tenant-create
+ :model_id (:id response))]
+ (is (= "Tenant" (:model audit-entry)))
+ (is (= {:name "Audit Tenant"
+ :slug "audit-tenant"
+ :is_active true
+ :attributes {:department "engineering"
+ :region "us-west"}}
+ (:details audit-entry))))))))
diff --git a/frontend/src/embedding-sdk-bundle/hooks/private/use-init-data/use-init-data-internal.ts b/frontend/src/embedding-sdk-bundle/hooks/private/use-init-data/use-init-data-internal.ts
index c632ec665b1..5ee481c2648 100644
--- a/frontend/src/embedding-sdk-bundle/hooks/private/use-init-data/use-init-data-internal.ts
+++ b/frontend/src/embedding-sdk-bundle/hooks/private/use-init-data/use-init-data-internal.ts
@@ -17,10 +17,28 @@ import { useMetabaseProviderPropsStore } from "embedding-sdk-shared/hooks/use-me
import { ensureMetabaseProviderPropsStore } from "embedding-sdk-shared/lib/ensure-metabase-provider-props-store";
import { getBuildInfo } from "embedding-sdk-shared/lib/get-build-info";
import registerDashboardVisualizations from "metabase/dashboard/visualizations/register";
-import { EMBEDDING_SDK_CONFIG } from "metabase/embedding-sdk/config";
+import {
+ EMBEDDING_SDK_CONFIG,
+ isEmbeddingEajs,
+} from "metabase/embedding-sdk/config";
+import type { OnBeforeRequestHandlerConfig } from "metabase/plugins/oss/api";
import api from "metabase/utils/api";
import registerVisualizations from "metabase/visualizations/register";
+const reactSdkEmbedReferrerHandler = async (
+ config: OnBeforeRequestHandlerConfig,
+): Promise<OnBeforeRequestHandlerConfig | void> => ({
+ ...config,
+ options: {
+ ...config.options,
+ headers: {
+ ...config.options.headers,
+ // eslint-disable-next-line metabase/no-literal-metabase-strings -- header name
+ "X-Metabase-Embed-Referrer": window.location.href,
+ },
+ },
+});
+
const registerVisualizationsOnce = _.once(registerVisualizations);
const registerDashboardVisualizationsOnce = _.once(
registerDashboardVisualizations,
@@ -80,10 +98,21 @@ export const useInitDataInternal = ({
if (!api.requestClient) {
api.requestClient = {
name: EMBEDDING_SDK_CONFIG.metabaseClientRequestHeader,
+ // Note: this is *package* version, it's undefined in EAJS
version: sdkPackageVersion,
};
}
+ // For the React SDK, send the host page URL as the embed referrer in a
+ // header on every request. The EAJS iframe registers its own handler in
+ // SdkIframeEmbedRoute.tsx using the value received via postMessage.
+ if (
+ !isEmbeddingEajs() &&
+ !api.beforeRequestHandlers.includes(reactSdkEmbedReferrerHandler)
+ ) {
+ api.beforeRequestHandlers.push(reactSdkEmbedReferrerHandler);
+ }
+
if (!api.onResponseError) {
api.onResponseError = ({ metabaseVersion }) => {
if (metabaseVersion == null) {
diff --git a/frontend/src/metabase-types/api/settings.ts b/frontend/src/metabase-types/api/settings.ts
index ebea977e590..6710706e67b 100644
--- a/frontend/src/metabase-types/api/settings.ts
+++ b/frontend/src/metabase-types/api/settings.ts
@@ -484,6 +484,7 @@ export type EmbeddingHomepageStatus =
interface AdminSettings {
"active-users-count"?: number;
+ "analytics-pii-retention-enabled"?: boolean;
"custom-geojson-enabled": boolean;
"encryption-enabled": boolean;
"deprecation-notice-version"?: string;
diff --git a/frontend/src/metabase/admin/settings/analytics.ts b/frontend/src/metabase/admin/settings/analytics.ts
index 6540b82c1a3..d68fb473e20 100644
--- a/frontend/src/metabase/admin/settings/analytics.ts
+++ b/frontend/src/metabase/admin/settings/analytics.ts
@@ -1,4 +1,4 @@
-import { trackSchemaEvent } from "metabase/analytics";
+import { trackSchemaEvent, trackSimpleEvent } from "metabase/analytics";
export const trackTrackingPermissionChanged = (isEnabled: boolean) => {
trackSchemaEvent("settings", {
@@ -9,6 +9,14 @@ export const trackTrackingPermissionChanged = (isEnabled: boolean) => {
});
};
+export const trackAnalyticsPiiRetentionChanged = (isEnabled: boolean) => {
+ trackSimpleEvent({
+ event: "analytics_pii_retention_changed",
+ event_detail: isEnabled ? "enabled" : "disabled",
+ triggered_from: "admin",
+ });
+};
+
export const trackCustomHomepageDashboardEnabled = (
source: "admin" | "homepage",
) => {
diff --git a/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.tsx b/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.tsx
index f0b80b0aceb..1c04d618bbd 100644
--- a/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.tsx
+++ b/frontend/src/metabase/admin/settings/components/SettingsPages/GeneralSettingsPage.tsx
@@ -4,6 +4,7 @@ import {
SettingsPageWrapper,
SettingsSection,
} from "metabase/admin/components/SettingsSection";
+import { CollectUserDataInput } from "metabase/admin/settings/components/widgets/UsageTracking/CollectUserDataInput";
import { UpsellDevInstances } from "metabase/admin/upsells";
import { ExternalLink } from "metabase/common/components/ExternalLink";
import { useDocsUrl, useHasTokenFeature } from "metabase/common/hooks";
@@ -11,10 +12,10 @@ import { PLUGIN_LANDING_PAGE, PLUGIN_SEMANTIC_SEARCH } from "metabase/plugins";
import { DevInstanceBanner } from "../GeneralSettings/DevInstanceBanner";
import { AdminSettingInput } from "../widgets/AdminSettingInput";
-import { AnonymousTrackingInput } from "../widgets/AnonymousTrackingInput";
import { CustomHomepageDashboardSetting } from "../widgets/CustomHomepageDashboardSetting";
import { HttpsOnlyWidget } from "../widgets/HttpsOnlyWidget";
import { SiteUrlWidget } from "../widgets/SiteUrlWidget";
+import { AnonymousTrackingInput } from "../widgets/UsageTracking/AnonymousTrackingInput";
export function GeneralSettingsPage() {
const { url: iframeDocsUrl } = useDocsUrl("configuring-metabase/settings", {
@@ -45,16 +46,12 @@ export function GeneralSettingsPage() {
<PLUGIN_LANDING_PAGE.LandingPageWidget />
</SettingsSection>
- <SettingsSection
- title={enableAnonymousTracking ? t`Email and tracking` : t`Email`}
- >
+ <SettingsSection title={t`Email`}>
<AdminSettingInput
name="admin-email"
title={t`Email address for help requests`}
inputType="text"
/>
-
- {enableAnonymousTracking && <AnonymousTrackingInput />}
</SettingsSection>
<SettingsSection title={t`Tables, X-Rays and domains`}>
@@ -88,6 +85,13 @@ export function GeneralSettingsPage() {
inputType="textarea"
/>
</SettingsSection>
+
+ <SettingsSection title={t`Usage tracking`}>
+ {enableAnonymousTracking && <AnonymousTrackingInput />}
+
+ <CollectUserDataInput />
+ </SettingsSection>
+
<UpsellDevInstances location="settings-general" />
</SettingsPageWrapper>
);
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 b7a12c6a53d..c6848a48d71 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
@@ -29,6 +29,7 @@ const generalSettings = {
"site-url": "https://mysite.biz",
"admin-email": "[email protected]",
"anon-tracking-enabled": false,
+ "analytics-pii-retention-enabled": false,
"redirect-all-requests-to-https": false,
"humanization-strategy": "simple",
"enable-xrays": false,
@@ -90,7 +91,8 @@ describe("GeneralSettingsPage", () => {
"Redirect to HTTPS",
"Custom homepage",
"Email address for help requests",
- "Anonymous tracking",
+ "Send anonymous tracking data to Metabase",
+ "Collect user data to display in usage analytics",
"Friendly table and field names",
"Enable X-Ray features",
"Allowed domains for iframes in dashboards",
@@ -167,12 +169,16 @@ describe("GeneralSettingsPage", () => {
it("should show Anonymous Tracking input for non-cloud plans", async () => {
await setup({ isCloudPlan: false });
- expect(screen.getByText("Anonymous tracking")).toBeInTheDocument();
+ expect(
+ screen.getByText("Send anonymous tracking data to Metabase"),
+ ).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();
+ expect(
+ screen.queryByText("Send anonymous tracking data to Metabase"),
+ ).not.toBeInTheDocument();
});
});
diff --git a/frontend/src/metabase/admin/settings/components/widgets/AdminSettingInput.tsx b/frontend/src/metabase/admin/settings/components/widgets/AdminSettingInput.tsx
index f684e289c6b..a6d11d947d5 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/AdminSettingInput.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/AdminSettingInput.tsx
@@ -1,6 +1,7 @@
import { useEffect, useState } from "react";
import { jt, t } from "ttag";
+import { isSettingSetFromEnvVar } from "metabase/admin/settings/settings";
import { useAdminSetting } from "metabase/api/utils";
import { ExternalLink } from "metabase/common/components/ExternalLink";
import { useDocsUrl } from "metabase/common/hooks";
@@ -285,11 +286,7 @@ export function SetByEnvVarWrapper<SettingName extends SettingKey>({
settingDetails,
children,
}: SetByEnvVarWrapperProps<SettingName>) {
- if (
- settingDetails &&
- settingDetails?.is_env_setting &&
- settingDetails?.env_name
- ) {
+ if (isSettingSetFromEnvVar(settingDetails)) {
return (
<Box mb="lg">
<SettingHeader
diff --git a/frontend/src/metabase/admin/settings/components/widgets/AnonymousTrackingInput.tsx b/frontend/src/metabase/admin/settings/components/widgets/AnonymousTrackingInput.tsx
deleted file mode 100644
index 2fd8211442b..00000000000
--- a/frontend/src/metabase/admin/settings/components/widgets/AnonymousTrackingInput.tsx
+++ /dev/null
@@ -1,53 +0,0 @@
-import { t } from "ttag";
-
-import { useAdminSetting } from "metabase/api/utils";
-import { Stack } from "metabase/ui";
-
-import { trackTrackingPermissionChanged } from "../../analytics";
-import { SettingHeader } from "../SettingHeader";
-
-import {
- BasicAdminSettingInput,
- SetByEnvVarWrapper,
-} from "./AdminSettingInput";
-
-export function AnonymousTrackingInput() {
- const { value, updateSetting, description, settingDetails } = useAdminSetting(
- "anon-tracking-enabled",
- );
-
- const handleChange = async (newValue: boolean) => {
- if (value) {
- // if we're changing this getting turned off, we need to track it before it's changed
- trackTrackingPermissionChanged(newValue);
- }
- await updateSetting({
- key: "anon-tracking-enabled",
- value: newValue,
- });
- if (newValue) {
- trackTrackingPermissionChanged(newValue);
- }
- };
-
- return (
- <Stack>
- <SettingHeader
- id="anon-tracking-enabled"
- title={t`Anonymous tracking`}
- description={description}
- />
- <SetByEnvVarWrapper
- settingKey="anon-tracking-enabled"
- settingDetails={settingDetails}
- >
- <BasicAdminSettingInput
- name="anon-tracking-enabled"
- inputType="boolean"
- value={value}
- onChange={(newValue) => handleChange(Boolean(newValue))}
- />
- </SetByEnvVarWrapper>
- </Stack>
- );
-}
diff --git a/frontend/src/metabase/admin/settings/components/widgets/UsageTracking/AnonymousTrackingInput.tsx b/frontend/src/metabase/admin/settings/components/widgets/UsageTracking/AnonymousTrackingInput.tsx
new file mode 100644
index 00000000000..febe0b18499
--- /dev/null
+++ b/frontend/src/metabase/admin/settings/components/widgets/UsageTracking/AnonymousTrackingInput.tsx
@@ -0,0 +1,15 @@
+import { t } from "ttag";
+
+import { trackTrackingPermissionChanged } from "../../../analytics";
+
+import { BaseUsageTrackingSettingToggle } from "./BaseUsageTrackingSettingToggle";
+
+export function AnonymousTrackingInput() {
+ return (
+ <BaseUsageTrackingSettingToggle
+ settingName="anon-tracking-enabled"
+ title={t`Send anonymous tracking data to Metabase`}
+ trackChange={trackTrackingPermissionChanged}
+ />
+ );
+}
diff --git a/frontend/src/metabase/admin/settings/components/widgets/AnonymousTrackingInput.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/widgets/UsageTracking/AnonymousTrackingInput.unit.spec.tsx
similarity index 84%
rename from frontend/src/metabase/admin/settings/components/widgets/AnonymousTrackingInput.unit.spec.tsx
rename to frontend/src/metabase/admin/settings/components/widgets/UsageTracking/AnonymousTrackingInput.unit.spec.tsx
index e705f7ea808..21b15fc255b 100644
--- a/frontend/src/metabase/admin/settings/components/widgets/AnonymousTrackingInput.unit.spec.tsx
+++ b/frontend/src/metabase/admin/settings/components/widgets/UsageTracking/AnonymousTrackingInput.unit.spec.tsx
@@ -13,12 +13,15 @@ import {
createMockSettings,
} from "metabase-types/api/mocks";
-import * as analytics from "../../analytics";
+import * as analytics from "../../../analytics";
import { AnonymousTrackingInput } from "./AnonymousTrackingInput";
const trackingFN = jest.spyOn(analytics, "trackTrackingPermissionChanged");
+const SETTING_NAME = "anon-tracking-enabled";
+const SETTING_ENV_VAR_NAME = "MB_ANON_TRACKING_ENABLED";
+
const setup = ({
value,
isEnvSetting,
@@ -27,18 +30,18 @@ const setup = ({
isEnvSetting?: boolean;
}) => {
const settings = createMockSettings({
- "anon-tracking-enabled": value,
+ [SETTING_NAME]: value,
});
setupPropertiesEndpoints(settings);
setupUpdateSettingEndpoint();
setupSettingsEndpoints([
createMockSettingDefinition({
- key: "anon-tracking-enabled",
+ key: SETTING_NAME,
description: "Enable the collection of anonymous usage data",
value: false,
is_env_setting: isEnvSetting,
- env_name: isEnvSetting ? "MB_ANON_TRACKING_ENABLED" : undefined,
+ env_name: isEnvSetting ? SETTING_ENV_VAR_NAME : undefined,
}),
]);
@@ -53,7 +56,9 @@ const setup = ({
describe("AnonymousTrackingInput", () => {
it("should show an anonymous tracking toggle", async () => {
setup({ value: true });
- expect(await screen.findByText("Anonymous tracking")).toBeInTheDocument();
+ expect(
+ await screen.findByText("Send anonymous tracking data to Metabase"),
+ ).toBeInTheDocument();
expect(
await screen.findByText(/Enable the collection of anonymous usage data/),
).toBeInTheDocument();
@@ -66,7 +71,7 @@ describe("AnonymousTrackingInput", () => {
expect(trackingFN).toHaveBeenCalledWith(false);
const [{ url, body }] = await findRequests("PUT");
- expect(url).toMatch(/\/api\/setting\/anon-tracking-enabled/);
+ expect(url).toMatch(new RegExp(`/api/setting/${SETTING_NAME}`));
expect(body).toEqual({ value: false });
expect(await screen.findByRole("switch")).not.toBeChecked();
@@ -77,7 +82,7 @@ describe("AnonymousTrackingInput", () => {
await userEvent.click(screen.getByRole("switch"));
const [{ url, body }] = await findRequests("PUT");
- expect(url).toMatch(/\/api\/setting\/anon-tracking-enabled/);
+ expect(url).toMatch(new RegExp(`/api/setting/${SETTING_NAME}`));
expect(body).toEqual({ value: true });
expect(trackingFN).toHaveBeenCalledWith(true);
@@ -89,9 +94,7 @@ describe("AnonymousTrackingInput", () => {
expect(
await screen.findByText(/This has been set by the/),
).toBeInTheDocument();
- expect(
- await screen.findByText("MB_ANON_TRACKING_ENABLED"),
- ).toBeInTheDocument();
+ expect(await screen.findByText(SETTING_ENV_VAR_NAME)).toBeInTheDocument();
});
it("should not show the switch when anonymous tracking is set via env var", async () => {
diff --git a/frontend/src/metabase/admin/settings/components/widgets/UsageTracking/BaseUsageTrackingSettingToggle.tsx b/frontend/src/metabase/admin/settings/components/widgets/UsageTracking/BaseUsageTrackingSettingToggle.tsx
new file mode 100644
index 00000000000..b11f0620830
--- /dev/null
+++ b/frontend/src/metabase/admin/settings/components/widgets/UsageTracking/BaseUsageTrackingSettingToggle.tsx
@@ -0,0 +1,55 @@
+import { isSettingSetFromEnvVar } from "metabase/admin/settings/settings";
+import { useAdminSetting } from "metabase/api/utils";
+import { Stack } from "metabase/ui";
+import type { Settings } from "metabase-types/api";
+
+import { SettingHeader } from "../../SettingHeader";
+import { BasicAdminSettingInput, SetByEnvVar } from "../AdminSettingInput";
+
+interface BaseUsageTrackingSettingToggleProps {
+ settingName: keyof Settings;
+ title: string;
+ trackChange: (isEnabled: boolean) => void;
+}
+
+export function BaseUsageTrackingSettingToggle({
+ settingName,
+ title,
+ trackChange,
+}: BaseUsageTrackingSettingToggleProps) {
+ const { value, updateSetting, description, settingDetails } =
+ useAdminSetting(settingName);
+
+ const handleChange = async (newValue: boolean) => {
+ if (value) {
+ // if we're changing this getting turned off, we need to track it before it's changed
+ trackChange(newValue);
+ }
+
+ await updateSetting({
+ key: settingName,
+ value: newValue,
+ });
+
+ if (newValue) {
+ trackChange(newValue);
+ }
+ };
+
+ return (
+ <Stack>
+ <SettingHeader id={settingName} title={title} description={description} />
+
+ {isSettingSetFromEnvVar(settingDetails) ? (
+ <SetByEnvVar varName={settingDetails.env_name} />
+ ) : (
+ <BasicAdminSettingInput
+ name={settingName}
+ inputType="boolean"
+ value={value}
+ onChange={(newValue) => handleChange(Boolean(newValue))}
+ />
+ )}
+ </Stack>
+ );
+}
diff --git a/frontend/src/metabase/admin/settings/components/widgets/UsageTracking/CollectUserDataInput.tsx b/frontend/src/metabase/admin/settings/components/widgets/UsageTracking/CollectUserDataInput.tsx
new file mode 100644
index 00000000000..81f8673db27
--- /dev/null
+++ b/frontend/src/metabase/admin/settings/components/widgets/UsageTracking/CollectUserDataInput.tsx
@@ -0,0 +1,15 @@
+import { t } from "ttag";
+
+import { trackAnalyticsPiiRetentionChanged } from "../../../analytics";
+
+import { BaseUsageTrackingSettingToggle } from "./BaseUsageTrackingSettingToggle";
+
+export function CollectUserDataInput() {
+ return (
+ <BaseUsageTrackingSettingToggle
+ settingName="analytics-pii-retention-enabled"
+ title={t`Collect user data to display in usage analytics`}
+ trackChange={trackAnalyticsPiiRetentionChanged}
+ />
+ );
+}
diff --git a/frontend/src/metabase/admin/settings/components/widgets/UsageTracking/CollectUserDataInput.unit.spec.tsx b/frontend/src/metabase/admin/settings/components/widgets/UsageTracking/CollectUserDataInput.unit.spec.tsx
new file mode 100644
index 00000000000..827573e5319
--- /dev/null
+++ b/frontend/src/metabase/admin/settings/components/widgets/UsageTracking/CollectUserDataInput.unit.spec.tsx
@@ -0,0 +1,127 @@
+import userEvent from "@testing-library/user-event";
+
+import {
+ findRequests,
+ setupPropertiesEndpoints,
+ setupSettingsEndpoints,
+ setupUpdateSettingEndpoint,
+} from "__support__/server-mocks";
+import { renderWithProviders, screen } from "__support__/ui";
+import { UndoListing } from "metabase/common/components/UndoListing";
+import {
+ createMockSettingDefinition,
+ createMockSettings,
+} from "metabase-types/api/mocks";
+
+import { CollectUserDataInput } from "./CollectUserDataInput";
+
+const { trackSimpleEvent } = jest.requireMock("metabase/analytics");
+
+const SETTING_NAME = "analytics-pii-retention-enabled";
+const SETTING_ENV_VAR_NAME = "MB_ANALYTICS_PII_RETENTION_ENABLED";
+
+const setup = ({
+ value,
+ isEnvSetting,
+}: {
+ value: boolean;
+ isEnvSetting?: boolean;
+}) => {
+ const settings = createMockSettings({
+ [SETTING_NAME]: value,
+ });
+
+ setupPropertiesEndpoints(settings);
+ setupUpdateSettingEndpoint();
+ setupSettingsEndpoints([
+ createMockSettingDefinition({
+ key: SETTING_NAME,
+ description:
+ "Enable logging of path, user agent, and IP address of who views your internal data and embeds.",
+ value: false,
+ is_env_setting: isEnvSetting,
+ env_name: isEnvSetting ? SETTING_ENV_VAR_NAME : undefined,
+ }),
+ ]);
+
+ return renderWithProviders(
+ <div>
+ <CollectUserDataInput />
+ <UndoListing />
+ </div>,
+ );
+};
+
+describe("CollectUserDataInput", () => {
+ beforeEach(() => {
+ trackSimpleEvent.mockClear();
+ });
+
+ it("should show the `analytics-pii-retention-enabled` setting toggle", async () => {
+ setup({ value: true });
+ expect(
+ await screen.findByText(
+ "Collect user data to display in usage analytics",
+ ),
+ ).toBeInTheDocument();
+ expect(
+ await screen.findByText(
+ /Enable logging of path, user agent, and IP address of who views your internal data and embeds/,
+ ),
+ ).toBeInTheDocument();
+ expect(screen.getByRole("switch")).toBeChecked();
+ });
+
+ it("should toggle the `analytics-pii-retention-enabled` setting off", async () => {
+ setup({ value: true });
+ await userEvent.click(screen.getByRole("switch"));
+ expect(trackSimpleEvent).toHaveBeenCalledWith({
+ event: "analytics_pii_retention_changed",
+ event_detail: "disabled",
+ triggered_from: "admin",
+ });
+
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toMatch(new RegExp(`/api/setting/${SETTING_NAME}`));
+ expect(body).toEqual({ value: false });
+
+ expect(await screen.findByRole("switch")).not.toBeChecked();
+ });
+
+ it("should toggle the `analytics-pii-retention-enabled` setting on", async () => {
+ setup({ value: false });
+ await userEvent.click(screen.getByRole("switch"));
+
+ const [{ url, body }] = await findRequests("PUT");
+ expect(url).toMatch(new RegExp(`/api/setting/${SETTING_NAME}`));
+ expect(body).toEqual({ value: true });
+ expect(trackSimpleEvent).toHaveBeenCalledWith({
+ event: "analytics_pii_retention_changed",
+ event_detail: "enabled",
+ triggered_from: "admin",
+ });
+
+ expect(await screen.findByRole("switch")).toBeChecked();
+ });
+
+ it("should show environment variable message when `analytics-pii-retention-enabled` is set via env var", async () => {
+ setup({ value: true, isEnvSetting: true });
+ expect(
+ await screen.findByText(/This has been set by the/),
+ ).toBeInTheDocument();
+ expect(await screen.findByText(SETTING_ENV_VAR_NAME)).toBeInTheDocument();
+ });
+
+ it("should not show the switch when `analytics-pii-retention-enabled` is set via env var", async () => {
+ setup({ value: true, isEnvSetting: true });
+ await screen.findByText(/This has been set by the/);
+
+ expect(screen.queryByRole("switch")).not.toBeInTheDocument();
+ });
+
+ it("should show the switch when `analytics-pii-retention-enabled` is not set via env var", async () => {
+ setup({ value: true, isEnvSetting: false });
+
+ expect(await screen.findByRole("switch")).toBeInTheDocument();
+ });
+});
diff --git a/frontend/src/metabase/admin/settings/settings.ts b/frontend/src/metabase/admin/settings/settings.ts
index a4acde93673..956459dbb3d 100644
--- a/frontend/src/metabase/admin/settings/settings.ts
+++ b/frontend/src/metabase/admin/settings/settings.ts
@@ -4,6 +4,7 @@ import { createThunkAction } from "metabase/redux";
import { refreshSiteSettings } from "metabase/redux/settings";
import type { State } from "metabase/redux/store";
import { SettingsApi } from "metabase/services";
+import type { SettingDefinition, SettingKey } from "metabase-types/api";
// ACTION TYPES AND ACTION CREATORS
@@ -42,3 +43,10 @@ export const updateSettings = createThunkAction(
};
},
);
+
+export const isSettingSetFromEnvVar = <SettingName extends SettingKey>(
+ settingDetails: SettingDefinition<SettingName> | undefined,
+): settingDetails is SettingDefinition<SettingName> &
+ Required<
+ Pick<SettingDefinition<SettingName>, "is_env_setting" | "env_name">
+ > => !!settingDetails?.is_env_setting && !!settingDetails?.env_name;
diff --git a/frontend/src/metabase/app-main.js b/frontend/src/metabase/app-main.js
index d19f8862b38..f12b1a981ff 100644
--- a/frontend/src/metabase/app-main.js
+++ b/frontend/src/metabase/app-main.js
@@ -11,6 +11,7 @@ import { setErrorPage } from "metabase/redux/app";
import { clearCurrentUser } from "metabase/redux/user";
import { getRoutes } from "metabase/routes";
import api from "metabase/utils/api";
+import { IFRAMED_IN_SELF, isWithinIframe } from "metabase/utils/iframe";
// If any of these receives a 403, we should display the "not authorized" page.
const NOT_AUTHORIZED_TRIGGERS = [
@@ -20,6 +21,15 @@ const NOT_AUTHORIZED_TRIGGERS = [
/\/api\/pulse\/\d+$/,
];
+/**
+ * This is the entry point for the core app, so if we're in an iframe (not on metabase itself) we can assume we're in full-app embedding.
+ * For the other embedding types we're setting a flag in `frontend/src/metabase/embedding/config.ts`, if we start doing many checks for full-app, we
+ * might want to use a flag too instead of just checking for being in an iframe.
+ */
+if (isWithinIframe() && !IFRAMED_IN_SELF) {
+ api.requestClient = "embedding-iframe-full-app";
+}
+
init(mainReducers, getRoutes, (store) => {
// received a 401 response
api.on("401", (url) => {
diff --git a/frontend/src/metabase/embedding/config.ts b/frontend/src/metabase/embedding/config.ts
index 160d5d7ff72..19e06bd94aa 100644
--- a/frontend/src/metabase/embedding/config.ts
+++ b/frontend/src/metabase/embedding/config.ts
@@ -1,4 +1,5 @@
import { isEmbeddingSdk } from "metabase/embedding-sdk/config";
+import api from "metabase/utils/api";
import { IFRAMED_IN_SELF, isWithinIframe } from "metabase/utils/iframe";
type InternalEmbeddingConfig = {
@@ -12,10 +13,20 @@ const EMBEDDING_CONFIG: InternalEmbeddingConfig = {
};
export function setIsPublicEmbedding() {
+ api.requestClient = "embedding-public";
+
EMBEDDING_CONFIG.isPublicEmbedding = true;
}
export function setIsStaticEmbedding() {
+ /**
+ * 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 (!isEmbedPreview()) {
+ api.requestClient = "embedding-iframe-static";
+ }
EMBEDDING_CONFIG.isStaticEmbedding = true;
}
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/build-embed-attributes.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/build-embed-attributes.ts
index 1f67ec4e6c8..8b3ce190c76 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/build-embed-attributes.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk-setup/utils/build-embed-attributes.ts
@@ -108,7 +108,10 @@ export const formatAttributeValue = (
return wrapWithQuotes ? `"${value}"` : String(value);
};
-type SettingKey = Exclude<keyof SdkIframeEmbedBaseSettings, "_isLocalhost">;
+type SettingKey = Exclude<
+ keyof SdkIframeEmbedBaseSettings,
+ "_isLocalhost" | "_embedReferrer"
+>;
function transformEmbedSettingsToAttributes({
settings,
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk/components/SdkIframeEmbedRoute.tsx b/frontend/src/metabase/embedding/embedding-iframe-sdk/components/SdkIframeEmbedRoute.tsx
index 196f14d2a01..274ea124d58 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk/components/SdkIframeEmbedRoute.tsx
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk/components/SdkIframeEmbedRoute.tsx
@@ -23,10 +23,12 @@ import { createSnowplowTracker } from "metabase/analytics";
import { EmbeddingFooter } from "metabase/embedding/components/EmbeddingFooter/EmbeddingFooter";
import { EMBEDDING_SDK_IFRAME_EMBEDDING_CONFIG } from "metabase/embedding-sdk/config";
import { PLUGIN_EMBEDDING_IFRAME_SDK } from "metabase/plugins";
+import type { OnBeforeRequestHandlerConfig } from "metabase/plugins/oss/api";
import { useSelector } from "metabase/redux";
import { getSetting } from "metabase/selectors/settings";
import { getUserId } from "metabase/selectors/user";
import { Stack } from "metabase/ui";
+import api from "metabase/utils/api";
import { useParamRerenderKey } from "../hooks/use-param-rerender-key";
import { useSdkIframeEmbedEventBus } from "../hooks/use-sdk-iframe-embed-event-bus";
@@ -41,10 +43,38 @@ import {
SdkIframeInvalidLicenseError,
} from "./SdkIframeError";
+let _embedReferrer: string | undefined;
+
+const embedReferrerHandler = async (
+ config: OnBeforeRequestHandlerConfig,
+): Promise<OnBeforeRequestHandlerConfig | void> => {
+ if (_embedReferrer) {
+ return {
+ ...config,
+ options: {
+ ...config.options,
+ headers: {
+ ...config.options.headers,
+ // eslint-disable-next-line metabase/no-literal-metabase-strings -- header name
+ "X-Metabase-Embed-Referrer": _embedReferrer,
+ },
+ },
+ };
+ }
+};
+
+// Register once — uses a named function ref so it can't be pushed twice
+if (!api.beforeRequestHandlers.includes(embedReferrerHandler)) {
+ api.beforeRequestHandlers.push(embedReferrerHandler);
+}
+
const onSettingsChanged = (settings: SdkIframeEmbedSettings) => {
// Tell the SDK whether to use the existing user session or not.
EMBEDDING_SDK_IFRAME_EMBEDDING_CONFIG.useExistingUserSession =
settings?.useExistingUserSession || false;
+
+ // Forward the host page URL so it's sent as X-Metabase-Embed-Referrer on API requests.
+ _embedReferrer = settings?._embedReferrer;
};
const store = getSdkStore();
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk/embed.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk/embed.ts
index 4a009596649..b203af30313 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk/embed.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk/embed.ts
@@ -189,6 +189,7 @@ export abstract class MetabaseEmbedElement<T extends string[] = string[]>
...attributesConverted,
componentName: this._componentName,
_isLocalhost: this._getIsLocalhost(),
+ _embedReferrer: window.location.href,
} as SdkIframeEmbedElementSettings;
}
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk/embed.unit.spec.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk/embed.unit.spec.ts
index cf16421caa1..ec315c5a23c 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk/embed.unit.spec.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk/embed.unit.spec.ts
@@ -409,6 +409,7 @@ describe("embed.js script tag for sdk iframe embedding", () => {
questionId: undefined,
componentName: "metabase-dashboard",
_isLocalhost: true,
+ _embedReferrer: "http://localhost/",
},
}),
"*",
diff --git a/frontend/src/metabase/embedding/embedding-iframe-sdk/types/embed.ts b/frontend/src/metabase/embedding/embedding-iframe-sdk/types/embed.ts
index 7f80d7f7395..b1c24976028 100644
--- a/frontend/src/metabase/embedding/embedding-iframe-sdk/types/embed.ts
+++ b/frontend/src/metabase/embedding/embedding-iframe-sdk/types/embed.ts
@@ -242,6 +242,9 @@ export type SdkIframeEmbedBaseSettings = {
// Whether the embed is running on localhost. Cannot be set by the user.
_isLocalhost?: boolean;
+ // Full URL of the host page embedding Metabase. Cannot be set by the user.
+ _embedReferrer?: string;
+
pluginsConfig?: {
// Callback to handle link clicks. Return { handled: true } to prevent default navigation.
handleLink?: (url: string) => { handled: boolean };
diff --git a/frontend/src/metabase/embedding/lib/override-requests-for-embeds.ts b/frontend/src/metabase/embedding/lib/override-requests-for-embeds.ts
index 31dd4df7abc..c74bee624f5 100644
--- a/frontend/src/metabase/embedding/lib/override-requests-for-embeds.ts
+++ b/frontend/src/metabase/embedding/lib/override-requests-for-embeds.ts
@@ -206,11 +206,6 @@ const overrideRequests = async ({
options.headers = {};
}
- /**
- * Set header to indicate that this request is for guest embed.
- */
- options.headers["x-metabase-guest-embed"] = "true";
-
return {
method: transformation.method,
url: replaceWithEmbedBase({ embedType, url: transformation.url }),
diff --git a/frontend/src/metabase/nav/components/search/SearchBar/SearchBar.styled.tsx b/frontend/src/metabase/nav/components/search/SearchBar/SearchBar.styled.tsx
index e3072ac4db4..999168f0d73 100644
--- a/frontend/src/metabase/nav/components/search/SearchBar/SearchBar.styled.tsx
+++ b/frontend/src/metabase/nav/components/search/SearchBar/SearchBar.styled.tsx
@@ -40,6 +40,7 @@ export const SearchInputContainer = styled.div<{
}
return css`
background-color: var(--mb-color-background-primary);
+
&:hover {
background-color: var(--mb-color-background-secondary);
}
diff --git a/frontend/src/metabase/utils/api.ts b/frontend/src/metabase/utils/api.ts
index 1962be40fa1..94d9fb385cf 100644
--- a/frontend/src/metabase/utils/api.ts
+++ b/frontend/src/metabase/utils/api.ts
@@ -5,7 +5,10 @@ import querystring from "querystring";
import { isEmbeddingSdk } from "metabase/embedding-sdk/config";
import { isTest } from "metabase/env";
import { PLUGIN_API, PLUGIN_EMBEDDING_SDK } from "metabase/plugins";
-import type { OnBeforeRequestHandlerConfig } from "metabase/plugins/oss/api";
+import type {
+ OnBeforeRequestHandler,
+ OnBeforeRequestHandlerConfig,
+} from "metabase/plugins/oss/api";
import { IFRAMED_IN_SELF, isWithinIframe } from "metabase/utils/iframe";
import { getTraceparentHeader } from "metabase/utils/otel";
import { delay } from "metabase/utils/promise";
@@ -92,6 +95,8 @@ export class Api extends EventEmitter {
onResponseError: ((info: ResponseErrorInfo) => void) | undefined;
requestClient: RequestClientInfo | undefined;
+ beforeRequestHandlers: OnBeforeRequestHandler[] = [];
+
GET: MethodCreator;
POST: MethodCreator;
PUT: MethodCreator;
@@ -117,16 +122,8 @@ export class Api extends EventEmitter {
headers["X-Metabase-Session"] = self.sessionToken!;
}
- if (isWithinIframe() && !self.requestClient) {
+ if (isWithinIframe() && !isEmbeddingSdk()) {
headers["X-Metabase-Embedded"] = "true";
- /**
- * 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 (!IFRAMED_IN_SELF) {
- headers["X-Metabase-Client"] = "embedding-iframe";
- }
}
if (self.requestClient) {
@@ -135,8 +132,9 @@ export class Api extends EventEmitter {
}
if (typeof self.requestClient === "object") {
headers["X-Metabase-Client"] = self.requestClient.name;
- headers["X-Metabase-Client-Version"] =
- self.requestClient.version ?? "unknown";
+ if (self.requestClient.version) {
+ headers["X-Metabase-Client-Version"] = self.requestClient.version;
+ }
} else {
headers["X-Metabase-Client"] = self.requestClient;
}
@@ -531,6 +529,8 @@ export class Api extends EventEmitter {
);
}
+ handlers.push(...this.beforeRequestHandlers);
+
if (handlers.length) {
for (const handler of handlers) {
const onBeforeRequestHandlerResult = await handler({
diff --git a/resources/instance_analytics/collections/main/usage_analytics/embedding_usage.yaml b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage.yaml
new file mode 100644
index 00000000000..1238c9091cc
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage.yaml
@@ -0,0 +1,609 @@
+name: Embedding Usage
+description: General information about embedding usage, including views across embedded dashboards and questions
+entity_id: 2NWw98hfm_kimGA4xuyMW
+created_at: '2026-04-21T08:46:38.087564Z'
+creator_id: [email protected]
+collection_id: vG58R8k-QddHWA7_47umn
+collection_position: 10
+parameters:
+- {default: past30days~, id: 8fa1b9ee, name: Date Filter, position: 1, sectionId: date, slug: date_filter, type: date/all-options}
+- {default: week, id: fb9b01de, name: Time grouping, position: 0, required: true, sectionId: temporal-unit, slug: time_grouping, type: temporal-unit}
+serdes/meta:
+- {id: 2NWw98hfm_kimGA4xuyMW, label: embedding_usage, model: Dashboard}
+dashcards:
+- entity_id: 8hZq53wdfb6uy0Exo6qIt
+ created_at: '2026-04-21T08:56:16.594345Z'
+ row: 0
+ col: 0
+ size_x: 24
+ size_y: 1
+ inline_parameters: []
+ parameter_mappings: []
+ series: []
+ visualization_settings:
+ column_settings: null
+ dashcard.background: false
+ text: Authenticated embeds
+ virtual_card:
+ archived: false
+ display: heading
+ name: null
+ visualization_settings: {}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: 8hZq53wdfb6uy0Exo6qIt, model: DashboardCard}
+- entity_id: nE5kY3a4-_2cWqpa_JLo0
+ card_id: g8NVUevCCqPFphn4FMrGd
+ created_at: '2026-04-21T08:54:32.332449Z'
+ row: 1
+ col: 0
+ size_x: 8
+ size_y: 4
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: g8NVUevCCqPFphn4FMrGd
+ parameter_id: 8fa1b9ee
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: default}
+ - {stage-number: 0}
+ - card_id: g8NVUevCCqPFphn4FMrGd
+ parameter_id: fb9b01de
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: week}
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: nE5kY3a4-_2cWqpa_JLo0, model: DashboardCard}
+- entity_id: 6_u-fFQXyLZJUHUc1YMuY
+ card_id: Unn3ZfmU9z6I1JAfyWqKK
+ created_at: '2026-04-21T08:59:57.695738Z'
+ row: 1
+ col: 8
+ size_x: 8
+ size_y: 4
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: Unn3ZfmU9z6I1JAfyWqKK
+ parameter_id: 8fa1b9ee
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: default}
+ - {stage-number: 0}
+ - card_id: Unn3ZfmU9z6I1JAfyWqKK
+ parameter_id: fb9b01de
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: week}
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: 6_u-fFQXyLZJUHUc1YMuY, model: DashboardCard}
+- entity_id: Cui4WwHzmCdM7Ie2VaUdc
+ card_id: 2Jr9KKCyLvvfy0SsoCRkG
+ created_at: '2026-04-21T09:09:47.054359Z'
+ row: 5
+ col: 0
+ size_x: 24
+ size_y: 9
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: 2Jr9KKCyLvvfy0SsoCRkG
+ parameter_id: 8fa1b9ee
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: default}
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: Cui4WwHzmCdM7Ie2VaUdc, model: DashboardCard}
+- entity_id: uVjCahKB32h8q-FTWFGHu
+ created_at: '2026-04-24T11:00:45.292018Z'
+ row: 14
+ col: 0
+ size_x: 24
+ size_y: 1
+ inline_parameters: []
+ parameter_mappings: []
+ series: []
+ visualization_settings:
+ column_settings: null
+ dashcard.background: false
+ text: ''
+ virtual_card:
+ archived: false
+ display: heading
+ name: null
+ visualization_settings: {}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: uVjCahKB32h8q-FTWFGHu, model: DashboardCard}
+- entity_id: 4J7rdPrI1Z0E9UFoQvsac
+ created_at: '2026-04-21T09:24:23.043947Z'
+ row: 15
+ col: 0
+ size_x: 24
+ size_y: 1
+ inline_parameters: []
+ parameter_mappings: []
+ series: []
+ visualization_settings:
+ column_settings: null
+ dashcard.background: false
+ text: Guest embeds
+ virtual_card:
+ archived: false
+ display: heading
+ name: null
+ visualization_settings: {}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: 4J7rdPrI1Z0E9UFoQvsac, model: DashboardCard}
+- entity_id: HosenwKxksBr9KCjEPxCB
+ card_id: 7zzk3uDuhKq7eOH0-Oa00
+ created_at: '2026-04-21T09:25:30.021532Z'
+ row: 16
+ col: 0
+ size_x: 8
+ size_y: 4
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: 7zzk3uDuhKq7eOH0-Oa00
+ parameter_id: 8fa1b9ee
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: default}
+ - {stage-number: 0}
+ - card_id: 7zzk3uDuhKq7eOH0-Oa00
+ parameter_id: fb9b01de
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: week}
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: HosenwKxksBr9KCjEPxCB, model: DashboardCard}
+- entity_id: VzrCbEHvxdjOfINAURaRP
+ card_id: gXGBEZMERaEfyEDnU3f_t
+ created_at: '2026-04-21T09:26:37.750107Z'
+ row: 20
+ col: 0
+ size_x: 24
+ size_y: 9
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: gXGBEZMERaEfyEDnU3f_t
+ parameter_id: 8fa1b9ee
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: default}
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: VzrCbEHvxdjOfINAURaRP, model: DashboardCard}
+- entity_id: hbfyia7tQ5l_4jvezBueP
+ created_at: '2026-04-24T11:03:30.325035Z'
+ row: 29
+ col: 0
+ size_x: 24
+ size_y: 1
+ inline_parameters: []
+ parameter_mappings: []
+ series: []
+ visualization_settings:
+ column_settings: null
+ dashcard.background: false
+ text: ''
+ virtual_card:
+ archived: false
+ display: heading
+ name: null
+ visualization_settings: {}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: hbfyia7tQ5l_4jvezBueP, model: DashboardCard}
+- entity_id: _8rNslzv8qcdL6MR_jDFT
+ created_at: '2026-04-22T11:10:00Z'
+ row: 30
+ col: 0
+ size_x: 24
+ size_y: 1
+ inline_parameters: []
+ parameter_mappings: []
+ series: []
+ visualization_settings:
+ column_settings: null
+ dashcard.background: false
+ text: Public links
+ virtual_card:
+ archived: false
+ display: heading
+ name: null
+ visualization_settings: {}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: _8rNslzv8qcdL6MR_jDFT, model: DashboardCard}
+- entity_id: eulPPLdtwi9nbuNOKSezh
+ card_id: QWuymxfyCmXYraR_cjBDR
+ created_at: '2026-04-22T11:10:00Z'
+ row: 31
+ col: 0
+ size_x: 8
+ size_y: 4
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: QWuymxfyCmXYraR_cjBDR
+ parameter_id: 8fa1b9ee
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: default}
+ - {stage-number: 0}
+ - card_id: QWuymxfyCmXYraR_cjBDR
+ parameter_id: fb9b01de
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: week}
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: eulPPLdtwi9nbuNOKSezh, model: DashboardCard}
+- entity_id: g0LTbH7N-ima8aQX1bCx_
+ card_id: xU_hRFlFpimUOpJTzfnOw
+ created_at: '2026-04-22T11:10:00Z'
+ row: 35
+ col: 0
+ size_x: 24
+ size_y: 9
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: xU_hRFlFpimUOpJTzfnOw
+ parameter_id: 8fa1b9ee
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: default}
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: g0LTbH7N-ima8aQX1bCx_, model: DashboardCard}
+- entity_id: oD2W4YcxLa9SA1cavYjKE
+ created_at: '2026-04-24T11:03:30.325035Z'
+ row: 44
+ col: 0
+ size_x: 24
+ size_y: 1
+ inline_parameters: []
+ parameter_mappings: []
+ series: []
+ visualization_settings:
+ column_settings: null
+ dashcard.background: false
+ text: ''
+ virtual_card:
+ archived: false
+ display: heading
+ name: null
+ visualization_settings: {}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: oD2W4YcxLa9SA1cavYjKE, model: DashboardCard}
+- entity_id: EVKpzm4gg2LTfd0VipICP
+ created_at: '2026-04-21T15:00:00Z'
+ row: 45
+ col: 0
+ size_x: 24
+ size_y: 1
+ inline_parameters: []
+ parameter_mappings: []
+ series: []
+ visualization_settings:
+ column_settings: null
+ dashcard.background: false
+ text: Breakdown of views
+ virtual_card:
+ archived: false
+ display: heading
+ name: null
+ visualization_settings: {}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: EVKpzm4gg2LTfd0VipICP, model: DashboardCard}
+- entity_id: gXaGcRm-ORORo2w8I0keQ
+ card_id: hYmO_Z9wc9dIqRPmvblbh
+ created_at: '2026-04-21T15:00:00Z'
+ row: 46
+ col: 0
+ size_x: 12
+ size_y: 8
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: hYmO_Z9wc9dIqRPmvblbh
+ parameter_id: 8fa1b9ee
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: default}
+ - {stage-number: 0}
+ - card_id: hYmO_Z9wc9dIqRPmvblbh
+ parameter_id: fb9b01de
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: week}
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: gXaGcRm-ORORo2w8I0keQ, model: DashboardCard}
+- entity_id: N-MQbSbgtoL0A6CGY2F8X
+ card_id: tga1bdEHrCMoNo6ZYJRcq
+ created_at: '2026-04-21T15:30:00Z'
+ row: 46
+ col: 12
+ size_x: 12
+ size_y: 8
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: tga1bdEHrCMoNo6ZYJRcq
+ parameter_id: 8fa1b9ee
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: default}
+ - {stage-number: 0}
+ - card_id: tga1bdEHrCMoNo6ZYJRcq
+ parameter_id: fb9b01de
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: week}
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: N-MQbSbgtoL0A6CGY2F8X, model: DashboardCard}
+- entity_id: O4L1rJJFL5ToLc4TO5S3E
+ created_at: '2026-04-24T11:03:30.325035Z'
+ row: 54
+ col: 0
+ size_x: 24
+ size_y: 1
+ inline_parameters: []
+ parameter_mappings: []
+ series: []
+ visualization_settings:
+ column_settings: null
+ dashcard.background: false
+ text: ''
+ virtual_card:
+ archived: false
+ display: heading
+ name: null
+ visualization_settings: {}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: O4L1rJJFL5ToLc4TO5S3E, model: DashboardCard}
+- entity_id: 5FK7Dx8zqEpCgLcDqgoiD
+ created_at: '2026-04-22T08:30:00Z'
+ row: 55
+ col: 0
+ size_x: 24
+ size_y: 1
+ inline_parameters: []
+ parameter_mappings: []
+ series: []
+ visualization_settings:
+ column_settings: null
+ dashcard.background: false
+ text: Tenants
+ virtual_card:
+ archived: false
+ display: heading
+ name: null
+ visualization_settings: {}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: 5FK7Dx8zqEpCgLcDqgoiD, model: DashboardCard}
+- entity_id: S7nTEK0l9VzL4Jw_xT3UY
+ card_id: tSWU3GuBUXLALRjF1TF3j
+ created_at: '2026-04-22T08:30:00Z'
+ row: 56
+ col: 0
+ size_x: 8
+ size_y: 4
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: tSWU3GuBUXLALRjF1TF3j
+ parameter_id: 8fa1b9ee
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: default}
+ - {stage-number: 0}
+ - card_id: tSWU3GuBUXLALRjF1TF3j
+ parameter_id: fb9b01de
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: week}
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: S7nTEK0l9VzL4Jw_xT3UY, model: DashboardCard}
+- entity_id: YcKImVjBKNgUAJVv7ODAE
+ created_at: '2026-04-24T11:09:25.553458Z'
+ row: 56
+ col: 8
+ size_x: 16
+ size_y: 4
+ inline_parameters: []
+ parameter_mappings: []
+ series: []
+ visualization_settings:
+ column_settings: null
+ dashcard.background: false
+ text: ''
+ virtual_card:
+ archived: false
+ display: heading
+ name: null
+ visualization_settings: {}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: YcKImVjBKNgUAJVv7ODAE, model: DashboardCard}
+- entity_id: Z1a2b3c4d5e6f7g8h9iJk
+ card_id: URLiB2ln8D_T0dIYGNA1O
+ created_at: '2026-04-22T08:30:00Z'
+ row: 60
+ col: 0
+ size_x: 24
+ size_y: 8
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: URLiB2ln8D_T0dIYGNA1O
+ parameter_id: 8fa1b9ee
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: default}
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: Z1a2b3c4d5e6f7g8h9iJk, model: DashboardCard}
+- entity_id: _7PLkrIh5ZHRIyedU9U00
+ created_at: '2026-04-24T11:03:30.325035Z'
+ row: 68
+ col: 0
+ size_x: 24
+ size_y: 1
+ inline_parameters: []
+ parameter_mappings: []
+ series: []
+ visualization_settings:
+ column_settings: null
+ dashcard.background: false
+ text: ''
+ virtual_card:
+ archived: false
+ display: heading
+ name: null
+ visualization_settings: {}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: _7PLkrIh5ZHRIyedU9U00, model: DashboardCard}
+- entity_id: 5lPZ_7Y2W8bL9ddX0hKsg
+ created_at: '2026-04-22T11:10:00Z'
+ row: 69
+ col: 0
+ size_x: 24
+ size_y: 1
+ inline_parameters: []
+ parameter_mappings: []
+ series: []
+ visualization_settings:
+ column_settings: null
+ dashcard.background: false
+ text: Environment
+ virtual_card:
+ archived: false
+ display: heading
+ name: null
+ visualization_settings: {}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: 5lPZ_7Y2W8bL9ddX0hKsg, model: DashboardCard}
+- entity_id: 2rxvji6Z2uYADawDBvvNv
+ card_id: groy2C3BTTfonftkwwXDU
+ created_at: '2026-04-23T12:00:00Z'
+ row: 70
+ col: 0
+ size_x: 12
+ size_y: 16
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: groy2C3BTTfonftkwwXDU
+ parameter_id: 8fa1b9ee
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: default}
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: 2rxvji6Z2uYADawDBvvNv, model: DashboardCard}
+- entity_id: HMZquOXricg0piXQdWsHD
+ card_id: CZVMu5tqSLaV7WIQNnL77
+ created_at: '2026-04-22T11:10:00Z'
+ row: 70
+ col: 12
+ size_x: 12
+ size_y: 16
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: CZVMu5tqSLaV7WIQNnL77
+ parameter_id: 8fa1b9ee
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: default}
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: 2NWw98hfm_kimGA4xuyMW, model: Dashboard}
+ - {id: HMZquOXricg0piXQdWsHD, model: DashboardCard}
+tabs: []
+width: fixed
diff --git a/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/active_tenants.yaml b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/active_tenants.yaml
new file mode 100644
index 00000000000..b1b3dc22417
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/active_tenants.yaml
@@ -0,0 +1,82 @@
+name: Active tenants
+entity_id: tSWU3GuBUXLALRjF1TF3j
+created_at: '2026-04-22T08:30:00Z'
+creator_id: [email protected]
+display: smartscalar
+collection_id: vG58R8k-QddHWA7_47umn
+query_type: query
+database_id: Internal Metabase Database
+table_id: [Internal Metabase Database, public, v_view_log]
+parameters: []
+parameter_mappings: []
+dataset_query:
+ database: Internal Metabase Database
+ stages:
+ - aggregation:
+ - - distinct
+ - {}
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer}
+ - [Internal Metabase Database, public, v_view_log, tenant_id]
+ breakout:
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, temporal-unit: week}
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ filters:
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer}
+ - [Internal Metabase Database, public, v_view_log, tenant_id]
+ source-card: P6Ityjj7igswKh4NgZZjz
+ lib/type: mbql.stage/mbql
+ lib/type: mbql/query
+result_metadata:
+- active: true
+ base_type: type/DateTimeWithLocalTZ
+ database_type: timestamptz
+ description: When the view happened
+ display_name: 'Timestamp: Week'
+ effective_type: type/DateTimeWithLocalTZ
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {temporal-unit: week}
+ id: [Internal Metabase Database, public, v_view_log, timestamp]
+ inherited_temporal_unit: week
+ name: timestamp
+ position: 1
+ semantic_type: type/CreationTimestamp
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_view_log]
+ unit: week
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1020
+ lib/deduplicated-name: timestamp
+ lib/desired-column-alias: timestamp
+ lib/from-model?: true
+ lib/original-display-name: Timestamp
+ lib/original-name: timestamp
+ lib/source: source/previous-stage
+ lib/source-column-alias: timestamp
+ lib/temporal-unit: week
+- base_type: type/Integer
+ display_name: Distinct values of Tenant ID
+ effective_type: type/Integer
+ field_ref: [aggregation, 0]
+ name: count
+ semantic_type: type/Quantity
+ source: aggregation
+ lib/deduplicated-name: count
+ lib/desired-column-alias: count
+ lib/original-name: count
+ lib/source: source/aggregations
+ lib/source-column-alias: count
+visualization_settings: {column_settings: null}
+card_schema: 23
+serdes/meta:
+- {id: tSWU3GuBUXLALRjF1TF3j, label: active_tenants, model: Card}
+dashboard_id: 2NWw98hfm_kimGA4xuyMW
+source_card_id: P6Ityjj7igswKh4NgZZjz
+type: question
diff --git a/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/authenticated_views.yaml b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/authenticated_views.yaml
new file mode 100644
index 00000000000..fcdbacc2ee4
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/authenticated_views.yaml
@@ -0,0 +1,122 @@
+name: Authenticated views
+entity_id: g8NVUevCCqPFphn4FMrGd
+created_at: '2026-04-21T08:54:11.562015Z'
+creator_id: [email protected]
+display: smartscalar
+collection_id: vG58R8k-QddHWA7_47umn
+query_type: query
+database_id: Internal Metabase Database
+table_id: [Internal Metabase Database, public, v_view_log]
+parameters: []
+parameter_mappings: []
+dataset_query:
+ database: Internal Metabase Database
+ stages:
+ - aggregation:
+ - - count
+ - {}
+ breakout:
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, temporal-unit: week}
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ expressions:
+ - - and
+ - {lib/expression-name: is_auth_embed}
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - - not-in
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ - public
+ - guest
+ - - not
+ - {lib/expression-name: is_top_level}
+ - - and
+ - {}
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_type]
+ - card
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - dashboard
+ filters:
+ - - =
+ - {}
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_auth_embed
+ - true
+ - - =
+ - {}
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_top_level
+ - true
+ source-card: P6Ityjj7igswKh4NgZZjz
+ lib/type: mbql.stage/mbql
+ lib/type: mbql/query
+result_metadata:
+- active: true
+ base_type: type/DateTimeWithLocalTZ
+ database_type: timestamptz
+ description: When the view happened
+ display_name: 'Timestamp: Week'
+ effective_type: type/DateTimeWithLocalTZ
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {temporal-unit: week}
+ id: [Internal Metabase Database, public, v_view_log, timestamp]
+ inherited_temporal_unit: week
+ name: timestamp
+ position: 1
+ semantic_type: type/CreationTimestamp
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_view_log]
+ unit: week
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1020
+ lib/deduplicated-name: timestamp
+ lib/desired-column-alias: timestamp
+ lib/from-model?: true
+ lib/original-display-name: Timestamp
+ lib/original-name: timestamp
+ lib/source: source/previous-stage
+ lib/source-column-alias: timestamp
+ lib/temporal-unit: week
+- base_type: type/Integer
+ display_name: Count
+ effective_type: type/Integer
+ field_ref: [aggregation, 0]
+ name: count
+ semantic_type: type/Quantity
+ source: aggregation
+ lib/deduplicated-name: count
+ lib/desired-column-alias: count
+ lib/original-name: count
+ lib/source: source/aggregations
+ lib/source-column-alias: count
+visualization_settings: {column_settings: null}
+card_schema: 23
+serdes/meta:
+- {id: g8NVUevCCqPFphn4FMrGd, label: authenticated_views, model: Card}
+dashboard_id: 2NWw98hfm_kimGA4xuyMW
+source_card_id: P6Ityjj7igswKh4NgZZjz
+type: question
diff --git a/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/guest_views.yaml b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/guest_views.yaml
new file mode 100644
index 00000000000..bbf837b7e4a
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/guest_views.yaml
@@ -0,0 +1,126 @@
+name: Guest views
+entity_id: 7zzk3uDuhKq7eOH0-Oa00
+created_at: '2026-04-21T09:25:29.987115Z'
+creator_id: [email protected]
+display: smartscalar
+collection_id: vG58R8k-QddHWA7_47umn
+query_type: query
+database_id: Internal Metabase Database
+table_id: [Internal Metabase Database, public, v_view_log]
+parameters: []
+parameter_mappings: []
+dataset_query:
+ database: Internal Metabase Database
+ stages:
+ - aggregation:
+ - - count
+ - {}
+ breakout:
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, inherited-temporal-unit: default, temporal-unit: week, lib/uuid: 64df4e63-7ad6-4499-806a-ff5e69936ebb}
+ - timestamp
+ expressions:
+ - - not-null
+ - {effective-type: type/Boolean, lib/expression-name: is_embed}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text, lib/uuid: 64a3de23-f89b-4676-860d-d371bea774dc}
+ - embedding_client
+ - - not
+ - {lib/expression-name: is_top_level}
+ - - and
+ - {}
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_type]
+ - card
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - dashboard
+ filters:
+ - - =
+ - {}
+ - - expression
+ - {effective-type: type/Boolean}
+ - is_embed
+ - true
+ - - =
+ - {}
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_top_level
+ - true
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ - guest
+ - - time-interval
+ - {include-current: true}
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, inherited-temporal-unit: default, lib/uuid: 50fb09ab-f795-46d6-ac76-d9242987c699}
+ - timestamp
+ - -30
+ - day
+ source-card: P6Ityjj7igswKh4NgZZjz
+ lib/type: mbql.stage/mbql
+ lib/type: mbql/query
+result_metadata:
+- active: true
+ base_type: type/DateTimeWithLocalTZ
+ database_type: timestamptz
+ description: When the view happened
+ display_name: 'Timestamp: Week'
+ effective_type: type/DateTimeWithLocalTZ
+ field_ref:
+ - field
+ - timestamp
+ - {base-type: type/DateTimeWithLocalTZ, temporal-unit: week}
+ id: [Internal Metabase Database, public, v_view_log, timestamp]
+ inherited_temporal_unit: week
+ name: timestamp
+ position: 1
+ semantic_type: type/CreationTimestamp
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_view_log]
+ unit: week
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1020
+ lib/deduplicated-name: timestamp
+ lib/desired-column-alias: timestamp
+ lib/from-model?: true
+ lib/original-display-name: Timestamp
+ lib/original-name: timestamp
+ lib/source: source/previous-stage
+ lib/source-column-alias: timestamp
+ lib/temporal-unit: week
+- base_type: type/Integer
+ display_name: Count
+ effective_type: type/Integer
+ field_ref: [aggregation, 0]
+ name: count
+ semantic_type: type/Quantity
+ source: aggregation
+ lib/deduplicated-name: count
+ lib/desired-column-alias: count
+ lib/original-name: count
+ lib/source: source/aggregations
+ lib/source-column-alias: count
+visualization_settings: {column_settings: null}
+card_schema: 23
+serdes/meta:
+- {id: 7zzk3uDuhKq7eOH0-Oa00, label: guest_views, model: Card}
+dashboard_id: 2NWw98hfm_kimGA4xuyMW
+source_card_id: P6Ityjj7igswKh4NgZZjz
+type: question
diff --git a/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/most_viewed_authenticated_embeds.yaml b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/most_viewed_authenticated_embeds.yaml
new file mode 100644
index 00000000000..a51474b1b92
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/most_viewed_authenticated_embeds.yaml
@@ -0,0 +1,319 @@
+name: Most viewed authenticated embeds
+entity_id: 2Jr9KKCyLvvfy0SsoCRkG
+created_at: '2026-04-21T09:09:47.006107Z'
+creator_id: [email protected]
+display: table
+collection_id: vG58R8k-QddHWA7_47umn
+query_type: query
+database_id: Internal Metabase Database
+table_id: [Internal Metabase Database, public, v_view_log]
+parameters: []
+parameter_mappings: []
+dataset_query:
+ database: Internal Metabase Database
+ stages:
+ - aggregation:
+ - - count
+ - {lib/uuid: 3c080d03-8995-4ddb-a659-af1c17fa3340}
+ breakout:
+ - - field
+ - {base-type: type/Text, effective-type: type/Text, join-alias: Content - Entity Qualified}
+ - [Internal Metabase Database, public, v_content, name]
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer, join-alias: Content - Entity Qualified}
+ - [Internal Metabase Database, public, v_content, entity_id]
+ - - expression
+ - {base-type: type/Text, effective-type: type/Text}
+ - entity_type_path
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ expressions:
+ - - and
+ - {lib/expression-name: is_auth_embed}
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - - not-in
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ - public
+ - guest
+ - - not
+ - {lib/expression-name: is_top_level}
+ - - and
+ - {}
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_type]
+ - card
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - dashboard
+ - - replace
+ - {lib/expression-name: entity_type_path}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_type]
+ - card
+ - question
+ filters:
+ - - =
+ - {}
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_auth_embed
+ - true
+ - - =
+ - {}
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_top_level
+ - true
+ - - '!='
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ - guest
+ - - time-interval
+ - {include-current: true}
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, lib/uuid: d1e60ffa-252e-4257-855c-6f0b22739719}
+ - timestamp
+ - -30
+ - day
+ joins:
+ - alias: Content - Entity Qualified
+ conditions:
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_qualified_id]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text, join-alias: Content - Entity Qualified}
+ - [Internal Metabase Database, public, v_content, entity_qualified_id]
+ stages:
+ - {source-card: AxSackBiyXVRUzM_TyyQY, lib/type: mbql.stage/mbql}
+ strategy: left-join
+ lib/options: {lib/uuid: 51ed0e0a-acf3-4849-b9a9-252f57001731}
+ lib/type: mbql/join
+ order-by:
+ - - desc
+ - {}
+ - - aggregation
+ - {base-type: type/BigInteger, effective-type: type/BigInteger, lib/source-name: count}
+ - 3c080d03-8995-4ddb-a659-af1c17fa3340
+ source-card: P6Ityjj7igswKh4NgZZjz
+ lib/type: mbql.stage/mbql
+ lib/type: mbql/query
+result_metadata:
+- active: true
+ base_type: type/Text
+ database_type: varchar
+ display_name: Content - Entity Qualified → Name
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_content, name]
+ - {join-alias: Content - Entity Qualified}
+ id: [Internal Metabase Database, public, v_content, name]
+ name: name
+ position: 6
+ semantic_type: type/Name
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_content]
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1018
+ lib/deduplicated-name: name
+ lib/desired-column-alias: Content - Entity Qualified__name
+ lib/from-model?: true
+ lib/join-alias: Content - Entity Qualified
+ lib/original-display-name: Name
+ lib/original-join-alias: Content - Entity Qualified
+ lib/original-name: name
+ lib/source: source/joins
+ lib/source-column-alias: name
+ qp/implicit-field?: true
+- active: true
+ base_type: type/Integer
+ database_type: int4
+ display_name: Content - Entity Qualified → Entity ID
+ effective_type: type/Integer
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_content, entity_id]
+ - {join-alias: Content - Entity Qualified}
+ id: [Internal Metabase Database, public, v_content, entity_id]
+ name: entity_id
+ position: 0
+ semantic_type: type/PK
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_content]
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1018
+ lib/deduplicated-name: entity_id
+ lib/desired-column-alias: Content - Entity Qualified__entity_id
+ lib/from-model?: true
+ lib/join-alias: Content - Entity Qualified
+ lib/original-display-name: Entity ID
+ lib/original-join-alias: Content - Entity Qualified
+ lib/original-name: entity_id
+ lib/source: source/joins
+ lib/source-column-alias: entity_id
+ qp/implicit-field?: true
+- base_type: type/Text
+ display_name: entity_type_path
+ effective_type: type/Text
+ field_ref: [expression, entity_type_path]
+ name: entity_type_path
+ source: breakout
+ lib/breakout?: true
+ lib/deduplicated-name: entity_type_path
+ lib/desired-column-alias: entity_type_path
+ lib/expression-name: entity_type_path
+ lib/original-name: entity_type_path
+ lib/source: source/expressions
+ lib/source-column-alias: entity_type_path
+- active: true
+ base_type: type/Text
+ database_type: varchar
+ display_name: Embedding Client
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - null
+ id: [Internal Metabase Database, public, v_view_log, embedding_client]
+ name: embedding_client
+ position: 6
+ semantic_type: type/Category
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_view_log]
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1020
+ lib/deduplicated-name: embedding_client
+ lib/desired-column-alias: embedding_client
+ lib/from-model?: true
+ lib/internal-remap:
+ human-readable-values: [Modular embedding SDK, Modular embedding SDK (Preview), Modular embedding, Modular embedding (Preview), Public sharing, Static embedding, Static embedding (Preview), Full app embedding, Full app embedding (Preview)]
+ id: 291
+ name: Embedding Client
+ values: [embedding-sdk-react, embedding-sdk-react-preview, embedding-simple, embedding-simple-preview, embedding-public, embedding-iframe-static, embedding-iframe-static-preview, embedding-iframe-full-app, embedding-iframe-full-app-preview]
+ lib/type: metadata.column.remapping/internal
+ lib/original-display-name: Embedding Client
+ lib/original-name: embedding_client
+ lib/source: source/previous-stage
+ lib/source-column-alias: embedding_client
+- active: true
+ base_type: type/Text
+ database_type: varchar
+ display_name: Auth Method
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ - null
+ id: [Internal Metabase Database, public, v_view_log, auth_method]
+ name: auth_method
+ position: 13
+ semantic_type: type/Category
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_view_log]
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1020
+ lib/deduplicated-name: auth_method
+ lib/desired-column-alias: auth_method
+ lib/from-model?: true
+ lib/internal-remap:
+ human-readable-values: [API key, Guest, JWT, Password, public, SAML]
+ id: 288
+ name: Auth Method
+ values: [api-key, guest, jwt, password, public, saml]
+ lib/type: metadata.column.remapping/internal
+ lib/original-display-name: Auth Method
+ lib/original-name: auth_method
+ lib/source: source/previous-stage
+ lib/source-column-alias: auth_method
+- base_type: type/Integer
+ display_name: Count
+ effective_type: type/Integer
+ field_ref: [aggregation, 0]
+ name: count
+ semantic_type: type/Quantity
+ source: aggregation
+ lib/deduplicated-name: count
+ lib/desired-column-alias: count
+ lib/original-name: count
+ lib/source: source/aggregations
+ lib/source-column-alias: count
+visualization_settings:
+ column_settings:
+ '["name","count"]': {column_title: Views, show_mini_bar: true}
+ '["name","entity_id"]': {column_title: Entity ID}
+ '["name","name"]': {column_title: Content, link_text: '', link_url: '/{{entity_type_path}}/{{entity_id}}', view_as: link}
+ table.cell_column: count
+ table.columns:
+ - enabled: true
+ fieldRef:
+ - field
+ - [Internal Metabase Database, public, v_content, name]
+ - {base-type: type/Text, join-alias: Content - Entity Qualified}
+ name: name
+ - enabled: false
+ fieldRef:
+ - field
+ - [Internal Metabase Database, public, v_content, entity_id]
+ - {base-type: type/Integer, join-alias: Content - Entity Qualified}
+ name: entity_id
+ - enabled: false
+ fieldRef:
+ - expression
+ - entity_type_path
+ - {base-type: type/Text}
+ name: entity_type_path
+ - enabled: true
+ fieldRef:
+ - field
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - {base-type: type/Text}
+ name: embedding_client
+ - enabled: true
+ fieldRef:
+ - field
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ - {base-type: type/Text}
+ name: auth_method
+ - enabled: true
+ fieldRef: [aggregation, 0]
+ name: count
+ table.pivot: false
+ table.pivot_column: auth_method
+card_schema: 23
+serdes/meta:
+- {id: 2Jr9KKCyLvvfy0SsoCRkG, label: most_viewed_authenticated_embeds, model: Card}
+dashboard_id: 2NWw98hfm_kimGA4xuyMW
+source_card_id: P6Ityjj7igswKh4NgZZjz
+type: question
diff --git a/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/most_viewed_guest_embeds.yaml b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/most_viewed_guest_embeds.yaml
new file mode 100644
index 00000000000..2185c70060b
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/most_viewed_guest_embeds.yaml
@@ -0,0 +1,315 @@
+name: Most viewed guest embeds
+entity_id: gXGBEZMERaEfyEDnU3f_t
+created_at: '2026-04-21T09:26:37.712634Z'
+creator_id: [email protected]
+display: table
+collection_id: vG58R8k-QddHWA7_47umn
+query_type: query
+database_id: Internal Metabase Database
+table_id: [Internal Metabase Database, public, v_view_log]
+parameters: []
+parameter_mappings: []
+dataset_query:
+ database: Internal Metabase Database
+ stages:
+ - aggregation:
+ - - count
+ - {lib/uuid: 3c080d03-8995-4ddb-a659-af1c17fa3340}
+ breakout:
+ - - field
+ - {base-type: type/Text, effective-type: type/Text, join-alias: Content - Entity Qualified}
+ - [Internal Metabase Database, public, v_content, name]
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer, join-alias: Content - Entity Qualified}
+ - [Internal Metabase Database, public, v_content, entity_id]
+ - - expression
+ - {base-type: type/Text, effective-type: type/Text}
+ - entity_type_path
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - - field
+ - {base-type: type/Boolean, effective-type: type/Boolean, join-alias: Content - Entity Qualified}
+ - [Internal Metabase Database, public, v_content, is_embedding_enabled]
+ expressions:
+ - - not-null
+ - {effective-type: type/Boolean, lib/expression-name: is_embed}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text, lib/uuid: d3904e09-4275-4f2a-8465-dbc753f00204}
+ - embedding_client
+ - - not
+ - {lib/expression-name: is_top_level}
+ - - and
+ - {}
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_type]
+ - card
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - dashboard
+ - - replace
+ - {lib/expression-name: entity_type_path}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_type]
+ - card
+ - question
+ filters:
+ - - =
+ - {}
+ - - expression
+ - {effective-type: type/Boolean}
+ - is_embed
+ - true
+ - - =
+ - {}
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_top_level
+ - true
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ - guest
+ - - time-interval
+ - {include-current: true}
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, lib/uuid: fd21df12-fa3c-4ce0-acf8-04c791a69eae}
+ - timestamp
+ - -30
+ - day
+ - - time-interval
+ - {include-current: true}
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, inherited-temporal-unit: default, lib/uuid: f7050f99-76df-4704-9a8b-6d0e20272cfe}
+ - timestamp
+ - -30
+ - day
+ joins:
+ - alias: Content - Entity Qualified
+ conditions:
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_qualified_id]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text, join-alias: Content - Entity Qualified}
+ - [Internal Metabase Database, public, v_content, entity_qualified_id]
+ stages:
+ - {source-card: AxSackBiyXVRUzM_TyyQY, lib/type: mbql.stage/mbql}
+ strategy: left-join
+ lib/options: {lib/uuid: ba4a2279-3d95-4388-8b34-e3a2f4100fc5}
+ lib/type: mbql/join
+ order-by:
+ - - desc
+ - {}
+ - - aggregation
+ - {base-type: type/BigInteger, effective-type: type/BigInteger, lib/source-name: count}
+ - 3c080d03-8995-4ddb-a659-af1c17fa3340
+ source-card: P6Ityjj7igswKh4NgZZjz
+ lib/type: mbql.stage/mbql
+ lib/type: mbql/query
+result_metadata:
+- active: true
+ base_type: type/Text
+ database_type: varchar
+ display_name: Content - Entity Qualified → Name
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_content, name]
+ - {join-alias: Content - Entity Qualified}
+ id: [Internal Metabase Database, public, v_content, name]
+ name: name
+ position: 6
+ semantic_type: type/Name
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_content]
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1018
+ lib/deduplicated-name: name
+ lib/desired-column-alias: Content - Entity Qualified__name
+ lib/from-model?: true
+ lib/join-alias: Content - Entity Qualified
+ lib/original-display-name: Name
+ lib/original-join-alias: Content - Entity Qualified
+ lib/original-name: name
+ lib/source: source/joins
+ lib/source-column-alias: name
+ qp/implicit-field?: true
+- active: true
+ base_type: type/Integer
+ database_type: int4
+ display_name: Content - Entity Qualified → Entity ID
+ effective_type: type/Integer
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_content, entity_id]
+ - {join-alias: Content - Entity Qualified}
+ id: [Internal Metabase Database, public, v_content, entity_id]
+ name: entity_id
+ position: 0
+ semantic_type: type/PK
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_content]
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1018
+ lib/deduplicated-name: entity_id
+ lib/desired-column-alias: Content - Entity Qualified__entity_id
+ lib/from-model?: true
+ lib/join-alias: Content - Entity Qualified
+ lib/original-display-name: Entity ID
+ lib/original-join-alias: Content - Entity Qualified
+ lib/original-name: entity_id
+ lib/source: source/joins
+ lib/source-column-alias: entity_id
+ qp/implicit-field?: true
+- base_type: type/Text
+ display_name: entity_type_path
+ effective_type: type/Text
+ field_ref: [expression, entity_type_path]
+ name: entity_type_path
+ source: breakout
+ lib/breakout?: true
+ lib/deduplicated-name: entity_type_path
+ lib/desired-column-alias: entity_type_path
+ lib/expression-name: entity_type_path
+ lib/original-name: entity_type_path
+ lib/source: source/expressions
+ lib/source-column-alias: entity_type_path
+- active: true
+ base_type: type/Text
+ database_type: varchar
+ display_name: Embedding Client
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - null
+ id: [Internal Metabase Database, public, v_view_log, embedding_client]
+ name: embedding_client
+ position: 6
+ semantic_type: type/Category
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_view_log]
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1020
+ lib/deduplicated-name: embedding_client
+ lib/desired-column-alias: embedding_client
+ lib/from-model?: true
+ lib/internal-remap:
+ human-readable-values: [Modular embedding SDK, Modular embedding SDK (Preview), Modular embedding, Modular embedding (Preview), Public sharing, Static embedding, Static embedding (Preview), Full app embedding, Full app embedding (Preview)]
+ id: 291
+ name: Embedding Client
+ values: [embedding-sdk-react, embedding-sdk-react-preview, embedding-simple, embedding-simple-preview, embedding-public, embedding-iframe-static, embedding-iframe-static-preview, embedding-iframe-full-app, embedding-iframe-full-app-preview]
+ lib/type: metadata.column.remapping/internal
+ lib/original-display-name: Embedding Client
+ lib/original-name: embedding_client
+ lib/source: source/previous-stage
+ lib/source-column-alias: embedding_client
+- active: true
+ base_type: type/Boolean
+ database_type: bool
+ display_name: Content - Entity Qualified → Is Embedding Enabled
+ effective_type: type/Boolean
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_content, is_embedding_enabled]
+ - {join-alias: Content - Entity Qualified}
+ id: [Internal Metabase Database, public, v_content, is_embedding_enabled]
+ name: is_embedding_enabled
+ position: 10
+ semantic_type: type/Category
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_content]
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1018
+ lib/deduplicated-name: is_embedding_enabled
+ lib/desired-column-alias: Content - Entity Qualified__is_embedding_enabled
+ lib/from-model?: true
+ lib/join-alias: Content - Entity Qualified
+ lib/original-display-name: Is Embedding Enabled
+ lib/original-join-alias: Content - Entity Qualified
+ lib/original-name: is_embedding_enabled
+ lib/source: source/joins
+ lib/source-column-alias: is_embedding_enabled
+ qp/implicit-field?: true
+- base_type: type/Integer
+ display_name: Count
+ effective_type: type/Integer
+ field_ref: [aggregation, 0]
+ name: count
+ semantic_type: type/Quantity
+ source: aggregation
+ lib/deduplicated-name: count
+ lib/desired-column-alias: count
+ lib/original-name: count
+ lib/source: source/aggregations
+ lib/source-column-alias: count
+visualization_settings:
+ column_settings:
+ '["name","count"]': {column_title: Views, show_mini_bar: true}
+ '["name","entity_id"]': {column_title: Entity ID}
+ '["name","is_embedding_enabled"]': {column_title: Published}
+ '["name","name"]': {column_title: Content, link_text: '', link_url: '/{{entity_type_path}}/{{entity_id}}', view_as: link}
+ table.cell_column: count
+ table.columns:
+ - enabled: true
+ fieldRef:
+ - field
+ - [Internal Metabase Database, public, v_content, name]
+ - {base-type: type/Text, join-alias: Content - Entity Qualified}
+ name: name
+ - enabled: false
+ fieldRef:
+ - field
+ - [Internal Metabase Database, public, v_content, entity_id]
+ - {base-type: type/Integer, join-alias: Content - Entity Qualified}
+ name: entity_id
+ - enabled: false
+ fieldRef:
+ - expression
+ - entity_type_path
+ - {base-type: type/Text}
+ name: entity_type_path
+ - enabled: true
+ fieldRef:
+ - field
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - {base-type: type/Text}
+ name: embedding_client
+ - enabled: true
+ fieldRef:
+ - field
+ - [Internal Metabase Database, public, v_content, is_embedding_enabled]
+ - {base-type: type/Boolean, join-alias: Content - Entity Qualified}
+ name: is_embedding_enabled
+ - enabled: true
+ fieldRef: [aggregation, 0]
+ name: count
+ table.pivot: false
+ table.pivot_column: entity_type_path
+card_schema: 23
+serdes/meta:
+- {id: gXGBEZMERaEfyEDnU3f_t, label: most_viewed_guest_embeds, model: Card}
+dashboard_id: 2NWw98hfm_kimGA4xuyMW
+source_card_id: P6Ityjj7igswKh4NgZZjz
+type: question
diff --git a/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/most_viewed_public_links.yaml b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/most_viewed_public_links.yaml
new file mode 100644
index 00000000000..04902f44bfe
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/most_viewed_public_links.yaml
@@ -0,0 +1,246 @@
+name: Most viewed public links
+entity_id: xU_hRFlFpimUOpJTzfnOw
+created_at: '2026-04-22T11:10:00Z'
+creator_id: [email protected]
+display: table
+collection_id: vG58R8k-QddHWA7_47umn
+query_type: query
+database_id: Internal Metabase Database
+table_id: [Internal Metabase Database, public, v_view_log]
+parameters: []
+parameter_mappings: []
+dataset_query:
+ database: Internal Metabase Database
+ stages:
+ - aggregation:
+ - - count
+ - {lib/uuid: fe8f34bc-4880-4da8-b9b4-35ba5f3fe66e}
+ breakout:
+ - - field
+ - {base-type: type/Text, effective-type: type/Text, join-alias: Content - Entity Qualified}
+ - [Internal Metabase Database, public, v_content, name]
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer, join-alias: Content - Entity Qualified}
+ - [Internal Metabase Database, public, v_content, entity_id]
+ - - expression
+ - {base-type: type/Text, effective-type: type/Text}
+ - entity_type_path
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_published
+ expressions:
+ - - not
+ - {lib/expression-name: is_top_level}
+ - - and
+ - {}
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_type]
+ - card
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - dashboard
+ - - replace
+ - {lib/expression-name: entity_type_path}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_type]
+ - card
+ - question
+ - - not-null
+ - {lib/expression-name: is_published}
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer, join-alias: Content - Entity Qualified}
+ - [Internal Metabase Database, public, v_content, made_public_by_user]
+ filters:
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - embedding-public
+ - - =
+ - {}
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_top_level
+ - true
+ - - time-interval
+ - {include-current: true}
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, lib/uuid: 5012ece5-f922-4222-b440-a5fdc2518e8f}
+ - timestamp
+ - -30
+ - day
+ joins:
+ - alias: Content - Entity Qualified
+ conditions:
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_qualified_id]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text, join-alias: Content - Entity Qualified}
+ - [Internal Metabase Database, public, v_content, entity_qualified_id]
+ stages:
+ - {source-card: AxSackBiyXVRUzM_TyyQY, lib/type: mbql.stage/mbql}
+ strategy: left-join
+ lib/options: {lib/uuid: ff1a8f80-c186-4224-abbd-02c37bd8c46a}
+ lib/type: mbql/join
+ order-by:
+ - - desc
+ - {}
+ - - aggregation
+ - {base-type: type/BigInteger, effective-type: type/BigInteger, lib/source-name: count}
+ - fe8f34bc-4880-4da8-b9b4-35ba5f3fe66e
+ source-card: P6Ityjj7igswKh4NgZZjz
+ lib/type: mbql.stage/mbql
+ lib/type: mbql/query
+result_metadata:
+- active: true
+ base_type: type/Text
+ database_type: varchar
+ display_name: Content - Entity Qualified → Name
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_content, name]
+ - {join-alias: Content - Entity Qualified}
+ id: [Internal Metabase Database, public, v_content, name]
+ name: name
+ position: 6
+ semantic_type: type/Name
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_content]
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1018
+ lib/deduplicated-name: name
+ lib/desired-column-alias: Content - Entity Qualified__name
+ lib/from-model?: true
+ lib/join-alias: Content - Entity Qualified
+ lib/original-display-name: Name
+ lib/original-join-alias: Content - Entity Qualified
+ lib/original-name: name
+ lib/source: source/joins
+ lib/source-column-alias: name
+ qp/implicit-field?: true
+- active: true
+ base_type: type/Integer
+ database_type: int4
+ display_name: Content - Entity Qualified → Entity ID
+ effective_type: type/Integer
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_content, entity_id]
+ - {join-alias: Content - Entity Qualified}
+ id: [Internal Metabase Database, public, v_content, entity_id]
+ name: entity_id
+ position: 0
+ semantic_type: type/PK
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_content]
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1018
+ lib/deduplicated-name: entity_id
+ lib/desired-column-alias: Content - Entity Qualified__entity_id
+ lib/from-model?: true
+ lib/join-alias: Content - Entity Qualified
+ lib/original-display-name: Entity ID
+ lib/original-join-alias: Content - Entity Qualified
+ lib/original-name: entity_id
+ lib/source: source/joins
+ lib/source-column-alias: entity_id
+ qp/implicit-field?: true
+- base_type: type/Text
+ display_name: entity_type_path
+ effective_type: type/Text
+ field_ref: [expression, entity_type_path]
+ name: entity_type_path
+ source: breakout
+ lib/breakout?: true
+ lib/deduplicated-name: entity_type_path
+ lib/desired-column-alias: entity_type_path
+ lib/expression-name: entity_type_path
+ lib/original-name: entity_type_path
+ lib/source: source/expressions
+ lib/source-column-alias: entity_type_path
+- base_type: type/Boolean
+ display_name: is_published
+ effective_type: type/Boolean
+ field_ref: [expression, is_published]
+ name: is_published
+ source: breakout
+ lib/breakout?: true
+ lib/deduplicated-name: is_published
+ lib/desired-column-alias: is_published
+ lib/expression-name: is_published
+ lib/original-name: is_published
+ lib/source: source/expressions
+ lib/source-column-alias: is_published
+- base_type: type/Integer
+ display_name: Count
+ effective_type: type/Integer
+ field_ref: [aggregation, 0]
+ name: count
+ semantic_type: type/Quantity
+ source: aggregation
+ lib/deduplicated-name: count
+ lib/desired-column-alias: count
+ lib/original-name: count
+ lib/source: source/aggregations
+ lib/source-column-alias: count
+visualization_settings:
+ column_settings:
+ '["name","count"]': {column_title: Views, show_mini_bar: true}
+ '["name","entity_id"]': {column_title: Entity ID}
+ '["name","is_published"]': {column_title: Published}
+ '["name","name"]': {column_title: Content, link_text: '', link_url: '/{{entity_type_path}}/{{entity_id}}', view_as: link}
+ table.cell_column: count
+ table.columns:
+ - enabled: true
+ fieldRef:
+ - field
+ - [Internal Metabase Database, public, v_content, name]
+ - {base-type: type/Text, join-alias: Content - Entity Qualified}
+ name: name
+ - enabled: false
+ fieldRef:
+ - field
+ - [Internal Metabase Database, public, v_content, entity_id]
+ - {base-type: type/Integer, join-alias: Content - Entity Qualified}
+ name: entity_id
+ - enabled: false
+ fieldRef:
+ - expression
+ - entity_type_path
+ - {base-type: type/Text}
+ name: entity_type_path
+ - enabled: true
+ fieldRef:
+ - expression
+ - is_published
+ - {base-type: type/Boolean}
+ name: is_published
+ - enabled: true
+ fieldRef: [aggregation, 0]
+ name: count
+ table.pivot: false
+card_schema: 23
+serdes/meta:
+- {id: xU_hRFlFpimUOpJTzfnOw, label: most_viewed_public_links, model: Card}
+dashboard_id: 2NWw98hfm_kimGA4xuyMW
+source_card_id: P6Ityjj7igswKh4NgZZjz
+type: question
diff --git a/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/public_link_views.yaml b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/public_link_views.yaml
new file mode 100644
index 00000000000..5d55db79222
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/public_link_views.yaml
@@ -0,0 +1,108 @@
+name: Public link views
+entity_id: QWuymxfyCmXYraR_cjBDR
+created_at: '2026-04-22T11:10:00Z'
+creator_id: [email protected]
+display: smartscalar
+collection_id: vG58R8k-QddHWA7_47umn
+query_type: query
+database_id: Internal Metabase Database
+table_id: [Internal Metabase Database, public, v_view_log]
+parameters: []
+parameter_mappings: []
+dataset_query:
+ database: Internal Metabase Database
+ stages:
+ - aggregation:
+ - - count
+ - {}
+ breakout:
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, temporal-unit: week}
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ expressions:
+ - - not
+ - {lib/expression-name: is_top_level}
+ - - and
+ - {}
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_type]
+ - card
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - dashboard
+ filters:
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - embedding-public
+ - - =
+ - {}
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_top_level
+ - true
+ source-card: P6Ityjj7igswKh4NgZZjz
+ lib/type: mbql.stage/mbql
+ lib/type: mbql/query
+result_metadata:
+- active: true
+ base_type: type/DateTimeWithLocalTZ
+ database_type: timestamptz
+ description: When the view happened
+ display_name: 'Timestamp: Week'
+ effective_type: type/DateTimeWithLocalTZ
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {temporal-unit: week}
+ id: [Internal Metabase Database, public, v_view_log, timestamp]
+ inherited_temporal_unit: week
+ name: timestamp
+ position: 1
+ semantic_type: type/CreationTimestamp
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_view_log]
+ unit: week
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1020
+ lib/deduplicated-name: timestamp
+ lib/desired-column-alias: timestamp
+ lib/from-model?: true
+ lib/original-display-name: Timestamp
+ lib/original-name: timestamp
+ lib/source: source/previous-stage
+ lib/source-column-alias: timestamp
+ lib/temporal-unit: week
+- base_type: type/Integer
+ display_name: Count
+ effective_type: type/Integer
+ field_ref: [aggregation, 0]
+ name: count
+ semantic_type: type/Quantity
+ source: aggregation
+ lib/deduplicated-name: count
+ lib/desired-column-alias: count
+ lib/original-name: count
+ lib/source: source/aggregations
+ lib/source-column-alias: count
+visualization_settings: {column_settings: null}
+card_schema: 23
+serdes/meta:
+- {id: QWuymxfyCmXYraR_cjBDR, label: public_link_views, model: Card}
+dashboard_id: 2NWw98hfm_kimGA4xuyMW
+source_card_id: P6Ityjj7igswKh4NgZZjz
+type: question
diff --git a/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/tenants_with_most_views.yaml b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/tenants_with_most_views.yaml
new file mode 100644
index 00000000000..30e8bad8736
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/tenants_with_most_views.yaml
@@ -0,0 +1,99 @@
+name: Tenants with most views
+entity_id: URLiB2ln8D_T0dIYGNA1O
+created_at: '2026-04-22T08:30:00Z'
+creator_id: [email protected]
+display: table
+collection_id: vG58R8k-QddHWA7_47umn
+query_type: query
+database_id: Internal Metabase Database
+table_id: [Internal Metabase Database, public, v_view_log]
+parameters: []
+parameter_mappings: []
+dataset_query:
+ database: Internal Metabase Database
+ stages:
+ - aggregation:
+ - - count
+ - {lib/uuid: 2d944947-900e-4f2a-850d-656faa225090}
+ - - distinct
+ - {}
+ - - field
+ - {base-type: type/*, effective-type: type/*, lib/uuid: 5b24d394-804e-47ee-a876-f161af64cb05}
+ - user_id
+ breakout:
+ - - field
+ - {base-type: type/Text, effective-type: type/Text, join-alias: Tenants}
+ - [Internal Metabase Database, public, v_tenants, name]
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer, join-alias: Tenants}
+ - [Internal Metabase Database, public, v_tenants, tenant_id]
+ filters:
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer}
+ - [Internal Metabase Database, public, v_view_log, tenant_id]
+ - - time-interval
+ - {include-current: true}
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, lib/uuid: 51171b56-4f9f-410a-b399-ce7904eeb94e}
+ - timestamp
+ - -30
+ - day
+ joins:
+ - alias: Tenants
+ conditions:
+ - - =
+ - {}
+ - - field
+ - {base-type: type/*, effective-type: type/*, lib/uuid: 5281bd5b-7c6e-4702-90ec-20fd6953ede1}
+ - tenant_id
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer, join-alias: Tenants}
+ - [Internal Metabase Database, public, v_tenants, tenant_id]
+ stages:
+ - {source-card: 7ttdbco3tMmYqcRxPsMgm, lib/type: mbql.stage/mbql}
+ strategy: left-join
+ lib/options: {lib/uuid: 3f8a9c21-7b4d-4e16-8923-5a1b0e4d6c72}
+ lib/type: mbql/join
+ order-by:
+ - - desc
+ - {}
+ - - aggregation
+ - {base-type: type/BigInteger, effective-type: type/BigInteger, lib/source-name: count}
+ - 2d944947-900e-4f2a-850d-656faa225090
+ source-card: P6Ityjj7igswKh4NgZZjz
+ lib/type: mbql.stage/mbql
+ lib/type: mbql/query
+visualization_settings:
+ column_settings:
+ '["name","count"]': {column_title: Views, show_mini_bar: true}
+ '["name","count_2"]': {column_title: Active users, show_mini_bar: true}
+ '["name","name"]': {column_title: Tenant, link_url: question/199, view_as: link}
+ '["name","tenant_id"]': {column_title: Tenant ID, link_url: question/199, view_as: link}
+ table.cell_column: count
+ table.columns:
+ - enabled: true
+ fieldRef:
+ - field
+ - [Internal Metabase Database, public, v_tenants, name]
+ - {base-type: type/Text, join-alias: Tenants}
+ name: name
+ - enabled: false
+ fieldRef:
+ - field
+ - [Internal Metabase Database, public, v_tenants, tenant_id]
+ - {base-type: type/Integer, join-alias: Tenants}
+ name: tenant_id
+ - enabled: true
+ fieldRef: [aggregation, 0]
+ name: count
+ - {enabled: true, name: count_2}
+ table.pivot: false
+ table.pivot_column: name
+card_schema: 23
+serdes/meta:
+- {id: URLiB2ln8D_T0dIYGNA1O, label: tenants_with_most_views, model: Card}
+dashboard_id: 2NWw98hfm_kimGA4xuyMW
+source_card_id: P6Ityjj7igswKh4NgZZjz
+type: question
diff --git a/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/unique_users.yaml b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/unique_users.yaml
new file mode 100644
index 00000000000..bdce141e472
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/unique_users.yaml
@@ -0,0 +1,131 @@
+name: Unique users
+entity_id: Unn3ZfmU9z6I1JAfyWqKK
+created_at: '2026-04-21T08:59:32.759117Z'
+creator_id: [email protected]
+display: smartscalar
+collection_id: vG58R8k-QddHWA7_47umn
+query_type: query
+database_id: Internal Metabase Database
+table_id: [Internal Metabase Database, public, v_view_log]
+parameters: []
+parameter_mappings: []
+dataset_query:
+ database: Internal Metabase Database
+ stages:
+ - aggregation:
+ - - distinct
+ - {}
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer}
+ - [Internal Metabase Database, public, v_view_log, user_id]
+ breakout:
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, temporal-unit: week}
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ expressions:
+ - - and
+ - {lib/expression-name: is_auth_embed}
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - - not-in
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ - public
+ - guest
+ - - not
+ - {lib/expression-name: is_top_level}
+ - - and
+ - {}
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_type]
+ - card
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - dashboard
+ filters:
+ - - =
+ - {}
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_auth_embed
+ - true
+ - - =
+ - {}
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_top_level
+ - true
+ - - '!='
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ - guest
+ source-card: P6Ityjj7igswKh4NgZZjz
+ lib/type: mbql.stage/mbql
+ lib/type: mbql/query
+result_metadata:
+- active: true
+ base_type: type/DateTimeWithLocalTZ
+ database_type: timestamptz
+ description: When the view happened
+ display_name: 'Timestamp: Week'
+ effective_type: type/DateTimeWithLocalTZ
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {temporal-unit: week}
+ id: [Internal Metabase Database, public, v_view_log, timestamp]
+ inherited_temporal_unit: week
+ name: timestamp
+ position: 1
+ semantic_type: type/CreationTimestamp
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_view_log]
+ unit: week
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1020
+ lib/deduplicated-name: timestamp
+ lib/desired-column-alias: timestamp
+ lib/from-model?: true
+ lib/original-display-name: Timestamp
+ lib/original-name: timestamp
+ lib/source: source/previous-stage
+ lib/source-column-alias: timestamp
+ lib/temporal-unit: week
+- base_type: type/Integer
+ display_name: Distinct values of User ID
+ effective_type: type/Integer
+ field_ref: [aggregation, 0]
+ name: count
+ semantic_type: type/Quantity
+ source: aggregation
+ lib/deduplicated-name: count
+ lib/desired-column-alias: count
+ lib/original-name: count
+ lib/source: source/aggregations
+ lib/source-column-alias: count
+visualization_settings: {column_settings: null}
+card_schema: 23
+serdes/meta:
+- {id: Unn3ZfmU9z6I1JAfyWqKK, label: unique_users, model: Card}
+dashboard_id: 2NWw98hfm_kimGA4xuyMW
+source_card_id: P6Ityjj7igswKh4NgZZjz
+type: question
diff --git a/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/views_by_auth_method.yaml b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/views_by_auth_method.yaml
new file mode 100644
index 00000000000..dcf660231a4
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/views_by_auth_method.yaml
@@ -0,0 +1,160 @@
+name: Views by auth method
+description: Embedding views over time, broken down by authentication method (JWT, SAML, guest, etc.).
+entity_id: tga1bdEHrCMoNo6ZYJRcq
+created_at: '2026-04-21T15:30:00Z'
+creator_id: [email protected]
+display: bar
+collection_id: vG58R8k-QddHWA7_47umn
+query_type: query
+database_id: Internal Metabase Database
+table_id: [Internal Metabase Database, public, v_view_log]
+parameters: []
+parameter_mappings: []
+dataset_query:
+ database: Internal Metabase Database
+ stages:
+ - aggregation:
+ - - count
+ - {}
+ breakout:
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, temporal-unit: week}
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ expressions:
+ - - and
+ - {lib/expression-name: is_embed}
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - - not-in
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ - public
+ - - not
+ - {lib/expression-name: is_top_level}
+ - - and
+ - {}
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_type]
+ - card
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - dashboard
+ filters:
+ - - =
+ - {}
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_embed
+ - true
+ - - =
+ - {}
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_top_level
+ - true
+ source-card: P6Ityjj7igswKh4NgZZjz
+ lib/type: mbql.stage/mbql
+ lib/type: mbql/query
+result_metadata:
+- active: true
+ base_type: type/DateTimeWithLocalTZ
+ database_type: timestamptz
+ description: When the view happened
+ display_name: 'Timestamp: Week'
+ effective_type: type/DateTimeWithLocalTZ
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {temporal-unit: week}
+ id: [Internal Metabase Database, public, v_view_log, timestamp]
+ inherited_temporal_unit: week
+ name: timestamp
+ position: 1
+ semantic_type: type/CreationTimestamp
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_view_log]
+ unit: week
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1020
+ lib/deduplicated-name: timestamp
+ lib/desired-column-alias: timestamp
+ lib/from-model?: true
+ lib/original-display-name: Timestamp
+ lib/original-name: timestamp
+ lib/source: source/previous-stage
+ lib/source-column-alias: timestamp
+ lib/temporal-unit: week
+- active: true
+ base_type: type/Text
+ database_type: varchar
+ display_name: Auth Method
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ - null
+ id: [Internal Metabase Database, public, v_view_log, auth_method]
+ name: auth_method
+ position: 13
+ semantic_type: type/Category
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_view_log]
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1020
+ lib/deduplicated-name: auth_method
+ lib/desired-column-alias: auth_method
+ lib/from-model?: true
+ lib/internal-remap:
+ human-readable-values: [API key, Guest, JWT, Password, public, SAML]
+ id: 288
+ name: Auth Method
+ values: [api-key, guest, jwt, password, public, saml]
+ lib/type: metadata.column.remapping/internal
+ lib/original-display-name: Auth Method
+ lib/original-name: auth_method
+ lib/source: source/previous-stage
+ lib/source-column-alias: auth_method
+- base_type: type/Integer
+ display_name: Count
+ effective_type: type/Integer
+ field_ref: [aggregation, 0]
+ name: count
+ semantic_type: type/Quantity
+ source: aggregation
+ lib/deduplicated-name: count
+ lib/desired-column-alias: count
+ lib/original-name: count
+ lib/source: source/aggregations
+ lib/source-column-alias: count
+visualization_settings:
+ column_settings: null
+ graph.dimensions: [timestamp, auth_method]
+ graph.metrics: [count]
+ stackable.stack_type: stacked
+card_schema: 23
+serdes/meta:
+- {id: tga1bdEHrCMoNo6ZYJRcq, label: views_by_auth_method, model: Card}
+dashboard_id: 2NWw98hfm_kimGA4xuyMW
+source_card_id: P6Ityjj7igswKh4NgZZjz
+type: question
diff --git a/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/views_by_embedding_client.yaml b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/views_by_embedding_client.yaml
new file mode 100644
index 00000000000..d77c552ea73
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/views_by_embedding_client.yaml
@@ -0,0 +1,160 @@
+name: Views by embedding client
+description: Embedding views over time, broken down by the client that served them (SDK, iframe, legacy, etc.).
+entity_id: hYmO_Z9wc9dIqRPmvblbh
+created_at: '2026-04-21T15:00:00Z'
+creator_id: [email protected]
+display: bar
+collection_id: vG58R8k-QddHWA7_47umn
+query_type: query
+database_id: Internal Metabase Database
+table_id: [Internal Metabase Database, public, v_view_log]
+parameters: []
+parameter_mappings: []
+dataset_query:
+ database: Internal Metabase Database
+ stages:
+ - aggregation:
+ - - count
+ - {}
+ breakout:
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, temporal-unit: week}
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ expressions:
+ - - and
+ - {lib/expression-name: is_embed}
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - - not-in
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ - public
+ - - not
+ - {lib/expression-name: is_top_level}
+ - - and
+ - {}
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, entity_type]
+ - card
+ - - not-null
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - - =
+ - {}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
+ - dashboard
+ filters:
+ - - =
+ - {}
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_embed
+ - true
+ - - =
+ - {}
+ - - expression
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - is_top_level
+ - true
+ source-card: P6Ityjj7igswKh4NgZZjz
+ lib/type: mbql.stage/mbql
+ lib/type: mbql/query
+result_metadata:
+- active: true
+ base_type: type/DateTimeWithLocalTZ
+ database_type: timestamptz
+ description: When the view happened
+ display_name: 'Timestamp: Week'
+ effective_type: type/DateTimeWithLocalTZ
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, timestamp]
+ - {temporal-unit: week}
+ id: [Internal Metabase Database, public, v_view_log, timestamp]
+ inherited_temporal_unit: week
+ name: timestamp
+ position: 1
+ semantic_type: type/CreationTimestamp
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_view_log]
+ unit: week
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1020
+ lib/deduplicated-name: timestamp
+ lib/desired-column-alias: timestamp
+ lib/from-model?: true
+ lib/original-display-name: Timestamp
+ lib/original-name: timestamp
+ lib/source: source/previous-stage
+ lib/source-column-alias: timestamp
+ lib/temporal-unit: week
+- active: true
+ base_type: type/Text
+ database_type: varchar
+ display_name: Embedding Client
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - null
+ id: [Internal Metabase Database, public, v_view_log, embedding_client]
+ name: embedding_client
+ position: 6
+ semantic_type: type/Category
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_view_log]
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1020
+ lib/deduplicated-name: embedding_client
+ lib/desired-column-alias: embedding_client
+ lib/from-model?: true
+ lib/internal-remap:
+ human-readable-values: [Modular embedding SDK, Modular embedding SDK (Preview), Modular embedding, Modular embedding (Preview), Public sharing, Static embedding, Static embedding (Preview), Full app embedding, Full app embedding (Preview)]
+ id: 291
+ name: Embedding Client
+ values: [embedding-sdk-react, embedding-sdk-react-preview, embedding-simple, embedding-simple-preview, embedding-public, embedding-iframe-static, embedding-iframe-static-preview, embedding-iframe-full-app, embedding-iframe-full-app-preview]
+ lib/type: metadata.column.remapping/internal
+ lib/original-display-name: Embedding Client
+ lib/original-name: embedding_client
+ lib/source: source/previous-stage
+ lib/source-column-alias: embedding_client
+- base_type: type/Integer
+ display_name: Count
+ effective_type: type/Integer
+ field_ref: [aggregation, 0]
+ name: count
+ semantic_type: type/Quantity
+ source: aggregation
+ lib/deduplicated-name: count
+ lib/desired-column-alias: count
+ lib/original-name: count
+ lib/source: source/aggregations
+ lib/source-column-alias: count
+visualization_settings:
+ column_settings: null
+ graph.dimensions: [timestamp, embedding_client]
+ graph.metrics: [count]
+ stackable.stack_type: stacked
+card_schema: 23
+serdes/meta:
+- {id: hYmO_Z9wc9dIqRPmvblbh, label: views_by_embedding_client, model: Card}
+dashboard_id: 2NWw98hfm_kimGA4xuyMW
+source_card_id: P6Ityjj7igswKh4NgZZjz
+type: question
diff --git a/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/views_by_embedding_host.yaml b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/views_by_embedding_host.yaml
new file mode 100644
index 00000000000..837f77beb59
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/views_by_embedding_host.yaml
@@ -0,0 +1,90 @@
+name: Views by embedding host
+description: Breakdown of embed views by the hostname where Metabase is embedded.
+entity_id: groy2C3BTTfonftkwwXDU
+created_at: '2026-04-23T12:00:00Z'
+creator_id: [email protected]
+display: pie
+collection_id: vG58R8k-QddHWA7_47umn
+query_type: query
+database_id: Internal Metabase Database
+table_id: [Internal Metabase Database, public, v_view_log]
+parameters: []
+parameter_mappings: []
+dataset_query:
+ database: Internal Metabase Database
+ stages:
+ - aggregation:
+ - - count
+ - {}
+ breakout:
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_hostname]
+ expressions:
+ - - not-null
+ - {effective-type: type/Boolean, lib/expression-name: is_embed}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text, lib/uuid: dff4c1e8-b51b-4250-b6bb-d90b8cd71cc2}
+ - embedding_client
+ filters:
+ - - =
+ - {}
+ - - expression
+ - {effective-type: type/Boolean}
+ - is_embed
+ - true
+ - - time-interval
+ - {include-current: true}
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, inherited-temporal-unit: default, lib/uuid: 6c8ef7a0-4224-42f7-b819-dd5ac021a2ca}
+ - timestamp
+ - -30
+ - day
+ source-card: P6Ityjj7igswKh4NgZZjz
+ lib/type: mbql.stage/mbql
+ lib/type: mbql/query
+result_metadata:
+- active: true
+ base_type: type/Text
+ database_type: varchar
+ display_name: Embedding Hostname
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, embedding_hostname]
+ - null
+ id: [Internal Metabase Database, public, v_view_log, embedding_hostname]
+ name: embedding_hostname
+ position: 15
+ semantic_type: type/Category
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_view_log]
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1020
+ lib/deduplicated-name: embedding_hostname
+ lib/desired-column-alias: embedding_hostname
+ lib/from-model?: true
+ lib/original-display-name: Embedding Hostname
+ lib/original-name: embedding_hostname
+ lib/source: source/previous-stage
+ lib/source-column-alias: embedding_hostname
+- base_type: type/Integer
+ display_name: Count
+ effective_type: type/Integer
+ field_ref: [aggregation, 0]
+ name: count
+ semantic_type: type/Quantity
+ source: aggregation
+ lib/deduplicated-name: count
+ lib/desired-column-alias: count
+ lib/original-name: count
+ lib/source: source/aggregations
+ lib/source-column-alias: count
+visualization_settings: {column_settings: null, pie.dimension: embedding_hostname, pie.metric: count}
+card_schema: 23
+serdes/meta:
+- {id: groy2C3BTTfonftkwwXDU, label: views_by_embedding_host, model: Card}
+dashboard_id: 2NWw98hfm_kimGA4xuyMW
+source_card_id: P6Ityjj7igswKh4NgZZjz
+type: question
diff --git a/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/views_by_user_agent.yaml b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/views_by_user_agent.yaml
new file mode 100644
index 00000000000..250ccc7f434
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/embedding_usage/views_by_user_agent.yaml
@@ -0,0 +1,90 @@
+name: Views by user agent
+description: Breakdown of embed views by sanitized user agent (browser + OS).
+entity_id: CZVMu5tqSLaV7WIQNnL77
+created_at: '2026-04-22T11:10:00Z'
+creator_id: [email protected]
+display: pie
+collection_id: vG58R8k-QddHWA7_47umn
+query_type: query
+database_id: Internal Metabase Database
+table_id: [Internal Metabase Database, public, v_view_log]
+parameters: []
+parameter_mappings: []
+dataset_query:
+ database: Internal Metabase Database
+ stages:
+ - aggregation:
+ - - count
+ - {}
+ breakout:
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, sanitized_user_agent]
+ expressions:
+ - - not-null
+ - {effective-type: type/Boolean, lib/expression-name: is_embed}
+ - - field
+ - {base-type: type/Text, effective-type: type/Text, lib/uuid: a7743886-95fd-4560-8c48-737742789d58}
+ - embedding_client
+ filters:
+ - - =
+ - {}
+ - - expression
+ - {effective-type: type/Boolean}
+ - is_embed
+ - true
+ - - time-interval
+ - {include-current: true}
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ, inherited-temporal-unit: default, lib/uuid: 89b84624-a957-4825-b587-430c79e2e6e9}
+ - timestamp
+ - -30
+ - day
+ source-card: P6Ityjj7igswKh4NgZZjz
+ lib/type: mbql.stage/mbql
+ lib/type: mbql/query
+result_metadata:
+- active: true
+ base_type: type/Text
+ database_type: varchar
+ display_name: Sanitized User Agent
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, sanitized_user_agent]
+ - null
+ id: [Internal Metabase Database, public, v_view_log, sanitized_user_agent]
+ name: sanitized_user_agent
+ position: 18
+ semantic_type: type/Category
+ source: breakout
+ table_id: [Internal Metabase Database, public, v_view_log]
+ visibility_type: normal
+ lib/breakout?: true
+ lib/card-id: 1020
+ lib/deduplicated-name: sanitized_user_agent
+ lib/desired-column-alias: sanitized_user_agent
+ lib/from-model?: true
+ lib/original-display-name: Sanitized User Agent
+ lib/original-name: sanitized_user_agent
+ lib/source: source/previous-stage
+ lib/source-column-alias: sanitized_user_agent
+- base_type: type/Integer
+ display_name: Count
+ effective_type: type/Integer
+ field_ref: [aggregation, 0]
+ name: count
+ semantic_type: type/Quantity
+ source: aggregation
+ lib/deduplicated-name: count
+ lib/desired-column-alias: count
+ lib/original-name: count
+ lib/source: source/aggregations
+ lib/source-column-alias: count
+visualization_settings: {column_settings: null, pie.dimension: sanitized_user_agent, pie.metric: count}
+card_schema: 23
+serdes/meta:
+- {id: CZVMu5tqSLaV7WIQNnL77, label: views_by_user_agent, model: Card}
+dashboard_id: 2NWw98hfm_kimGA4xuyMW
+source_card_id: P6Ityjj7igswKh4NgZZjz
+type: question
diff --git a/resources/instance_analytics/collections/main/usage_analytics/people.yaml b/resources/instance_analytics/collections/main/usage_analytics/people.yaml
index c56496cb505..d23ba47e18e 100644
--- a/resources/instance_analytics/collections/main/usage_analytics/people.yaml
+++ b/resources/instance_analytics/collections/main/usage_analytics/people.yaml
@@ -231,6 +231,21 @@ result_metadata:
semantic_type: null
settings: null
visibility_type: normal
+- base_type: type/Integer
+ coercion_strategy: null
+ description: null
+ display_name: Tenant ID
+ effective_type: type/Integer
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_users, tenant_id]
+ - null
+ fk_target_field_id: [Internal Metabase Database, public, v_tenants, tenant_id]
+ id: [Internal Metabase Database, public, v_users, tenant_id]
+ name: tenant_id
+ semantic_type: type/FK
+ settings: null
+ visibility_type: normal
visualization_settings: {column_settings: null, table.cell_column: locale, table.pivot_column: sso_source}
card_schema: 23
serdes/meta:
diff --git a/resources/instance_analytics/collections/main/usage_analytics/performance_overview.yaml b/resources/instance_analytics/collections/main/usage_analytics/performance_overview.yaml
index 7545e9783b9..d3829a425d3 100644
--- a/resources/instance_analytics/collections/main/usage_analytics/performance_overview.yaml
+++ b/resources/instance_analytics/collections/main/usage_analytics/performance_overview.yaml
@@ -18,6 +18,106 @@ parameters:
serdes/meta:
- {id: Glqmoytsnu0n6rfLUjock, label: performance_overview, model: Dashboard}
dashcards:
+- entity_id: UlsgYi_x2daJzHLZ2swws
+ card_id: vsyV8w3Ucl-JGTgeS8bny
+ created_at: '2024-05-15T20:30:53.532641Z'
+ row: 0
+ col: 0
+ size_x: 12
+ size_y: 7
+ dashboard_tab_id: [Glqmoytsnu0n6rfLUjock, JhgNHmeFZrMlDjtQX14Xg]
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: vsyV8w3Ucl-JGTgeS8bny
+ parameter_id: cbef6d30
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_databases, name]
+ - base-type: type/Text
+ source-field: [Internal Metabase Database, public, v_query_log, database_qualified_id]
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
+ - {id: JhgNHmeFZrMlDjtQX14Xg, model: DashboardTab}
+ - {id: UlsgYi_x2daJzHLZ2swws, model: DashboardCard}
+- entity_id: lGuQPTtK6YrLmy66Egtb0
+ card_id: aC-dZfkgNTINqvVTNKfCV
+ created_at: '2024-05-15T20:28:48.62533Z'
+ row: 0
+ col: 12
+ size_x: 12
+ size_y: 7
+ dashboard_tab_id: [Glqmoytsnu0n6rfLUjock, JhgNHmeFZrMlDjtQX14Xg]
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: aC-dZfkgNTINqvVTNKfCV
+ parameter_id: cbef6d30
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_databases, name]
+ - base-type: type/Text
+ source-field: [Internal Metabase Database, public, v_query_log, database_qualified_id]
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
+ - {id: JhgNHmeFZrMlDjtQX14Xg, model: DashboardTab}
+ - {id: lGuQPTtK6YrLmy66Egtb0, model: DashboardCard}
+- entity_id: Ef7ZcAuubqThMtFbLv0Uk
+ card_id: HyPss6g8k1a6kSx_ErtVg
+ created_at: '2024-05-15T20:23:36.38975Z'
+ row: 7
+ col: 0
+ size_x: 12
+ size_y: 7
+ dashboard_tab_id: [Glqmoytsnu0n6rfLUjock, JhgNHmeFZrMlDjtQX14Xg]
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: HyPss6g8k1a6kSx_ErtVg
+ parameter_id: cbef6d30
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_databases, name]
+ - base-type: type/Text
+ source-field: [Internal Metabase Database, public, v_query_log, database_qualified_id]
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
+ - {id: JhgNHmeFZrMlDjtQX14Xg, model: DashboardTab}
+ - {id: Ef7ZcAuubqThMtFbLv0Uk, model: DashboardCard}
+- entity_id: JiVoIgWqa_MVtI5BPtjH_
+ card_id: ycqt74TQ1W0kjmkLXFae5
+ created_at: '2024-05-15T20:33:13.586607Z'
+ row: 7
+ col: 12
+ size_x: 12
+ size_y: 7
+ dashboard_tab_id: [Glqmoytsnu0n6rfLUjock, JhgNHmeFZrMlDjtQX14Xg]
+ inline_parameters: []
+ parameter_mappings:
+ - card_id: ycqt74TQ1W0kjmkLXFae5
+ parameter_id: cbef6d30
+ target:
+ - dimension
+ - - field
+ - [Internal Metabase Database, public, v_databases, name]
+ - base-type: type/Text
+ source-field: [Internal Metabase Database, public, v_query_log, database_qualified_id]
+ - {stage-number: 0}
+ series: []
+ visualization_settings: {column_settings: null}
+ serdes/meta:
+ - {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
+ - {id: JhgNHmeFZrMlDjtQX14Xg, model: DashboardTab}
+ - {id: JiVoIgWqa_MVtI5BPtjH_, model: DashboardCard}
- entity_id: iJ6TElSxr9vyZm6PgNn9s
card_id: mm8k37Rgk7ChMNwAUdXK2
created_at: '2023-11-01T11:21:03.166953Z'
@@ -98,38 +198,6 @@ dashcards:
- {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
- {id: jBvRp7n8EAyim_aK6rCnP, model: DashboardTab}
- {id: I6pKZnuNRduK6inlhtJG8, model: DashboardCard}
-- entity_id: GuplD3L8-SZv_or20dYNI
- card_id: zdVQGoMs__No_3l_amEWV
- created_at: '2023-11-13T20:40:42.614766Z'
- row: 0
- col: 12
- size_x: 12
- size_y: 7
- dashboard_tab_id: [Glqmoytsnu0n6rfLUjock, 4cbECWHJ2N1_nIPXQ186S]
- inline_parameters: []
- parameter_mappings:
- - card_id: zdVQGoMs__No_3l_amEWV
- parameter_id: cbef6d30
- target:
- - dimension
- - - field
- - [Internal Metabase Database, public, v_databases, name]
- - source-field: [Internal Metabase Database, public, v_query_log, database_qualified_id]
- - {stage-number: 0}
- - card_id: zdVQGoMs__No_3l_amEWV
- parameter_id: dbeeb776
- target:
- - dimension
- - - field
- - [Internal Metabase Database, public, v_group_members, group_name]
- - {join-alias: Group Members - User}
- - {stage-number: 0}
- series: []
- visualization_settings: {column_settings: null}
- serdes/meta:
- - {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
- - {id: 4cbECWHJ2N1_nIPXQ186S, model: DashboardTab}
- - {id: GuplD3L8-SZv_or20dYNI, model: DashboardCard}
- entity_id: YmdWBHC1EHgN0VI06DiDP
card_id: OCkxXZM5KPJ9zOjYVEnqY
created_at: '2023-11-13T20:40:42.614766Z'
@@ -162,17 +230,17 @@ dashcards:
- {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
- {id: 4cbECWHJ2N1_nIPXQ186S, model: DashboardTab}
- {id: YmdWBHC1EHgN0VI06DiDP, model: DashboardCard}
-- entity_id: aBpCVPlOAxucmmKrdx9VM
- card_id: DuL1yrlkmnqOgz4drGiG4
+- entity_id: GuplD3L8-SZv_or20dYNI
+ card_id: zdVQGoMs__No_3l_amEWV
created_at: '2023-11-13T20:40:42.614766Z'
row: 0
- col: 0
- size_x: 24
- size_y: 9
- dashboard_tab_id: [Glqmoytsnu0n6rfLUjock, w4-8vby2KqplrfPXB_vIf]
+ col: 12
+ size_x: 12
+ size_y: 7
+ dashboard_tab_id: [Glqmoytsnu0n6rfLUjock, 4cbECWHJ2N1_nIPXQ186S]
inline_parameters: []
parameter_mappings:
- - card_id: DuL1yrlkmnqOgz4drGiG4
+ - card_id: zdVQGoMs__No_3l_amEWV
parameter_id: cbef6d30
target:
- dimension
@@ -180,7 +248,7 @@ dashcards:
- [Internal Metabase Database, public, v_databases, name]
- source-field: [Internal Metabase Database, public, v_query_log, database_qualified_id]
- {stage-number: 0}
- - card_id: DuL1yrlkmnqOgz4drGiG4
+ - card_id: zdVQGoMs__No_3l_amEWV
parameter_id: dbeeb776
target:
- dimension
@@ -192,8 +260,8 @@ dashcards:
visualization_settings: {column_settings: null}
serdes/meta:
- {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
- - {id: w4-8vby2KqplrfPXB_vIf, model: DashboardTab}
- - {id: aBpCVPlOAxucmmKrdx9VM, model: DashboardCard}
+ - {id: 4cbECWHJ2N1_nIPXQ186S, model: DashboardTab}
+ - {id: GuplD3L8-SZv_or20dYNI, model: DashboardCard}
- entity_id: K2iosE8HMewiHs5tJAKIB
card_id: KXNGLyYyS1pO_9wMguHIB
created_at: '2023-11-13T20:44:16.084445Z'
@@ -242,107 +310,46 @@ dashcards:
- {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
- {id: m7yuefui-NMfdMQmhW0ML, model: DashboardTab}
- {id: rSsdJlI3VVC8zjbpMZarM, model: DashboardCard}
-- entity_id: Ef7ZcAuubqThMtFbLv0Uk
- card_id: HyPss6g8k1a6kSx_ErtVg
- created_at: '2024-05-15T20:23:36.38975Z'
- row: 7
- col: 0
- size_x: 12
- size_y: 7
- dashboard_tab_id: [Glqmoytsnu0n6rfLUjock, JhgNHmeFZrMlDjtQX14Xg]
- inline_parameters: []
- parameter_mappings:
- - card_id: HyPss6g8k1a6kSx_ErtVg
- parameter_id: cbef6d30
- target:
- - dimension
- - - field
- - [Internal Metabase Database, public, v_databases, name]
- - base-type: type/Text
- source-field: [Internal Metabase Database, public, v_query_log, database_qualified_id]
- - {stage-number: 0}
- series: []
- visualization_settings: {column_settings: null}
- serdes/meta:
- - {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
- - {id: JhgNHmeFZrMlDjtQX14Xg, model: DashboardTab}
- - {id: Ef7ZcAuubqThMtFbLv0Uk, model: DashboardCard}
-- entity_id: lGuQPTtK6YrLmy66Egtb0
- card_id: aC-dZfkgNTINqvVTNKfCV
- created_at: '2024-05-15T20:28:48.62533Z'
+- entity_id: aBpCVPlOAxucmmKrdx9VM
+ card_id: DuL1yrlkmnqOgz4drGiG4
+ created_at: '2023-11-13T20:40:42.614766Z'
row: 0
- col: 12
- size_x: 12
- size_y: 7
- dashboard_tab_id: [Glqmoytsnu0n6rfLUjock, JhgNHmeFZrMlDjtQX14Xg]
+ col: 0
+ size_x: 24
+ size_y: 9
+ dashboard_tab_id: [Glqmoytsnu0n6rfLUjock, w4-8vby2KqplrfPXB_vIf]
inline_parameters: []
parameter_mappings:
- - card_id: aC-dZfkgNTINqvVTNKfCV
+ - card_id: DuL1yrlkmnqOgz4drGiG4
parameter_id: cbef6d30
target:
- dimension
- - field
- [Internal Metabase Database, public, v_databases, name]
- - base-type: type/Text
- source-field: [Internal Metabase Database, public, v_query_log, database_qualified_id]
+ - source-field: [Internal Metabase Database, public, v_query_log, database_qualified_id]
- {stage-number: 0}
- series: []
- visualization_settings: {column_settings: null}
- serdes/meta:
- - {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
- - {id: JhgNHmeFZrMlDjtQX14Xg, model: DashboardTab}
- - {id: lGuQPTtK6YrLmy66Egtb0, model: DashboardCard}
-- entity_id: UlsgYi_x2daJzHLZ2swws
- card_id: vsyV8w3Ucl-JGTgeS8bny
- created_at: '2024-05-15T20:30:53.532641Z'
- row: 0
- col: 0
- size_x: 12
- size_y: 7
- dashboard_tab_id: [Glqmoytsnu0n6rfLUjock, JhgNHmeFZrMlDjtQX14Xg]
- inline_parameters: []
- parameter_mappings:
- - card_id: vsyV8w3Ucl-JGTgeS8bny
- parameter_id: cbef6d30
+ - card_id: DuL1yrlkmnqOgz4drGiG4
+ parameter_id: dbeeb776
target:
- dimension
- - field
- - [Internal Metabase Database, public, v_databases, name]
- - base-type: type/Text
- source-field: [Internal Metabase Database, public, v_query_log, database_qualified_id]
+ - [Internal Metabase Database, public, v_group_members, group_name]
+ - {join-alias: Group Members - User}
- {stage-number: 0}
series: []
visualization_settings: {column_settings: null}
serdes/meta:
- {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
- - {id: JhgNHmeFZrMlDjtQX14Xg, model: DashboardTab}
- - {id: UlsgYi_x2daJzHLZ2swws, model: DashboardCard}
-- entity_id: JiVoIgWqa_MVtI5BPtjH_
- card_id: ycqt74TQ1W0kjmkLXFae5
- created_at: '2024-05-15T20:33:13.586607Z'
- row: 7
- col: 12
- size_x: 12
- size_y: 7
- dashboard_tab_id: [Glqmoytsnu0n6rfLUjock, JhgNHmeFZrMlDjtQX14Xg]
- inline_parameters: []
- parameter_mappings:
- - card_id: ycqt74TQ1W0kjmkLXFae5
- parameter_id: cbef6d30
- target:
- - dimension
- - - field
- - [Internal Metabase Database, public, v_databases, name]
- - base-type: type/Text
- source-field: [Internal Metabase Database, public, v_query_log, database_qualified_id]
- - {stage-number: 0}
- series: []
- visualization_settings: {column_settings: null}
+ - {id: w4-8vby2KqplrfPXB_vIf, model: DashboardTab}
+ - {id: aBpCVPlOAxucmmKrdx9VM, model: DashboardCard}
+tabs:
+- created_at: '2024-05-15T20:20:42.495152Z'
+ entity_id: JhgNHmeFZrMlDjtQX14Xg
+ name: Caching
+ position: 0
serdes/meta:
- {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
- {id: JhgNHmeFZrMlDjtQX14Xg, model: DashboardTab}
- - {id: JiVoIgWqa_MVtI5BPtjH_, model: DashboardCard}
-tabs:
- created_at: '2023-11-13T20:40:42.614766Z'
entity_id: jBvRp7n8EAyim_aK6rCnP
name: Dashboards
@@ -371,11 +378,4 @@ tabs:
serdes/meta:
- {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
- {id: w4-8vby2KqplrfPXB_vIf, model: DashboardTab}
-- created_at: '2024-05-15T20:20:42.495152Z'
- entity_id: JhgNHmeFZrMlDjtQX14Xg
- name: Caching
- position: 0
- serdes/meta:
- - {id: Glqmoytsnu0n6rfLUjock, model: Dashboard}
- - {id: JhgNHmeFZrMlDjtQX14Xg, model: DashboardTab}
width: full
diff --git a/resources/instance_analytics/collections/main/usage_analytics/query_log.yaml b/resources/instance_analytics/collections/main/usage_analytics/query_log.yaml
index f09383ab5dd..4d13ab219a5 100644
--- a/resources/instance_analytics/collections/main/usage_analytics/query_log.yaml
+++ b/resources/instance_analytics/collections/main/usage_analytics/query_log.yaml
@@ -14,7 +14,110 @@ parameter_mappings: []
dataset_query:
database: Internal Metabase Database
stages:
- - source-table: [Internal Metabase Database, public, v_query_log]
+ - fields:
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer}
+ - [Internal Metabase Database, public, v_query_log, entity_id]
+ - - field
+ - {base-type: type/DateTimeWithLocalTZ, effective-type: type/DateTimeWithLocalTZ}
+ - [Internal Metabase Database, public, v_query_log, started_at]
+ - - field
+ - {base-type: type/Float, effective-type: type/Float}
+ - [Internal Metabase Database, public, v_query_log, running_time_seconds]
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer}
+ - [Internal Metabase Database, public, v_query_log, result_rows]
+ - - field
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - [Internal Metabase Database, public, v_query_log, is_native]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, query_source]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, error]
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer}
+ - [Internal Metabase Database, public, v_query_log, user_id]
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer}
+ - [Internal Metabase Database, public, v_query_log, card_id]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, card_qualified_id]
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer}
+ - [Internal Metabase Database, public, v_query_log, dashboard_id]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, dashboard_qualified_id]
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer}
+ - [Internal Metabase Database, public, v_query_log, pulse_id]
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer}
+ - [Internal Metabase Database, public, v_query_log, database_id]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, database_qualified_id]
+ - - field
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - [Internal Metabase Database, public, v_query_log, cache_hit]
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer}
+ - [Internal Metabase Database, public, v_query_log, action_id]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, action_qualified_id]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, query]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, embedding_client]
+ - - field
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - [Internal Metabase Database, public, v_query_log, is_preview]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, embedding_sdk_version]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, metabase_version]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, auth_method]
+ - - field
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - [Internal Metabase Database, public, v_query_log, is_sandboxed]
+ - - field
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - [Internal Metabase Database, public, v_query_log, is_impersonated]
+ - - field
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - [Internal Metabase Database, public, v_query_log, is_db_routed]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, parameters]
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer}
+ - [Internal Metabase Database, public, v_query_log, tenant_id]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, embedding_hostname]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, embedding_path]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, user_agent]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, sanitized_user_agent]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_query_log, ip_address]
+ source-table: [Internal Metabase Database, public, v_query_log]
lib/type: mbql.stage/mbql
lib/type: mbql/query
result_metadata:
@@ -304,6 +407,231 @@ result_metadata:
semantic_type: type/SerializedJSON
settings: null
visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Embedding Client
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, embedding_client]
+ - null
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_query_log, embedding_client]
+ name: embedding_client
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Boolean
+ coercion_strategy: null
+ description: null
+ display_name: Is Preview
+ effective_type: type/Boolean
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, is_preview]
+ - null
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_query_log, is_preview]
+ name: is_preview
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Embedding SDK Package Version
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, embedding_sdk_version]
+ - null
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_query_log, embedding_sdk_version]
+ name: embedding_sdk_version
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Metabase Version
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, metabase_version]
+ - null
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_query_log, metabase_version]
+ name: metabase_version
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Auth Method
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, auth_method]
+ - null
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_query_log, auth_method]
+ name: auth_method
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Boolean
+ coercion_strategy: null
+ description: null
+ display_name: Is Sandboxed
+ effective_type: type/Boolean
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, is_sandboxed]
+ - null
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_query_log, is_sandboxed]
+ name: is_sandboxed
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Boolean
+ coercion_strategy: null
+ description: null
+ display_name: Is Impersonated
+ effective_type: type/Boolean
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, is_impersonated]
+ - null
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_query_log, is_impersonated]
+ name: is_impersonated
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Boolean
+ coercion_strategy: null
+ description: null
+ display_name: Is Db Routed
+ effective_type: type/Boolean
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, is_db_routed]
+ - null
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_query_log, is_db_routed]
+ name: is_db_routed
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Parameters
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, parameters]
+ - null
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_query_log, parameters]
+ name: parameters
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Integer
+ coercion_strategy: null
+ description: null
+ display_name: Tenant ID
+ effective_type: type/Integer
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, tenant_id]
+ - null
+ fk_target_field_id: [Internal Metabase Database, public, v_tenants, tenant_id]
+ id: [Internal Metabase Database, public, v_query_log, tenant_id]
+ name: tenant_id
+ semantic_type: type/FK
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Embedding Hostname
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, embedding_hostname]
+ - null
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_query_log, embedding_hostname]
+ name: embedding_hostname
+ semantic_type: null
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Embedding Path
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, embedding_path]
+ - null
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_query_log, embedding_path]
+ name: embedding_path
+ semantic_type: null
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: User Agent
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, user_agent]
+ - null
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_query_log, user_agent]
+ name: user_agent
+ semantic_type: null
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Sanitized User Agent
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, sanitized_user_agent]
+ - null
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_query_log, sanitized_user_agent]
+ name: sanitized_user_agent
+ semantic_type: null
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: IP Address
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_query_log, ip_address]
+ - null
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_query_log, ip_address]
+ name: ip_address
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
visualization_settings:
column_settings: null
table.cell_column: running_time_seconds
@@ -327,6 +655,21 @@ visualization_settings:
- {enabled: true, name: action_id}
- {enabled: true, name: action_qualified_id}
- {enabled: true, name: query}
+ - {enabled: true, name: embedding_client}
+ - {enabled: true, name: is_preview}
+ - {enabled: true, name: embedding_sdk_version}
+ - {enabled: true, name: metabase_version}
+ - {enabled: true, name: auth_method}
+ - {enabled: true, name: is_sandboxed}
+ - {enabled: true, name: is_impersonated}
+ - {enabled: true, name: is_db_routed}
+ - {enabled: true, name: parameters}
+ - {enabled: true, name: tenant_id}
+ - {enabled: true, name: embedding_hostname}
+ - {enabled: true, name: embedding_path}
+ - {enabled: true, name: user_agent}
+ - {enabled: true, name: sanitized_user_agent}
+ - {enabled: true, name: ip_address}
table.pivot_column: error
card_schema: 23
serdes/meta:
diff --git a/resources/instance_analytics/collections/main/usage_analytics/tenants.yaml b/resources/instance_analytics/collections/main/usage_analytics/tenants.yaml
new file mode 100644
index 00000000000..70d56b95cbe
--- /dev/null
+++ b/resources/instance_analytics/collections/main/usage_analytics/tenants.yaml
@@ -0,0 +1,284 @@
+name: Tenants
+description: All tenants in this Metabase instance
+entity_id: 7ttdbco3tMmYqcRxPsMgm
+created_at: '2026-04-21T16:00:00Z'
+creator_id: [email protected]
+display: table
+collection_id: vG58R8k-QddHWA7_47umn
+query_type: query
+database_id: Internal Metabase Database
+table_id: [Internal Metabase Database, public, v_tenants]
+parameters: []
+parameter_mappings: []
+dataset_query:
+ database: Internal Metabase Database
+ stages:
+ - source-table: [Internal Metabase Database, public, v_tenants]
+ lib/type: mbql.stage/mbql
+ lib/type: mbql/query
+result_metadata:
+- active: true
+ base_type: type/Integer
+ database_type: int4
+ display_name: Tenant ID
+ effective_type: type/Integer
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_tenants, tenant_id]
+ - null
+ id: [Internal Metabase Database, public, v_tenants, tenant_id]
+ name: tenant_id
+ position: 0
+ semantic_type: type/PK
+ source: fields
+ table_id: [Internal Metabase Database, public, v_tenants]
+ visibility_type: normal
+ lib/breakout?: false
+ lib/card-id: 1081
+ lib/deduplicated-name: tenant_id
+ lib/desired-column-alias: tenant_id
+ lib/from-model?: true
+ lib/original-display-name: Tenant ID
+ lib/original-name: tenant_id
+ lib/source: source/previous-stage
+ lib/source-column-alias: tenant_id
+ qp/implicit-field?: true
+- active: true
+ base_type: type/Text
+ database_type: text
+ display_name: Entity Qualified ID
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_tenants, entity_qualified_id]
+ - null
+ id: [Internal Metabase Database, public, v_tenants, entity_qualified_id]
+ name: entity_qualified_id
+ position: 1
+ semantic_type: type/Category
+ source: fields
+ table_id: [Internal Metabase Database, public, v_tenants]
+ visibility_type: normal
+ lib/breakout?: false
+ lib/card-id: 1081
+ lib/deduplicated-name: entity_qualified_id
+ lib/desired-column-alias: entity_qualified_id
+ lib/from-model?: true
+ lib/original-display-name: Entity Qualified ID
+ lib/original-name: entity_qualified_id
+ lib/source: source/previous-stage
+ lib/source-column-alias: entity_qualified_id
+ qp/implicit-field?: true
+- active: true
+ base_type: type/Text
+ database_type: varchar
+ display_name: Name
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_tenants, name]
+ - null
+ id: [Internal Metabase Database, public, v_tenants, name]
+ name: name
+ position: 2
+ semantic_type: type/Name
+ source: fields
+ table_id: [Internal Metabase Database, public, v_tenants]
+ visibility_type: normal
+ lib/breakout?: false
+ lib/card-id: 1081
+ lib/deduplicated-name: name
+ lib/desired-column-alias: name
+ lib/from-model?: true
+ lib/original-display-name: Name
+ lib/original-name: name
+ lib/source: source/previous-stage
+ lib/source-column-alias: name
+ qp/implicit-field?: true
+- active: true
+ base_type: type/Text
+ database_type: varchar
+ display_name: Slug
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_tenants, slug]
+ - null
+ id: [Internal Metabase Database, public, v_tenants, slug]
+ name: slug
+ position: 3
+ semantic_type: type/Category
+ source: fields
+ table_id: [Internal Metabase Database, public, v_tenants]
+ visibility_type: normal
+ lib/breakout?: false
+ lib/card-id: 1081
+ lib/deduplicated-name: slug
+ lib/desired-column-alias: slug
+ lib/from-model?: true
+ lib/original-display-name: Slug
+ lib/original-name: slug
+ lib/source: source/previous-stage
+ lib/source-column-alias: slug
+ qp/implicit-field?: true
+- active: true
+ base_type: type/Boolean
+ database_type: bool
+ display_name: Is Active
+ effective_type: type/Boolean
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_tenants, is_active]
+ - null
+ id: [Internal Metabase Database, public, v_tenants, is_active]
+ name: is_active
+ position: 4
+ semantic_type: type/Category
+ source: fields
+ table_id: [Internal Metabase Database, public, v_tenants]
+ visibility_type: normal
+ lib/breakout?: false
+ lib/card-id: 1081
+ lib/deduplicated-name: is_active
+ lib/desired-column-alias: is_active
+ lib/from-model?: true
+ lib/original-display-name: Is Active
+ lib/original-name: is_active
+ lib/source: source/previous-stage
+ lib/source-column-alias: is_active
+ qp/implicit-field?: true
+- active: true
+ base_type: type/Text
+ database_type: text
+ display_name: Attributes
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_tenants, attributes]
+ - null
+ id: [Internal Metabase Database, public, v_tenants, attributes]
+ name: attributes
+ position: 5
+ semantic_type: type/SerializedJSON
+ source: fields
+ table_id: [Internal Metabase Database, public, v_tenants]
+ visibility_type: normal
+ lib/breakout?: false
+ lib/card-id: 1081
+ lib/deduplicated-name: attributes
+ lib/desired-column-alias: attributes
+ lib/from-model?: true
+ lib/original-display-name: Attributes
+ lib/original-name: attributes
+ lib/source: source/previous-stage
+ lib/source-column-alias: attributes
+ qp/implicit-field?: true
+- active: true
+ base_type: type/DateTimeWithLocalTZ
+ database_type: timestamptz
+ display_name: Created At
+ effective_type: type/DateTimeWithLocalTZ
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_tenants, created_at]
+ - null
+ id: [Internal Metabase Database, public, v_tenants, created_at]
+ name: created_at
+ position: 6
+ semantic_type: type/CreationTimestamp
+ source: fields
+ table_id: [Internal Metabase Database, public, v_tenants]
+ visibility_type: normal
+ lib/breakout?: false
+ lib/card-id: 1081
+ lib/deduplicated-name: created_at
+ lib/desired-column-alias: created_at
+ lib/from-model?: true
+ lib/original-display-name: Created At
+ lib/original-name: created_at
+ lib/source: source/previous-stage
+ lib/source-column-alias: created_at
+ qp/implicit-field?: true
+- active: true
+ base_type: type/DateTimeWithLocalTZ
+ database_type: timestamptz
+ display_name: Updated At
+ effective_type: type/DateTimeWithLocalTZ
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_tenants, updated_at]
+ - null
+ id: [Internal Metabase Database, public, v_tenants, updated_at]
+ name: updated_at
+ position: 7
+ semantic_type: type/UpdatedTimestamp
+ source: fields
+ table_id: [Internal Metabase Database, public, v_tenants]
+ visibility_type: normal
+ lib/breakout?: false
+ lib/card-id: 1081
+ lib/deduplicated-name: updated_at
+ lib/desired-column-alias: updated_at
+ lib/from-model?: true
+ lib/original-display-name: Updated At
+ lib/original-name: updated_at
+ lib/source: source/previous-stage
+ lib/source-column-alias: updated_at
+ qp/implicit-field?: true
+- active: true
+ base_type: type/Integer
+ database_type: int4
+ display_name: Tenant Collection ID
+ effective_type: type/Integer
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_tenants, tenant_collection_id]
+ - null
+ id: [Internal Metabase Database, public, v_tenants, tenant_collection_id]
+ name: tenant_collection_id
+ position: 8
+ semantic_type: null
+ source: fields
+ table_id: [Internal Metabase Database, public, v_tenants]
+ visibility_type: normal
+ lib/breakout?: false
+ lib/card-id: 1081
+ lib/deduplicated-name: tenant_collection_id
+ lib/desired-column-alias: tenant_collection_id
+ lib/from-model?: true
+ lib/original-display-name: Tenant Collection ID
+ lib/original-name: tenant_collection_id
+ lib/source: source/previous-stage
+ lib/source-column-alias: tenant_collection_id
+ qp/implicit-field?: true
+- active: true
+ base_type: type/Text
+ database_type: text
+ display_name: Tenant Collection Qualified ID
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_tenants, tenant_collection_qualified_id]
+ - null
+ id: [Internal Metabase Database, public, v_tenants, tenant_collection_qualified_id]
+ name: tenant_collection_qualified_id
+ position: 9
+ semantic_type: type/Category
+ source: fields
+ table_id: [Internal Metabase Database, public, v_tenants]
+ visibility_type: normal
+ lib/breakout?: false
+ lib/card-id: 1081
+ lib/deduplicated-name: tenant_collection_qualified_id
+ lib/desired-column-alias: tenant_collection_qualified_id
+ lib/from-model?: true
+ lib/original-display-name: Tenant Collection Qualified ID
+ lib/original-name: tenant_collection_qualified_id
+ lib/source: source/previous-stage
+ lib/source-column-alias: tenant_collection_qualified_id
+ qp/implicit-field?: true
+visualization_settings: {column_settings: null, table.cell_column: tenant_collection_qualified_id, table.pivot_column: is_active}
+card_schema: 23
+serdes/meta:
+- {id: 7ttdbco3tMmYqcRxPsMgm, label: tenants, model: Card}
+type: model
diff --git a/resources/instance_analytics/collections/main/usage_analytics/view_log.yaml b/resources/instance_analytics/collections/main/usage_analytics/view_log.yaml
index 318fe7b2053..46734a196b2 100644
--- a/resources/instance_analytics/collections/main/usage_analytics/view_log.yaml
+++ b/resources/instance_analytics/collections/main/usage_analytics/view_log.yaml
@@ -33,6 +33,42 @@ dataset_query:
- - field
- {base-type: type/Text, effective-type: type/Text}
- [Internal Metabase Database, public, v_view_log, entity_qualified_id]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ - - field
+ - {base-type: type/Boolean, effective-type: type/Boolean}
+ - [Internal Metabase Database, public, v_view_log, is_preview]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, metabase_version]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_sdk_version]
+ - - field
+ - {base-type: type/Integer, effective-type: type/Integer}
+ - [Internal Metabase Database, public, v_view_log, tenant_id]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_hostname]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, embedding_path]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, user_agent]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, sanitized_user_agent]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, ip_address]
+ - - field
+ - {base-type: type/Text, effective-type: type/Text}
+ - [Internal Metabase Database, public, v_view_log, context]
order-by:
- - desc
- {}
@@ -134,6 +170,186 @@ result_metadata:
semantic_type: type/FK
settings: null
visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Embedding Client
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, embedding_client]
+ - {base-type: type/Text}
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_view_log, embedding_client]
+ name: embedding_client
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Auth Method
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, auth_method]
+ - {base-type: type/Text}
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_view_log, auth_method]
+ name: auth_method
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Boolean
+ coercion_strategy: null
+ description: null
+ display_name: Is Preview
+ effective_type: type/Boolean
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, is_preview]
+ - {base-type: type/Boolean}
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_view_log, is_preview]
+ name: is_preview
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Metabase Version
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, metabase_version]
+ - {base-type: type/Text}
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_view_log, metabase_version]
+ name: metabase_version
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Embedding SDK Package Version
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, embedding_sdk_version]
+ - {base-type: type/Text}
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_view_log, embedding_sdk_version]
+ name: embedding_sdk_version
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Integer
+ coercion_strategy: null
+ description: null
+ display_name: Tenant ID
+ effective_type: type/Integer
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, tenant_id]
+ - {base-type: type/Integer}
+ fk_target_field_id: [Internal Metabase Database, public, v_tenants, tenant_id]
+ id: [Internal Metabase Database, public, v_view_log, tenant_id]
+ name: tenant_id
+ semantic_type: type/FK
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Embedding Hostname
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, embedding_hostname]
+ - {base-type: type/Text}
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_view_log, embedding_hostname]
+ name: embedding_hostname
+ semantic_type: null
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Embedding Path
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, embedding_path]
+ - {base-type: type/Text}
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_view_log, embedding_path]
+ name: embedding_path
+ semantic_type: null
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: User Agent
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, user_agent]
+ - {base-type: type/Text}
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_view_log, user_agent]
+ name: user_agent
+ semantic_type: null
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: Sanitized User Agent
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, sanitized_user_agent]
+ - {base-type: type/Text}
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_view_log, sanitized_user_agent]
+ name: sanitized_user_agent
+ semantic_type: null
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: null
+ display_name: IP Address
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, ip_address]
+ - {base-type: type/Text}
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_view_log, ip_address]
+ name: ip_address
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
+- base_type: type/Text
+ coercion_strategy: null
+ description: Context the view happened in (dashboard, collection, etc.). Use to filter out dashcards from top-viewed content.
+ display_name: Context
+ effective_type: type/Text
+ field_ref:
+ - field
+ - [Internal Metabase Database, public, v_view_log, context]
+ - {base-type: type/Text}
+ fk_target_field_id: null
+ id: [Internal Metabase Database, public, v_view_log, context]
+ name: context
+ semantic_type: type/Category
+ settings: null
+ visibility_type: normal
visualization_settings: {column_settings: null, table.cell_column: user_id, table.pivot_column: details}
card_schema: 23
serdes/meta:
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/auth_method.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/auth_method.yaml
new file mode 100644
index 00000000000..afe75a95659
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/auth_method.yaml
@@ -0,0 +1,28 @@
+name: auth_method
+display_name: Auth Method
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions:
+- created_at: '2026-04-22T13:37:14.216504Z'
+ entity_id: tSIAFwx4wFNxvZj3OBqCz
+ name: Auth Method
+ type: internal
+ serdes/meta:
+ - {id: tSIAFwx4wFNxvZj3OBqCz, label: auth_method, model: Dimension}
+position: 28
+custom_position: 0
+database_position: 28
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: auth_method, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/auth_method___fieldvalues.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/auth_method___fieldvalues.yaml
new file mode 100644
index 00000000000..9a6b09edc37
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/auth_method___fieldvalues.yaml
@@ -0,0 +1,11 @@
+created_at: '2026-04-22T14:46:18.377074Z'
+human_readable_values: [API key, Guest, JWT, Password]
+last_used_at: '2026-04-22T14:46:18.377074Z'
+type: full
+values: [api-key, guest, jwt, password]
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: auth_method, model: Field}
+- {id: '0', model: FieldValues}
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_client.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_client.yaml
new file mode 100644
index 00000000000..0828b645bd5
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_client.yaml
@@ -0,0 +1,28 @@
+name: embedding_client
+display_name: Embedding Client
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions:
+- created_at: '2026-04-21T16:24:27.061441Z'
+ entity_id: nssVx8_sGrHpkHTjIxxK0
+ name: Embedding Client
+ type: internal
+ serdes/meta:
+ - {id: nssVx8_sGrHpkHTjIxxK0, label: embedding_client, model: Dimension}
+position: 23
+custom_position: 0
+database_position: 23
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: embedding_client, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_client___fieldvalues.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_client___fieldvalues.yaml
new file mode 100644
index 00000000000..b1f9d4269f5
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_client___fieldvalues.yaml
@@ -0,0 +1,11 @@
+created_at: '2026-04-22T14:46:17.273549Z'
+human_readable_values: [Modular embedding SDK, Modular embedding SDK (Preview), Modular embedding, Modular embedding (Preview), Public sharing, Static embedding, Static embedding (Preview), Full app embedding, Full app embedding (Preview)]
+last_used_at: '2026-04-22T14:46:17.273549Z'
+type: full
+values: [embedding-sdk-react, embedding-sdk-react-preview, embedding-simple, embedding-simple-preview, embedding-public, embedding-iframe-static, embedding-iframe-static-preview, embedding-iframe-full-app, embedding-iframe-full-app-preview]
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: embedding_client, model: Field}
+- {id: '0', model: FieldValues}
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_hostname.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_hostname.yaml
new file mode 100644
index 00000000000..96b285e441f
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_hostname.yaml
@@ -0,0 +1,22 @@
+name: embedding_hostname
+display_name: Embedding Hostname
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 34
+custom_position: 0
+database_position: 34
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: embedding_hostname, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_path.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_path.yaml
new file mode 100644
index 00000000000..bcbcfd5ae93
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_path.yaml
@@ -0,0 +1,22 @@
+name: embedding_path
+display_name: Embedding Path
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 35
+custom_position: 0
+database_position: 35
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: embedding_path, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_route.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_route.yaml
new file mode 100644
index 00000000000..6d63a46e754
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_route.yaml
@@ -0,0 +1,22 @@
+name: embedding_route
+display_name: Embedding Route
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 24
+custom_position: 0
+database_position: 24
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: embedding_route, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_sdk_version.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_sdk_version.yaml
new file mode 100644
index 00000000000..e0d22584d71
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/embedding_sdk_version.yaml
@@ -0,0 +1,22 @@
+name: embedding_sdk_version
+display_name: Embedding SDK Package Version
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 26
+custom_position: 0
+database_position: 26
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: embedding_sdk_version, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/ip_address.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/ip_address.yaml
new file mode 100644
index 00000000000..1163aaf9ffc
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/ip_address.yaml
@@ -0,0 +1,22 @@
+name: ip_address
+display_name: IP Address
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 38
+custom_position: 0
+database_position: 38
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: ip_address, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/is_db_routed.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/is_db_routed.yaml
new file mode 100644
index 00000000000..1f575fa2c1b
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/is_db_routed.yaml
@@ -0,0 +1,21 @@
+name: is_db_routed
+display_name: Is Db Routed
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: bool
+base_type: type/Boolean
+effective_type: type/Boolean
+dimensions: []
+position: 31
+custom_position: 0
+database_position: 31
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: is_db_routed, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/is_impersonated.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/is_impersonated.yaml
new file mode 100644
index 00000000000..c59bcdd7cab
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/is_impersonated.yaml
@@ -0,0 +1,21 @@
+name: is_impersonated
+display_name: Is Impersonated
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: bool
+base_type: type/Boolean
+effective_type: type/Boolean
+dimensions: []
+position: 30
+custom_position: 0
+database_position: 30
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: is_impersonated, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/is_preview.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/is_preview.yaml
new file mode 100644
index 00000000000..ea0bdc78581
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/is_preview.yaml
@@ -0,0 +1,21 @@
+name: is_preview
+display_name: Is Preview
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: bool
+base_type: type/Boolean
+effective_type: type/Boolean
+dimensions: []
+position: 25
+custom_position: 0
+database_position: 25
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: is_preview, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/is_sandboxed.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/is_sandboxed.yaml
new file mode 100644
index 00000000000..cba8e42efe2
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/is_sandboxed.yaml
@@ -0,0 +1,21 @@
+name: is_sandboxed
+display_name: Is Sandboxed
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: bool
+base_type: type/Boolean
+effective_type: type/Boolean
+dimensions: []
+position: 29
+custom_position: 0
+database_position: 29
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: is_sandboxed, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/metabase_version.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/metabase_version.yaml
new file mode 100644
index 00000000000..dd6c1c8ed75
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/metabase_version.yaml
@@ -0,0 +1,22 @@
+name: metabase_version
+display_name: Metabase Version
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 27
+custom_position: 0
+database_position: 27
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: metabase_version, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/parameters.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/parameters.yaml
new file mode 100644
index 00000000000..232dc711c21
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/parameters.yaml
@@ -0,0 +1,22 @@
+name: parameters
+display_name: Parameters
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: text
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 32
+custom_position: 0
+database_position: 32
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: parameters, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/sanitized_user_agent.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/sanitized_user_agent.yaml
new file mode 100644
index 00000000000..4e23d7f6a1a
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/sanitized_user_agent.yaml
@@ -0,0 +1,22 @@
+name: sanitized_user_agent
+display_name: Sanitized User Agent
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 37
+custom_position: 0
+database_position: 37
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: sanitized_user_agent, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/tenant_id.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/tenant_id.yaml
new file mode 100644
index 00000000000..fafa8fbb083
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/tenant_id.yaml
@@ -0,0 +1,30 @@
+name: tenant_id
+display_name: Tenant ID
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: int4
+base_type: type/Integer
+effective_type: type/Integer
+semantic_type: type/FK
+fk_target_field_id: [Internal Metabase Database, public, v_tenants, tenant_id]
+dimensions:
+- created_at: '2026-04-22T08:30:40.371511Z'
+ entity_id: SrWQEQU3lWK9qZX0VI2lN
+ human_readable_field_id: [Internal Metabase Database, public, v_tenants, name]
+ name: Tenant
+ type: external
+ serdes/meta:
+ - {id: SrWQEQU3lWK9qZX0VI2lN, label: tenant, model: Dimension}
+position: 33
+custom_position: 0
+database_position: 33
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: tenant_id, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/user_agent.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/user_agent.yaml
new file mode 100644
index 00000000000..9d19ce87558
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_query_log/fields/user_agent.yaml
@@ -0,0 +1,22 @@
+name: user_agent
+display_name: User Agent
+created_at: '2026-04-21T08:37:34.791214Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_query_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 36
+custom_position: 0
+database_position: 36
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_query_log, model: Table}
+- {id: user_agent, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/entity_type.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/entity_type.yaml
index 32747aa42d4..e1e86ec427a 100644
--- a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/entity_type.yaml
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/entity_type.yaml
@@ -6,6 +6,7 @@ table_id: [Internal Metabase Database, public, v_tables]
database_type: varchar
base_type: type/Text
effective_type: type/Text
+semantic_type: type/Category
dimensions: []
position: 11
custom_position: 0
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/estimated_row_count.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/estimated_row_count.yaml
index 79aeb099224..18a042a51f4 100644
--- a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/estimated_row_count.yaml
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/estimated_row_count.yaml
@@ -6,6 +6,7 @@ table_id: [Internal Metabase Database, public, v_tables]
database_type: int8
base_type: type/BigInteger
effective_type: type/BigInteger
+semantic_type: type/Quantity
dimensions: []
position: 13
custom_position: 0
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/owner_email.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/owner_email.yaml
index 0abc25281ba..3a0421889e9 100644
--- a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/owner_email.yaml
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/owner_email.yaml
@@ -6,6 +6,7 @@ table_id: [Internal Metabase Database, public, v_tables]
database_type: text
base_type: type/Text
effective_type: type/Text
+semantic_type: type/Owner
dimensions: []
position: 15
custom_position: 0
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/owner_user_id.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/owner_user_id.yaml
index e58af6ba927..19359e46924 100644
--- a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/owner_user_id.yaml
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/owner_user_id.yaml
@@ -6,6 +6,7 @@ table_id: [Internal Metabase Database, public, v_tables]
database_type: int4
base_type: type/Integer
effective_type: type/Integer
+semantic_type: type/Owner
dimensions: []
position: 16
custom_position: 0
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/view_count.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/view_count.yaml
index 7179bac1744..d47c171ea7f 100644
--- a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/view_count.yaml
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/view_count.yaml
@@ -6,6 +6,7 @@ table_id: [Internal Metabase Database, public, v_tables]
database_type: int4
base_type: type/Integer
effective_type: type/Integer
+semantic_type: type/Quantity
dimensions: []
position: 14
custom_position: 0
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/visibility_type.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/visibility_type.yaml
index 7ce1fcd9437..ddccd1b74d4 100644
--- a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/visibility_type.yaml
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tables/fields/visibility_type.yaml
@@ -6,6 +6,7 @@ table_id: [Internal Metabase Database, public, v_tables]
database_type: varchar
base_type: type/Text
effective_type: type/Text
+semantic_type: type/Category
dimensions: []
position: 12
custom_position: 0
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/attributes.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/attributes.yaml
new file mode 100644
index 00000000000..9888ce199d8
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/attributes.yaml
@@ -0,0 +1,22 @@
+name: attributes
+display_name: Attributes
+created_at: '2026-04-21T08:37:34.861542Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_tenants]
+database_type: text
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 5
+custom_position: 0
+database_position: 5
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_tenants, model: Table}
+- {id: attributes, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/created_at.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/created_at.yaml
new file mode 100644
index 00000000000..bc540ff11cb
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/created_at.yaml
@@ -0,0 +1,21 @@
+name: created_at
+display_name: Created At
+created_at: '2026-04-21T08:37:34.861542Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_tenants]
+database_type: timestamptz
+base_type: type/DateTimeWithLocalTZ
+effective_type: type/DateTimeWithLocalTZ
+semantic_type: type/CreationTimestamp
+dimensions: []
+position: 6
+custom_position: 0
+database_position: 6
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_tenants, model: Table}
+- {id: created_at, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/entity_qualified_id.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/entity_qualified_id.yaml
new file mode 100644
index 00000000000..c2cd8908c26
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/entity_qualified_id.yaml
@@ -0,0 +1,22 @@
+name: entity_qualified_id
+display_name: Entity Qualified ID
+created_at: '2026-04-21T08:37:34.861542Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_tenants]
+database_type: text
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 1
+custom_position: 0
+database_position: 1
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_tenants, model: Table}
+- {id: entity_qualified_id, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/is_active.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/is_active.yaml
new file mode 100644
index 00000000000..816a3e15535
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/is_active.yaml
@@ -0,0 +1,21 @@
+name: is_active
+display_name: Is Active
+created_at: '2026-04-21T08:37:34.861542Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_tenants]
+database_type: bool
+base_type: type/Boolean
+effective_type: type/Boolean
+dimensions: []
+position: 4
+custom_position: 0
+database_position: 4
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_tenants, model: Table}
+- {id: is_active, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/name.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/name.yaml
new file mode 100644
index 00000000000..0922fb622bc
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/name.yaml
@@ -0,0 +1,22 @@
+name: name
+display_name: Name
+created_at: '2026-04-21T08:37:34.861542Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_tenants]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Name
+dimensions: []
+position: 2
+custom_position: 0
+database_position: 2
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_tenants, model: Table}
+- {id: name, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/slug.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/slug.yaml
new file mode 100644
index 00000000000..ded06bd5b74
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/slug.yaml
@@ -0,0 +1,22 @@
+name: slug
+display_name: Slug
+created_at: '2026-04-21T08:37:34.861542Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_tenants]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 3
+custom_position: 0
+database_position: 3
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_tenants, model: Table}
+- {id: slug, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/tenant_collection_id.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/tenant_collection_id.yaml
new file mode 100644
index 00000000000..9a15f2fab56
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/tenant_collection_id.yaml
@@ -0,0 +1,21 @@
+name: tenant_collection_id
+display_name: Tenant Collection ID
+created_at: '2026-04-21T08:37:34.861542Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_tenants]
+database_type: int4
+base_type: type/Integer
+effective_type: type/Integer
+dimensions: []
+position: 8
+custom_position: 0
+database_position: 8
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_tenants, model: Table}
+- {id: tenant_collection_id, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/tenant_collection_qualified_id.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/tenant_collection_qualified_id.yaml
new file mode 100644
index 00000000000..5a5b677fa53
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/tenant_collection_qualified_id.yaml
@@ -0,0 +1,22 @@
+name: tenant_collection_qualified_id
+display_name: Tenant Collection Qualified ID
+created_at: '2026-04-21T08:37:34.861542Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_tenants]
+database_type: text
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 9
+custom_position: 0
+database_position: 9
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_tenants, model: Table}
+- {id: tenant_collection_qualified_id, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/tenant_id.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/tenant_id.yaml
new file mode 100644
index 00000000000..fb527e870e0
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/tenant_id.yaml
@@ -0,0 +1,21 @@
+name: tenant_id
+display_name: Tenant ID
+created_at: '2026-04-21T08:37:34.861542Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_tenants]
+database_type: int4
+base_type: type/Integer
+effective_type: type/Integer
+dimensions: []
+position: 0
+custom_position: 0
+database_position: 0
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_tenants, model: Table}
+- {id: tenant_id, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/updated_at.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/updated_at.yaml
new file mode 100644
index 00000000000..1291a4814e7
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/fields/updated_at.yaml
@@ -0,0 +1,21 @@
+name: updated_at
+display_name: Updated At
+created_at: '2026-04-21T08:37:34.861542Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_tenants]
+database_type: timestamptz
+base_type: type/DateTimeWithLocalTZ
+effective_type: type/DateTimeWithLocalTZ
+semantic_type: type/UpdatedTimestamp
+dimensions: []
+position: 7
+custom_position: 0
+database_position: 7
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_tenants, model: Table}
+- {id: updated_at, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/v_tenants.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/v_tenants.yaml
new file mode 100644
index 00000000000..2411e218373
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_tenants/v_tenants.yaml
@@ -0,0 +1,15 @@
+name: v_tenants
+display_name: V Tenants
+created_at: '2026-04-21T08:37:32.179875Z'
+db_id: Internal Metabase Database
+schema: public
+entity_type: entity/GenericTable
+active: true
+field_order: database
+initial_sync_status: complete
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_tenants, model: Table}
+data_authority: unconfigured
+data_layer: internal
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_users/fields/tenant_id.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_users/fields/tenant_id.yaml
new file mode 100644
index 00000000000..e10550a7a77
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_users/fields/tenant_id.yaml
@@ -0,0 +1,30 @@
+name: tenant_id
+display_name: Tenant ID
+created_at: '2026-04-21T08:37:34.874245Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_users]
+database_type: int4
+base_type: type/Integer
+effective_type: type/Integer
+semantic_type: type/FK
+fk_target_field_id: [Internal Metabase Database, public, v_tenants, tenant_id]
+dimensions:
+- created_at: '2026-04-22T08:30:40.858933Z'
+ entity_id: v5tnim5gwIE3HfB07NEqG
+ human_readable_field_id: [Internal Metabase Database, public, v_tenants, name]
+ name: Tenant
+ type: external
+ serdes/meta:
+ - {id: v5tnim5gwIE3HfB07NEqG, label: tenant, model: Dimension}
+position: 14
+custom_position: 0
+database_position: 14
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_users, model: Table}
+- {id: tenant_id, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_users/fields/tenant_qualified_id.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_users/fields/tenant_qualified_id.yaml
new file mode 100644
index 00000000000..e40e2f2f5e2
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_users/fields/tenant_qualified_id.yaml
@@ -0,0 +1,22 @@
+name: tenant_qualified_id
+display_name: Tenant Qualified ID
+created_at: '2026-04-21T08:37:34.874245Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_users]
+database_type: text
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 15
+custom_position: 0
+database_position: 15
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_users, model: Table}
+- {id: tenant_qualified_id, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/auth_method.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/auth_method.yaml
new file mode 100644
index 00000000000..2cfec378bdd
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/auth_method.yaml
@@ -0,0 +1,28 @@
+name: auth_method
+display_name: Auth Method
+created_at: '2026-04-21T08:37:34.889621Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_view_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions:
+- created_at: '2026-04-22T11:09:22.230197Z'
+ entity_id: Z52VKFCj1VMP9l2TY82mb
+ name: Auth Method
+ type: internal
+ serdes/meta:
+ - {id: Z52VKFCj1VMP9l2TY82mb, label: auth_method, model: Dimension}
+position: 13
+custom_position: 0
+database_position: 13
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: auth_method, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/auth_method___fieldvalues.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/auth_method___fieldvalues.yaml
new file mode 100644
index 00000000000..4a670f47124
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/auth_method___fieldvalues.yaml
@@ -0,0 +1,11 @@
+created_at: '2026-04-22T14:46:17.807133Z'
+human_readable_values: [API key, Guest, JWT, Password, public, SAML]
+last_used_at: '2026-04-22T16:08:53.647096Z'
+type: full
+values: [api-key, guest, jwt, password, public, saml]
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: auth_method, model: Field}
+- {id: '0', model: FieldValues}
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/context.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/context.yaml
new file mode 100644
index 00000000000..7b07d694b87
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/context.yaml
@@ -0,0 +1,22 @@
+name: context
+display_name: Context
+created_at: '2026-04-21T08:37:34.889621Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_view_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 10
+custom_position: 0
+database_position: 10
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: context, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_client.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_client.yaml
new file mode 100644
index 00000000000..bed326c6e83
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_client.yaml
@@ -0,0 +1,28 @@
+name: embedding_client
+display_name: Embedding Client
+created_at: '2026-04-21T08:37:34.889621Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_view_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions:
+- created_at: '2026-04-21T16:21:23.43183Z'
+ entity_id: Q28WWBnVpviA9FlQnjpMo
+ name: Embedding Client
+ type: internal
+ serdes/meta:
+ - {id: Q28WWBnVpviA9FlQnjpMo, label: embedding_client, model: Dimension}
+position: 6
+custom_position: 0
+database_position: 6
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: embedding_client, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_client___fieldvalues.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_client___fieldvalues.yaml
new file mode 100644
index 00000000000..96a676fc5f7
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_client___fieldvalues.yaml
@@ -0,0 +1,11 @@
+created_at: '2026-04-22T14:46:16.631421Z'
+human_readable_values: [Modular embedding SDK, Modular embedding SDK (Preview), Modular embedding, Modular embedding (Preview), Public sharing, Static embedding, Static embedding (Preview), Full app embedding, Full app embedding (Preview)]
+last_used_at: '2026-04-22T16:08:52.003887Z'
+type: full
+values: [embedding-sdk-react, embedding-sdk-react-preview, embedding-simple, embedding-simple-preview, embedding-public, embedding-iframe-static, embedding-iframe-static-preview, embedding-iframe-full-app, embedding-iframe-full-app-preview]
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: embedding_client, model: Field}
+- {id: '0', model: FieldValues}
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_hostname.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_hostname.yaml
new file mode 100644
index 00000000000..e8fa98a931b
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_hostname.yaml
@@ -0,0 +1,22 @@
+name: embedding_hostname
+display_name: Embedding Hostname
+created_at: '2026-04-21T08:37:34.889621Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_view_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 15
+custom_position: 0
+database_position: 15
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: embedding_hostname, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_path.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_path.yaml
new file mode 100644
index 00000000000..d40dbd2156a
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_path.yaml
@@ -0,0 +1,22 @@
+name: embedding_path
+display_name: Embedding Path
+created_at: '2026-04-21T08:37:34.889621Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_view_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 16
+custom_position: 0
+database_position: 16
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: embedding_path, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_route.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_route.yaml
new file mode 100644
index 00000000000..acb945482fe
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_route.yaml
@@ -0,0 +1,22 @@
+name: embedding_route
+display_name: Embedding Route
+created_at: '2026-04-21T08:37:34.889621Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_view_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 7
+custom_position: 0
+database_position: 7
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: embedding_route, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_sdk_version.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_sdk_version.yaml
new file mode 100644
index 00000000000..33dffac1d19
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/embedding_sdk_version.yaml
@@ -0,0 +1,22 @@
+name: embedding_sdk_version
+display_name: Embedding SDK Package Version
+created_at: '2026-04-21T08:37:34.889621Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_view_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 11
+custom_position: 0
+database_position: 11
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: embedding_sdk_version, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/has_access.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/has_access.yaml
new file mode 100644
index 00000000000..7964c4dc419
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/has_access.yaml
@@ -0,0 +1,21 @@
+name: has_access
+display_name: Has Access
+created_at: '2026-04-21T08:37:34.889621Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_view_log]
+database_type: bool
+base_type: type/Boolean
+effective_type: type/Boolean
+dimensions: []
+position: 9
+custom_position: 0
+database_position: 9
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: has_access, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/ip_address.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/ip_address.yaml
new file mode 100644
index 00000000000..115094634b3
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/ip_address.yaml
@@ -0,0 +1,22 @@
+name: ip_address
+display_name: IP Address
+created_at: '2026-04-21T08:37:34.889621Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_view_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 19
+custom_position: 0
+database_position: 19
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: ip_address, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/is_preview.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/is_preview.yaml
new file mode 100644
index 00000000000..5a4e1a211ef
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/is_preview.yaml
@@ -0,0 +1,21 @@
+name: is_preview
+display_name: Is Preview
+created_at: '2026-04-21T08:37:34.889621Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_view_log]
+database_type: bool
+base_type: type/Boolean
+effective_type: type/Boolean
+dimensions: []
+position: 8
+custom_position: 0
+database_position: 8
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: is_preview, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/metabase_version.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/metabase_version.yaml
new file mode 100644
index 00000000000..264ffdf2f6f
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/metabase_version.yaml
@@ -0,0 +1,22 @@
+name: metabase_version
+display_name: Metabase Version
+created_at: '2026-04-21T08:37:34.889621Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_view_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 12
+custom_position: 0
+database_position: 12
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: metabase_version, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/sanitized_user_agent.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/sanitized_user_agent.yaml
new file mode 100644
index 00000000000..b88ced13399
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/sanitized_user_agent.yaml
@@ -0,0 +1,22 @@
+name: sanitized_user_agent
+display_name: Sanitized User Agent
+created_at: '2026-04-21T08:37:34.889621Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_view_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 18
+custom_position: 0
+database_position: 18
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: sanitized_user_agent, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/tenant_id.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/tenant_id.yaml
new file mode 100644
index 00000000000..3e6253d88c7
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/tenant_id.yaml
@@ -0,0 +1,30 @@
+name: tenant_id
+display_name: Tenant ID
+created_at: '2026-04-21T08:37:34.889621Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_view_log]
+database_type: int4
+base_type: type/Integer
+effective_type: type/Integer
+semantic_type: type/FK
+fk_target_field_id: [Internal Metabase Database, public, v_tenants, tenant_id]
+dimensions:
+- created_at: '2026-04-22T08:30:40.093517Z'
+ entity_id: gema7Cwa0xbZfs1jbUuNJ
+ human_readable_field_id: [Internal Metabase Database, public, v_tenants, name]
+ name: Tenant
+ type: external
+ serdes/meta:
+ - {id: gema7Cwa0xbZfs1jbUuNJ, label: tenant, model: Dimension}
+position: 14
+custom_position: 0
+database_position: 14
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: tenant_id, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/user_agent.yaml b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/user_agent.yaml
new file mode 100644
index 00000000000..186633bb3ae
--- /dev/null
+++ b/resources/instance_analytics/databases/internal_metabase_database/schemas/public/tables/v_view_log/fields/user_agent.yaml
@@ -0,0 +1,22 @@
+name: user_agent
+display_name: User Agent
+created_at: '2026-04-21T08:37:34.889621Z'
+visibility_type: normal
+table_id: [Internal Metabase Database, public, v_view_log]
+database_type: varchar
+base_type: type/Text
+effective_type: type/Text
+semantic_type: type/Category
+dimensions: []
+position: 17
+custom_position: 0
+database_position: 17
+has_field_values: auto-list
+serdes/meta:
+- {id: Internal Metabase Database, model: Database}
+- {id: public, model: Schema}
+- {id: v_view_log, model: Table}
+- {id: user_agent, model: Field}
+database_is_generated: false
+database_is_nullable: true
+database_is_pk: false
diff --git a/resources/migrations/061/20260326_enhanced_usage_analytics.yaml b/resources/migrations/061/20260326_enhanced_usage_analytics.yaml
new file mode 100644
index 00000000000..14090ac4b3c
--- /dev/null
+++ b/resources/migrations/061/20260326_enhanced_usage_analytics.yaml
@@ -0,0 +1,508 @@
+## Enhanced usage analytics columns for view_log and query_execution
+
+databaseChangeLog:
+ - logicalFilePath: migrations/061_update_migrations.yaml
+
+ # ============================================================
+ # view_log columns
+ # ============================================================
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:00
+ author: bgrabow
+ comment: Add auth_method column to view_log for tracking authentication method
+ changes:
+ - addColumn:
+ tableName: view_log
+ columns:
+ - column:
+ name: auth_method
+ type: varchar(32)
+ remarks: Authentication method used (e.g. jwt, saml, api-key, public, guest, etc.)
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:01
+ author: bgrabow
+ comment: Add tenant_id column to view_log for multi-tenant analytics
+ changes:
+ - addColumn:
+ tableName: view_log
+ columns:
+ - column:
+ name: tenant_id
+ type: int
+ remarks: Tenant ID of the user who generated this view
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:02
+ author: bgrabow
+ comment: Add embedding_hostname column to view_log for embedding analytics
+ changes:
+ - addColumn:
+ tableName: view_log
+ columns:
+ - column:
+ name: embedding_hostname
+ type: varchar(512)
+ remarks: Hostname from Origin header, PII
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:03
+ author: bgrabow
+ comment: Add embedding_path column to view_log for embedding analytics
+ changes:
+ - addColumn:
+ tableName: view_log
+ columns:
+ - column:
+ name: embedding_path
+ type: varchar(2048)
+ remarks: Path from Referer header (query params stripped), PII
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:04
+ author: bgrabow
+ comment: Add user_agent column to view_log for usage analytics
+ changes:
+ - addColumn:
+ tableName: view_log
+ columns:
+ - column:
+ name: user_agent
+ type: varchar(512)
+ remarks: User-Agent header, PII
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:05
+ author: bgrabow
+ comment: Add ip_address column to view_log for usage analytics
+ changes:
+ - addColumn:
+ tableName: view_log
+ columns:
+ - column:
+ name: ip_address
+ type: varchar(45)
+ remarks: Client IP address, PII
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:06
+ author: bgrabow
+ comment: Add index on view_log.tenant_id for tenant-scoped analytics queries
+ changes:
+ - createIndex:
+ tableName: view_log
+ indexName: idx_view_log_tenant_id
+ columns:
+ - column:
+ name: tenant_id
+
+ # ============================================================
+ # query_execution columns
+ # ============================================================
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:07
+ author: bgrabow
+ comment: Add auth_method column to query_execution for tracking authentication method
+ changes:
+ - addColumn:
+ tableName: query_execution
+ columns:
+ - column:
+ name: auth_method
+ type: varchar(32)
+ remarks: Authentication method used (e.g. jwt, saml, api-key, public, guest)
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:08
+ author: bgrabow
+ comment: Add tenant_id column to query_execution for multi-tenant analytics
+ changes:
+ - addColumn:
+ tableName: query_execution
+ columns:
+ - column:
+ name: tenant_id
+ type: int
+ remarks: Tenant ID of the user who executed this query
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:09
+ author: bgrabow
+ comment: Add is_impersonated column to query_execution for connection impersonation tracking
+ changes:
+ - addColumn:
+ tableName: query_execution
+ columns:
+ - column:
+ name: is_impersonated
+ type: ${boolean.type}
+ remarks: Whether the query was executed with connection impersonation
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:10
+ author: bgrabow
+ comment: Add is_db_routed column to query_execution for database routing tracking
+ changes:
+ - addColumn:
+ tableName: query_execution
+ columns:
+ - column:
+ name: is_db_routed
+ type: ${boolean.type}
+ remarks: Whether the query was routed to a destination database
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:11
+ author: bgrabow
+ comment: Add parameters column to query_execution for tracking query filter values
+ changes:
+ - addColumn:
+ tableName: query_execution
+ columns:
+ - column:
+ name: parameters
+ type: ${text.type}
+ remarks: JSON-encoded query parameters (filter values)
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:12
+ author: bgrabow
+ comment: Add embedding_hostname column to query_execution for embedding analytics
+ changes:
+ - addColumn:
+ tableName: query_execution
+ columns:
+ - column:
+ name: embedding_hostname
+ type: varchar(512)
+ remarks: Hostname from Origin header, PII
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:13
+ author: bgrabow
+ comment: Add embedding_path column to query_execution for embedding analytics
+ changes:
+ - addColumn:
+ tableName: query_execution
+ columns:
+ - column:
+ name: embedding_path
+ type: varchar(2048)
+ remarks: Path from Referer header (query params stripped), PII
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:14
+ author: bgrabow
+ comment: Add user_agent column to query_execution for embedding analytics
+ changes:
+ - addColumn:
+ tableName: query_execution
+ columns:
+ - column:
+ name: user_agent
+ type: varchar(512)
+ remarks: User-Agent header, PII
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:15
+ author: bgrabow
+ comment: Add ip_address column to query_execution for embedding analytics
+ changes:
+ - addColumn:
+ tableName: query_execution
+ columns:
+ - column:
+ name: ip_address
+ type: varchar(45)
+ remarks: Client IP address, PII
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:16
+ author: bgrabow
+ comment: Add index on query_execution.tenant_id for tenant-scoped analytics queries
+ changes:
+ - createIndex:
+ tableName: query_execution
+ indexName: idx_query_execution_tenant_id
+ columns:
+ - column:
+ name: tenant_id
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:23
+ author: bcm
+ comment: Add sanitized_user_agent column to view_log for human-readable parsed UA
+ changes:
+ - addColumn:
+ tableName: view_log
+ columns:
+ - column:
+ name: sanitized_user_agent
+ type: varchar(512)
+ remarks: Human-friendly parsed User-Agent (e.g. Browser (Chrome/Windows)), PII
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:24
+ author: bcm
+ comment: Add sanitized_user_agent column to query_execution for human-readable parsed UA
+ changes:
+ - addColumn:
+ tableName: query_execution
+ columns:
+ - column:
+ name: sanitized_user_agent
+ type: varchar(512)
+ remarks: Human-friendly parsed User-Agent (e.g. Browser (Chrome/Windows)), PII
+ constraints:
+ nullable: true
+
+ # ============================================================
+ # embedding_route column (separate from embedding_client)
+ # ============================================================
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:21
+ author: bgrabow
+ comment: Add embedding_route column to view_log for route-surface tracking
+ changes:
+ - addColumn:
+ tableName: view_log
+ columns:
+ - column:
+ name: embedding_route
+ type: varchar(64)
+ remarks: API route surface (e.g. public, guest-embed, metabot, agent-api)
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:22
+ author: bgrabow
+ comment: Add embedding_route column to query_execution for route-surface tracking
+ changes:
+ - addColumn:
+ tableName: query_execution
+ columns:
+ - column:
+ name: embedding_route
+ type: varchar(64)
+ remarks: API route surface (e.g. public, guest-embed, metabot, agent-api)
+ constraints:
+ nullable: true
+
+ # ============================================================
+ # metabase_version column + rename embedding_version -> embedding_sdk_version
+ # ============================================================
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:25
+ author: bcm
+ comment: Add metabase_version column to view_log for tracking server version at insert time (EMB-1577)
+ changes:
+ - addColumn:
+ tableName: view_log
+ columns:
+ - column:
+ name: metabase_version
+ type: varchar(32)
+ remarks: Metabase server version tag at time of insert
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:26
+ author: bcm
+ comment: Add metabase_version column to query_execution for tracking server version at insert time (EMB-1577)
+ changes:
+ - addColumn:
+ tableName: query_execution
+ columns:
+ - column:
+ name: metabase_version
+ type: varchar(32)
+ remarks: Metabase server version tag at time of insert
+ constraints:
+ nullable: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:27
+ author: bcm
+ comment: Rename embedding_version to embedding_sdk_version on view_log (EMB-1578)
+ changes:
+ - renameColumn:
+ tableName: view_log
+ oldColumnName: embedding_version
+ newColumnName: embedding_sdk_version
+ columnDataType: varchar(254)
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:28
+ author: bcm
+ comment: Rename embedding_version to embedding_sdk_version on query_execution (EMB-1578)
+ changes:
+ - renameColumn:
+ tableName: query_execution
+ oldColumnName: embedding_version
+ newColumnName: embedding_sdk_version
+ columnDataType: varchar(254)
+
+ # ============================================================
+ # Analytics view updates - add embedding_client, is_preview
+ # ============================================================
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:17
+ author: bcm
+ comment: Updated view v_view_log v4 - add embedding_client, is_preview (EMB-1535)
+ changes:
+ - sqlFile:
+ dbms: postgresql
+ path: ../instance_analytics_views/view_log/v4/postgres-view_log.sql
+ relativeToChangelogFile: true
+ - sqlFile:
+ dbms: mysql,mariadb
+ path: ../instance_analytics_views/view_log/v4/mysql-view_log.sql
+ relativeToChangelogFile: true
+ - sqlFile:
+ dbms: h2
+ path: ../instance_analytics_views/view_log/v4/h2-view_log.sql
+ relativeToChangelogFile: true
+ rollback:
+ - sqlFile:
+ dbms: postgresql
+ path: ../instance_analytics_views/view_log/v2/postgres-view_log.sql
+ relativeToChangelogFile: true
+ - sqlFile:
+ dbms: mysql,mariadb
+ path: ../instance_analytics_views/view_log/v3/mysql-view_log.sql
+ relativeToChangelogFile: true
+ - sqlFile:
+ dbms: h2
+ path: ../instance_analytics_views/view_log/v2/h2-view_log.sql
+ relativeToChangelogFile: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:18
+ author: bcm
+ comment: Updated view v_query_log v5 - add embedding_client, is_preview (EMB-1535)
+ changes:
+ - sqlFile:
+ dbms: postgresql
+ path: ../instance_analytics_views/query_log/v5/postgres-query_log.sql
+ relativeToChangelogFile: true
+ - sqlFile:
+ dbms: mysql,mariadb
+ path: ../instance_analytics_views/query_log/v5/mysql-query_log.sql
+ relativeToChangelogFile: true
+ - sqlFile:
+ dbms: h2
+ path: ../instance_analytics_views/query_log/v5/h2-query_log.sql
+ relativeToChangelogFile: true
+ rollback:
+ - sqlFile:
+ dbms: postgresql
+ path: ../instance_analytics_views/query_log/v4/postgres-query_log.sql
+ relativeToChangelogFile: true
+ - sqlFile:
+ dbms: mysql,mariadb
+ path: ../instance_analytics_views/query_log/v4/mysql-query_log.sql
+ relativeToChangelogFile: true
+ - sqlFile:
+ dbms: h2
+ path: ../instance_analytics_views/query_log/v4/h2-query_log.sql
+ relativeToChangelogFile: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:19
+ author: bcm
+ comment: Updated view v_users v5 - add tenant_id (EMB-1506)
+ changes:
+ - sqlFile:
+ dbms: postgresql
+ path: ../instance_analytics_views/users/v5/postgres-users.sql
+ relativeToChangelogFile: true
+ - sqlFile:
+ dbms: mysql,mariadb
+ path: ../instance_analytics_views/users/v5/mysql-users.sql
+ relativeToChangelogFile: true
+ - sqlFile:
+ dbms: h2
+ path: ../instance_analytics_views/users/v5/h2-users.sql
+ relativeToChangelogFile: true
+ rollback:
+ - sql:
+ dbms: postgresql
+ sql: DROP VIEW IF EXISTS v_users;
+ - sqlFile:
+ dbms: postgresql
+ path: ../instance_analytics_views/users/v3/postgres-users.sql
+ relativeToChangelogFile: true
+ - sql:
+ dbms: mysql,mariadb
+ sql: DROP VIEW IF EXISTS v_users;
+ - sqlFile:
+ dbms: mysql,mariadb
+ path: ../instance_analytics_views/users/v4/mysql-users.sql
+ relativeToChangelogFile: true
+ - sql:
+ dbms: h2
+ sql: DROP VIEW IF EXISTS v_users;
+ - sqlFile:
+ dbms: h2
+ path: ../instance_analytics_views/users/v3/h2-users.sql
+ relativeToChangelogFile: true
+
+ - changeSet:
+ id: v61.2026-03-26T00:00:20
+ author: bcm
+ comment: New view v_tenants v1 - expose tenant data (EMB-1506)
+ changes:
+ - sqlFile:
+ dbms: postgresql
+ path: ../instance_analytics_views/tenants/v1/postgres-tenants.sql
+ relativeToChangelogFile: true
+ - sqlFile:
+ dbms: mysql,mariadb
+ path: ../instance_analytics_views/tenants/v1/mysql-tenants.sql
+ relativeToChangelogFile: true
+ - sqlFile:
+ dbms: h2
+ path: ../instance_analytics_views/tenants/v1/h2-tenants.sql
+ relativeToChangelogFile: true
+ rollback:
+ - sql:
+ sql: DROP VIEW IF EXISTS v_tenants;
diff --git a/resources/migrations/instance_analytics_views/query_log/v5/h2-query_log.sql b/resources/migrations/instance_analytics_views/query_log/v5/h2-query_log.sql
new file mode 100644
index 00000000000..4509191ea51
--- /dev/null
+++ b/resources/migrations/instance_analytics_views/query_log/v5/h2-query_log.sql
@@ -0,0 +1,45 @@
+DROP VIEW IF EXISTS v_query_log;
+
+
+CREATE OR REPLACE VIEW v_query_log AS
+SELECT id AS entity_id,
+ started_at,
+ cast(running_time AS DOUBLE) / 1000 AS running_time_seconds,
+ result_rows,
+ native AS is_native,
+ context AS query_source,
+ error,
+ coalesce(executor_id, 0) AS user_id,
+ card_id,
+ 'card_' || card_id AS card_qualified_id,
+ dashboard_id,
+ 'dashboard_' || dashboard_id AS dashboard_qualified_id,
+ pulse_id,
+ database_id,
+ 'database_' || database_id AS database_qualified_id,
+ cache_hit,
+ action_id,
+ 'action_' || action_id AS action_qualified_id,
+ transform_id,
+ 'transform_' || transform_id AS transform_qualified_id,
+ lens_id,
+ lens_params,
+ query,
+ embedding_client,
+ embedding_route,
+ CASE WHEN embedding_client LIKE '%-preview' THEN TRUE ELSE FALSE END AS is_preview,
+ embedding_sdk_version,
+ metabase_version,
+ auth_method,
+ is_sandboxed,
+ is_impersonated,
+ is_db_routed,
+ parameters,
+ tenant_id,
+ embedding_hostname,
+ embedding_path,
+ user_agent,
+ sanitized_user_agent,
+ ip_address
+FROM query_execution
+ LEFT JOIN query ON query_execution.hash = query.query_hash;
diff --git a/resources/migrations/instance_analytics_views/query_log/v5/mysql-query_log.sql b/resources/migrations/instance_analytics_views/query_log/v5/mysql-query_log.sql
new file mode 100644
index 00000000000..b21e8d3cf77
--- /dev/null
+++ b/resources/migrations/instance_analytics_views/query_log/v5/mysql-query_log.sql
@@ -0,0 +1,47 @@
+DROP VIEW IF EXISTS v_query_log;
+
+
+CREATE OR REPLACE
+SQL SECURITY INVOKER
+VIEW v_query_log AS
+SELECT id AS entity_id,
+ started_at,
+ cast(running_time AS DOUBLE) / 1000 AS running_time_seconds,
+ result_rows,
+ native AS is_native,
+ context AS query_source,
+ error,
+ coalesce(executor_id, 0) AS user_id,
+ card_id,
+ concat('card_', card_id) AS card_qualified_id,
+ dashboard_id,
+ concat('dashboard_', dashboard_id) AS dashboard_qualified_id,
+ pulse_id,
+ database_id,
+ concat('database_', database_id) AS database_qualified_id,
+ cache_hit,
+ action_id,
+ concat('action_', action_id) AS action_qualified_id,
+ transform_id,
+ concat('transform_', transform_id) AS transform_qualified_id,
+ lens_id,
+ lens_params,
+ query,
+ embedding_client,
+ embedding_route,
+ CASE WHEN embedding_client LIKE '%-preview' THEN TRUE ELSE FALSE END AS is_preview,
+ embedding_sdk_version,
+ metabase_version,
+ auth_method,
+ is_sandboxed,
+ is_impersonated,
+ is_db_routed,
+ parameters,
+ tenant_id,
+ embedding_hostname,
+ embedding_path,
+ user_agent,
+ sanitized_user_agent,
+ ip_address
+FROM query_execution
+ LEFT JOIN query ON query_execution.hash = query.query_hash;
diff --git a/resources/migrations/instance_analytics_views/query_log/v5/postgres-query_log.sql b/resources/migrations/instance_analytics_views/query_log/v5/postgres-query_log.sql
new file mode 100644
index 00000000000..fa4e414a44a
--- /dev/null
+++ b/resources/migrations/instance_analytics_views/query_log/v5/postgres-query_log.sql
@@ -0,0 +1,45 @@
+DROP VIEW IF EXISTS v_query_log;
+
+
+CREATE OR REPLACE VIEW v_query_log AS
+SELECT id AS entity_id,
+ started_at,
+ cast(running_time AS double precision) / 1000 AS running_time_seconds,
+ result_rows,
+ native AS is_native,
+ context AS query_source,
+ error,
+ coalesce(executor_id, 0) AS user_id,
+ card_id,
+ 'card_' || card_id AS card_qualified_id,
+ dashboard_id,
+ 'dashboard_' || dashboard_id AS dashboard_qualified_id,
+ pulse_id,
+ database_id,
+ 'database_' || database_id AS database_qualified_id,
+ cache_hit,
+ action_id,
+ 'action_' || action_id AS action_qualified_id,
+ transform_id,
+ 'transform_' || transform_id AS transform_qualified_id,
+ lens_id,
+ lens_params,
+ query,
+ embedding_client,
+ embedding_route,
+ CASE WHEN embedding_client LIKE '%-preview' THEN TRUE ELSE FALSE END AS is_preview,
+ embedding_sdk_version,
+ metabase_version,
+ auth_method,
+ is_sandboxed,
+ is_impersonated,
+ is_db_routed,
+ parameters,
+ tenant_id,
+ embedding_hostname,
+ embedding_path,
+ user_agent,
+ sanitized_user_agent,
+ ip_address
+FROM query_execution
+ LEFT JOIN query ON query_execution.hash = query.query_hash;
diff --git a/resources/migrations/instance_analytics_views/tenants/v1/h2-tenants.sql b/resources/migrations/instance_analytics_views/tenants/v1/h2-tenants.sql
new file mode 100644
index 00000000000..4609fd0200d
--- /dev/null
+++ b/resources/migrations/instance_analytics_views/tenants/v1/h2-tenants.sql
@@ -0,0 +1,12 @@
+CREATE OR REPLACE VIEW v_tenants AS
+SELECT id AS tenant_id,
+ 'tenant_' || id AS entity_qualified_id,
+ name,
+ slug,
+ is_active,
+ attributes,
+ created_at,
+ updated_at,
+ tenant_collection_id,
+ 'collection_' || tenant_collection_id AS tenant_collection_qualified_id
+FROM tenant;
diff --git a/resources/migrations/instance_analytics_views/tenants/v1/mysql-tenants.sql b/resources/migrations/instance_analytics_views/tenants/v1/mysql-tenants.sql
new file mode 100644
index 00000000000..56d2c281364
--- /dev/null
+++ b/resources/migrations/instance_analytics_views/tenants/v1/mysql-tenants.sql
@@ -0,0 +1,14 @@
+CREATE OR REPLACE
+SQL SECURITY INVOKER
+VIEW v_tenants AS
+SELECT id AS tenant_id,
+ concat('tenant_', id) AS entity_qualified_id,
+ name,
+ slug,
+ is_active,
+ attributes,
+ created_at,
+ updated_at,
+ tenant_collection_id,
+ concat('collection_', tenant_collection_id) AS tenant_collection_qualified_id
+FROM tenant;
diff --git a/resources/migrations/instance_analytics_views/tenants/v1/postgres-tenants.sql b/resources/migrations/instance_analytics_views/tenants/v1/postgres-tenants.sql
new file mode 100644
index 00000000000..4609fd0200d
--- /dev/null
+++ b/resources/migrations/instance_analytics_views/tenants/v1/postgres-tenants.sql
@@ -0,0 +1,12 @@
+CREATE OR REPLACE VIEW v_tenants AS
+SELECT id AS tenant_id,
+ 'tenant_' || id AS entity_qualified_id,
+ name,
+ slug,
+ is_active,
+ attributes,
+ created_at,
+ updated_at,
+ tenant_collection_id,
+ 'collection_' || tenant_collection_id AS tenant_collection_qualified_id
+FROM tenant;
diff --git a/resources/migrations/instance_analytics_views/users/v5/h2-users.sql b/resources/migrations/instance_analytics_views/users/v5/h2-users.sql
new file mode 100644
index 00000000000..b5dd2116e8d
--- /dev/null
+++ b/resources/migrations/instance_analytics_views/users/v5/h2-users.sql
@@ -0,0 +1,37 @@
+CREATE OR REPLACE VIEW v_users AS
+SELECT id AS user_id,
+ 'user_' || id AS entity_qualified_id,
+ type,
+ CASE WHEN type = 'api-key' THEN null ELSE email END as email,
+ first_name,
+ last_name,
+ COALESCE(first_name || ' ' || last_name,
+ first_name,
+ last_name) AS full_name,
+ date_joined,
+ last_login,
+ updated_at,
+ is_superuser AS is_admin,
+ is_active,
+ sso_source,
+ locale,
+ tenant_id,
+ 'tenant_' || tenant_id AS tenant_qualified_id
+FROM core_user
+UNION
+SELECT 0 AS user_id,
+ 'user_0' AS entity_qualified_id,
+ 'anonymous' as type,
+ NULL AS email,
+ 'External' AS first_name,
+ 'User' AS last_name,
+ 'External User' AS full_name,
+ NULL AS date_joined,
+ NULL AS last_login,
+ NULL AS updated_at,
+ FALSE AS is_admin,
+ NULL AS is_active,
+ NULL AS sso_source,
+ NULL AS locale,
+ NULL AS tenant_id,
+ NULL AS tenant_qualified_id ;
diff --git a/resources/migrations/instance_analytics_views/users/v5/mysql-users.sql b/resources/migrations/instance_analytics_views/users/v5/mysql-users.sql
new file mode 100644
index 00000000000..6a0b0d801ca
--- /dev/null
+++ b/resources/migrations/instance_analytics_views/users/v5/mysql-users.sql
@@ -0,0 +1,39 @@
+CREATE OR REPLACE
+SQL SECURITY INVOKER
+VIEW v_users AS
+SELECT id AS user_id,
+ concat('user_', id) AS entity_qualified_id,
+ type,
+ CASE WHEN type = 'api-key' THEN null ELSE email END as email,
+ first_name,
+ last_name,
+ COALESCE(concat(first_name, ' ', last_name),
+ first_name,
+ last_name) as full_name,
+ date_joined,
+ last_login,
+ updated_at,
+ is_superuser AS is_admin,
+ is_active,
+ sso_source,
+ locale,
+ tenant_id,
+ concat('tenant_', tenant_id) AS tenant_qualified_id
+FROM core_user
+UNION
+SELECT 0 AS user_id,
+ 'user_0' AS entity_qualified_id,
+ 'anonymous' as type,
+ NULL AS email,
+ 'External' AS first_name,
+ 'User' AS last_name,
+ 'External User' AS full_name,
+ NULL AS date_joined,
+ NULL AS last_login,
+ NULL AS updated_at,
+ FALSE AS is_admin,
+ NULL AS is_active,
+ NULL AS sso_source,
+ NULL AS locale,
+ NULL AS tenant_id,
+ NULL AS tenant_qualified_id ;
diff --git a/resources/migrations/instance_analytics_views/users/v5/postgres-users.sql b/resources/migrations/instance_analytics_views/users/v5/postgres-users.sql
new file mode 100644
index 00000000000..b5dd2116e8d
--- /dev/null
+++ b/resources/migrations/instance_analytics_views/users/v5/postgres-users.sql
@@ -0,0 +1,37 @@
+CREATE OR REPLACE VIEW v_users AS
+SELECT id AS user_id,
+ 'user_' || id AS entity_qualified_id,
+ type,
+ CASE WHEN type = 'api-key' THEN null ELSE email END as email,
+ first_name,
+ last_name,
+ COALESCE(first_name || ' ' || last_name,
+ first_name,
+ last_name) AS full_name,
+ date_joined,
+ last_login,
+ updated_at,
+ is_superuser AS is_admin,
+ is_active,
+ sso_source,
+ locale,
+ tenant_id,
+ 'tenant_' || tenant_id AS tenant_qualified_id
+FROM core_user
+UNION
+SELECT 0 AS user_id,
+ 'user_0' AS entity_qualified_id,
+ 'anonymous' as type,
+ NULL AS email,
+ 'External' AS first_name,
+ 'User' AS last_name,
+ 'External User' AS full_name,
+ NULL AS date_joined,
+ NULL AS last_login,
+ NULL AS updated_at,
+ FALSE AS is_admin,
+ NULL AS is_active,
+ NULL AS sso_source,
+ NULL AS locale,
+ NULL AS tenant_id,
+ NULL AS tenant_qualified_id ;
diff --git a/resources/migrations/instance_analytics_views/view_log/v4/h2-view_log.sql b/resources/migrations/instance_analytics_views/view_log/v4/h2-view_log.sql
new file mode 100644
index 00000000000..b3d7d17b914
--- /dev/null
+++ b/resources/migrations/instance_analytics_views/view_log/v4/h2-view_log.sql
@@ -0,0 +1,23 @@
+DROP VIEW IF EXISTS v_view_log;
+
+
+CREATE OR REPLACE VIEW v_view_log AS
+ (SELECT id, timestamp, coalesce(user_id, 0) as user_id,
+ model AS entity_type,
+ model_id AS entity_id,
+ model || '_' || model_id AS entity_qualified_id,
+ embedding_client,
+ embedding_route,
+ CASE WHEN embedding_client LIKE '%-preview' THEN TRUE ELSE FALSE END AS is_preview,
+ has_access,
+ context,
+ embedding_sdk_version,
+ metabase_version,
+ auth_method,
+ tenant_id,
+ embedding_hostname,
+ embedding_path,
+ user_agent,
+ sanitized_user_agent,
+ ip_address
+ FROM view_log)
diff --git a/resources/migrations/instance_analytics_views/view_log/v4/mysql-view_log.sql b/resources/migrations/instance_analytics_views/view_log/v4/mysql-view_log.sql
new file mode 100644
index 00000000000..3c576c61a73
--- /dev/null
+++ b/resources/migrations/instance_analytics_views/view_log/v4/mysql-view_log.sql
@@ -0,0 +1,25 @@
+DROP VIEW IF EXISTS v_view_log;
+
+
+CREATE OR REPLACE
+SQL SECURITY INVOKER
+VIEW v_view_log AS
+ (SELECT id, timestamp, coalesce(user_id, 0) as user_id,
+ model AS entity_type,
+ model_id AS entity_id,
+ concat(model, '_', model_id) AS entity_qualified_id,
+ embedding_client,
+ embedding_route,
+ CASE WHEN embedding_client LIKE '%-preview' THEN TRUE ELSE FALSE END AS is_preview,
+ has_access,
+ context,
+ embedding_sdk_version,
+ metabase_version,
+ auth_method,
+ tenant_id,
+ embedding_hostname,
+ embedding_path,
+ user_agent,
+ sanitized_user_agent,
+ ip_address
+ FROM view_log)
diff --git a/resources/migrations/instance_analytics_views/view_log/v4/postgres-view_log.sql b/resources/migrations/instance_analytics_views/view_log/v4/postgres-view_log.sql
new file mode 100644
index 00000000000..f1f70e1a7f4
--- /dev/null
+++ b/resources/migrations/instance_analytics_views/view_log/v4/postgres-view_log.sql
@@ -0,0 +1,23 @@
+DROP VIEW IF EXISTS v_view_log;
+
+
+CREATE OR REPLACE VIEW v_view_log AS
+ (SELECT id, timestamp, coalesce(user_id, 0) AS user_id,
+ model AS entity_type,
+ model_id AS entity_id,
+ model || '_' || model_id AS entity_qualified_id,
+ embedding_client,
+ embedding_route,
+ CASE WHEN embedding_client LIKE '%-preview' THEN TRUE ELSE FALSE END AS is_preview,
+ has_access,
+ context,
+ embedding_sdk_version,
+ metabase_version,
+ auth_method,
+ tenant_id,
+ embedding_hostname,
+ embedding_path,
+ user_agent,
+ sanitized_user_agent,
+ ip_address
+ FROM view_log)
diff --git a/src/metabase/analytics/core.clj b/src/metabase/analytics/core.clj
index 08500c8aae9..5407f22773d 100644
--- a/src/metabase/analytics/core.clj
+++ b/src/metabase/analytics/core.clj
@@ -48,8 +48,13 @@
embedding-context?
embedding-mw
+ extract-hostname
+ extract-path
include-sdk-info
+ pii-request-info
+ with-auth-method! get-auth-method
with-client! get-client
+ get-route
with-version! get-version]
[metabase.analytics.settings
diff --git a/src/metabase/analytics/prometheus.clj b/src/metabase/analytics/prometheus.clj
index 5e4e3b1ca5c..33a8040336a 100644
--- a/src/metabase/analytics/prometheus.clj
+++ b/src/metabase/analytics/prometheus.clj
@@ -464,6 +464,18 @@
(prometheus/counter :metabase-embedding-iframe/response
{:description "Number of iframe embedding responses by status code."
:labels [:status]})
+ (prometheus/counter :metabase-embedding-iframe-full-app/response
+ {:description "Number of full-app iframe embedding responses by status code."
+ :labels [:status]})
+ (prometheus/counter :metabase-embedding-iframe-static/response
+ {:description "Number of static iframe embedding responses by status code."
+ :labels [:status]})
+ (prometheus/counter :metabase-embedding-public/response
+ {:description "Number of public embedding responses by status code."
+ :labels [:status]})
+ (prometheus/counter :metabase-embedding-simple/response
+ {:description "Number of simple (modular) embedding responses by status code."
+ :labels [:status]})
(prometheus/counter :metabase-gsheets/connection-deleted
{:description "How many times the instance has deleted their Google Sheets connection."})
(prometheus/counter :metabase-gsheets/connection-manually-synced
diff --git a/src/metabase/analytics/sdk.clj b/src/metabase/analytics/sdk.clj
index fb523d2680c..bf5a823e568 100644
--- a/src/metabase/analytics/sdk.clj
+++ b/src/metabase/analytics/sdk.clj
@@ -4,14 +4,23 @@
Here is how we collect analytics information about the embedding client:
The X-Metabase-Client and X-Metabase-Client-Version headers are sent, and if present bound to *metabase-client* and *metabase-client-version* respectively.
- When we execute a query, or record a view log, we include the *client* and *version* as embedding_client and embedding_version in the view_log or query_execution record.
+ When we execute a query, or record a view log, we include the *client* and *version* as embedding_client and embedding_sdk_version in the view_log or query_execution record.
then we can use the information on the tables to track information about the embedding client,
and TODO: send it out in `summarize-execution`."
(:require
+ [clojure.string :as str]
[metabase.analytics-interface.core :as analytics]
+ [metabase.analytics.settings :as analytics.settings]
+ [metabase.config.core :as config]
+ [metabase.request.current :as request.current]
+ [metabase.request.user-agent :as request.user-agent]
[metabase.util.log :as log]
- [metabase.util.malli :as mu]))
+ [metabase.util.malli :as mu])
+ (:import
+ (java.net URI)))
+
+(set! *warn-on-reflection* true)
(def ^:dynamic *version* "Used to track information about the metabase embedding client version." nil)
@@ -31,49 +40,146 @@
(defn get-client "Returns [[*client*]] dynamic var" [] *client*)
+(def ^:dynamic *route* "Used to track the API route for the current request (e.g. \"public\", \"guest-embed\")." nil)
+
+(defn get-route "Returns [[*route*]]." [] *route*)
+
+(def ^:dynamic *auth-method* "Used to track the authentication method for the current request (e.g. \"password\", \"jwt\", \"api-key\")." nil)
+
+(defmacro with-auth-method! "Binds [[*auth-method*]] for the duration of `body`."
+ [value & body]
+ `(binding [*auth-method* ~value]
+ ~@body))
+
+(defn get-auth-method "Returns [[*auth-method*]]." [] *auth-method*)
+
+(defn extract-hostname
+ "Extracts the hostname from a URL string. Returns nil if the URL is nil or unparseable."
+ [url]
+ (when url
+ (try
+ (let [host (.getHost (URI. url))]
+ (when-not (str/blank? host)
+ (subs host 0 (min (count host) 512))))
+ (catch Exception _
+ nil))))
+
+(defn extract-path
+ "Extracts the path from a URL string, stripping query params and fragment.
+ Returns nil if the URL is nil or unparseable."
+ [url]
+ (when url
+ (try
+ (let [path (.getPath (URI. url))]
+ (when-not (str/blank? path)
+ (subs path 0 (min (count path) 2048))))
+ (catch Exception _
+ nil))))
+
+(defn pii-request-info
+ "Pure function that computes GDPR-gated request metadata from individual request values.
+ Returns a map with `:embedding_hostname`, `:embedding_path`, `:user_agent`, and `:ip_address`."
+ [{:keys [origin referer user-agent ip-address]}]
+ {:embedding_hostname (extract-hostname origin)
+ :embedding_path (extract-path referer)
+ :user_agent (some-> user-agent (subs 0 (min (count user-agent) 512)))
+ :sanitized_user_agent (request.user-agent/describe-user-agent user-agent)
+ :ip_address ip-address})
+
+(defn- hostname-fields
+ "Returns embedding_hostname from the current request. Always collected (not PII)."
+ []
+ (when-let [request (request.current/current-request)]
+ {:embedding_hostname (extract-hostname (get-in request [:headers "x-metabase-embed-referrer"]))}))
+
+(defn- pii-fields
+ "Returns PII fields from the current request when the `analytics-pii-retention-enabled` setting is true."
+ []
+ (when (analytics.settings/analytics-pii-retention-enabled)
+ (when-let [request (request.current/current-request)]
+ {:embedding_path (extract-path (get-in request [:headers "x-metabase-embed-referrer"]))
+ :user_agent (some-> (get-in request [:headers "user-agent"])
+ (subs 0 (min (count (get-in request [:headers "user-agent"])) 512)))
+ :sanitized_user_agent (request.user-agent/describe-user-agent (get-in request [:headers "user-agent"]))
+ :ip_address (request.current/ip-address request)})))
+
(mu/defn include-sdk-info :- :map
"Adds the currently bound, or existing `*client*` and `*version*` to the given map, which is usually a row going
into the `view_log` or `query_execution` table. Falls back to the original value."
[m :- :map]
(-> m
(update :embedding_client (fn [client] (or *client* client)))
- (update :embedding_version (fn [version] (or *version* version)))))
+ (update :embedding_route (fn [route] (or *route* route)))
+ (update :embedding_sdk_version (fn [version] (or *version* version)))
+ (update :auth_method (fn [method] (or *auth-method* method)))
+ (assoc :metabase_version (:tag config/mb-version-info))
+ (merge (hostname-fields) (pii-fields))))
-(def ^:private embedding-sdk-client "embedding-sdk-react")
-(def ^:private embedding-iframe-client "embedding-iframe")
+(def ^:private embedding-clients
+ #{"embedding-sdk-react"
+ "embedding-iframe"
+ "embedding-iframe-full-app"
+ "embedding-iframe-static"
+ "embedding-public"
+ "embedding-simple"})
(defn- track-sdk-response
"Tabulates the number of responses by status code made by clients of the SDK."
[sdk-client {:keys [status]}]
(case sdk-client
- "embedding-sdk-react" (analytics/inc! :metabase-sdk/response {:status (str status)})
- "embedding-iframe" (analytics/inc! :metabase-embedding-iframe/response {:status (str status)})
+ "embedding-sdk-react" (analytics/inc! :metabase-sdk/response {:status (str status)})
+ "embedding-iframe" (analytics/inc! :metabase-embedding-iframe/response {:status (str status)})
+ "embedding-iframe-full-app" (analytics/inc! :metabase-embedding-iframe-full-app/response {:status (str status)})
+ "embedding-iframe-static" (analytics/inc! :metabase-embedding-iframe-static/response {:status (str status)})
+ "embedding-public" (analytics/inc! :metabase-embedding-public/response {:status (str status)})
+ "embedding-simple" (analytics/inc! :metabase-embedding-simple/response {:status (str status)})
(log/infof "Unknown client. client: %s" sdk-client)))
(defn embedding-context?
"Should we track this request as being made by an embedding client?"
[client]
- (or (= client embedding-sdk-client)
- (= client embedding-iframe-client)))
+ (contains? embedding-clients client))
+
+(def ^:private embedding-route-mapping
+ [["/api/public/" "public"]
+ ["/api/embed/" "guest-embed"]
+ ;; preview_embed is guest-embed; the "-preview" suffix is appended separately
+ ;; when X-Metabase-Embedded-Preview: true (see embedding-mw below).
+ ["/api/preview_embed/" "guest-embed"]
+ ["/api/metabot/" "metabot"]
+ ["/api/agent/" "agent-api"]])
+
+(defn embedding-route
+ "Returns the route surface string for a URI, or nil if no route matches."
+ [uri]
+ (first (keep (fn [[prefix surface]]
+ (when (str/starts-with? (or uri "") prefix) surface))
+ embedding-route-mapping)))
(defn embedding-mw
"Reads Metabase Client and Version headers and binds them to *metabase-client{-version}*."
[handler]
(fn embedding-mw-fn
[request respond raise]
- (let [sdk-client (get-in request [:headers "x-metabase-client"])
+ (let [metabase-client-header (get-in request [:headers "x-metabase-client"])
version (get-in request [:headers "x-metabase-client-version"])
- preview? (= (get-in request [:headers "x-metabase-embedded-preview"]) "true")]
- (binding [*client* (if preview? (str sdk-client "-preview") sdk-client)
+ preview? (= (get-in request [:headers "x-metabase-embedded-preview"]) "true")
+ route (embedding-route (:uri request))
+ ;; *client* is the SDK/client identity from the header, with -preview suffix if applicable
+ client (cond-> metabase-client-header
+ preview? (some-> (str "-preview")))]
+ (binding [*client* client
+ *route* route
*version* version]
(handler request
(fn responder [response]
- (when (embedding-context? sdk-client)
- (track-sdk-response sdk-client response))
+ ;; Only track prometheus when NO route match AND header is an embedding context
+ (when (and (nil? route) (embedding-context? metabase-client-header))
+ (track-sdk-response metabase-client-header response))
(respond response))
(fn raiser [response]
- (when (embedding-context? sdk-client)
- (track-sdk-response sdk-client
+ (when (and (nil? route) (embedding-context? metabase-client-header))
+ (track-sdk-response metabase-client-header
(if (:status response)
response
{:status 500})))
diff --git a/src/metabase/analytics/settings.clj b/src/metabase/analytics/settings.clj
index 4045e4e1280..57cec0cef09 100644
--- a/src/metabase/analytics/settings.clj
+++ b/src/metabase/analytics/settings.clj
@@ -32,7 +32,7 @@
:doc false)
(defsetting anon-tracking-enabled
- (deferred-tru "Enable the collection of anonymous usage data in order to help us improve.")
+ (deferred-tru "Enable the collection of anonymous usage data in order to help Metabase improve..")
:type :boolean
:default true
:visibility :public
@@ -105,3 +105,11 @@
:type :boolean
:export? true
:setter #'-non-table-chart-generated!)
+
+(defsetting analytics-pii-retention-enabled
+ (deferred-tru (str "Enable logging of embed path, query parameters, user agent, and IP address of who views your "
+ "internal data and embeds. This information will be shown in your usage analytics."))
+ :type :boolean
+ :default false
+ :visibility :admin
+ :export? true)
diff --git a/src/metabase/analytics/stats.clj b/src/metabase/analytics/stats.clj
index ad3847a4365..c7bc6f1f485 100644
--- a/src/metabase/analytics/stats.clj
+++ b/src/metabase/analytics/stats.clj
@@ -650,7 +650,7 @@
[executions]
(mapv (fn [qe-group]
{:group (str qe-group) :value (get executions qe-group)})
- [:interactive_embed :internal :public_link :sdk_embed :static_embed]))
+ [:interactive_embed :internal :public_link :sdk_embed :simple_embed :static_embed]))
(mu/defn- snowplow-grouped-metrics
:- [:sequential
diff --git a/src/metabase/internal_stats/query_executions.clj b/src/metabase/internal_stats/query_executions.clj
index d92a14c13ba..ad6cd156097 100644
--- a/src/metabase/internal_stats/query_executions.clj
+++ b/src/metabase/internal_stats/query_executions.clj
@@ -4,34 +4,47 @@
[metabase.internal-stats.util :as u]
[toucan2.core :as t2]))
+(def ^:private sdk-embed-condition
+ [:= :embedding_client "embedding-sdk-react"])
+
+(def ^:private simple-embed-condition
+ [:= :embedding_client "embedding-simple"])
+
+(def ^:private interactive-embed-condition
+ [:or
+ [:= :embedding_client "embedding-iframe-full-app"]
+ ;; legacy for backwards compatibility
+ [:and [:= :embedding_client "embedding-iframe"]
+ [:!= :executor_id nil]]])
+
+(def ^:private static-embed-condition
+ [:or
+ [:= :embedding_client "embedding-iframe-static"]
+ ;; legacy for backwards compatibility
+ [:and [:= :embedding_client "embedding-iframe"]
+ [:= :executor_id nil]]])
+
+(def ^:private public-link-condition
+ [:or
+ [:= :embedding_client "embedding-public"]
+ [:like :context "public-%"]])
+
(def ^:private query-execution-statistics
[:model/QueryExecution
- [(u/count-case [:= :embedding_client "embedding-sdk-react"]) :sdk_embed]
- [(u/count-case [:= :embedding_client "embedding-simple"]) :simple_embed]
- [(u/count-case [:and [:= :embedding_client "embedding-iframe"]
- [:!= :executor_id nil]])
- :interactive_embed]
- [(u/count-case [:and [:= :embedding_client "embedding-iframe"]
- [:= :executor_id nil]])
- :static_embed]
- [(u/count-case [:and
- [:or [:= :embedding_client nil]
- [:!= :embedding_client "embedding-sdk-react"]]
- [:or [:= :embedding_client nil]
- [:!= :embedding_client "embedding-simple"]]
- [:or [:= :embedding_client nil]
- [:!= :embedding_client "embedding-iframe"]]
- [:like :context "public-%"]])
- :public_link]
- [(u/count-case [:and
- [:or [:= :embedding_client nil]
- [:!= :embedding_client "embedding-sdk-react"]]
- [:or [:= :embedding_client nil]
- [:!= :embedding_client "embedding-simple"]]
- [:or [:= :embedding_client nil]
- [:!= :embedding_client "embedding-iframe"]]
- [:not [:like :context "public-%"]]])
- :internal]])
+ [(u/count-case sdk-embed-condition) :sdk_embed]
+ [(u/count-case interactive-embed-condition) :interactive_embed]
+ [(u/count-case static-embed-condition) :static_embed]
+ [(u/count-case public-link-condition) :public_link]
+ [(u/count-case simple-embed-condition) :simple_embed]
+ ;; fallthru: if a row does NOT match the above, it will match this condition and be counted internal.
+ ;; COALESCE needed because when embedding_client IS NULL, the OR of equality checks returns NULL
+ ;; (not FALSE), and NOT(NULL) = NULL which would skip the row instead of counting it.
+ [(u/count-case [:not [:coalesce [:or sdk-embed-condition
+ interactive-embed-condition
+ simple-embed-condition
+ static-embed-condition
+ public-link-condition]
+ [:inline false]]]) :internal]])
(defn query-executions-all-time-and-last-24h
"Calculate query executions for the entire available history and over the last 24 hours from now."
diff --git a/src/metabase/queries/models/query_execution.clj b/src/metabase/queries/models/query_execution.clj
index b9a65e76dfb..35cf05dc180 100644
--- a/src/metabase/queries/models/query_execution.clj
+++ b/src/metabase/queries/models/query_execution.clj
@@ -29,6 +29,9 @@
(throw (ex-info (tru "Invalid query execution context: {0}" (pr-str error))
{:error error}))))
+;; Captures SDK info from dynamic vars. For the normal async QP path, SDK info is already in the map
+;; (captured on-thread in `process-userland-query/save-execution-metadata!` before async handoff).
+;; This hook serves as a safety net for any direct sync inserts.
(t2/define-before-insert :model/QueryExecution
[{context :context, :as query-execution}]
(u/prog1 (analytics/include-sdk-info query-execution)
diff --git a/src/metabase/query_processor/middleware/enterprise.clj b/src/metabase/query_processor/middleware/enterprise.clj
index 3131823c049..f2cd7617b5c 100644
--- a/src/metabase/query_processor/middleware/enterprise.clj
+++ b/src/metabase/query_processor/middleware/enterprise.clj
@@ -42,6 +42,26 @@
[query]
query)
+(defenterprise currently-impersonated?
+ "True when a connection-impersonation role is bound for the current query. Read from the enterprise
+ impersonation dynamic var. OSS: always false."
+ metabase-enterprise.impersonation.middleware
+ []
+ false)
+
+(defenterprise currently-db-routed?
+ "True when DB routing has swapped in a destination DB for the current query. Read from the enterprise
+ database-routing dynamic var. OSS: always false."
+ metabase-enterprise.database-routing.middleware
+ []
+ false)
+
+(defenterprise currently-destination-database-id
+ "Destination DB id when DB routing has swapped one in for the current query, else nil. OSS: always nil."
+ metabase-enterprise.database-routing.middleware
+ []
+ nil)
+
(defn apply-impersonation-postprocessing-middleware
"Helper middleware wrapper for [[apply-impersonation-postprocessing]] to make sure we do [[defenterprise]] dispatch
correctly on each QP run rather than just once when we combine all of the QP middleware"
diff --git a/src/metabase/query_processor/middleware/process_userland_query.clj b/src/metabase/query_processor/middleware/process_userland_query.clj
index 7615810265f..3c5e96b55c7 100644
--- a/src/metabase/query_processor/middleware/process_userland_query.clj
+++ b/src/metabase/query_processor/middleware/process_userland_query.clj
@@ -10,13 +10,17 @@
[java-time.api :as t]
[metabase.analytics-interface.core :as analytics]
[metabase.analytics.core :as analytics.core]
+ [metabase.analytics.settings :as analytics.settings]
+ [metabase.api.common :as api]
[metabase.events.core :as events]
[metabase.lib.computed :as lib.computed]
[metabase.queries.models.query :as query]
+ [metabase.query-processor.middleware.enterprise :as qp.middleware.enterprise]
[metabase.query-processor.schema :as qp.schema]
[metabase.query-processor.util :as qp.util]
[metabase.tracing.core :as tracing]
[metabase.util :as u]
+ [metabase.util.json :as json]
[metabase.util.log :as log]
[metabase.util.malli :as mu]
[metabase.util.performance :refer [every? empty? get-in]]
@@ -54,7 +58,11 @@
(defn- save-execution-metadata!
"Save a `QueryExecution` row containing `execution-info`. Done asynchronously when a query is finished."
[execution-info]
- (let [execution-info' (analytics.core/include-sdk-info execution-info)]
+ (let [;; Capture SDK info now, on the request thread, because `with-execute-async` below intentionally
+ ;; does not convey dynamic var bindings to the background thread (to avoid holding DB connections).
+ ;; `include-sdk-info` also runs in the `before-insert` hook as a safety net for any code path
+ ;; that inserts QueryExecution directly (where dynamic vars would still be bound).
+ execution-info' (analytics.core/include-sdk-info execution-info)]
(qp.util/with-execute-async
;; 1. Asynchronously save QueryExecution, update query average execution time etc. using the Agent/pooledExecutor
;; pool, which is a fixed pool of size `nthreads + 2`. This way we don't spin up a ton of threads doing unimportant
@@ -72,10 +80,10 @@
(defn- save-successful-execution-metadata! [cache-details is-sandboxed? query-execution result-rows]
(let [qe-map (assoc query-execution
- :cache_hit (boolean (:cached cache-details))
- :cache_hash (:hash cache-details)
- :result_rows result-rows
- :is_sandboxed (boolean is-sandboxed?))]
+ :cache_hit (boolean (:cached cache-details))
+ :cache_hash (:hash cache-details)
+ :result_rows result-rows
+ :is_sandboxed (boolean is-sandboxed?))]
(save-execution-metadata! qe-map)))
(defn- save-failed-query-execution! [query-execution message]
@@ -92,8 +100,8 @@
(merge
(-> query-execution
add-running-time
- (dissoc :error :hash :executor_id :action_id :is_sandboxed :card_id :dashboard_id :transform_id :lens_id :lens_params :pulse_id :result_rows :native
- :parameterized))
+ (dissoc :error :hash :executor_id :action_id :is_sandboxed :is_impersonated :is_db_routed :card_id :dashboard_id :transform_id :lens_id :lens_params :pulse_id :result_rows :native
+ :parameterized :parameters))
(dissoc result :cache/details)
{:cached (when (:cached cache) (:updated_at cache))
:status :completed
@@ -114,7 +122,8 @@
(events/publish-event! :event/card-query {:user-id (:executor_id execution-info)
:card-id (:card_id execution-info)
:context (:context execution-info)}))
- (save-successful-execution-metadata! (:cache/details acc) (get-in acc [:data :is_sandboxed]) execution-info @row-count)
+ (save-successful-execution-metadata!
+ (:cache/details acc) (get-in acc [:data :is_sandboxed]) execution-info @row-count)
(rf (if (map? acc)
(success-response execution-info acc)
acc)))
@@ -124,14 +133,17 @@
(rf result row)))))
(mu/defn- query-execution-info
- "Return the info for the QueryExecution entry for this `query`."
+ "Return the info for the QueryExecution entry for this `query`. Fields that depend on dynamic vars set by
+ postprocessing middleware (`is_impersonated`, `is_db_routed`, the routed `database_id`) are NOT computed here —
+ they're added later by [[enrich-with-execution-context]] from inside the postprocessing rff, where the bindings
+ are still in effect. See PR #71386 — reading those values from the query map at the top of the around middleware
+ was a timing bug because pre-processing hadn't yet run."
{:arglists '([query])}
[{{:keys [executed-by query-hash context action-id card-id dashboard-id transform-id lens-id lens-params pulse-id]
:pivot/keys [original-query]} :info
database-id :database
query-type :type
parameters :parameters
- destination-database-id :destination-database/id
:as query} :- ::qp.schema/any-query]
{:pre [(bytes? query-hash)]}
(let [json-query (if original-query
@@ -140,7 +152,7 @@
(assoc :was-pivot true))
(cond-> (dissoc query :info)
(empty? (:parameters query)) (dissoc :parameters)))]
- {:database_id (or destination-database-id database-id)
+ {:database_id database-id
:executor_id executed-by
:action_id action-id
:card_id card-id
@@ -155,11 +167,25 @@
(every? #(some? (:value %)) parameters))
:native (= (keyword query-type) :native)
:json_query json-query
+ :tenant_id (:tenant_id @api/*current-user*)
+ :parameters (when (and (seq parameters) (analytics.settings/analytics-pii-retention-enabled))
+ (json/encode parameters))
:started_at (t/zoned-date-time)
:running_time 0
:result_rows 0
:start_time_millis (System/currentTimeMillis)}))
+(defn- enrich-with-execution-context
+ "Adds fields derived from postprocessing-middleware dynamic vars (`*impersonation-role*`,
+ `*destination-database-id*`) to `execution-info`. Must be called from inside the postprocessing rff, before the
+ async dispatch in [[save-execution-metadata!]] drops dynamic bindings."
+ [execution-info]
+ (let [destination-db-id (qp.middleware.enterprise/currently-destination-database-id)]
+ (cond-> (assoc execution-info
+ :is_impersonated (qp.middleware.enterprise/currently-impersonated?)
+ :is_db_routed (qp.middleware.enterprise/currently-db-routed?))
+ destination-db-id (assoc :database_id destination-db-id))))
+
(mu/defn process-userland-query-middleware :- ::qp.schema/qp
"Around middleware.
@@ -184,17 +210,23 @@
execution-info (query-execution-info query)]
(letfn [(rff* [metadata]
(let [;; we only need the preprocessed query to find field usages, so make sure we don't return it
- result (rff (dissoc metadata :preprocessed_query))]
- ;; temporarily disabled because it impacts query performance
+ result (rff (dissoc metadata :preprocessed_query))
+ ;; Enrich here, while the impersonation / db-routing dynamic var bindings established by
+ ;; postprocessing middleware are still in effect. Doing this at the top of the around
+ ;; middleware was wrong — preprocessing hadn't run yet and the bindings weren't set.
+ execution-info (enrich-with-execution-context execution-info)]
(add-and-save-execution-metadata-xform! execution-info result)))]
(try
(qp query rff*)
(catch Throwable e
- (save-failed-query-execution!
- execution-info
- (or
- (some-> e ex-cause ex-message)
- (ex-message e)))
- (throw (ex-info (ex-message e)
- {:query-execution execution-info}
- e)))))))))
+ ;; Same enrichment for the error path: we're still inside `(qp query rff*)` so the postprocessing
+ ;; bindings are in effect.
+ (let [execution-info (enrich-with-execution-context execution-info)]
+ (save-failed-query-execution!
+ execution-info
+ (or
+ (some-> e ex-cause ex-message)
+ (ex-message e)))
+ (throw (ex-info (ex-message e)
+ {:query-execution execution-info}
+ e))))))))))
diff --git a/src/metabase/request/core.clj b/src/metabase/request/core.clj
index 8b039e64dd4..1faadd9ce02 100644
--- a/src/metabase/request/core.clj
+++ b/src/metabase/request/core.clj
@@ -6,6 +6,7 @@
[metabase.request.current]
[metabase.request.session]
[metabase.request.settings]
+ [metabase.request.user-agent]
[metabase.request.util]
[potemkin :as p]))
@@ -14,6 +15,7 @@
metabase.request.current/keep-me
metabase.request.session/keep-me
metabase.request.settings/keep-me
+ metabase.request.user-agent/keep-me
metabase.request.util/keep-me)
;; TODO -- move stuff in [[metabase.server.middleware.session]]
@@ -32,6 +34,7 @@
set-session-timeout-cookie]
[metabase.request.current
current-request
+ ip-address
limit
offset
paged?
@@ -45,18 +48,18 @@
[metabase.request.settings
session-timeout
session-timeout!]
+ [metabase.request.user-agent
+ describe-user-agent]
[metabase.request.util
DeviceInfo
api-call?
auth-call?
cacheable?
- describe-user-agent
device-info
embed?
embedded?
geocode-ip-addresses
https?
- ip-address
public?])
(defn enabled-session-timeout-seconds
diff --git a/src/metabase/request/current.clj b/src/metabase/request/current.clj
index 393ff2897bf..38e420426f1 100644
--- a/src/metabase/request/current.clj
+++ b/src/metabase/request/current.clj
@@ -2,7 +2,10 @@
"Dynamic variables for things associated with the current HTTP request, such as current user and their permissions;
current limit and offset, etc.
- TODO -- move stuff like `*current-user-id*` into this namespace.")
+ TODO -- move stuff like `*current-user-id*` into this namespace."
+ (:require
+ [clojure.string :as str]
+ [metabase.request.settings :as request.settings]))
(def ^:private ^:dynamic *request*
nil)
@@ -62,3 +65,21 @@
{:style/indent :defn}
[limit offset & body]
`(do-with-limit-and-offset ~limit ~offset (^:once fn* [] ~@body)))
+
+(defn ip-address
+ "The IP address a Ring `request` came from. Looks at the `request.settings/source-address-header` header (by default
+ `X-Forwarded-For`, or the `(:remote-addr request)` if not set, or if disabled via MB_NOT_BEHIND_PROXY=true."
+ [{:keys [headers remote-addr]}]
+ (let [header-ip-address (some->> (request.settings/source-address-header)
+ (get headers))
+ source-address (if (or (request.settings/not-behind-proxy)
+ (not header-ip-address))
+ remote-addr
+ header-ip-address)]
+ (some-> source-address
+ ;; first IP (if there are multiple) is the actual client -- see
+ ;; https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For
+ (str/split #"\s*,\s*")
+ first
+ ;; strip out non-ip-address characters like square brackets which we get sometimes
+ (str/replace #"[^0-9a-fA-F.:]" ""))))
diff --git a/src/metabase/request/user_agent.clj b/src/metabase/request/user_agent.clj
new file mode 100644
index 00000000000..a094ead408b
--- /dev/null
+++ b/src/metabase/request/user_agent.clj
@@ -0,0 +1,24 @@
+(ns metabase.request.user-agent
+ "Parsing and formatting of User-Agent strings."
+ (:require
+ [clojure.string :as str]
+ [metabase.util.i18n :refer [tru]]
+ [user-agent :as user-agent]))
+
+(defn describe-user-agent
+ "Format a user-agent string from a request in a human-friendly way."
+ [user-agent-string]
+ (when-not (str/blank? user-agent-string)
+ (when-let [{device-type :type-name
+ {os-name :name} :os
+ browser-name :name} (some-> user-agent-string user-agent/parse not-empty)]
+ (let [non-blank (fn [s]
+ (when-not (str/blank? s)
+ s))
+ device-type (or (non-blank device-type)
+ (tru "Unknown device type"))
+ os-name (or (non-blank os-name)
+ (tru "Unknown OS"))
+ browser-name (or (non-blank browser-name)
+ (tru "Unknown browser"))]
+ (format "%s (%s/%s)" device-type browser-name os-name)))))
diff --git a/src/metabase/request/util.clj b/src/metabase/request/util.clj
index 20c4c698f37..6424bb8ab07 100644
--- a/src/metabase/request/util.clj
+++ b/src/metabase/request/util.clj
@@ -7,14 +7,13 @@
[metabase.analytics-interface.core :as analytics]
[metabase.config.core :as config]
[metabase.embedding.util :as embed.util]
- [metabase.request.settings :as request.settings]
+ [metabase.request.current :as request.current]
[metabase.util :as u]
- [metabase.util.i18n :refer [trs tru]]
+ [metabase.util.i18n :refer [trs]]
[metabase.util.json :as json]
[metabase.util.log :as log]
[metabase.util.malli :as mu]
- [metabase.util.malli.schema :as ms]
- [user-agent :as user-agent])
+ [metabase.util.malli.schema :as ms])
(:import
(java.time ZoneId)))
@@ -66,24 +65,6 @@
[request]
(some-> request (get-in [:headers "x-metabase-embedded"]) Boolean/parseBoolean))
-(defn ip-address
- "The IP address a Ring `request` came from. Looks at the `request.settings/source-address-header` header (by default
- `X-Forwarded-For`, or the `(:remote-addr request)` if not set, or if disabled via MB_NOT_BEHIND_PROXY=true."
- [{:keys [headers remote-addr]}]
- (let [header-ip-address (some->> (request.settings/source-address-header)
- (get headers))
- source-address (if (or (request.settings/not-behind-proxy)
- (not header-ip-address))
- remote-addr
- header-ip-address)]
- (some-> source-address
- ;; first IP (if there are multiple) is the actual client -- see
- ;; https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Forwarded-For
- (str/split #"\s*,\s*")
- first
- ;; strip out non-ip-address characters like square brackets which we get sometimes
- (str/replace #"[^0-9a-fA-F.:]" ""))))
-
(def DeviceInfo
"Schema for the device info returned by `device-info`."
[:map {:closed true}
@@ -100,7 +81,7 @@
(log/warn "Login request is missing device ID information"))
description (or user-agent
(log/warn "Login request is missing user-agent information"))
- ip-address (or (ip-address request)
+ ip-address (or (request.current/ip-address request)
(log/warn "Unable to determine login request IP address"))]
(when-not (and id description ip-address)
(log/warn "Error determining login history for request"))
@@ -110,24 +91,6 @@
:ip_address (or ip-address (trs "unknown"))
:token_exchange (boolean token-exchange?)}))
-(defn describe-user-agent
- "Format a user-agent string from a request in a human-friendly way."
- [user-agent-string]
- (when-not (str/blank? user-agent-string)
- (when-let [{device-type :type-name
- {os-name :name} :os
- browser-name :name} (some-> user-agent-string user-agent/parse not-empty)]
- (let [non-blank (fn [s]
- (when-not (str/blank? s)
- s))
- device-type (or (non-blank device-type)
- (tru "Unknown device type"))
- os-name (or (non-blank os-name)
- (tru "Unknown OS"))
- browser-name (or (non-blank browser-name)
- (tru "Unknown browser"))]
- (format "%s (%s/%s)" device-type browser-name os-name)))))
-
(defn- describe-location [{:keys [city region country]}]
(when-let [info (not-empty (remove str/blank? [city region country]))]
(str/join ", " info)))
diff --git a/src/metabase/server/handler.clj b/src/metabase/server/handler.clj
index 09d57bd1f97..426a5b8623e 100644
--- a/src/metabase/server/handler.clj
+++ b/src/metabase/server/handler.clj
@@ -78,8 +78,9 @@
(defn middleware-fn [handler]
(fn handler' [request respond raise]
(handler request respond raise)))"
- ;; ▼▼▼ Middleware is APPLIED from TOP-TO-BOTTOM, but the returned `handlers` will see the requests in order from BOTTOM-TO-TOP. ▼▼▼
- (->> [#'mw.exceptions/catch-uncaught-exceptions ; catch any Exceptions that weren't passed to `raise`
+ ;; ▼▼▼ The returned `handlers` will see the requests in order from BOTTOM-TO-TOP, but the middleware is CONSTRUCTED/WRAPPED from TOP-TO-BOTTOM. ▼▼▼
+ (->> [ ;; Inside of the middleware onion
+ #'mw.exceptions/catch-uncaught-exceptions ; catch any Exceptions that weren't passed to `raise`
#'mw.exceptions/catch-api-exceptions ; catch exceptions and return them in our expected format
#'mw.log/log-api-call ; log info about the request, db call counts etc.
#'mw.browser-cookie/ensure-browser-id-cookie ; add cookie to identify browser; add `:browser-id` to the request
@@ -111,6 +112,7 @@
#'mw.ssl/redirect-to-https-middleware
wrap-reload-dev-mw ; reloads outdated clojure code when --hot flag is passed with the :dev-start alias
wrap-remote-api-proxy-dev-mw ; proxies /api/* to remote backend if MB_REMOTE_API_URL is set (dev only)
+ ;; Outside of middleware onion
]
(remove nil?)))
diff --git a/src/metabase/server/middleware/session.clj b/src/metabase/server/middleware/session.clj
index 2d4e4c8f374..caa566c8ee5 100644
--- a/src/metabase/server/middleware/session.clj
+++ b/src/metabase/server/middleware/session.clj
@@ -19,6 +19,7 @@
[java-time.api :as t]
[malli.error :as me]
[medley.core :as m]
+ [metabase.analytics.core :as analytics]
[metabase.api-keys.core :as api-key]
[metabase.api-keys.schema :as api-keys.schema]
[metabase.app-db.core :as mdb]
@@ -116,10 +117,12 @@
(cond-> {:select [[:session.user_id :metabase-user-id]
[:user.is_superuser :is-superuser?]
[:user.is_data_analyst :is-data-analyst?]
- [:user.locale :user-locale]]
+ [:user.locale :user-locale]
+ [:auth_identity.provider :auth-provider]]
:from [[:core_session :session]]
:left-join [[:core_user :user] [:= :session.user_id :user.id]
- [:tenant] [:= :tenant.id :user.tenant_id]]
+ [:tenant] [:= :tenant.id :user.tenant_id]
+ [:auth_identity] [:= :auth_identity.id :session.auth_identity_id]]
:where (into [:and
(if enable-tenants?
[:or [:= :tenant.id nil] :tenant.is_active]
@@ -238,15 +241,25 @@
(-> user-info
(dissoc :api-key)))))))
+(defn- auth-method
+ [session-info api-key-info embedding-route]
+ (or ({"guest-embed" "guest"} embedding-route embedding-route)
+ (cond session-info (or (:auth-provider session-info) "session")
+ api-key-info "api-key")))
+
(defn- merge-current-user-info
[{:keys [metabase-session-key anti-csrf-token], {:strs [x-metabase-locale x-api-key]} :headers, :as request}]
- (merge
- request
- (or (current-user-info-for-session metabase-session-key anti-csrf-token)
- (current-user-info-for-api-key x-api-key))
- (when x-metabase-locale
- (log/tracef "Found X-Metabase-Locale header: using %s as user locale" (pr-str x-metabase-locale))
- {:user-locale (i18n/normalized-locale-string x-metabase-locale)})))
+ (let [session-info (current-user-info-for-session metabase-session-key anti-csrf-token)
+ api-key-info (when-not session-info (current-user-info-for-api-key x-api-key))
+ embedding-route (analytics/get-route)
+ auth-method (auth-method session-info api-key-info embedding-route)]
+ (merge
+ request
+ (dissoc (or session-info api-key-info) :auth-provider)
+ (when auth-method {:embedding/auth-method auth-method})
+ (when x-metabase-locale
+ (log/tracef "Found X-Metabase-Locale header: using %s as user locale" (pr-str x-metabase-locale))
+ {:user-locale (i18n/normalized-locale-string x-metabase-locale)}))))
(defn wrap-current-user-info
"Add `:metabase-user-id`, `:is-superuser?`, `:is-group-manager?` and `:user-locale` to the request if a valid session
@@ -255,7 +268,8 @@
(fn [request respond raise]
(let [request' (tracing/with-span :db-app "db-app.session-lookup" {}
(merge-current-user-info request))]
- (handler request' respond raise))))
+ (analytics/with-auth-method! (:embedding/auth-method request')
+ (handler request' respond raise)))))
;;; +----------------------------------------------------------------------------------------------------------------+
;;; | bind-current-user |
diff --git a/src/metabase/view_log/events/view_log.clj b/src/metabase/view_log/events/view_log.clj
index 75cee224a2a..5df06d7bda9 100644
--- a/src/metabase/view_log/events/view_log.clj
+++ b/src/metabase/view_log/events/view_log.clj
@@ -92,7 +92,8 @@
:user_id (or user-id api/*current-user-id*)
:model_id (or object-id (u/id object))
:has_access has-access
- :context context})
+ :context context
+ :tenant_id (:tenant_id @api/*current-user*)})
(derive ::card-read-event :metabase/event)
(derive :event/card-read ::card-read-event)
diff --git a/test/metabase/analytics/prometheus_test.clj b/test/metabase/analytics/prometheus_test.clj
index 772f03696e0..2d80e141ecc 100644
--- a/test/metabase/analytics/prometheus_test.clj
+++ b/test/metabase/analytics/prometheus_test.clj
@@ -255,6 +255,10 @@
(prometheus/inc! :metabase-sdk/response {:status "404"} 0)
(prometheus/inc! :metabase-embedding-iframe/response {:status "200"} 0)
(prometheus/inc! :metabase-embedding-iframe/response {:status "404"} 0)
+ (prometheus/inc! :metabase-embedding-iframe-full-app/response {:status "200"} 0)
+ (prometheus/inc! :metabase-embedding-iframe-static/response {:status "200"} 0)
+ (prometheus/inc! :metabase-embedding-public/response {:status "200"} 0)
+ (prometheus/inc! :metabase-embedding-simple/response {:status "200"} 0)
;; Track SDK responses
(prometheus/inc! :metabase-sdk/response {:status "200"})
@@ -264,10 +268,22 @@
(prometheus/inc! :metabase-embedding-iframe/response {:status "200"})
(prometheus/inc! :metabase-embedding-iframe/response {:status "404"})
+ ;; Track new embedding responses
+ (prometheus/inc! :metabase-embedding-iframe-full-app/response {:status "200"})
+ (prometheus/inc! :metabase-embedding-iframe-static/response {:status "200"})
+ (prometheus/inc! :metabase-embedding-public/response {:status "200"})
+ (prometheus/inc! :metabase-embedding-simple/response {:status "200"})
+
(testing "SDK response metrics are recorded correctly"
(is (approx= 1 (mt/metric-value system :metabase-sdk/response {:status "200"})))
(is (approx= 1 (mt/metric-value system :metabase-sdk/response {:status "404"}))))
(testing "iframe response metrics are recorded correctly"
(is (approx= 1 (mt/metric-value system :metabase-embedding-iframe/response {:status "200"})))
- (is (approx= 1 (mt/metric-value system :metabase-embedding-iframe/response {:status "404"})))))))
+ (is (approx= 1 (mt/metric-value system :metabase-embedding-iframe/response {:status "404"}))))
+
+ (testing "new embedding response metrics are recorded correctly"
+ (is (approx= 1 (mt/metric-value system :metabase-embedding-iframe-full-app/response {:status "200"})))
+ (is (approx= 1 (mt/metric-value system :metabase-embedding-iframe-static/response {:status "200"})))
+ (is (approx= 1 (mt/metric-value system :metabase-embedding-public/response {:status "200"})))
+ (is (approx= 1 (mt/metric-value system :metabase-embedding-simple/response {:status "200"})))))))
diff --git a/test/metabase/comments/api_test.clj b/test/metabase/comments/api_test.clj
index 9ffbc15454f..50573ede076 100644
--- a/test/metabase/comments/api_test.clj
+++ b/test/metabase/comments/api_test.clj
@@ -4,7 +4,6 @@
[clojure.set :as set]
[clojure.string :as str]
[clojure.test :refer :all]
- [metabase.analytics.sdk :as sdk]
[metabase.notification.seed :as notification.seed]
[metabase.test :as mt]
[metabase.util :as u]
@@ -351,10 +350,10 @@
(is (=? {:comments []
:disabled true}
(mt/user-http-request :rasta :get 200 "comment/"
- {:request-options {:headers {"x-metabase-client" @#'sdk/embedding-iframe-client}}}
+ {:request-options {:headers {"x-metabase-client" "embedding-iframe"}}}
:target_type "document"
:target_id doc-id))))
(testing "Users mentions are not available either"
(is (= "Not found."
(mt/user-http-request :rasta :get 404 "comment/mentions"
- {:request-options {:headers {"x-metabase-client" @#'sdk/embedding-iframe-client}}})))))))
+ {:request-options {:headers {"x-metabase-client" "embedding-iframe"}}})))))))
diff --git a/test/metabase/embedding_rest/api/preview_embed_test.clj b/test/metabase/embedding_rest/api/preview_embed_test.clj
index d76e44d61c9..f20332b38b0 100644
--- a/test/metabase/embedding_rest/api/preview_embed_test.clj
+++ b/test/metabase/embedding_rest/api/preview_embed_test.clj
@@ -584,7 +584,7 @@
(let [signed-token (dash-token dashboard)
url (format "preview_embed/dashboard/%s/params/%s/values" signed-token "_STATIC_CATEGORY_")]
(testing "Should work if the param we're fetching values for is enabled"
- (testing "\nGET /api/preview-embed/dashboard/:token/params/:param-key/values"
+ (testing "\nGET /api/preview_embed/dashboard/:token/params/:param-key/values"
(is (= {:values [["African"] ["American"] ["Asian"]]
:has_more_values false}
(mt/user-http-request :rasta :get 200 url))))))))))
diff --git a/test/metabase/internal_stats/query_executions_test.clj b/test/metabase/internal_stats/query_executions_test.clj
index c75f5f5b1a8..ed52d316dc0 100644
--- a/test/metabase/internal_stats/query_executions_test.clj
+++ b/test/metabase/internal_stats/query_executions_test.clj
@@ -18,25 +18,47 @@
:started_at (t/offset-date-time)})
(deftest query-execution-24h-filtering-test
+ (mt/initialize-if-needed! :db)
(t/with-clock (t/mock-clock 1583351015000)
(let [before (sut/query-executions-all-time-and-last-24h)
one-year-ago-defaults (assoc query-execution-defaults
:started_at (-> (t/offset-date-time)
(t/minus (t/years 1))))]
(mt/with-temp [:model/User u {}
+ ;; -- one year ago rows (all-time only) --
:model/QueryExecution _ one-year-ago-defaults
:model/QueryExecution _ (assoc one-year-ago-defaults :embedding_client "embedding-sdk-react")
+ :model/QueryExecution _ (assoc one-year-ago-defaults :embedding_client "embedding-simple")
+ ;; legacy embedding-iframe (no executor = static)
:model/QueryExecution _ (assoc one-year-ago-defaults :embedding_client "embedding-iframe")
:model/QueryExecution _ (assoc one-year-ago-defaults :embedding_client "embedding-iframe")
+ ;; legacy embedding-iframe (with executor = interactive)
:model/QueryExecution _ (assoc one-year-ago-defaults
:embedding_client "embedding-iframe"
:executor_id (u/the-id u))
+ ;; new header values
+ :model/QueryExecution _ (assoc one-year-ago-defaults
+ :embedding_client "embedding-iframe-full-app"
+ :executor_id (u/the-id u))
+ :model/QueryExecution _ (assoc one-year-ago-defaults :embedding_client "embedding-iframe-static")
+ :model/QueryExecution _ (assoc one-year-ago-defaults :embedding_client "embedding-public")
+ ;; context-based public link
:model/QueryExecution _ (assoc one-year-ago-defaults :context :public-question)
:model/QueryExecution _ (assoc one-year-ago-defaults :context :public-csv-download)
+ ;; -- recent rows (within 24h) --
:model/QueryExecution _ query-execution-defaults
:model/QueryExecution _ (assoc query-execution-defaults :embedding_client "embedding-sdk-react")
+ :model/QueryExecution _ (assoc query-execution-defaults :embedding_client "embedding-simple")
+ ;; legacy embedding-iframe (no executor = static)
:model/QueryExecution _ (assoc query-execution-defaults :embedding_client "embedding-iframe")
:model/QueryExecution _ (assoc query-execution-defaults :embedding_client "embedding-iframe")
+ ;; new header values
+ :model/QueryExecution _ (assoc query-execution-defaults
+ :embedding_client "embedding-iframe-full-app"
+ :executor_id (u/the-id u))
+ :model/QueryExecution _ (assoc query-execution-defaults :embedding_client "embedding-iframe-static")
+ :model/QueryExecution _ (assoc query-execution-defaults :embedding_client "embedding-public")
+ ;; context-based public link
:model/QueryExecution _ (assoc query-execution-defaults :context :public-question)
:model/QueryExecution _ (assoc query-execution-defaults :context :public-csv-download)]
(let [after (sut/query-executions-all-time-and-last-24h)
@@ -48,19 +70,26 @@
(is (= 1 (- after-24h-internal before-24h-internal)))
(is (= 2 (- (-> after :query-executions :sdk_embed)
(-> before :query-executions :sdk_embed))))
- (is (= 4 (- (-> after :query-executions :static_embed)
+ (is (= 2 (- (-> after :query-executions :simple_embed)
+ (-> before :query-executions :simple_embed))))
+ ;; 3 static per window: 2 legacy embedding-iframe + 1 embedding-iframe-static
+ (is (= 6 (- (-> after :query-executions :static_embed)
(-> before :query-executions :static_embed))))
- (is (= 4 (- (-> after :query-executions :public_link)
+ ;; 3 public per window: 2 context-based + 1 embedding-public
+ (is (= 6 (- (-> after :query-executions :public_link)
(-> before :query-executions :public_link))))
- (is (= 1 (- (-> after :query-executions :interactive_embed)
+ ;; 3 interactive total: 1 old legacy + 1 old new + 1 recent new
+ (is (= 3 (- (-> after :query-executions :interactive_embed)
(-> before :query-executions :interactive_embed))))
(is (= 1 (- (-> after :query-executions-24h :sdk_embed)
(-> before :query-executions-24h :sdk_embed))))
- (is (= 2 (- (-> after :query-executions-24h :static_embed)
+ (is (= 1 (- (-> after :query-executions-24h :simple_embed)
+ (-> before :query-executions-24h :simple_embed))))
+ (is (= 3 (- (-> after :query-executions-24h :static_embed)
(-> before :query-executions-24h :static_embed))))
- (is (= 2 (- (-> after :query-executions-24h :public_link)
+ (is (= 3 (- (-> after :query-executions-24h :public_link)
(-> before :query-executions-24h :public_link))))
- (is (= 0 (- (-> after :query-executions-24h :interactive_embed)
+ (is (= 1 (- (-> after :query-executions-24h :interactive_embed)
(-> before :query-executions-24h :interactive_embed)))))))))
(deftest query-execution-last-utc-day-test
diff --git a/test/metabase/metabot/query_analyzer/parameter_substitution_test.clj b/test/metabase/metabot/query_analyzer/parameter_substitution_test.clj
index 7535366cc5e..4d74fa00fea 100644
--- a/test/metabase/metabot/query_analyzer/parameter_substitution_test.clj
+++ b/test/metabase/metabot/query_analyzer/parameter_substitution_test.clj
@@ -1,9 +1,12 @@
(ns metabase.metabot.query-analyzer.parameter-substitution-test
(:require
- [clojure.test :refer [deftest is testing]]
+ [clojure.test :refer [deftest is testing use-fixtures]]
[metabase.lib.core :as lib]
[metabase.lib.test-metadata :as meta]
- [metabase.metabot.query-analyzer.parameter-substitution :as nqa.sub]))
+ [metabase.metabot.query-analyzer.parameter-substitution :as nqa.sub]
+ [metabase.test.fixtures :as fixtures]))
+
+(use-fixtures :once (fixtures/initialize :db))
(deftest replace-tags-without-template-tags-test
(testing "Query without template tags returns raw SQL"
diff --git a/test/metabase/queries_rest/api/card_test.clj b/test/metabase/queries_rest/api/card_test.clj
index 0b40eedc84b..07f6ab5df38 100644
--- a/test/metabase/queries_rest/api/card_test.clj
+++ b/test/metabase/queries_rest/api/card_test.clj
@@ -310,8 +310,8 @@
(mt/user-http-request :crowberto :post 202 (str "card/" (u/the-id card-1) "/query")
{:request-options {:headers {"x-metabase-client" client-string
"x-metabase-client-version" version-string}}}))
- (is (= {:embedding_client client-string, :embedding_version version-string}
- (t2/select-one [:model/ViewLog :embedding_client :embedding_version] :model "card" :model_id (u/the-id card-1))))))))
+ (is (= {:embedding_client client-string, :embedding_sdk_version version-string}
+ (t2/select-one [:model/ViewLog :embedding_client :embedding_sdk_version] :model "card" :model_id (u/the-id card-1))))))))
(deftest embedding-sdk-info-saves-query-execution
(testing "GET /api/card with embedding headers set"
@@ -324,10 +324,10 @@
(mt/user-http-request :crowberto :post 202 (format "card/%d/query" (u/the-id card-1))
{:request-options {:headers {"x-metabase-client" "client-B"
"x-metabase-client-version" "2"}}})
- (is (=? {:embedding_client "client-B", :embedding_version "2"}
+ (is (=? {:embedding_client "client-B", :embedding_sdk_version "2"}
;; The query metadata is handled asynchronously, so we need to poll until it's available:
(tu/poll-until 2000
- (t2/select-one [:model/QueryExecution :embedding_client :embedding_version]
+ (t2/select-one [:model/QueryExecution :embedding_client :embedding_sdk_version]
:card_id (u/the-id card-1))))))))
(deftest filter-by-bookmarked-test
diff --git a/test/metabase/query_processor/api_test.clj b/test/metabase/query_processor/api_test.clj
index 14abfb9749b..baa21212b32 100644
--- a/test/metabase/query_processor/api_test.clj
+++ b/test/metabase/query_processor/api_test.clj
@@ -53,7 +53,7 @@
(m/dissoc-in [:data :results_metadata])
(m/dissoc-in [:data :insights]))]
(cond
- (contains? #{:id :started_at :running_time :hash :cache_hash} k)
+ (contains? #{:id :started_at :running_time :hash :cache_hash :auth_method :metabase_version} k)
[k (boolean v)]
(and (= :data k) (contains? v :native_form))
@@ -128,7 +128,19 @@
:started_at true
:running_time true
:embedding_client nil
- :embedding_version nil}
+ :embedding_hostname nil
+ :embedding_path nil
+ :embedding_route nil
+ :embedding_sdk_version nil
+ :metabase_version true
+ :auth_method true
+ :ip_address nil
+ :is_db_routed false
+ :is_impersonated false
+ :parameters nil
+ :tenant_id nil
+ :user_agent nil
+ :sanitized_user_agent nil}
(format-response (most-recent-query-execution-for-query query)))))))))
(deftest failure-test
diff --git a/test/metabase/query_processor/middleware/process_userland_query_test.clj b/test/metabase/query_processor/middleware/process_userland_query_test.clj
index 5b4cd6e233c..0a11b83e06f 100644
--- a/test/metabase/query_processor/middleware/process_userland_query_test.clj
+++ b/test/metabase/query_processor/middleware/process_userland_query_test.clj
@@ -84,23 +84,26 @@
:cached nil}
(process-userland-query query))
"Result should have query execution info")
- (is (=? {:hash (codecs/bytes->hex (qp.util/query-hash query))
- :database_id (mt/id)
- :result_rows 0
- :started_at #t "2020-02-04T12:22:00.000-08:00[US/Pacific]"
- :executor_id nil
- :json_query (dissoc (mt/userland-query query) :info)
- :native false
- :pulse_id nil
- :card_id nil
- :action_id nil
- :is_sandboxed false
- :context nil
- :running_time true
- :cache_hit false
- :cache_hash nil ;; this is filled only for eligible queries
- :dashboard_id nil
- :parameterized false}
+ (is (=? {:hash (codecs/bytes->hex (qp.util/query-hash query))
+ :database_id (mt/id)
+ :result_rows 0
+ :started_at #t "2020-02-04T12:22:00.000-08:00[US/Pacific]"
+ :executor_id nil
+ :json_query (dissoc (mt/userland-query query) :info)
+ :native false
+ :pulse_id nil
+ :card_id nil
+ :action_id nil
+ :is_sandboxed false
+ :is_impersonated false
+ :is_db_routed false
+ :parameters nil
+ :context nil
+ :running_time true
+ :cache_hit false
+ :cache_hash nil ;; this is filled only for eligible queries
+ :dashboard_id nil
+ :parameterized false}
(qe))
"QueryExecution should be saved"))))
@@ -160,6 +163,29 @@
(process-userland-query query)
(is (=? {:parameterized true} (qe)))))))
+(deftest parameters-pii-gated-test
+ (testing ":parameters is only persisted when analytics-pii-retention-enabled is true"
+ (let [query (mt/query venues
+ {:query {:aggregation [[:count]]}
+ :parameters [{:name "price"
+ :type :category
+ :target $price
+ :value "4"}]})]
+ (testing "PII retention enabled -> parameters populated"
+ (mt/with-temporary-setting-values [analytics-pii-retention-enabled true]
+ (with-query-execution! [qe query]
+ (process-userland-query query)
+ (is (=? {:parameterized true
+ :parameters some?}
+ (qe))))))
+ (testing "PII retention disabled -> parameters nil, parameterized still set"
+ (mt/with-temporary-setting-values [analytics-pii-retention-enabled false]
+ (with-query-execution! [qe query]
+ (process-userland-query query)
+ (is (=? {:parameterized true
+ :parameters nil}
+ (qe)))))))))
+
(def ^:private ^:dynamic *viewlog-call-count* nil)
(methodical/defmethod events/publish-event! ::event
diff --git a/test/metabase/request/util_test.clj b/test/metabase/request/util_test.clj
index 25630f86087..f019d97b964 100644
--- a/test/metabase/request/util_test.clj
+++ b/test/metabase/request/util_test.clj
@@ -5,6 +5,8 @@
[clojure.test :refer :all]
[clojure.tools.reader.edn :as edn]
[java-time.api :as t]
+ [metabase.request.current :as request.current]
+ [metabase.request.user-agent :as request.user-agent]
[metabase.request.util :as req.util]
[metabase.test :as mt]
[metabase.util.json :as json]
@@ -72,7 +74,7 @@
(req.util/device-info (update @mock-request :headers assoc "x-metabase-client" "embedding-simple"))))))
(deftest ^:parallel describe-user-agent-test
- (are [user-agent expected] (= expected (req.util/describe-user-agent user-agent))
+ (are [user-agent expected] (= expected (request.user-agent/describe-user-agent user-agent))
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML like Gecko) Chrome/89.0.4389.86 Safari/537.36"
"Browser (Chrome/Windows)"
@@ -95,31 +97,31 @@
(let [request (ring.mock/request :get "api/session")]
(testing "request with no forwarding"
(is (= "127.0.0.1"
- (req.util/ip-address request))))
+ (request.current/ip-address request))))
(testing "request with forwarding"
(let [mock-request (-> (ring.mock/request :get "api/session")
(ring.mock/header "X-Forwarded-For" "5.6.7.8"))]
(is (= "5.6.7.8"
- (req.util/ip-address mock-request))))
+ (request.current/ip-address mock-request))))
(testing "multiple IP addresses"
(let [mock-request (-> (ring.mock/request :get "api/session")
(ring.mock/header "X-Forwarded-For" "1.2.3.4, 5.6.7.8"))]
(is (= "1.2.3.4"
- (req.util/ip-address mock-request)))))
+ (request.current/ip-address mock-request)))))
(testing "different header than default X-Forwarded-For"
(mt/with-temporary-setting-values [source-address-header "X-ProxyUser-Ip"]
(let [mock-request (-> (ring.mock/request :get "api/session")
(ring.mock/header "x-proxyuser-ip" "1.2.3.4"))]
(is (= "1.2.3.4"
- (req.util/ip-address mock-request)))))))
+ (request.current/ip-address mock-request)))))))
(testing "forwarding explicitly disabled via MB_NOT_BEHIND_PROXY=true"
(mt/with-temp-env-var-value! [mb-not-behind-proxy "true"]
(let [mock-request (-> (ring.mock/request :get "api/session")
(ring.mock/header "X-Forwarded-For" "5.6.7.8"))]
(is (= "127.0.0.1"
- (req.util/ip-address mock-request))))))))
+ (request.current/ip-address mock-request))))))))
(def ^:private mock-geojs-responses
"Canned GeoJS responses for test IPs. These mock what GeoJS would return."
diff --git a/test/metabase/server/middleware/sdk_test.clj b/test/metabase/server/middleware/sdk_test.clj
index b3303a3f183..c018cbdf914 100644
--- a/test/metabase/server/middleware/sdk_test.clj
+++ b/test/metabase/server/middleware/sdk_test.clj
@@ -5,6 +5,7 @@
[metabase.analytics-interface.core :as analytics]
[metabase.analytics.core :as analytics.core]
[metabase.analytics.sdk :as sdk]
+ [metabase.request.current :as request.current]
[metabase.test :as mt]
[metabase.util :as u]
[ring.mock.request :as ring.mock]))
@@ -45,7 +46,7 @@
(deftest embeding-mw-bumps-metrics-with-react-sdk-client-header
(mt/with-prometheus-system! [_ system]
;; X-Metabase-Client header == "embedding-sdk-react" => SDK context
- (let [request (mock-request {:client @#'sdk/embedding-sdk-client})
+ (let [request (mock-request {:client "embedding-sdk-react"})
good (analytics.core/embedding-mw (fn [_ respond _] (respond {:status 200})))
bad (analytics.core/embedding-mw (fn [_ respond _] (respond {:status 400})))
exception (analytics.core/embedding-mw (fn [_ _respond raise] (raise {})))]
@@ -62,7 +63,7 @@
(deftest embeding-mw-bumps-metrics-with-iframe-client-header
(mt/with-prometheus-system! [_ system]
;; X-Metabase-Client header == "embedding-iframe" => iframe context
- (let [request (mock-request {:client @#'sdk/embedding-iframe-client})
+ (let [request (mock-request {:client "embedding-iframe"})
good (analytics.core/embedding-mw (fn [_ respond _] (respond {:status 200})))
bad (analytics.core/embedding-mw (fn [_ respond _] (respond {:status 400})))
exception (analytics.core/embedding-mw (fn [_ _respond raise] (raise {})))]
@@ -76,6 +77,70 @@
(is (= 1.0 (mt/metric-value system :metabase-embedding-iframe/response {:status "400"})))
(is (= 1.0 (mt/metric-value system :metabase-embedding-iframe/response {:status "500"}))))))
+(deftest embedding-mw-bumps-metrics-with-iframe-full-app-client-header
+ (mt/with-prometheus-system! [_ system]
+ (let [request (mock-request {:client "embedding-iframe-full-app"})
+ good (analytics.core/embedding-mw (fn [_ respond _] (respond {:status 200})))
+ bad (analytics.core/embedding-mw (fn [_ respond _] (respond {:status 400})))
+ exception (analytics.core/embedding-mw (fn [_ _respond raise] (raise {})))]
+ (good request identity identity)
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-iframe-full-app/response {:status "200"})))
+ (bad request identity identity)
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-iframe-full-app/response {:status "200"})))
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-iframe-full-app/response {:status "400"})))
+ (exception request identity identity)
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-iframe-full-app/response {:status "200"})))
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-iframe-full-app/response {:status "400"})))
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-iframe-full-app/response {:status "500"}))))))
+
+(deftest embedding-mw-bumps-metrics-with-iframe-static-client-header
+ (mt/with-prometheus-system! [_ system]
+ (let [request (mock-request {:client "embedding-iframe-static"})
+ good (analytics.core/embedding-mw (fn [_ respond _] (respond {:status 200})))
+ bad (analytics.core/embedding-mw (fn [_ respond _] (respond {:status 400})))
+ exception (analytics.core/embedding-mw (fn [_ _respond raise] (raise {})))]
+ (good request identity identity)
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-iframe-static/response {:status "200"})))
+ (bad request identity identity)
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-iframe-static/response {:status "200"})))
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-iframe-static/response {:status "400"})))
+ (exception request identity identity)
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-iframe-static/response {:status "200"})))
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-iframe-static/response {:status "400"})))
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-iframe-static/response {:status "500"}))))))
+
+(deftest embedding-mw-bumps-metrics-with-public-client-header
+ (mt/with-prometheus-system! [_ system]
+ (let [request (mock-request {:client "embedding-public"})
+ good (analytics.core/embedding-mw (fn [_ respond _] (respond {:status 200})))
+ bad (analytics.core/embedding-mw (fn [_ respond _] (respond {:status 400})))
+ exception (analytics.core/embedding-mw (fn [_ _respond raise] (raise {})))]
+ (good request identity identity)
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-public/response {:status "200"})))
+ (bad request identity identity)
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-public/response {:status "200"})))
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-public/response {:status "400"})))
+ (exception request identity identity)
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-public/response {:status "200"})))
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-public/response {:status "400"})))
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-public/response {:status "500"}))))))
+
+(deftest embedding-mw-bumps-metrics-with-simple-client-header
+ (mt/with-prometheus-system! [_ system]
+ (let [request (mock-request {:client "embedding-simple"})
+ good (analytics.core/embedding-mw (fn [_ respond _] (respond {:status 200})))
+ bad (analytics.core/embedding-mw (fn [_ respond _] (respond {:status 400})))
+ exception (analytics.core/embedding-mw (fn [_ _respond raise] (raise {})))]
+ (good request identity identity)
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-simple/response {:status "200"})))
+ (bad request identity identity)
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-simple/response {:status "200"})))
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-simple/response {:status "400"})))
+ (exception request identity identity)
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-simple/response {:status "200"})))
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-simple/response {:status "400"})))
+ (is (= 1.0 (mt/metric-value system :metabase-embedding-simple/response {:status "500"}))))))
+
(deftest embeding-mw-does-not-bump-metrics-with-random-sdk-header
(let [prometheus-standin (atom {})]
(with-redefs [analytics/inc! (fn [k _] (swap! prometheus-standin update k (fnil inc 0)))]
@@ -105,20 +170,180 @@
(exception request identity identity)
(is (= {} @prometheus-standin))))))
+(deftest extract-hostname-test
+ (testing "extracts hostname from various URL formats"
+ (are [url expected]
+ (= expected (sdk/extract-hostname url))
+ "https://app.example.com" "app.example.com"
+ "https://app.example.com:8443" "app.example.com"
+ "https://app.example.com/path?q=1" "app.example.com"
+ "http://localhost:3000" "localhost"
+ "http://192.168.1.1:8080" "192.168.1.1"))
+ (testing "returns nil for nil, blank, or unparseable input"
+ (are [url]
+ (nil? (sdk/extract-hostname url))
+ nil
+ ""
+ "not a url")))
+
+(deftest extract-path-test
+ (testing "extracts path, stripping query params and fragment"
+ (are [url expected]
+ (= expected (sdk/extract-path url))
+ "https://example.com/dashboard/1" "/dashboard/1"
+ "https://example.com/dash/1?foo=bar" "/dash/1"
+ "https://example.com/dash/1#section" "/dash/1"
+ "https://example.com/dash/1?a=b#section" "/dash/1"))
+ (testing "returns nil for nil, blank, or root-only URLs"
+ (are [url]
+ (nil? (sdk/extract-path url))
+ nil
+ ""
+ "not a url")))
+
+(deftest pii-request-info-test
+ (testing "returns all fields from request values"
+ (is (= {:embedding_hostname "app.example.com"
+ :embedding_path "/dashboard/1"
+ :user_agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
+ :sanitized_user_agent "Browser (Chrome/OS X)"
+ :ip_address "10.0.0.1"}
+ (sdk/pii-request-info {:origin "https://app.example.com"
+ :referer "https://app.example.com/dashboard/1?x=y"
+ :user-agent "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
+ :ip-address "10.0.0.1"}))))
+ (testing "handles nil values gracefully"
+ (is (= {:embedding_hostname nil, :embedding_path nil, :user_agent nil, :sanitized_user_agent nil, :ip_address nil}
+ (sdk/pii-request-info {})))))
+
+(defn- client-from-mw
+ "Runs a request through embedding-mw and returns the *client* value bound inside the handler."
+ [request]
+ (let [handler (analytics.core/embedding-mw
+ (fn [_ respond _] (respond {:status 200 :body (sdk/get-client)})))]
+ (:body (handler request identity identity))))
+
+(defn- route-from-mw
+ "Runs a request through embedding-mw and returns the *route* value bound inside the handler."
+ [request]
+ (let [handler (analytics.core/embedding-mw
+ (fn [_ respond _] (respond {:status 200 :body (sdk/get-route)})))]
+ (:body (handler request identity identity))))
+
+(deftest route-based-client-derivation-test
+ (testing "route prefix populates *route*, not *client*"
+ (are [uri expected]
+ (= expected (route-from-mw (assoc (ring.mock/request :get uri)
+ :uri uri)))
+ "/api/public/card/1" "public"
+ "/api/embed/dashboard/42" "guest-embed"
+ "/api/preview_embed/card/1" "guest-embed"
+ "/api/metabot/query" "metabot"
+ "/api/agent/chat" "agent-api"))
+ (testing "route requests without header give nil *client*"
+ (let [request (assoc (ring.mock/request :get "/api/public/card/1")
+ :uri "/api/public/card/1")]
+ (is (nil? (client-from-mw request)))))
+ (testing "header populates *client* independently of route"
+ (let [request (-> (ring.mock/request :get "/api/public/card/1")
+ (assoc :uri "/api/public/card/1")
+ (ring.mock/header "x-metabase-client" "embedding-sdk-react"))]
+ (is (= "embedding-sdk-react" (client-from-mw request)))
+ (is (= "public" (route-from-mw request)))))
+ (testing "falls back to header when no route matches"
+ (let [request (-> (ring.mock/request :get "/api/card/1")
+ (ring.mock/header "x-metabase-client" "embedding-sdk-react"))]
+ (is (= "embedding-sdk-react" (client-from-mw request)))))
+ (testing "nil when no route match and no header"
+ (is (nil? (client-from-mw (ring.mock/request :get "/api/card/1"))))
+ (is (nil? (route-from-mw (ring.mock/request :get "/api/card/1"))))))
+
+(deftest preview-suffix-test
+ (testing "-preview only applies to *client*, not *route*"
+ (let [request (-> (ring.mock/request :get "/api/embed/dashboard/42")
+ (assoc :uri "/api/embed/dashboard/42")
+ (ring.mock/header "x-metabase-client" "embedding-sdk-react")
+ (ring.mock/header "x-metabase-embedded-preview" "true"))]
+ (is (= "embedding-sdk-react-preview" (client-from-mw request)))
+ (is (= "guest-embed" (route-from-mw request)))))
+ (testing "preview with route but no header -> nil client"
+ (let [request (-> (ring.mock/request :get "/api/embed/dashboard/42")
+ (assoc :uri "/api/embed/dashboard/42")
+ (ring.mock/header "x-metabase-embedded-preview" "true"))]
+ (is (nil? (client-from-mw request)))
+ (is (= "guest-embed" (route-from-mw request)))))
+ (testing "preview header appends -preview to header-derived client"
+ (let [request (-> (ring.mock/request :get "/api/card/1")
+ (ring.mock/header "x-metabase-client" "embedding-sdk-react")
+ (ring.mock/header "x-metabase-embedded-preview" "true"))]
+ (is (= "embedding-sdk-react-preview" (client-from-mw request)))))
+ (testing "no -preview without the header"
+ (let [request (-> (ring.mock/request :get "/api/embed/dashboard/42")
+ (assoc :uri "/api/embed/dashboard/42")
+ (ring.mock/header "x-metabase-client" "embedding-sdk-react"))]
+ (is (= "embedding-sdk-react" (client-from-mw request))))))
+
(deftest include-analytics-is-idempotent
(let [m (atom {})]
(analytics.core/with-client! ["client-C"]
(analytics.core/with-version! ["1.33.7"]
- (is (= {:embedding_client "client-C"
- :embedding_version "1.33.7"}
- (analytics.core/include-sdk-info @m)))
+ (is (=? {:embedding_client "client-C"
+ :embedding_sdk_version "1.33.7"}
+ (analytics.core/include-sdk-info @m)))
(swap! m analytics.core/include-sdk-info)))
;; unset the vars:
(analytics.core/with-client! [nil]
(analytics.core/with-version! [nil]
- (is (= {:embedding_client "client-C"
- :embedding_version "1.33.7"} @m))
+ (is (=? {:embedding_client "client-C"
+ :embedding_sdk_version "1.33.7"} @m))
(testing "the values in m are used when the vars are not set"
- (is (= {:embedding_client "client-C"
- :embedding_version "1.33.7"}
- (analytics.core/include-sdk-info @m))))))))
+ (is (=? {:embedding_client "client-C"
+ :embedding_sdk_version "1.33.7"}
+ (analytics.core/include-sdk-info @m))))))))
+
+(deftest include-sdk-info-pii-fields-test
+ (let [request (-> (ring.mock/request :get "/api/public/card/1")
+ (ring.mock/header "x-metabase-embed-referrer" "https://app.example.com/dashboard/1?x=y")
+ (ring.mock/header "user-agent" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36")
+ (assoc :remote-addr "10.0.0.1"))]
+ (testing "PII fields populated when setting enabled and request bound"
+ (mt/with-temporary-setting-values [analytics-pii-retention-enabled true]
+ (request.current/with-current-request request
+ (let [result (sdk/include-sdk-info {})]
+ (is (= "app.example.com" (:embedding_hostname result)))
+ (is (= "/dashboard/1" (:embedding_path result)))
+ (is (= "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36"
+ (:user_agent result)))
+ (is (= "Browser (Chrome/OS X)" (:sanitized_user_agent result)))
+ (is (= "10.0.0.1" (:ip_address result)))))))
+ (testing "PII fields nil when setting disabled, but hostname still populated"
+ (mt/with-temporary-setting-values [analytics-pii-retention-enabled false]
+ (request.current/with-current-request request
+ (let [result (sdk/include-sdk-info {})]
+ (is (= "app.example.com" (:embedding_hostname result)))
+ (is (nil? (:embedding_path result)))
+ (is (nil? (:user_agent result)))
+ (is (nil? (:sanitized_user_agent result)))
+ (is (nil? (:ip_address result)))))))
+ (testing "PII fields nil when no request bound"
+ (mt/with-temporary-setting-values [analytics-pii-retention-enabled true]
+ (let [result (sdk/include-sdk-info {})]
+ (is (nil? (:embedding_hostname result)))
+ (is (nil? (:embedding_path result)))
+ (is (nil? (:user_agent result)))
+ (is (nil? (:sanitized_user_agent result)))
+ (is (nil? (:ip_address result))))))))
+
+(deftest embed-referrer-header-precedence-test
+ (let [request (-> (ring.mock/request :get "/api/embed/card/1")
+ (ring.mock/header "x-metabase-embed-referrer" "https://embed.example.com/analytics/dash")
+ (ring.mock/header "origin" "https://fallback-origin.example.com")
+ (ring.mock/header "referer" "https://fallback-referer.example.com/other/path")
+ (assoc :remote-addr "10.0.0.1"))]
+ (mt/with-temporary-setting-values [analytics-pii-retention-enabled true]
+ (request.current/with-current-request request
+ (let [result (sdk/include-sdk-info {})]
+ (testing "hostname comes from embed-referrer header, not origin"
+ (is (= "embed.example.com" (:embedding_hostname result))))
+ (testing "path comes from embed-referrer header, not referer"
+ (is (= "/analytics/dash" (:embedding_path result)))))))))
diff --git a/test/metabase/server/middleware/session_test.clj b/test/metabase/server/middleware/session_test.clj
index 1dda0b0c25d..4261a67beac 100644
--- a/test/metabase/server/middleware/session_test.clj
+++ b/test/metabase/server/middleware/session_test.clj
@@ -117,19 +117,21 @@
(let [req {:headers {"x-api-key" "mb_foobar123"}}]
(testing "No premium features, do not include :is-group-manager?"
(mt/with-premium-features #{}
- (is (= (merge req {:metabase-user-id (mt/user->id :lucky)
- :is-superuser? false
- :is-data-analyst? false
- :user-locale nil})
+ (is (= (merge req {:metabase-user-id (mt/user->id :lucky)
+ :is-superuser? false
+ :is-data-analyst? false
+ :user-locale nil
+ :embedding/auth-method "api-key"})
(#'mw.session/merge-current-user-info req)))))
(testing "Include :is-group-manager? if we have EE + :advanced-permissions "
(when config/ee-available?
(mt/with-premium-features #{:advanced-permissions}
- (is (= (merge req {:metabase-user-id (mt/user->id :lucky)
- :is-superuser? false
- :is-data-analyst? false
- :is-group-manager? false
- :user-locale nil})
+ (is (= (merge req {:metabase-user-id (mt/user->id :lucky)
+ :is-superuser? false
+ :is-data-analyst? false
+ :is-group-manager? false
+ :user-locale nil
+ :embedding/auth-method "api-key"})
(#'mw.session/merge-current-user-info req))))))))))
(deftest ^:parallel current-user-info-for-api-key-test-1b
@@ -238,7 +240,8 @@
:is-superuser? false,
:is-group-manager? false,
:user-locale nil
- :is-data-analyst? false}
+ :is-data-analyst? false
+ :auth-provider nil}
(#'mw.session/current-user-info-for-session test-session-key nil)))
(finally
(t2/delete! :model/Session :id test-session-id)))))
@@ -253,7 +256,8 @@
:is-superuser? true,
:is-group-manager? false,
:user-locale nil
- :is-data-analyst? false}
+ :is-data-analyst? false
+ :auth-provider nil}
(#'mw.session/current-user-info-for-session test-session-key nil)))
(finally
(t2/delete! :model/Session :id test-session-id)))))
@@ -305,7 +309,8 @@
:is-superuser? false,
:is-group-manager? false,
:user-locale nil
- :is-data-analyst? false}
+ :is-data-analyst? false
+ :auth-provider nil}
(#'mw.session/current-user-info-for-session test-session-key test-anti-csrf-token)))
(finally
(t2/delete! :model/Session :id test-session-id)))
@@ -354,6 +359,36 @@
(finally
(t2/delete! :model/Session :id test-session-id)))))
+(deftest auth-provider-via-left-join-test
+ (testing "session LEFT JOIN on auth_identity returns correct provider for each auth method"
+ (mt/with-temp [:model/User {user-id :id} {}]
+ ;; "password" is excluded - its before-insert hook requires credentials, and it's already
+ ;; tested via auth-method-test in view_log_test.clj. "api-key" is tested above in
+ ;; current-user-info-for-api-key-test (different code path, no auth_identity).
+ (doseq [provider ["jwt" "saml" "google" "ldap" "oidc"
+ "custom-oidc" "slack-connect" "support-access-grant"]]
+ (testing (str "provider: " provider)
+ (let [ai (first (t2/insert-returning-instances! (t2/table-name :model/AuthIdentity)
+ {:user_id user-id
+ :provider provider
+ :provider_id (str user-id "-" provider)
+ :created_at :%now
+ :updated_at :%now}))
+ session-key (session/generate-session-key)
+ session-id (session/generate-session-id)]
+ (try
+ (t2/insert! (t2/table-name :model/Session)
+ {:id session-id
+ :key_hashed (session/hash-session-key session-key)
+ :user_id user-id
+ :auth_identity_id (:id ai)
+ :created_at :%now})
+ (is (= provider
+ (:auth-provider (#'mw.session/current-user-info-for-session session-key nil))))
+ (finally
+ (t2/delete! :model/Session :id session-id)
+ (t2/delete! :model/AuthIdentity :id (:id ai))))))))))
+
;; create a simple example of our middleware wrapped around a handler that simply returns our bound variables for users
(defn- user-bound-handler [request]
((mw.session/bind-current-user
@@ -487,3 +522,25 @@
{:id session-id :key_hashed key-hashed :user_id user-id :created_at :%now
:last_active_at (h2x/add-interval-honeysql-form (mdb/db-type) :%now -600 :second)})
(is (some? (#'mw.session/current-user-info-for-session session-key nil))))))))
+
+(deftest auth-method-test
+ (testing "auth-method prefers route-based override on special routes"
+ (let [f #'mw.session/auth-method]
+ (are [session-info api-key-info embedding-route expected]
+ (= expected (f session-info api-key-info embedding-route))
+ ;; session-based auth on non-special routes
+ {:auth-provider "password"} nil nil "password"
+ {:auth-provider "saml"} nil nil "saml"
+ {:auth-provider "jwt"} nil nil "jwt"
+ {:auth-provider "ldap"} nil nil "ldap"
+ {} nil nil "session"
+ ;; api-key on non-special route
+ nil {} nil "api-key"
+ ;; route override: special routes win over credentials
+ nil {} "guest-embed" "guest" ; api-key + embed -> guest
+ nil nil "guest-embed" "guest" ; anon guest embed
+ nil nil "public" "public"
+ nil nil "metabot" "metabot"
+ nil nil "agent-api" "agent-api"
+ ;; fully anonymous, non-special route
+ nil nil nil nil))))
diff --git a/test/metabase/test/data/users.clj b/test/metabase/test/data/users.clj
index e6d9d89266c..e2a18702f28 100644
--- a/test/metabase/test/data/users.clj
+++ b/test/metabase/test/data/users.clj
@@ -152,10 +152,15 @@
;;; consistently fails for me when using [[metabase.test.http-client/authenticate]] instead of the code below. See #48489 for
;;; more info
(mu/defn ^:private authenticate! :- ms/UUIDString
- "Create a new `:model/Session` for one of the test users."
+ "Create a new `:model/Session` for one of the test users, linked to their password `:model/AuthIdentity`."
[username :- TestUserName]
- (let [session-key (session/generate-session-key)]
- (t2/insert! :model/Session {:id (session/generate-session-id) :key_hashed (session/hash-session-key session-key), :user_id (user->id username)})
+ (let [session-key (session/generate-session-key)
+ user-id (user->id username)
+ auth-id (t2/select-one-pk :model/AuthIdentity :user_id user-id :provider "password")]
+ (t2/insert! :model/Session (cond-> {:id (session/generate-session-id)
+ :key_hashed (session/hash-session-key session-key)
+ :user_id user-id}
+ auth-id (assoc :auth_identity_id auth-id)))
session-key))
(mu/defn username->token :- ms/UUIDString
diff --git a/test/metabase/test/http_client.clj b/test/metabase/test/http_client.clj
index e8f3e9950db..86ffa662561 100644
--- a/test/metabase/test/http_client.clj
+++ b/test/metabase/test/http_client.clj
@@ -388,6 +388,7 @@
(authenticate credentials)
credentials))}
:query-string (build-query-string query-parameters)
+ :remote-addr "127.0.0.1"
:request-method method
:uri (str *url-prefix* url)}
request-options
diff --git a/test/metabase/view_log/events/view_log_test.clj b/test/metabase/view_log/events/view_log_test.clj
index e89dda10b85..57d3d7d09f4 100644
--- a/test/metabase/view_log/events/view_log_test.clj
+++ b/test/metabase/view_log/events/view_log_test.clj
@@ -2,15 +2,20 @@
(:require
[clojure.test :refer :all]
[java-time.api :as t]
+ [metabase.analytics.sdk :as sdk]
+ [metabase.config.core :as config]
[metabase.dashboards-rest.api-test :as api.dashboard-test]
[metabase.embedding-rest.api.embed-test :as embed-test]
[metabase.events.core :as events]
[metabase.permissions.models.data-permissions :as data-perms]
[metabase.permissions.models.permissions-group :as perms-group]
[metabase.public-sharing-rest.api-test :as public-test]
+ [metabase.query-processor.middleware.process-userland-query :as process-userland-query]
+ [metabase.query-processor.util :as qp.util]
[metabase.test :as mt]
[metabase.test.http-client :as client]
[metabase.util :as u]
+ [metabase.util.json :as json]
[metabase.view-log.events.view-log :as events.view-log]
[toucan2.core :as t2]))
@@ -36,7 +41,21 @@
:model_id (u/id card)
:has_access true
:context :question}
- (latest-view (u/id user) (u/id card))))))))
+ (latest-view (u/id user) (u/id card))))
+ (testing "tenant_id is nil for user without a tenant"
+ (is (= nil (:tenant_id (latest-view (u/id user) (u/id card))))))))))
+
+(deftest card-read-tenant-id-test
+ (when config/ee-available?
+ (mt/with-premium-features #{:audit-app :tenants}
+ (mt/with-temp [:model/Tenant tenant {:name "Test Tenant" :slug "test-tenant"}
+ :model/User user {:tenant_id (:id tenant)}
+ :model/Card card {:creator_id (u/id user)}]
+ (testing "tenant_id is populated from current user's tenant"
+ (mt/with-current-user (u/id user)
+ (events/publish-event! :event/card-read {:object-id (u/id card) :user-id (u/id user) :context :question})
+ (is (= (:id tenant)
+ (:tenant_id (latest-view (u/id user) (u/id card)))))))))))
(deftest card-read-oss-no-view-logging-test
(mt/with-premium-features #{}
@@ -44,7 +63,7 @@
:model/Card card {:creator_id (u/id user)}]
(testing "A basic card read event is not recorded in OSS"
(events/publish-event! :event/card-read {:object-id (u/id card) :user-id (u/the-id user) :context :question})
- (is (nil? (latest-view (u/id user) (u/id card)))
+ (is (= nil (latest-view (u/id user) (u/id card)))
"view log entries should not be made in OSS")))))
(deftest collection-read-ee-test
@@ -112,7 +131,7 @@
(mt/with-current-user (u/id user)
(data-perms/set-table-permission! (perms-group/all-users) (mt/id :users) :perms/create-queries :no)
(events/publish-event! :event/table-read {:object table :user-id (u/id user)})
- (is (false? (:has_access (latest-view (u/id user) (u/id table))))))))))))
+ (is (= false (:has_access (latest-view (u/id user) (u/id table))))))))))))
(deftest dashboard-read-ee-test
(mt/with-premium-features #{:audit-app}
@@ -131,7 +150,7 @@
:context nil}
(latest-view (u/id user) (u/id dashboard))))
(testing "Card read events are not recorded when viewing a dashboard"
- (is (nil? (latest-view (u/id user) (u/id card))))))))))
+ (is (= nil (latest-view (u/id user) (u/id card))))))))))
(deftest card-read-view-count-test
(mt/test-helpers-set-global-values!
@@ -254,7 +273,8 @@
(public-test/with-temp-public-card [card]
(testing "GET /api/public/card/:uuid/query"
(client/client :get 202 (str "public/card/" (:public_uuid card) "/query"))
- (is (partial= {:model "card", :model_id (:id card), :has_access true, :context :question}
+ (is (partial= {:model "card", :model_id (:id card), :has_access true, :context :question
+ :embedding_route "public"}
(latest-view nil (:id card))))))))))
(deftest public-dashboard-card-query-view-log-test
@@ -285,7 +305,8 @@
:dataset_query (mt/mbql-query venues {:limit 1})}]
(testing "GET /api/embed/card/:token/query"
(client/client :get 202 (str (embed-test/card-url card) "/query"))
- (is (partial= {:model "card", :model_id (:id card), :has_access true}
+ (is (partial= {:model "card", :model_id (:id card), :has_access true
+ :embedding_route "guest-embed"}
(latest-view nil (:id card))))))))))
(deftest embedded-dashboard-card-query-view-log-test
@@ -311,4 +332,284 @@
(is (partial= {:model "dashboard", :model_id (:id dash), :has_access true}
(latest-view nil (:id dash))))))))))
+(deftest client-and-route-stored-independently-test
+ (mt/with-premium-features #{:audit-app}
+ (testing "embedding_client comes from header, embedding_route from URI"
+ (mt/with-temporary-setting-values [enable-public-sharing true]
+ (public-test/with-temp-public-card [card]
+ (client/client :get 202 (str "public/card/" (:public_uuid card) "/query")
+ {:request-options {:headers {"x-metabase-client" "embedding-sdk-react"}}})
+ (let [view (latest-view nil (:id card))]
+ (is (= "embedding-sdk-react" (:embedding_client view)))
+ (is (= "public" (:embedding_route view)))))))))
+
+(defn- latest-qe
+ "Returns the most recent QueryExecution for a given card ID."
+ [card-id]
+ (t2/select-one :model/QueryExecution
+ :card_id card-id
+ {:order-by [[:id :desc]]}))
+
+(deftest query-execution-tenant-id-test
+ (when config/ee-available?
+ (testing "tenant_id on query_execution comes from *current-user*"
+ (mt/with-temp [:model/Tenant tenant {:name "QE Tenant" :slug "qe-tenant"}
+ :model/User user {:tenant_id (:id tenant)}]
+ (mt/with-current-user (u/id user)
+ (let [query (assoc (mt/mbql-query venues {:limit 1})
+ :info {:executed-by (u/id user)
+ :query-hash (qp.util/query-hash (mt/mbql-query venues {:limit 1}))
+ :context :question})
+ ei (#'process-userland-query/query-execution-info query)]
+ (is (= (:id tenant) (:tenant_id ei))))))))
+ (testing "tenant_id nil when user has no tenant"
+ (mt/with-temp [:model/User user {}]
+ (mt/with-current-user (u/id user)
+ (let [query (assoc (mt/mbql-query venues {:limit 1})
+ :info {:executed-by (u/id user)
+ :query-hash (qp.util/query-hash (mt/mbql-query venues {:limit 1}))
+ :context :question})
+ ei (#'process-userland-query/query-execution-info query)]
+ (is (= nil (:tenant_id ei))))))))
+
+(defn- make-test-query
+ "Builds a minimal query suitable for `query-execution-info`, with optional overrides merged in."
+ [& {:as overrides}]
+ (merge (mt/mbql-query venues {:limit 1})
+ {:info {:executed-by 1
+ :query-hash (qp.util/query-hash (mt/mbql-query venues {:limit 1}))
+ :context :question}}
+ overrides))
+
+;; `is_db_routed` is now populated from the `*destination-database-id*` dynamic var in
+;; `enrich-with-execution-context` (see process_userland_query.clj). End-to-end coverage lives in
+;; `metabase-enterprise.database-routing.query-execution-test`.
+
+(deftest query-execution-parameters-test
+ (testing "parameters is JSON-encoded when PII retention enabled"
+ (mt/with-temporary-setting-values [analytics-pii-retention-enabled true]
+ (let [params [{:type "text/single" :value "foo"}]
+ ei (#'process-userland-query/query-execution-info
+ (make-test-query :parameters params))]
+ (is (string? (:parameters ei)))
+ (is (= params (json/decode+kw (:parameters ei)))))))
+ (testing "parameters is nil when PII retention disabled"
+ (mt/with-temporary-setting-values [analytics-pii-retention-enabled false]
+ (let [params [{:type "text/single" :value "foo"}]
+ ei (#'process-userland-query/query-execution-info
+ (make-test-query :parameters params))]
+ (is (= nil (:parameters ei))))))
+ (testing "parameters is nil when absent"
+ (let [ei (#'process-userland-query/query-execution-info (make-test-query))]
+ (is (= nil (:parameters ei))))))
+
+;; `is_impersonated` is now populated from the `*impersonation-role*` dynamic var in
+;; `enrich-with-execution-context` (see process_userland_query.clj). End-to-end coverage lives in
+;; `metabase-enterprise.impersonation.query-execution-test`.
+
+(deftest public-card-pii-fields-test
+ (mt/with-premium-features #{:audit-app}
+ (mt/with-temporary-setting-values [enable-public-sharing true]
+ (binding [qp.util/*execute-async?* false]
+ (testing "PII fields populated when setting enabled"
+ (mt/with-temporary-setting-values [analytics-pii-retention-enabled true]
+ (public-test/with-temp-public-card [card]
+ (client/client :get 202 (str "public/card/" (:public_uuid card) "/query")
+ {:request-options {:headers {"x-metabase-embed-referrer" "https://app.example.com/dashboard/1"
+ "user-agent" "TestAgent/1.0"}}})
+ (testing "in view_log"
+ (let [view (latest-view nil (:id card))]
+ (is (= "app.example.com" (:embedding_hostname view)))
+ (is (= "/dashboard/1" (:embedding_path view)))
+ (is (= "TestAgent/1.0" (:user_agent view)))
+ (is (= "Unknown device type (unknown/unknown)" (:sanitized_user_agent view)))
+ (is (= "127.0.0.1" (:ip_address view)))))
+ (testing "in query_execution"
+ (let [qe (latest-qe (:id card))]
+ (is (= "public" (:embedding_route qe)))
+ (is (= "app.example.com" (:embedding_hostname qe)))
+ (is (= "/dashboard/1" (:embedding_path qe)))
+ (is (= "TestAgent/1.0" (:user_agent qe)))
+ (is (= "Unknown device type (unknown/unknown)" (:sanitized_user_agent qe)))
+ (is (= "127.0.0.1" (:ip_address qe))))))))
+ (testing "PII fields nil when setting disabled, but hostname still populated"
+ (mt/with-temporary-setting-values [analytics-pii-retention-enabled false]
+ (public-test/with-temp-public-card [card]
+ (client/client :get 202 (str "public/card/" (:public_uuid card) "/query")
+ {:request-options {:headers {"x-metabase-embed-referrer" "https://app.example.com/dashboard/1"
+ "user-agent" "TestAgent/1.0"}}})
+ (testing "in view_log"
+ (let [view (latest-view nil (:id card))]
+ (is (= "app.example.com" (:embedding_hostname view)))
+ (is (= nil (:embedding_path view)))
+ (is (= nil (:user_agent view)))
+ (is (= nil (:sanitized_user_agent view)))
+ (is (= nil (:ip_address view)))))
+ (testing "in query_execution"
+ (let [qe (latest-qe (:id card))]
+ (is (= "app.example.com" (:embedding_hostname qe)))
+ (is (= nil (:embedding_path qe)))
+ (is (= nil (:user_agent qe)))
+ (is (= nil (:sanitized_user_agent qe)))
+ (is (= nil (:ip_address qe))))))))))))
+
+(deftest public-dashboard-card-pii-fields-test
+ (mt/with-premium-features #{:audit-app}
+ (mt/with-temporary-setting-values [enable-public-sharing true]
+ (binding [qp.util/*execute-async?* false]
+ (testing "PII fields populated via dashboard card query when setting enabled"
+ (mt/with-temporary-setting-values [analytics-pii-retention-enabled true]
+ (public-test/with-temp-public-dashboard-and-card [dash card dashcard]
+ (client/client :get 202 (public-test/dashcard-url dash card dashcard)
+ {:request-options {:headers {"x-metabase-embed-referrer" "https://dash.example.com/analytics"
+ "user-agent" "DashAgent/2.0"}}})
+ (testing "in view_log"
+ (let [view (latest-view nil (:id card))]
+ (is (= "dash.example.com" (:embedding_hostname view)))
+ (is (= "/analytics" (:embedding_path view)))
+ (is (= "DashAgent/2.0" (:user_agent view)))
+ (is (= "Unknown device type (unknown/unknown)" (:sanitized_user_agent view)))
+ (is (= "127.0.0.1" (:ip_address view)))))
+ (testing "in query_execution"
+ (let [qe (latest-qe (:id card))]
+ (is (= "public" (:embedding_route qe)))
+ (is (= "dash.example.com" (:embedding_hostname qe)))
+ (is (= "/analytics" (:embedding_path qe)))
+ (is (= "DashAgent/2.0" (:user_agent qe)))
+ (is (= "Unknown device type (unknown/unknown)" (:sanitized_user_agent qe)))
+ (is (= "127.0.0.1" (:ip_address qe))))))))))))
+
+(deftest auth-method-test
+ (mt/with-premium-features #{:audit-app}
+ (binding [qp.util/*execute-async?* false]
+ (testing "session-authenticated request records auth_method from auth_identity provider"
+ (mt/with-temp [:model/Card card {:name "Auth Test Card" :type :question
+ :dataset_query (mt/mbql-query venues {:limit 1})}]
+ (mt/user-http-request :crowberto :post 202 (format "card/%s/query" (u/id card)))
+ (let [view (latest-view (mt/user->id :crowberto) (u/id card))
+ qe (latest-qe (:id card))]
+ (is (= "password" (:auth_method view)))
+ (is (= "password" (:auth_method qe))))))
+ (testing "unauthenticated public request records auth_method as 'public'"
+ (mt/with-temporary-setting-values [enable-public-sharing true]
+ (public-test/with-temp-public-card [card]
+ (client/client :get 202 (str "public/card/" (:public_uuid card) "/query"))
+ (let [view (latest-view nil (:id card))
+ qe (latest-qe (:id card))]
+ (is (= "public" (:auth_method view)))
+ (is (= "public" (:auth_method qe))))))))))
+
+(deftest route-surface-test
+ (testing "route-surface returns the correct surface for known prefixes"
+ (are [uri expected]
+ (= expected (sdk/embedding-route uri))
+ "/api/public/something" "public"
+ "/api/embed/something" "guest-embed"
+ "/api/preview_embed/something" "guest-embed"
+ "/api/metabot/something" "metabot"
+ "/api/agent/something" "agent-api"))
+ (testing "route-surface returns nil for non-matching URIs"
+ (is (= nil (sdk/embedding-route "/api/card/1")))
+ (is (= nil (sdk/embedding-route nil)))))
+
+(defn- ->bool
+ "Coerce a value to boolean. MySQL JDBC returns Integer 1/0 for TRUE/FALSE
+ in CASE expressions, and byte arrays for bit literals."
+ [v]
+ (cond
+ (instance? Boolean v) v
+ (number? v) (pos? (long v))
+ (bytes? v) (pos? (first v))
+ :else (boolean v)))
+
+(defn- latest-v-view-log
+ "Returns the most recent row from the v_view_log view for a given entity_id."
+ [entity-id]
+ (first (t2/query ["SELECT * FROM v_view_log WHERE entity_id = ? ORDER BY id DESC LIMIT 1" entity-id])))
+
+(defn- latest-v-query-log
+ "Returns the most recent row from the v_query_log view for a given card_id."
+ [card-id]
+ (first (t2/query ["SELECT * FROM v_query_log WHERE card_id = ? ORDER BY entity_id DESC LIMIT 1" card-id])))
+
+(deftest end-to-end-analytics-views-pii-true-test
+ (mt/with-premium-features #{:audit-app}
+ (mt/with-temporary-setting-values [enable-public-sharing true
+ analytics-pii-retention-enabled true]
+ (binding [qp.util/*execute-async?* false]
+ (testing "public card request with SDK header populates all analytics fields on both views"
+ (public-test/with-temp-public-card [card]
+ (client/client :get 202 (str "public/card/" (:public_uuid card) "/query")
+ {:request-options {:headers {"x-metabase-client" "embedding-sdk-react"
+ "x-metabase-client-version" "1.42.0"
+ "x-metabase-embed-referrer" "https://app.example.com/dashboard/1"
+ "user-agent" "TestAgent/1.0"}}})
+ (testing "v_view_log"
+ (let [row (latest-v-view-log (:id card))]
+ (is (= "card" (:entity_type row)))
+ (is (= "embedding-sdk-react" (:embedding_client row)))
+ (is (= "public" (:embedding_route row)))
+
+ (is (= false (->bool (:is_preview row))))
+ (is (= "1.42.0" (:embedding_sdk_version row)))
+ (is (= "public" (:auth_method row)))
+ (is (= "app.example.com" (:embedding_hostname row)))
+ (is (= "/dashboard/1" (:embedding_path row)))
+ (is (= "TestAgent/1.0" (:user_agent row)))
+ (is (some? (:sanitized_user_agent row)))
+ (is (= "127.0.0.1" (:ip_address row)))))
+ (testing "v_query_log"
+ (let [row (latest-v-query-log (:id card))]
+ (is (= "embedding-sdk-react" (:embedding_client row)))
+ (is (= "public" (:embedding_route row)))
+
+ (is (= false (->bool (:is_preview row))))
+ (is (= "1.42.0" (:embedding_sdk_version row)))
+ (is (= "public" (:auth_method row)))
+ (is (= "app.example.com" (:embedding_hostname row)))
+ (is (= "/dashboard/1" (:embedding_path row)))
+ (is (= "TestAgent/1.0" (:user_agent row)))
+ (is (some? (:sanitized_user_agent row)))
+ (is (= "127.0.0.1" (:ip_address row)))))))))))
+
+(deftest end-to-end-analytics-views-pii-false-test
+ (mt/with-premium-features #{:audit-app}
+ (mt/with-temporary-setting-values [enable-public-sharing true
+ analytics-pii-retention-enabled false]
+ (binding [qp.util/*execute-async?* false]
+ (testing "public card request with SDK header populates all analytics fields on both views"
+ (public-test/with-temp-public-card [card]
+ (client/client :get 202 (str "public/card/" (:public_uuid card) "/query")
+ {:request-options {:headers {"x-metabase-client" "embedding-sdk-react"
+ "x-metabase-client-version" "1.42.0"
+ "x-metabase-embed-referrer" "https://app.example.com/dashboard/1"
+ "user-agent" "TestAgent/1.0"}}})
+ (testing "v_view_log"
+ (let [row (latest-v-view-log (:id card))]
+ (is (= "card" (:entity_type row)))
+ (is (= "embedding-sdk-react" (:embedding_client row)))
+ (is (= "public" (:embedding_route row)))
+
+ (is (= false (->bool (:is_preview row))))
+ (is (= "1.42.0" (:embedding_sdk_version row)))
+ (is (= "public" (:auth_method row)))
+ (is (= "app.example.com" (:embedding_hostname row)))
+ (is (= nil (:embedding_path row)))
+ (is (= nil (:user_agent row)))
+ (is (= nil (:sanitized_user_agent row)))
+ (is (= nil (:ip_address row)))))
+ (testing "v_query_log"
+ (let [row (latest-v-query-log (:id card))]
+ (is (= "embedding-sdk-react" (:embedding_client row)))
+ (is (= "public" (:embedding_route row)))
+
+ (is (= false (->bool (:is_preview row))))
+ (is (= "1.42.0" (:embedding_sdk_version row)))
+ (is (= "public" (:auth_method row)))
+ (is (= "app.example.com" (:embedding_hostname row)))
+ (is (= nil (:embedding_path row)))
+ (is (= nil (:user_agent row)))
+ (is (= nil (:sanitized_user_agent row)))
+ (is (= nil (:ip_address row)))))))))))
+
;;; ---------------------------------------- API tests end -----------------------------------------
diff --git a/test_resources/serialization_baseline/settings.yaml b/test_resources/serialization_baseline/settings.yaml
index dda68c5ccc1..f91c6f46175 100644
--- a/test_resources/serialization_baseline/settings.yaml
+++ b/test_resources/serialization_baseline/settings.yaml
@@ -2,6 +2,7 @@ agent-api-enabled?: null
aggregated-query-row-limit: null
ai-features-enabled?: null
allowed-iframe-hosts: null
+analytics-pii-retention-enabled: null
application-colors: null
application-favicon-url: null
application-font: null