@checkstack/healthcheck-http-backend 0.1.0 → 0.1.1

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,29 @@
1
1
  # @checkstack/healthcheck-http-backend
2
2
 
3
+ ## 0.1.1
4
+
5
+ ### Patch Changes
6
+
7
+ - 97c5a6b: Add UUID-based collector identification for better multiple collector support
8
+
9
+ **Breaking Change**: Existing health check configurations with collectors need to be recreated.
10
+
11
+ - Each collector instance now has a unique UUID assigned on creation
12
+ - Collector results are stored under the UUID key with `_collectorId` and `_assertionFailed` metadata
13
+ - Auto-charts correctly display separate charts for each collector instance
14
+ - Charts are now grouped by collector instance with clear headings
15
+ - Assertion status card shows pass/fail for each collector
16
+ - Renamed "Success" to "HTTP Success" to clarify it's about HTTP request success
17
+ - Fixed deletion of collectors not persisting to database
18
+ - Fixed duplicate React key warnings in auto-chart grid
19
+
20
+ - Updated dependencies [97c5a6b]
21
+ - Updated dependencies [8e43507]
22
+ - Updated dependencies [97c5a6b]
23
+ - @checkstack/backend-api@0.2.0
24
+ - @checkstack/common@0.1.0
25
+ - @checkstack/healthcheck-common@0.2.0
26
+
3
27
  ## 0.1.0
4
28
 
5
29
  ### Minor Changes
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@checkstack/healthcheck-http-backend",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "type": "module",
5
5
  "main": "src/index.ts",
6
6
  "scripts": {
@@ -64,7 +64,7 @@ const requestResultSchema = z.object({
64
64
  }),
65
65
  success: healthResultBoolean({
66
66
  "x-chart-type": "boolean",
67
- "x-chart-label": "Success",
67
+ "x-chart-label": "HTTP Success",
68
68
  }),
69
69
  });
70
70
 
@@ -181,16 +181,16 @@ describe("HttpHealthCheckStrategy", () => {
181
181
  });
182
182
 
183
183
  describe("aggregateResult", () => {
184
- it("should calculate status code counts correctly", () => {
184
+ it("should count errors correctly", () => {
185
185
  const runs = [
186
186
  {
187
187
  id: "1",
188
- status: "healthy" as const,
188
+ status: "unhealthy" as const,
189
189
  latencyMs: 100,
190
190
  checkId: "c1",
191
191
  timestamp: new Date(),
192
192
  metadata: {
193
- statusCode: 200,
193
+ error: "Connection refused",
194
194
  },
195
195
  },
196
196
  {
@@ -199,40 +199,34 @@ describe("HttpHealthCheckStrategy", () => {
199
199
  latencyMs: 150,
200
200
  checkId: "c1",
201
201
  timestamp: new Date(),
202
- metadata: {
203
- statusCode: 200,
204
- },
202
+ metadata: {},
205
203
  },
206
204
  {
207
205
  id: "3",
208
- status: "healthy" as const,
206
+ status: "unhealthy" as const,
209
207
  latencyMs: 120,
210
208
  checkId: "c1",
211
209
  timestamp: new Date(),
212
210
  metadata: {
213
- statusCode: 404,
211
+ error: "Timeout",
214
212
  },
215
213
  },
216
214
  ];
217
215
 
218
216
  const aggregated = strategy.aggregateResult(runs);
219
217
 
220
- expect(aggregated.statusCodeCounts["200"]).toBe(2);
221
- expect(aggregated.statusCodeCounts["404"]).toBe(1);
222
- expect(aggregated.successRate).toBe(100);
218
+ expect(aggregated.errorCount).toBe(2);
223
219
  });
224
220
 
225
- it("should count errors", () => {
221
+ it("should return zero errors when all runs succeed", () => {
226
222
  const runs = [
227
223
  {
228
224
  id: "1",
229
- status: "unhealthy" as const,
225
+ status: "healthy" as const,
230
226
  latencyMs: 100,
231
227
  checkId: "c1",
232
228
  timestamp: new Date(),
233
- metadata: {
234
- error: "Connection refused",
235
- },
229
+ metadata: {},
236
230
  },
237
231
  {
238
232
  id: "2",
@@ -240,17 +234,13 @@ describe("HttpHealthCheckStrategy", () => {
240
234
  latencyMs: 150,
241
235
  checkId: "c1",
242
236
  timestamp: new Date(),
243
- metadata: {
244
- statusCode: 200,
245
- responseTime: 100,
246
- },
237
+ metadata: {},
247
238
  },
248
239
  ];
249
240
 
250
241
  const aggregated = strategy.aggregateResult(runs);
251
242
 
252
- expect(aggregated.errorCount).toBe(1);
253
- expect(aggregated.successRate).toBe(50);
243
+ expect(aggregated.errorCount).toBe(0);
254
244
  });
255
245
  });
256
246
  });
package/src/strategy.ts CHANGED
@@ -48,14 +48,6 @@ interface HttpConfigV2 extends HttpConfigV1 {
48
48
 
49
49
  /** Per-run result metadata */
50
50
  const httpResultMetadataSchema = z.object({
51
- statusCode: healthResultNumber({
52
- "x-chart-type": "pie",
53
- "x-chart-label": "Status Code",
54
- }).optional(),
55
- contentType: healthResultString({
56
- "x-chart-type": "counter",
57
- "x-chart-label": "Content Type",
58
- }).optional(),
59
51
  error: healthResultString({
60
52
  "x-chart-type": "status",
61
53
  "x-chart-label": "Error",
@@ -66,14 +58,6 @@ type HttpResultMetadata = z.infer<typeof httpResultMetadataSchema>;
66
58
 
67
59
  /** Aggregated metadata for buckets */
68
60
  const httpAggregatedMetadataSchema = z.object({
69
- statusCodeCounts: z.record(z.string(), z.number()).meta({
70
- "x-chart-type": "pie",
71
- "x-chart-label": "Status Code Distribution",
72
- }),
73
- successRate: healthResultNumber({
74
- "x-chart-type": "gauge",
75
- "x-chart-label": "Success Rate (%)",
76
- }),
77
61
  errorCount: healthResultNumber({
78
62
  "x-chart-type": "counter",
79
63
  "x-chart-label": "Errors",
@@ -137,26 +121,15 @@ export class HttpHealthCheckStrategy
137
121
  aggregateResult(
138
122
  runs: HealthCheckRunForAggregation<HttpResultMetadata>[]
139
123
  ): HttpAggregatedMetadata {
140
- const statusCodeCounts: Record<string, number> = {};
141
124
  let errorCount = 0;
142
- let successCount = 0;
143
125
 
144
126
  for (const run of runs) {
145
127
  if (run.metadata?.error) {
146
128
  errorCount++;
147
- } else {
148
- successCount++;
149
- }
150
-
151
- if (run.metadata?.statusCode !== undefined) {
152
- const key = String(run.metadata.statusCode);
153
- statusCodeCounts[key] = (statusCodeCounts[key] || 0) + 1;
154
129
  }
155
130
  }
156
- const successRate =
157
- runs.length > 0 ? Math.round((successCount / runs.length) * 100) : 0;
158
131
 
159
- return { statusCodeCounts, successRate, errorCount };
132
+ return { errorCount };
160
133
  }
161
134
 
162
135
  /**