@honeybadger-io/js 6.14.0 → 6.15.2

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.
@@ -57,7 +57,7 @@
57
57
  return stack;
58
58
  }, []);
59
59
  }
60
- var chromeRe = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
60
+ var chromeRe = /^\s*at (.*?) ?\(((?:file|https?|blob|chrome-extension|native|eval|webpack|rsc|<anonymous>|\/|[a-z]:\\|\\\\).*?)(?::(\d+))?(?::(\d+))?\)?\s*$/i;
61
61
  var chromeEvalRe = /\((\S*)(?::(\d+))(?::(\d+))\)/;
62
62
 
63
63
  function parseChrome(line) {
@@ -91,7 +91,7 @@
91
91
  };
92
92
  }
93
93
 
94
- var winjsRe = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
94
+ var winjsRe = /^\s*at (?:((?:\[object object\])?.+) )?\(?((?:file|ms-appx|https?|webpack|rsc|blob):.*?):(\d+)(?::(\d+))?\)?\s*$/i;
95
95
 
96
96
  function parseWinjs(line) {
97
97
  var parts = winjsRe.exec(line);
@@ -109,7 +109,7 @@
109
109
  };
110
110
  }
111
111
 
112
- var geckoRe = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;
112
+ var geckoRe = /^\s*(.*?)(?:\((.*?)\))?(?:^|@)((?:file|https?|blob|chrome|webpack|rsc|resource|\[native).*?|[^@]*bundle)(?::(\d+))?(?::(\d+))?\s*$/i;
113
113
  var geckoEvalRe = /(\S+) line (\d+)(?: > eval line \d+)* > eval/i;
114
114
 
115
115
  function parseGecko(line) {
@@ -220,7 +220,7 @@
220
220
  function verb(n) { return function (v) { return step([n, v]); }; }
221
221
  function step(op) {
222
222
  if (f) throw new TypeError("Generator is already executing.");
223
- while (_) try {
223
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
224
224
  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;
225
225
  if (y = 0, t) op = [op[0] & 2, t.value];
226
226
  switch (op[0]) {
@@ -939,7 +939,7 @@
939
939
  var defaults = {};
940
940
 
941
941
  Object.defineProperty(defaults, "__esModule", { value: true });
942
- defaults.CONFIG = void 0;
942
+ defaults.BREADCRUMBS_SELECTOR_ATTRIBUTES = defaults.CONFIG = void 0;
943
943
  defaults.CONFIG = {
944
944
  apiKey: null,
945
945
  endpoint: 'https://api.honeybadger.io',
@@ -966,6 +966,8 @@
966
966
  filters: ['creditcard', 'password'],
967
967
  __plugins: [],
968
968
  };
969
+ // Browser-only, so it lives outside CONFIG (which is shared with Node).
970
+ defaults.BREADCRUMBS_SELECTOR_ATTRIBUTES = ['data-hb-name'];
969
971
 
970
972
  var __assign$2 = (commonjsGlobal && commonjsGlobal.__assign) || function () {
971
973
  __assign$2 = Object.assign || function(t) {
@@ -993,7 +995,7 @@
993
995
  function verb(n) { return function (v) { return step([n, v]); }; }
994
996
  function step(op) {
995
997
  if (f) throw new TypeError("Generator is already executing.");
996
- while (_) try {
998
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
997
999
  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;
998
1000
  if (y = 0, t) op = [op[0] & 2, t.value];
999
1001
  switch (op[0]) {
@@ -1157,7 +1159,7 @@
1157
1159
  function verb(n) { return function (v) { return step([n, v]); }; }
1158
1160
  function step(op) {
1159
1161
  if (f) throw new TypeError("Generator is already executing.");
1160
- while (_) try {
1162
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
1161
1163
  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;
1162
1164
  if (y = 0, t) op = [op[0] & 2, t.value];
1163
1165
  switch (op[0]) {
@@ -1198,7 +1200,7 @@
1198
1200
  this.__notifier = {
1199
1201
  name: '@honeybadger-io/core',
1200
1202
  url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/core',
1201
- version: '6.14.0'
1203
+ version: '6.15.2'
1202
1204
  };
1203
1205
  this.config = __assign$1(__assign$1({}, defaults_1.CONFIG), opts);
1204
1206
  this.__initStore();
@@ -1633,12 +1635,34 @@
1633
1635
  util.preferCatch = util.encodeCookie = util.decodeCookie = util.localURLPathname = util.parseURL = util.nativeFetch = util.stringTextOfElement = util.stringSelectorOfElement = util.stringNameOfElement = void 0;
1634
1636
  var core_1$7 = src;
1635
1637
  var globalThisOrWindow$7 = core_1$7.Util.globalThisOrWindow;
1638
+ var BREADCRUMBS_SELECTOR_ATTRIBUTES = core_1$7.Defaults.BREADCRUMBS_SELECTOR_ATTRIBUTES;
1636
1639
  /**
1637
1640
  * Converts an HTMLElement into a human-readable string.
1638
1641
  * @param {!HTMLElement} element
1639
1642
  * @return {string}
1640
1643
  */
1641
- function stringNameOfElement(element) {
1644
+ function cleanNameOfElement(element, attributes) {
1645
+ if (!Array.isArray(attributes)) {
1646
+ return undefined;
1647
+ }
1648
+ if (!element || typeof element.getAttribute !== 'function') {
1649
+ return undefined;
1650
+ }
1651
+ for (var _i = 0, attributes_1 = attributes; _i < attributes_1.length; _i++) {
1652
+ var attr = attributes_1[_i];
1653
+ if (typeof attr !== 'string' || attr.length === 0) {
1654
+ continue;
1655
+ }
1656
+ var value = element.getAttribute(attr);
1657
+ if (value && value.trim()) {
1658
+ var normalized = value.trim().replace(/\s+/g, ' ');
1659
+ return truncate(normalized, 100);
1660
+ }
1661
+ }
1662
+ return undefined;
1663
+ }
1664
+ function stringNameOfElement(element, attributes) {
1665
+ if (attributes === void 0) { attributes = BREADCRUMBS_SELECTOR_ATTRIBUTES; }
1642
1666
  if (!element || !element.tagName) {
1643
1667
  return '';
1644
1668
  }
@@ -1647,6 +1671,10 @@
1647
1671
  if (name === 'html') {
1648
1672
  return '';
1649
1673
  }
1674
+ var cleanName = cleanNameOfElement(element, attributes);
1675
+ if (cleanName) {
1676
+ return cleanName;
1677
+ }
1650
1678
  if (element.id) {
1651
1679
  name += "#".concat(element.id);
1652
1680
  }
@@ -1669,10 +1697,15 @@
1669
1697
  return name;
1670
1698
  }
1671
1699
  util.stringNameOfElement = stringNameOfElement;
1672
- function stringSelectorOfElement(element) {
1673
- var name = stringNameOfElement(element);
1700
+ function stringSelectorOfElement(element, attributes) {
1701
+ if (attributes === void 0) { attributes = BREADCRUMBS_SELECTOR_ATTRIBUTES; }
1702
+ var name = stringNameOfElement(element, attributes);
1703
+ // A named element anchors the selector: stop walking up.
1704
+ if (name && cleanNameOfElement(element, attributes)) {
1705
+ return name;
1706
+ }
1674
1707
  if (element.parentNode && element.parentNode.tagName) {
1675
- var parentName = stringSelectorOfElement(element.parentNode);
1708
+ var parentName = stringSelectorOfElement(element.parentNode, attributes);
1676
1709
  if (parentName.length > 0) {
1677
1710
  return "".concat(parentName, " > ").concat(name);
1678
1711
  }
@@ -1923,7 +1956,20 @@
1923
1956
  client.notify(notice);
1924
1957
  return;
1925
1958
  }
1926
- var message = typeof reason === 'string' ? reason : ((_a = JSON.stringify(reason)) !== null && _a !== void 0 ? _a : 'Unspecified reason');
1959
+ var message;
1960
+ if (typeof reason === 'string') {
1961
+ message = reason;
1962
+ }
1963
+ else {
1964
+ try {
1965
+ message = (_a = JSON.stringify(reason)) !== null && _a !== void 0 ? _a : 'Unspecified reason';
1966
+ }
1967
+ catch (_err) {
1968
+ // Circular structures (e.g. DOM nodes with React fiber expandos) can't be stringified
1969
+ var name_1 = reason != null && reason.constructor ? reason.constructor.name : null;
1970
+ message = name_1 ? "[".concat(name_1, "]") : Object.prototype.toString.call(reason);
1971
+ }
1972
+ }
1927
1973
  client.notify({
1928
1974
  name: 'window.onunhandledrejection',
1929
1975
  message: "UnhandledPromiseRejectionWarning: ".concat(message)
@@ -2002,8 +2048,9 @@
2002
2048
  _window.addEventListener('click', function (event) {
2003
2049
  var message, selector, text;
2004
2050
  try {
2005
- message = (0, util_1.stringNameOfElement)(event.target);
2006
- selector = (0, util_1.stringSelectorOfElement)(event.target);
2051
+ var attributes = client.config.breadcrumbsSelectorAttributes;
2052
+ message = (0, util_1.stringNameOfElement)(event.target, attributes);
2053
+ selector = (0, util_1.stringSelectorOfElement)(event.target, attributes);
2007
2054
  text = (0, util_1.stringTextOfElement)(event.target);
2008
2055
  }
2009
2056
  catch (e) {
@@ -2302,7 +2349,7 @@
2302
2349
  function verb(n) { return function (v) { return step([n, v]); }; }
2303
2350
  function step(op) {
2304
2351
  if (f) throw new TypeError("Generator is already executing.");
2305
- while (_) try {
2352
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
2306
2353
  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;
2307
2354
  if (y = 0, t) op = [op[0] & 2, t.value];
2308
2355
  switch (op[0]) {
@@ -2498,7 +2545,7 @@
2498
2545
  function verb(n) { return function (v) { return step([n, v]); }; }
2499
2546
  function step(op) {
2500
2547
  if (f) throw new TypeError("Generator is already executing.");
2501
- while (_) try {
2548
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
2502
2549
  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;
2503
2550
  if (y = 0, t) op = [op[0] & 2, t.value];
2504
2551
  switch (op[0]) {
@@ -2552,7 +2599,7 @@
2552
2599
  __extends(Honeybadger, _super);
2553
2600
  function Honeybadger(opts) {
2554
2601
  if (opts === void 0) { opts = {}; }
2555
- var _this = _super.call(this, __assign({ userFeedbackEndpoint: 'https://api.honeybadger.io/v2/feedback', async: true, maxErrors: null, ignoreBrowserExtensionErrors: false, projectRoot: getProjectRoot() }, opts), new transport_1.BrowserTransport({
2602
+ var _this = _super.call(this, __assign({ userFeedbackEndpoint: 'https://api.honeybadger.io/v2/feedback', async: true, maxErrors: null, ignoreBrowserExtensionErrors: false, breadcrumbsSelectorAttributes: core_1.Defaults.BREADCRUMBS_SELECTOR_ATTRIBUTES, projectRoot: getProjectRoot() }, opts), new transport_1.BrowserTransport({
2556
2603
  'User-Agent': userAgent(),
2557
2604
  })) || this;
2558
2605
  /** @internal */
@@ -2726,7 +2773,7 @@
2726
2773
  var NOTIFIER = {
2727
2774
  name: '@honeybadger-io/js',
2728
2775
  url: 'https://github.com/honeybadger-io/honeybadger-js/tree/master/packages/js',
2729
- version: '6.14.0'
2776
+ version: '6.15.2'
2730
2777
  };
2731
2778
  var userAgent = function () {
2732
2779
  if (typeof navigator !== 'undefined') {