|
| 1 | +import { z } from 'zod' |
| 2 | + |
| 3 | +/** |
| 4 | + * Schema for retrieving RUM events. |
| 5 | + * Defines parameters for querying RUM events within a time window. |
| 6 | + * |
| 7 | + * @param query - Datadog RUM query string |
| 8 | + * @param from - Start time in epoch seconds |
| 9 | + * @param to - End time in epoch seconds |
| 10 | + * @param limit - Maximum number of events to return (default: 100) |
| 11 | + */ |
| 12 | +export const GetRumEventsZodSchema = z.object({ |
| 13 | + query: z.string().default('').describe('Datadog RUM query string'), |
| 14 | + from: z.number().describe('Start time in epoch seconds'), |
| 15 | + to: z.number().describe('End time in epoch seconds'), |
| 16 | + limit: z |
| 17 | + .number() |
| 18 | + .optional() |
| 19 | + .default(100) |
| 20 | + .describe('Maximum number of events to return. Default is 100.'), |
| 21 | +}) |
| 22 | + |
| 23 | +/** |
| 24 | + * Schema for retrieving RUM applications. |
| 25 | + * Returns a list of all RUM applications in the organization. |
| 26 | + */ |
| 27 | +export const GetRumApplicationsZodSchema = z.object({}) |
| 28 | + |
| 29 | +/** |
| 30 | + * Schema for retrieving unique user session counts. |
| 31 | + * Defines parameters for querying session counts within a time window. |
| 32 | + * |
| 33 | + * @param query - Optional. Additional query filter for RUM search. Defaults to "*" (all events) |
| 34 | + * @param from - Start time in epoch seconds |
| 35 | + * @param to - End time in epoch seconds |
| 36 | + * @param groupBy - Optional. Dimension to group results by (e.g., 'application.name') |
| 37 | + */ |
| 38 | +export const GetRumGroupedEventCountZodSchema = z.object({ |
| 39 | + query: z |
| 40 | + .string() |
| 41 | + .default('*') |
| 42 | + .describe('Optional query filter for RUM search'), |
| 43 | + from: z.number().describe('Start time in epoch seconds'), |
| 44 | + to: z.number().describe('End time in epoch seconds'), |
| 45 | + groupBy: z |
| 46 | + .string() |
| 47 | + .optional() |
| 48 | + .default('application.name') |
| 49 | + .describe('Dimension to group results by. Default is application.name'), |
| 50 | +}) |
| 51 | + |
| 52 | +/** |
| 53 | + * Schema for retrieving page performance metrics. |
| 54 | + * Defines parameters for querying performance metrics within a time window. |
| 55 | + * |
| 56 | + * @param query - Optional. Additional query filter for RUM search. Defaults to "*" (all events) |
| 57 | + * @param from - Start time in epoch seconds |
| 58 | + * @param to - End time in epoch seconds |
| 59 | + * @param metricNames - Array of metric names to retrieve (e.g., 'view.load_time', 'view.first_contentful_paint') |
| 60 | + */ |
| 61 | +export const GetRumPagePerformanceZodSchema = z.object({ |
| 62 | + query: z |
| 63 | + .string() |
| 64 | + .default('*') |
| 65 | + .describe('Optional query filter for RUM search'), |
| 66 | + from: z.number().describe('Start time in epoch seconds'), |
| 67 | + to: z.number().describe('End time in epoch seconds'), |
| 68 | + metricNames: z |
| 69 | + .array(z.string()) |
| 70 | + .default([ |
| 71 | + 'view.load_time', |
| 72 | + 'view.first_contentful_paint', |
| 73 | + 'view.largest_contentful_paint', |
| 74 | + ]) |
| 75 | + .describe('Array of metric names to retrieve'), |
| 76 | +}) |
| 77 | + |
| 78 | +/** |
| 79 | + * Schema for retrieving RUM page waterfall data. |
| 80 | + * Defines parameters for querying waterfall data within a time window. |
| 81 | + * |
| 82 | + * @param application - Application name or ID to filter events |
| 83 | + * @param sessionId - Session ID to filter events |
| 84 | + * @param from - Start time in epoch seconds |
| 85 | + * @param to - End time in epoch seconds |
| 86 | + */ |
| 87 | +export const GetRumPageWaterfallZodSchema = z.object({ |
| 88 | + applicationName: z.string().describe('Application name to filter events'), |
| 89 | + sessionId: z.string().describe('Session ID to filter events'), |
| 90 | +}) |
0 commit comments