UNPKG

react-native-debug-toolkit

Version:

A simple yet powerful debugging toolkit for React Native with a convenient floating UI for development

92 lines (84 loc) 2.57 kB
// Define the entity types and names as constants for better type safety export const EntityType = { mine_module: 'mine_module', search_module: 'search_module', page_view: 'page_view', error_module: 'error_module', navigation: 'navigation', content: 'content', user_action: 'user_action', } as const export const EntityName = { MINE_POST: 'MINE_POST', HOME_PAGE: 'HOME_PAGE', SEARCH_BAR: 'SEARCH_BAR', PROFILE_PAGE: 'PROFILE_PAGE', NAVIGATION_TAB: 'NAVIGATION_TAB', CONTENT_ITEM: 'CONTENT_ITEM', USER_BUTTON: 'USER_BUTTON', } as const export type TrackEventOptions = { entityType: (typeof EntityType)[keyof typeof EntityType] entityName?: (typeof EntityName)[keyof typeof EntityName] pageId?: string objId?: string entityPath?: string objType?: number objPt?: string // 瀑布流作品pt refPageLocation?: string position?: string entityLocation?: string frontOperation?: string sessionId?: string //搜索模块需要 requestId?: string //搜索模块需要 searchKeywored?: string //搜索模块需要 enSearchKeywored?: string //搜索模块需要 } // Complete event structure that includes the event name and all tracking options export type TrackEvent = { eventName: string timestamp: Date } & TrackEventOptions // Track feature interface export interface ITrackFeature { setup(): ITrackFeature getData(): TrackEvent[] cleanup(): void logEvent(eventData: TrackEventOptions & { eventName: string }): void getEventStats(): EventStats addEventToBlacklist(pattern: string | RegExp): void removeEventFromBlacklist(pattern: string | RegExp): void clearBlacklist(): void getBlacklist(): (string | RegExp)[] } // Event statistics structure export type EventStats = { [eventName: string]: { count: number lastSeen: Date entityTypes: string[] operations: string[] } } // Common event names used in the application export const CommonEventNames = { LOG_ACTION_FRONT: 'log_action_front', LOG_ERROR_FRONT: 'log_error_front', LOG_VIEW_FRONT: 'log_view_front', LOG_SEARCH_FRONT: 'log_search_front', LOG_NAVIGATION_FRONT: 'log_navigation_front', } as const // Common front operations export const FrontOperations = { CLICK: 'click', VIEW: 'view', SEARCH: 'search', SWIPE: 'swipe', SCROLL: 'scroll', ERROR: 'error', NAVIGATE: 'navigate', } as const // Helper type for creating events with better type safety export type CreateTrackEvent<T extends keyof typeof CommonEventNames> = { eventName: (typeof CommonEventNames)[T] } & TrackEventOptions