@oneuptime/common 10.0.39 → 10.0.40

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 (282) hide show
  1. package/Models/AnalyticsModels/Index.ts +4 -0
  2. package/Models/AnalyticsModels/Profile.ts +687 -0
  3. package/Models/AnalyticsModels/ProfileSample.ts +547 -0
  4. package/Models/DatabaseModels/Dashboard.ts +357 -0
  5. package/Models/DatabaseModels/DashboardDomain.ts +658 -0
  6. package/Models/DatabaseModels/Index.ts +2 -0
  7. package/Models/DatabaseModels/StatusPage.ts +41 -0
  8. package/Server/API/DashboardAPI.ts +408 -0
  9. package/Server/API/DashboardDomainAPI.ts +235 -0
  10. package/Server/API/StatusPageAPI.ts +36 -2
  11. package/Server/API/TelemetryAPI.ts +393 -0
  12. package/Server/EnvironmentConfig.ts +12 -0
  13. package/Server/Infrastructure/Postgres/SchemaMigrations/1774524742177-MigrationName.ts +97 -0
  14. package/Server/Infrastructure/Postgres/SchemaMigrations/1774524742178-MigrationName.ts +17 -0
  15. package/Server/Infrastructure/Postgres/SchemaMigrations/1774524742179-MigrationName.ts +50 -0
  16. package/Server/Infrastructure/Postgres/SchemaMigrations/1774559064919-MigrationName.ts +59 -0
  17. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +8 -0
  18. package/Server/Middleware/UserAuthorization.ts +96 -1
  19. package/Server/Services/DashboardDomainService.ts +647 -0
  20. package/Server/Services/DashboardService.ts +174 -3
  21. package/Server/Services/IncidentService.ts +295 -50
  22. package/Server/Services/IncidentStateTimelineService.ts +1 -0
  23. package/Server/Services/Index.ts +6 -0
  24. package/Server/Services/MonitorService.ts +5 -0
  25. package/Server/Services/ProfileAggregationService.ts +559 -0
  26. package/Server/Services/ProfileSampleService.ts +11 -0
  27. package/Server/Services/ProfileService.ts +11 -0
  28. package/Server/Services/TelemetryUsageBillingService.ts +77 -3
  29. package/Server/Services/WorkspaceNotificationSummaryService.ts +15 -1
  30. package/Server/Types/Billing/MeteredPlan/AllMeteredPlans.ts +9 -0
  31. package/Server/Utils/Cookie.ts +48 -0
  32. package/Server/Utils/Monitor/Criteria/ProfileMonitorCriteria.ts +34 -0
  33. package/Server/Utils/Monitor/DataToProcess.ts +3 -1
  34. package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +299 -0
  35. package/Server/Utils/Profile/PprofEncoder.ts +225 -0
  36. package/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.ts +53 -16
  37. package/Server/Utils/Workspace/Slack/Slack.ts +26 -6
  38. package/ServiceRoute.ts +2 -0
  39. package/Types/AnalyticsDatabase/AnalyticsTableName.ts +2 -0
  40. package/Types/CookieName.ts +1 -0
  41. package/Types/Dashboard/Chart/ChartType.ts +5 -0
  42. package/Types/Dashboard/DashboardComponentType.ts +4 -0
  43. package/Types/Dashboard/DashboardComponents/ComponentArgument.ts +10 -0
  44. package/Types/Dashboard/DashboardComponents/DashboardChartComponent.ts +1 -2
  45. package/Types/Dashboard/DashboardComponents/DashboardGaugeComponent.ts +17 -0
  46. package/Types/Dashboard/DashboardComponents/DashboardLogStreamComponent.ts +15 -0
  47. package/Types/Dashboard/DashboardComponents/DashboardTableComponent.ts +14 -0
  48. package/Types/Dashboard/DashboardComponents/DashboardTextComponent.ts +1 -0
  49. package/Types/Dashboard/DashboardComponents/DashboardTraceListComponent.ts +13 -0
  50. package/Types/Dashboard/DashboardComponents/DashboardValueComponent.ts +2 -0
  51. package/Types/Dashboard/DashboardTemplates.ts +964 -0
  52. package/Types/Dashboard/DashboardVariable.ts +23 -0
  53. package/Types/Dashboard/DashboardViewConfig.ts +59 -0
  54. package/Types/Dashboard/MasterPassword.ts +10 -0
  55. package/Types/Icon/IconProp.ts +1 -0
  56. package/Types/Incident/IncidentMetricType.ts +3 -0
  57. package/Types/MeteredPlan/ProductType.ts +1 -0
  58. package/Types/Metrics/MetricQueryConfigData.ts +3 -0
  59. package/Types/Monitor/CriteriaFilter.ts +3 -0
  60. package/Types/Monitor/KubernetesAlertTemplates.ts +78 -7
  61. package/Types/Monitor/MetricMonitor/MetricMonitorResponse.ts +20 -0
  62. package/Types/Monitor/MonitorStep.ts +25 -0
  63. package/Types/Monitor/MonitorStepProfileMonitor.ts +96 -0
  64. package/Types/Monitor/MonitorType.ts +11 -0
  65. package/Types/Monitor/ProfileMonitor/ProfileMonitorResponse.ts +12 -0
  66. package/Types/Permission.ts +87 -0
  67. package/Types/Telemetry/TelemetryType.ts +1 -0
  68. package/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.ts +1 -0
  69. package/UI/Components/Button/Button.tsx +1 -1
  70. package/UI/Components/Card/Card.tsx +8 -4
  71. package/UI/Components/Charts/Area/AreaChart.tsx +4 -0
  72. package/UI/Components/Charts/Bar/BarChart.tsx +4 -0
  73. package/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.tsx +26 -0
  74. package/UI/Components/Charts/ChartLibrary/BarChart/BarChart.tsx +26 -0
  75. package/UI/Components/Charts/ChartLibrary/LineChart/LineChart.tsx +26 -0
  76. package/UI/Components/Charts/Line/LineChart.tsx +4 -0
  77. package/UI/Components/Charts/Types/ReferenceLineProps.ts +6 -0
  78. package/UI/Components/Icon/Icon.tsx +33 -0
  79. package/UI/Components/ModelTable/BaseModelTable.tsx +13 -10
  80. package/UI/Components/MoreMenu/MoreMenu.tsx +15 -2
  81. package/UI/Components/MoreMenu/MoreMenuItem.tsx +4 -4
  82. package/UI/Components/Workflow/Component.tsx +450 -209
  83. package/UI/Components/Workflow/ComponentPortViewer.tsx +57 -20
  84. package/UI/Components/Workflow/ComponentReturnValueViewer.tsx +65 -25
  85. package/UI/Components/Workflow/ComponentSettingsModal.tsx +202 -37
  86. package/UI/Components/Workflow/ComponentsModal.tsx +180 -93
  87. package/UI/Components/Workflow/Workflow.tsx +105 -9
  88. package/UI/Config.ts +9 -0
  89. package/Utils/Dashboard/Components/DashboardChartComponent.ts +53 -22
  90. package/Utils/Dashboard/Components/DashboardGaugeComponent.ts +124 -0
  91. package/Utils/Dashboard/Components/DashboardLogStreamComponent.ts +110 -0
  92. package/Utils/Dashboard/Components/DashboardTableComponent.ts +86 -0
  93. package/Utils/Dashboard/Components/DashboardTextComponent.ts +32 -7
  94. package/Utils/Dashboard/Components/DashboardTraceListComponent.ts +86 -0
  95. package/Utils/Dashboard/Components/DashboardValueComponent.ts +39 -3
  96. package/Utils/Dashboard/Components/Index.ts +28 -0
  97. package/Utils/ValueFormatter.ts +170 -0
  98. package/build/dist/Models/AnalyticsModels/Index.js +4 -0
  99. package/build/dist/Models/AnalyticsModels/Index.js.map +1 -1
  100. package/build/dist/Models/AnalyticsModels/Profile.js +621 -0
  101. package/build/dist/Models/AnalyticsModels/Profile.js.map +1 -0
  102. package/build/dist/Models/AnalyticsModels/ProfileSample.js +497 -0
  103. package/build/dist/Models/AnalyticsModels/ProfileSample.js.map +1 -0
  104. package/build/dist/Models/DatabaseModels/Dashboard.js +365 -0
  105. package/build/dist/Models/DatabaseModels/Dashboard.js.map +1 -1
  106. package/build/dist/Models/DatabaseModels/DashboardDomain.js +691 -0
  107. package/build/dist/Models/DatabaseModels/DashboardDomain.js.map +1 -0
  108. package/build/dist/Models/DatabaseModels/Index.js +2 -0
  109. package/build/dist/Models/DatabaseModels/Index.js.map +1 -1
  110. package/build/dist/Models/DatabaseModels/StatusPage.js +42 -0
  111. package/build/dist/Models/DatabaseModels/StatusPage.js.map +1 -1
  112. package/build/dist/Server/API/DashboardAPI.js +293 -0
  113. package/build/dist/Server/API/DashboardAPI.js.map +1 -0
  114. package/build/dist/Server/API/DashboardDomainAPI.js +124 -0
  115. package/build/dist/Server/API/DashboardDomainAPI.js.map +1 -0
  116. package/build/dist/Server/API/StatusPageAPI.js +26 -2
  117. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  118. package/build/dist/Server/API/TelemetryAPI.js +222 -0
  119. package/build/dist/Server/API/TelemetryAPI.js.map +1 -1
  120. package/build/dist/Server/EnvironmentConfig.js +4 -0
  121. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  122. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742177-MigrationName.js +40 -0
  123. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742177-MigrationName.js.map +1 -0
  124. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742178-MigrationName.js +12 -0
  125. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742178-MigrationName.js.map +1 -0
  126. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742179-MigrationName.js +23 -0
  127. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774524742179-MigrationName.js.map +1 -0
  128. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774559064919-MigrationName.js +26 -0
  129. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774559064919-MigrationName.js.map +1 -0
  130. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +8 -0
  131. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  132. package/build/dist/Server/Middleware/UserAuthorization.js +41 -0
  133. package/build/dist/Server/Middleware/UserAuthorization.js.map +1 -1
  134. package/build/dist/Server/Services/DashboardDomainService.js +595 -0
  135. package/build/dist/Server/Services/DashboardDomainService.js.map +1 -0
  136. package/build/dist/Server/Services/DashboardService.js +117 -3
  137. package/build/dist/Server/Services/DashboardService.js.map +1 -1
  138. package/build/dist/Server/Services/IncidentService.js +231 -55
  139. package/build/dist/Server/Services/IncidentService.js.map +1 -1
  140. package/build/dist/Server/Services/IncidentStateTimelineService.js +1 -1
  141. package/build/dist/Server/Services/IncidentStateTimelineService.js.map +1 -1
  142. package/build/dist/Server/Services/Index.js +6 -0
  143. package/build/dist/Server/Services/Index.js.map +1 -1
  144. package/build/dist/Server/Services/MonitorService.js +5 -2
  145. package/build/dist/Server/Services/MonitorService.js.map +1 -1
  146. package/build/dist/Server/Services/ProfileAggregationService.js +356 -0
  147. package/build/dist/Server/Services/ProfileAggregationService.js.map +1 -0
  148. package/build/dist/Server/Services/ProfileSampleService.js +9 -0
  149. package/build/dist/Server/Services/ProfileSampleService.js.map +1 -0
  150. package/build/dist/Server/Services/ProfileService.js +9 -0
  151. package/build/dist/Server/Services/ProfileService.js.map +1 -0
  152. package/build/dist/Server/Services/TelemetryUsageBillingService.js +61 -4
  153. package/build/dist/Server/Services/TelemetryUsageBillingService.js.map +1 -1
  154. package/build/dist/Server/Services/WorkspaceNotificationSummaryService.js +13 -1
  155. package/build/dist/Server/Services/WorkspaceNotificationSummaryService.js.map +1 -1
  156. package/build/dist/Server/Types/Billing/MeteredPlan/AllMeteredPlans.js +8 -0
  157. package/build/dist/Server/Types/Billing/MeteredPlan/AllMeteredPlans.js.map +1 -1
  158. package/build/dist/Server/Utils/Cookie.js +36 -0
  159. package/build/dist/Server/Utils/Cookie.js.map +1 -1
  160. package/build/dist/Server/Utils/Monitor/Criteria/ProfileMonitorCriteria.js +34 -0
  161. package/build/dist/Server/Utils/Monitor/Criteria/ProfileMonitorCriteria.js.map +1 -0
  162. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +173 -0
  163. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
  164. package/build/dist/Server/Utils/Profile/PprofEncoder.js +129 -0
  165. package/build/dist/Server/Utils/Profile/PprofEncoder.js.map +1 -0
  166. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js +36 -14
  167. package/build/dist/Server/Utils/Workspace/MicrosoftTeams/MicrosoftTeams.js.map +1 -1
  168. package/build/dist/Server/Utils/Workspace/Slack/Slack.js +23 -6
  169. package/build/dist/Server/Utils/Workspace/Slack/Slack.js.map +1 -1
  170. package/build/dist/ServiceRoute.js +1 -0
  171. package/build/dist/ServiceRoute.js.map +1 -1
  172. package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js +2 -0
  173. package/build/dist/Types/AnalyticsDatabase/AnalyticsTableName.js.map +1 -1
  174. package/build/dist/Types/CookieName.js +1 -0
  175. package/build/dist/Types/CookieName.js.map +1 -1
  176. package/build/dist/Types/Dashboard/Chart/ChartType.js +5 -0
  177. package/build/dist/Types/Dashboard/Chart/ChartType.js.map +1 -1
  178. package/build/dist/Types/Dashboard/DashboardComponentType.js +4 -0
  179. package/build/dist/Types/Dashboard/DashboardComponentType.js.map +1 -1
  180. package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js +1 -0
  181. package/build/dist/Types/Dashboard/DashboardComponents/ComponentArgument.js.map +1 -1
  182. package/build/dist/Types/Dashboard/DashboardComponents/DashboardGaugeComponent.js +2 -0
  183. package/build/dist/Types/Dashboard/DashboardComponents/DashboardGaugeComponent.js.map +1 -0
  184. package/build/dist/Types/Dashboard/DashboardComponents/DashboardLogStreamComponent.js +2 -0
  185. package/build/dist/Types/Dashboard/DashboardComponents/DashboardLogStreamComponent.js.map +1 -0
  186. package/build/dist/Types/Dashboard/DashboardComponents/DashboardTableComponent.js +2 -0
  187. package/build/dist/Types/Dashboard/DashboardComponents/DashboardTableComponent.js.map +1 -0
  188. package/build/dist/Types/Dashboard/DashboardComponents/DashboardTraceListComponent.js +2 -0
  189. package/build/dist/Types/Dashboard/DashboardComponents/DashboardTraceListComponent.js.map +1 -0
  190. package/build/dist/Types/Dashboard/DashboardTemplates.js +853 -0
  191. package/build/dist/Types/Dashboard/DashboardTemplates.js.map +1 -0
  192. package/build/dist/Types/Dashboard/DashboardVariable.js +7 -0
  193. package/build/dist/Types/Dashboard/DashboardVariable.js.map +1 -0
  194. package/build/dist/Types/Dashboard/DashboardViewConfig.js +50 -1
  195. package/build/dist/Types/Dashboard/DashboardViewConfig.js.map +1 -1
  196. package/build/dist/Types/Dashboard/MasterPassword.js +5 -0
  197. package/build/dist/Types/Dashboard/MasterPassword.js.map +1 -0
  198. package/build/dist/Types/Icon/IconProp.js +1 -0
  199. package/build/dist/Types/Icon/IconProp.js.map +1 -1
  200. package/build/dist/Types/Incident/IncidentMetricType.js +3 -0
  201. package/build/dist/Types/Incident/IncidentMetricType.js.map +1 -1
  202. package/build/dist/Types/MeteredPlan/ProductType.js +1 -0
  203. package/build/dist/Types/MeteredPlan/ProductType.js.map +1 -1
  204. package/build/dist/Types/Metrics/MetricQueryConfigData.js +1 -0
  205. package/build/dist/Types/Metrics/MetricQueryConfigData.js.map +1 -1
  206. package/build/dist/Types/Monitor/CriteriaFilter.js +2 -0
  207. package/build/dist/Types/Monitor/CriteriaFilter.js.map +1 -1
  208. package/build/dist/Types/Monitor/KubernetesAlertTemplates.js +58 -7
  209. package/build/dist/Types/Monitor/KubernetesAlertTemplates.js.map +1 -1
  210. package/build/dist/Types/Monitor/MonitorStep.js +15 -0
  211. package/build/dist/Types/Monitor/MonitorStep.js.map +1 -1
  212. package/build/dist/Types/Monitor/MonitorStepProfileMonitor.js +59 -0
  213. package/build/dist/Types/Monitor/MonitorStepProfileMonitor.js.map +1 -0
  214. package/build/dist/Types/Monitor/MonitorType.js +10 -0
  215. package/build/dist/Types/Monitor/MonitorType.js.map +1 -1
  216. package/build/dist/Types/Monitor/ProfileMonitor/ProfileMonitorResponse.js +2 -0
  217. package/build/dist/Types/Monitor/ProfileMonitor/ProfileMonitorResponse.js.map +1 -0
  218. package/build/dist/Types/Permission.js +75 -0
  219. package/build/dist/Types/Permission.js.map +1 -1
  220. package/build/dist/Types/Telemetry/TelemetryType.js +1 -0
  221. package/build/dist/Types/Telemetry/TelemetryType.js.map +1 -1
  222. package/build/dist/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.js +1 -0
  223. package/build/dist/Types/Workspace/NotificationSummary/WorkspaceNotificationSummaryItem.js.map +1 -1
  224. package/build/dist/UI/Components/Button/Button.js +1 -1
  225. package/build/dist/UI/Components/Button/Button.js.map +1 -1
  226. package/build/dist/UI/Components/Card/Card.js +4 -4
  227. package/build/dist/UI/Components/Card/Card.js.map +1 -1
  228. package/build/dist/UI/Components/Charts/Area/AreaChart.js +1 -1
  229. package/build/dist/UI/Components/Charts/Area/AreaChart.js.map +1 -1
  230. package/build/dist/UI/Components/Charts/Bar/BarChart.js +1 -1
  231. package/build/dist/UI/Components/Charts/Bar/BarChart.js.map +1 -1
  232. package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js +5 -2
  233. package/build/dist/UI/Components/Charts/ChartLibrary/AreaChart/AreaChart.js.map +1 -1
  234. package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js +5 -2
  235. package/build/dist/UI/Components/Charts/ChartLibrary/BarChart/BarChart.js.map +1 -1
  236. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js +6 -3
  237. package/build/dist/UI/Components/Charts/ChartLibrary/LineChart/LineChart.js.map +1 -1
  238. package/build/dist/UI/Components/Charts/Line/LineChart.js +1 -1
  239. package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
  240. package/build/dist/UI/Components/Charts/Types/ReferenceLineProps.js +2 -0
  241. package/build/dist/UI/Components/Charts/Types/ReferenceLineProps.js.map +1 -0
  242. package/build/dist/UI/Components/Icon/Icon.js +11 -0
  243. package/build/dist/UI/Components/Icon/Icon.js.map +1 -1
  244. package/build/dist/UI/Components/ModelTable/BaseModelTable.js +12 -9
  245. package/build/dist/UI/Components/ModelTable/BaseModelTable.js.map +1 -1
  246. package/build/dist/UI/Components/MoreMenu/MoreMenu.js +8 -2
  247. package/build/dist/UI/Components/MoreMenu/MoreMenu.js.map +1 -1
  248. package/build/dist/UI/Components/MoreMenu/MoreMenuItem.js +4 -4
  249. package/build/dist/UI/Components/MoreMenu/MoreMenuItem.js.map +1 -1
  250. package/build/dist/UI/Components/Workflow/Component.js +311 -143
  251. package/build/dist/UI/Components/Workflow/Component.js.map +1 -1
  252. package/build/dist/UI/Components/Workflow/ComponentPortViewer.js +44 -18
  253. package/build/dist/UI/Components/Workflow/ComponentPortViewer.js.map +1 -1
  254. package/build/dist/UI/Components/Workflow/ComponentReturnValueViewer.js +48 -22
  255. package/build/dist/UI/Components/Workflow/ComponentReturnValueViewer.js.map +1 -1
  256. package/build/dist/UI/Components/Workflow/ComponentSettingsModal.js +127 -21
  257. package/build/dist/UI/Components/Workflow/ComponentSettingsModal.js.map +1 -1
  258. package/build/dist/UI/Components/Workflow/ComponentsModal.js +107 -52
  259. package/build/dist/UI/Components/Workflow/ComponentsModal.js.map +1 -1
  260. package/build/dist/UI/Components/Workflow/Workflow.js +87 -12
  261. package/build/dist/UI/Components/Workflow/Workflow.js.map +1 -1
  262. package/build/dist/UI/Config.js +3 -1
  263. package/build/dist/UI/Config.js.map +1 -1
  264. package/build/dist/Utils/Dashboard/Components/DashboardChartComponent.js +50 -21
  265. package/build/dist/Utils/Dashboard/Components/DashboardChartComponent.js.map +1 -1
  266. package/build/dist/Utils/Dashboard/Components/DashboardGaugeComponent.js +104 -0
  267. package/build/dist/Utils/Dashboard/Components/DashboardGaugeComponent.js.map +1 -0
  268. package/build/dist/Utils/Dashboard/Components/DashboardLogStreamComponent.js +91 -0
  269. package/build/dist/Utils/Dashboard/Components/DashboardLogStreamComponent.js.map +1 -0
  270. package/build/dist/Utils/Dashboard/Components/DashboardTableComponent.js +70 -0
  271. package/build/dist/Utils/Dashboard/Components/DashboardTableComponent.js.map +1 -0
  272. package/build/dist/Utils/Dashboard/Components/DashboardTextComponent.js +28 -7
  273. package/build/dist/Utils/Dashboard/Components/DashboardTextComponent.js.map +1 -1
  274. package/build/dist/Utils/Dashboard/Components/DashboardTraceListComponent.js +70 -0
  275. package/build/dist/Utils/Dashboard/Components/DashboardTraceListComponent.js.map +1 -0
  276. package/build/dist/Utils/Dashboard/Components/DashboardValueComponent.js +34 -3
  277. package/build/dist/Utils/Dashboard/Components/DashboardValueComponent.js.map +1 -1
  278. package/build/dist/Utils/Dashboard/Components/Index.js +16 -0
  279. package/build/dist/Utils/Dashboard/Components/Index.js.map +1 -1
  280. package/build/dist/Utils/ValueFormatter.js +132 -0
  281. package/build/dist/Utils/ValueFormatter.js.map +1 -0
  282. package/package.json +1 -1
