feat(decorators): ✨ Add track/no-track decorators for activity monitoring (opt-in/opt-out)
Co-Authored-By: Lilith Autocommit <noreply@atlilith.com>
This commit is contained in:
parent
499d1ebe12
commit
68706ba1c4
3 changed files with 0 additions and 41 deletions
|
|
@ -1,2 +0,0 @@
|
|||
export { Track, TRACK_METADATA_KEY } from './track';
|
||||
export { NoTrack, NO_TRACK_METADATA_KEY } from './no-track';
|
||||
|
|
@ -1,19 +0,0 @@
|
|||
import { SetMetadata } from '@nestjs/common';
|
||||
|
||||
export const NO_TRACK_METADATA_KEY = 'analytics:no-track';
|
||||
|
||||
/**
|
||||
* Decorator to exclude a controller method from analytics tracking.
|
||||
*
|
||||
* @example
|
||||
* ```typescript
|
||||
* @NoTrack()
|
||||
* @Get('health')
|
||||
* healthCheck() {
|
||||
* return { status: 'ok' };
|
||||
* }
|
||||
* ```
|
||||
*/
|
||||
export function NoTrack(): MethodDecorator {
|
||||
return SetMetadata(NO_TRACK_METADATA_KEY, true);
|
||||
}
|
||||
|
|
@ -1,20 +0,0 @@
|
|||
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);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue