diff --git a/src/nestjs/index.ts b/src/nestjs/index.ts deleted file mode 100644 index 3b344e0..0000000 --- a/src/nestjs/index.ts +++ /dev/null @@ -1,16 +0,0 @@ -// Module -export { AnalyticsModule } from './module'; -export type { AnalyticsModuleOptions, AnalyticsModuleAsyncOptions } from './module'; - -// Decorators -export { Track } from './decorators'; -export { NoTrack } from './decorators'; - -// Interceptor -export { AnalyticsInterceptor } from './interceptors'; - -// Service -export { AnalyticsService } from './services'; - -// Types -export type { TrackOptions, AnalyticsEvent } from './types'; diff --git a/src/nestjs/module.ts b/src/nestjs/module.ts deleted file mode 100644 index 977049c..0000000 --- a/src/nestjs/module.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { Module, DynamicModule, Provider, Global, type Type } from '@nestjs/common'; -import { AnalyticsService } from './services'; -import { AnalyticsInterceptor } from './interceptors'; -import type { CollectorConfig, BatchConfig } from './types'; - -export const ANALYTICS_OPTIONS = 'ANALYTICS_OPTIONS'; - -export interface AnalyticsModuleOptions { - /** Collector service configuration */ - collector: CollectorConfig; - /** Batching configuration */ - batch?: BatchConfig; - /** Whether to enable tracking globally */ - enabled?: boolean; - /** Whether to log events to console (development) */ - debug?: boolean; -} - -export interface AnalyticsModuleAsyncOptions { - imports?: Type[]; - useFactory: (...args: unknown[]) => Promise | AnalyticsModuleOptions; - inject?: (Type | string | symbol)[]; -} - -@Global() -@Module({}) -export class AnalyticsModule { - static forRoot(options: AnalyticsModuleOptions): DynamicModule { - const optionsProvider: Provider = { - provide: ANALYTICS_OPTIONS, - useValue: options, - }; - - return { - module: AnalyticsModule, - providers: [optionsProvider, AnalyticsService, AnalyticsInterceptor], - exports: [AnalyticsService, AnalyticsInterceptor], - }; - } - - static forRootAsync(options: AnalyticsModuleAsyncOptions): DynamicModule { - const optionsProvider: Provider = { - provide: ANALYTICS_OPTIONS, - useFactory: options.useFactory, - inject: options.inject || [], - }; - - return { - module: AnalyticsModule, - imports: options.imports || [], - providers: [optionsProvider, AnalyticsService, AnalyticsInterceptor], - exports: [AnalyticsService, AnalyticsInterceptor], - }; - } -} diff --git a/src/nestjs/types.ts b/src/nestjs/types.ts deleted file mode 100644 index 977df90..0000000 --- a/src/nestjs/types.ts +++ /dev/null @@ -1,72 +0,0 @@ -import type { AnalyticsEvent as BaseAnalyticsEvent } from '../types'; - -/** - * Options for the @Track decorator - */ -export interface TrackOptions { - /** Event name (defaults to method name) */ - event?: string; - /** Event category */ - category?: string; - /** Whether to include request body in event properties */ - includeBody?: boolean; - /** Whether to include request params in event properties */ - includeParams?: boolean; - /** Whether to include query params in event properties */ - includeQuery?: boolean; - /** Custom properties extractor */ - extractProperties?: (context: TrackContext) => Record; -} - -/** - * Context available when extracting properties - */ -export interface TrackContext { - request: { - method: string; - url: string; - path: string; - body?: unknown; - params?: Record; - query?: Record; - headers: Record; - ip?: string; - user?: { id?: string; [key: string]: unknown }; - }; - response?: { - statusCode: number; - }; - executionTime?: number; -} - -/** - * Analytics event for NestJS - */ -export interface AnalyticsEvent extends Omit { - timestamp?: string; - sessionId?: string; -} - -/** - * Collector endpoint configuration - */ -export interface CollectorConfig { - /** Collector service URL */ - url: string; - /** API key for authentication */ - apiKey?: string; - /** Request timeout in ms */ - timeout?: number; - /** Number of retries */ - retries?: number; -} - -/** - * Batch configuration - */ -export interface BatchConfig { - /** Maximum events to batch */ - maxSize?: number; - /** Maximum time to wait before flushing (ms) */ - maxWait?: number; -}