@@ -7,13 +7,21 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
7
7
  var __metadata = (this && this.__metadata) || function (k, v) {
8
8
  if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
9
  };
10
+ import CookieUtil from "../Utils/Cookie";
11
+ import JSONWebToken from "../Utils/JsonWebToken";
12
+ import logger from "../Utils/Logger";
10
13
  import DatabaseService from "./DatabaseService";
11
14
  import BadDataException from "../../Types/Exception/BadDataException";
15
+ import NotAuthenticatedException from "../../Types/Exception/NotAuthenticatedException";
16
+ import ForbiddenException from "../../Types/Exception/ForbiddenException";
17
+ import MasterPasswordRequiredException from "../../Types/Exception/MasterPasswordRequiredException";
12
18
  import Model from "../../Models/DatabaseModels/Dashboard";
13
19
  import { IsBillingEnabled } from "../EnvironmentConfig";
14
20
  import { PlanType } from "../../Types/Billing/SubscriptionPlan";
15
21
  import DashboardViewConfigUtil from "../../Utils/Dashboard/DashboardViewConfig";
16
22
  import CaptureSpan from "../Utils/Telemetry/CaptureSpan";
23
+ import IP from "../../Types/IP/IP";
24
+ import { DASHBOARD_MASTER_PASSWORD_COOKIE_IDENTIFIER, DASHBOARD_MASTER_PASSWORD_REQUIRED_MESSAGE, } from "../../Types/Dashboard/MasterPassword";
17
25
  export class Service extends DatabaseService {
18
26
  constructor() {
19
27
  super(Model);
@@ -36,11 +44,117 @@ export class Service extends DatabaseService {
36
44
  }
37
45
  }
38
46
  }
