import { SetMetadata } from '@nestjs/common';
import type { TrackOptions } from '../types';

export const TRACK_METADATA_KEY = 'analytics:track';

/**
 * Decorator to track a controller method as an analytics event.
 *
 * @example
 * ```typescript
 * @Track({ event: 'user.created', category: 'users' })
 * @Post()
 * createUser(@Body() dto: CreateUserDto) {
 *   // ...
 * }
 * ```
 */
export function Track(options: TrackOptions = {}): MethodDecorator {
  return SetMetadata(TRACK_METADATA_KEY, options);
}
