Skip to content

armgit / umami

Public Imported from GitHub
0

Umami is a privacy-first web and product analytics platform. Traffic, campaigns, behavior, conversions, and revenue in one place. No cookies, no surveillance, self-hosted or in the cloud.

2.7 KB
Raw Blame
import { z } from 'zod';
import { funnelQuerySchema } from '@/lib/analytics-schema';
import { defineOperation } from '@/openapi/operation';
import { badRequestResponse, notFoundResponse, unauthorizedResponse } from '@/openapi/schemas';

export const operations = [
  defineOperation({
    method: 'get',
    path: '/api/websites/{websiteId}/funnels/stats',
    audience: 'public',
    auth: 'bearer-or-share',
    operation: {
      operationId: 'getWebsiteFunnelStats',
      summary: 'Get website funnel stats',
      tags: ['Websites'],
      requestParams: { path: z.object({ websiteId: z.uuid() }), query: funnelQuerySchema },
      responses: {
        '200': {
          description: 'The operation completed successfully.',
          content: {
            'application/json': {
              schema: {
                type: 'array',
                items: {
                  type: 'object',
                  properties: {
                    visitors: {
                      type: 'number',
                    },
                    previous: {
                      type: 'number',
                    },
                    dropped: {
                      type: 'number',
                    },
                    dropoff: {
                      type: 'number',
                    },
                    remaining: {
                      type: 'number',
                    },
                    type: {
                      type: 'string',
                    },
                    value: {
                      type: 'string',
                    },
                    filters: {
                      type: 'array',
                      items: {
                        type: 'object',
                        properties: {
                          property: {
                            type: 'string',
                          },
                          operator: {
                            type: 'string',
                          },
                          value: {
                            type: 'string',
                          },
                        },
                        required: ['property', 'operator', 'value'],
                      },
                    },
                  },
                  required: [
                    'visitors',
                    'previous',
                    'dropped',
                    'dropoff',
                    'remaining',
                    'type',
                    'value',
                  ],
                },
              },
            },
          },
        },
        '400': badRequestResponse,
        '401': unauthorizedResponse,
        '404': notFoundResponse,
      },
    },
  }),
] as const;