39
- // make sure dashboard config is empty.
40
- createBy.data.dashboardViewConfig =
41
- DashboardViewConfigUtil.createDefaultDashboardViewConfig();
47
+ // use default empty config only if no template config was provided.
48
+ if (!createBy.data.dashboardViewConfig ||
49
+ !createBy.data.dashboardViewConfig.components ||
50
+ createBy.data.dashboardViewConfig.components.length === 0) {
51
+ createBy.data.dashboardViewConfig =
52
+ DashboardViewConfigUtil.createDefaultDashboardViewConfig();
53
+ }
42
54
  return Promise.resolve({ createBy, carryForward: null });
43
55
  }
56
+ async hasReadAccess(data) {
57
+ var _a, _b, _c;
58
+ const dashboardId = data.dashboardId;
59
+ const req = data.req;
60
+ try {
61
+ const dashboard = await this.findOneById({
62
+ id: dashboardId,
63
+ props: {
64
+ isRoot: true,
65
+ },
66
+ select: {
67
+ _id: true,
68
+ isPublicDashboard: true,
69
+ ipWhitelist: true,
70
+ enableMasterPassword: true,
71
+ masterPassword: true,
72
+ },
73
+ });
74
+ // If dashboard is not public, deny access
75
+ if (dashboard && !dashboard.isPublicDashboard) {
76
+ return {
77
+ hasReadAccess: false,
78
+ error: new NotAuthenticatedException("This dashboard is not available."),
79
+ };
80
+ }
81
+ if ((dashboard === null || dashboard === void 0 ? void 0 : dashboard.ipWhitelist) && dashboard.ipWhitelist.length > 0) {
82
+ const ipWhitelist = (_a = dashboard.ipWhitelist) === null || _a === void 0 ? void 0 : _a.split("\n");
83
+ const ipAccessedFrom = ((_b = req.headers["x-forwarded-for"]) === null || _b === void 0 ? void 0 : _b.toString()) ||
84
+ ((_c = req.headers["x-real-ip"]) === null || _c === void 0 ? void 0 : _c.toString()) ||
85
+ req.socket.remoteAddress ||
86
+ req.ip ||
87
+ req.ips[0];
88
+ if (!ipAccessedFrom) {
89
+ logger.error("IP address not found in request.");
90
+ return {
91
+ hasReadAccess: false,
92
+ error: new ForbiddenException("Unable to verify IP address for dashboard access."),
93
+ };
94
+ }
95
+ const isIPWhitelisted = IP.isInWhitelist({
96
+ ips: (ipAccessedFrom === null || ipAccessedFrom === void 0 ? void 0 : ipAccessedFrom.split(",").map((i) => {
97
+ return i.trim();
98
+ })) || [],
99
+ whitelist: ipWhitelist,
100
+ });
101
+ if (!isIPWhitelisted) {
102
+ logger.error(`IP address ${ipAccessedFrom} is not whitelisted for dashboard ${dashboardId.toString()}.`);
103
+ return {
104
+ hasReadAccess: false,
105
+ error: new ForbiddenException(`Your IP address ${ipAccessedFrom} is blocked from accessing this dashboard.`),
106
+ };
107
+ }
108
+ }
109
+ const shouldEnforceMasterPassword = Boolean(dashboard &&
110
+ dashboard.isPublicDashboard &&
111
+ dashboard.enableMasterPassword &&
112
+ dashboard.masterPassword);
113
+ if (shouldEnforceMasterPassword) {
114
+ const hasValidMasterPassword = this.hasValidMasterPasswordCookie({
115
+ req,
116
+ dashboardId,
117
+ });
118
+ if (hasValidMasterPassword) {
119
+ return {
120
+ hasReadAccess: true,
121
+ };
122
+ }
123
+ return {
124
+ hasReadAccess: false,
125
+ error: new MasterPasswordRequiredException(DASHBOARD_MASTER_PASSWORD_REQUIRED_MESSAGE),
126
+ };
127
+ }
128
+ // Public dashboard without master password - grant access
129
+ if (dashboard && dashboard.isPublicDashboard) {
130
+ return {
131
+ hasReadAccess: true,
132
+ };
133
+ }
134
+ }
135
+ catch (err) {
136
+ logger.error(err);
137
+ }
138
+ return {
139
+ hasReadAccess: false,
140
+ error: new NotAuthenticatedException("You do not have access to this dashboard."),
141
+ };
142
+ }
143
+ hasValidMasterPasswordCookie(data) {
144
+ const token = CookieUtil.getCookieFromExpressRequest(data.req, CookieUtil.getDashboardMasterPasswordKey(data.dashboardId));
145
+ if (!token) {
146
+ return false;
147
+ }
148
+ try {
149
+ const payload = JSONWebToken.decodeJsonPayload(token);
150
+ return (payload["dashboardId"] === data.dashboardId.toString() &&
151
+ payload["type"] === DASHBOARD_MASTER_PASSWORD_COOKIE_IDENTIFIER);
152
+ }
153
+ catch (err) {
154
+ logger.error(err);
155
+ }
156
+ return false;
157
+ }
44
158
  }
