import { Entity, Column, PrimaryGeneratedColumn, CreateDateColumn, Index } from 'typeorm';

@Entity('telemetry_events')
@Index('idx_telemetry_events_name_time', ['eventName', 'eventTime'])
export class TelemetryEvent {
  @PrimaryGeneratedColumn({ type: 'bigint' })
  id: string;

  @Column({ name: 'user_id', type: 'uuid', nullable: true })
  userId: string | null;

  @Column({ name: 'install_id', length: 128 })
  installId: string;

  @Column({ name: 'event_name', length: 64 })
  eventName: string;

  @Column({ name: 'event_time', type: 'timestamptz' })
  eventTime: Date;

  @Column({ type: 'jsonb', default: '{}' })
  properties: Record<string, any>;

  @CreateDateColumn({ name: 'created_at', type: 'timestamptz' })
  createdAt: Date;
}
