Skip to content

Commit

Permalink
🤖 backported "Required filters: track when a filter is made required" (…
Browse files Browse the repository at this point in the history
…#39195)

* Add dashboard_filter_required (#39159)

* Fix

---------

Co-authored-by: Oleg Gromov <mail@oleggromov.com>
  • Loading branch information
metabase-bot[bot] and oleggromov committed Feb 27, 2024
1 parent db89d6a commit 40bf237
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 6 deletions.
18 changes: 14 additions & 4 deletions frontend/src/metabase/dashboard/actions/parameters.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,10 @@ import {
PULSE_PARAM_EMPTY,
} from "metabase-lib/parameters/utils/parameter-values";

import { trackAutoApplyFiltersDisabled } from "../analytics";
import {
trackAutoApplyFiltersDisabled,
trackFilterRequired,
} from "../analytics";
import {
getDashboard,
getDraftParameterValues,
Expand Down Expand Up @@ -245,17 +248,24 @@ export const SET_PARAMETER_REQUIRED =
"metabase/dashboard/SET_PARAMETER_REQUIRED";
export const setParameterRequired = createThunkAction(
SET_PARAMETER_REQUIRED,
(parameterId, value) => (dispatch, getState) => {
(parameterId, required) => (dispatch, getState) => {
const parameter = getParameters(getState()).find(
({ id }) => id === parameterId,
);

if (parameter.required !== value) {
if (parameter.required !== required) {
updateParameter(dispatch, getState, parameterId, parameter => ({
...parameter,
required: value,
required,
}));
}

if (required) {
const dashboardId = getDashboardId(getState());
if (dashboardId) {
trackFilterRequired(dashboardId);
}
}
},
);

Expand Down
9 changes: 8 additions & 1 deletion frontend/src/metabase/dashboard/analytics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { DashboardId, DashboardWidth } from "metabase-types/api";

import type { SectionId } from "./sections";

const DASHBOARD_SCHEMA_VERSION = "1-1-3";
const DASHBOARD_SCHEMA_VERSION = "1-1-4";

export const trackAutoApplyFiltersDisabled = (dashboardId: DashboardId) => {
trackSchemaEvent("dashboard", DASHBOARD_SCHEMA_VERSION, {
Expand Down Expand Up @@ -97,3 +97,10 @@ export const trackTabDuplicated = (dashboardId: DashboardId) => {
dashboard_id: dashboardId,
});
};

export const trackFilterRequired = (dashboardId: DashboardId) => {
trackSchemaEvent("dashboard", DASHBOARD_SCHEMA_VERSION, {
event: "dashboard_filter_required",
dashboard_id: dashboardId,
});
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
{
"$schema": "http://iglucentral.com/schemas/com.snowplowanalytics.self-desc/schema/jsonschema/1-0-0#",
"description": "Dashboard events",
"self": {
"vendor": "com.metabase",
"name": "dashboard",
"format": "jsonschema",
"version": "1-1-4"
},
"type": "object",
"properties": {
"event": {
"description": "Event name",
"type": "string",
"enum": [
"dashboard_created",
"dashboard_saved",
"question_added_to_dashboard",
"auto_apply_filters_disabled",
"dashboard_tab_created",
"dashboard_tab_deleted",
"dashboard_tab_duplicated",
"new_text_card_created",
"new_heading_card_created",
"new_link_card_created",
"new_action_card_created",
"card_set_to_hide_when_no_results",
"dashboard_pdf_exported",
"card_moved_to_tab",
"dashboard_card_duplicated",
"dashboard_card_replaced",
"dashboard_section_added",
"dashboard_width_toggled",
"dashboard_filter_required"
],
"maxLength": 1024
},
"dashboard_id": {
"description": "Unique identifier for a dashboard within the Metabase instance",
"type": "integer",
"minimum": 0,
"maximum": 2147483647
},
"question_id": {
"description": "Unique identifier for a question added to a dashboard",
"type": [
"integer",
"null"
],
"minimum": 0,
"maximum": 2147483647
},
"num_tabs": {
"description": "Number of tabs affected after the event",
"type": [
"integer",
"null"
],
"minimum": 0,
"maximum": 2147483647
},
"total_num_tabs": {
"description": "Total number of active tabs after the events",
"type": [
"integer",
"null"
],
"minimum": 0,
"maximum": 2147483647
},
"duration_milliseconds": {
"description": "Duration the action took to complete in milliseconds",
"type": [
"integer",
"null"
],
"minimum": 0,
"maximum": 2147483647
},
"section_layout": {
"description": "String describing the layout that was selected from the pre-built options",
"type": [
"string",
"null"
],
"maxLength": 1024
},
"full_width": {
"description": "Boolean set to True if the dashboard was toggled to full width and False if full width was disabled.",
"type": [
"boolean",
"null"
]
}
},
"required": [
"event",
"dashboard_id"
],
"additionalProperties": true
}
2 changes: 1 addition & 1 deletion src/metabase/analytics/snowplow.clj
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
::browse_data "1-0-0"
::invite "1-0-1"
::csvupload "1-0-0"
::dashboard "1-1-3"
::dashboard "1-1-4"
::database "1-0-1"
::instance "1-1-2"
::metabot "1-0-1"
Expand Down

0 comments on commit 40bf237

Please sign in to comment.