All files / src/lib/api-docs/endpoints analytics.ts

100% Statements 48/48
100% Branches 0/0
100% Functions 0/0
100% Lines 48/48

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 491x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x  
/**
 * Analytics Tracking Endpoints
 * Client-side analytics event tracking endpoints
 */
 
import type { ApiEndpoint } from '@/types/api-docs';
 
export const analyticsTrackingEndpoints: ApiEndpoint[] = [
  {
    id: 'analytics-track-events',
    method: 'POST',
    path: '/api/analytics/track',
    summary: 'Track analytics events',
    description: 'Track custom analytics events (supports batching up to 50 events)',
    category: 'analytics',
    requiresAuth: false,
    requestBody: {
      contentType: 'application/json',
      fields: [
        { name: 'events', type: 'array', required: true, description: 'Array of events to track (1-50 events)' },
        { name: 'events[].eventType', type: 'string', required: true, description: 'Event type/category (max 50 chars)' },
        { name: 'events[].eventName', type: 'string', required: true, description: 'Event name/action (max 100 chars)' },
        { name: 'events[].sessionId', type: 'string', required: true, description: 'Session ID' },
        { name: 'events[].visitorId', type: 'string', required: true, description: 'Visitor ID (max 50 chars)' },
        { name: 'events[].path', type: 'string', required: true, description: 'Page path (max 500 chars)' },
        { name: 'events[].referrer', type: 'string', required: false, description: 'Referrer URL (max 500 chars)' },
        { name: 'events[].properties', type: 'object', required: false, description: 'Additional event properties' },
      ],
      example: {
        events: [
          {
            eventType: 'interaction',
            eventName: 'add_to_cart',
            sessionId: 'sess_123',
            visitorId: 'vis_456',
            path: '/products/123',
            properties: { productId: 123, quantity: 1 },
          },
        ],
      },
    },
    responses: [
      { status: 200, description: 'Events tracked successfully', example: { success: true, eventsTracked: 1 } },
      { status: 400, description: 'Invalid event format or validation failed' },
      { status: 500, description: 'Failed to track events' },
    ],
  },
];