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


##########
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:
   Fair point, pulled the predicate into a shared `hasFilterValue` helper used 
by both `getFiltersToApply` and the log payload (fe04187).



-- 
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