@oneuptime/common 10.0.52 → 10.0.54

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (405) hide show
  1. package/Models/AnalyticsModels/Metric.ts +78 -0
  2. package/Server/API/AIAgentDataAPI.ts +6 -1
  3. package/Server/API/BillingAPI.ts +28 -6
  4. package/Server/API/CommonAPI.ts +11 -0
  5. package/Server/API/DashboardAPI.ts +6 -2
  6. package/Server/API/DashboardDomainAPI.ts +10 -3
  7. package/Server/API/GitHubAPI.ts +58 -14
  8. package/Server/API/MicrosoftTeamsAPI.ts +97 -33
  9. package/Server/API/OpenSourceDeploymentAPI.ts +2 -2
  10. package/Server/API/SlackAPI.ts +107 -36
  11. package/Server/API/StatusAPI.ts +37 -16
  12. package/Server/API/StatusPageAPI.ts +97 -23
  13. package/Server/API/StatusPageDomainAPI.ts +6 -3
  14. package/Server/API/TelemetryAPI.ts +81 -0
  15. package/Server/API/UserAPI.ts +3 -3
  16. package/Server/API/UserCallAPI.ts +5 -2
  17. package/Server/API/UserEmailAPI.ts +5 -2
  18. package/Server/API/UserPushAPI.ts +9 -3
  19. package/Server/API/UserSmsAPI.ts +5 -2
  20. package/Server/API/UserWhatsAppAPI.ts +5 -2
  21. package/Server/Infrastructure/Postgres/SchemaMigrations/1774559064921-MigrationName.ts +47 -0
  22. package/Server/Infrastructure/Postgres/SchemaMigrations/1775735059360-MigrationName.ts +35 -0
  23. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +4 -0
  24. package/Server/Middleware/NotificationMiddleware.ts +2 -2
  25. package/Server/Middleware/ProjectAuthorization.ts +6 -0
  26. package/Server/Middleware/SCIMAuthorization.ts +2 -1
  27. package/Server/Middleware/SlackAuthorization.ts +28 -10
  28. package/Server/Middleware/TelemetryIngest.ts +16 -3
  29. package/Server/Middleware/UserAuthorization.ts +22 -5
  30. package/Server/Middleware/WhatsAppAuthorization.ts +15 -4
  31. package/Server/Services/AIAgentService.ts +13 -6
  32. package/Server/Services/AIService.ts +9 -3
  33. package/Server/Services/AlertEpisodeFeedService.ts +17 -5
  34. package/Server/Services/AlertEpisodeService.ts +34 -3
  35. package/Server/Services/AlertEpisodeStateTimelineService.ts +80 -22
  36. package/Server/Services/AlertFeedService.ts +17 -5
  37. package/Server/Services/AlertGroupingEngineService.ts +36 -7
  38. package/Server/Services/AlertService.ts +60 -8
  39. package/Server/Services/AlertStateTimelineService.ts +29 -7
  40. package/Server/Services/AnalyticsDatabaseService.ts +59 -25
  41. package/Server/Services/BillingInvoiceService.ts +7 -3
  42. package/Server/Services/BillingService.ts +9 -2
  43. package/Server/Services/DashboardDomainService.ts +56 -22
  44. package/Server/Services/DashboardService.ts +11 -4
  45. package/Server/Services/DatabaseService.ts +31 -11
  46. package/Server/Services/IncidentEpisodeFeedService.ts +17 -5
  47. package/Server/Services/IncidentEpisodeService.ts +34 -3
  48. package/Server/Services/IncidentEpisodeStateTimelineService.ts +80 -22
  49. package/Server/Services/IncidentFeedService.ts +33 -9
  50. package/Server/Services/IncidentGroupingEngineService.ts +35 -6
  51. package/Server/Services/IncidentService.ts +103 -9
  52. package/Server/Services/IncidentSlaRuleService.ts +16 -4
  53. package/Server/Services/IncidentSlaService.ts +20 -4
  54. package/Server/Services/IncidentStateTimelineService.ts +120 -31
  55. package/Server/Services/KubernetesClusterService.ts +62 -14
  56. package/Server/Services/LabelService.ts +14 -1
  57. package/Server/Services/MonitorFeedService.ts +33 -9
  58. package/Server/Services/MonitorProbeService.ts +31 -2
  59. package/Server/Services/MonitorService.ts +35 -4
  60. package/Server/Services/MonitorStatusTimelineService.ts +68 -20
  61. package/Server/Services/NotificationService.ts +4 -2
  62. package/Server/Services/OnCallDutyPolicyEscalationRuleService.ts +53 -9
  63. package/Server/Services/OnCallDutyPolicyEscalationRuleUserService.ts +9 -2
  64. package/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.ts +29 -8
  65. package/Server/Services/OnCallDutyPolicyFeedService.ts +33 -8
  66. package/Server/Services/OnCallDutyPolicyScheduleService.ts +97 -24
  67. package/Server/Services/OnCallDutyPolicyService.ts +2 -1
  68. package/Server/Services/OpenTelemetryIngestService.ts +51 -20
  69. package/Server/Services/ProbeService.ts +16 -7
  70. package/Server/Services/ProjectService.ts +29 -11
  71. package/Server/Services/ScheduledMaintenanceFeedService.ts +17 -4
  72. package/Server/Services/ScheduledMaintenanceService.ts +52 -6
  73. package/Server/Services/ScheduledMaintenanceStateTimelineService.ts +72 -20
  74. package/Server/Services/StatusPageDomainService.ts +59 -23
  75. package/Server/Services/StatusPageService.ts +26 -8
  76. package/Server/Services/StatusPageSubscriberService.ts +382 -111
  77. package/Server/Services/TeamMemberService.ts +9 -3
  78. package/Server/Services/TelemetryAttributeService.ts +117 -4
  79. package/Server/Services/UserNotificationRuleService.ts +9 -3
  80. package/Server/Services/UserService.ts +6 -4
  81. package/Server/Services/UserWhatsAppService.ts +9 -3
  82. package/Server/Services/WorkflowService.ts +7 -3
  83. package/Server/Services/WorkspaceNotificationRuleService.ts +398 -156
  84. package/Server/Types/Domain.ts +15 -5
  85. package/Server/Types/Workflow/Components/API/Post.ts +22 -8
  86. package/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.ts +12 -4
  87. package/Server/Utils/AnalyticsDatabase/StatementGenerator.ts +10 -0
  88. package/Server/Utils/CodeRepository/CodeRepository.ts +62 -13
  89. package/Server/Utils/Express.ts +1 -0
  90. package/Server/Utils/Greenlock/Greenlock.ts +75 -20
  91. package/Server/Utils/LLM/LLMService.ts +22 -7
  92. package/Server/Utils/Logger.ts +93 -13
  93. package/Server/Utils/Monitor/MonitorAlert.ts +15 -3
  94. package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +15 -5
  95. package/Server/Utils/Monitor/MonitorIncident.ts +17 -3
  96. package/Server/Utils/Monitor/MonitorStatusTimeline.ts +6 -1
  97. package/Server/Utils/Profiling.ts +11 -5
  98. package/Server/Utils/Realtime.ts +90 -31
  99. package/Server/Utils/Response.ts +2 -2
  100. package/Server/Utils/StartServer.ts +43 -9
  101. package/Server/Utils/Telemetry/SpanUtil.ts +90 -0
  102. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.ts +58 -15
  103. package/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.ts +58 -15
  104. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.ts +19 -3
  105. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.ts +87 -22
  106. package/Server/Utils/Workspace/MicrosoftTeams/Actions/Monitor.ts +12 -3
  107. package/Server/Utils/Workspace/MicrosoftTeams/Actions/OnCallDutyPolicy.ts +25 -7
  108. package/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.ts +55 -8
  109. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +100 -22
  110. package/Server/Utils/Workspace/Slack/Actions/Alert.ts +35 -9
  111. package/Server/Utils/Workspace/Slack/Actions/AlertEpisode.ts +32 -8
  112. package/Server/Utils/Workspace/Slack/Actions/Auth.ts +3 -1
  113. package/Server/Utils/Workspace/Slack/Actions/Incident.ts +52 -11
  114. package/Server/Utils/Workspace/Slack/Actions/IncidentEpisode.ts +4 -1
  115. package/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.ts +89 -20
  116. package/Server/Utils/Workspace/Slack/Slack.ts +498 -247
  117. package/Server/Utils/Workspace/Workspace.ts +33 -11
  118. package/Server/Utils/Workspace/WorkspaceBase.ts +3 -1
  119. package/Server/Utils/Workspace/WorkspaceMessages/Alert.ts +8 -2
  120. package/Tests/Server/Middleware/UserAuthorization.test.ts +1 -1
  121. package/Tests/Server/Services/AnalyticsDatabaseService.test.ts +12 -3
  122. package/UI/Components/BulkUpdate/BulkUpdateForm.tsx +60 -38
  123. package/UI/Components/Charts/Area/AreaChart.tsx +35 -1
  124. package/UI/Components/Charts/ChartGroup/ChartGroup.tsx +7 -0
  125. package/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx +33 -0
  126. package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +33 -0
  127. package/UI/Components/Charts/ChartLibrary/Types/FormattedExemplarPoint.ts +14 -0
  128. package/UI/Components/Charts/Line/LineChart.tsx +35 -1
  129. package/UI/Components/Charts/Types/ExemplarPoint.ts +6 -0
  130. package/UI/Components/Dictionary/Dictionary.tsx +13 -1
  131. package/UI/Components/Filters/FiltersForm.tsx +2 -0
  132. package/UI/Components/Filters/JSONFilter.tsx +5 -1
  133. package/UI/Components/Filters/Types/Filter.ts +2 -0
  134. package/UI/Components/Markdown.tsx/MarkdownViewer.tsx +3 -3
  135. package/UI/Components/ModelTable/BaseModelTable.tsx +10 -6
  136. package/UI/Components/Navbar/NavBar.tsx +10 -0
  137. package/build/dist/Models/AnalyticsModels/Metric.js +70 -0
  138. package/build/dist/Models/AnalyticsModels/Metric.js.map +1 -1
  139. package/build/dist/Server/API/AIAgentDataAPI.js +6 -6
  140. package/build/dist/Server/API/AIAgentDataAPI.js.map +1 -1
  141. package/build/dist/Server/API/BillingAPI.js +13 -13
  142. package/build/dist/Server/API/BillingAPI.js.map +1 -1
  143. package/build/dist/Server/API/CommonAPI.js +5 -0
  144. package/build/dist/Server/API/CommonAPI.js.map +1 -1
  145. package/build/dist/Server/API/DashboardAPI.js +2 -2
  146. package/build/dist/Server/API/DashboardAPI.js.map +1 -1
  147. package/build/dist/Server/API/DashboardDomainAPI.js +3 -3
  148. package/build/dist/Server/API/DashboardDomainAPI.js.map +1 -1
  149. package/build/dist/Server/API/GitHubAPI.js +19 -19
  150. package/build/dist/Server/API/GitHubAPI.js.map +1 -1
  151. package/build/dist/Server/API/MicrosoftTeamsAPI.js +34 -34
  152. package/build/dist/Server/API/MicrosoftTeamsAPI.js.map +1 -1
  153. package/build/dist/Server/API/OpenSourceDeploymentAPI.js +2 -2
  154. package/build/dist/Server/API/OpenSourceDeploymentAPI.js.map +1 -1
  155. package/build/dist/Server/API/SlackAPI.js +38 -38
  156. package/build/dist/Server/API/SlackAPI.js.map +1 -1
  157. package/build/dist/Server/API/StatusAPI.js +16 -16
  158. package/build/dist/Server/API/StatusAPI.js.map +1 -1
  159. package/build/dist/Server/API/StatusPageAPI.js +52 -52
  160. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  161. package/build/dist/Server/API/StatusPageDomainAPI.js +3 -3
  162. package/build/dist/Server/API/StatusPageDomainAPI.js.map +1 -1
  163. package/build/dist/Server/API/TelemetryAPI.js +39 -0
  164. package/build/dist/Server/API/TelemetryAPI.js.map +1 -1
  165. package/build/dist/Server/API/UserAPI.js +3 -3
  166. package/build/dist/Server/API/UserAPI.js.map +1 -1
  167. package/build/dist/Server/API/UserCallAPI.js +2 -2
  168. package/build/dist/Server/API/UserCallAPI.js.map +1 -1
  169. package/build/dist/Server/API/UserEmailAPI.js +2 -2
  170. package/build/dist/Server/API/UserEmailAPI.js.map +1 -1
  171. package/build/dist/Server/API/UserPushAPI.js +3 -3
  172. package/build/dist/Server/API/UserPushAPI.js.map +1 -1
  173. package/build/dist/Server/API/UserSmsAPI.js +2 -2
  174. package/build/dist/Server/API/UserSmsAPI.js.map +1 -1
  175. package/build/dist/Server/API/UserWhatsAppAPI.js +2 -2
  176. package/build/dist/Server/API/UserWhatsAppAPI.js.map +1 -1
  177. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774559064921-MigrationName.js +40 -0
  178. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774559064921-MigrationName.js.map +1 -0
  179. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1775735059360-MigrationName.js +18 -0
  180. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1775735059360-MigrationName.js.map +1 -0
  181. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +4 -0
  182. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  183. package/build/dist/Server/Middleware/NotificationMiddleware.js +2 -2
  184. package/build/dist/Server/Middleware/NotificationMiddleware.js.map +1 -1
  185. package/build/dist/Server/Middleware/ProjectAuthorization.js +5 -0
  186. package/build/dist/Server/Middleware/ProjectAuthorization.js.map +1 -1
  187. package/build/dist/Server/Middleware/SCIMAuthorization.js +2 -2
  188. package/build/dist/Server/Middleware/SCIMAuthorization.js.map +1 -1
  189. package/build/dist/Server/Middleware/SlackAuthorization.js +10 -10
  190. package/build/dist/Server/Middleware/SlackAuthorization.js.map +1 -1
  191. package/build/dist/Server/Middleware/TelemetryIngest.js +9 -4
  192. package/build/dist/Server/Middleware/TelemetryIngest.js.map +1 -1
  193. package/build/dist/Server/Middleware/UserAuthorization.js +10 -5
  194. package/build/dist/Server/Middleware/UserAuthorization.js.map +1 -1
  195. package/build/dist/Server/Middleware/WhatsAppAuthorization.js +6 -6
  196. package/build/dist/Server/Middleware/WhatsAppAuthorization.js.map +1 -1
  197. package/build/dist/Server/Services/AIAgentService.js +13 -7
  198. package/build/dist/Server/Services/AIAgentService.js.map +1 -1
  199. package/build/dist/Server/Services/AIService.js +9 -2
  200. package/build/dist/Server/Services/AIService.js.map +1 -1
  201. package/build/dist/Server/Services/AlertEpisodeFeedService.js +17 -5
  202. package/build/dist/Server/Services/AlertEpisodeFeedService.js.map +1 -1
  203. package/build/dist/Server/Services/AlertEpisodeService.js +40 -10
  204. package/build/dist/Server/Services/AlertEpisodeService.js.map +1 -1
  205. package/build/dist/Server/Services/AlertEpisodeStateTimelineService.js +81 -24
  206. package/build/dist/Server/Services/AlertEpisodeStateTimelineService.js.map +1 -1
  207. package/build/dist/Server/Services/AlertFeedService.js +17 -5
  208. package/build/dist/Server/Services/AlertFeedService.js.map +1 -1
  209. package/build/dist/Server/Services/AlertGroupingEngineService.js +44 -28
  210. package/build/dist/Server/Services/AlertGroupingEngineService.js.map +1 -1
  211. package/build/dist/Server/Services/AlertService.js +72 -20
  212. package/build/dist/Server/Services/AlertService.js.map +1 -1
  213. package/build/dist/Server/Services/AlertStateTimelineService.js +36 -13
  214. package/build/dist/Server/Services/AlertStateTimelineService.js.map +1 -1
  215. package/build/dist/Server/Services/AnalyticsDatabaseService.js +52 -28
  216. package/build/dist/Server/Services/AnalyticsDatabaseService.js.map +1 -1
  217. package/build/dist/Server/Services/BillingInvoiceService.js +7 -2
  218. package/build/dist/Server/Services/BillingInvoiceService.js.map +1 -1
  219. package/build/dist/Server/Services/BillingService.js +8 -8
  220. package/build/dist/Server/Services/BillingService.js.map +1 -1
  221. package/build/dist/Server/Services/DashboardDomainService.js +49 -27
  222. package/build/dist/Server/Services/DashboardDomainService.js.map +1 -1
  223. package/build/dist/Server/Services/DashboardService.js +11 -4
  224. package/build/dist/Server/Services/DashboardService.js.map +1 -1
  225. package/build/dist/Server/Services/DatabaseService.js +32 -12
  226. package/build/dist/Server/Services/DatabaseService.js.map +1 -1
  227. package/build/dist/Server/Services/IncidentEpisodeFeedService.js +17 -5
  228. package/build/dist/Server/Services/IncidentEpisodeFeedService.js.map +1 -1
  229. package/build/dist/Server/Services/IncidentEpisodeService.js +40 -10
  230. package/build/dist/Server/Services/IncidentEpisodeService.js.map +1 -1
  231. package/build/dist/Server/Services/IncidentEpisodeStateTimelineService.js +81 -24
  232. package/build/dist/Server/Services/IncidentEpisodeStateTimelineService.js.map +1 -1
  233. package/build/dist/Server/Services/IncidentFeedService.js +34 -10
  234. package/build/dist/Server/Services/IncidentFeedService.js.map +1 -1
  235. package/build/dist/Server/Services/IncidentGroupingEngineService.js +43 -29
  236. package/build/dist/Server/Services/IncidentGroupingEngineService.js.map +1 -1
  237. package/build/dist/Server/Services/IncidentService.js +116 -28
  238. package/build/dist/Server/Services/IncidentService.js.map +1 -1
  239. package/build/dist/Server/Services/IncidentSlaRuleService.js +19 -11
  240. package/build/dist/Server/Services/IncidentSlaRuleService.js.map +1 -1
  241. package/build/dist/Server/Services/IncidentSlaService.js +21 -14
  242. package/build/dist/Server/Services/IncidentSlaService.js.map +1 -1
  243. package/build/dist/Server/Services/IncidentStateTimelineService.js +130 -37
  244. package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
  245. package/build/dist/Server/Services/KubernetesClusterService.js +51 -14
  246. package/build/dist/Server/Services/KubernetesClusterService.js.map +1 -1
  247. package/build/dist/Server/Services/LabelService.js +10 -1
  248. package/build/dist/Server/Services/LabelService.js.map +1 -1
  249. package/build/dist/Server/Services/MonitorFeedService.js +34 -10
  250. package/build/dist/Server/Services/MonitorFeedService.js.map +1 -1
  251. package/build/dist/Server/Services/MonitorProbeService.js +23 -3
  252. package/build/dist/Server/Services/MonitorProbeService.js.map +1 -1
  253. package/build/dist/Server/Services/MonitorService.js +42 -11
  254. package/build/dist/Server/Services/MonitorService.js.map +1 -1
  255. package/build/dist/Server/Services/MonitorStatusTimelineService.js +69 -21
  256. package/build/dist/Server/Services/MonitorStatusTimelineService.js.map +1 -1
  257. package/build/dist/Server/Services/NotificationService.js +4 -3
  258. package/build/dist/Server/Services/NotificationService.js.map +1 -1
  259. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js +49 -12
  260. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleService.js.map +1 -1
  261. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js +9 -3
  262. package/build/dist/Server/Services/OnCallDutyPolicyEscalationRuleUserService.js.map +1 -1
  263. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js +26 -11
  264. package/build/dist/Server/Services/OnCallDutyPolicyExecutionLogTimelineService.js.map +1 -1
  265. package/build/dist/Server/Services/OnCallDutyPolicyFeedService.js +34 -10
  266. package/build/dist/Server/Services/OnCallDutyPolicyFeedService.js.map +1 -1
  267. package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js +94 -37
  268. package/build/dist/Server/Services/OnCallDutyPolicyScheduleService.js.map +1 -1
  269. package/build/dist/Server/Services/OnCallDutyPolicyService.js +1 -1
  270. package/build/dist/Server/Services/OnCallDutyPolicyService.js.map +1 -1
  271. package/build/dist/Server/Services/OpenTelemetryIngestService.js +45 -17
  272. package/build/dist/Server/Services/OpenTelemetryIngestService.js.map +1 -1
  273. package/build/dist/Server/Services/ProbeService.js +13 -7
  274. package/build/dist/Server/Services/ProbeService.js.map +1 -1
  275. package/build/dist/Server/Services/ProjectService.js +41 -21
  276. package/build/dist/Server/Services/ProjectService.js.map +1 -1
  277. package/build/dist/Server/Services/ScheduledMaintenanceFeedService.js +17 -5
  278. package/build/dist/Server/Services/ScheduledMaintenanceFeedService.js.map +1 -1
  279. package/build/dist/Server/Services/ScheduledMaintenanceService.js +71 -24
  280. package/build/dist/Server/Services/ScheduledMaintenanceService.js.map +1 -1
  281. package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js +72 -24
  282. package/build/dist/Server/Services/ScheduledMaintenanceStateTimelineService.js.map +1 -1
  283. package/build/dist/Server/Services/StatusPageDomainService.js +55 -29
  284. package/build/dist/Server/Services/StatusPageDomainService.js.map +1 -1
  285. package/build/dist/Server/Services/StatusPageService.js +29 -9
  286. package/build/dist/Server/Services/StatusPageService.js.map +1 -1
  287. package/build/dist/Server/Services/StatusPageSubscriberService.js +393 -130
  288. package/build/dist/Server/Services/StatusPageSubscriberService.js.map +1 -1
  289. package/build/dist/Server/Services/TeamMemberService.js +10 -2
  290. package/build/dist/Server/Services/TeamMemberService.js.map +1 -1
  291. package/build/dist/Server/Services/TelemetryAttributeService.js +83 -6
  292. package/build/dist/Server/Services/TelemetryAttributeService.js.map +1 -1
  293. package/build/dist/Server/Services/UserNotificationRuleService.js +10 -2
  294. package/build/dist/Server/Services/UserNotificationRuleService.js.map +1 -1
  295. package/build/dist/Server/Services/UserService.js +8 -3
  296. package/build/dist/Server/Services/UserService.js.map +1 -1
  297. package/build/dist/Server/Services/UserWhatsAppService.js +10 -2
  298. package/build/dist/Server/Services/UserWhatsAppService.js.map +1 -1
  299. package/build/dist/Server/Services/WorkflowService.js +7 -2
  300. package/build/dist/Server/Services/WorkflowService.js.map +1 -1
  301. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js +367 -180
  302. package/build/dist/Server/Services/WorkspaceNotificationRuleService.js.map +1 -1
  303. package/build/dist/Server/Types/Domain.js +12 -6
  304. package/build/dist/Server/Types/Domain.js.map +1 -1
  305. package/build/dist/Server/Types/Workflow/Components/API/Post.js +11 -7
  306. package/build/dist/Server/Types/Workflow/Components/API/Post.js.map +1 -1
  307. package/build/dist/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.js +11 -4
  308. package/build/dist/Server/Types/Workflow/Components/BaseModel/OnTriggerBaseModel.js.map +1 -1
  309. package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js +7 -0
  310. package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js.map +1 -1
  311. package/build/dist/Server/Utils/CodeRepository/CodeRepository.js +45 -17
  312. package/build/dist/Server/Utils/CodeRepository/CodeRepository.js.map +1 -1
  313. package/build/dist/Server/Utils/Express.js.map +1 -1
  314. package/build/dist/Server/Utils/Greenlock/Greenlock.js +36 -29
  315. package/build/dist/Server/Utils/Greenlock/Greenlock.js.map +1 -1
  316. package/build/dist/Server/Utils/LLM/LLMService.js +18 -6
  317. package/build/dist/Server/Utils/LLM/LLMService.js.map +1 -1
  318. package/build/dist/Server/Utils/Logger.js +61 -13
  319. package/build/dist/Server/Utils/Logger.js.map +1 -1
  320. package/build/dist/Server/Utils/Monitor/MonitorAlert.js +23 -20
  321. package/build/dist/Server/Utils/Monitor/MonitorAlert.js.map +1 -1
  322. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +13 -4
  323. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
  324. package/build/dist/Server/Utils/Monitor/MonitorIncident.js +25 -22
  325. package/build/dist/Server/Utils/Monitor/MonitorIncident.js.map +1 -1
  326. package/build/dist/Server/Utils/Monitor/MonitorStatusTimeline.js +6 -3
  327. package/build/dist/Server/Utils/Monitor/MonitorStatusTimeline.js.map +1 -1
  328. package/build/dist/Server/Utils/Profiling.js +9 -6
  329. package/build/dist/Server/Utils/Profiling.js.map +1 -1
  330. package/build/dist/Server/Utils/Realtime.js +50 -34
  331. package/build/dist/Server/Utils/Realtime.js.map +1 -1
  332. package/build/dist/Server/Utils/Response.js +2 -2
  333. package/build/dist/Server/Utils/Response.js.map +1 -1
  334. package/build/dist/Server/Utils/StartServer.js +23 -11
  335. package/build/dist/Server/Utils/StartServer.js.map +1 -1
  336. package/build/dist/Server/Utils/Telemetry/SpanUtil.js +52 -0
  337. package/build/dist/Server/Utils/Telemetry/SpanUtil.js.map +1 -0
  338. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js +58 -15
  339. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Alert.js.map +1 -1
  340. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js +58 -15
  341. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/AlertEpisode.js.map +1 -1
  342. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js +19 -5
  343. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Auth.js.map +1 -1
  344. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js +90 -26
  345. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Incident.js.map +1 -1
  346. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Monitor.js +12 -3
  347. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/Monitor.js.map +1 -1
  348. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/OnCallDutyPolicy.js +25 -7
  349. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/OnCallDutyPolicy.js.map +1 -1
  350. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.js +58 -19
  351. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/Actions/ScheduledMaintenance.js.map +1 -1
  352. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +102 -29
  353. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  354. package/build/dist/Server/Utils/Workspace/Slack/Actions/Alert.js +38 -9
  355. package/build/dist/Server/Utils/Workspace/Slack/Actions/Alert.js.map +1 -1
  356. package/build/dist/Server/Utils/Workspace/Slack/Actions/AlertEpisode.js +34 -8
  357. package/build/dist/Server/Utils/Workspace/Slack/Actions/AlertEpisode.js.map +1 -1
  358. package/build/dist/Server/Utils/Workspace/Slack/Actions/Auth.js +3 -1
  359. package/build/dist/Server/Utils/Workspace/Slack/Actions/Auth.js.map +1 -1
  360. package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js +55 -13
  361. package/build/dist/Server/Utils/Workspace/Slack/Actions/Incident.js.map +1 -1
  362. package/build/dist/Server/Utils/Workspace/Slack/Actions/IncidentEpisode.js +5 -1
  363. package/build/dist/Server/Utils/Workspace/Slack/Actions/IncidentEpisode.js.map +1 -1
  364. package/build/dist/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.js +91 -26
  365. package/build/dist/Server/Utils/Workspace/Slack/Actions/ScheduledMaintenance.js.map +1 -1
  366. package/build/dist/Server/Utils/Workspace/Slack/Slack.js +355 -270
  367. package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
  368. package/build/dist/Server/Utils/Workspace/Workspace.js +21 -12
  369. package/build/dist/Server/Utils/Workspace/Workspace.js.map +1 -1
  370. package/build/dist/Server/Utils/Workspace/WorkspaceBase.js +3 -1
  371. package/build/dist/Server/Utils/Workspace/WorkspaceBase.js.map +1 -1
  372. package/build/dist/Server/Utils/Workspace/WorkspaceMessages/Alert.js +9 -2
  373. package/build/dist/Server/Utils/Workspace/WorkspaceMessages/Alert.js.map +1 -1
  374. package/build/dist/Tests/Server/Middleware/UserAuthorization.test.js +1 -1
  375. package/build/dist/Tests/Server/Middleware/UserAuthorization.test.js.map +1 -1
  376. package/build/dist/Tests/Server/Services/AnalyticsDatabaseService.test.js +12 -6
  377. package/build/dist/Tests/Server/Services/AnalyticsDatabaseService.test.js.map +1 -1
  378. package/build/dist/UI/Components/BulkUpdate/BulkUpdateForm.js +31 -30
  379. package/build/dist/UI/Components/BulkUpdate/BulkUpdateForm.js.map +1 -1
  380. package/build/dist/UI/Components/Charts/Area/AreaChart.js +20 -2
  381. package/build/dist/UI/Components/Charts/Area/AreaChart.js.map +1 -1
  382. package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js +2 -2
  383. package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js.map +1 -1
  384. package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js +9 -2
  385. package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js.map +1 -1
  386. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +9 -2
  387. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -1
  388. package/build/dist/UI/Components/Charts/ChartLibrary/Types/FormattedExemplarPoint.js +2 -0
  389. package/build/dist/UI/Components/Charts/ChartLibrary/Types/FormattedExemplarPoint.js.map +1 -0
  390. package/build/dist/UI/Components/Charts/Line/LineChart.js +20 -2
  391. package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
  392. package/build/dist/UI/Components/Charts/Types/ExemplarPoint.js +2 -0
  393. package/build/dist/UI/Components/Charts/Types/ExemplarPoint.js.map +1 -0
  394. package/build/dist/UI/Components/Dictionary/Dictionary.js +9 -1
  395. package/build/dist/UI/Components/Dictionary/Dictionary.js.map +1 -1
  396. package/build/dist/UI/Components/Filters/FiltersForm.js +1 -1
  397. package/build/dist/UI/Components/Filters/FiltersForm.js.map +1 -1
  398. package/build/dist/UI/Components/Filters/JSONFilter.js +1 -1
  399. package/build/dist/UI/Components/Filters/JSONFilter.js.map +1 -1
  400. package/build/dist/UI/Components/Markdown.tsx/MarkdownViewer.js +3 -3
  401. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +9 -5
  402. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  403. package/build/dist/UI/Components/Navbar/NavBar.js +9 -1
  404. package/build/dist/UI/Components/Navbar/NavBar.js.map +1 -1
  405. package/package.json +1 -1
