gabotorresruiz commented on code in PR #44821:
URL: https://github.com/apache/superset/pull/44821#discussion_r4190564500


##########
superset-frontend/src/dashboard/components/nativeFilters/FilterBar/utils.ts:
##########
@@ -190,6 +190,39 @@ export const getFiltersToApply = (
     })
     .map(([filterId]) => filterId);
 
+export type AppliedFilterLogEntry = {
+  id: string;
+  name?: string;
+  hasValue: boolean;
+};
+
+/**
+ * Build the `change_dashboard_filter` payload for filters about to be applied.
+ *
+ * Records the filter id, display name, and whether a value is selected. The
+ * selected value itself is omitted because filter values can contain personal
+ * data and this event is written to the logs table.
+ */
+export const getAppliedFilterLogPayload = (
+  filterIds: string[],
+  filtersById: Record<string, { name?: string } | undefined>,
+  dataMaskSelected: DataMaskStateWithId,
+): AppliedFilterLogEntry[] =>
+  filterIds.flatMap(filterId => {
+    const filter = filtersById[filterId];
+    if (!filter) {
+      return [];
+    }
+    const value = dataMaskSelected[filterId]?.filterState?.value;
+    return [
+      {
+        id: filterId,
+        name: filter.name,
+        hasValue: value !== undefined && value !== null,

Review Comment:
   Not a blocker, more a question about scope. The linked issue asks for "at 
minimum the filter name and the selected value(s)", and omitting the value is a 
deliberate choice here. I think that is a defensible default, but two things 
make me want to check it is the intended trade off: the same `logs` table 
already stores the raw `filters` (values included) on every 
`ChartDataRestApi.data` row, since `collect_request_payload` merges the JSON 
body and `DBEventLogger.log` dumps the whole record, so leaving them out here 
is consistent hygiene rather than a privacy boundary; and `hasValue` alone 
still does not let a downstream consumer tell what was filtered, which was the 
reporter's actual need. Would it make sense to either keep `Fixes` and get the 
reporter's agreement that `hasValue` closes it, or switch to `Related to` so 
the value question stays open? Happy with either, I just do not want the issue 
auto closed with the main ask unanswered.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to