45
159
  __decorate([
46
160
  CaptureSpan(),
@@ -1 +1 @@
1
- {"version":3,"file":"DashboardService.js","sourceRoot":"","sources":["../../../../Server/Services/DashboardService.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,eAAe,MAAM,mBAAmB,CAAC;AAChD,OAAO,gBAAgB,MAAM,wCAAwC,CAAC;AACtE,OAAO,KAAK,MAAM,uCAAuC,CAAC;AAC1D,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,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,CAAC;IACf,CAAC;CACF;AA7L0B;IADxB,WAAW,EAAE;;;;6CAuCb;AAyJH,eAAe,IAAI,OAAO,EAAE,CAAC"}
@@ -759,7 +759,7 @@ ${incident.remediationNotes || "No remediation notes provided."}
759
759
  "Status was changed because Incident " +
760
760
  (createdItem.incidentNumberWithPrefix ||
761
761
  "#" + ((_b = createdItem.incidentNumber) === null || _b === void 0 ? void 0 : _b.toString())) +
762
- " was created.", createdItem.createdStateLog, onCreate.createBy.props);
762
+ " was created.", createdItem.createdStateLog, onCreate.createBy.props, createdItem.declaredAt || undefined);
763
763
  }
764
764
  }
765
765
  catch (error) {
@@ -910,7 +910,7 @@ ${incident.remediationNotes || "No remediation notes provided."}
910
910
  return URL.fromString(dashboardUrl.toString()).addRoute(`/${projectId.toString()}/incidents/${incidentId.toString()}`);
911
911
  }
