@maple-dev/browser 0.10.0 → 0.10.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.
package/README.md
CHANGED
|
@@ -68,8 +68,9 @@ fingerprint to one contentless issue that buries the real ones. Add
|
|
|
68
68
|
|
|
69
69
|
### Failed HTTP requests
|
|
70
70
|
|
|
71
|
-
`
|
|
72
|
-
|
|
71
|
+
`fetch`/XHR responses with a 4xx or 5xx status are errors, typed by status, as the HTTP semantic
|
|
72
|
+
conventions say for client spans. Narrow that with `errors: { captureHttpStatus: [[500, 599]] }`.
|
|
73
|
+
A network failure is always an error.
|
|
73
74
|
|
|
74
75
|
### Breadcrumbs
|
|
75
76
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { E as selectorOf, F as scrubUrl, l as onSessionEvent, w as sdkHint, x as ingestHeaders } from "./sink-BOR9_z4b.mjs";
|
|
2
|
-
import { _ as consentRevokedAt, a as detachLogSink, c as resourceAttributes, d as attachSpanStash, f as claimPageSignal, g as consentAllowedSince, h as severityOf, i as attachLogSink, l as SDK_NAME, m as Severity, n as navigationSpanAt, o as emitLog, p as onErrorRecorded, r as onDocumentPageload, s as liveMapleTracer, u as SDK_VERSION, v as hasConsent, y as onConsentChange } from "./src-
|
|
2
|
+
import { _ as consentRevokedAt, a as detachLogSink, c as resourceAttributes, d as attachSpanStash, f as claimPageSignal, g as consentAllowedSince, h as severityOf, i as attachLogSink, l as SDK_NAME, m as Severity, n as navigationSpanAt, o as emitLog, p as onErrorRecorded, r as onDocumentPageload, s as liveMapleTracer, u as SDK_VERSION, v as hasConsent, y as onConsentChange } from "./src-D4e1o0x4.mjs";
|
|
3
3
|
import { t as installConsoleCapture } from "./console-BrjBnOiX.mjs";
|
|
4
4
|
import { ROOT_CONTEXT, TraceFlags, context, trace } from "@opentelemetry/api";
|
|
5
5
|
import { resourceFromAttributes } from "@opentelemetry/resources";
|
package/dist/index.d.mts
CHANGED
|
@@ -57,8 +57,9 @@ interface ErrorFilterOptions {
|
|
|
57
57
|
readonly beforeCapture?: (error: Error, hint: ErrorFilterHint) => boolean;
|
|
58
58
|
/**
|
|
59
59
|
* HTTP response statuses that make a client request span an error (and so an
|
|
60
|
-
* issue)
|
|
61
|
-
*
|
|
60
|
+
* issue). Default `[[400, 599]]`, as the HTTP semantic conventions say for
|
|
61
|
+
* client spans; narrow it, e.g. `[[500, 599]]`, to count fewer. A network
|
|
62
|
+
* failure is always an error.
|
|
62
63
|
*/
|
|
63
64
|
readonly captureHttpStatus?: ReadonlyArray<HttpStatusRange>;
|
|
64
65
|
/**
|
package/dist/index.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as MapleBrowser } from "./src-
|
|
1
|
+
import { t as MapleBrowser } from "./src-D4e1o0x4.mjs";
|
|
2
2
|
export { MapleBrowser };
|
package/dist/react.mjs
CHANGED
|
@@ -542,6 +542,8 @@ function resolveHeaderCapture(raw) {
|
|
|
542
542
|
}
|
|
543
543
|
//#endregion
|
|
544
544
|
//#region ../sdk-core/src/http-status.ts
|
|
545
|
+
/** The statuses the HTTP semantic conventions make a client span Error for: every 4xx and 5xx. */
|
|
546
|
+
const DEFAULT_ERROR_STATUS = [[400, 599]];
|
|
545
547
|
const inStatusRanges = (status, ranges) => ranges.some((range) => typeof range === "number" ? range === status : status >= range[0] && status <= range[1]);
|
|
546
548
|
/** The status on a span's attributes, current or pre-1.23 semconv key. */
|
|
547
549
|
function responseStatus(read) {
|
|
@@ -550,17 +552,12 @@ function responseStatus(read) {
|
|
|
550
552
|
if (typeof value === "string" && /^\d{3}$/.test(value)) return Number(value);
|
|
551
553
|
}
|
|
552
554
|
/**
|
|
553
|
-
* The `error.type`
|
|
554
|
-
*
|
|
555
|
-
*
|
|
555
|
+
* The `error.type` for a counted status or a network failure (`TypeError`,
|
|
556
|
+
* `timeout`), per the HTTP semantic conventions. No message: `error.message` is
|
|
557
|
+
* deprecated, and the status code already says what went wrong.
|
|
556
558
|
*/
|
|
557
|
-
function
|
|
558
|
-
|
|
559
|
-
const url = String(read("url.full") ?? read("http.url") ?? "").replace(/[?#].*$/, "");
|
|
560
|
-
return {
|
|
561
|
-
"error.type": String(status),
|
|
562
|
-
"error.message": `${String(method)} ${url} -> ${status}`
|
|
563
|
-
};
|
|
559
|
+
function httpErrorType(status) {
|
|
560
|
+
return { "error.type": String(status) };
|
|
564
561
|
}
|
|
565
562
|
//#endregion
|
|
566
563
|
//#region ../sdk-core/src/log-record.ts
|
|
@@ -842,7 +839,7 @@ function withStatus(span, status, attributes) {
|
|
|
842
839
|
var HttpStatusExporter = class {
|
|
843
840
|
inner;
|
|
844
841
|
captureStatus;
|
|
845
|
-
constructor(inner, captureStatus =
|
|
842
|
+
constructor(inner, captureStatus = DEFAULT_ERROR_STATUS) {
|
|
846
843
|
this.inner = inner;
|
|
847
844
|
this.captureStatus = captureStatus;
|
|
848
845
|
}
|
|
@@ -853,14 +850,9 @@ var HttpStatusExporter = class {
|
|
|
853
850
|
if (span.events.some((event) => event.name === "exception")) return span;
|
|
854
851
|
return withStatus(span, { code: SpanStatusCode.ERROR }, {
|
|
855
852
|
...span.attributes,
|
|
856
|
-
...
|
|
853
|
+
...httpErrorType(status)
|
|
857
854
|
});
|
|
858
855
|
}
|
|
859
|
-
const errorType = span.attributes["error.type"];
|
|
860
|
-
if (span.kind === SpanKind.CLIENT && span.status.code === SpanStatusCode.ERROR && typeof errorType === "string" && !HTTP_STATUS.test(errorType) && span.attributes["error.message"] === void 0 && !span.events.some((event) => event.name === "exception")) return withStatus(span, span.status, {
|
|
861
|
-
...span.attributes,
|
|
862
|
-
"error.message": httpStatusError(read, errorType)["error.message"]
|
|
863
|
-
});
|
|
864
856
|
if (!isStatusOnlyError(span)) return span;
|
|
865
857
|
const { "error.type": _errorType, ...attributes } = span.attributes;
|
|
866
858
|
return withStatus(span, { code: SpanStatusCode.UNSET }, attributes);
|
|
@@ -914,7 +906,7 @@ var OfflineSpanExporter = class {
|
|
|
914
906
|
};
|
|
915
907
|
//#endregion
|
|
916
908
|
//#region src/version.ts
|
|
917
|
-
const SDK_VERSION = "0.
|
|
909
|
+
const SDK_VERSION = "0.10.1";
|
|
918
910
|
/** The `x-maple-sdk` value this build sends. */
|
|
919
911
|
const SDK_NAME = "maple-browser";
|
|
920
912
|
//#endregion
|
|
@@ -1082,7 +1074,7 @@ function setupTracing(config) {
|
|
|
1082
1074
|
const sent = request instanceof Request ? request.headers : new Headers(request.headers);
|
|
1083
1075
|
setHeaderAttributes(span, "request", headers.request, (name) => sent.get(name));
|
|
1084
1076
|
if (result instanceof Response) setHeaderAttributes(span, "response", headers.response, (name) => result.headers.get(name));
|
|
1085
|
-
else if (result instanceof Error && result.name !== "AbortError" && !request.signal?.aborted) {
|
|
1077
|
+
else if (result instanceof Error && (isTimeout(result, request.signal) || result.name !== "AbortError" && !request.signal?.aborted)) {
|
|
1086
1078
|
span.setStatus({
|
|
1087
1079
|
code: SpanStatusCode.ERROR,
|
|
1088
1080
|
message: result.message
|
|
@@ -1118,6 +1110,11 @@ function setupTracing(config) {
|
|
|
1118
1110
|
}
|
|
1119
1111
|
};
|
|
1120
1112
|
}
|
|
1113
|
+
/** `AbortSignal.timeout()` aborts with, and rejects the fetch with, a `TimeoutError` DOMException. */
|
|
1114
|
+
function isTimeout(error, signal) {
|
|
1115
|
+
const reason = signal?.reason;
|
|
1116
|
+
return error.name === "TimeoutError" || reason instanceof DOMException && reason.name === "TimeoutError";
|
|
1117
|
+
}
|
|
1121
1118
|
function escapeRegExp(value) {
|
|
1122
1119
|
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
1123
1120
|
}
|
|
@@ -1533,7 +1530,7 @@ function init(rawConfig) {
|
|
|
1533
1530
|
if (config.tracingEnabled && config.tracingCaptureErrors && !stopErrorCapture) stopErrorCapture = setupErrorCapture();
|
|
1534
1531
|
if (!deferredPending) {
|
|
1535
1532
|
setLogIdentity(() => activeConfig?.identity?.id);
|
|
1536
|
-
deferredPending = import("./deferred-
|
|
1533
|
+
deferredPending = import("./deferred-BDp5NC7U.mjs").then(({ startDeferred }) => {
|
|
1537
1534
|
stopDeferred = startDeferred(config);
|
|
1538
1535
|
}).catch(() => {});
|
|
1539
1536
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maple-dev/browser",
|
|
3
|
-
"version": "0.10.
|
|
3
|
+
"version": "0.10.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",
|
|
@@ -82,4 +82,4 @@
|
|
|
82
82
|
"optional": true
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
}
|
|
85
|
+
}
|