User Event Breakdown
rybbit_get_user_event_breakdownAnalyze individual user behavior by retrieving event count breakdowns for specific users, showing how many times each event was triggered during a defined period.
Instructions
Get event count breakdown for a specific user. Shows how many times each event_name was triggered by this user. Accepts either the Rybbit user_id (device hash) or the identified_user_id (app-provided user ID). Useful for analyzing per-user behavior like ad_click, chat_message_sent, etc.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| siteId | Yes | Site ID (numeric ID or domain identifier) | |
| startDate | No | Start date in ISO format (YYYY-MM-DD) | |
| endDate | No | End date in ISO format (YYYY-MM-DD) | |
| timeZone | No | IANA timezone (e.g., Europe/Prague). Default: UTC | |
| filters | No | Array of filters. Example: [{parameter:'browser',type:'equals',value:['Chrome']},{parameter:'country',type:'equals',value:['US','DE']}] | |
| pastMinutesStart | No | Alternative to dates: minutes ago start (e.g., 60 = last hour) | |
| pastMinutesEnd | No | Alternative to dates: minutes ago end (default 0 = now) | |
| userId | Yes | User ID — either Rybbit device hash (user_id) or app-provided ID (identified_user_id). Both are checked. |
Implementation Reference
- src/tools/users.ts:294-335 (handler)The tool `rybbit_get_user_event_breakdown` is registered and implemented directly in this block. It handles user filtering and fetches event breakdown data from the analytics API.
server.registerTool( "rybbit_get_user_event_breakdown", { title: "User Event Breakdown", annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true, destructiveHint: false }, description: "Get event count breakdown for a specific user. Shows how many times each event_name was triggered by this user. " + "Accepts either the Rybbit user_id (device hash) or the identified_user_id (app-provided user ID). " + "Useful for analyzing per-user behavior like ad_click, chat_message_sent, etc.", inputSchema: { ...analyticsInputSchema, userId: z.string().describe("User ID — either Rybbit device hash (user_id) or app-provided ID (identified_user_id). Both are checked."), }, }, async (args) => { try { // Build filters with user_id (backend checks both user_id and identified_user_id) const userFilter: FilterParam = { parameter: "user_id", type: "equals", value: [args.userId], }; const filters = [...(args.filters ?? []), userFilter]; const safeArgs = { ...args, filters }; // Fetch event names endpoint — it already returns counts per event_name, // and the user_id filter will scope it to this user. const params = client.buildAnalyticsParams(safeArgs); const data = await client.get(`/sites/${args.siteId}/events/names`, params); return { content: [{ type: "text" as const, text: truncateResponse(data) }], }; } catch (err) { const message = err instanceof Error ? err.message : String(err); return { content: [{ type: "text" as const, text: `Error: ${message}` }], isError: true, }; } } );