@@ -7,6 +7,47 @@ import ConfigLogLevel from "../Types/ConfigLogLevel";
7
7
 
8
8
  export type LogBody = string | JSONObject | Exception | Error | unknown;
9
9
 
10
+ export interface LogAttributes {
11
+ userId?: string | undefined;
12
+ projectId?: string | undefined;
13
+ requestId?: string | undefined;
14
+ [key: string]: string | number | boolean | undefined;
15
+ }
16
+
17
+ export interface RequestLike {
18
+ requestId?: string;
19
+ tenantId?: { toString(): string };
20
+ userAuthorization?: { userId?: { toString(): string } };
21
+ }
22
+
23
+ export function getLogAttributesFromRequest(
24
+ req?: RequestLike | null,
25
+ ): LogAttributes {
26
+ if (!req) {
27
+ return {};
28
+ }
29
+
30
+ try {
31
+ const attributes: LogAttributes = {};
32
+
33
+ if (req.requestId) {
34
+ attributes.requestId = req.requestId;
35
+ }
36
+
37
+ if (req.tenantId) {
38
+ attributes.projectId = req.tenantId.toString();
39
+ }
40
+
41
+ if (req.userAuthorization?.userId) {
42
+ attributes.userId = req.userAuthorization.userId.toString();
43
+ }
44
+
45
+ return attributes;
46
+ } catch {
47
+ return {};
48
+ }
49
+ }
50
+
10
51
  export default class logger {
11
52
  public static getLogLevel(): ConfigLogLevel {
12
53
  if (!LogLevel) {
@@ -25,7 +66,31 @@ export default class logger {
25
66
  return JSON.stringify(body);
26
67
  }
27
68
 
28
- public static info(message: LogBody): void {
69
+ private static sanitizeAttributes(
70
+ attributes?: LogAttributes,
71
+ ): Record<string, string | number | boolean> | undefined {
72
+ if (!attributes) {
73
+ return undefined;
74
+ }
75
+
76
+ try {
77
+ const sanitized: Record<string, string | number | boolean> = {};
78
+
79
+ for (const key in attributes) {
80
+ const value: string | number | boolean | undefined = attributes[key];
81
+
82
+ if (value !== undefined && value !== null) {
83
+ sanitized[key] = value;
84
+ }
85
+ }
86
+
87
+ return Object.keys(sanitized).length > 0 ? sanitized : undefined;
88
+ } catch {
89
+ return undefined;
90
+ }
91
+ }
92
+
93
+ public static info(message: LogBody, attributes?: LogAttributes): void {
29
94
  const logLevel: ConfigLogLevel = this.getLogLevel();
30
95
 
31
96
  if (logLevel === ConfigLogLevel.DEBUG || logLevel === ConfigLogLevel.INFO) {
@@ -35,11 +100,12 @@ export default class logger {
35
100
  this.emit({
36
101
  body: message,
37
102
  severityNumber: SeverityNumber.INFO,
103
+ attributes,
38
104
  });
39
105
  }
40
106
  }
41
107
 
42
- public static error(message: LogBody): void {
108
+ public static error(message: LogBody, attributes?: LogAttributes): void {
43
109
  const logLevel: ConfigLogLevel = this.getLogLevel();
44
110
 
45
111
  if (
@@ -54,11 +120,12 @@ export default class logger {
54
120
  this.emit({
55
121
  body: message,
56
122
  severityNumber: SeverityNumber.ERROR,
123
+ attributes,
57
124
  });
58
125
  }
59
126
  }
60
127
 
61
- public static warn(message: LogBody): void {
128
+ public static warn(message: LogBody, attributes?: LogAttributes): void {
62
129
  const logLevel: ConfigLogLevel = this.getLogLevel();
63
130
 
64
131
  if (
@@ -72,11 +139,12 @@ export default class logger {
72
139
  this.emit({
73
140
  body: message,
74
141
  severityNumber: SeverityNumber.WARN,
142
+ attributes,
75
143
  });
76
144
  }
77
145
  }
78
146
 
79
- public static debug(message: LogBody): void {
147
+ public static debug(message: LogBody, attributes?: LogAttributes): void {
80
148
  const logLevel: ConfigLogLevel = this.getLogLevel();
81
149
 
82
150
  if (logLevel === ConfigLogLevel.DEBUG) {
@@ -86,6 +154,7 @@ export default class logger {
86
154
  this.emit({
87
155
  body: message,
88
156
  severityNumber: SeverityNumber.DEBUG,
157
+ attributes,
89
158
  });
90
159
  }
91
160
  }
@@ -93,20 +162,30 @@ export default class logger {
93
162
  public static emit(data: {
94
163
  body: LogBody;
95
164
  severityNumber: SeverityNumber;
165
+ attributes?: LogAttributes | undefined;
96
166
  }): void {
97
- const logger: TelemetryLogger | null = OneUptimeTelemetry.getLogger();
167
+ try {
168
+ const logger: TelemetryLogger | null = OneUptimeTelemetry.getLogger();
98
169
 
99
- if (logger === null) {
100
- return;
101
- }
170
+ if (logger === null) {
171
+ return;
172
+ }
102
173
 
103
- logger.emit({
104
- body: this.serializeLogBody(data.body),
105
- severityNumber: data.severityNumber,
106
- });
174
+ const sanitizedAttributes:
175
+ | Record<string, string | number | boolean>
176
+ | undefined = this.sanitizeAttributes(data.attributes);
177
+
178
+ logger.emit({
179
+ body: this.serializeLogBody(data.body),
180
+ severityNumber: data.severityNumber,
181
+ ...(sanitizedAttributes ? { attributes: sanitizedAttributes } : {}),
182
+ });
183
+ } catch {
184
+ // Never let logging errors propagate
185
+ }
107
186
  }
108
187
 
109
- public static trace(message: LogBody): void {
188
+ public static trace(message: LogBody, attributes?: LogAttributes): void {
110
189
  const logLevel: ConfigLogLevel = this.getLogLevel();
111
190
 
112
191
  if (logLevel === ConfigLogLevel.DEBUG) {
@@ -116,6 +195,7 @@ export default class logger {
116
195
  this.emit({
117
196
  body: message,
118
197
  severityNumber: SeverityNumber.DEBUG,
198
+ attributes,
119
199
  });
120
200
  }
121
201
  }
@@ -17,7 +17,7 @@ import { DisableAutomaticAlertCreation } from "../../EnvironmentConfig";
17
17
  import AlertService from "../../Services/AlertService";
18
18
  import AlertSeverityService from "../../Services/AlertSeverityService";
19
19
  import AlertStateTimelineService from "../../Services/AlertStateTimelineService";
20
- import logger from "../Logger";
20
+ import logger, { LogAttributes } from "../Logger";
21
21
  import CaptureSpan from "../Telemetry/CaptureSpan";
22
22
  import DataToProcess from "./DataToProcess";
23
23
  import MonitorTemplateUtil from "./MonitorTemplateUtil";
@@ -104,8 +104,15 @@ export default class MonitorAlert {
104
104
  telemetryQuery?: TelemetryQuery | undefined;
105
105
  };
106
106
  }): Promise<void> {
107
+ const alertLogAttributes: LogAttributes = {
108
+ projectId: input.monitor.projectId?.toString(),
109
+ };
110
+
107
111
  // check open alerts
108
- logger.debug(`${input.monitor.id?.toString()} - Check open alerts.`);
112
+ logger.debug(
113
+ `${input.monitor.id?.toString()} - Check open alerts.`,
114
+ alertLogAttributes,
115
+ );
109
116
  // check active alerts and if there are open alerts, do not cretae anothr alert.
110
117
  const openAlerts: Array<Alert> =
111
118
  await this.checkOpenAlertsAndCloseIfResolved({
@@ -137,10 +144,12 @@ export default class MonitorAlert {
137
144
 
138
145
  logger.debug(
139
146
  `${input.monitor.id?.toString()} - Open Alert ${alreadyOpenAlert?.id?.toString()}`,
147
+ alertLogAttributes,
140
148
  );
141
149
 
142
150
  logger.debug(
143
151
  `${input.monitor.id?.toString()} - Has open alert ${hasAlreadyOpenAlert}`,
152
+ alertLogAttributes,
144
153
  );
145
154
 
146
155
  if (hasAlreadyOpenAlert) {
@@ -161,7 +170,10 @@ export default class MonitorAlert {
161
170
 
162
171
  // create alert here.
163
172
 
164
- logger.debug(`${input.monitor.id?.toString()} - Create alert.`);
173
+ logger.debug(
174
+ `${input.monitor.id?.toString()} - Create alert.`,
175
+ alertLogAttributes,
176
+ );
165
177
 
166
178
  const alert: Alert = new Alert();
167
179
  const storageMap: JSONObject =
@@ -1,4 +1,4 @@
1
- import logger from "../Logger";
1
+ import logger, { LogAttributes } from "../Logger";
2
2
  import LogAggregationService from "../../Services/LogAggregationService";
3
3
  import VMUtil from "../VM/VMAPI";
4
4
  import APIRequestCriteria from "./Criteria/APIRequestCriteria";
@@ -284,7 +284,9 @@ ${contextBlock}
284
284
  .responseBody as string) || "{}",
285
285
  );
286
286
  } catch (err) {
287
- logger.error(err);
287
+ logger.error(err, {
288
+ projectId: input.monitor.projectId?.toString(),
289
+ });
288
290
  responseBody = (input.dataToProcess as ProbeMonitorResponse)
289
291
  .responseBody as JSONObject;
290
292
  }
@@ -331,7 +333,9 @@ ${contextBlock}
331
333
  },
332
334
  });
333
335
  } catch (err) {
334
- logger.error(err);
336
+ logger.error(err, {
337
+ projectId: input.monitor.projectId?.toString(),
338
+ });
335
339
  return null;
336
340
  }
337
341
 
@@ -903,8 +907,14 @@ ${contextBlock}
903
907
  );
904
908
  }
905
909
  } catch (err) {
906
- logger.error("Failed to fetch container logs for root cause context");
907
- logger.error(err);
910
+ const k8sLogAttributes: LogAttributes = {
911
+ projectId: input.monitor.projectId?.toString(),
912
+ };
913
+ logger.error(
914
+ "Failed to fetch container logs for root cause context",
915
+ k8sLogAttributes,
916
+ );
917
+ logger.error(err, k8sLogAttributes);
908
918
  }
909
919
  }
910
920
  }
@@ -19,7 +19,7 @@ import IncidentService from "../../Services/IncidentService";
19
19
  import IncidentSeverityService from "../../Services/IncidentSeverityService";
20
20
  import IncidentStateTimelineService from "../../Services/IncidentStateTimelineService";
21
21
  import IncidentMemberService from "../../Services/IncidentMemberService";
22
- import logger from "../Logger";
22
+ import logger, { LogAttributes } from "../Logger";
23
23
  import CaptureSpan from "../Telemetry/CaptureSpan";
24
24
  import DataToProcess from "./DataToProcess";
25
25
  import MonitorTemplateUtil from "./MonitorTemplateUtil";
@@ -113,8 +113,15 @@ export default class MonitorIncident {
113
113
  telemetryQuery?: TelemetryQuery | undefined;
114
114
  };
115
115
  }): Promise<void> {
116
+ const incidentLogAttributes: LogAttributes = {
117
+ projectId: input.monitor.projectId?.toString(),
118
+ };
119
+
116
120
  // check open incidents
117
- logger.debug(`${input.monitor.id?.toString()} - Check open incidents.`);
121
+ logger.debug(
122
+ `${input.monitor.id?.toString()} - Check open incidents.`,
123
+ incidentLogAttributes,
124
+ );
118
125
  // check active incidents and if there are open incidents, do not cretae anothr incident.
119
126
  const openIncidents: Array<Incident> =
120
127
  await this.checkOpenIncidentsAndCloseIfResolved({
@@ -149,10 +156,12 @@ export default class MonitorIncident {
149
156
 
150
157
  logger.debug(
151
158
  `${input.monitor.id?.toString()} - Open Incident ${alreadyOpenIncident?.id?.toString()}`,
159
+ incidentLogAttributes,
152
160
  );
153
161
 
154
162
  logger.debug(
155
163
  `${input.monitor.id?.toString()} - Has open incident ${hasAlreadyOpenIncident}`,
164
+ incidentLogAttributes,
156
165
  );
157
166
 
158
167
  if (hasAlreadyOpenIncident) {
@@ -171,7 +180,10 @@ export default class MonitorIncident {
171
180
  continue;
172
181
  }
173
182
 
174
- logger.debug(`${input.monitor.id?.toString()} - Create incident.`);
183
+ logger.debug(
184
+ `${input.monitor.id?.toString()} - Create incident.`,
185
+ incidentLogAttributes,
186
+ );
175
187
 
176
188
  const incident: Incident = new Incident();
177
189
  const storageMap: JSONObject =
@@ -341,11 +353,13 @@ export default class MonitorIncident {
341
353
 
342
354
  logger.debug(
343
355
  `${input.monitor.id?.toString()} - Assigned incident member role ${assignment.roleId.toString()} to user ${assignment.userId.toString()}`,
356
+ incidentLogAttributes,
344
357
  );
345
358
  }
346
359
  } catch (memberError) {
347
360
  logger.error(
348
361
  `${input.monitor.id?.toString()} - Failed to assign incident member role: ${memberError}`,
362
+ incidentLogAttributes,
349
363
  );
350
364
  }
351
365
  }
@@ -6,7 +6,7 @@ import MonitorCriteriaInstance from "../../../Types/Monitor/MonitorCriteriaInsta
6
6
  import ObjectID from "../../../Types/ObjectID";
7
7
  import { TelemetryQuery } from "../../../Types/Telemetry/TelemetryQuery";
8
8
  import MonitorStatusTimelineService from "../../Services/MonitorStatusTimelineService";
9
- import logger from "../Logger";
9
+ import logger, { LogAttributes } from "../Logger";
10
10
  import CaptureSpan from "../Telemetry/CaptureSpan";
11
11
  import DataToProcess from "./DataToProcess";
12
12
 
@@ -71,8 +71,13 @@ export default class MonitorStatusTimelineUtil {
71
71
  }
72
72
 
73
73
  if (shouldUpdateStatus) {
74
+ const monitorLogAttributes: LogAttributes = {
75
+ projectId: input.monitor.projectId?.toString(),
76
+ };
77
+
74
78
  logger.debug(
75
79
  `${input.monitor.id?.toString()} - Change monitor status to ${input.criteriaInstance.data?.monitorStatusId?.toString()}`,
80
+ monitorLogAttributes,
76
81
  );
77
82
  // change monitor status
78
83
 
@@ -1,6 +1,6 @@
1
1
  import Pyroscope from "@pyroscope/nodejs";
2
2
  import { EnableProfiling } from "../EnvironmentConfig";
3
- import logger from "./Logger";
3
+ import logger, { LogAttributes } from "./Logger";
4
4
 
5
5
  export default class Profiling {
6
6
  public static init(data: { serviceName: string }): void {
@@ -11,9 +11,14 @@ export default class Profiling {
11
11
  const serverAddress: string | undefined = this.getServerAddress();
12
12
  const authToken: string | undefined = this.getAuthToken();
13
13
 
14
+ const profilingLogAttributes: LogAttributes = {
15
+ serviceName: data.serviceName,
16
+ };
17
+
14
18
  if (!serverAddress) {
15
19
  logger.warn(
16
20
  "Profiling enabled but OPENTELEMETRY_EXPORTER_OTLP_ENDPOINT not configured. Skipping profiling initialization.",
21
+ profilingLogAttributes,
17
22
  );
18
23
  return;
19
24
  }
@@ -32,16 +37,17 @@ export default class Profiling {
32
37
 
33
38
  logger.info(
34
39
  `Profiling initialized for service: ${data.serviceName} -> ${serverAddress}`,
40
+ profilingLogAttributes,
35
41
  );
36
42
  } catch (err) {
37
- logger.error("Failed to initialize profiling:");
38
- logger.error(err);
43
+ logger.error("Failed to initialize profiling:", profilingLogAttributes);
44
+ logger.error(err, profilingLogAttributes);
39
45
  }
40
46
 
41
47
  process.on("SIGTERM", () => {
42
48
  Pyroscope.stop().catch((err: unknown) => {
43
- logger.error("Error stopping profiler:");
44
- logger.error(err);
49
+ logger.error("Error stopping profiler:", profilingLogAttributes);
50
+ logger.error(err, profilingLogAttributes);
45
51
  });
46
52
  });
47
53
  }
@@ -1,5 +1,5 @@
1
1
  import IO, { Socket, SocketServer } from "../Infrastructure/SocketIO";
2
- import logger from "./Logger";
2
+ import logger, { LogAttributes } from "./Logger";
3
3
  import AnalyticsBaseModel from "../../Models/AnalyticsModels/AnalyticsBaseModel/AnalyticsBaseModel";
4
4
  import BaseModel from "../../Models/DatabaseModels/DatabaseBaseModel/DatabaseBaseModel";
5
5
  import DatabaseType from "../../Types/BaseDatabase/DatabaseType";
@@ -49,20 +49,24 @@ export default abstract class Realtime {
49
49
  logger.debug("Received ListenToModalEvent with data:");
50
50
  logger.debug(data);
51
51
 
52
+ const socketLogAttributes: LogAttributes = {
53
+ projectId: data["tenantId"]?.toString(),
54
+ };
55
+
52
56
  if (typeof data["eventType"] !== "string") {
53
- logger.error("eventType is not a string");
57
+ logger.error("eventType is not a string", socketLogAttributes);
54
58
  throw new BadDataException("eventType is not a string");
55
59
  }
56
60
  if (typeof data["modelType"] !== "string") {
57
- logger.error("modelType is not a string");
61
+ logger.error("modelType is not a string", socketLogAttributes);
58
62
  throw new BadDataException("modelType is not a string");
59
63
  }
60
64
  if (typeof data["modelName"] !== "string") {
61
- logger.error("modelName is not a string");
65
+ logger.error("modelName is not a string", socketLogAttributes);
62
66
  throw new BadDataException("modelName is not a string");
63
67
  }
64
68
  if (typeof data["tenantId"] !== "string") {
65
- logger.error("tenantId is not a string");
69
+ logger.error("tenantId is not a string", socketLogAttributes);
66
70
  throw new BadDataException("tenantId is not a string");
67
71
  }
68
72
 
@@ -84,11 +88,18 @@ export default abstract class Realtime {
84
88
  socket: Socket,
85
89
  data: ListenToModelEventJSON,
86
90
  ): Promise<void> {
87
- logger.debug("Listening to model event with data:");
88
- logger.debug(data);
91
+ const listenLogAttributes: LogAttributes = {
92
+ projectId: data.tenantId?.toString(),
93
+ };
94
+
95
+ logger.debug("Listening to model event with data:", listenLogAttributes);
96
+ logger.debug(data, listenLogAttributes);
89
97
 
90
98
  if (!this.socketServer) {
91
- logger.debug("Socket server not initialized, initializing now");
99
+ logger.debug(
100
+ "Socket server not initialized, initializing now",
101
+ listenLogAttributes,
102
+ );
92
103
  await this.init();
93
104
  }
94
105
 
@@ -97,42 +108,56 @@ export default abstract class Realtime {
97
108
  * and to this model and to this event type
98
109
  */
99
110
 
100
- logger.debug("Extracting user access token from socket");
111
+ logger.debug(
112
+ "Extracting user access token from socket",
113
+ listenLogAttributes,
114
+ );
101
115
  const userAccessToken: string | undefined =
102
116
  this.getAccessTokenFromSocket(socket);
103
117
 
104
118
  if (!userAccessToken) {
105
119
  logger.debug(
106
120
  "User access token not found in socket, aborting joining room",
121
+ listenLogAttributes,
107
122
  );
108
123
  return;
109
124
  }
110
125
 
111
- logger.debug("Decoding user access token");
126
+ logger.debug("Decoding user access token", listenLogAttributes);
112
127
  const userAuthorizationData: JSONWebTokenData =
113
128
  JSONWebToken.decode(userAccessToken);
114
129
 
115
130
  if (!userAuthorizationData) {
116
131
  logger.debug(
117
132
  "User authorization data not found in socket, aborting joining room",
133
+ listenLogAttributes,
118
134
  );
119
135
  return;
120
136
  }
121
137
 
122
138
  if (!userAuthorizationData.userId) {
123
- logger.debug("User ID not found in socket, aborting joining room");
139
+ logger.debug(
140
+ "User ID not found in socket, aborting joining room",
141
+ listenLogAttributes,
142
+ );
124
143
  return;
125
144
  }
126
145
 
127
- logger.debug("Checking user access permissions");
146
+ logger.debug("Checking user access permissions", listenLogAttributes);
128
147
  let hasAccess: boolean = false;
129
148
 
130
149
  if (userAuthorizationData.isMasterAdmin) {
131
- logger.debug("User is a master admin, granting access");
150
+ logger.debug(
151
+ "User is a master admin, granting access",
152
+ listenLogAttributes,
153
+ );
132
154
  hasAccess = true;
133
155
  }
134
156
 
135
- logger.debug("Fetching user global access permissions");
157
+ logger.debug(
158
+ "Fetching user global access permissions",
159
+ listenLogAttributes,
160
+ );
136
161
  const userGlobalAccessPermission: UserGlobalAccessPermission | null =
137
162
  await UserPermissionUtil.getUserGlobalAccessPermissionFromCache(
138
163
  userAuthorizationData.userId,
@@ -140,7 +165,10 @@ export default abstract class Realtime {
140
165
 
141
166
  // check if the user has access to this tenant
142
167
  if (userGlobalAccessPermission && !hasAccess) {
143
- logger.debug("Checking if user has access to the tenant");
168
+ logger.debug(
169
+ "Checking if user has access to the tenant",
170
+ listenLogAttributes,
171
+ );
144
172
  const hasAccessToProjectId: boolean =
145
173
  userGlobalAccessPermission.projectIds.some((projectId: ObjectID) => {
146
174
  return projectId.toString() === data.tenantId.toString();
@@ -149,11 +177,15 @@ export default abstract class Realtime {
149
177
  if (!hasAccessToProjectId) {
150
178
  logger.debug(
151
179
  "User does not have access to this tenant, aborting joining room",
180
+ listenLogAttributes,
152
181
  );
153
182
  return;
154
183
  }
155
184
 
156
- logger.debug("User has access to the tenant, checking model access");
185
+ logger.debug(
186
+ "User has access to the tenant, checking model access",
187
+ listenLogAttributes,
188
+ );
157
189
  const userId: ObjectID = new ObjectID(
158
190
  userAuthorizationData.userId.toString(),
159
191
  );
@@ -174,7 +206,10 @@ export default abstract class Realtime {
174
206
  data.modelName,
175
207
  )
176
208
  ) {
177
- logger.debug("User has access to the model, granting access");
209
+ logger.debug(
210
+ "User has access to the model, granting access",
211
+ listenLogAttributes,
212
+ );
178
213
  hasAccess = true;
179
214
  }
180
215
  }
@@ -182,6 +217,7 @@ export default abstract class Realtime {
182
217
  if (!hasAccess) {
183
218
  logger.debug(
184
219
  "User does not have access to this tenant, aborting joining room",
220
+ listenLogAttributes,
185
221
  );
186
222
  return;
187
223
  }
@@ -194,7 +230,7 @@ export default abstract class Realtime {
194
230
  data.modelId,
195
231
  );
196
232
 
197
- logger.debug(`Joining room with ID: ${modelRoomId}`);
233
+ logger.debug(`Joining room with ID: ${modelRoomId}`, listenLogAttributes);
198
234
  // join the room.
199
235
  await socket.join(modelRoomId);
200
236
  } else {
@@ -204,7 +240,7 @@ export default abstract class Realtime {
204
240
  data.eventType,
205
241
  );
206
242
 
207
- logger.debug(`Joining room with ID: ${roomId}`);
243
+ logger.debug(`Joining room with ID: ${roomId}`, listenLogAttributes);
208
244
  // join the room.
209
245
  await socket.join(roomId);
210
246
  }
@@ -215,11 +251,21 @@ export default abstract class Realtime {
215
251
  socket: Socket,
216
252
  data: ListenToModelEventJSON,
217
253
  ): Promise<void> {
218
- logger.debug("Stopping listening to model event with data:");
219
- logger.debug(data);
254
+ const stopLogAttributes: LogAttributes = {
255
+ projectId: data.tenantId?.toString(),
256
+ };
257
+
258
+ logger.debug(
259
+ "Stopping listening to model event with data:",
260
+ stopLogAttributes,
261
+ );
262
+ logger.debug(data, stopLogAttributes);
220
263
 
221
264
  if (!this.socketServer) {
222
- logger.debug("Socket server not initialized, initializing now");
265
+ logger.debug(
266
+ "Socket server not initialized, initializing now",
267
+ stopLogAttributes,
268
+ );
223
269
  await this.init();
224
270
  }
225
271
 
@@ -230,7 +276,7 @@ export default abstract class Realtime {
230
276
  data.modelId,
231
277
  );
232
278
 
233
- logger.debug(`Leaving room with ID: ${roomId}`);
279
+ logger.debug(`Leaving room with ID: ${roomId}`, stopLogAttributes);
234
280
  // leave this room.
235
281
  await socket.leave(roomId);
236
282
  }
@@ -242,13 +288,20 @@ export default abstract class Realtime {
242
288
  modelId: ObjectID;
243
289
  modelType: { new (): BaseModel | AnalyticsBaseModel };
244
290
  }): Promise<void> {
245
- logger.debug("Emitting model event with data:");
246
- logger.debug(`Tenant ID: ${data.tenantId}`);
247
- logger.debug(`Event Type: ${data.eventType}`);
248
- logger.debug(`Model ID: ${data.modelId}`);
291
+ const emitLogAttributes: LogAttributes = {
292
+ projectId: data.tenantId?.toString(),
293
+ };
294
+
295
+ logger.debug("Emitting model event with data:", emitLogAttributes);
296
+ logger.debug(`Tenant ID: ${data.tenantId}`, emitLogAttributes);
297
+ logger.debug(`Event Type: ${data.eventType}`, emitLogAttributes);
298
+ logger.debug(`Model ID: ${data.modelId}`, emitLogAttributes);
249
299
 
250
300
  if (!this.socketServer) {
251
- logger.debug("Socket server not initialized, initializing now");
301
+ logger.debug(
302
+ "Socket server not initialized, initializing now",
303
+ emitLogAttributes,
304
+ );
252
305
  await this.init();
253
306
  }
254
307
 
@@ -259,7 +312,10 @@ export default abstract class Realtime {
259
312
  const model: BaseModel | AnalyticsBaseModel = new data.modelType();
260
313
 
261
314
  if (!model.tableName) {
262
- logger.warn("Model does not have a tableName, aborting emit");
315
+ logger.warn(
316
+ "Model does not have a tableName, aborting emit",
317
+ emitLogAttributes,
318
+ );
263
319
  return;
264
320
  }
265
321
 
@@ -276,8 +332,11 @@ export default abstract class Realtime {
276
332
  data.modelId,
277
333
  );
278
334
 
279
- logger.debug(`Emitting event to room with ID: ${roomId}`);
280
- logger.debug(jsonObject);
335
+ logger.debug(
336
+ `Emitting event to room with ID: ${roomId}`,
337
+ emitLogAttributes,
338
+ );
339
+ logger.debug(jsonObject, emitLogAttributes);
281
340
 
282
341
  this.socketServer!.to(roomId).emit(roomId, jsonObject);
283
342
  this.socketServer!.to(modelRoomId).emit(modelRoomId, jsonObject);
@@ -5,7 +5,7 @@ import {
5
5
  OneUptimeResponse,
6
6
  } from "./Express";
7
7
  import JsonToCsv from "./JsonToCsv";
8
- import logger from "./Logger";
8
+ import logger, { getLogAttributesFromRequest } from "./Logger";
9
9
  import AnalyticsDataModel, {
10
10
  AnalyticsBaseModelType,
11
11
  } from "../../Models/AnalyticsModels/AnalyticsBaseModel/AnalyticsBaseModel";
@@ -109,7 +109,7 @@ export default class Response {
109
109
  const status: number = error.code || 500;
110
110
  const message: string = error.message || "Server Error";
111
111
 
112
- logger.error(error);
112
+ logger.error(error, getLogAttributesFromRequest(_req as any));
113
113
 
114
114
  oneUptimeResponse.status(status).send({ message });
115
115
  }