MCPcopy Create free account
hub / github.com/Openpanel-dev/openpanel / runReportFromConfig

Function runReportFromConfig

packages/mcp/src/tools/analytics/reports.ts:167–208  ·  view source on GitHub ↗
(input: {
  organizationId: string;
  projectId: string;
  /** Full zReportInput shape, with required startDate/endDate */
  config: {
    chartType: string;
    interval: string;
    startDate: string;
    endDate: string;
    [key: string]: unknown;
  };
})

Source from the content-addressed store, hash-verified

165 * Used by `generate_report` tool in chat.
166 */
167export async function runReportFromConfig(input: {
168 organizationId: string;
169 projectId: string;
170 /** Full zReportInput shape, with required startDate/endDate */
171 config: {
172 chartType: string;
173 interval: string;
174 startDate: string;
175 endDate: string;
176 [key: string]: unknown;
177 };
178}): Promise<{
179 chartType: string;
180 interval: string;
181 startDate: string;
182 endDate: string;
183 report: typeof input.config & { projectId: string };
184 data: unknown;
185}> {
186 const { timezone } = await getSettingsForProject(input.projectId);
187 const chartInput = {
188 ...input.config,
189 projectId: input.projectId,
190 timezone,
191 } as unknown as Parameters<typeof ChartEngine.execute>[0];
192
193 const meta = {
194 chartType: input.config.chartType,
195 interval: input.config.interval,
196 startDate: input.config.startDate,
197 endDate: input.config.endDate,
198 report: { ...input.config, projectId: input.projectId },
199 };
200
201 if (input.config.chartType === 'funnel') {
202 return { ...meta, data: await funnelService.getFunnel(chartInput as Parameters<typeof funnelService.getFunnel>[0]) };
203 }
204 if (input.config.chartType === 'metric') {
205 return { ...meta, data: await AggregateChartEngine.execute(chartInput) };
206 }
207 return { ...meta, data: await ChartEngine.execute(chartInput) };
208}

Callers 2

base.tsFile · 0.90
report.tsFile · 0.90

Calls 3

getSettingsForProjectFunction · 0.90
getFunnelMethod · 0.80
executeMethod · 0.80

Tested by

no test coverage detected