@honeybadger-io/js 6.6.0 → 6.7.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/dist/browser/honeybadger.js +347 -83
- package/dist/browser/honeybadger.js.map +1 -1
- package/dist/browser/honeybadger.min.js +1 -1
- package/dist/browser/honeybadger.min.js.map +1 -1
- package/dist/browser/integrations/events.d.ts +3 -0
- package/dist/server/{checkins-manager/checkin.d.ts → check-ins-manager/check-in.d.ts} +10 -10
- package/dist/server/check-ins-manager/client.d.ts +21 -0
- package/dist/server/check-ins-manager/index.d.ts +15 -0
- package/dist/server/{checkins-manager → check-ins-manager}/types.d.ts +8 -8
- package/dist/server/check-ins-sync-exec.d.ts +2 -0
- package/dist/server/{checkins-sync-exec.js → check-ins-sync-exec.js} +130 -129
- package/dist/server/check-ins-sync-exec.js.map +1 -0
- package/dist/server/check-ins-sync.d.ts +2 -0
- package/dist/server/honeybadger.d.ts +4 -4
- package/dist/server/honeybadger.js +320 -85
- package/dist/server/honeybadger.js.map +1 -1
- package/package.json +4 -4
- package/dist/server/checkins-manager/client.d.ts +0 -21
- package/dist/server/checkins-manager/index.d.ts +0 -15
- package/dist/server/checkins-sync-exec.d.ts +0 -2
- package/dist/server/checkins-sync-exec.js.map +0 -1
- package/dist/server/checkins-sync.d.ts +0 -2
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var require$$0$
|
|
3
|
+
var require$$0$2 = require('os');
|
|
4
4
|
var require$$1$1 = require('domain');
|
|
5
5
|
var require$$1 = require('fs');
|
|
6
6
|
var require$$2 = require('util');
|
|
7
7
|
var require$$3 = require('cosmiconfig');
|
|
8
|
-
var require$$0$
|
|
8
|
+
var require$$0$3 = require('url');
|
|
9
9
|
var require$$3$1 = require('http');
|
|
10
10
|
var require$$4 = require('https');
|
|
11
11
|
|
|
12
12
|
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
13
13
|
|
|
14
|
-
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$
|
|
14
|
+
var require$$0__default = /*#__PURE__*/_interopDefaultLegacy(require$$0$2);
|
|
15
15
|
var require$$1__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$1$1);
|
|
16
16
|
var require$$1__default = /*#__PURE__*/_interopDefaultLegacy(require$$1);
|
|
17
17
|
var require$$2__default = /*#__PURE__*/_interopDefaultLegacy(require$$2);
|
|
18
18
|
var require$$3__default = /*#__PURE__*/_interopDefaultLegacy(require$$3);
|
|
19
|
-
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$
|
|
19
|
+
var require$$0__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$0$3);
|
|
20
20
|
var require$$3__default$1 = /*#__PURE__*/_interopDefaultLegacy(require$$3$1);
|
|
21
21
|
var require$$4__default = /*#__PURE__*/_interopDefaultLegacy(require$$4);
|
|
22
22
|
|
|
@@ -195,7 +195,7 @@ var stackTraceParser_esm = /*#__PURE__*/Object.freeze({
|
|
|
195
195
|
parse: parse
|
|
196
196
|
});
|
|
197
197
|
|
|
198
|
-
var require$$0 = /*@__PURE__*/getAugmentedNamespace(stackTraceParser_esm);
|
|
198
|
+
var require$$0$1 = /*@__PURE__*/getAugmentedNamespace(stackTraceParser_esm);
|
|
199
199
|
|
|
200
200
|
(function (exports) {
|
|
201
201
|
var __createBinding = (commonjsGlobal && commonjsGlobal.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
@@ -258,8 +258,9 @@ var require$$0 = /*@__PURE__*/getAugmentedNamespace(stackTraceParser_esm);
|
|
|
258
258
|
}
|
|
259
259
|
};
|
|
260
260
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
261
|
-
exports.isBrowserConfig = exports.clone = exports.formatCGIData = exports.filterUrl = exports.filter = exports.generateStackTrace = exports.endpoint = exports.instrument = exports.isErrorObject = exports.makeNotice = exports.logger = exports.sanitize = exports.shallowClone = exports.runAfterNotifyHandlers = exports.runBeforeNotifyHandlers = exports.getSourceForBacktrace = exports.getCauses = exports.calculateBacktraceShift = exports.DEFAULT_BACKTRACE_SHIFT = exports.makeBacktrace = exports.objectIsExtensible = exports.objectIsEmpty = exports.mergeNotice = exports.merge = void 0;
|
|
262
|
-
|
|
261
|
+
exports.isBrowserConfig = exports.clone = exports.formatCGIData = exports.filterUrl = exports.filter = exports.generateStackTrace = exports.endpoint = exports.instrumentConsole = exports.instrument = exports.isErrorObject = exports.makeNotice = exports.logger = exports.sanitize = exports.shallowClone = exports.runAfterNotifyHandlers = exports.runBeforeNotifyHandlers = exports.getSourceForBacktrace = exports.getCauses = exports.calculateBacktraceShift = exports.DEFAULT_BACKTRACE_SHIFT = exports.makeBacktrace = exports.objectIsExtensible = exports.objectIsEmpty = exports.mergeNotice = exports.merge = void 0;
|
|
262
|
+
/* eslint-disable prefer-rest-params */
|
|
263
|
+
var stackTraceParser = __importStar(require$$0$1);
|
|
263
264
|
function merge(obj1, obj2) {
|
|
264
265
|
var result = {};
|
|
265
266
|
for (var k in obj1) {
|
|
@@ -619,6 +620,39 @@ var require$$0 = /*@__PURE__*/getAugmentedNamespace(stackTraceParser_esm);
|
|
|
619
620
|
}
|
|
620
621
|
}
|
|
621
622
|
exports.instrument = instrument;
|
|
623
|
+
var _consoleAlreadyInstrumented = false;
|
|
624
|
+
var listeners = [];
|
|
625
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
626
|
+
function instrumentConsole(_window, handler) {
|
|
627
|
+
if (!_window || !_window.console || !handler) {
|
|
628
|
+
return;
|
|
629
|
+
}
|
|
630
|
+
listeners.push(handler);
|
|
631
|
+
if (_consoleAlreadyInstrumented) {
|
|
632
|
+
return;
|
|
633
|
+
}
|
|
634
|
+
_consoleAlreadyInstrumented = true;
|
|
635
|
+
['debug', 'info', 'warn', 'error', 'log'].forEach(function (level) {
|
|
636
|
+
instrument(_window.console, level, function hbLogger(original) {
|
|
637
|
+
return function () {
|
|
638
|
+
var args = Array.prototype.slice.call(arguments);
|
|
639
|
+
listeners.forEach(function (listener) {
|
|
640
|
+
try {
|
|
641
|
+
listener(level, args);
|
|
642
|
+
}
|
|
643
|
+
catch (_e) {
|
|
644
|
+
// ignore
|
|
645
|
+
// should never reach here because instrument method already wraps with try/catch block
|
|
646
|
+
}
|
|
647
|
+
});
|
|
648
|
+
if (typeof original === 'function') {
|
|
649
|
+
Function.prototype.apply.call(original, _window.console, arguments);
|
|
650
|
+
}
|
|
651
|
+
};
|
|
652
|
+
});
|
|
653
|
+
});
|
|
654
|
+
}
|
|
655
|
+
exports.instrumentConsole = instrumentConsole;
|
|
622
656
|
function endpoint(base, path) {
|
|
623
657
|
var endpoint = base.trim().replace(/\/$/, '');
|
|
624
658
|
path = path.trim().replace(/(^\/|\/$)/g, '');
|
|
@@ -772,7 +806,7 @@ var store = {};
|
|
|
772
806
|
|
|
773
807
|
Object.defineProperty(store, "__esModule", { value: true });
|
|
774
808
|
store.GlobalStore = void 0;
|
|
775
|
-
var util_1$
|
|
809
|
+
var util_1$6 = util$1;
|
|
776
810
|
var GlobalStore = /** @class */ (function () {
|
|
777
811
|
function GlobalStore(contents, breadcrumbsLimit) {
|
|
778
812
|
this.contents = contents;
|
|
@@ -789,7 +823,7 @@ var GlobalStore = /** @class */ (function () {
|
|
|
789
823
|
return JSON.parse(JSON.stringify(value));
|
|
790
824
|
};
|
|
791
825
|
GlobalStore.prototype.setContext = function (context) {
|
|
792
|
-
this.contents.context = (0, util_1$
|
|
826
|
+
this.contents.context = (0, util_1$6.merge)(this.contents.context, context || {});
|
|
793
827
|
};
|
|
794
828
|
GlobalStore.prototype.addBreadcrumb = function (breadcrumb) {
|
|
795
829
|
if (this.contents.breadcrumbs.length == this.breadcrumbsLimit) {
|
|
@@ -808,6 +842,195 @@ var GlobalStore = /** @class */ (function () {
|
|
|
808
842
|
}());
|
|
809
843
|
store.GlobalStore = GlobalStore;
|
|
810
844
|
|
|
845
|
+
var throttled_events_logger = {};
|
|
846
|
+
|
|
847
|
+
class NdJson {
|
|
848
|
+
static parse(data) {
|
|
849
|
+
const lines = data.trim().split('\n');
|
|
850
|
+
return lines.map(line => JSON.parse(line));
|
|
851
|
+
}
|
|
852
|
+
static stringify(data) {
|
|
853
|
+
return data.map(item => JSON.stringify(item)).join('\n');
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
|
|
857
|
+
var module$1 = /*#__PURE__*/Object.freeze({
|
|
858
|
+
__proto__: null,
|
|
859
|
+
NdJson: NdJson
|
|
860
|
+
});
|
|
861
|
+
|
|
862
|
+
var require$$0 = /*@__PURE__*/getAugmentedNamespace(module$1);
|
|
863
|
+
|
|
864
|
+
var defaults = {};
|
|
865
|
+
|
|
866
|
+
Object.defineProperty(defaults, "__esModule", { value: true });
|
|
867
|
+
defaults.CONFIG = void 0;
|
|
868
|
+
defaults.CONFIG = {
|
|
869
|
+
apiKey: null,
|
|
870
|
+
endpoint: 'https://api.honeybadger.io',
|
|
871
|
+
environment: null,
|
|
872
|
+
hostname: null,
|
|
873
|
+
projectRoot: null,
|
|
874
|
+
component: null,
|
|
875
|
+
action: null,
|
|
876
|
+
revision: null,
|
|
877
|
+
reportData: null,
|
|
878
|
+
breadcrumbsEnabled: true,
|
|
879
|
+
eventsEnabled: false,
|
|
880
|
+
maxBreadcrumbs: 40,
|
|
881
|
+
maxObjectDepth: 8,
|
|
882
|
+
logger: console,
|
|
883
|
+
developmentEnvironments: ['dev', 'development', 'test'],
|
|
884
|
+
debug: false,
|
|
885
|
+
tags: null,
|
|
886
|
+
enableUncaught: true,
|
|
887
|
+
enableUnhandledRejection: true,
|
|
888
|
+
afterUncaught: function () { return true; },
|
|
889
|
+
filters: ['creditcard', 'password'],
|
|
890
|
+
__plugins: [],
|
|
891
|
+
};
|
|
892
|
+
|
|
893
|
+
var __assign$2 = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
894
|
+
__assign$2 = Object.assign || function(t) {
|
|
895
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
896
|
+
s = arguments[i];
|
|
897
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
898
|
+
t[p] = s[p];
|
|
899
|
+
}
|
|
900
|
+
return t;
|
|
901
|
+
};
|
|
902
|
+
return __assign$2.apply(this, arguments);
|
|
903
|
+
};
|
|
904
|
+
var __awaiter$3 = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
905
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
906
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
907
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
908
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
909
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
910
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
911
|
+
});
|
|
912
|
+
};
|
|
913
|
+
var __generator$3 = (commonjsGlobal && commonjsGlobal.__generator) || function (thisArg, body) {
|
|
914
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
915
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
916
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
917
|
+
function step(op) {
|
|
918
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
919
|
+
while (_) try {
|
|
920
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
921
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
922
|
+
switch (op[0]) {
|
|
923
|
+
case 0: case 1: t = op; break;
|
|
924
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
925
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
926
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
927
|
+
default:
|
|
928
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
929
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
930
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
931
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
932
|
+
if (t[2]) _.ops.pop();
|
|
933
|
+
_.trys.pop(); continue;
|
|
934
|
+
}
|
|
935
|
+
op = body.call(thisArg, _);
|
|
936
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
937
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
938
|
+
}
|
|
939
|
+
};
|
|
940
|
+
Object.defineProperty(throttled_events_logger, "__esModule", { value: true });
|
|
941
|
+
throttled_events_logger.ThrottledEventsLogger = void 0;
|
|
942
|
+
var json_nd_1 = require$$0;
|
|
943
|
+
var util_1$5 = util$1;
|
|
944
|
+
var defaults_1$1 = defaults;
|
|
945
|
+
var ThrottledEventsLogger = /** @class */ (function () {
|
|
946
|
+
function ThrottledEventsLogger(config, transport) {
|
|
947
|
+
this.config = config;
|
|
948
|
+
this.transport = transport;
|
|
949
|
+
this.queue = [];
|
|
950
|
+
this.isProcessing = false;
|
|
951
|
+
this.config = __assign$2(__assign$2({}, defaults_1$1.CONFIG), config);
|
|
952
|
+
this.logger = this.originalLogger();
|
|
953
|
+
}
|
|
954
|
+
ThrottledEventsLogger.prototype.logEvent = function (data) {
|
|
955
|
+
this.queue.push(data);
|
|
956
|
+
if (!this.isProcessing) {
|
|
957
|
+
this.processQueue();
|
|
958
|
+
}
|
|
959
|
+
};
|
|
960
|
+
ThrottledEventsLogger.prototype.processQueue = function () {
|
|
961
|
+
var _this = this;
|
|
962
|
+
if (this.queue.length === 0 || this.isProcessing) {
|
|
963
|
+
return;
|
|
964
|
+
}
|
|
965
|
+
this.isProcessing = true;
|
|
966
|
+
var eventsData = this.queue.slice();
|
|
967
|
+
this.queue = [];
|
|
968
|
+
var data = json_nd_1.NdJson.stringify(eventsData);
|
|
969
|
+
this.makeHttpRequest(data)
|
|
970
|
+
.then(function () {
|
|
971
|
+
setTimeout(function () {
|
|
972
|
+
_this.isProcessing = false;
|
|
973
|
+
_this.processQueue();
|
|
974
|
+
}, 50);
|
|
975
|
+
})
|
|
976
|
+
.catch(function (error) {
|
|
977
|
+
_this.logger.error('[Honeybadger] Error making HTTP request:', error);
|
|
978
|
+
// Continue processing the queue even if there's an error
|
|
979
|
+
setTimeout(function () {
|
|
980
|
+
_this.isProcessing = false;
|
|
981
|
+
_this.processQueue();
|
|
982
|
+
}, 50);
|
|
983
|
+
});
|
|
984
|
+
};
|
|
985
|
+
ThrottledEventsLogger.prototype.makeHttpRequest = function (data) {
|
|
986
|
+
return __awaiter$3(this, void 0, void 0, function () {
|
|
987
|
+
var _this = this;
|
|
988
|
+
return __generator$3(this, function (_a) {
|
|
989
|
+
return [2 /*return*/, this.transport
|
|
990
|
+
.send({
|
|
991
|
+
headers: {
|
|
992
|
+
'X-API-Key': this.config.apiKey,
|
|
993
|
+
'Content-Type': 'application/json',
|
|
994
|
+
},
|
|
995
|
+
method: 'POST',
|
|
996
|
+
endpoint: (0, util_1$5.endpoint)(this.config.endpoint, '/v1/events'),
|
|
997
|
+
maxObjectDepth: this.config.maxObjectDepth,
|
|
998
|
+
logger: this.logger,
|
|
999
|
+
}, data)
|
|
1000
|
+
.then(function () {
|
|
1001
|
+
if (_this.config.debug) {
|
|
1002
|
+
_this.logger.debug('[Honeybadger] Events sent successfully');
|
|
1003
|
+
}
|
|
1004
|
+
})
|
|
1005
|
+
.catch(function (err) {
|
|
1006
|
+
_this.logger.error("[Honeybadger] Error sending events: ".concat(err.message));
|
|
1007
|
+
})];
|
|
1008
|
+
});
|
|
1009
|
+
});
|
|
1010
|
+
};
|
|
1011
|
+
/**
|
|
1012
|
+
* The EventsLogger overrides the console methods
|
|
1013
|
+
* so if we want to log something we need to use the original methods
|
|
1014
|
+
*/
|
|
1015
|
+
ThrottledEventsLogger.prototype.originalLogger = function () {
|
|
1016
|
+
var _a, _b, _c, _d, _e;
|
|
1017
|
+
return {
|
|
1018
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1019
|
+
log: (_a = console.log.__hb_original) !== null && _a !== void 0 ? _a : console.log,
|
|
1020
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1021
|
+
info: (_b = console.info.__hb_original) !== null && _b !== void 0 ? _b : console.info,
|
|
1022
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1023
|
+
debug: (_c = console.debug.__hb_original) !== null && _c !== void 0 ? _c : console.debug,
|
|
1024
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1025
|
+
warn: (_d = console.warn.__hb_original) !== null && _d !== void 0 ? _d : console.warn,
|
|
1026
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
1027
|
+
error: (_e = console.error.__hb_original) !== null && _e !== void 0 ? _e : console.error,
|
|
1028
|
+
};
|
|
1029
|
+
};
|
|
1030
|
+
return ThrottledEventsLogger;
|
|
1031
|
+
}());
|
|
1032
|
+
throttled_events_logger.ThrottledEventsLogger = ThrottledEventsLogger;
|
|
1033
|
+
|
|
811
1034
|
var __assign$1 = (commonjsGlobal && commonjsGlobal.__assign) || function () {
|
|
812
1035
|
__assign$1 = Object.assign || function(t) {
|
|
813
1036
|
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
@@ -859,6 +1082,8 @@ Object.defineProperty(client$1, "__esModule", { value: true });
|
|
|
859
1082
|
client$1.Client = void 0;
|
|
860
1083
|
var util_1$4 = util$1;
|
|
861
1084
|
var store_1 = store;
|
|
1085
|
+
var throttled_events_logger_1 = throttled_events_logger;
|
|
1086
|
+
var defaults_1 = defaults;
|
|
862
1087
|
// Split at commas and spaces
|
|
863
1088
|
var TAG_SEPARATOR = /,|\s+/;
|
|
864
1089
|
// Checks for non-blank characters
|
|
@@ -873,11 +1098,12 @@ var Client = /** @class */ (function () {
|
|
|
873
1098
|
this.__notifier = {
|
|
874
1099
|
name: '@honeybadger-io/core',
|
|
875
1100
|
url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/core',
|
|
876
|
-
version: '6.
|
|
1101
|
+
version: '6.7.0'
|
|
877
1102
|
};
|
|
878
|
-
this.config = __assign$1({
|
|
1103
|
+
this.config = __assign$1(__assign$1({}, defaults_1.CONFIG), opts);
|
|
879
1104
|
this.__initStore();
|
|
880
1105
|
this.__transport = transport;
|
|
1106
|
+
this.__eventsLogger = new throttled_events_logger_1.ThrottledEventsLogger(this.config, this.__transport);
|
|
881
1107
|
this.logger = (0, util_1$4.logger)(this);
|
|
882
1108
|
}
|
|
883
1109
|
Client.prototype.getVersion = function () {
|
|
@@ -1075,6 +1301,9 @@ var Client = /** @class */ (function () {
|
|
|
1075
1301
|
});
|
|
1076
1302
|
return this;
|
|
1077
1303
|
};
|
|
1304
|
+
Client.prototype.logEvent = function (data) {
|
|
1305
|
+
this.__eventsLogger.logEvent(data);
|
|
1306
|
+
};
|
|
1078
1307
|
Client.prototype.__getBreadcrumbs = function () {
|
|
1079
1308
|
return this.__store.getContents('breadcrumbs').slice();
|
|
1080
1309
|
};
|
|
@@ -1827,7 +2056,8 @@ var ServerTransport = /** @class */ (function () {
|
|
|
1827
2056
|
};
|
|
1828
2057
|
var data = undefined;
|
|
1829
2058
|
if (payload) {
|
|
1830
|
-
|
|
2059
|
+
var dataStr = typeof payload === 'string' ? payload : JSON.stringify(sanitize(payload, options.maxObjectDepth));
|
|
2060
|
+
data = Buffer.from(dataStr, 'utf8');
|
|
1831
2061
|
httpOptions.headers['Content-Length'] = data.length;
|
|
1832
2062
|
}
|
|
1833
2063
|
var req = transport.request(httpOptions, function (res) {
|
|
@@ -1982,12 +2212,12 @@ stacked_store.StackedStore = StackedStore;
|
|
|
1982
2212
|
|
|
1983
2213
|
var client = {};
|
|
1984
2214
|
|
|
1985
|
-
var
|
|
2215
|
+
var checkIn = {};
|
|
1986
2216
|
|
|
1987
|
-
Object.defineProperty(
|
|
1988
|
-
|
|
1989
|
-
var
|
|
1990
|
-
function
|
|
2217
|
+
Object.defineProperty(checkIn, "__esModule", { value: true });
|
|
2218
|
+
checkIn.CheckIn = void 0;
|
|
2219
|
+
var CheckIn = /** @class */ (function () {
|
|
2220
|
+
function CheckIn(props) {
|
|
1991
2221
|
this.id = props.id;
|
|
1992
2222
|
this.name = props.name;
|
|
1993
2223
|
this.slug = props.slug;
|
|
@@ -1999,33 +2229,33 @@ var Checkin = /** @class */ (function () {
|
|
|
1999
2229
|
this.projectId = props.projectId;
|
|
2000
2230
|
this.deleted = false;
|
|
2001
2231
|
}
|
|
2002
|
-
|
|
2232
|
+
CheckIn.prototype.isDeleted = function () {
|
|
2003
2233
|
return this.deleted;
|
|
2004
2234
|
};
|
|
2005
|
-
|
|
2235
|
+
CheckIn.prototype.markAsDeleted = function () {
|
|
2006
2236
|
this.deleted = true;
|
|
2007
2237
|
};
|
|
2008
|
-
|
|
2238
|
+
CheckIn.prototype.validate = function () {
|
|
2009
2239
|
if (!this.projectId) {
|
|
2010
|
-
throw new Error('projectId is required for each
|
|
2240
|
+
throw new Error('projectId is required for each check-in');
|
|
2011
2241
|
}
|
|
2012
2242
|
if (!this.name) {
|
|
2013
|
-
throw new Error('name is required for each
|
|
2243
|
+
throw new Error('name is required for each check-in');
|
|
2014
2244
|
}
|
|
2015
2245
|
if (!this.scheduleType) {
|
|
2016
|
-
throw new Error('scheduleType is required for each
|
|
2246
|
+
throw new Error('scheduleType is required for each check-in');
|
|
2017
2247
|
}
|
|
2018
2248
|
if (!['simple', 'cron'].includes(this.scheduleType)) {
|
|
2019
2249
|
throw new Error("".concat(this.name, " [scheduleType] must be \"simple\" or \"cron\""));
|
|
2020
2250
|
}
|
|
2021
2251
|
if (this.scheduleType === 'simple' && !this.reportPeriod) {
|
|
2022
|
-
throw new Error("".concat(this.name, " [reportPeriod] is required for simple
|
|
2252
|
+
throw new Error("".concat(this.name, " [reportPeriod] is required for simple check-ins"));
|
|
2023
2253
|
}
|
|
2024
2254
|
if (this.scheduleType === 'cron' && !this.cronSchedule) {
|
|
2025
|
-
throw new Error("".concat(this.name, " [cronSchedule] is required for cron
|
|
2255
|
+
throw new Error("".concat(this.name, " [cronSchedule] is required for cron check-ins"));
|
|
2026
2256
|
}
|
|
2027
2257
|
};
|
|
2028
|
-
|
|
2258
|
+
CheckIn.prototype.asRequestPayload = function () {
|
|
2029
2259
|
var _a, _b, _c;
|
|
2030
2260
|
var payload = {
|
|
2031
2261
|
name: this.name,
|
|
@@ -2043,11 +2273,11 @@ var Checkin = /** @class */ (function () {
|
|
|
2043
2273
|
return payload;
|
|
2044
2274
|
};
|
|
2045
2275
|
/**
|
|
2046
|
-
* Compares two
|
|
2047
|
-
* If the one in the config file does not match the
|
|
2276
|
+
* Compares two check-ins, usually the one from the API and the one from the config file.
|
|
2277
|
+
* If the one in the config file does not match the check-in from the API,
|
|
2048
2278
|
* then we issue an update request.
|
|
2049
2279
|
*/
|
|
2050
|
-
|
|
2280
|
+
CheckIn.prototype.isInSync = function (other) {
|
|
2051
2281
|
var _a, _b, _c, _d, _e, _f;
|
|
2052
2282
|
return this.name === other.name
|
|
2053
2283
|
&& this.projectId === other.projectId
|
|
@@ -2058,8 +2288,8 @@ var Checkin = /** @class */ (function () {
|
|
|
2058
2288
|
&& ((_c = this.gracePeriod) !== null && _c !== void 0 ? _c : '') === ((_d = other.gracePeriod) !== null && _d !== void 0 ? _d : '')
|
|
2059
2289
|
&& ((_e = this.cronTimezone) !== null && _e !== void 0 ? _e : '') === ((_f = other.cronTimezone) !== null && _f !== void 0 ? _f : '');
|
|
2060
2290
|
};
|
|
2061
|
-
|
|
2062
|
-
return new
|
|
2291
|
+
CheckIn.fromResponsePayload = function (projectId, payload) {
|
|
2292
|
+
return new CheckIn({
|
|
2063
2293
|
projectId: projectId,
|
|
2064
2294
|
id: payload.id,
|
|
2065
2295
|
name: payload.name,
|
|
@@ -2071,9 +2301,9 @@ var Checkin = /** @class */ (function () {
|
|
|
2071
2301
|
cronTimezone: payload.cron_timezone,
|
|
2072
2302
|
});
|
|
2073
2303
|
};
|
|
2074
|
-
return
|
|
2304
|
+
return CheckIn;
|
|
2075
2305
|
}());
|
|
2076
|
-
|
|
2306
|
+
checkIn.CheckIn = CheckIn;
|
|
2077
2307
|
|
|
2078
2308
|
var __awaiter = (commonjsGlobal && commonjsGlobal.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2079
2309
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
@@ -2112,19 +2342,19 @@ var __generator = (commonjsGlobal && commonjsGlobal.__generator) || function (th
|
|
|
2112
2342
|
}
|
|
2113
2343
|
};
|
|
2114
2344
|
Object.defineProperty(client, "__esModule", { value: true });
|
|
2115
|
-
client.
|
|
2116
|
-
var
|
|
2117
|
-
var
|
|
2118
|
-
function
|
|
2345
|
+
client.CheckInsClient = void 0;
|
|
2346
|
+
var check_in_1 = checkIn;
|
|
2347
|
+
var CheckInsClient = /** @class */ (function () {
|
|
2348
|
+
function CheckInsClient(config, transport) {
|
|
2119
2349
|
this.BASE_URL = 'https://app.honeybadger.io';
|
|
2120
2350
|
this.transport = transport;
|
|
2121
2351
|
this.config = config;
|
|
2122
2352
|
this.logger = config.logger;
|
|
2123
2353
|
this.cache = {};
|
|
2124
2354
|
}
|
|
2125
|
-
|
|
2355
|
+
CheckInsClient.prototype.listForProject = function (projectId) {
|
|
2126
2356
|
return __awaiter(this, void 0, void 0, function () {
|
|
2127
|
-
var response, data,
|
|
2357
|
+
var response, data, checkIns;
|
|
2128
2358
|
return __generator(this, function (_a) {
|
|
2129
2359
|
switch (_a.label) {
|
|
2130
2360
|
case 0:
|
|
@@ -2146,16 +2376,16 @@ var CheckinsClient = /** @class */ (function () {
|
|
|
2146
2376
|
throw new Error("Failed to fetch checkins for project[".concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2147
2377
|
}
|
|
2148
2378
|
data = JSON.parse(response.body);
|
|
2149
|
-
|
|
2150
|
-
this.cache[projectId] =
|
|
2151
|
-
return [2 /*return*/,
|
|
2379
|
+
checkIns = data.results.map(function (checkin) { return check_in_1.CheckIn.fromResponsePayload(projectId, checkin); });
|
|
2380
|
+
this.cache[projectId] = checkIns;
|
|
2381
|
+
return [2 /*return*/, checkIns];
|
|
2152
2382
|
}
|
|
2153
2383
|
});
|
|
2154
2384
|
});
|
|
2155
2385
|
};
|
|
2156
|
-
|
|
2386
|
+
CheckInsClient.prototype.get = function (projectId, checkInId) {
|
|
2157
2387
|
return __awaiter(this, void 0, void 0, function () {
|
|
2158
|
-
var response, data,
|
|
2388
|
+
var response, data, checkIn;
|
|
2159
2389
|
return __generator(this, function (_a) {
|
|
2160
2390
|
switch (_a.label) {
|
|
2161
2391
|
case 0:
|
|
@@ -2165,23 +2395,23 @@ var CheckinsClient = /** @class */ (function () {
|
|
|
2165
2395
|
return [4 /*yield*/, this.transport.send({
|
|
2166
2396
|
method: 'GET',
|
|
2167
2397
|
headers: this.getHeaders(),
|
|
2168
|
-
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(projectId, "/check_ins/").concat(
|
|
2398
|
+
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(projectId, "/check_ins/").concat(checkInId),
|
|
2169
2399
|
logger: this.logger,
|
|
2170
2400
|
})];
|
|
2171
2401
|
case 1:
|
|
2172
2402
|
response = _a.sent();
|
|
2173
2403
|
if (response.statusCode !== 200) {
|
|
2174
|
-
throw new Error("Failed to fetch
|
|
2404
|
+
throw new Error("Failed to fetch check-in[".concat(checkInId, "] for project[").concat(projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2175
2405
|
}
|
|
2176
2406
|
data = JSON.parse(response.body);
|
|
2177
|
-
|
|
2178
|
-
|
|
2179
|
-
return [2 /*return*/,
|
|
2407
|
+
checkIn = check_in_1.CheckIn.fromResponsePayload(projectId, data);
|
|
2408
|
+
checkIn.projectId = projectId;
|
|
2409
|
+
return [2 /*return*/, checkIn];
|
|
2180
2410
|
}
|
|
2181
2411
|
});
|
|
2182
2412
|
});
|
|
2183
2413
|
};
|
|
2184
|
-
|
|
2414
|
+
CheckInsClient.prototype.create = function (checkIn) {
|
|
2185
2415
|
return __awaiter(this, void 0, void 0, function () {
|
|
2186
2416
|
var response, data, result;
|
|
2187
2417
|
return __generator(this, function (_a) {
|
|
@@ -2193,23 +2423,23 @@ var CheckinsClient = /** @class */ (function () {
|
|
|
2193
2423
|
return [4 /*yield*/, this.transport.send({
|
|
2194
2424
|
method: 'POST',
|
|
2195
2425
|
headers: this.getHeaders(),
|
|
2196
|
-
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(
|
|
2426
|
+
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(checkIn.projectId, "/check_ins"),
|
|
2197
2427
|
logger: this.logger,
|
|
2198
|
-
}, { check_in:
|
|
2428
|
+
}, { check_in: checkIn.asRequestPayload() })];
|
|
2199
2429
|
case 1:
|
|
2200
2430
|
response = _a.sent();
|
|
2201
2431
|
if (response.statusCode !== 201) {
|
|
2202
|
-
throw new Error("Failed to create
|
|
2432
|
+
throw new Error("Failed to create check-in[".concat(checkIn.name, "] for project[").concat(checkIn.projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2203
2433
|
}
|
|
2204
2434
|
data = JSON.parse(response.body);
|
|
2205
|
-
result =
|
|
2206
|
-
result.projectId =
|
|
2435
|
+
result = check_in_1.CheckIn.fromResponsePayload(checkIn.projectId, data);
|
|
2436
|
+
result.projectId = checkIn.projectId;
|
|
2207
2437
|
return [2 /*return*/, result];
|
|
2208
2438
|
}
|
|
2209
2439
|
});
|
|
2210
2440
|
});
|
|
2211
2441
|
};
|
|
2212
|
-
|
|
2442
|
+
CheckInsClient.prototype.update = function (checkIn) {
|
|
2213
2443
|
return __awaiter(this, void 0, void 0, function () {
|
|
2214
2444
|
var response;
|
|
2215
2445
|
return __generator(this, function (_a) {
|
|
@@ -2221,20 +2451,20 @@ var CheckinsClient = /** @class */ (function () {
|
|
|
2221
2451
|
return [4 /*yield*/, this.transport.send({
|
|
2222
2452
|
method: 'PUT',
|
|
2223
2453
|
headers: this.getHeaders(),
|
|
2224
|
-
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(
|
|
2454
|
+
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(checkIn.projectId, "/check_ins/").concat(checkIn.id),
|
|
2225
2455
|
logger: this.logger,
|
|
2226
|
-
}, { check_in:
|
|
2456
|
+
}, { check_in: checkIn.asRequestPayload() })];
|
|
2227
2457
|
case 1:
|
|
2228
2458
|
response = _a.sent();
|
|
2229
2459
|
if (response.statusCode !== 204) {
|
|
2230
|
-
throw new Error("Failed to update checkin[".concat(
|
|
2460
|
+
throw new Error("Failed to update checkin[".concat(checkIn.name, "] for project[").concat(checkIn.projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2231
2461
|
}
|
|
2232
|
-
return [2 /*return*/,
|
|
2462
|
+
return [2 /*return*/, checkIn];
|
|
2233
2463
|
}
|
|
2234
2464
|
});
|
|
2235
2465
|
});
|
|
2236
2466
|
};
|
|
2237
|
-
|
|
2467
|
+
CheckInsClient.prototype.remove = function (checkIn) {
|
|
2238
2468
|
return __awaiter(this, void 0, void 0, function () {
|
|
2239
2469
|
var response;
|
|
2240
2470
|
return __generator(this, function (_a) {
|
|
@@ -2246,26 +2476,26 @@ var CheckinsClient = /** @class */ (function () {
|
|
|
2246
2476
|
return [4 /*yield*/, this.transport.send({
|
|
2247
2477
|
method: 'DELETE',
|
|
2248
2478
|
headers: this.getHeaders(),
|
|
2249
|
-
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(
|
|
2479
|
+
endpoint: "".concat(this.BASE_URL, "/v2/projects/").concat(checkIn.projectId, "/check_ins/").concat(checkIn.id),
|
|
2250
2480
|
logger: this.logger,
|
|
2251
2481
|
})];
|
|
2252
2482
|
case 1:
|
|
2253
2483
|
response = _a.sent();
|
|
2254
2484
|
if (response.statusCode !== 204) {
|
|
2255
|
-
throw new Error("Failed to remove checkin[".concat(
|
|
2485
|
+
throw new Error("Failed to remove checkin[".concat(checkIn.name, "] for project[").concat(checkIn.projectId, "]: ").concat(this.getErrorMessage(response.body)));
|
|
2256
2486
|
}
|
|
2257
2487
|
return [2 /*return*/];
|
|
2258
2488
|
}
|
|
2259
2489
|
});
|
|
2260
2490
|
});
|
|
2261
2491
|
};
|
|
2262
|
-
|
|
2492
|
+
CheckInsClient.prototype.getHeaders = function () {
|
|
2263
2493
|
return {
|
|
2264
2494
|
'Authorization': "Basic ".concat(Buffer.from("".concat(this.config.personalAuthToken, ":")).toString('base64')),
|
|
2265
2495
|
'Content-Type': 'application/json'
|
|
2266
2496
|
};
|
|
2267
2497
|
};
|
|
2268
|
-
|
|
2498
|
+
CheckInsClient.prototype.getErrorMessage = function (responseBody) {
|
|
2269
2499
|
var _a;
|
|
2270
2500
|
if (!responseBody) {
|
|
2271
2501
|
return '';
|
|
@@ -2278,9 +2508,9 @@ var CheckinsClient = /** @class */ (function () {
|
|
|
2278
2508
|
return responseBody;
|
|
2279
2509
|
}
|
|
2280
2510
|
};
|
|
2281
|
-
return
|
|
2511
|
+
return CheckInsClient;
|
|
2282
2512
|
}());
|
|
2283
|
-
client.
|
|
2513
|
+
client.CheckInsClient = CheckInsClient;
|
|
2284
2514
|
|
|
2285
2515
|
(function (exports) {
|
|
2286
2516
|
var __extends = (commonjsGlobal && commonjsGlobal.__extends) || (function () {
|
|
@@ -2373,7 +2603,9 @@ client.CheckinsClient = CheckinsClient;
|
|
|
2373
2603
|
if (opts === void 0) { opts = {}; }
|
|
2374
2604
|
var _this = this;
|
|
2375
2605
|
var _a;
|
|
2376
|
-
var transport = new transport_1.ServerTransport(
|
|
2606
|
+
var transport = new transport_1.ServerTransport({
|
|
2607
|
+
'User-Agent': userAgent(),
|
|
2608
|
+
});
|
|
2377
2609
|
_this = _super.call(this, __assign({ projectRoot: process.cwd(), hostname: os_1.default.hostname() }, opts), transport) || this;
|
|
2378
2610
|
/** @internal */
|
|
2379
2611
|
_this.__beforeNotifyHandlers = [
|
|
@@ -2393,7 +2625,7 @@ client.CheckinsClient = CheckinsClient;
|
|
|
2393
2625
|
var config = _this.config;
|
|
2394
2626
|
config.reportTimeoutWarning = (_a = config.reportTimeoutWarning) !== null && _a !== void 0 ? _a : true;
|
|
2395
2627
|
config.timeoutWarningThresholdMs = config.timeoutWarningThresholdMs || 50;
|
|
2396
|
-
_this.
|
|
2628
|
+
_this.__checkInsClient = new client_1.CheckInsClient(_this.config, transport);
|
|
2397
2629
|
_this.__getSourceFileHandler = util_1.getSourceFile.bind(_this);
|
|
2398
2630
|
_this.errorHandler = middleware_1.errorHandler.bind(_this);
|
|
2399
2631
|
_this.requestHandler = middleware_1.requestHandler.bind(_this);
|
|
@@ -2424,7 +2656,7 @@ client.CheckinsClient = CheckinsClient;
|
|
|
2424
2656
|
switch (_a.label) {
|
|
2425
2657
|
case 0:
|
|
2426
2658
|
_a.trys.push([0, 3, , 4]);
|
|
2427
|
-
return [4 /*yield*/, this.
|
|
2659
|
+
return [4 /*yield*/, this.getCheckInId(idOrName)];
|
|
2428
2660
|
case 1:
|
|
2429
2661
|
id = _a.sent();
|
|
2430
2662
|
return [4 /*yield*/, this.__transport
|
|
@@ -2446,33 +2678,33 @@ client.CheckinsClient = CheckinsClient;
|
|
|
2446
2678
|
});
|
|
2447
2679
|
});
|
|
2448
2680
|
};
|
|
2449
|
-
Honeybadger.prototype.
|
|
2681
|
+
Honeybadger.prototype.getCheckInId = function (idOrName) {
|
|
2450
2682
|
return __awaiter(this, void 0, void 0, function () {
|
|
2451
|
-
var
|
|
2683
|
+
var localCheckIn, projectCheckIns, remoteCheckIn;
|
|
2452
2684
|
return __generator(this, function (_a) {
|
|
2453
2685
|
switch (_a.label) {
|
|
2454
2686
|
case 0:
|
|
2455
2687
|
if (!this.config.checkins || this.config.checkins.length === 0) {
|
|
2456
2688
|
return [2 /*return*/, idOrName];
|
|
2457
2689
|
}
|
|
2458
|
-
|
|
2459
|
-
if (!
|
|
2690
|
+
localCheckIn = this.config.checkins.find(function (c) { return c.name === idOrName; });
|
|
2691
|
+
if (!localCheckIn) {
|
|
2460
2692
|
return [2 /*return*/, idOrName];
|
|
2461
2693
|
}
|
|
2462
|
-
if (
|
|
2463
|
-
return [2 /*return*/,
|
|
2694
|
+
if (localCheckIn.id) {
|
|
2695
|
+
return [2 /*return*/, localCheckIn.id];
|
|
2464
2696
|
}
|
|
2465
|
-
return [4 /*yield*/, this.
|
|
2697
|
+
return [4 /*yield*/, this.__checkInsClient.listForProject(localCheckIn.projectId)];
|
|
2466
2698
|
case 1:
|
|
2467
|
-
|
|
2468
|
-
|
|
2469
|
-
if (!
|
|
2699
|
+
projectCheckIns = _a.sent();
|
|
2700
|
+
remoteCheckIn = projectCheckIns.find(function (c) { return c.name === localCheckIn.name; });
|
|
2701
|
+
if (!remoteCheckIn) {
|
|
2470
2702
|
this.logger.debug("Checkin[".concat(idOrName, "] was not found on HB. This should not happen. Was the sync command executed?"));
|
|
2471
2703
|
return [2 /*return*/, idOrName];
|
|
2472
2704
|
}
|
|
2473
|
-
// store the id
|
|
2474
|
-
|
|
2475
|
-
return [2 /*return*/,
|
|
2705
|
+
// store the id in-memory, so subsequent check-ins won't have to call the API
|
|
2706
|
+
localCheckIn.id = remoteCheckIn.id;
|
|
2707
|
+
return [2 /*return*/, localCheckIn.id];
|
|
2476
2708
|
}
|
|
2477
2709
|
});
|
|
2478
2710
|
});
|
|
@@ -2506,12 +2738,15 @@ client.CheckinsClient = CheckinsClient;
|
|
|
2506
2738
|
};
|
|
2507
2739
|
return Honeybadger;
|
|
2508
2740
|
}(core_1.Client));
|
|
2509
|
-
var singleton = new Honeybadger(__assign({ __plugins: DEFAULT_PLUGINS }, ((_a = (0, util_1.readConfigFromFileSystem)()) !== null && _a !== void 0 ? _a : {})));
|
|
2510
2741
|
var NOTIFIER = {
|
|
2511
2742
|
name: '@honeybadger-io/js',
|
|
2512
2743
|
url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/js',
|
|
2513
|
-
version: '6.
|
|
2744
|
+
version: '6.7.0'
|
|
2745
|
+
};
|
|
2746
|
+
var userAgent = function () {
|
|
2747
|
+
return "Honeybadger JS Server Client ".concat(NOTIFIER.version, ", ").concat(os_1.default.version(), "; ").concat(os_1.default.platform());
|
|
2514
2748
|
};
|
|
2749
|
+
var singleton = new Honeybadger(__assign({ __plugins: DEFAULT_PLUGINS }, ((_a = (0, util_1.readConfigFromFileSystem)()) !== null && _a !== void 0 ? _a : {})));
|
|
2515
2750
|
singleton.setNotifier(NOTIFIER);
|
|
2516
2751
|
var core_2 = src;
|
|
2517
2752
|
Object.defineProperty(exports, "Types", { enumerable: true, get: function () { return core_2.Types; } });
|