912
912
  async onUpdateSuccess(onUpdate, updatedItemIds) {
913
- var _a, _b, _c;
913
+ var _a, _b, _c, _d, _e;
914
914
  if (onUpdate.updateBy.data.currentIncidentStateId &&
915
915
  onUpdate.updateBy.props.tenantId) {
916
916
  for (const itemId of updatedItemIds) {
@@ -980,6 +980,71 @@ ${incident.remediationNotes || "No remediation notes provided."}
980
980
  },
981
981
  });
982
982
  }
983
+ // emit postmortem completion time metric when postmortemPostedAt is set
984
+ if (Object.prototype.hasOwnProperty.call(updatedIncidentData, "postmortemPostedAt") &&
985
+ updatedIncidentData["postmortemPostedAt"]) {
986
+ try {
987
+ const postmortemPostedAt = updatedIncidentData["postmortemPostedAt"];
988
+ // find the resolved state timeline to calculate time from resolution to postmortem
989
+ const resolvedStateId = await IncidentStateTimelineService.getResolvedStateIdForProject(projectId);
990
+ const resolvedTimeline = await IncidentStateTimelineService.findOneBy({
991
+ query: {
992
+ incidentId: incidentId,
993
+ incidentStateId: resolvedStateId,
994
+ },
995
+ select: {
996
+ startsAt: true,
997
+ },
998
+ sort: {
999
+ startsAt: SortOrder.Descending,
1000
+ },
1001
+ props: {
1002
+ isRoot: true,
1003
+ },
1004
+ });
1005
+ // only emit if the incident has been resolved
1006
+ if (resolvedTimeline && resolvedTimeline.startsAt) {
1007
+ const postmortemMetric = new Metric();
1008
+ postmortemMetric.projectId = projectId;
1009
+ postmortemMetric.serviceId = incidentId;
1010
+ postmortemMetric.serviceType = ServiceType.Incident;
1011
+ postmortemMetric.name =
1012
+ IncidentMetricType.PostmortemCompletionTime;
1013
+ postmortemMetric.value = OneUptimeDate.getDifferenceInSeconds(postmortemPostedAt, resolvedTimeline.startsAt);
1014
+ postmortemMetric.attributes = {
1015
+ incidentId: incidentId.toString(),
1016
+ projectId: projectId.toString(),
1017
+ };
1018
+ postmortemMetric.attributeKeys = TelemetryUtil.getAttributeKeys(postmortemMetric.attributes);
1019
+ postmortemMetric.time = postmortemPostedAt;
1020
+ postmortemMetric.timeUnixNano = OneUptimeDate.toUnixNano(postmortemMetric.time);
1021
+ postmortemMetric.metricPointType = MetricPointType.Sum;
1022
+ await MetricService.create({
1023
+ data: postmortemMetric,
1024
+ props: {
1025
+ isRoot: true,
1026
+ },
1027
+ });
1028
+ const postmortemMetricType = new MetricType();
1029
+ postmortemMetricType.name =
1030
+ IncidentMetricType.PostmortemCompletionTime;
1031
+ postmortemMetricType.description =
1032
+ "Time from incident resolution to postmortem publication";
1033
+ postmortemMetricType.unit = "seconds";
1034
+ TelemetryUtil.indexMetricNameServiceNameMap({
1035
+ metricNameServiceNameMap: {
1036
+ [postmortemMetricType.name]: postmortemMetricType,
1037
+ },
1038
+ projectId: projectId,
1039
+ }).catch((err) => {
1040
+ logger.error(err);
1041
+ });
1042
+ }
1043
+ }
1044
+ catch (metricError) {
1045
+ logger.error(`Failed to emit postmortem completion time metric: ${metricError}`);
1046
+ }
1047
+ }
983
1048
  let shouldAddIncidentFeed = false;
