@multiplayer-app/session-recorder-browser 1.3.27 → 1.3.28
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/index.js +347 -123
- package/dist/exporters/index.js +1 -1
- package/dist/exporters/index.js.LICENSE.txt +12 -0
- package/dist/exporters/index.js.map +1 -1
- package/dist/index.js +345 -123
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +346 -123
- package/dist/index.umd.js.map +1 -1
- package/dist/otel/CrashBufferSpanProcessor.d.ts +2 -3
- package/dist/otel/CrashBufferSpanProcessor.d.ts.map +1 -1
- package/dist/otel/CrashBufferSpanProcessor.js +11 -12
- package/dist/otel/CrashBufferSpanProcessor.js.map +1 -1
- package/dist/otel/index.d.ts +1 -1
- package/dist/otel/index.d.ts.map +1 -1
- package/dist/otel/index.js +73 -50
- package/dist/otel/index.js.map +1 -1
- package/dist/services/crashBuffer.service.d.ts.map +1 -1
- package/dist/services/crashBuffer.service.js +40 -7
- package/dist/services/crashBuffer.service.js.map +1 -1
- package/dist/services/indexedDb.service.d.ts +11 -1
- package/dist/services/indexedDb.service.d.ts.map +1 -1
- package/dist/services/indexedDb.service.js +47 -3
- package/dist/services/indexedDb.service.js.map +1 -1
- package/dist/session-recorder.d.ts.map +1 -1
- package/dist/session-recorder.js +6 -5
- package/dist/session-recorder.js.map +1 -1
- package/package.json +2 -2
package/dist/browser/index.js
CHANGED
|
@@ -25054,7 +25054,7 @@ const CONTINUOUS_DEBUGGING_TIMEOUT = 60000; // 1 minutes
|
|
|
25054
25054
|
const DEBUG_SESSION_MAX_DURATION_SECONDS = 10 * 60 + 30; // TODO: move to shared config otel core
|
|
25055
25055
|
const REMOTE_SESSION_RECORDING_START = 'remote-session-recording:start';
|
|
25056
25056
|
const REMOTE_SESSION_RECORDING_STOP = 'remote-session-recording:stop';
|
|
25057
|
-
const PACKAGE_VERSION_EXPORT = "1.3.
|
|
25057
|
+
const PACKAGE_VERSION_EXPORT = "1.3.28" || 0;
|
|
25058
25058
|
// Regex patterns for OpenTelemetry ignore URLs
|
|
25059
25059
|
const OTEL_IGNORE_URLS = [
|
|
25060
25060
|
// Traces endpoint
|
|
@@ -25748,31 +25748,30 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
25748
25748
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
25749
25749
|
/* harmony export */ CrashBufferSpanProcessor: () => (/* binding */ CrashBufferSpanProcessor)
|
|
25750
25750
|
/* harmony export */ });
|
|
25751
|
-
/* harmony import */ var _opentelemetry_api__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @opentelemetry/api */ "../../node_modules/@opentelemetry/api/build/esm/trace/trace_flags.js");
|
|
25752
25751
|
/* harmony import */ var _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @multiplayer-app/session-recorder-common */ "../session-recorder-common/dist/esm/index-browser.js");
|
|
25753
25752
|
|
|
25754
|
-
|
|
25755
25753
|
/**
|
|
25756
25754
|
* Implementation of the {@link SpanProcessor} that batches spans exported by
|
|
25757
25755
|
* the SDK then pushes them to the exporter pipeline.
|
|
25758
25756
|
*/
|
|
25759
25757
|
class CrashBufferSpanProcessor {
|
|
25760
|
-
constructor(
|
|
25761
|
-
this._exporter = _exporter;
|
|
25758
|
+
constructor(_crashBuffer, _serializeSpan) {
|
|
25762
25759
|
this._crashBuffer = _crashBuffer;
|
|
25763
25760
|
this._serializeSpan = _serializeSpan;
|
|
25764
25761
|
}
|
|
25765
25762
|
forceFlush() {
|
|
25766
|
-
return
|
|
25763
|
+
return Promise.resolve();
|
|
25767
25764
|
}
|
|
25768
25765
|
onStart(_span, _parentContext) {
|
|
25769
|
-
return
|
|
25766
|
+
return;
|
|
25770
25767
|
}
|
|
25771
25768
|
onEnd(span) {
|
|
25772
|
-
const
|
|
25773
|
-
|
|
25774
|
-
|
|
25775
|
-
|
|
25769
|
+
const _spanContext = span.spanContext();
|
|
25770
|
+
const traceId = _spanContext.traceId;
|
|
25771
|
+
// // Never buffer/export unsampled spans.
|
|
25772
|
+
// if ((_spanContext.traceFlags & TraceFlags.SAMPLED) === 0) {
|
|
25773
|
+
// return
|
|
25774
|
+
// }
|
|
25776
25775
|
if (traceId.startsWith(_multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_0__.MULTIPLAYER_TRACE_SESSION_CACHE_PREFIX)) {
|
|
25777
25776
|
if (this._crashBuffer) {
|
|
25778
25777
|
this._crashBuffer.appendSpans([
|
|
@@ -25784,10 +25783,9 @@ class CrashBufferSpanProcessor {
|
|
|
25784
25783
|
}
|
|
25785
25784
|
return;
|
|
25786
25785
|
}
|
|
25787
|
-
this._exporter.onEnd(span);
|
|
25788
25786
|
}
|
|
25789
25787
|
shutdown() {
|
|
25790
|
-
return
|
|
25788
|
+
return Promise.resolve();
|
|
25791
25789
|
}
|
|
25792
25790
|
}
|
|
25793
25791
|
|
|
@@ -26036,17 +26034,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26036
26034
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
26037
26035
|
/* harmony export */ TracerBrowserSDK: () => (/* binding */ TracerBrowserSDK)
|
|
26038
26036
|
/* harmony export */ });
|
|
26039
|
-
/* harmony import */ var
|
|
26037
|
+
/* harmony import */ var _opentelemetry_resources__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! @opentelemetry/resources */ "../../node_modules/@opentelemetry/resources/build/esm/ResourceImpl.js");
|
|
26040
26038
|
/* harmony import */ var _opentelemetry_core__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! @opentelemetry/core */ "../../node_modules/@opentelemetry/core/build/esm/trace/W3CTraceContextPropagator.js");
|
|
26041
|
-
/* harmony import */ var
|
|
26042
|
-
/* harmony import */ var
|
|
26043
|
-
/* harmony import */ var
|
|
26039
|
+
/* harmony import */ var _opentelemetry_sdk_trace_web__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! @opentelemetry/sdk-trace-web */ "../../node_modules/@opentelemetry/sdk-trace-web/build/esm/WebTracerProvider.js");
|
|
26040
|
+
/* harmony import */ var _opentelemetry_sdk_trace_base__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! @opentelemetry/sdk-trace-base */ "../../node_modules/@opentelemetry/sdk-trace-base/build/esm/platform/browser/export/BatchSpanProcessor.js");
|
|
26041
|
+
/* harmony import */ var _opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! @opentelemetry/semantic-conventions */ "../../node_modules/@opentelemetry/semantic-conventions/build/esm/resource/SemanticResourceAttributes.js");
|
|
26044
26042
|
/* harmony import */ var _opentelemetry_instrumentation__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! @opentelemetry/instrumentation */ "../../node_modules/@opentelemetry/instrumentation/build/esm/autoLoader.js");
|
|
26045
26043
|
/* harmony import */ var _opentelemetry_auto_instrumentations_web__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @opentelemetry/auto-instrumentations-web */ "../../node_modules/@opentelemetry/auto-instrumentations-web/build/esm/index.js");
|
|
26046
26044
|
/* harmony import */ var _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @multiplayer-app/session-recorder-common */ "../session-recorder-common/dist/esm/index-browser.js");
|
|
26047
|
-
/* harmony import */ var _opentelemetry_api__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! @opentelemetry/api */ "../../node_modules/@opentelemetry/api/build/esm/trace-api.js");
|
|
26048
|
-
/* harmony import */ var _opentelemetry_api__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! @opentelemetry/api */ "../../node_modules/@opentelemetry/api/build/esm/context-api.js");
|
|
26049
|
-
/* harmony import */ var _opentelemetry_api__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! @opentelemetry/api */ "../../node_modules/@opentelemetry/api/build/esm/trace/status.js");
|
|
26050
26045
|
/* harmony import */ var _config__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../config */ "./src/config/index.ts");
|
|
26051
26046
|
/* harmony import */ var _helpers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./helpers */ "./src/otel/helpers.ts");
|
|
26052
26047
|
/* harmony import */ var _CrashBufferSpanProcessor__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./CrashBufferSpanProcessor */ "./src/otel/CrashBufferSpanProcessor.ts");
|
|
@@ -26061,7 +26056,6 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
26061
26056
|
|
|
26062
26057
|
|
|
26063
26058
|
|
|
26064
|
-
|
|
26065
26059
|
const clientIdGenerator = _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionRecorderSdk.getIdGenerator(_multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.MULTIPLAYER_TRACE_CLIENT_ID_LENGTH);
|
|
26066
26060
|
class TracerBrowserSDK {
|
|
26067
26061
|
constructor() {
|
|
@@ -26087,18 +26081,20 @@ class TracerBrowserSDK {
|
|
|
26087
26081
|
url: (0,_helpers__WEBPACK_IMPORTED_MODULE_3__.getExporterEndpoint)(options.exporterEndpoint),
|
|
26088
26082
|
usePostMessageFallback: options.usePostMessageFallback,
|
|
26089
26083
|
});
|
|
26090
|
-
|
|
26091
|
-
|
|
26092
|
-
|
|
26093
|
-
|
|
26094
|
-
|
|
26095
|
-
|
|
26096
|
-
|
|
26084
|
+
const resourceAttributes = (0,_opentelemetry_resources__WEBPACK_IMPORTED_MODULE_5__.resourceFromAttributes)({
|
|
26085
|
+
[_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_6__.SEMRESATTRS_SERVICE_NAME]: application,
|
|
26086
|
+
[_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_6__.SEMRESATTRS_SERVICE_VERSION]: version,
|
|
26087
|
+
[_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_6__.SEMRESATTRS_DEPLOYMENT_ENVIRONMENT]: environment,
|
|
26088
|
+
});
|
|
26089
|
+
_multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionRecorderSdk.setResourceAttributes(resourceAttributes.attributes);
|
|
26090
|
+
this.tracerProvider = new _opentelemetry_sdk_trace_web__WEBPACK_IMPORTED_MODULE_7__.WebTracerProvider({
|
|
26091
|
+
resource: resourceAttributes,
|
|
26097
26092
|
idGenerator: this.idGenerator,
|
|
26098
26093
|
sampler: new _multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionRecorderTraceIdRatioBasedSampler(this.config.sampleTraceRatio),
|
|
26099
26094
|
spanProcessors: [
|
|
26100
26095
|
this._getSpanSessionIdProcessor(),
|
|
26101
|
-
new
|
|
26096
|
+
new _opentelemetry_sdk_trace_base__WEBPACK_IMPORTED_MODULE_8__.BatchSpanProcessor(this.exporter),
|
|
26097
|
+
new _CrashBufferSpanProcessor__WEBPACK_IMPORTED_MODULE_4__.CrashBufferSpanProcessor(this.crashBuffer, this.exporter.serializeSpan),
|
|
26102
26098
|
],
|
|
26103
26099
|
});
|
|
26104
26100
|
this.tracerProvider.register({
|
|
@@ -26229,13 +26225,70 @@ class TracerBrowserSDK {
|
|
|
26229
26225
|
}
|
|
26230
26226
|
this.exporter.setApiKey(apiKey);
|
|
26231
26227
|
}
|
|
26232
|
-
|
|
26228
|
+
static _toReadableSpanLike(span) {
|
|
26233
26229
|
var _a;
|
|
26234
|
-
if (
|
|
26235
|
-
|
|
26236
|
-
// return this.batchSpanProcessor.onEnd()
|
|
26230
|
+
if (span && typeof span.spanContext === 'function' && span.instrumentationScope) {
|
|
26231
|
+
return span;
|
|
26237
26232
|
}
|
|
26238
|
-
|
|
26233
|
+
const spanContext = typeof (span === null || span === void 0 ? void 0 : span.spanContext) === 'function' ? span.spanContext() : span === null || span === void 0 ? void 0 : span._spanContext;
|
|
26234
|
+
const normalizedCtx = spanContext ||
|
|
26235
|
+
{
|
|
26236
|
+
traceId: span === null || span === void 0 ? void 0 : span.traceId,
|
|
26237
|
+
spanId: span === null || span === void 0 ? void 0 : span.spanId,
|
|
26238
|
+
traceFlags: span === null || span === void 0 ? void 0 : span.traceFlags,
|
|
26239
|
+
traceState: span === null || span === void 0 ? void 0 : span.traceState,
|
|
26240
|
+
};
|
|
26241
|
+
const instrumentationScope = (span === null || span === void 0 ? void 0 : span.instrumentationScope) ||
|
|
26242
|
+
(span === null || span === void 0 ? void 0 : span.instrumentationLibrary) ||
|
|
26243
|
+
{ name: 'multiplayer-buffer', version: undefined, schemaUrl: undefined };
|
|
26244
|
+
const normalizedScope = {
|
|
26245
|
+
name: (instrumentationScope === null || instrumentationScope === void 0 ? void 0 : instrumentationScope.name) || 'multiplayer-buffer',
|
|
26246
|
+
version: instrumentationScope === null || instrumentationScope === void 0 ? void 0 : instrumentationScope.version,
|
|
26247
|
+
schemaUrl: instrumentationScope === null || instrumentationScope === void 0 ? void 0 : instrumentationScope.schemaUrl,
|
|
26248
|
+
};
|
|
26249
|
+
const resource = (span === null || span === void 0 ? void 0 : span.resource) || { attributes: {}, asyncAttributesPending: false };
|
|
26250
|
+
const parentSpanId = span === null || span === void 0 ? void 0 : span.parentSpanId;
|
|
26251
|
+
return {
|
|
26252
|
+
name: (span === null || span === void 0 ? void 0 : span.name) || '',
|
|
26253
|
+
kind: span === null || span === void 0 ? void 0 : span.kind,
|
|
26254
|
+
spanContext: () => normalizedCtx,
|
|
26255
|
+
parentSpanContext: parentSpanId
|
|
26256
|
+
? {
|
|
26257
|
+
traceId: normalizedCtx === null || normalizedCtx === void 0 ? void 0 : normalizedCtx.traceId,
|
|
26258
|
+
spanId: parentSpanId,
|
|
26259
|
+
traceFlags: normalizedCtx === null || normalizedCtx === void 0 ? void 0 : normalizedCtx.traceFlags,
|
|
26260
|
+
traceState: normalizedCtx === null || normalizedCtx === void 0 ? void 0 : normalizedCtx.traceState,
|
|
26261
|
+
}
|
|
26262
|
+
: undefined,
|
|
26263
|
+
startTime: span === null || span === void 0 ? void 0 : span.startTime,
|
|
26264
|
+
endTime: (_a = span === null || span === void 0 ? void 0 : span.endTime) !== null && _a !== void 0 ? _a : span === null || span === void 0 ? void 0 : span.startTime,
|
|
26265
|
+
duration: span === null || span === void 0 ? void 0 : span.duration,
|
|
26266
|
+
status: span === null || span === void 0 ? void 0 : span.status,
|
|
26267
|
+
attributes: (span === null || span === void 0 ? void 0 : span.attributes) || {},
|
|
26268
|
+
links: (span === null || span === void 0 ? void 0 : span.links) || [],
|
|
26269
|
+
events: (span === null || span === void 0 ? void 0 : span.events) || [],
|
|
26270
|
+
ended: typeof (span === null || span === void 0 ? void 0 : span.ended) === 'boolean' ? span.ended : true,
|
|
26271
|
+
droppedAttributesCount: (span === null || span === void 0 ? void 0 : span.droppedAttributesCount) || 0,
|
|
26272
|
+
droppedEventsCount: (span === null || span === void 0 ? void 0 : span.droppedEventsCount) || 0,
|
|
26273
|
+
droppedLinksCount: (span === null || span === void 0 ? void 0 : span.droppedLinksCount) || 0,
|
|
26274
|
+
resource,
|
|
26275
|
+
instrumentationScope: normalizedScope,
|
|
26276
|
+
};
|
|
26277
|
+
}
|
|
26278
|
+
async exportTraces(spans) {
|
|
26279
|
+
if (!this.exporter) {
|
|
26280
|
+
throw new Error('Trace exporter not initialized');
|
|
26281
|
+
}
|
|
26282
|
+
if (!spans || spans.length === 0) {
|
|
26283
|
+
return Promise.resolve();
|
|
26284
|
+
}
|
|
26285
|
+
const readableSpans = spans.map((s) => TracerBrowserSDK._toReadableSpanLike(s));
|
|
26286
|
+
return new Promise((resolve) => {
|
|
26287
|
+
var _a;
|
|
26288
|
+
(_a = this.exporter) === null || _a === void 0 ? void 0 : _a.exportBuffer(readableSpans, (result) => {
|
|
26289
|
+
resolve(result);
|
|
26290
|
+
});
|
|
26291
|
+
});
|
|
26239
26292
|
}
|
|
26240
26293
|
/**
|
|
26241
26294
|
* Capture an exception as an error span/event.
|
|
@@ -26243,42 +26296,7 @@ class TracerBrowserSDK {
|
|
|
26243
26296
|
* Otherwise, a short-lived span will be created to hold the exception event.
|
|
26244
26297
|
*/
|
|
26245
26298
|
captureException(error, errorInfo) {
|
|
26246
|
-
|
|
26247
|
-
if (!error)
|
|
26248
|
-
return;
|
|
26249
|
-
// Prefer attaching to the active span to keep correlation intact
|
|
26250
|
-
try {
|
|
26251
|
-
const activeSpan = _opentelemetry_api__WEBPACK_IMPORTED_MODULE_11__.trace.getSpan(_opentelemetry_api__WEBPACK_IMPORTED_MODULE_12__.context.active());
|
|
26252
|
-
if (activeSpan) {
|
|
26253
|
-
this._recordException(activeSpan, error, errorInfo);
|
|
26254
|
-
(_a = this.tracerProvider) === null || _a === void 0 ? void 0 : _a.forceFlush();
|
|
26255
|
-
return;
|
|
26256
|
-
}
|
|
26257
|
-
// eslint-disable-next-line
|
|
26258
|
-
}
|
|
26259
|
-
catch (_ignored) { }
|
|
26260
|
-
// Fallback: create a short-lived span to hold the exception details
|
|
26261
|
-
try {
|
|
26262
|
-
const tracer = _opentelemetry_api__WEBPACK_IMPORTED_MODULE_11__.trace.getTracer('exception');
|
|
26263
|
-
const span = tracer.startSpan(error.name || 'Error');
|
|
26264
|
-
this._recordException(span, error, errorInfo);
|
|
26265
|
-
span.end();
|
|
26266
|
-
(_b = this.tracerProvider) === null || _b === void 0 ? void 0 : _b.forceFlush();
|
|
26267
|
-
// eslint-disable-next-line
|
|
26268
|
-
}
|
|
26269
|
-
catch (_ignored) { }
|
|
26270
|
-
}
|
|
26271
|
-
_recordException(span, error, errorInfo) {
|
|
26272
|
-
span.recordException(error);
|
|
26273
|
-
span.setStatus({ code: _opentelemetry_api__WEBPACK_IMPORTED_MODULE_13__.SpanStatusCode.ERROR, message: error.message });
|
|
26274
|
-
span.setAttribute('exception.type', error.name || 'Error');
|
|
26275
|
-
span.setAttribute('exception.message', error.message);
|
|
26276
|
-
span.setAttribute('exception.stacktrace', error.stack || '');
|
|
26277
|
-
if (errorInfo) {
|
|
26278
|
-
Object.entries(errorInfo).forEach(([key, value]) => {
|
|
26279
|
-
span.setAttribute(`error_info.${key}`, value);
|
|
26280
|
-
});
|
|
26281
|
-
}
|
|
26299
|
+
_multiplayer_app_session_recorder_common__WEBPACK_IMPORTED_MODULE_1__.SessionRecorderSdk.captureException(error, errorInfo);
|
|
26282
26300
|
}
|
|
26283
26301
|
_getSpanSessionIdProcessor() {
|
|
26284
26302
|
return {
|
|
@@ -27138,7 +27156,9 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
27138
27156
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
27139
27157
|
/* harmony export */ CrashBufferService: () => (/* binding */ CrashBufferService)
|
|
27140
27158
|
/* harmony export */ });
|
|
27141
|
-
/* harmony import */ var
|
|
27159
|
+
/* harmony import */ var _opentelemetry_api__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @opentelemetry/api */ "../../node_modules/@opentelemetry/api/build/esm/trace/status.js");
|
|
27160
|
+
/* harmony import */ var _rrweb_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @rrweb/types */ "../../node_modules/@rrweb/types/dist/types.js");
|
|
27161
|
+
|
|
27142
27162
|
|
|
27143
27163
|
class CrashBufferService {
|
|
27144
27164
|
constructor(db, tabId, windowMs) {
|
|
@@ -27171,12 +27191,16 @@ class CrashBufferService {
|
|
|
27171
27191
|
}, undefined);
|
|
27172
27192
|
}
|
|
27173
27193
|
async appendEvent(payload, _windowMs) {
|
|
27194
|
+
var _a;
|
|
27174
27195
|
this.lastSeenEventTs = Math.max(this.lastSeenEventTs, payload.ts || 0);
|
|
27175
27196
|
if (!this.isActive)
|
|
27176
27197
|
return;
|
|
27177
27198
|
const isFullSnapshot = Boolean(payload.isFullSnapshot);
|
|
27178
|
-
|
|
27179
|
-
|
|
27199
|
+
const eventType = (_a = payload === null || payload === void 0 ? void 0 : payload.event) === null || _a === void 0 ? void 0 : _a.eventType;
|
|
27200
|
+
const isMeta = eventType === _rrweb_types__WEBPACK_IMPORTED_MODULE_0__.EventType.Meta;
|
|
27201
|
+
if (this.requiresFullSnapshot && !isFullSnapshot && !isMeta) {
|
|
27202
|
+
// rrweb replayable prefix is Meta -> FullSnapshot.
|
|
27203
|
+
// While waiting for the first FullSnapshot, we still keep the Meta event (but drop incrementals).
|
|
27180
27204
|
return;
|
|
27181
27205
|
}
|
|
27182
27206
|
await this._safe(async () => {
|
|
@@ -27189,8 +27213,8 @@ class CrashBufferService {
|
|
|
27189
27213
|
}, undefined);
|
|
27190
27214
|
if (isFullSnapshot && this.requiresFullSnapshot) {
|
|
27191
27215
|
// Ensure this snapshot becomes the first replayable event.
|
|
27192
|
-
//
|
|
27193
|
-
await this._safe(() => this.db.
|
|
27216
|
+
// Keep Meta + FullSnapshot (if present) and prune everything older.
|
|
27217
|
+
await this._safe(() => this.db.pruneOlderThanWithRrwebSnapshotAnchor(this.tabId, payload.ts), undefined);
|
|
27194
27218
|
this.requiresFullSnapshot = false;
|
|
27195
27219
|
}
|
|
27196
27220
|
else if (isFullSnapshot) {
|
|
@@ -27208,7 +27232,7 @@ class CrashBufferService {
|
|
|
27208
27232
|
await this._safe(async () => {
|
|
27209
27233
|
const records = payload.map((p) => {
|
|
27210
27234
|
var _a, _b;
|
|
27211
|
-
if (!errorEvent && ((_b = (_a = p === null || p === void 0 ? void 0 : p.span) === null || _a === void 0 ? void 0 : _a.status) === null || _b === void 0 ? void 0 : _b.code) ===
|
|
27235
|
+
if (!errorEvent && ((_b = (_a = p === null || p === void 0 ? void 0 : p.span) === null || _a === void 0 ? void 0 : _a.status) === null || _b === void 0 ? void 0 : _b.code) === _opentelemetry_api__WEBPACK_IMPORTED_MODULE_1__.SpanStatusCode.ERROR) {
|
|
27212
27236
|
errorEvent = { ts: p.ts, span: p.span };
|
|
27213
27237
|
}
|
|
27214
27238
|
return {
|
|
@@ -27253,6 +27277,7 @@ class CrashBufferService {
|
|
|
27253
27277
|
}
|
|
27254
27278
|
}
|
|
27255
27279
|
async snapshot(_windowMs, now = Date.now()) {
|
|
27280
|
+
var _a, _b;
|
|
27256
27281
|
const toTs = now;
|
|
27257
27282
|
const fromTs = Math.max(0, toTs - this.windowMs);
|
|
27258
27283
|
// Always include a full snapshot "anchor" if one exists at/before the window start.
|
|
@@ -27268,10 +27293,37 @@ class CrashBufferService {
|
|
|
27268
27293
|
const rrwebSorted = rrweb
|
|
27269
27294
|
.sort((a, b) => a.ts - b.ts)
|
|
27270
27295
|
.map((r) => ({ ts: r.ts, isFullSnapshot: r.isFullSnapshot, event: r.event }));
|
|
27271
|
-
// Hard guarantee: snapshot payload starts with
|
|
27296
|
+
// Hard guarantee: snapshot payload starts with Meta -> FullSnapshot (or is empty).
|
|
27272
27297
|
const firstFullSnapshotIdx = rrwebSorted.findIndex((e) => Boolean(e.isFullSnapshot));
|
|
27273
|
-
|
|
27274
|
-
|
|
27298
|
+
if (firstFullSnapshotIdx < 0) {
|
|
27299
|
+
return {
|
|
27300
|
+
rrwebEvents: [],
|
|
27301
|
+
otelSpans: [],
|
|
27302
|
+
attrs: attrs
|
|
27303
|
+
? {
|
|
27304
|
+
sessionAttributes: attrs.sessionAttributes,
|
|
27305
|
+
resourceAttributes: attrs.resourceAttributes,
|
|
27306
|
+
userAttributes: attrs.userAttributes,
|
|
27307
|
+
}
|
|
27308
|
+
: null,
|
|
27309
|
+
windowMs: this.windowMs,
|
|
27310
|
+
fromTs,
|
|
27311
|
+
toTs,
|
|
27312
|
+
};
|
|
27313
|
+
}
|
|
27314
|
+
// Prefer including the Meta event immediately preceding the first FullSnapshot.
|
|
27315
|
+
let startIdx = firstFullSnapshotIdx;
|
|
27316
|
+
for (let i = firstFullSnapshotIdx - 1; i >= 0; i--) {
|
|
27317
|
+
const t = (_b = (_a = rrwebSorted[i]) === null || _a === void 0 ? void 0 : _a.event) === null || _b === void 0 ? void 0 : _b.eventType;
|
|
27318
|
+
if (t === _rrweb_types__WEBPACK_IMPORTED_MODULE_0__.EventType.Meta) {
|
|
27319
|
+
startIdx = i;
|
|
27320
|
+
break;
|
|
27321
|
+
}
|
|
27322
|
+
}
|
|
27323
|
+
const rrwebEvents = rrwebSorted.slice(startIdx);
|
|
27324
|
+
// Align spans with the rrweb replay start (Meta if present, otherwise FullSnapshot).
|
|
27325
|
+
// Important: we return `fromTs` to consumers and many UIs compute relative offsets from it,
|
|
27326
|
+
// so `fromTs` must match the first rrweb event timestamp we return.
|
|
27275
27327
|
const replayStartTs = rrwebEvents.length > 0 ? rrwebEvents[0].ts : fromTs;
|
|
27276
27328
|
const otelSpans = spans
|
|
27277
27329
|
.filter((s) => typeof (s === null || s === void 0 ? void 0 : s.ts) === 'number' && s.ts >= replayStartTs)
|
|
@@ -27360,12 +27412,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
27360
27412
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
27361
27413
|
/* harmony export */ IndexedDBService: () => (/* binding */ IndexedDBService)
|
|
27362
27414
|
/* harmony export */ });
|
|
27415
|
+
/* harmony import */ var _rrweb_types__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @rrweb/types */ "../../node_modules/@rrweb/types/dist/types.js");
|
|
27363
27416
|
const dbName = 'mpEventsDB';
|
|
27364
27417
|
const dbVersion = 2;
|
|
27365
27418
|
const legacyStoreName = 'mpEventsStore';
|
|
27366
27419
|
const rrwebEventsStore = 'rrwebEvents';
|
|
27367
27420
|
const otelSpansStore = 'otelSpans';
|
|
27368
27421
|
const attrsStore = 'crashBufferAttrs';
|
|
27422
|
+
|
|
27369
27423
|
class IndexedDBService {
|
|
27370
27424
|
constructor() {
|
|
27371
27425
|
this.dbPromise = this.openDB();
|
|
@@ -27573,6 +27627,40 @@ class IndexedDBService {
|
|
|
27573
27627
|
req.onerror = () => reject(req.error);
|
|
27574
27628
|
});
|
|
27575
27629
|
}
|
|
27630
|
+
/**
|
|
27631
|
+
* Returns the last (highest-ts) Meta event record at/before `cutoffTs`.
|
|
27632
|
+
*
|
|
27633
|
+
* rrweb replays expect the stream to begin with:
|
|
27634
|
+
* - Meta
|
|
27635
|
+
* - FullSnapshot
|
|
27636
|
+
*
|
|
27637
|
+
* We persist packed events (plus a small wrapper) so we detect Meta via `record.event.eventType`.
|
|
27638
|
+
*/
|
|
27639
|
+
async getLastRrwebMetaBefore(tabId, cutoffTs) {
|
|
27640
|
+
const db = await this.dbPromise;
|
|
27641
|
+
const range = IDBKeyRange.bound([tabId, 0], [tabId, cutoffTs]);
|
|
27642
|
+
return new Promise((resolve, reject) => {
|
|
27643
|
+
const tx = db.transaction(rrwebEventsStore, 'readonly');
|
|
27644
|
+
const idx = tx.objectStore(rrwebEventsStore).index('tabId_ts');
|
|
27645
|
+
const req = idx.openCursor(range, 'prev');
|
|
27646
|
+
req.onsuccess = () => {
|
|
27647
|
+
var _a;
|
|
27648
|
+
const cursor = req.result;
|
|
27649
|
+
if (!cursor) {
|
|
27650
|
+
resolve(null);
|
|
27651
|
+
return;
|
|
27652
|
+
}
|
|
27653
|
+
const value = cursor.value;
|
|
27654
|
+
const eventType = (_a = value === null || value === void 0 ? void 0 : value.event) === null || _a === void 0 ? void 0 : _a.eventType;
|
|
27655
|
+
if (eventType === _rrweb_types__WEBPACK_IMPORTED_MODULE_0__.EventType.Meta) {
|
|
27656
|
+
resolve(value);
|
|
27657
|
+
return;
|
|
27658
|
+
}
|
|
27659
|
+
cursor.continue();
|
|
27660
|
+
};
|
|
27661
|
+
req.onerror = () => reject(req.error);
|
|
27662
|
+
});
|
|
27663
|
+
}
|
|
27576
27664
|
async getOtelSpansWindow(tabId, fromTs, toTs) {
|
|
27577
27665
|
const db = await this.dbPromise;
|
|
27578
27666
|
const range = IDBKeyRange.bound([tabId, fromTs], [tabId, toTs]);
|
|
@@ -27619,15 +27707,24 @@ class IndexedDBService {
|
|
|
27619
27707
|
}
|
|
27620
27708
|
/**
|
|
27621
27709
|
* Prune older data while keeping rrweb replayability:
|
|
27622
|
-
* - rrweb: keep the last FullSnapshot at/before cutoff as an "anchor"
|
|
27710
|
+
* - rrweb: keep the last Meta + FullSnapshot pair at/before cutoff as an "anchor"
|
|
27623
27711
|
* - spans: prune strictly by cutoff
|
|
27624
27712
|
*/
|
|
27625
27713
|
async pruneOlderThanWithRrwebSnapshotAnchor(tabId, cutoffTs) {
|
|
27626
27714
|
const db = await this.dbPromise;
|
|
27627
27715
|
const anchor = await this.getLastRrwebFullSnapshotBefore(tabId, cutoffTs);
|
|
27628
|
-
// rrweb: delete everything strictly older than the anchor
|
|
27716
|
+
// rrweb: delete everything strictly older than the anchor meta event (if any),
|
|
27717
|
+
// otherwise strictly older than the anchor snapshot (keep the anchor itself).
|
|
27718
|
+
//
|
|
27719
|
+
// This preserves rrweb's expected replay prefix:
|
|
27720
|
+
// Meta -> FullSnapshot
|
|
27721
|
+
const anchorMeta = anchor ? await this.getLastRrwebMetaBefore(tabId, anchor.ts) : null;
|
|
27629
27722
|
// spans: delete everything older than cutoffTs
|
|
27630
|
-
const rrwebCutoffTs = typeof (
|
|
27723
|
+
const rrwebCutoffTs = typeof (anchorMeta === null || anchorMeta === void 0 ? void 0 : anchorMeta.ts) === 'number'
|
|
27724
|
+
? Math.max(0, anchorMeta.ts - 1)
|
|
27725
|
+
: typeof (anchor === null || anchor === void 0 ? void 0 : anchor.ts) === 'number'
|
|
27726
|
+
? Math.max(0, anchor.ts - 1)
|
|
27727
|
+
: cutoffTs;
|
|
27631
27728
|
const rrwebRange = IDBKeyRange.bound([tabId, 0], [tabId, rrwebCutoffTs]);
|
|
27632
27729
|
const spansRange = IDBKeyRange.bound([tabId, 0], [tabId, cutoffTs]);
|
|
27633
27730
|
const pruneStore = (store, range) => new Promise((resolve, reject) => {
|
|
@@ -28265,6 +28362,7 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
|
|
|
28265
28362
|
return;
|
|
28266
28363
|
if (!payload.span)
|
|
28267
28364
|
return;
|
|
28365
|
+
console.log('error-span-appended', payload);
|
|
28268
28366
|
this._createExceptionSession(payload.span);
|
|
28269
28367
|
});
|
|
28270
28368
|
this._registerCrashBufferLifecycleHandlers();
|
|
@@ -28500,11 +28598,6 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
|
|
|
28500
28598
|
return null;
|
|
28501
28599
|
this._isFlushingBuffer = true;
|
|
28502
28600
|
try {
|
|
28503
|
-
// await this._crashBuffer.setAttrs({
|
|
28504
|
-
// sessionAttributes: this.sessionAttributes,
|
|
28505
|
-
// resourceAttributes: getNavigatorInfo(),
|
|
28506
|
-
// userAttributes: this._userAttributes
|
|
28507
|
-
// })
|
|
28508
28601
|
const snapshot = await this._crashBuffer.snapshot();
|
|
28509
28602
|
if (snapshot.rrwebEvents.length === 0 && snapshot.otelSpans.length === 0) {
|
|
28510
28603
|
return null;
|
|
@@ -28517,6 +28610,8 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
|
|
|
28517
28610
|
this._apiService.exportEvents(sessionId, { events }),
|
|
28518
28611
|
this._apiService.updateSessionAttributes(sessionId, {
|
|
28519
28612
|
name: this._getSessionName(),
|
|
28613
|
+
// startedAt: new Date(snapshot.rrwebEvents[0].ts).toISOString(),
|
|
28614
|
+
// stoppedAt: new Date().toISOString(),
|
|
28520
28615
|
sessionAttributes: this.sessionAttributes,
|
|
28521
28616
|
resourceAttributes: (0,_utils__WEBPACK_IMPORTED_MODULE_3__.getNavigatorInfo)(),
|
|
28522
28617
|
userAttributes: this._userAttributes || undefined
|
|
@@ -28701,6 +28796,9 @@ class SessionRecorder extends lib0_observable__WEBPACK_IMPORTED_MODULE_16__.Obse
|
|
|
28701
28796
|
async _createExceptionSession(span) {
|
|
28702
28797
|
try {
|
|
28703
28798
|
const session = await this._apiService.createErrorSession({ span });
|
|
28799
|
+
console.log('====================================');
|
|
28800
|
+
console.log(span);
|
|
28801
|
+
console.log('====================================');
|
|
28704
28802
|
if (session) {
|
|
28705
28803
|
void this._flushBuffer(session._id);
|
|
28706
28804
|
}
|
|
@@ -31091,12 +31189,14 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
31091
31189
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
31092
31190
|
/* harmony export */ SessionRecorderTraceIdRatioBasedSampler: () => (/* binding */ SessionRecorderTraceIdRatioBasedSampler)
|
|
31093
31191
|
/* harmony export */ });
|
|
31094
|
-
/* harmony import */ var
|
|
31095
|
-
/* harmony import */ var
|
|
31192
|
+
/* harmony import */ var _opentelemetry_api__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @opentelemetry/api */ "../../node_modules/@opentelemetry/api/build/esm/trace/spancontext-utils.js");
|
|
31193
|
+
/* harmony import */ var _opentelemetry_sdk_trace_base__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @opentelemetry/sdk-trace-base */ "../../node_modules/@opentelemetry/sdk-trace-base/build/esm/Sampler.js");
|
|
31194
|
+
/* harmony import */ var _opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @opentelemetry/semantic-conventions */ "../../node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js");
|
|
31096
31195
|
/* harmony import */ var _constants_constants_base__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants/constants.base */ "../session-recorder-common/dist/esm/constants/constants.base.js");
|
|
31097
31196
|
|
|
31098
31197
|
|
|
31099
31198
|
|
|
31199
|
+
|
|
31100
31200
|
var SessionRecorderTraceIdRatioBasedSampler = /** @class */ (function () {
|
|
31101
31201
|
function SessionRecorderTraceIdRatioBasedSampler(_ratio) {
|
|
31102
31202
|
if (_ratio === void 0) { _ratio = 0; }
|
|
@@ -31104,20 +31204,25 @@ var SessionRecorderTraceIdRatioBasedSampler = /** @class */ (function () {
|
|
|
31104
31204
|
this._ratio = this._normalize(_ratio);
|
|
31105
31205
|
this._upperBound = Math.floor(this._ratio * 0xffffffff);
|
|
31106
31206
|
}
|
|
31107
|
-
SessionRecorderTraceIdRatioBasedSampler.prototype.shouldSample = function (context, traceId) {
|
|
31207
|
+
SessionRecorderTraceIdRatioBasedSampler.prototype.shouldSample = function (context, traceId, spanName, spanKind, attributes, links) {
|
|
31208
|
+
if (attributes[_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_1__.ATTR_EXCEPTION_MESSAGE] || attributes[_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_1__.ATTR_EXCEPTION_STACKTRACE] || attributes[_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_1__.ATTR_EXCEPTION_TYPE]) {
|
|
31209
|
+
return {
|
|
31210
|
+
decision: _opentelemetry_sdk_trace_base__WEBPACK_IMPORTED_MODULE_2__.SamplingDecision.RECORD_AND_SAMPLED,
|
|
31211
|
+
};
|
|
31212
|
+
}
|
|
31108
31213
|
if (traceId.startsWith(_constants_constants_base__WEBPACK_IMPORTED_MODULE_0__.MULTIPLAYER_TRACE_DEBUG_PREFIX)
|
|
31109
31214
|
|| traceId.startsWith(_constants_constants_base__WEBPACK_IMPORTED_MODULE_0__.MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX)
|
|
31110
|
-
|
|
31215
|
+
|| traceId.startsWith(_constants_constants_base__WEBPACK_IMPORTED_MODULE_0__.MULTIPLAYER_TRACE_SESSION_CACHE_PREFIX)
|
|
31111
31216
|
// || traceId.startsWith(MULTIPLAYER_TRACE_CONTINUOUS_SESSION_CACHE_PREFIX)
|
|
31112
31217
|
) {
|
|
31113
31218
|
return {
|
|
31114
|
-
decision:
|
|
31219
|
+
decision: _opentelemetry_sdk_trace_base__WEBPACK_IMPORTED_MODULE_2__.SamplingDecision.RECORD_AND_SAMPLED,
|
|
31115
31220
|
};
|
|
31116
31221
|
}
|
|
31117
|
-
var decision =
|
|
31118
|
-
if ((0,
|
|
31222
|
+
var decision = _opentelemetry_sdk_trace_base__WEBPACK_IMPORTED_MODULE_2__.SamplingDecision.NOT_RECORD;
|
|
31223
|
+
if ((0,_opentelemetry_api__WEBPACK_IMPORTED_MODULE_3__.isValidTraceId)(traceId)
|
|
31119
31224
|
&& this._accumulate(traceId) < this._upperBound) {
|
|
31120
|
-
decision =
|
|
31225
|
+
decision = _opentelemetry_sdk_trace_base__WEBPACK_IMPORTED_MODULE_2__.SamplingDecision.RECORD_AND_SAMPLED;
|
|
31121
31226
|
}
|
|
31122
31227
|
return { decision: decision };
|
|
31123
31228
|
};
|
|
@@ -31374,46 +31479,48 @@ var SessionRecorderBrowserTraceExporter = /** @class */ (function () {
|
|
|
31374
31479
|
this.postMessageTargetOrigin = postMessageTargetOrigin;
|
|
31375
31480
|
this.exporter = this._createExporter();
|
|
31376
31481
|
}
|
|
31377
|
-
SessionRecorderBrowserTraceExporter.prototype.
|
|
31482
|
+
SessionRecorderBrowserTraceExporter.prototype._export = function (spans, resultCallback) {
|
|
31378
31483
|
var _this = this;
|
|
31379
|
-
// Filter spans to only include those with Multiplayer trace prefixes
|
|
31380
|
-
var filteredSpans = spans.filter(function (span) {
|
|
31381
|
-
var traceId = span.spanContext().traceId;
|
|
31382
|
-
return (traceId.startsWith(_constants_constants_base__WEBPACK_IMPORTED_MODULE_0__.MULTIPLAYER_TRACE_DEBUG_PREFIX) ||
|
|
31383
|
-
traceId.startsWith(_constants_constants_base__WEBPACK_IMPORTED_MODULE_0__.MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX));
|
|
31384
|
-
});
|
|
31385
31484
|
// Only proceed if there are filtered spans
|
|
31386
|
-
if (
|
|
31485
|
+
if (spans.length === 0) {
|
|
31387
31486
|
resultCallback({ code: 0 });
|
|
31388
31487
|
return;
|
|
31389
31488
|
}
|
|
31390
31489
|
if (this.usePostMessage) {
|
|
31391
|
-
this.exportViaPostMessage(
|
|
31490
|
+
this.exportViaPostMessage(spans, resultCallback);
|
|
31392
31491
|
return;
|
|
31393
31492
|
}
|
|
31394
|
-
this.exporter.export(
|
|
31493
|
+
this.exporter.export(spans, function (result) {
|
|
31395
31494
|
if (result.code === 0) {
|
|
31396
31495
|
resultCallback(result);
|
|
31397
31496
|
}
|
|
31398
31497
|
else if (_this.config.usePostMessageFallback) {
|
|
31399
31498
|
_this.usePostMessage = true;
|
|
31400
|
-
_this.exportViaPostMessage(
|
|
31499
|
+
_this.exportViaPostMessage(spans, resultCallback);
|
|
31401
31500
|
}
|
|
31402
31501
|
else {
|
|
31403
31502
|
resultCallback(result);
|
|
31404
31503
|
}
|
|
31405
31504
|
});
|
|
31406
31505
|
};
|
|
31407
|
-
SessionRecorderBrowserTraceExporter.prototype.
|
|
31408
|
-
|
|
31506
|
+
SessionRecorderBrowserTraceExporter.prototype.export = function (spans, resultCallback) {
|
|
31507
|
+
// Filter spans to only include those with Multiplayer trace prefixes
|
|
31508
|
+
var filteredSpans = spans.filter(function (span) {
|
|
31509
|
+
var traceId = span.spanContext().traceId;
|
|
31510
|
+
return (traceId.startsWith(_constants_constants_base__WEBPACK_IMPORTED_MODULE_0__.MULTIPLAYER_TRACE_DEBUG_PREFIX) ||
|
|
31511
|
+
traceId.startsWith(_constants_constants_base__WEBPACK_IMPORTED_MODULE_0__.MULTIPLAYER_TRACE_CONTINUOUS_DEBUG_PREFIX));
|
|
31512
|
+
});
|
|
31513
|
+
this._export(filteredSpans, resultCallback);
|
|
31409
31514
|
};
|
|
31410
|
-
SessionRecorderBrowserTraceExporter.prototype.exportBuffer = function (spans) {
|
|
31411
|
-
var
|
|
31412
|
-
|
|
31413
|
-
|
|
31414
|
-
resolve(result);
|
|
31415
|
-
});
|
|
31515
|
+
SessionRecorderBrowserTraceExporter.prototype.exportBuffer = function (spans, resultCallback) {
|
|
31516
|
+
var filteredSpans = spans.filter(function (span) {
|
|
31517
|
+
var traceId = span.spanContext().traceId;
|
|
31518
|
+
return traceId.startsWith(_constants_constants_base__WEBPACK_IMPORTED_MODULE_0__.MULTIPLAYER_TRACE_SESSION_CACHE_PREFIX);
|
|
31416
31519
|
});
|
|
31520
|
+
this._export(filteredSpans, resultCallback);
|
|
31521
|
+
};
|
|
31522
|
+
SessionRecorderBrowserTraceExporter.prototype.shutdown = function () {
|
|
31523
|
+
return this.exporter.shutdown();
|
|
31417
31524
|
};
|
|
31418
31525
|
SessionRecorderBrowserTraceExporter.prototype.exportViaPostMessage = function (spans, resultCallback) {
|
|
31419
31526
|
var _this = this;
|
|
@@ -31434,8 +31541,42 @@ var SessionRecorderBrowserTraceExporter = /** @class */ (function () {
|
|
|
31434
31541
|
}
|
|
31435
31542
|
};
|
|
31436
31543
|
SessionRecorderBrowserTraceExporter.prototype.serializeSpan = function (span) {
|
|
31544
|
+
var _a;
|
|
31437
31545
|
var spanContext = span.spanContext();
|
|
31438
|
-
|
|
31546
|
+
var instrumentationScope =
|
|
31547
|
+
// OTel SDK (modern)
|
|
31548
|
+
span.instrumentationScope ||
|
|
31549
|
+
// Older SDKs
|
|
31550
|
+
span.instrumentationLibrary || { name: 'unknown', version: undefined, schemaUrl: undefined };
|
|
31551
|
+
var normalizedScope = {
|
|
31552
|
+
name: (instrumentationScope === null || instrumentationScope === void 0 ? void 0 : instrumentationScope.name) || 'unknown',
|
|
31553
|
+
version: instrumentationScope === null || instrumentationScope === void 0 ? void 0 : instrumentationScope.version,
|
|
31554
|
+
schemaUrl: instrumentationScope === null || instrumentationScope === void 0 ? void 0 : instrumentationScope.schemaUrl,
|
|
31555
|
+
};
|
|
31556
|
+
return {
|
|
31557
|
+
_spanContext: spanContext,
|
|
31558
|
+
traceId: spanContext.traceId,
|
|
31559
|
+
spanId: spanContext.spanId,
|
|
31560
|
+
name: span.name,
|
|
31561
|
+
kind: span.kind,
|
|
31562
|
+
links: span.links,
|
|
31563
|
+
ended: span.ended,
|
|
31564
|
+
events: span.events,
|
|
31565
|
+
status: span.status,
|
|
31566
|
+
endTime: span.endTime,
|
|
31567
|
+
startTime: span.startTime,
|
|
31568
|
+
duration: span.duration,
|
|
31569
|
+
attributes: span.attributes,
|
|
31570
|
+
parentSpanId: (_a = span.parentSpanContext) === null || _a === void 0 ? void 0 : _a.spanId,
|
|
31571
|
+
droppedAttributesCount: span.droppedAttributesCount,
|
|
31572
|
+
droppedEventsCount: span.droppedEventsCount,
|
|
31573
|
+
droppedLinksCount: span.droppedLinksCount,
|
|
31574
|
+
instrumentationScope: normalizedScope,
|
|
31575
|
+
resource: {
|
|
31576
|
+
attributes: span.resource.attributes,
|
|
31577
|
+
asyncAttributesPending: span.resource.asyncAttributesPending,
|
|
31578
|
+
},
|
|
31579
|
+
};
|
|
31439
31580
|
};
|
|
31440
31581
|
SessionRecorderBrowserTraceExporter.prototype._createExporter = function () {
|
|
31441
31582
|
return new _opentelemetry_exporter_trace_otlp_http__WEBPACK_IMPORTED_MODULE_1__.OTLPTraceExporter({
|
|
@@ -31566,26 +31707,82 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
31566
31707
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
31567
31708
|
/* harmony export */ captureException: () => (/* binding */ captureException)
|
|
31568
31709
|
/* harmony export */ });
|
|
31569
|
-
/* harmony import */ var _opentelemetry_api__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! @opentelemetry/api */ "../../node_modules/@opentelemetry/api/build/esm/trace-api.js");
|
|
31570
31710
|
/* harmony import */ var _opentelemetry_api__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! @opentelemetry/api */ "../../node_modules/@opentelemetry/api/build/esm/context-api.js");
|
|
31571
|
-
/* harmony import */ var _opentelemetry_api__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @opentelemetry/api */ "../../node_modules/@opentelemetry/api/build/esm/trace
|
|
31711
|
+
/* harmony import */ var _opentelemetry_api__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! @opentelemetry/api */ "../../node_modules/@opentelemetry/api/build/esm/trace-api.js");
|
|
31712
|
+
/* harmony import */ var _opentelemetry_api__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! @opentelemetry/api */ "../../node_modules/@opentelemetry/api/build/esm/trace/status.js");
|
|
31713
|
+
/* harmony import */ var _opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! @opentelemetry/semantic-conventions */ "../../node_modules/@opentelemetry/semantic-conventions/build/esm/stable_attributes.js");
|
|
31714
|
+
/* harmony import */ var _set_resource_attributes__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./set-resource-attributes */ "../session-recorder-common/dist/esm/sdk/set-resource-attributes.js");
|
|
31715
|
+
var __assign = (undefined && undefined.__assign) || function () {
|
|
31716
|
+
__assign = Object.assign || function(t) {
|
|
31717
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
31718
|
+
s = arguments[i];
|
|
31719
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
31720
|
+
t[p] = s[p];
|
|
31721
|
+
}
|
|
31722
|
+
return t;
|
|
31723
|
+
};
|
|
31724
|
+
return __assign.apply(this, arguments);
|
|
31725
|
+
};
|
|
31726
|
+
var __read = (undefined && undefined.__read) || function (o, n) {
|
|
31727
|
+
var m = typeof Symbol === "function" && o[Symbol.iterator];
|
|
31728
|
+
if (!m) return o;
|
|
31729
|
+
var i = m.call(o), r, ar = [], e;
|
|
31730
|
+
try {
|
|
31731
|
+
while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
|
|
31732
|
+
}
|
|
31733
|
+
catch (error) { e = { error: error }; }
|
|
31734
|
+
finally {
|
|
31735
|
+
try {
|
|
31736
|
+
if (r && !r.done && (m = i["return"])) m.call(i);
|
|
31737
|
+
}
|
|
31738
|
+
finally { if (e) throw e.error; }
|
|
31739
|
+
}
|
|
31740
|
+
return ar;
|
|
31741
|
+
};
|
|
31742
|
+
|
|
31743
|
+
|
|
31572
31744
|
|
|
31573
31745
|
/**
|
|
31574
31746
|
* @description Add error to current span
|
|
31575
31747
|
* @param {Error} error
|
|
31576
31748
|
* @returns {void}
|
|
31577
31749
|
*/
|
|
31578
|
-
var captureException = function (error) {
|
|
31579
|
-
|
|
31580
|
-
|
|
31581
|
-
var span = _opentelemetry_api__WEBPACK_IMPORTED_MODULE_0__.trace.getSpan(_opentelemetry_api__WEBPACK_IMPORTED_MODULE_1__.context.active());
|
|
31582
|
-
if (!span)
|
|
31750
|
+
var captureException = function (error, errorInfo) {
|
|
31751
|
+
var _a, _b;
|
|
31752
|
+
if (!error) {
|
|
31583
31753
|
return;
|
|
31754
|
+
}
|
|
31755
|
+
var activeContext = _opentelemetry_api__WEBPACK_IMPORTED_MODULE_1__.context.active();
|
|
31756
|
+
var span = _opentelemetry_api__WEBPACK_IMPORTED_MODULE_2__.trace.getSpan(activeContext);
|
|
31757
|
+
var isNewSpan = false;
|
|
31758
|
+
if (!span || !span.isRecording()) {
|
|
31759
|
+
span = _opentelemetry_api__WEBPACK_IMPORTED_MODULE_2__.trace.getTracer('exception').startSpan(error.name || 'Error', {
|
|
31760
|
+
attributes: __assign((_a = {}, _a[_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_3__.ATTR_EXCEPTION_MESSAGE] = error.message, _a[_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_3__.ATTR_EXCEPTION_STACKTRACE] = error.stack, _a[_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_3__.ATTR_EXCEPTION_TYPE] = error.name, _a), (0,_set_resource_attributes__WEBPACK_IMPORTED_MODULE_0__.getResourceAttributes)()),
|
|
31761
|
+
});
|
|
31762
|
+
_opentelemetry_api__WEBPACK_IMPORTED_MODULE_2__.trace.setSpan(activeContext, span);
|
|
31763
|
+
isNewSpan = true;
|
|
31764
|
+
}
|
|
31765
|
+
else {
|
|
31766
|
+
span.setAttributes((_b = {},
|
|
31767
|
+
_b[_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_3__.ATTR_EXCEPTION_MESSAGE] = error.message,
|
|
31768
|
+
_b[_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_3__.ATTR_EXCEPTION_STACKTRACE] = error.stack,
|
|
31769
|
+
_b[_opentelemetry_semantic_conventions__WEBPACK_IMPORTED_MODULE_3__.ATTR_EXCEPTION_TYPE] = error.name,
|
|
31770
|
+
_b));
|
|
31771
|
+
}
|
|
31772
|
+
if (errorInfo) {
|
|
31773
|
+
Object.entries(errorInfo).forEach(function (_a) {
|
|
31774
|
+
var _b = __read(_a, 2), key = _b[0], value = _b[1];
|
|
31775
|
+
span.setAttribute("error_info.".concat(key), value);
|
|
31776
|
+
});
|
|
31777
|
+
}
|
|
31584
31778
|
span.recordException(error);
|
|
31585
31779
|
span.setStatus({
|
|
31586
|
-
code:
|
|
31780
|
+
code: _opentelemetry_api__WEBPACK_IMPORTED_MODULE_4__.SpanStatusCode.ERROR,
|
|
31587
31781
|
message: error.message,
|
|
31588
31782
|
});
|
|
31783
|
+
if (isNewSpan) {
|
|
31784
|
+
span.end();
|
|
31785
|
+
}
|
|
31589
31786
|
};
|
|
31590
31787
|
//# sourceMappingURL=capture-exception.js.map
|
|
31591
31788
|
|
|
@@ -31630,6 +31827,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
31630
31827
|
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
31631
31828
|
/* harmony export */ captureException: () => (/* reexport safe */ _capture_exception__WEBPACK_IMPORTED_MODULE_4__.captureException),
|
|
31632
31829
|
/* harmony export */ getIdGenerator: () => (/* reexport safe */ _id_generator__WEBPACK_IMPORTED_MODULE_3__.getIdGenerator),
|
|
31830
|
+
/* harmony export */ getResourceAttributes: () => (/* reexport safe */ _set_resource_attributes__WEBPACK_IMPORTED_MODULE_7__.getResourceAttributes),
|
|
31633
31831
|
/* harmony export */ isGzip: () => (/* reexport safe */ _is_gzip__WEBPACK_IMPORTED_MODULE_2__.isGzip),
|
|
31634
31832
|
/* harmony export */ mask: () => (/* reexport safe */ _mask__WEBPACK_IMPORTED_MODULE_0__["default"]),
|
|
31635
31833
|
/* harmony export */ saveContinuousSession: () => (/* reexport safe */ _save_continuous_deb_session__WEBPACK_IMPORTED_MODULE_6__.saveContinuousSession),
|
|
@@ -31644,6 +31842,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
31644
31842
|
/* harmony export */ setHttpResponseBody: () => (/* reexport safe */ _set_attribute__WEBPACK_IMPORTED_MODULE_5__.setHttpResponseBody),
|
|
31645
31843
|
/* harmony export */ setHttpResponseHeaders: () => (/* reexport safe */ _set_attribute__WEBPACK_IMPORTED_MODULE_5__.setHttpResponseHeaders),
|
|
31646
31844
|
/* harmony export */ setMessageBody: () => (/* reexport safe */ _set_attribute__WEBPACK_IMPORTED_MODULE_5__.setMessageBody),
|
|
31845
|
+
/* harmony export */ setResourceAttributes: () => (/* reexport safe */ _set_resource_attributes__WEBPACK_IMPORTED_MODULE_7__.setResourceAttributes),
|
|
31647
31846
|
/* harmony export */ setRpcRequestMessage: () => (/* reexport safe */ _set_attribute__WEBPACK_IMPORTED_MODULE_5__.setRpcRequestMessage),
|
|
31648
31847
|
/* harmony export */ setRpcResponseMessage: () => (/* reexport safe */ _set_attribute__WEBPACK_IMPORTED_MODULE_5__.setRpcResponseMessage)
|
|
31649
31848
|
/* harmony export */ });
|
|
@@ -31654,6 +31853,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
31654
31853
|
/* harmony import */ var _capture_exception__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./capture-exception */ "../session-recorder-common/dist/esm/sdk/capture-exception.js");
|
|
31655
31854
|
/* harmony import */ var _set_attribute__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./set-attribute */ "../session-recorder-common/dist/esm/sdk/set-attribute.js");
|
|
31656
31855
|
/* harmony import */ var _save_continuous_deb_session__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./save-continuous-deb-session */ "../session-recorder-common/dist/esm/sdk/save-continuous-deb-session.js");
|
|
31856
|
+
/* harmony import */ var _set_resource_attributes__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./set-resource-attributes */ "../session-recorder-common/dist/esm/sdk/set-resource-attributes.js");
|
|
31857
|
+
|
|
31657
31858
|
|
|
31658
31859
|
|
|
31659
31860
|
|
|
@@ -32142,6 +32343,29 @@ var setGrpcResponseMessage = function (body, options) {
|
|
|
32142
32343
|
|
|
32143
32344
|
/***/ }),
|
|
32144
32345
|
|
|
32346
|
+
/***/ "../session-recorder-common/dist/esm/sdk/set-resource-attributes.js":
|
|
32347
|
+
/*!**************************************************************************!*\
|
|
32348
|
+
!*** ../session-recorder-common/dist/esm/sdk/set-resource-attributes.js ***!
|
|
32349
|
+
\**************************************************************************/
|
|
32350
|
+
/***/ ((__unused_webpack_module, __webpack_exports__, __webpack_require__) => {
|
|
32351
|
+
|
|
32352
|
+
"use strict";
|
|
32353
|
+
__webpack_require__.r(__webpack_exports__);
|
|
32354
|
+
/* harmony export */ __webpack_require__.d(__webpack_exports__, {
|
|
32355
|
+
/* harmony export */ getResourceAttributes: () => (/* binding */ getResourceAttributes),
|
|
32356
|
+
/* harmony export */ setResourceAttributes: () => (/* binding */ setResourceAttributes)
|
|
32357
|
+
/* harmony export */ });
|
|
32358
|
+
var resourceAttributes = {};
|
|
32359
|
+
var setResourceAttributes = function (attributes) {
|
|
32360
|
+
resourceAttributes = attributes;
|
|
32361
|
+
};
|
|
32362
|
+
var getResourceAttributes = function () {
|
|
32363
|
+
return resourceAttributes;
|
|
32364
|
+
};
|
|
32365
|
+
//# sourceMappingURL=set-resource-attributes.js.map
|
|
32366
|
+
|
|
32367
|
+
/***/ }),
|
|
32368
|
+
|
|
32145
32369
|
/***/ "../session-recorder-common/dist/esm/type/crash-buffer.js":
|
|
32146
32370
|
/*!****************************************************************!*\
|
|
32147
32371
|
!*** ../session-recorder-common/dist/esm/type/crash-buffer.js ***!
|