Get daily performance (revenue / transactions / sessions)
grips_get_daily_performanceRetrieve daily revenue, transactions, and sessions timeseries for one or more domains to detect spikes, dips, promo effects, and day-of-week patterns. Supports US, GB, DE. Returns markdown or JSON.
Instructions
Returns a daily timeseries of revenue, transactions, and sessions for one or more domains. Useful for spike/dip detection, promo windows, and day-of-week patterns. Note: Grips only offers daily data for a subset of domains — smaller sites often return empty. Defaults to markdown output.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| domains | Yes | One or more domains (e.g. ['adidas.com', 'nike.com']). Protocol and trailing slash are stripped automatically. | |
| date_from | Yes | Start of the reporting window, inclusive, as YYYY-MM-DD. Example: '2024-01-01'. | |
| date_to | Yes | End of the reporting window, inclusive, as YYYY-MM-DD. Example: '2024-12-31'. | |
| country | No | Optional country filter. Defaults to the server's GRIPS_DEFAULT_COUNTRY (usually 'US'). | |
| format | No | Response format. 'markdown' is human-readable; 'json' is machine-parseable. | markdown |
Implementation Reference
- src/tools/daily.ts:42-100 (handler)The main handler function `runDailyPerformance` that executes the gripps_get_daily_performance tool logic. It calls the Grips API with DAILY_PERFORMANCE_QUERY, normalizes dates, and returns either JSON or a markdown table with revenue/transactions/sessions timeseries data.
export async function runDailyPerformance( client: GripsApiClient, args: DailyPerformanceInput, defaultCountry: string, ): Promise<string> { const country = args.country ?? defaultCountry; const variables = buildFilters({ domains: args.domains, date_from: args.date_from, date_to: args.date_to, country, }); let rawData: { performance?: unknown } = {}; try { rawData = await client.query<{ performance?: unknown }>({ query: DAILY_PERFORMANCE_QUERY, variables, }); } catch (err) { const msg = formatUpstreamError(err); const hint = errorHint(err); return `Error: ${msg}${hint ? `\n\nHint: ${hint}` : ""}`; } const rows = toArray<DailyPerformanceRow>(rawData.performance).map((r) => ({ ...r, date: normalizeDate(r?.date), })); if (rows.length === 0) { return `**Grips daily performance — ${args.domains.join(", ")} (${country}, ${args.date_from} → ${args.date_to})**\n\n_No daily data returned by Grips. Daily data is only available for a subset of covered domains — try \`grips_get_domain_performance\` for monthly data instead._`; } if (args.format === "json") { return toJson({ domains: args.domains, country, date_from: args.date_from, date_to: args.date_to, rows: rows.map((r) => ({ date: r.date, transactionrevenue: safeNumberOrNull(r.transactionrevenue), transactions: safeNumberOrNull(r.transactions), sessions: safeNumberOrNull(r.sessions), })), }); } const tableRows = rows.map((r) => ({ Date: r.date, Revenue: formatCurrency(r.transactionrevenue), Transactions: formatInt(r.transactions), Sessions: formatInt(r.sessions), })); const header = `**Grips daily performance — ${args.domains.join(", ")} (${country}, ${args.date_from} → ${args.date_to})**`; return truncateIfNeeded(`${header}\n\n${toMarkdownTable(tableRows)}`); } - src/index.ts:81-90 (registration)Registration of the `grips_get_daily_performance` tool via `server.registerTool()`, wiring the tool definition to the `runDailyPerformance` handler.
server.registerTool( dailyPerformanceToolDef.name, { title: dailyPerformanceToolDef.title, description: dailyPerformanceToolDef.description, inputSchema: dailyPerformanceToolDef.inputSchema, annotations: dailyPerformanceToolDef.annotations, }, async (args) => asText(await runDailyPerformance(client, args as any, defaultCountry)), ); - src/tools/daily.ts:25-40 (schema)Input schema (`dailyPerformanceInputSchema`) and tool definition (`dailyPerformanceToolDef`) for gripps_get_daily_performance. Uses `baseFilterFields` (domains, date_from, date_to, country, format).
export const dailyPerformanceInputSchema = z.object(baseFilterFields); export type DailyPerformanceInput = z.infer<typeof dailyPerformanceInputSchema>; export const dailyPerformanceToolDef = { name: "grips_get_daily_performance", title: "Get daily performance (revenue / transactions / sessions)", description: "Returns a daily timeseries of revenue, transactions, and sessions for one or more domains. Useful for spike/dip detection, promo windows, and day-of-week patterns. Note: Grips only offers daily data for a subset of domains — smaller sites often return empty. Defaults to markdown output.", inputSchema: baseFilterFields, annotations: { readOnlyHint: true, destructiveHint: false, idempotentHint: true, openWorldHint: true, }, }; - src/schemas/common.ts:41-74 (schema)`baseFilterFields` shared schema used by gripps_get_daily_performance, defining domains, date_from, date_to, country, and format fields.
export const baseFilterFields = { domains: domainsArray.describe( "One or more domains (e.g. ['adidas.com', 'nike.com']). Protocol and trailing slash are stripped automatically.", ), date_from: isoDate.describe( "Start of the reporting window, inclusive, as YYYY-MM-DD. Example: '2024-01-01'.", ), date_to: isoDate.describe( "End of the reporting window, inclusive, as YYYY-MM-DD. Example: '2024-12-31'.", ), country: countryEnum .optional() .describe("Optional country filter. Defaults to the server's GRIPS_DEFAULT_COUNTRY (usually 'US')."), format: outputFormat, }; /** Convenience: build the `{ filters: {...} }` payload Grips expects. */ export function buildFilters(args: { domains: string[]; date_from: string; date_to: string; country?: string; channel?: string[]; }): { filters: Record<string, unknown> } { const filters: Record<string, unknown> = { domain: { in: args.domains }, date: { gte: args.date_from, lte: args.date_to }, }; if (args.country) filters.country = args.country; if (args.channel && args.channel.length > 0) { filters.channel = { in: args.channel }; } return { filters }; } - src/services/queries.ts:41-64 (helper)The DAILY_PERFORMANCE_QUERY GraphQL string used by the handler to fetch daily revenue, transactions, and sessions timeseries data from the Grips API.
/** Daily performance — only available for a subset of domains. */ export const DAILY_PERFORMANCE_QUERY = ` input Date { gte: String! lte: String! } input OrArray { in: [String!] } input Filters { country: String domain: OrArray! date: Date! } query domain_performance_daily($filters: Filters) { performance: fetch(filters: $filters) { date (type: Array, sort_asc: date) { transactionrevenue: sum(a:revenue) transactions: sum(a:transactions) sessions: sum(a:sessions) } } } `;