@oneuptime/common 10.0.43 → 10.0.45

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 (120) hide show
  1. package/Models/DatabaseModels/Workflow.ts +29 -0
  2. package/Server/API/StatusPageAPI.ts +48 -0
  3. package/Server/EnvironmentConfig.ts +5 -8
  4. package/Server/Infrastructure/Postgres/SchemaMigrations/1774559064920-MigrationName.ts +22 -0
  5. package/Server/Infrastructure/Postgres/SchemaMigrations/Index.ts +2 -0
  6. package/Server/Services/AlertService.ts +45 -0
  7. package/Server/Services/IncidentService.ts +81 -13
  8. package/Server/Services/LogAggregationService.ts +1 -0
  9. package/Server/Services/WorkflowService.ts +28 -1
  10. package/Server/Types/Workflow/Components/Webhook.ts +28 -5
  11. package/Server/Utils/AnalyticsDatabase/StatementGenerator.ts +29 -13
  12. package/Server/Utils/Monitor/MonitorCriteriaEvaluator.ts +163 -26
  13. package/Server/Utils/Monitor/MonitorMetricUtil.ts +92 -0
  14. package/Server/Utils/Profiling.ts +101 -0
  15. package/Server/Utils/VM/VMRunner.ts +88 -0
  16. package/Types/Dashboard/DashboardTemplates.ts +1149 -0
  17. package/Types/Exception/ExceptionMetricType.ts +15 -0
  18. package/Types/IsolatedVM/ReturnResult.ts +3 -0
  19. package/Types/Metrics/MetricDashboardMetricType.ts +28 -0
  20. package/Types/Metrics/MetricsQuery.ts +2 -1
  21. package/Types/Monitor/CustomCodeMonitor/CapturedMetric.ts +7 -0
  22. package/Types/Monitor/CustomCodeMonitor/CustomCodeMonitorResponse.ts +2 -0
  23. package/Types/Monitor/UptimeBarTooltipIncident.ts +21 -0
  24. package/Types/Profile/ProfileMetricType.ts +16 -0
  25. package/Types/Span/SpanMetricType.ts +17 -0
  26. package/UI/Components/Charts/Area/AreaChart.tsx +40 -33
  27. package/UI/Components/Charts/Bar/BarChart.tsx +37 -30
  28. package/UI/Components/Charts/ChartGroup/ChartGroup.tsx +196 -51
  29. package/UI/Components/Charts/ChartGroup/NoDataMessage.tsx +13 -0
  30. package/UI/Components/Charts/Line/LineChart.tsx +39 -32
  31. package/UI/Components/Forms/BasicForm.tsx +1 -1
  32. package/UI/Components/Graphs/DayUptimeGraph.tsx +88 -35
  33. package/UI/Components/Graphs/UptimeBarTooltip.tsx +547 -0
  34. package/UI/Components/MonitorGraphs/Uptime.tsx +7 -0
  35. package/UI/Components/MonitorGraphs/UptimeBarDayModal.tsx +225 -0
  36. package/UI/Components/RadioButtons/GroupRadioButtons.tsx +1 -0
  37. package/UI/Components/Tooltip/Tooltip.tsx +29 -4
  38. package/UI/Components/Workflow/ComponentSettingsModal.tsx +2 -0
  39. package/UI/Components/Workflow/DocumentationViewer.tsx +5 -0
  40. package/UI/Components/Workflow/Workflow.tsx +2 -0
  41. package/Utils/Alerts/AlertMetricType.ts +98 -0
  42. package/Utils/Incident/IncidentMetricType.ts +130 -0
  43. package/build/dist/Models/DatabaseModels/Workflow.js +30 -0
  44. package/build/dist/Models/DatabaseModels/Workflow.js.map +1 -1
  45. package/build/dist/Server/API/StatusPageAPI.js +42 -0
  46. package/build/dist/Server/API/StatusPageAPI.js.map +1 -1
  47. package/build/dist/Server/EnvironmentConfig.js +2 -2
  48. package/build/dist/Server/EnvironmentConfig.js.map +1 -1
  49. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774559064920-MigrationName.js +14 -0
  50. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/1774559064920-MigrationName.js.map +1 -0
  51. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js +2 -0
  52. package/build/dist/Server/Infrastructure/Postgres/SchemaMigrations/Index.js.map +1 -1
  53. package/build/dist/Server/Services/AlertService.js +34 -0
  54. package/build/dist/Server/Services/AlertService.js.map +1 -1
  55. package/build/dist/Server/Services/IncidentService.js +52 -9
  56. package/build/dist/Server/Services/IncidentService.js.map +1 -1
  57. package/build/dist/Server/Services/LogAggregationService.js.map +1 -1
  58. package/build/dist/Server/Services/WorkflowService.js +25 -0
  59. package/build/dist/Server/Services/WorkflowService.js.map +1 -1
  60. package/build/dist/Server/Types/Workflow/Components/Webhook.js +23 -5
  61. package/build/dist/Server/Types/Workflow/Components/Webhook.js.map +1 -1
  62. package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js +21 -7
  63. package/build/dist/Server/Utils/AnalyticsDatabase/StatementGenerator.js.map +1 -1
  64. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js +120 -21
  65. package/build/dist/Server/Utils/Monitor/MonitorCriteriaEvaluator.js.map +1 -1
  66. package/build/dist/Server/Utils/Monitor/MonitorMetricUtil.js +68 -1
  67. package/build/dist/Server/Utils/Monitor/MonitorMetricUtil.js.map +1 -1
  68. package/build/dist/Server/Utils/Profiling.js +80 -0
  69. package/build/dist/Server/Utils/Profiling.js.map +1 -0
  70. package/build/dist/Server/Utils/VM/VMRunner.js +68 -0
  71. package/build/dist/Server/Utils/VM/VMRunner.js.map +1 -1
  72. package/build/dist/Types/Dashboard/DashboardTemplates.js +1095 -0
  73. package/build/dist/Types/Dashboard/DashboardTemplates.js.map +1 -1
  74. package/build/dist/Types/Exception/ExceptionMetricType.js +16 -0
  75. package/build/dist/Types/Exception/ExceptionMetricType.js.map +1 -0
  76. package/build/dist/Types/Metrics/MetricDashboardMetricType.js +26 -0
  77. package/build/dist/Types/Metrics/MetricDashboardMetricType.js.map +1 -0
  78. package/build/dist/Types/Monitor/CustomCodeMonitor/CapturedMetric.js +2 -0
  79. package/build/dist/Types/Monitor/CustomCodeMonitor/CapturedMetric.js.map +1 -0
  80. package/build/dist/Types/Monitor/UptimeBarTooltipIncident.js +2 -0
  81. package/build/dist/Types/Monitor/UptimeBarTooltipIncident.js.map +1 -0
  82. package/build/dist/Types/Profile/ProfileMetricType.js +17 -0
  83. package/build/dist/Types/Profile/ProfileMetricType.js.map +1 -0
  84. package/build/dist/Types/Span/SpanMetricType.js +18 -0
  85. package/build/dist/Types/Span/SpanMetricType.js.map +1 -0
  86. package/build/dist/UI/Components/Charts/Area/AreaChart.js +21 -16
  87. package/build/dist/UI/Components/Charts/Area/AreaChart.js.map +1 -1
  88. package/build/dist/UI/Components/Charts/Bar/BarChart.js +20 -15
  89. package/build/dist/UI/Components/Charts/Bar/BarChart.js.map +1 -1
  90. package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js +73 -15
  91. package/build/dist/UI/Components/Charts/ChartGroup/ChartGroup.js.map +1 -1
  92. package/build/dist/UI/Components/Charts/ChartGroup/NoDataMessage.js +7 -0
  93. package/build/dist/UI/Components/Charts/ChartGroup/NoDataMessage.js.map +1 -0
  94. package/build/dist/UI/Components/Charts/Line/LineChart.js +20 -15
  95. package/build/dist/UI/Components/Charts/Line/LineChart.js.map +1 -1
  96. package/build/dist/UI/Components/Forms/BasicForm.js +1 -1
  97. package/build/dist/UI/Components/Forms/BasicForm.js.map +1 -1
  98. package/build/dist/UI/Components/Graphs/DayUptimeGraph.js +46 -20
  99. package/build/dist/UI/Components/Graphs/DayUptimeGraph.js.map +1 -1
  100. package/build/dist/UI/Components/Graphs/UptimeBarTooltip.js +303 -0
  101. package/build/dist/UI/Components/Graphs/UptimeBarTooltip.js.map +1 -0
  102. package/build/dist/UI/Components/MonitorGraphs/Uptime.js +1 -1
  103. package/build/dist/UI/Components/MonitorGraphs/Uptime.js.map +1 -1
  104. package/build/dist/UI/Components/MonitorGraphs/UptimeBarDayModal.js +118 -0
  105. package/build/dist/UI/Components/MonitorGraphs/UptimeBarDayModal.js.map +1 -0
  106. package/build/dist/UI/Components/RadioButtons/GroupRadioButtons.js +1 -1
  107. package/build/dist/UI/Components/RadioButtons/GroupRadioButtons.js.map +1 -1
  108. package/build/dist/UI/Components/Tooltip/Tooltip.js +13 -3
  109. package/build/dist/UI/Components/Tooltip/Tooltip.js.map +1 -1
  110. package/build/dist/UI/Components/Workflow/ComponentSettingsModal.js +1 -1
  111. package/build/dist/UI/Components/Workflow/ComponentSettingsModal.js.map +1 -1
  112. package/build/dist/UI/Components/Workflow/DocumentationViewer.js +1 -0
  113. package/build/dist/UI/Components/Workflow/DocumentationViewer.js.map +1 -1
  114. package/build/dist/UI/Components/Workflow/Workflow.js +1 -1
  115. package/build/dist/UI/Components/Workflow/Workflow.js.map +1 -1
  116. package/build/dist/Utils/Alerts/AlertMetricType.js +84 -0
  117. package/build/dist/Utils/Alerts/AlertMetricType.js.map +1 -0
  118. package/build/dist/Utils/Incident/IncidentMetricType.js +114 -0
  119. package/build/dist/Utils/Incident/IncidentMetricType.js.map +1 -0
  120. package/package.json +3 -2
