@@ -93,6 +93,7 @@ class MixpanelDataClient implements AnalyticsReportingClient {
9393 event: metricName,
9494 fromDate: DateFormat ('yyyy-MM-dd' ).format (startDate),
9595 toDate: DateFormat ('yyyy-MM-dd' ).format (endDate),
96+ unit: MixpanelTimeUnit .day,
9697 );
9798
9899 final response = await _httpClient.get <Map <String , dynamic >>(
@@ -142,17 +143,19 @@ class MixpanelDataClient implements AnalyticsReportingClient {
142143
143144 _log.info ('Fetching total for metric "$metricName " from Mixpanel.' );
144145
145- // To get a single total, we call the segmentation endpoint *without* the 'unit' parameter.
146- final queryParameters = {
147- 'project_id' : _projectId,
148- 'event' : metricName,
149- 'from_date' : DateFormat ('yyyy-MM-dd' ).format (startDate),
150- 'to_date' : DateFormat ('yyyy-MM-dd' ).format (endDate),
151- };
146+ // To get a single total, we call the segmentation endpoint without the 'unit'
147+ // parameter. The MixpanelSegmentationRequest model supports this by having
148+ // a nullable 'unit'.
149+ final request = MixpanelSegmentationRequest (
150+ projectId: _projectId,
151+ event: metricName,
152+ fromDate: DateFormat ('yyyy-MM-dd' ).format (startDate),
153+ toDate: DateFormat ('yyyy-MM-dd' ).format (endDate),
154+ );
152155
153156 final response = await _httpClient.get <Map <String , dynamic >>(
154157 '/segmentation' ,
155- queryParameters: queryParameters ,
158+ queryParameters: request. toJson () ,
156159 );
157160
158161 final segmentationData =
0 commit comments