listSessionMetrics method
- required String botId,
- required DateTime endDateTime,
- required List<
AnalyticsSessionMetric> metrics, - required DateTime startDateTime,
- List<
AnalyticsBinBySpecification> ? binBy, - List<
AnalyticsSessionFilter> ? filters, - List<
AnalyticsSessionGroupBySpecification> ? groupBy, - int? maxResults,
- String? nextToken,
Retrieves summary metrics for the user sessions with your bot. The following fields are required:
-
metrics– A list of AnalyticsSessionMetric objects. In each object, use thenamefield to specify the metric to calculate, thestatisticfield to specify whether to calculate theSum,Average, orMaxnumber, and theorderfield to specify whether to sort the results inAscendingorDescendingorder. -
startDateTimeandendDateTime– Define a time range for which you want to retrieve results.
-
Use the
filtersfield to filter the results, thegroupByfield to specify categories by which to group the results, and thebinByfield to specify time intervals by which to group the results. -
Use the
maxResultsfield to limit the number of results to return in a single response and thenextTokenfield to return the next batch of results if the response does not return the full set of results.
order field exists in both binBy
and metrics. Currently, you can specify it in either field,
but not in both.
May throw InternalServerException.
May throw PreconditionFailedException.
May throw ServiceQuotaExceededException.
May throw ThrottlingException.
May throw ValidationException.
Parameter botId :
The identifier for the bot for which you want to retrieve session metrics.
Parameter endDateTime :
The date and time that marks the end of the range of time for which you
want to see session metrics.
Parameter metrics :
A list of objects, each of which contains a metric you want to list, the
statistic for the metric you want to return, and the method by which to
organize the results.
Parameter startDateTime :
The date and time that marks the beginning of the range of time for which
you want to see session metrics.
Parameter binBy :
A list of objects, each of which contains specifications for organizing
the results by time.
Parameter filters :
A list of objects, each of which describes a condition by which you want
to filter the results.
Parameter groupBy :
A list of objects, each of which specifies how to group the results. You
can group by the following criteria:
-
ConversationEndState– The final state of the conversation. The possible end states are detailed in Key definitions in the user guide. -
LocaleId– The unique identifier of the bot locale.
Parameter maxResults :
The maximum number of results to return in each page of results. If there
are fewer results than the maximum page size, only the actual number of
results are returned.
Parameter nextToken :
If the response from the ListSessionMetrics operation contains more
results than specified in the maxResults parameter, a token is returned in
the response.
Use the returned token in the nextToken parameter of a ListSessionMetrics request to return the next page of results. For a complete set of results, call the ListSessionMetrics operation until the nextToken returned in the response is null.
Implementation
Future<ListSessionMetricsResponse> listSessionMetrics({
required String botId,
required DateTime endDateTime,
required List<AnalyticsSessionMetric> metrics,
required DateTime startDateTime,
List<AnalyticsBinBySpecification>? binBy,
List<AnalyticsSessionFilter>? filters,
List<AnalyticsSessionGroupBySpecification>? groupBy,
int? maxResults,
String? nextToken,
}) async {
_s.validateNumRange(
'maxResults',
maxResults,
1,
1000,
);
final $payload = <String, dynamic>{
'endDateTime': unixTimestampToJson(endDateTime),
'metrics': metrics,
'startDateTime': unixTimestampToJson(startDateTime),
if (binBy != null) 'binBy': binBy,
if (filters != null) 'filters': filters,
if (groupBy != null) 'groupBy': groupBy,
if (maxResults != null) 'maxResults': maxResults,
if (nextToken != null) 'nextToken': nextToken,
};
final response = await _protocol.send(
payload: $payload,
method: 'POST',
requestUri:
'/bots/${Uri.encodeComponent(botId)}/analytics/sessionmetrics',
exceptionFnMap: _exceptionFns,
);
return ListSessionMetricsResponse.fromJson(response);
}