@multiplayer-app/session-recorder-browser 1.2.26 → 1.2.27

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/index.umd.js CHANGED
@@ -24461,7 +24461,7 @@ const DEFAULT_MAX_HTTP_CAPTURING_PAYLOAD_SIZE = 100000;
24461
24461
  const SESSION_RESPONSE = 'multiplayer-debug-session-response';
24462
24462
  const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
24463
24463
  const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
24464
- const PACKAGE_VERSION_EXPORT = "1.2.26" || 0;
24464
+ const PACKAGE_VERSION_EXPORT = "1.2.27" || 0;
24465
24465
  // Regex patterns for OpenTelemetry ignore URLs
24466
24466
  const OTEL_IGNORE_URLS = [
24467
24467
  // Traces endpoint
@@ -25504,33 +25504,40 @@ class TracerBrowserSDK {
25504
25504
  * If there is an active span, the exception will be recorded on it.
25505
25505
  * Otherwise, a short-lived span will be created to hold the exception event.
25506
25506
  */
25507
- captureException(error) {
25507
+ captureException(error, errorInfo) {
25508
25508
  if (!error)
25509
25509
  return;
25510
- // Try to record on the currently active span first
25511
- const activeSpan = _opentelemetry_api__WEBPACK_IMPORTED_MODULE_10__.trace.getSpan(_opentelemetry_api__WEBPACK_IMPORTED_MODULE_11__.context.active());
25512
- if (activeSpan) {
25513
- try {
25510
+ // Prefer attaching to the active span to keep correlation intact
25511
+ try {
25512
+ const activeSpan = _opentelemetry_api__WEBPACK_IMPORTED_MODULE_10__.trace.getSpan(_opentelemetry_api__WEBPACK_IMPORTED_MODULE_11__.context.active());
25513
+ if (activeSpan) {
25514
+ // Standard OTEL exception event + span status
25514
25515
  _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionRecorderSdk.captureException(error);
25516
+ activeSpan.addEvent('exception', {
25517
+ 'exception.type': error.name || 'Error',
25518
+ 'exception.message': error.message,
25519
+ 'exception.stacktrace': error.stack || '',
25520
+ ...(errorInfo || {}),
25521
+ });
25515
25522
  return;
25516
25523
  }
25517
- catch (_e) {
25518
- // fallthrough to creating a dedicated span
25519
- }
25520
25524
  }
25525
+ catch (_ignored) { }
25526
+ // Fallback: create a short-lived span to hold the exception details
25521
25527
  try {
25522
- const tracer = _opentelemetry_api__WEBPACK_IMPORTED_MODULE_10__.trace.getTracer('session-recorder');
25523
- const span = tracer.startSpan('exception');
25528
+ const tracer = _opentelemetry_api__WEBPACK_IMPORTED_MODULE_10__.trace.getTracer('exception');
25529
+ const span = tracer.startSpan(error.name || 'Error');
25524
25530
  span.recordException(error);
25525
25531
  span.setStatus({ code: _opentelemetry_api__WEBPACK_IMPORTED_MODULE_12__.SpanStatusCode.ERROR, message: error.message });
25532
+ span.addEvent('exception', {
25533
+ 'exception.type': error.name || 'Error',
25534
+ 'exception.message': error.message,
25535
+ 'exception.stacktrace': error.stack || '',
25536
+ ...(errorInfo || {}),
25537
+ });
25526
25538
  span.end();
25527
25539
  }
25528
- catch (_err) {
25529
- // eslint-disable-next-line no-console
25530
- if (true) {
25531
- console.warn('[MULTIPLAYER_SESSION_RECORDER] Failed to capture exception', _err);
25532
- }
25533
- }
25540
+ catch (_ignored) { }
25534
25541
  }
25535
25542
  _getSpanSessionIdProcessor() {
25536
25543
  return {
@@ -26769,10 +26776,11 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_14__.Obse
26769
26776
  /**
26770
26777
  * Capture an exception manually and send it as an error trace.
26771
26778
  */
26772
- captureException(error) {
26779
+ captureException(error, errorInfo) {
26773
26780
  try {
26774
26781
  const normalizedError = this._normalizeError(error);
26775
- this._tracer.captureException(normalizedError);
26782
+ const normalizedErrorInfo = this._normalizeErrorInfo(errorInfo);
26783
+ this._tracer.captureException(normalizedError, normalizedErrorInfo);
26776
26784
  }
26777
26785
  catch (e) {
26778
26786
  this.error = (e === null || e === void 0 ? void 0 : e.message) || 'Failed to capture exception';
@@ -27037,6 +27045,16 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_14__.Obse
27037
27045
  return new Error(String(error));
27038
27046
  }
27039
27047
  }
27048
+ _normalizeErrorInfo(errorInfo) {
27049
+ if (!errorInfo)
27050
+ return {};
27051
+ try {
27052
+ return JSON.parse(JSON.stringify(errorInfo));
27053
+ }
27054
+ catch (_e) {
27055
+ return { errorInfo: String(errorInfo) };
27056
+ }
27057
+ }
27040
27058
  }
27041
27059
 
27042
27060