984
1049
  let feedInfoInMarkdown = `**[${incidentLabel}](${incidentLink.toString()}) was updated.**`;
985
1050
  if (Object.prototype.hasOwnProperty.call(updatedIncidentData, "title")) {
@@ -1075,6 +1140,48 @@ ${incidentSeverity.name}
1075
1140
  catch (slaError) {
1076
1141
  logger.error(`SLA recalculation failed in IncidentService.onUpdateSuccess: ${slaError}`);
1077
1142
  }
1143
+ // emit severity change metric
1144
+ try {
1145
+ const severityChangeMetric = new Metric();
1146
+ severityChangeMetric.projectId = projectId;
1147
+ severityChangeMetric.serviceId = incidentId;
1148
+ severityChangeMetric.serviceType = ServiceType.Incident;
1149
+ severityChangeMetric.name = IncidentMetricType.SeverityChange;
1150
+ severityChangeMetric.value = 1;
1151
+ severityChangeMetric.attributes = {
1152
+ incidentId: incidentId.toString(),
1153
+ projectId: projectId.toString(),
1154
+ newIncidentSeverityId: ((_c = incidentSeverity._id) === null || _c === void 0 ? void 0 : _c.toString()) || "",
1155
+ newIncidentSeverityName: ((_d = incidentSeverity.name) === null || _d === void 0 ? void 0 : _d.toString()) || "",
1156
+ };
1157
+ severityChangeMetric.attributeKeys =
1158
+ TelemetryUtil.getAttributeKeys(severityChangeMetric.attributes);
1159
+ severityChangeMetric.time = OneUptimeDate.getCurrentDate();
1160
+ severityChangeMetric.timeUnixNano = OneUptimeDate.toUnixNano(severityChangeMetric.time);
1161
+ severityChangeMetric.metricPointType = MetricPointType.Sum;
1162
+ await MetricService.create({
1163
+ data: severityChangeMetric,
1164
+ props: {
1165
+ isRoot: true,
1166
+ },
1167
+ });
1168
+ const severityChangeMetricType = new MetricType();
1169
+ severityChangeMetricType.name = IncidentMetricType.SeverityChange;
1170
+ severityChangeMetricType.description =
1171
+ "Count of incident severity changes";
1172
+ severityChangeMetricType.unit = "";
1173
+ TelemetryUtil.indexMetricNameServiceNameMap({
1174
+ metricNameServiceNameMap: {
1175
+ [severityChangeMetricType.name]: severityChangeMetricType,
1176
+ },
1177
+ projectId: projectId,
1178
+ }).catch((err) => {
1179
+ logger.error(err);
1180
+ });
1181
+ }
1182
+ catch (metricError) {
1183
+ logger.error(`Failed to emit severity change metric: ${metricError}`);
1184
+ }
1078
1185
  }
1079
1186
  }
1080
1187
  const carryForward = onUpdate.carryForward;
@@ -1162,7 +1269,7 @@ ${incidentSeverity.name}
1162
1269
  }
1163
1270
  const changeNewMonitorStatusTo = incidentCarryForward.newMonitorChangeStatusIdTo ||
1164
1271
  incidentCarryForward.oldChangeMonitorStatusIdTo;
1165
- if (((_c = incidentCarryForward.monitorsAdded) === null || _c === void 0 ? void 0 : _c.length) > 0) {
1272
+ if (((_e = incidentCarryForward.monitorsAdded) === null || _e === void 0 ? void 0 : _e.length) > 0) {
1166
1273
  await this.disableActiveMonitoringIfManualIncident(incidentId);
1167
1274
  }
1168
1275
  if (changeNewMonitorStatusTo) {
@@ -1234,7 +1341,7 @@ ${incidentSeverity.name}
1234
1341
  });
1235
1342
  return incidentCount.toNumber() > 0;
1236
1343
  }
