Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Required filters: track when a filter is made required #39159

Merged
merged 1 commit into from
Feb 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 11 additions & 1 deletion frontend/src/metabase/dashboard/actions/parameters.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,10 @@ import type {
} from "metabase-types/api";
import type { Dispatch, GetState } from "metabase-types/store";

import { trackAutoApplyFiltersDisabled } from "../analytics";
import {
trackAutoApplyFiltersDisabled,
trackFilterRequired,
} from "../analytics";
import {
getAutoApplyFiltersToastId,
getDashboard,
Expand Down Expand Up @@ -298,6 +301,13 @@ export const setParameterRequired = createThunkAction(
required,
}));
}

if (required) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

shouldn't we track only when parameter becomes required from a not-required state?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mean the case when required is true and paramater.required is also true?
We don't emit this action like that but I could add an additional check if you think it makes sense.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I actually mean (if I understand the logic correctly) that we need to track when parameter wasn't required and then became required

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I understood. In case we were emitting this action without checks (now because it's a "switch" you can't emit it when a parameter is already required), it would make sense. But broadly speaking, I don't think this is necessary.

This event is used to track feature adoption, which Conor agreed doesn't have to be very precise. That's why we didn't track it at saving for instance and instead track just toggling it on.

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 @@ -32,7 +32,7 @@
{::account "1-0-1"
::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