@honeybadger-io/js 4.3.0 → 4.6.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 +51 -50
- 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/server/async_store.d.ts +24 -4
- package/dist/server/honeybadger.d.ts +2 -0
- package/dist/server/honeybadger.js +186 -82
- package/dist/server/stacked_store.d.ts +23 -0
- package/package.json +3 -3
|
@@ -689,20 +689,37 @@
|
|
|
689
689
|
|
|
690
690
|
Object.defineProperty(store, "__esModule", { value: true });
|
|
691
691
|
store.GlobalStore = void 0;
|
|
692
|
+
var util_1$2 = util$1;
|
|
692
693
|
var GlobalStore = /** @class */ (function () {
|
|
693
|
-
function GlobalStore(
|
|
694
|
-
this.
|
|
694
|
+
function GlobalStore(contents, breadcrumbsLimit) {
|
|
695
|
+
this.contents = contents;
|
|
696
|
+
this.breadcrumbsLimit = breadcrumbsLimit;
|
|
695
697
|
}
|
|
696
|
-
GlobalStore.
|
|
697
|
-
return
|
|
698
|
+
GlobalStore.create = function (contents, breadcrumbsLimit) {
|
|
699
|
+
return new GlobalStore(contents, breadcrumbsLimit);
|
|
698
700
|
};
|
|
699
|
-
GlobalStore.prototype.
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
701
|
+
GlobalStore.prototype.available = function () {
|
|
702
|
+
return true;
|
|
703
|
+
};
|
|
704
|
+
GlobalStore.prototype.getContents = function (key) {
|
|
705
|
+
var value = key ? this.contents[key] : this.contents;
|
|
706
|
+
return JSON.parse(JSON.stringify(value));
|
|
707
|
+
};
|
|
708
|
+
GlobalStore.prototype.setContext = function (context) {
|
|
709
|
+
this.contents.context = (0, util_1$2.merge)(this.contents.context, context || {});
|
|
710
|
+
};
|
|
711
|
+
GlobalStore.prototype.addBreadcrumb = function (breadcrumb) {
|
|
712
|
+
if (this.contents.breadcrumbs.length == this.breadcrumbsLimit) {
|
|
713
|
+
this.contents.breadcrumbs.shift();
|
|
703
714
|
}
|
|
704
|
-
this.
|
|
705
|
-
|
|
715
|
+
this.contents.breadcrumbs.push(breadcrumb);
|
|
716
|
+
};
|
|
717
|
+
GlobalStore.prototype.clear = function () {
|
|
718
|
+
this.contents.context = {};
|
|
719
|
+
this.contents.breadcrumbs = [];
|
|
720
|
+
};
|
|
721
|
+
GlobalStore.prototype.run = function (callback) {
|
|
722
|
+
return callback();
|
|
706
723
|
};
|
|
707
724
|
return GlobalStore;
|
|
708
725
|
}());
|
|
@@ -726,7 +743,7 @@
|
|
|
726
743
|
var notifier = {
|
|
727
744
|
name: 'honeybadger-js',
|
|
728
745
|
url: 'https://github.com/honeybadger-io/honeybadger-js',
|
|
729
|
-
version: '4.
|
|
746
|
+
version: '4.6.0'
|
|
730
747
|
};
|
|
731
748
|
// Split at commas and spaces
|
|
732
749
|
var TAG_SEPARATOR = /,|\s+/;
|
|
@@ -740,9 +757,7 @@
|
|
|
740
757
|
this.__beforeNotifyHandlers = [];
|
|
741
758
|
this.__afterNotifyHandlers = [];
|
|
742
759
|
this.config = __assign({ apiKey: null, endpoint: 'https://api.honeybadger.io', environment: null, hostname: null, projectRoot: null, component: null, action: null, revision: null, reportData: null, breadcrumbsEnabled: true, maxBreadcrumbs: 40, maxObjectDepth: 8, logger: console, developmentEnvironments: ['dev', 'development', 'test'], debug: false, tags: null, enableUncaught: true, enableUnhandledRejection: true, afterUncaught: function () { return true; }, filters: ['creditcard', 'password'], __plugins: [] }, opts);
|
|
743
|
-
|
|
744
|
-
// Webserver middleware can then switch to the AsyncStore for async context tracking.
|
|
745
|
-
this.__store = new store_1.GlobalStore({ context: {}, breadcrumbs: [] });
|
|
760
|
+
this.__initStore();
|
|
746
761
|
this.__transport = transport;
|
|
747
762
|
this.logger = (0, util_1$1.logger)(this);
|
|
748
763
|
}
|
|
@@ -761,8 +776,8 @@
|
|
|
761
776
|
}
|
|
762
777
|
return this;
|
|
763
778
|
};
|
|
764
|
-
Client.prototype.
|
|
765
|
-
this.__store =
|
|
779
|
+
Client.prototype.__initStore = function () {
|
|
780
|
+
this.__store = new store_1.GlobalStore({ context: {}, breadcrumbs: [] }, this.config.maxBreadcrumbs);
|
|
766
781
|
};
|
|
767
782
|
Client.prototype.beforeNotify = function (handler) {
|
|
768
783
|
this.__beforeNotifyHandlers.push(handler);
|
|
@@ -773,27 +788,21 @@
|
|
|
773
788
|
return this;
|
|
774
789
|
};
|
|
775
790
|
Client.prototype.setContext = function (context) {
|
|
776
|
-
if (typeof context === 'object') {
|
|
777
|
-
|
|
778
|
-
store.context = (0, util_1$1.merge)(store.context, context);
|
|
791
|
+
if (typeof context === 'object' && context != null) {
|
|
792
|
+
this.__store.setContext(context);
|
|
779
793
|
}
|
|
780
794
|
return this;
|
|
781
795
|
};
|
|
782
796
|
Client.prototype.resetContext = function (context) {
|
|
783
797
|
this.logger.warn('Deprecation warning: `Honeybadger.resetContext()` has been deprecated; please use `Honeybadger.clear()` instead.');
|
|
784
|
-
|
|
798
|
+
this.__store.clear();
|
|
785
799
|
if (typeof context === 'object' && context !== null) {
|
|
786
|
-
|
|
787
|
-
}
|
|
788
|
-
else {
|
|
789
|
-
store.context = {};
|
|
800
|
+
this.__store.setContext(context);
|
|
790
801
|
}
|
|
791
802
|
return this;
|
|
792
803
|
};
|
|
793
804
|
Client.prototype.clear = function () {
|
|
794
|
-
|
|
795
|
-
store.context = {};
|
|
796
|
-
store.breadcrumbs = [];
|
|
805
|
+
this.__store.clear();
|
|
797
806
|
return this;
|
|
798
807
|
};
|
|
799
808
|
Client.prototype.notify = function (noticeable, name, extra) {
|
|
@@ -838,8 +847,8 @@
|
|
|
838
847
|
stack: notice.stack
|
|
839
848
|
}
|
|
840
849
|
});
|
|
841
|
-
var breadcrumbs = this.
|
|
842
|
-
notice.__breadcrumbs = this.config.breadcrumbsEnabled ? breadcrumbs
|
|
850
|
+
var breadcrumbs = this.__store.getContents('breadcrumbs');
|
|
851
|
+
notice.__breadcrumbs = this.config.breadcrumbsEnabled ? breadcrumbs : [];
|
|
843
852
|
(0, util_1$1.getSourceForBacktrace)(sourceCodeData, this.__getSourceFileHandler)
|
|
844
853
|
.then(function (sourcePerTrace) {
|
|
845
854
|
sourcePerTrace.forEach(function (source, index) {
|
|
@@ -940,7 +949,7 @@
|
|
|
940
949
|
if ((0, util_1$1.objectIsEmpty)(notice)) {
|
|
941
950
|
return null;
|
|
942
951
|
}
|
|
943
|
-
var context = this.
|
|
952
|
+
var context = this.__store.getContents('context');
|
|
944
953
|
var noticeTags = this.__constructTags(notice.tags);
|
|
945
954
|
var contextTags = this.__constructTags(context['tags']);
|
|
946
955
|
var configTags = this.__constructTags(this.config.tags);
|
|
@@ -973,21 +982,20 @@
|
|
|
973
982
|
var metadata = (0, util_1$1.shallowClone)(opts.metadata);
|
|
974
983
|
var category = opts.category || 'custom';
|
|
975
984
|
var timestamp = new Date().toISOString();
|
|
976
|
-
|
|
977
|
-
var breadcrumbs = store.breadcrumbs;
|
|
978
|
-
breadcrumbs.push({
|
|
985
|
+
this.__store.addBreadcrumb({
|
|
979
986
|
category: category,
|
|
980
987
|
message: message,
|
|
981
988
|
metadata: metadata,
|
|
982
989
|
timestamp: timestamp
|
|
983
990
|
});
|
|
984
|
-
var limit = this.config.maxBreadcrumbs;
|
|
985
|
-
if (breadcrumbs.length > limit) {
|
|
986
|
-
breadcrumbs = breadcrumbs.slice(breadcrumbs.length - limit);
|
|
987
|
-
}
|
|
988
|
-
store.breadcrumbs = breadcrumbs;
|
|
989
991
|
return this;
|
|
990
992
|
};
|
|
993
|
+
Client.prototype.__getBreadcrumbs = function () {
|
|
994
|
+
return this.__store.getContents('breadcrumbs').slice();
|
|
995
|
+
};
|
|
996
|
+
Client.prototype.__getContext = function () {
|
|
997
|
+
return this.__store.getContents('context');
|
|
998
|
+
};
|
|
991
999
|
Client.prototype.__developmentMode = function () {
|
|
992
1000
|
if (this.config.reportData === true) {
|
|
993
1001
|
return false;
|
|
@@ -1036,16 +1044,6 @@
|
|
|
1036
1044
|
}
|
|
1037
1045
|
return tags.toString().split(TAG_SEPARATOR).filter(function (tag) { return NOT_BLANK.test(tag); });
|
|
1038
1046
|
};
|
|
1039
|
-
/**
|
|
1040
|
-
* For ALS, the store may be uninitialized (if .run()` has not been called).
|
|
1041
|
-
* This provides an easy way to read the existing store object or fall back to a default.
|
|
1042
|
-
* Returns *a copy* of the s tore contents.
|
|
1043
|
-
*/
|
|
1044
|
-
Client.prototype.__getStoreContentsOrDefault = function () {
|
|
1045
|
-
var existingStoreContents = this.__store.getStore();
|
|
1046
|
-
var storeContents = existingStoreContents || {};
|
|
1047
|
-
return __assign({ context: {}, breadcrumbs: [] }, storeContents);
|
|
1048
|
-
};
|
|
1049
1047
|
return Client;
|
|
1050
1048
|
}());
|
|
1051
1049
|
client.Client = Client;
|
|
@@ -1071,6 +1069,9 @@
|
|
|
1071
1069
|
}) : function(o, v) {
|
|
1072
1070
|
o["default"] = v;
|
|
1073
1071
|
});
|
|
1072
|
+
var __exportStar = (commonjsGlobal && commonjsGlobal.__exportStar) || function(m, exports) {
|
|
1073
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
1074
|
+
};
|
|
1074
1075
|
var __importStar = (commonjsGlobal && commonjsGlobal.__importStar) || function (mod) {
|
|
1075
1076
|
if (mod && mod.__esModule) return mod;
|
|
1076
1077
|
var result = {};
|
|
@@ -1079,10 +1080,10 @@
|
|
|
1079
1080
|
return result;
|
|
1080
1081
|
};
|
|
1081
1082
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1082
|
-
exports.Util = exports.Types = exports.
|
|
1083
|
+
exports.Util = exports.Types = exports.Client = void 0;
|
|
1083
1084
|
var client_1 = client;
|
|
1084
1085
|
Object.defineProperty(exports, "Client", { enumerable: true, get: function () { return client_1.Client; } });
|
|
1085
|
-
|
|
1086
|
+
__exportStar(store, exports);
|
|
1086
1087
|
exports.Types = __importStar(types);
|
|
1087
1088
|
exports.Util = __importStar(util$1);
|
|
1088
1089
|
} (src));
|