getWebsiteSessionsStats method
Gets summarized session statistics for the website.
token JWT authentication token.
websiteId Website ID.
startAt Start timestamp (ms).
endAt End timestamp (ms).
filters Additional filters (optional).
Returns a Map with the stats or null on error.
Implementation
Future<Map<String, dynamic>?> getWebsiteSessionsStats({
required String token,
required String websiteId,
required int startAt,
required int endAt,
Map<String, String>? filters,
}) async {
final params = <String, String>{
'startAt': startAt.toString(),
'endAt': endAt.toString(),
if (filters != null) ...filters,
};
final uri = Uri.parse('$endpoint/api/websites/$websiteId/sessions/stats').replace(queryParameters: params);
final response = await http.get(
uri,
headers: {
'Content-Type': 'application/json',
'Authorization': 'Bearer $token',
},
);
if (response.statusCode == 200) {
return jsonDecode(response.body);
}
debugPrint('Failed to fetch session stats: ${response.statusCode} ${response.body}');
return null;
}