@honeybadger-io/js 3.2.3 → 3.2.7

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.
@@ -488,7 +488,7 @@ function formatCGIData(vars, prefix) {
488
488
  var notifier = {
489
489
  name: 'honeybadger-js',
490
490
  url: 'https://github.com/honeybadger-io/honeybadger-js',
491
- version: '3.2.3'
491
+ version: '3.2.7'
492
492
  };
493
493
  // Split at commas
494
494
  var TAG_SEPARATOR = /,/;
@@ -564,10 +564,6 @@ var Client = /** @class */ (function () {
564
564
  Client.prototype.notify = function (notice, name, extra) {
565
565
  if (name === void 0) { name = undefined; }
566
566
  if (extra === void 0) { extra = undefined; }
567
- if (!this.config.apiKey) {
568
- this.logger.warn('Unable to send error report: no API key has been configured');
569
- return false;
570
- }
571
567
  if (this.config.disabled) {
572
568
  this.logger.warn('Deprecation warning: instead of `disabled: true`, use `reportData: false` to explicitly disable Honeybadger reporting. (Dropping notice: honeybadger.js is disabled)');
573
569
  return false;
@@ -576,6 +572,10 @@ var Client = /** @class */ (function () {
576
572
  this.logger.debug('Dropping notice: honeybadger.js is in development mode');
577
573
  return false;
578
574
  }
575
+ if (!this.config.apiKey) {
576
+ this.logger.warn('Unable to send error report: no API key has been configured');
577
+ return false;
578
+ }
579
579
  notice = makeNotice(notice);
580
580
  if (name && !(typeof name === 'object')) {
581
581
  var n = String(name);
@@ -689,7 +689,8 @@ var Client = /** @class */ (function () {
689
689
  revision: notice.revision,
690
690
  hostname: this.config.hostname,
691
691
  time: new Date().toUTCString()
692
- }
692
+ },
693
+ details: notice.details || {}
693
694
  };
694
695
  };
695
696
  /** @internal */
@@ -829,31 +830,38 @@ function errorHandler(err, req, _res, next) {
829
830
  }
830
831
  function lambdaHandler(handler) {
831
832
  return function lambdaHandler(event, context, callback) {
833
+ // in the case of an async handler, the length of the handler will be less than 3 (no callback function).
834
+ // if this is the case, we have to explicitly call the callback function from the function we are returning.
835
+ // we don't have to do that if the handler has third callback function parameter,
836
+ // because it will be called directly from inside the handler.
837
+ var shouldInvokeCallbackExplicitly = handler.length < 3;
832
838
  // eslint-disable-next-line prefer-rest-params
833
839
  var args = arguments;
834
840
  var dom = domain__default['default'].create();
835
841
  // eslint-disable-next-line @typescript-eslint/no-this-alias
836
842
  var hb = this;
837
- dom.on('error', function (err) {
838
- hb.notify(err, {
843
+ var hbHandler = function (err) {
844
+ var willNotify = hb.notify(err, {
839
845
  afterNotify: function () {
840
846
  hb.clear();
841
847
  callback(err);
842
848
  }
843
849
  });
844
- });
850
+ if (!willNotify) {
851
+ callback(err);
852
+ }
853
+ };
854
+ dom.on('error', hbHandler);
845
855
  dom.run(function () {
846
856
  process.nextTick(function () {
847
857
  Promise.resolve(handler.apply(this, args))
848
- .then(function () { hb.clear(); })
849
- .catch(function (err) {
850
- hb.notify(err, {
851
- afterNotify: function () {
852
- hb.clear();
853
- callback(err);
854
- }
855
- });
856
- });
858
+ .then(function (res) {
859
+ hb.clear();
860
+ if (shouldInvokeCallbackExplicitly) {
861
+ callback(null, res);
862
+ }
863
+ })
864
+ .catch(hbHandler);
857
865
  });
858
866
  });
859
867
  }.bind(this);
@@ -64,6 +64,7 @@ export interface Notice {
64
64
  environment?: string | undefined;
65
65
  revision?: string | undefined;
66
66
  tags: string | string[];
67
+ details: Record<string, Record<string, unknown>>;
67
68
  __breadcrumbs: BreadcrumbRecord[];
68
69
  afterNotify?: AfterNotifyHandler;
69
70
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@honeybadger-io/js",
3
- "version": "3.2.3",
3
+ "version": "3.2.7",
4
4
  "license": "MIT",
5
5
  "homepage": "https://github.com/honeybadger-io/honeybadger-js",
6
6
  "author": {
@@ -48,26 +48,26 @@
48
48
  "@rollup/plugin-node-resolve": "^13.0.4",
49
49
  "@rollup/plugin-replace": "^3.0.0",
50
50
  "@rollup/plugin-typescript": "^8.2.5",
51
- "@types/jest": "^26.0.24",
52
- "@typescript-eslint/eslint-plugin": "^4.29.0",
53
- "@typescript-eslint/parser": "^4.29.0",
54
- "axios": ">=0.21.1",
51
+ "@types/jest": "^27.0.2",
52
+ "@typescript-eslint/eslint-plugin": "^5.0.0",
53
+ "@typescript-eslint/parser": "^5.0.0",
54
+ "axios": ">=0.21.4",
55
55
  "concurrently": "^6.2.1",
56
- "eslint": "^7.32.0",
57
- "eslint-plugin-import": "^2.23.4",
58
- "eslint-plugin-jest": "^24.4.0",
56
+ "eslint": "^8.0.0",
57
+ "eslint-plugin-import": "^2.24.1",
58
+ "eslint-plugin-jest": "^25.0.1",
59
59
  "eslint-plugin-promise": "^5.1.0",
60
60
  "express": "^4.17.1",
61
61
  "jest": "^27.0.6",
62
- "nock": "^13.1.1",
63
- "rollup": "^2.56.1",
62
+ "nock": "^13.1.2",
63
+ "rollup": "^2.56.2",
64
64
  "rollup-plugin-uglify": "^6.0.2",
65
- "shipjs": "0.23.3",
65
+ "shipjs": "0.24.0",
66
66
  "sinon": "^11.1.2",
67
- "supertest": "^6.1.4",
68
- "ts-jest": "^27.0.4",
69
- "tsd": "^0.17.0",
70
- "tslib": "^2.3.0",
67
+ "supertest": "^6.1.6",
68
+ "ts-jest": "^27.0.5",
69
+ "tsd": "^0.18.0",
70
+ "tslib": "^2.3.1",
71
71
  "typescript": "^4.3.5"
72
72
  },
73
73
  "readmeFilename": "README.md",