@@ -7,6 +7,7 @@ import ChartCurve from "../Types/ChartCurve";
7
7
  import ChartDataPoint from "../ChartLibrary/Types/ChartDataPoint";
8
8
  import DataPointUtil from "../Utils/DataPoint";
9
9
  import ChartReferenceLineProps from "../Types/ReferenceLineProps";
10
+ import NoDataMessage from "../ChartGroup/NoDataMessage";
10
11
 
11
12
  export interface ComponentProps {
12
13
  data: Array<SeriesPoint>;
@@ -32,12 +33,8 @@ const LineChartElement: FunctionComponent<LineInternalProps> = (
32
33
  });
33
34
 
34
35
  useEffect(() => {
35
- if (!props.data || props.data.length === 0) {
36
- setRecords([]);
37
- }
38
-
39
36
  const records: Array<ChartDataPoint> = DataPointUtil.getChartDataPoints({
40
- seriesPoints: props.data,
37
+ seriesPoints: props.data || [],
41
38
  xAxis: props.xAxis,
42
39
  yAxis: props.yAxis,
43
40
  });
@@ -50,34 +47,44 @@ const LineChartElement: FunctionComponent<LineInternalProps> = (
50
47
  ? { height: `${props.heightInPx}px` }
51
48
  : {};
52
49
 
50
+ const hasNoData: boolean =
51
+ !props.data ||
52
+ props.data.length === 0 ||
53
+ props.data.every((series: SeriesPoint) => {
54
+ return series.data.length === 0;
55
+ });
56
+
53
57
  return (
54
- <LineChart
55
- className={className}
56
- style={style}
57
- data={records}
58
- tickGap={1}
59
- index={"Time"}
60
- categories={categories}
61
- colors={[
62
- "indigo",
63
- "rose",
64
- "emerald",
65
- "amber",
66
- "cyan",
67
- "gray",
68
- "pink",
69
- "lime",
70
- "fuchsia",
71
- ]}
72
- valueFormatter={props.yAxis.options.formatter || undefined}
73
- showTooltip={true}
74
- connectNulls={true}
75
- curve={props.curve}
76
- syncid={props.sync ? props.syncid : undefined}
77
- yAxisWidth={60}
78
- onValueChange={() => {}}
79
- referenceLines={props.referenceLines}
80
- />
58
+ <div className="relative">
59
+ <LineChart
60
+ className={className}
61
+ style={style}
62
+ data={records}
63
+ tickGap={1}
64
+ index={"Time"}
65
+ categories={categories}
66
+ colors={[
67
+ "indigo",
68
+ "rose",
69
+ "emerald",
70
+ "amber",
71
+ "cyan",
72
+ "gray",
73
+ "pink",
74
+ "lime",
75
+ "fuchsia",
76
+ ]}
77
+ valueFormatter={props.yAxis.options.formatter || undefined}
78
+ showTooltip={true}
79
+ connectNulls={true}
80
+ curve={props.curve}
81
+ syncid={props.sync ? props.syncid : undefined}
82
+ yAxisWidth={60}
83
+ onValueChange={() => {}}
84
+ referenceLines={props.referenceLines}
85
+ />
86
+ {hasNoData && <NoDataMessage />}
87
+ </div>
81
88
  );
82
89
  };
83
90
 
@@ -607,7 +607,7 @@ const BasicForm: ForwardRefExoticComponent<any> = forwardRef(
607
607
  }
608
608
 
609
609
  return (
610
- <div className="row">
610
+ <div className="row" id={props.id}>
611
611
  <div className="col-lg-1">
612
612
  <div>
613
613
  {props.title && (
@@ -1,9 +1,11 @@
1
1
  import Tooltip from "../Tooltip/Tooltip";
2
+ import UptimeBarTooltip, { StatusDuration } from "./UptimeBarTooltip";
2
3
  import { Green } from "../../../Types/BrandColors";
3
4
  import Color from "../../../Types/Color";
4
5
  import OneUptimeDate from "../../../Types/Date";
5
6
  import Dictionary from "../../../Types/Dictionary";
6
7
  import ObjectID from "../../../Types/ObjectID";
8
+ import UptimeBarTooltipIncident from "../../../Types/Monitor/UptimeBarTooltipIncident";
7
9
  import React, {
8
10
  FunctionComponent,
9
11
  ReactElement,
@@ -27,6 +29,11 @@ export interface ComponentProps {
27
29
  barColorRules?: Array<BarChartRule> | undefined;
28
30
  downtimeEventStatusIds?: Array<ObjectID> | undefined;
29
31
  defaultBarColor: Color;
32
+ incidents?: Array<UptimeBarTooltipIncident> | undefined;
33
+ onBarClick?:
34
+ | ((date: Date, incidents: Array<UptimeBarTooltipIncident>) => void)
35
+ | undefined;
36
+ onIncidentClick?: ((incidentId: string) => void) | undefined;
30
37
  }
31
38
 
32
39
  const DayUptimeGraph: FunctionComponent<ComponentProps> = (
@@ -43,6 +50,24 @@ const DayUptimeGraph: FunctionComponent<ComponentProps> = (
43
50
  );
44
51
  }, [props.startDate, props.endDate]);
45
52
 
53
+ type GetIncidentsForDayFunction = (
54
+ startOfDay: Date,
55
+ endOfDay: Date,
56
+ ) => Array<UptimeBarTooltipIncident>;
57
+
58
+ const getIncidentsForDay: GetIncidentsForDayFunction = (
59
+ startOfDay: Date,
60
+ endOfDay: Date,
61
+ ): Array<UptimeBarTooltipIncident> => {
62
+ if (!props.incidents || props.incidents.length === 0) {
63
+ return [];
64
+ }
65
+
66
+ return props.incidents.filter((incident: UptimeBarTooltipIncident) => {
67
+ return OneUptimeDate.isBetween(incident.declaredAt, startOfDay, endOfDay);
68
+ });
69
+ };
70
+
46
71
  type GetUptimeBarFunction = (dayNumber: number) => ReactElement;
47
72
 
48
73
  const getUptimeBar: GetUptimeBarFunction = (
@@ -55,11 +80,6 @@ const DayUptimeGraph: FunctionComponent<ComponentProps> = (
55
80
  dayNumber,
56
81
  );
57
82
 
58
- let toolTipText: string = `${OneUptimeDate.getDateAsUserFriendlyLocalFormattedString(
59
- todaysDay,
60
- true,
61
- )}`;
62
-
63
83
  const startOfTheDay: Date = OneUptimeDate.getStartOfDay(todaysDay);
64
84
  const endOfTheDay: Date = OneUptimeDate.getEndOfDay(todaysDay);
65
85
 
@@ -90,6 +110,7 @@ const DayUptimeGraph: FunctionComponent<ComponentProps> = (
90
110
  });
91
111
 
92
112
  const secondsOfEvent: Dictionary<number> = {};
113
+ const eventColors: Dictionary<Color> = {};
93
114
 
94
115
  let currentPriority: number = 1;
95
116
 
@@ -121,6 +142,7 @@ const DayUptimeGraph: FunctionComponent<ComponentProps> = (
121
142
  secondsOfEvent[event.eventStatusId.toString()]! += seconds;
122
143
 
123
144
  eventLabels[event.eventStatusId.toString()] = event.label;
145
+ eventColors[event.eventStatusId.toString()] = event.color;
124
146
 
125
147
  // set bar color.
126
148
  if (currentPriority <= event.priority) {
@@ -140,33 +162,21 @@ const DayUptimeGraph: FunctionComponent<ComponentProps> = (
140
162
 
141
163
  let totalUptimeInSeconds: number = 0;
142
164
 
165
+ const downtimeStatusIds: Array<string> = (
166
+ props.downtimeEventStatusIds || []
167
+ ).map((id: ObjectID) => {
168
+ return id.toString();
169
+ });
170
+
143
171
  for (const key in secondsOfEvent) {
144
172
  hasEvents = true;
145
173
 
146
174
  const eventStatusId: string = key;
147
175
 
148
- // if this is downtime state then, include tooltip.
149
-
150
- if (
151
- (props.downtimeEventStatusIds?.filter((id: ObjectID) => {
152
- return id.toString() === eventStatusId.toString();
153
- }).length || 0) > 0
154
- ) {
155
- toolTipText += `, ${
156
- eventLabels[key]
157
- } for ${OneUptimeDate.secondsToFormattedFriendlyTimeString(
158
- secondsOfEvent[key] || 0,
159
- )}`;
160
- }
161
-
162
- const isDowntimeEvent: boolean = Boolean(
163
- props.downtimeEventStatusIds?.find((id: ObjectID) => {
164
- return id.toString() === eventStatusId;
165
- }),
166
- );
176
+ const isDowntimeEvent: boolean =
177
+ downtimeStatusIds.includes(eventStatusId);
167
178
 
168
179
  if (isDowntimeEvent) {
169
- // remove the seconds from total uptime.
170
180
  const secondsOfDowntime: number = secondsOfEvent[key] || 0;
171
181
  totalDowntimeInSeconds += secondsOfDowntime;
172
182
  } else {
@@ -177,8 +187,11 @@ const DayUptimeGraph: FunctionComponent<ComponentProps> = (
177
187
  // now check bar rules and finalize the color of the bar
178
188
 
179
189
  const uptimePercentForTheDay: number =
180
- (totalUptimeInSeconds / (totalDowntimeInSeconds + totalUptimeInSeconds)) *
181
- 100;
190
+ totalUptimeInSeconds + totalDowntimeInSeconds > 0
191
+ ? (totalUptimeInSeconds /
192
+ (totalDowntimeInSeconds + totalUptimeInSeconds)) *
193
+ 100
194
+ : 100;
182
195
 
183
196
  for (const rules of props.barColorRules || []) {
184
197
  if (uptimePercentForTheDay >= rules.uptimePercentGreaterThanOrEqualTo) {
@@ -187,31 +200,71 @@ const DayUptimeGraph: FunctionComponent<ComponentProps> = (
187
200
  }
188
201
  }
189
202
 
203
+ if (todaysEvents.length === 1 && !hasEvents) {
204
+ hasEvents = true;
205
+ }
206
+
190
207
  if (todaysEvents.length === 1) {
191
208
  hasEvents = true;
192
- toolTipText = `${OneUptimeDate.getDateAsUserFriendlyLocalFormattedString(
193
- todaysDay,
194
- true,
195
- )} - 100% ${todaysEvents[0]?.label || "Operational"}.`;
196
209
  }
197
210
 
198
- if (!hasEvents) {
199
- toolTipText += ` - No data for this day.`;
211
+ if (todaysEvents.length === 0) {
212
+ hasEvents = false;
200
213
  color = props.defaultBarColor || Green;
201
214
  }
202
215
 
216
+ // Get incidents for this day
217
+ const dayIncidents: Array<UptimeBarTooltipIncident> = getIncidentsForDay(
218
+ startOfTheDay,
219
+ endOfTheDay,
220
+ );
221
+
203
222
  let className: string = "h-20 w-20";
204
223
 
205
224
  if (props.height) {
206
225
  className = "w-20 h-" + props.height;
207
226
  }
227
+
228
+ // Build status durations for tooltip
229
+ const statusDurations: Array<StatusDuration> = [];
230
+ for (const key in secondsOfEvent) {
231
+ statusDurations.push({
232
+ label: eventLabels[key] || "Unknown",
233
+ seconds: secondsOfEvent[key] || 0,
234
+ color: eventColors[key] || props.defaultBarColor || Green,
235
+ isDowntime: downtimeStatusIds.includes(key),
236
+ });
237
+ }
238
+
239
+ const hasDayIncidents: boolean = dayIncidents.length > 0;
240
+ const isClickable: boolean = hasDayIncidents && Boolean(props.onBarClick);
241
+
208
242
  return (
209
- <Tooltip key={dayNumber} text={toolTipText || "100% Operational"}>
243
+ <Tooltip
244
+ key={dayNumber}
245
+ richContent={
246
+ <UptimeBarTooltip
247
+ date={todaysDay}
248
+ uptimePercent={uptimePercentForTheDay}
249
+ hasEvents={hasEvents}
250
+ statusDurations={statusDurations}
251
+ incidents={dayIncidents}
252
+ onIncidentClick={props.onIncidentClick}
253
+ />
254
+ }
255
+ >
210
256
  <div
211
- className={className}
257
+ className={`${className}${isClickable ? " cursor-pointer hover:opacity-80" : ""}`}
212
258
  style={{
213
259
  backgroundColor: color.toString(),
214
260
  }}
261
+ onClick={
262
+ isClickable
263
+ ? () => {
264
+ props.onBarClick!(todaysDay, dayIncidents);
265
+ }
266
+ : undefined
267
+ }
215
268
  ></div>
216
269
  </Tooltip>
217
270
  );