Skip to content

Commit 12c9a99

Browse files
committed
fix(analytics): sum multiple engagement types in Mixpanel data
- Update `getValue` method to handle cases where there are multiple values in the segmentation data - Instead of returning just the first value, it now sums all values in the list - This change ensures more accurate reporting when multiple engagement types are present
1 parent 46e4ff1 commit 12c9a99

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/src/services/analytics/mixpanel_data_client.dart

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,11 @@ class MixpanelDataClient implements AnalyticsReportingClient {
167167
segmentationData.values.values.first.isEmpty) {
168168
return 0;
169169
}
170-
return segmentationData.values.values.first.first;
170+
// Sum all values in the first (and typically only) list of values.
171+
return segmentationData.values.values.first.fold<num>(
172+
0,
173+
(previousValue, element) => previousValue + (element as num),
174+
);
171175
}
172176

173177
@override

0 commit comments

Comments
 (0)