Funnels do not work with date range filters
The following discussion from gitlab-org/analytics-section/product-analytics/devkit!113 (closed) should be addressed:
-
@jiaan started a discussion: (+1 comment) Question: Should funnels be compatible with date range
filters
?🤔 Currently that doesn't seem to be the case. Testing this locally I get a"Invalid query format: \"filters[0]\" does not match any of the allowed types"
response when querying via a dashboard visualization.
The issue here is that we currently map the date range filters to specific table/field combos to make sure that the right field is used depending upon the schema. Since dynamic schemas can't be mapped individually, we don't get the date range field and the resulting query is malformed.
Proposed solution
Update the date range logic on the frontend to fallback to the date
field for dynamic schemas:
Index: ee/app/assets/javascripts/analytics/analytics_dashboards/data_sources/cube_analytics.js
===================================================================
diff --git a/ee/app/assets/javascripts/analytics/analytics_dashboards/data_sources/cube_analytics.js b/ee/app/assets/javascripts/analytics/analytics_dashboards/data_sources/cube_analytics.js
--- a/ee/app/assets/javascripts/analytics/analytics_dashboards/data_sources/cube_analytics.js (revision Staged)
+++ b/ee/app/assets/javascripts/analytics/analytics_dashboards/data_sources/cube_analytics.js (date 1715699178039)
@@ -92,13 +92,14 @@
if (!startDate && !endDate) return {};
const tableKey = getQueryTableKey(query);
+ const member = DATE_RANGE_FILTER_DIMENSIONS[tableKey] ?? `${tableKey}.date`;
return {
filters: [
...(query.filters ?? []),
...(queryOverrides.filters ?? []),
{
- member: DATE_RANGE_FILTER_DIMENSIONS[tableKey],
+ member,
operator: 'inDateRange',
values: [pikadayToString(startDate), pikadayToString(endDate)],
},
Implementation plan
frontend -
- Update
ee/app/assets/javascripts/analytics/analytics_dashboards/data_sources/cube_analytics.js
to add a default date range field to support dynamic schemas. - Update
ee/spec/frontend/analytics/analytics_dashboards/components/data_sources/cube_analytics_spec.js
to test the default is applied correctly. - Test and verify that the all Cube-based visualizations are picking the correct date range for their type.
- Create a visualization through the visualization designer and verify it works as before.