get_analytics
Retrieve detailed analytics for a specific email draft in Buttondown by providing the draft ID. Supports email performance tracking and data-driven decisions.
Instructions
Retrieve analytics data for a specific email draft from Buttondown
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
| draftId | Yes | The ID of the email draft to get analytics for |
Implementation Reference
- src/mcp/index.ts:177-188 (handler)The asynchronous handler function for the 'get_analytics' tool. It ensures the API key is set, fetches analytics using the API client, and returns the response as formatted JSON text.async ({ draftId }) => { await this.ensureApiKey(); const response = await this.api.getAnalytics(draftId); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; }
- src/mcp/index.ts:172-176 (schema)Zod schema for the input parameters of the 'get_analytics' tool, requiring a 'draftId' string.{ draftId: z .string() .describe("The ID of the email draft to get analytics for"), },
- src/mcp/index.ts:169-189 (registration)Registration of the 'get_analytics' MCP tool on the server, including name, description, input schema, and handler function.this.server.tool( "get_analytics", "Retrieve analytics data for a specific email draft from Buttondown", { draftId: z .string() .describe("The ID of the email draft to get analytics for"), }, async ({ draftId }) => { await this.ensureApiKey(); const response = await this.api.getAnalytics(draftId); return { content: [ { type: "text", text: JSON.stringify(response, null, 2), }, ], }; } );
- src/api/client.ts:87-89 (helper)The ButtondownAPI client's getAnalytics method that makes the HTTP request to retrieve analytics for a given email ID.async getAnalytics(emailId: string): Promise<ButtondownAnalytics> { return this.request<ButtondownAnalytics>(`/emails/${emailId}/analytics`); }