The easy-to-use open source Business Intelligence and Embedded Analytics tool that lets everyone work with data :bar_chart:
TypeScript analyticsbibusiness-intelligencebusinessintelligenceclojuredashboarddatadata-analysisdata-visualizationdatabasemetabasemysqlpostgrespostgresqlreportingslacksql-editorvisualization
Fix test flake related to search analytics (#75576)
Chris Truter4246d2979a11
diff --git a/e2e/test/scenarios/search/search-snowplow.cy.spec.js b/e2e/test/scenarios/search/search-snowplow.cy.spec.jsindex 2300c05deda..61f82f6c158 100644--- a/e2e/test/scenarios/search/search-snowplow.cy.spec.js+++ b/e2e/test/scenarios/search/search-snowplow.cy.spec.js@@ -68,13 +68,22 @@ describe("scenarios > search > snowplow", () => {cy.visit("/");H.commandPaletteSearch("Orders", false);- //Passing a function to ensure that runtime_milliseconds is populated as a number+ // Match the full event shape (notably a non-null search_term_hash) so this pins the user's "Orders"+ // search specifically, and stays a count-of-1 even as more search surfaces start emitting events.+ // Passing a function also asserts runtime_milliseconds is a number.H.expectUnstructuredSnowplowEvent((event) =>isMatching({event: NEW_SEARCH_QUERY_EVENT_NAME,context: "command-palette",runtime_milliseconds: P.number,+ search_engine: P.string,+ request_id: P.string,+ offset: null,+ search_term_hash: P.string,+ // The raw term is redacted to null on every instance except Metabase's own stats instance+ // (shouldReportSearchTerm); the salted search_term_hash above is what identifies the query.+ search_term: null,},event,),diff --git a/frontend/src/metabase-types/api/search.ts b/frontend/src/metabase-types/api/search.tsindex 812f5871e7e..820a248cc13 100644--- a/frontend/src/metabase-types/api/search.ts+++ b/frontend/src/metabase-types/api/search.ts@@ -131,6 +131,7 @@ export type SearchContext =| "entity-picker"| "data-picker"| "type-filter"+ | "basic-actions"| "browse"| "embedding-setup"| "document"diff --git a/frontend/src/metabase/api/search.ts b/frontend/src/metabase/api/search.tsindex 0c391ee7a0f..d231b5827e8 100644--- a/frontend/src/metabase/api/search.ts+++ b/frontend/src/metabase/api/search.ts@@ -17,7 +17,9 @@ export const searchApi = Api.injectEndpoints({providesTags: (response, error, { models }) =>provideSearchItemListTags(response?.data ?? [], models),onQueryStarted: (args, { queryFulfilled, requestId }) => {- if (isTrackedSearchContext(args.context)) {+ // Only track searches with an actual text query. Query-less requests are filter/available-model+ // lookups and internal existence probes, not searches the user performed.+ if (isTrackedSearchContext(args.context) && args.q?.trim()) {const start = Date.now();return handleQueryFulfilled(queryFulfilled, (data) => {const duration = Date.now() - start;diff --git a/frontend/src/metabase/palette/hooks/useCommandPaletteBasicActions.tsx b/frontend/src/metabase/palette/hooks/useCommandPaletteBasicActions.tsxindex 472b7d464c0..0620a050f55 100644--- a/frontend/src/metabase/palette/hooks/useCommandPaletteBasicActions.tsx+++ b/frontend/src/metabase/palette/hooks/useCommandPaletteBasicActions.tsx@@ -66,7 +66,7 @@ export const useCommandPaletteBasicActions = ({});const { data: searchResults } = useSearchQuery(isLoggedIn- ? { models: ["dataset"], limit: 1, context: "command-palette" }+ ? { models: ["dataset"], limit: 1, context: "basic-actions" }: skipToken,);const hasModels = (searchResults?.data?.length ?? 0) > 0;diff --git a/src/metabase/search/config.clj b/src/metabase/search/config.cljindex 59aa0dc14fa..8d84a86611e 100644--- a/src/metabase/search/config.clj+++ b/src/metabase/search/config.clj@@ -310,6 +310,7 @@:entity-picker ; the entity-picker modal (cards, dashboards, collections, …):data-picker ; picking a data source (table/model/metric) while building a query:type-filter ; the search type-filter dropdown's available-models lookup+ :basic-actions ; the command palette's basic-actions "do any models exist?" gate (New action), not a user search:browse ; the Browse models / Browse metrics pages:embedding-setup ; embedding/SDK setup and preview resource selection:document ; entity references embedded in documents@@ -335,8 +336,7 @@(def context->normalized-context"Collapses search `context` values that should rank and filter alike onto a shared normalized context.Only genuine remappings appear here; an unlisted context normalizes to itself and inherits `:default`.- The full-page search app, command palette, and type-filter lookup share `:global`, as opposed to the- scoped `:data-picker` / `:entity-picker` contexts."+ Add an entry to make a surface share another's ranking/filter profile; omit it to keep the surface's own.";; TODO (Chris 2026-06-08) -- the nav search bar is deliberately left off `:global` for now so it keeps;; the default filters/weights; decide whether any of its behaviour should be DRYed up with the other;; broad-search surfaces.