1+ import type { HexTaskType } from './tasks' ;
2+
3+ export interface BaseEvent {
4+ eventName : string ;
5+ userId : string ;
6+ hostId ?: string ;
7+ timestamp : Date ;
8+ properties ?: Record < string , any > ;
9+ }
10+
11+ export interface TaskEvent extends BaseEvent {
12+ taskId : string ;
13+ taskType : HexTaskType ;
14+ taskStatus : string ;
15+ errorMessage ?: string ;
16+ }
17+
18+ export interface AppEvent extends TaskEvent {
19+ appId : string ;
20+ appTrain ?: string ;
21+ appVersion ?: string ;
22+ appTrueNasVersion ?: string ;
23+ }
24+
25+ export enum EventState {
26+ STARTED = 'started' ,
27+ COMPLETED = 'completed' ,
28+ FAILED = 'failed' ,
29+ DISMISSED = 'dismissed' ,
30+ }
31+
32+ export type TaskEventName = `${Lowercase < `${HexTaskType } `> } _${EventState } `;
33+
34+ export const SystemEventNames = {
35+ SERVER_CONNECTED : 'server_connected' ,
36+ SERVER_DISCONNECTED : 'server_disconnected' ,
37+ USER_LOGIN : 'user_login' ,
38+ USER_LOGOUT : 'user_logout' ,
39+ DRIVE_UTILIZED : 'drive_utilized' , // Drive added to a pool
40+ DRIVE_REPLACED : 'drive_replaced' ,
41+ DRIVE_REMOVED : 'drive_removed' ,
42+ DRIVE_FAILED : 'drive_failed' ,
43+ DRIVE_HEALTHY : 'drive_healthy' , // Drive has no errors
44+ DRIVE_DISCOVERED : 'drive_discovered' , // Drive found on system (assigned or unassigned)
45+ APP_DISCOVERED : 'app_discovered' , // App found on system
46+ } as const ;
47+
48+ export type SystemEventName = typeof SystemEventNames [ keyof typeof SystemEventNames ] ;
49+ export type EventName = TaskEventName | SystemEventName ;
50+
51+ export interface EventQueryOptions {
52+ eventName ?: EventName | EventName [ ] ;
53+ userId ?: string ;
54+ hostId ?: string ;
55+ taskType ?: HexTaskType ;
56+ appId ?: string ;
57+ appTrain ?: string ;
58+ appVersion ?: string ;
59+ startDate ?: Date ;
60+ endDate ?: Date ;
61+ limit ?: number ;
62+ }
63+
64+ export interface AppPopularityMetrics {
65+ appId : string ;
66+ installCount : number ;
67+ uninstallCount : number ;
68+ upgradeCount : number ;
69+ failureCount : number ;
70+ lastInstalled : Date ;
71+ }
0 commit comments