@honeybadger-io/js 6.7.2 → 6.8.0
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/README.md +11 -0
- package/dist/browser/honeybadger.js +2 -2
- package/dist/browser/honeybadger.min.js +1 -1
- package/dist/server/check-ins-manager/check-in.d.ts +7 -4
- package/dist/server/check-ins-manager/client.d.ts +6 -8
- package/dist/server/check-ins-manager/types.d.ts +5 -8
- package/dist/server/check-ins-sync-exec.js +122 -106
- package/dist/server/check-ins-sync-exec.js.map +1 -1
- package/dist/server/honeybadger.d.ts +4 -2
- package/dist/server/honeybadger.js +107 -84
- package/dist/server/honeybadger.js.map +1 -1
- package/package.json +2 -2
|
@@ -1105,7 +1105,7 @@ var Client = /** @class */ (function () {
|
|
|
1105
1105
|
this.__notifier = {
|
|
1106
1106
|
name: '@honeybadger-io/core',
|
|
1107
1107
|
url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/core',
|
|
1108
|
-
version: '6.
|
|
1108
|
+
version: '6.8.0'
|
|
1109
1109
|
};
|
|
1110
1110
|
this.config = __assign$1(__assign$1({}, defaults_1.CONFIG), opts);
|
|
1111
1111
|
this.__initStore();
|
|
@@ -2231,7 +2231,6 @@ var CheckIn = /** @class */ (function () {
|
|
|
2231
2231
|
this.gracePeriod = props.gracePeriod;
|
|
2232
2232
|
this.cronSchedule = props.cronSchedule;
|
|
2233
2233
|
this.cronTimezone = props.cronTimezone;
|
|
2234
|
-
this.projectId = props.projectId;
|
|
2235
2234
|
this.deleted = false;
|
|
2236
2235
|
}
|
|
2237
2236
|
CheckIn.prototype.isDeleted = function () {
|
|
@@ -2241,39 +2240,36 @@ var CheckIn = /** @class */ (function () {
|
|
|
2241
2240
|
this.deleted = true;
|
|
2242
2241
|
};
|
|
2243
2242
|
CheckIn.prototype.validate = function () {
|
|
2244
|
-
if (!this.
|
|
2245
|
-
throw new Error('
|
|
2246
|
-
}
|
|
2247
|
-
if (!this.name) {
|
|
2248
|
-
throw new Error('name is required for each check-in');
|
|
2243
|
+
if (!this.slug) {
|
|
2244
|
+
throw new Error('slug is required for each check-in');
|
|
2249
2245
|
}
|
|
2250
2246
|
if (!this.scheduleType) {
|
|
2251
2247
|
throw new Error('scheduleType is required for each check-in');
|
|
2252
2248
|
}
|
|
2253
2249
|
if (!['simple', 'cron'].includes(this.scheduleType)) {
|
|
2254
|
-
throw new Error("".concat(this.
|
|
2250
|
+
throw new Error("".concat(this.slug, " [scheduleType] must be \"simple\" or \"cron\""));
|
|
2255
2251
|
}
|
|
2256
2252
|
if (this.scheduleType === 'simple' && !this.reportPeriod) {
|
|
2257
|
-
throw new Error("".concat(this.
|
|
2253
|
+
throw new Error("".concat(this.slug, " [reportPeriod] is required for simple check-ins"));
|
|
2258
2254
|
}
|
|
2259
2255
|
if (this.scheduleType === 'cron' && !this.cronSchedule) {
|
|
2260
|
-
throw new Error("".concat(this.
|
|
2256
|
+
throw new Error("".concat(this.slug, " [cronSchedule] is required for cron check-ins"));
|
|
2261
2257
|
}
|
|
2262
2258
|
};
|
|
2263
2259
|
CheckIn.prototype.asRequestPayload = function () {
|
|
2264
|
-
var _a, _b
|
|
2260
|
+
var _a, _b;
|
|
2265
2261
|
var payload = {
|
|
2266
2262
|
name: this.name,
|
|
2267
2263
|
schedule_type: this.scheduleType,
|
|
2268
|
-
slug:
|
|
2269
|
-
grace_period: (
|
|
2264
|
+
slug: this.slug,
|
|
2265
|
+
grace_period: (_a = this.gracePeriod) !== null && _a !== void 0 ? _a : '' // default is empty string
|
|
2270
2266
|
};
|
|
2271
2267
|
if (this.scheduleType === 'simple') {
|
|
2272
2268
|
payload.report_period = this.reportPeriod;
|
|
2273
2269
|
}
|
|
2274
2270
|
else {
|
|
2275
2271
|
payload.cron_schedule = this.cronSchedule;
|
|
2276
|
-
payload.cron_timezone = (
|
|
2272
|
+
payload.cron_timezone = (_b = this.cronTimezone) !== null && _b !== void 0 ? _b : ''; // default is empty string
|
|
2277
2273
|
}
|
|
2278
2274
|
return payload;
|
|
2279
2275
|
};
|
|
@@ -2281,21 +2277,25 @@ var CheckIn = /** @class */ (function () {
|
|
|
2281
2277
|
* Compares two check-ins, usually the one from the API and the one from the config file.
|
|
2282
2278
|
* If the one in the config file does not match the check-in from the API,
|
|
2283
2279
|
* then we issue an update request.
|
|
2280
|
+
*
|
|
2281
|
+
* `name`, `gracePeriod` and `cronTimezone` are optional fields that are automatically
|
|
2282
|
+
* set to a value from the server if one is not provided,
|
|
2283
|
+
* so we ignore their values if they are not set locally.
|
|
2284
2284
|
*/
|
|
2285
2285
|
CheckIn.prototype.isInSync = function (other) {
|
|
2286
|
-
var
|
|
2287
|
-
|
|
2288
|
-
|
|
2286
|
+
var ignoreNameCheck = this.name === undefined;
|
|
2287
|
+
var ignoreGracePeriodCheck = this.gracePeriod === undefined;
|
|
2288
|
+
var ignoreCronTimezoneCheck = this.cronTimezone === undefined;
|
|
2289
|
+
return this.slug === other.slug
|
|
2289
2290
|
&& this.scheduleType === other.scheduleType
|
|
2290
2291
|
&& this.reportPeriod === other.reportPeriod
|
|
2291
2292
|
&& this.cronSchedule === other.cronSchedule
|
|
2292
|
-
&& (
|
|
2293
|
-
&& (
|
|
2294
|
-
&& (
|
|
2293
|
+
&& (ignoreNameCheck || this.name === other.name)
|
|
2294
|
+
&& (ignoreGracePeriodCheck || this.gracePeriod === other.gracePeriod)
|
|
2295
|
+
&& (ignoreCronTimezoneCheck || this.cronTimezone === other.cronTimezone);
|
|
2295
2296
|
};
|
|
2296
|
-
CheckIn.fromResponsePayload = function (
|
|
2297
|
+
CheckIn.fromResponsePayload = function (payload) {
|
|
2297
2298
|
return new CheckIn({
|
|
2298
|
-
projectId: projectId,
|
|
2299
2299
|
id: payload.id,
|
|
2300
2300
|
name: payload.name,
|
|
2301
2301
|
slug: payload.slug,
|
|
@@ -2355,17 +2355,40 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
2355
2355
|
this.transport = transport;
|
|
2356
2356
|
this.config = config;
|
|
2357
2357
|
this.logger = config.logger;
|
|
2358
|
-
this.cache = {};
|
|
2359
2358
|
}
|
|
2359
|
+
CheckInsClient.prototype.getProjectId = function (projectApiKey) {
|
|
2360
|
+
var _a;
|
|
2361
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2362
|
+
var response, data;
|
|
2363
|
+
return __generator(this, function (_b) {
|
|
2364
|
+
switch (_b.label) {
|
|
2365
|
+
case 0:
|
|
2366
|
+
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2367
|
+
throw new Error('personalAuthToken is required');
|
|
2368
|
+
}
|
|
2369
|
+
return [4 /*yield*/, this.transport.send({
|
|
2370
|
+
method: 'GET',
|
|
2371
|
+
headers: this.getHeaders(),
|
|
2372
|
+
endpoint: "".concat(this.BASE_URL, "/v2/project_keys/").concat(projectApiKey),
|
|
2373
|
+
logger: this.logger,
|
|
2374
|
+
})];
|
|
2375
|
+
case 1:
|
|
2376
|
+
response = _b.sent();
|
|
2377
|
+
if (response.statusCode !== 200) {
|
|
2378
|
+
throw new Error("Failed to fetch project[".concat(projectApiKey, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2379
|
+
}
|
|
2380
|
+
data = JSON.parse(response.body);
|
|
2381
|
+
return [2 /*return*/, (_a = data === null || data === void 0 ? void 0 : data.project) === null || _a === void 0 ? void 0 : _a.id];
|
|
2382
|
+
}
|
|
2383
|
+
});
|
|
2384
|
+
});
|
|
2385
|
+
};
|
|
2360
2386
|
CheckInsClient.prototype.listForProject = function (projectId) {
|
|
2361
2387
|
return __awaiter(this, void 0, void 0, function () {
|
|
2362
|
-
var response, data
|
|
2388
|
+
var response, data;
|
|
2363
2389
|
return __generator(this, function (_a) {
|
|
2364
2390
|
switch (_a.label) {
|
|
2365
2391
|
case 0:
|
|
2366
|
-
if (this.cache[projectId]) {
|
|
2367
|
-
return [2 /*return*/, this.cache[projectId]];
|
|
2368
|
-
}
|
|
2369
2392
|
if (!this.config.personalAuthToken || this.config.personalAuthToken === '') {
|
|
2370
2393
|
throw new Error('personalAuthToken is required');
|
|
2371
2394
|
}
|
|
@@ -2381,16 +2404,14 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
2381
2404
|
throw new Error("Failed to fetch checkins for project[".concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2382
2405
|
}
|
|
2383
2406
|
data = JSON.parse(response.body);
|
|
2384
|
-
|
|
2385
|
-
this.cache[projectId] = checkIns;
|
|
2386
|
-
return [2 /*return*/, checkIns];
|
|
2407
|
+
return [2 /*return*/, data.results.map(function (checkin) { return check_in_1.CheckIn.fromResponsePayload(checkin); })];
|
|
2387
2408
|
}
|
|
2388
2409
|
});
|
|
2389
2410
|
});
|
|
2390
2411
|
};
|
|
2391
2412
|
CheckInsClient.prototype.get = function (projectId, checkInId) {
|
|
2392
2413
|
return __awaiter(this, void 0, void 0, function () {
|
|
2393
|
-
var response, data
|
|
2414
|
+
var response, data;
|
|
2394
2415
|
return __generator(this, function (_a) {
|
|
2395
2416
|
switch (_a.label) {
|
|
2396
2417
|
case 0:
|
|
@@ -2409,16 +2430,14 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
2409
2430
|
throw new Error("Failed to fetch check-in[".concat(checkInId, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2410
2431
|
}
|
|
2411
2432
|
data = JSON.parse(response.body);
|
|
2412
|
-
|
|
2413
|
-
checkIn.projectId = projectId;
|
|
2414
|
-
return [2 /*return*/, checkIn];
|
|
2433
|
+
return [2 /*return*/, check_in_1.CheckIn.fromResponsePayload(data)];
|
|
2415
2434
|
}
|
|
2416
2435
|
});
|
|
2417
2436
|
});
|
|
2418
2437
|
};
|
|
2419
|
-
CheckInsClient.prototype.create = function (checkIn) {
|
|
2438
|
+
CheckInsClient.prototype.create = function (projectId, checkIn) {
|
|
2420
2439
|
return __awaiter(this, void 0, void 0, function () {
|
|
2421
|
-
var response, data
|
|
2440
|
+
var response, data;
|
|
2422
2441
|
return __generator(this, function (_a) {
|
|
2423
2442
|
switch (_a.label) {
|
|
2424
2443
|
case 0:
|
|
@@ -2428,23 +2447,21 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
2428
2447
|
return [4 /*yield*/, this.transport.send({
|
|
2429
2448
|
method: 'POST',
|
|
2430
2449
|
headers: this.getHeaders(),
|
|
2431
|
-
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(
|
|
2450
|
+
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(projectId, "/check_ins"),
|
|
2432
2451
|
logger: this.logger,
|
|
2433
2452
|
}, { check_in: checkIn.asRequestPayload() })];
|
|
2434
2453
|
case 1:
|
|
2435
2454
|
response = _a.sent();
|
|
2436
2455
|
if (response.statusCode !== 201) {
|
|
2437
|
-
throw new Error("Failed to create check-in[".concat(checkIn.
|
|
2456
|
+
throw new Error("Failed to create check-in[".concat(checkIn.slug, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2438
2457
|
}
|
|
2439
2458
|
data = JSON.parse(response.body);
|
|
2440
|
-
|
|
2441
|
-
result.projectId = checkIn.projectId;
|
|
2442
|
-
return [2 /*return*/, result];
|
|
2459
|
+
return [2 /*return*/, check_in_1.CheckIn.fromResponsePayload(data)];
|
|
2443
2460
|
}
|
|
2444
2461
|
});
|
|
2445
2462
|
});
|
|
2446
2463
|
};
|
|
2447
|
-
CheckInsClient.prototype.update = function (checkIn) {
|
|
2464
|
+
CheckInsClient.prototype.update = function (projectId, checkIn) {
|
|
2448
2465
|
return __awaiter(this, void 0, void 0, function () {
|
|
2449
2466
|
var response;
|
|
2450
2467
|
return __generator(this, function (_a) {
|
|
@@ -2456,20 +2473,20 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
2456
2473
|
return [4 /*yield*/, this.transport.send({
|
|
2457
2474
|
method: 'PUT',
|
|
2458
2475
|
headers: this.getHeaders(),
|
|
2459
|
-
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(
|
|
2476
|
+
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(projectId, "/check_ins/").concat(checkIn.id),
|
|
2460
2477
|
logger: this.logger,
|
|
2461
2478
|
}, { check_in: checkIn.asRequestPayload() })];
|
|
2462
2479
|
case 1:
|
|
2463
2480
|
response = _a.sent();
|
|
2464
2481
|
if (response.statusCode !== 204) {
|
|
2465
|
-
throw new Error("Failed to update checkin[".concat(checkIn.
|
|
2482
|
+
throw new Error("Failed to update checkin[".concat(checkIn.slug, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2466
2483
|
}
|
|
2467
2484
|
return [2 /*return*/, checkIn];
|
|
2468
2485
|
}
|
|
2469
2486
|
});
|
|
2470
2487
|
});
|
|
2471
2488
|
};
|
|
2472
|
-
CheckInsClient.prototype.remove = function (checkIn) {
|
|
2489
|
+
CheckInsClient.prototype.remove = function (projectId, checkIn) {
|
|
2473
2490
|
return __awaiter(this, void 0, void 0, function () {
|
|
2474
2491
|
var response;
|
|
2475
2492
|
return __generator(this, function (_a) {
|
|
@@ -2481,13 +2498,13 @@ var CheckInsClient = /** @class */ (function () {
|
|
|
2481
2498
|
return [4 /*yield*/, this.transport.send({
|
|
2482
2499
|
method: 'DELETE',
|
|
2483
2500
|
headers: this.getHeaders(),
|
|
2484
|
-
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(
|
|
2501
|
+
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(projectId, "/check_ins/").concat(checkIn.id),
|
|
2485
2502
|
logger: this.logger,
|
|
2486
2503
|
})];
|
|
2487
2504
|
case 1:
|
|
2488
2505
|
response = _a.sent();
|
|
2489
2506
|
if (response.statusCode !== 204) {
|
|
2490
|
-
throw new Error("Failed to remove checkin[".concat(checkIn.
|
|
2507
|
+
throw new Error("Failed to remove checkin[".concat(checkIn.slug, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2491
2508
|
}
|
|
2492
2509
|
return [2 /*return*/];
|
|
2493
2510
|
}
|
|
@@ -2654,66 +2671,72 @@ client.CheckInsClient = CheckInsClient;
|
|
|
2654
2671
|
Honeybadger.prototype.showUserFeedbackForm = function () {
|
|
2655
2672
|
throw new Error('Honeybadger.showUserFeedbackForm() is not supported on the server-side');
|
|
2656
2673
|
};
|
|
2657
|
-
Honeybadger.prototype.checkIn = function (
|
|
2674
|
+
Honeybadger.prototype.checkIn = function (idOrSlug) {
|
|
2658
2675
|
return __awaiter(this, void 0, void 0, function () {
|
|
2659
|
-
|
|
2676
|
+
return __generator(this, function (_a) {
|
|
2677
|
+
if (this.isCheckInSlug(idOrSlug)) {
|
|
2678
|
+
return [2 /*return*/, this.checkInWithSlug(idOrSlug)];
|
|
2679
|
+
}
|
|
2680
|
+
return [2 /*return*/, this.checkInWithId(idOrSlug)];
|
|
2681
|
+
});
|
|
2682
|
+
});
|
|
2683
|
+
};
|
|
2684
|
+
Honeybadger.prototype.checkInWithSlug = function (slug) {
|
|
2685
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
2686
|
+
var err_1;
|
|
2660
2687
|
return __generator(this, function (_a) {
|
|
2661
2688
|
switch (_a.label) {
|
|
2662
2689
|
case 0:
|
|
2663
|
-
_a.trys.push([0,
|
|
2664
|
-
return [4 /*yield*/, this.getCheckInId(idOrName)];
|
|
2665
|
-
case 1:
|
|
2666
|
-
id = _a.sent();
|
|
2690
|
+
_a.trys.push([0, 2, , 3]);
|
|
2667
2691
|
return [4 /*yield*/, this.__transport
|
|
2668
2692
|
.send({
|
|
2669
2693
|
method: 'GET',
|
|
2670
|
-
endpoint: endpoint(this.config.endpoint, "v1/check_in/".concat(
|
|
2694
|
+
endpoint: endpoint(this.config.endpoint, "v1/check_in/".concat(this.config.apiKey, "/").concat(slug)),
|
|
2671
2695
|
logger: this.logger,
|
|
2672
2696
|
})];
|
|
2673
|
-
case
|
|
2697
|
+
case 1:
|
|
2674
2698
|
_a.sent();
|
|
2675
|
-
this.logger.info(
|
|
2676
|
-
return [3 /*break*/,
|
|
2677
|
-
case
|
|
2699
|
+
this.logger.info("Check-In with slug[".concat(slug, "] sent"));
|
|
2700
|
+
return [3 /*break*/, 3];
|
|
2701
|
+
case 2:
|
|
2678
2702
|
err_1 = _a.sent();
|
|
2679
|
-
this.logger.error("CheckIn[".concat(
|
|
2680
|
-
return [3 /*break*/,
|
|
2681
|
-
case
|
|
2703
|
+
this.logger.error("CheckIn with slug[".concat(slug, "] failed: an unknown error occurred."), "message=".concat(err_1.message));
|
|
2704
|
+
return [3 /*break*/, 3];
|
|
2705
|
+
case 3: return [2 /*return*/];
|
|
2682
2706
|
}
|
|
2683
2707
|
});
|
|
2684
2708
|
});
|
|
2685
2709
|
};
|
|
2686
|
-
Honeybadger.prototype.
|
|
2710
|
+
Honeybadger.prototype.checkInWithId = function (id) {
|
|
2687
2711
|
return __awaiter(this, void 0, void 0, function () {
|
|
2688
|
-
var
|
|
2712
|
+
var err_2;
|
|
2689
2713
|
return __generator(this, function (_a) {
|
|
2690
2714
|
switch (_a.label) {
|
|
2691
2715
|
case 0:
|
|
2692
|
-
|
|
2693
|
-
|
|
2694
|
-
|
|
2695
|
-
|
|
2696
|
-
|
|
2697
|
-
|
|
2698
|
-
|
|
2699
|
-
if (localCheckIn.id) {
|
|
2700
|
-
return [2 /*return*/, localCheckIn.id];
|
|
2701
|
-
}
|
|
2702
|
-
return [4 /*yield*/, this.__checkInsClient.listForProject(localCheckIn.projectId)];
|
|
2716
|
+
_a.trys.push([0, 2, , 3]);
|
|
2717
|
+
return [4 /*yield*/, this.__transport
|
|
2718
|
+
.send({
|
|
2719
|
+
method: 'GET',
|
|
2720
|
+
endpoint: endpoint(this.config.endpoint, "v1/check_in/".concat(id)),
|
|
2721
|
+
logger: this.logger,
|
|
2722
|
+
})];
|
|
2703
2723
|
case 1:
|
|
2704
|
-
|
|
2705
|
-
|
|
2706
|
-
|
|
2707
|
-
|
|
2708
|
-
|
|
2709
|
-
|
|
2710
|
-
|
|
2711
|
-
|
|
2712
|
-
return [2 /*return*/, localCheckIn.id];
|
|
2724
|
+
_a.sent();
|
|
2725
|
+
this.logger.info("Check-In with id[".concat(id, "] sent"));
|
|
2726
|
+
return [3 /*break*/, 3];
|
|
2727
|
+
case 2:
|
|
2728
|
+
err_2 = _a.sent();
|
|
2729
|
+
this.logger.error("Check-In with id[".concat(id, "] failed: an unknown error occurred."), "message=".concat(err_2.message));
|
|
2730
|
+
return [3 /*break*/, 3];
|
|
2731
|
+
case 3: return [2 /*return*/];
|
|
2713
2732
|
}
|
|
2714
2733
|
});
|
|
2715
2734
|
});
|
|
2716
2735
|
};
|
|
2736
|
+
Honeybadger.prototype.isCheckInSlug = function (idOrSlug) {
|
|
2737
|
+
var _a, _b;
|
|
2738
|
+
return (_b = (_a = this.config.checkins) === null || _a === void 0 ? void 0 : _a.some(function (c) { return c.slug === idOrSlug; })) !== null && _b !== void 0 ? _b : false;
|
|
2739
|
+
};
|
|
2717
2740
|
// This method is intended for web frameworks.
|
|
2718
2741
|
// It allows us to track context for individual requests without leaking to other requests
|
|
2719
2742
|
// by doing two things:
|
|
@@ -2746,7 +2769,7 @@ client.CheckInsClient = CheckInsClient;
|
|
|
2746
2769
|
var NOTIFIER = {
|
|
2747
2770
|
name: '@honeybadger-io/js',
|
|
2748
2771
|
url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/js',
|
|
2749
|
-
version: '6.
|
|
2772
|
+
version: '6.8.0'
|
|
2750
2773
|
};
|
|
2751
2774
|
var userAgent = function () {
|
|
2752
2775
|
return "Honeybadger JS Server Client ".concat(NOTIFIER.version, ", ").concat(os_1.default.version(), "; ").concat(os_1.default.platform());
|