@maple-dev/browser 0.11.0 → 0.11.1
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.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { A as selectorOf, G as scrubUrl, K as mayUseStorage, L as consentAllowedSince, O as sdkHint, R as consentRevokedAt, S as ingestHeaders, V as onConsentChange, l as onSessionEvent, z as hasConsent } from "./sink-DbEuphC-.mjs";
|
|
2
|
-
import { _ as severityOf, a as detachLogSink, c as resourceAttributes, d as OtlpExporter, f as newestFirstOnExit, g as Severity, h as onErrorRecorded, i as attachLogSink, l as SDK_NAME, m as claimPageSignal, n as navigationSpanAt, o as emitLog, p as attachSpanStash, r as onDocumentPageload, s as liveMapleTracer, u as SDK_VERSION } from "./src-
|
|
2
|
+
import { _ as severityOf, a as detachLogSink, c as resourceAttributes, d as OtlpExporter, f as newestFirstOnExit, g as Severity, h as onErrorRecorded, i as attachLogSink, l as SDK_NAME, m as claimPageSignal, n as navigationSpanAt, o as emitLog, p as attachSpanStash, r as onDocumentPageload, s as liveMapleTracer, u as SDK_VERSION } from "./src-CCfykEMo.mjs";
|
|
3
3
|
import { t as installConsoleCapture } from "./console-Bkd3hBGp.mjs";
|
|
4
4
|
import { ROOT_CONTEXT, TraceFlags, context, trace } from "@opentelemetry/api";
|
|
5
5
|
import { JsonLogsSerializer, JsonTraceSerializer } from "@opentelemetry/otlp-transformer";
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as MapleBrowser } from "./src-
|
|
1
|
+
import { t as MapleBrowser } from "./src-CCfykEMo.mjs";
|
|
2
2
|
export { MapleBrowser };
|
package/dist/react.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { D as reserveKeepalive, F as withStartedTraceId, G as scrubUrl, K as mayUseStorage, M as safeEmit, N as activeTraceId, R as consentRevokedAt, T as postSessionMeta, W as isJsonObject, d as startEventSink, g as nextChunkSeq, h as markReplayTriggered, j as BLOCK_SELECTOR, k as warnDropped, m as markActivity, n as getObservedTraceIds, o as startSessionLifecycle, r as publishSessionSink, w as postSessionBlob, x as gzip } from "./sink-DbEuphC-.mjs";
|
|
2
|
-
import { v as PENDING_CHUNK_KEY, y as clearPendingChunk } from "./src-
|
|
2
|
+
import { v as PENDING_CHUNK_KEY, y as clearPendingChunk } from "./src-CCfykEMo.mjs";
|
|
3
3
|
import { t as installConsoleCapture } from "./console-Bkd3hBGp.mjs";
|
|
4
4
|
import { record } from "rrweb";
|
|
5
5
|
//#region ../browser-session/src/replay/capture/network.ts
|
|
@@ -923,7 +923,7 @@ function newestFirstOnExit(inner, serializer, olderReserve = 0) {
|
|
|
923
923
|
}
|
|
924
924
|
//#endregion
|
|
925
925
|
//#region src/version.ts
|
|
926
|
-
const SDK_VERSION = "0.
|
|
926
|
+
const SDK_VERSION = "0.11.0";
|
|
927
927
|
/** The `x-maple-sdk` value this build sends. */
|
|
928
928
|
const SDK_NAME = "maple-browser";
|
|
929
929
|
//#endregion
|
|
@@ -1060,15 +1060,34 @@ function setupTracing(config) {
|
|
|
1060
1060
|
const onExit = () => {
|
|
1061
1061
|
provider.forceFlush().catch(() => {});
|
|
1062
1062
|
};
|
|
1063
|
+
let connectionLosses = 0;
|
|
1064
|
+
let lastLossReason = "";
|
|
1065
|
+
const lossesAtStart = /* @__PURE__ */ new WeakMap();
|
|
1066
|
+
const noteLost = (reason) => {
|
|
1067
|
+
connectionLosses += 1;
|
|
1068
|
+
lastLossReason = reason;
|
|
1069
|
+
};
|
|
1070
|
+
const connectionLost = (span) => {
|
|
1071
|
+
if (typeof navigator !== "undefined" && navigator.onLine === false) return "offline";
|
|
1072
|
+
if (typeof document !== "undefined" && document.visibilityState === "hidden") return "page_hidden";
|
|
1073
|
+
const atStart = lossesAtStart.get(span);
|
|
1074
|
+
return atStart !== void 0 && atStart !== connectionLosses ? lastLossReason : void 0;
|
|
1075
|
+
};
|
|
1076
|
+
const onOffline = () => noteLost("offline");
|
|
1063
1077
|
const onVisibilityChange = () => {
|
|
1064
|
-
if (document.visibilityState
|
|
1078
|
+
if (document.visibilityState !== "hidden") return;
|
|
1079
|
+
noteLost("page_hidden");
|
|
1080
|
+
onExit();
|
|
1065
1081
|
};
|
|
1066
1082
|
const settledRequests = /* @__PURE__ */ new Map();
|
|
1067
|
-
const onPageHide = () =>
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1083
|
+
const onPageHide = () => {
|
|
1084
|
+
noteLost("page_unload");
|
|
1085
|
+
flushUnloading(() => {
|
|
1086
|
+
for (const [span, endTime] of settledRequests) if (span.isRecording()) span.end(endTime);
|
|
1087
|
+
settledRequests.clear();
|
|
1088
|
+
onExit();
|
|
1089
|
+
});
|
|
1090
|
+
};
|
|
1072
1091
|
const noteSettled = (span) => {
|
|
1073
1092
|
for (const settled of settledRequests.keys()) if (!settled.isRecording()) settledRequests.delete(settled);
|
|
1074
1093
|
settledRequests.set(span, Date.now());
|
|
@@ -1077,6 +1096,7 @@ function setupTracing(config) {
|
|
|
1077
1096
|
if (canListen) {
|
|
1078
1097
|
document.addEventListener("visibilitychange", onVisibilityChange);
|
|
1079
1098
|
window.addEventListener("pagehide", onPageHide);
|
|
1099
|
+
window.addEventListener("offline", onOffline);
|
|
1080
1100
|
}
|
|
1081
1101
|
const requestOptions = {
|
|
1082
1102
|
ignoreUrls: [new RegExp(`${escapeRegExp(config.endpoint)}/v1/`)],
|
|
@@ -1085,17 +1105,24 @@ function setupTracing(config) {
|
|
|
1085
1105
|
const headers = config.captureHeaders;
|
|
1086
1106
|
const instrumentations = [...config.tracingInstrumentFetch ? [new FetchInstrumentation({
|
|
1087
1107
|
...requestOptions,
|
|
1108
|
+
requestHook: (span) => {
|
|
1109
|
+
lossesAtStart.set(span, connectionLosses);
|
|
1110
|
+
},
|
|
1088
1111
|
applyCustomAttributesOnSpan: (span, request, result) => {
|
|
1089
1112
|
noteSettled(span);
|
|
1090
1113
|
const sent = request instanceof Request ? request.headers : new Headers(request.headers);
|
|
1091
1114
|
setHeaderAttributes(span, "request", headers.request, (name) => sent.get(name));
|
|
1092
1115
|
if (result instanceof Response) setHeaderAttributes(span, "response", headers.response, (name) => result.headers.get(name));
|
|
1093
1116
|
else if (result instanceof Error && (isTimeout(result, request.signal) || result.name !== "AbortError" && !request.signal?.aborted)) {
|
|
1094
|
-
span
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1117
|
+
const lost = connectionLost(span);
|
|
1118
|
+
if (lost !== void 0) span.setAttribute("maple.connection_lost", lost);
|
|
1119
|
+
else {
|
|
1120
|
+
span.setStatus({
|
|
1121
|
+
code: SpanStatusCode.ERROR,
|
|
1122
|
+
message: result.message
|
|
1123
|
+
});
|
|
1124
|
+
span.setAttribute("error.type", result.name);
|
|
1125
|
+
}
|
|
1099
1126
|
}
|
|
1100
1127
|
}
|
|
1101
1128
|
})] : [], ...config.tracingInstrumentXhr ? [new XMLHttpRequestInstrumentation({
|
|
@@ -1115,6 +1142,7 @@ function setupTracing(config) {
|
|
|
1115
1142
|
if (canListen) {
|
|
1116
1143
|
document.removeEventListener("visibilitychange", onVisibilityChange);
|
|
1117
1144
|
window.removeEventListener("pagehide", onPageHide);
|
|
1145
|
+
window.removeEventListener("offline", onOffline);
|
|
1118
1146
|
}
|
|
1119
1147
|
unregisterInstrumentations?.();
|
|
1120
1148
|
if (mapleProvider === provider) mapleProvider = void 0;
|
|
@@ -1547,7 +1575,7 @@ function init(rawConfig) {
|
|
|
1547
1575
|
if (config.tracingEnabled && config.tracingCaptureErrors && !stopErrorCapture) stopErrorCapture = setupErrorCapture();
|
|
1548
1576
|
if (!deferredPending) {
|
|
1549
1577
|
setLogIdentity(() => activeConfig?.identity?.id);
|
|
1550
|
-
deferredPending = import("./deferred-
|
|
1578
|
+
deferredPending = import("./deferred-B8pFPgZ_.mjs").then(({ startDeferred }) => {
|
|
1551
1579
|
stopDeferred = startDeferred(config);
|
|
1552
1580
|
}).catch(() => {});
|
|
1553
1581
|
}
|
|
@@ -1581,7 +1609,7 @@ function init(rawConfig) {
|
|
|
1581
1609
|
runtime = next;
|
|
1582
1610
|
const ownGeneration = ++generation;
|
|
1583
1611
|
const stale = () => stopped || !hasConsent() || generation !== ownGeneration || runtime !== next;
|
|
1584
|
-
next.replayPending = import("./replay-session-
|
|
1612
|
+
next.replayPending = import("./replay-session-D0zjvZIV.mjs").then(({ startReplaySession }) => {
|
|
1585
1613
|
if (stale()) return;
|
|
1586
1614
|
next.replay = startReplaySession({
|
|
1587
1615
|
...shared,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maple-dev/browser",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.1",
|
|
4
4
|
"description": "Maple browser SDK — OpenTelemetry tracing and rrweb session replay in one package. Every span and replay event shares a session id for trace↔replay correlation.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"maple",
|