@coralogix/browser 2.13.0 → 2.14.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/CHANGELOG.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## 2.14.0 (2025-12-07)
2
+
3
+ ### 🚀 Features
4
+
5
+ - **errors:** add stack traces to console error logs
6
+
1
7
  ## 2.13.0 (2025-12-07)
2
8
 
3
9
  ### 🩹 Fixes
package/index.esm2.js CHANGED
@@ -503,7 +503,8 @@ var _consoleErrorHandler = function (errorInstrumentation) {
503
503
  for (var _i = 0; _i < arguments.length; _i++) {
504
504
  args[_i] = arguments[_i];
505
505
  }
506
- errorInstrumentation.report(ErrorSource.CONSOLE, args);
506
+ var stackContextError = new Error();
507
+ errorInstrumentation.report(ErrorSource.CONSOLE, args, stackContextError);
507
508
  return original.apply(console, args);
508
509
  };
509
510
  };
@@ -555,7 +556,7 @@ var CoralogixErrorInstrumentation = (function (_super) {
555
556
  CxGlobal.removeEventListener('unhandledrejection', _unhandledRejectionListener(this));
556
557
  document.documentElement.removeEventListener('error', _documentErrorListener(this), { capture: true });
557
558
  };
558
- CoralogixErrorInstrumentation.prototype.report = function (source, arg) {
559
+ CoralogixErrorInstrumentation.prototype.report = function (source, arg, stackContextError) {
559
560
  var _this = this;
560
561
  if (arg instanceof Array) {
561
562
  if (arg.length === 0) {
@@ -573,7 +574,7 @@ var CoralogixErrorInstrumentation = (function (_super) {
573
574
  this.reportEvent(source, arg);
574
575
  break;
575
576
  case typeof arg === 'string':
576
- this.reportString(source, arg);
577
+ this.reportString(source, arg, stackContextError);
577
578
  break;
578
579
  case arg instanceof Array: {
579
580
  var firstError = arg.find(function (x) { return x instanceof Error; });
@@ -582,7 +583,8 @@ var CoralogixErrorInstrumentation = (function (_super) {
582
583
  return typeof msg === 'string' ? msg : _this.parseErrorObject(msg);
583
584
  })
584
585
  .join(' ');
585
- this.reportString(source, message, firstError);
586
+ var stackSourceError = firstError !== null && firstError !== void 0 ? firstError : stackContextError;
587
+ this.reportString(source, message, stackSourceError);
586
588
  break;
587
589
  }
588
590
  default:
@@ -617,7 +619,7 @@ var CoralogixErrorInstrumentation = (function (_super) {
617
619
  });
618
620
  });
619
621
  };
620
- CoralogixErrorInstrumentation.prototype.reportString = function (source, message, firstError) {
622
+ CoralogixErrorInstrumentation.prototype.reportString = function (source, message, stackError) {
621
623
  return __awaiter(this, void 0, void 0, function () {
622
624
  var span;
623
625
  return __generator(this, function (_a) {
@@ -627,8 +629,8 @@ var CoralogixErrorInstrumentation = (function (_super) {
627
629
  addErrorDefaultAttributes(span);
628
630
  span.setAttribute(CoralogixAttributes.SOURCE, source);
629
631
  span.setAttribute(ErrorAttributes.MESSAGE, message === null || message === void 0 ? void 0 : message.substring(0, MESSAGE_LIMIT));
630
- if (!firstError) return [3, 2];
631
- return [4, buildStacktrace(span, firstError)];
632
+ if (!stackError) return [3, 2];
633
+ return [4, buildStacktrace(span, stackError)];
632
634
  case 1:
633
635
  _a.sent();
634
636
  _a.label = 2;
@@ -947,6 +949,9 @@ var CoralogixFetchInstrumentation = (function (_super) {
947
949
  return __generator(this, function (_b) {
948
950
  switch (_b.label) {
949
951
  case 0:
952
+ if (!span.isRecording()) {
953
+ return [2];
954
+ }
950
955
  status = response.status;
951
956
  networkExtraConfig = getSdkConfig().networkExtraConfig;
952
957
  url = span.attributes['http.url'] ||
@@ -1083,6 +1088,9 @@ var CoralogixXhrInstrumentation = (function (_super) {
1083
1088
  }
1084
1089
  CoralogixXhrInstrumentation.prototype.setNetworkSpanAttributes = function (span, xhr) {
1085
1090
  var _a;
1091
+ if (!span.isRecording()) {
1092
+ return;
1093
+ }
1086
1094
  var status = xhr.status;
1087
1095
  var networkExtraConfig = getSdkConfig().networkExtraConfig;
1088
1096
  var resolvedConfig = this.networkDataManager.resolveConfigForUrl(xhr.responseURL, networkExtraConfig);
@@ -4130,7 +4138,7 @@ function resolveUrlBlueprinters(urlBlueprinters) {
4130
4138
  return resolvedUrlBlueprinters;
4131
4139
  }
4132
4140
 
4133
- var SDK_VERSION = '2.13.0';
4141
+ var SDK_VERSION = '2.14.0';
4134
4142
 
4135
4143
  function shouldDropEvent(cxRumEvent, options) {
4136
4144
  if (isDocumentErrorWithoutMessage(cxRumEvent)) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coralogix/browser",
3
- "version": "2.13.0",
3
+ "version": "2.14.0",
4
4
  "description": "Official Coralogix SDK for browsers",
5
5
  "license": "Apache-2.0",
6
6
  "author": "Coralogix",
@@ -23,7 +23,7 @@ export declare class CoralogixErrorInstrumentation extends InstrumentationBase {
23
23
  protected init(): void;
24
24
  enable(): void;
25
25
  disable(): void;
26
- report(source: ErrorSource, arg: string | Error | Event | ErrorEvent | Array<any>): void;
26
+ report(source: ErrorSource, arg: string | Error | Event | ErrorEvent | Array<any>, stackContextError?: Error): void;
27
27
  parseErrorObject: (obj: any) => string;
28
28
  reportError(source: ErrorSource, err: Error, customData?: unknown, labels?: CoralogixRumLabels): Promise<void>;
29
29
  private reportString;
package/src/version.d.ts CHANGED
@@ -1 +1 @@
1
- export declare const SDK_VERSION = "2.13.0";
1
+ export declare const SDK_VERSION = "2.14.0";