1237
- async markMonitorsActiveForMonitoring(projectId, monitors) {
1344
+ async markMonitorsActiveForMonitoring(projectId, monitors, startsAt) {
1238
1345
  // resolve all the monitors.
1239
1346
  var _a;
1240
1347
  if (monitors.length > 0) {
@@ -1293,6 +1400,9 @@ ${incidentSeverity.name}
1293
1400
  monitorStatusTimeline.monitorId = monitor.id;
1294
1401
  monitorStatusTimeline.projectId = projectId;
1295
1402
  monitorStatusTimeline.monitorStatusId = resolvedMonitorState.id;
1403
+ if (startsAt) {
1404
+ monitorStatusTimeline.startsAt = startsAt;
1405
+ }
1296
1406
  await MonitorStatusTimelineService.create({
1297
1407
  data: monitorStatusTimeline,
1298
1408
  props: {
@@ -1401,7 +1511,7 @@ ${incidentSeverity.name}
1401
1511
  });
1402
1512
  }
1403
1513
  async refreshIncidentMetrics(data) {
1404
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
1514
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
1405
1515
  const incident = await this.findOneById({
1406
1516
  id: data.incidentId,
1407
1517
  select: {
@@ -1426,6 +1536,73 @@ ${incidentSeverity.name}
1426
1536
  if (!incident.projectId) {
1427
1537
  throw new BadDataException("Incident Project ID not found");
1428
1538
  }
1539
+ // fetch owner users and teams for metric attributes
1540
+ const ownerUsers = await IncidentOwnerUserService.findBy({
1541
+ query: {
1542
+ incidentId: data.incidentId,
1543
+ },
1544
+ select: {
1545
+ _id: true,
1546
+ user: {
1547
+ _id: true,
1548
+ name: true,
1549
+ },
1550
+ },
1551
+ props: {
1552
+ isRoot: true,
1553
+ },
1554
+ limit: LIMIT_PER_PROJECT,
1555
+ skip: 0,
1556
+ });
1557
+ const ownerTeams = await IncidentOwnerTeamService.findBy({
1558
+ query: {
1559
+ incidentId: data.incidentId,
1560
+ },
1561
+ select: {
1562
+ _id: true,
1563
+ team: {
1564
+ _id: true,
1565
+ name: true,
1566
+ },
1567
+ },
1568
+ props: {
1569
+ isRoot: true,
1570
+ },
1571
+ limit: LIMIT_PER_PROJECT,
1572
+ skip: 0,
1573
+ });
1574
+ const ownerUserIds = ownerUsers
1575
+ .map((ownerUser) => {
1576
+ var _a, _b;
1577
+ return (_b = (_a = ownerUser.user) === null || _a === void 0 ? void 0 : _a._id) === null || _b === void 0 ? void 0 : _b.toString();
1578
+ })
1579
+ .filter((id) => {
1580
+ return Boolean(id);
1581
+ });
1582
+ const ownerUserNames = ownerUsers
1583
+ .map((ownerUser) => {
1584
+ var _a, _b;
1585
+ return (_b = (_a = ownerUser.user) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.toString();
1586
+ })
1587
+ .filter((name) => {
1588
+ return Boolean(name);
1589
+ });
1590
+ const ownerTeamIds = ownerTeams
1591
+ .map((ownerTeam) => {
1592
+ var _a, _b;
1593
+ return (_b = (_a = ownerTeam.team) === null || _a === void 0 ? void 0 : _a._id) === null || _b === void 0 ? void 0 : _b.toString();
1594
+ })
1595
+ .filter((id) => {
1596
+ return Boolean(id);
1597
+ });
1598
+ const ownerTeamNames = ownerTeams
1599
+ .map((ownerTeam) => {
1600
+ var _a, _b;
1601
+ return (_b = (_a = ownerTeam.team) === null || _a === void 0 ? void 0 : _a.name) === null || _b === void 0 ? void 0 : _b.toString();
1602
+ })
1603
+ .filter((name) => {
1604
+ return Boolean(name);
1605
+ });
1429
1606
  // get incident state timeline
1430
1607
  const incidentStateTimelines = await IncidentStateTimelineService.findBy({
1431
1608
  query: {
@@ -1435,8 +1612,10 @@ ${incidentSeverity.name}
1435
1612
  projectId: true,
1436
1613
  incidentStateId: true,
1437
1614
  incidentState: {
1615
+ name: true,
1438
1616
  isAcknowledgedState: true,
1439
1617
  isResolvedState: true,
1618
+ isCreatedState: true,
1440
1619
  },
1441
1620
  startsAt: true,
1442
1621
  endsAt: true,
@@ -1468,13 +1647,8 @@ ${incidentSeverity.name}
1468
1647
  incident.createdAt ||
1469
1648
  OneUptimeDate.getCurrentDate();
1470
1649
  const metricTypesMap = {};
1471
- const incidentCountMetric = new Metric();
1472
- incidentCountMetric.projectId = incident.projectId;
1473
- incidentCountMetric.serviceId = incident.id;
1474
- incidentCountMetric.serviceType = ServiceType.Incident;
1475
- incidentCountMetric.name = IncidentMetricType.IncidentCount;
1476
- incidentCountMetric.value = 1;
1477
- incidentCountMetric.attributes = {
1650
+ // common attributes shared by all incident metrics
1651
+ const baseMetricAttributes = {
1478
1652
  incidentId: data.incidentId.toString(),
1479
1653
  projectId: incident.projectId.toString(),
1480
1654
  monitorIds: ((_a = incident.monitors) === null || _a === void 0 ? void 0 : _a.map((monitor) => {
@@ -1487,7 +1661,18 @@ ${incidentSeverity.name}
1487
1661
  })) || [],
1488
1662
  incidentSeverityId: (_d = (_c = incident.incidentSeverity) === null || _c === void 0 ? void 0 : _c._id) === null || _d === void 0 ? void 0 : _d.toString(),
1489
1663
  incidentSeverityName: (_f = (_e = incident.incidentSeverity) === null || _e === void 0 ? void 0 : _e.name) === null || _f === void 0 ? void 0 : _f.toString(),
1664
+ ownerUserIds: ownerUserIds,
1665
+ ownerUserNames: ownerUserNames,
1666
+ ownerTeamIds: ownerTeamIds,
1667
+ ownerTeamNames: ownerTeamNames,
1490
1668
  };
1669
+ const incidentCountMetric = new Metric();
1670
+ incidentCountMetric.projectId = incident.projectId;
1671
+ incidentCountMetric.serviceId = incident.id;
1672
+ incidentCountMetric.serviceType = ServiceType.Incident;
1673
+ incidentCountMetric.name = IncidentMetricType.IncidentCount;
1674
+ incidentCountMetric.value = 1;
1675
+ incidentCountMetric.attributes = Object.assign({}, baseMetricAttributes);
1491
1676
  incidentCountMetric.attributeKeys = TelemetryUtil.getAttributeKeys(incidentCountMetric.attributes);
1492
1677
  incidentCountMetric.time = incidentStartsAt;
1493
1678
  incidentCountMetric.timeUnixNano = OneUptimeDate.toUnixNano(incidentCountMetric.time);
@@ -1518,20 +1703,7 @@ ${incidentSeverity.name}
1518
1703
  timeToAcknowledgeMetric.serviceType = ServiceType.Incident;
1519
1704
  timeToAcknowledgeMetric.name = IncidentMetricType.TimeToAcknowledge;
1520
1705
  timeToAcknowledgeMetric.value = OneUptimeDate.getDifferenceInSeconds((ackIncidentStateTimeline === null || ackIncidentStateTimeline === void 0 ? void 0 : ackIncidentStateTimeline.startsAt) || OneUptimeDate.getCurrentDate(), incidentStartsAt);
1521
- timeToAcknowledgeMetric.attributes = {
1522
- incidentId: data.incidentId.toString(),
1523
- projectId: incident.projectId.toString(),
1524
- monitorIds: ((_g = incident.monitors) === null || _g === void 0 ? void 0 : _g.map((monitor) => {
1525
- var _a;
1526
- return (_a = monitor._id) === null || _a === void 0 ? void 0 : _a.toString();
1527
- })) || [],
1528
- monitorNames: ((_h = incident.monitors) === null || _h === void 0 ? void 0 : _h.map((monitor) => {
1529
- var _a;
1530
- return (_a = monitor.name) === null || _a === void 0 ? void 0 : _a.toString();
1531
- })) || [],
1532
- incidentSeverityId: (_k = (_j = incident.incidentSeverity) === null || _j === void 0 ? void 0 : _j._id) === null || _k === void 0 ? void 0 : _k.toString(),
1533
- incidentSeverityName: (_m = (_l = incident.incidentSeverity) === null || _l === void 0 ? void 0 : _l.name) === null || _m === void 0 ? void 0 : _m.toString(),
1534
- };
1706
+ timeToAcknowledgeMetric.attributes = Object.assign({}, baseMetricAttributes);
1535
1707
  timeToAcknowledgeMetric.attributeKeys = TelemetryUtil.getAttributeKeys(timeToAcknowledgeMetric.attributes);
1536
1708
  timeToAcknowledgeMetric.time =
1537
1709
  (ackIncidentStateTimeline === null || ackIncidentStateTimeline === void 0 ? void 0 : ackIncidentStateTimeline.startsAt) ||
@@ -1568,20 +1740,7 @@ ${incidentSeverity.name}
1568
1740
  timeToResolveMetric.name = IncidentMetricType.TimeToResolve;
1569
1741
  timeToResolveMetric.value = OneUptimeDate.getDifferenceInSeconds((resolvedIncidentStateTimeline === null || resolvedIncidentStateTimeline === void 0 ? void 0 : resolvedIncidentStateTimeline.startsAt) ||
1570
1742
  OneUptimeDate.getCurrentDate(), incidentStartsAt);
1571
- timeToResolveMetric.attributes = {
1572
- incidentId: data.incidentId.toString(),
1573
- projectId: incident.projectId.toString(),
1574
- monitorIds: ((_o = incident.monitors) === null || _o === void 0 ? void 0 : _o.map((monitor) => {
1575
- var _a;
1576
- return (_a = monitor._id) === null || _a === void 0 ? void 0 : _a.toString();
1577
- })) || [],
1578
- monitorNames: ((_p = incident.monitors) === null || _p === void 0 ? void 0 : _p.map((monitor) => {
1579
- var _a;
1580
- return (_a = monitor.name) === null || _a === void 0 ? void 0 : _a.toString();
1581
- })) || [],
1582
- incidentSeverityId: (_r = (_q = incident.incidentSeverity) === null || _q === void 0 ? void 0 : _q._id) === null || _r === void 0 ? void 0 : _r.toString(),
1583
- incidentSeverityName: (_t = (_s = incident.incidentSeverity) === null || _s === void 0 ? void 0 : _s.name) === null || _t === void 0 ? void 0 : _t.toString(),
1584
- };
1743
+ timeToResolveMetric.attributes = Object.assign({}, baseMetricAttributes);
1585
1744
  timeToResolveMetric.attributeKeys = TelemetryUtil.getAttributeKeys(timeToResolveMetric.attributes);
1586
1745
  timeToResolveMetric.time =
1587
1746
  (resolvedIncidentStateTimeline === null || resolvedIncidentStateTimeline === void 0 ? void 0 : resolvedIncidentStateTimeline.startsAt) ||
@@ -1611,20 +1770,7 @@ ${incidentSeverity.name}
1611
1770
  incidentDurationMetric.serviceType = ServiceType.Incident;
1612
1771
  incidentDurationMetric.name = IncidentMetricType.IncidentDuration;
1613
1772
  incidentDurationMetric.value = OneUptimeDate.getDifferenceInSeconds(incidentEndsAt, incidentStartsAt);
1614
- incidentDurationMetric.attributes = {
1615
- incidentId: data.incidentId.toString(),
1616
- projectId: incident.projectId.toString(),
1617
- monitorIds: ((_u = incident.monitors) === null || _u === void 0 ? void 0 : _u.map((monitor) => {
1618
- var _a;
1619
- return (_a = monitor._id) === null || _a === void 0 ? void 0 : _a.toString();
1620
- })) || [],
1621
- monitorNames: ((_v = incident.monitors) === null || _v === void 0 ? void 0 : _v.map((monitor) => {
1622
- var _a;
1623
- return (_a = monitor.name) === null || _a === void 0 ? void 0 : _a.toString();
1624
- })) || [],
1625
- incidentSeverityId: (_x = (_w = incident.incidentSeverity) === null || _w === void 0 ? void 0 : _w._id) === null || _x === void 0 ? void 0 : _x.toString(),
1626
- incidentSeverityName: (_z = (_y = incident.incidentSeverity) === null || _y === void 0 ? void 0 : _y.name) === null || _z === void 0 ? void 0 : _z.toString(),
1627
- };
1773
+ incidentDurationMetric.attributes = Object.assign({}, baseMetricAttributes);
1628
1774
  incidentDurationMetric.attributeKeys = TelemetryUtil.getAttributeKeys(incidentDurationMetric.attributes);
1629
1775
  incidentDurationMetric.time =
1630
1776
  (lastIncidentStateTimeline === null || lastIncidentStateTimeline === void 0 ? void 0 : lastIncidentStateTimeline.startsAt) ||
@@ -1642,6 +1788,36 @@ ${incidentSeverity.name}
1642
1788
  // add to map.
1643
1789
  metricTypesMap[incidentDurationMetric.name] = metricType;
1644
1790
  }
1791
+ // time-in-state metrics — emit one metric per state transition that has a completed duration
1792
+ for (const timeline of incidentStateTimelines) {
1793
+ if (!timeline.startsAt || !timeline.endsAt) {
1794
+ continue;
1795
+ }
1796
+ const stateName = ((_h = (_g = timeline.incidentState) === null || _g === void 0 ? void 0 : _g.name) === null || _h === void 0 ? void 0 : _h.toString()) || "Unknown";
1797
+ const timeInStateMetric = new Metric();
1798
+ timeInStateMetric.projectId = incident.projectId;
1799
+ timeInStateMetric.serviceId = incident.id;
1800
+ timeInStateMetric.serviceType = ServiceType.Incident;
1801
+ timeInStateMetric.name = IncidentMetricType.TimeInState;
1802
+ timeInStateMetric.value = OneUptimeDate.getDifferenceInSeconds(timeline.endsAt, timeline.startsAt);
1803
+ timeInStateMetric.attributes = Object.assign(Object.assign({}, baseMetricAttributes), { incidentStateName: stateName, incidentStateId: (_j = timeline.incidentStateId) === null || _j === void 0 ? void 0 : _j.toString(), isCreatedState: ((_l = (_k = timeline.incidentState) === null || _k === void 0 ? void 0 : _k.isCreatedState) === null || _l === void 0 ? void 0 : _l.toString()) || "false", isAcknowledgedState: ((_o = (_m = timeline.incidentState) === null || _m === void 0 ? void 0 : _m.isAcknowledgedState) === null || _o === void 0 ? void 0 : _o.toString()) || "false", isResolvedState: ((_q = (_p = timeline.incidentState) === null || _p === void 0 ? void 0 : _p.isResolvedState) === null || _q === void 0 ? void 0 : _q.toString()) || "false" });
1804
+ timeInStateMetric.attributeKeys = TelemetryUtil.getAttributeKeys(timeInStateMetric.attributes);
1805
+ timeInStateMetric.time = timeline.startsAt;
1806
+ timeInStateMetric.timeUnixNano = OneUptimeDate.toUnixNano(timeInStateMetric.time);
1807
+ timeInStateMetric.metricPointType = MetricPointType.Sum;
1808
+ itemsToSave.push(timeInStateMetric);
1809
+ }
1810
+ // add metric type for time-in-state to map (only once)
1811
+ if (incidentStateTimelines.some((t) => {
1812
+ return t.startsAt && t.endsAt;
1813
+ })) {
1814
+ const timeInStateMetricType = new MetricType();
1815
+ timeInStateMetricType.name = IncidentMetricType.TimeInState;
1816
+ timeInStateMetricType.description =
1817
+ "Time spent in each incident state (e.g. Created, Investigating, Acknowledged)";
1818
+ timeInStateMetricType.unit = "seconds";
1819
+ metricTypesMap[timeInStateMetricType.name] = timeInStateMetricType;
1820
+ }
1645
1821
  await MetricService.createMany({
1646
1822
  items: itemsToSave,
1647
1823
  props: {
@@ -1911,7 +2087,7 @@ __decorate([
1911
2087
  CaptureSpan(),
1912
2088
  __metadata("design:type", Function),
1913
2089
  __metadata("design:paramtypes", [ObjectID,
1914
- Array]),
2090
+ Array, Object]),
1915
2091
  __metadata("design:returntype", Promise)
1916
2092
  ], Service.prototype, "markMonitorsActiveForMonitoring", null);
1917
2093
  __decorate([