aggregate_sessions
Analyze user session data by calculating metrics like duration, error rates, and page views, grouped by time periods, devices, or locations to identify behavioral patterns.
Instructions
Aggregate session data with various metrics and groupings
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| startDate | No | Start date in ISO format | |
| endDate | No | End date in ISO format | |
| metrics | Yes | Metrics to calculate | |
| groupBy | No | Fields to group by | |
| filters | No | Same filter format as search_sessions |
Implementation Reference
- src/index.ts:406-417 (handler)The handler function that implements the logic for the 'aggregate_sessions' tool. Currently, it returns a message indicating that aggregation is not supported via API key authentication.private async aggregateSessions(args: any) { // Aggregation requires access to the full sessions/search endpoint // which is not available via API key authentication return { content: [ { type: "text", text: "Session aggregation is not available via API key authentication. You can retrieve individual user sessions instead.", }, ], }; }
- src/index.ts:142-165 (schema)The input schema definition for the 'aggregate_sessions' tool, specifying parameters like startDate, endDate, metrics, groupBy, and filters.inputSchema: { type: "object", properties: { startDate: { type: "string", description: "Start date in ISO format" }, endDate: { type: "string", description: "End date in ISO format" }, metrics: { type: "array", description: "Metrics to calculate", items: { type: "string", enum: ["count", "avg_duration", "error_rate", "bounce_rate", "unique_users", "page_views"] } }, groupBy: { type: "array", description: "Fields to group by", items: { type: "string", enum: ["hour", "day", "week", "browser", "device", "country", "page", "error_type"] } }, filters: { type: "array", description: "Same filter format as search_sessions" } }, required: ["metrics"]
- src/index.ts:139-167 (registration)The tool registration in the listTools response, including name, description, and input schema for 'aggregate_sessions'.{ name: "aggregate_sessions", description: "Aggregate session data with various metrics and groupings", inputSchema: { type: "object", properties: { startDate: { type: "string", description: "Start date in ISO format" }, endDate: { type: "string", description: "End date in ISO format" }, metrics: { type: "array", description: "Metrics to calculate", items: { type: "string", enum: ["count", "avg_duration", "error_rate", "bounce_rate", "unique_users", "page_views"] } }, groupBy: { type: "array", description: "Fields to group by", items: { type: "string", enum: ["hour", "day", "week", "browser", "device", "country", "page", "error_type"] } }, filters: { type: "array", description: "Same filter format as search_sessions" } }, required: ["metrics"] } },
- src/index.ts:284-285 (handler)The dispatch case in the CallToolRequest handler that routes to the aggregateSessions method.case "aggregate_sessions": return await this.aggregateSessions(args);