User Retention
rybbit_get_retentionAnalyze user retention cohorts to track how many users return over specific time periods for website analytics.
Instructions
Get user retention cohort analysis showing how many users return over time periods.
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) |
Implementation Reference
- src/tools/metrics.ts:104-137 (handler)The handler implementation for the 'rybbit_get_retention' tool, which fetches cohort analysis data from the Rybbit API.
async (args) => { try { const { siteId, ...rest } = args as { siteId: string; startDate?: string; endDate?: string; timeZone?: string; filters?: Array<{ parameter: string; type: string; value: (string | number)[] }>; pastMinutesStart?: number; pastMinutesEnd?: number; }; const params = client.buildAnalyticsParams(rest); const data = await client.get<RetentionData[]>( `/sites/${siteId}/retention`, 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, }; } - src/tools/metrics.ts:88-103 (registration)Registration of the 'rybbit_get_retention' tool, including its schema and metadata.
server.registerTool( "rybbit_get_retention", { title: "User Retention", description: "Get user retention cohort analysis showing how many users return over time periods.", annotations: { readOnlyHint: true, idempotentHint: true, openWorldHint: true, destructiveHint: false, }, inputSchema: { ...analyticsInputSchema, }, },