@maple-dev/browser 0.12.0 → 0.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/README.md +23 -9
- package/dist/console-iNhlufZV.mjs +183 -0
- package/dist/{deferred-BDKAWiKZ.mjs → deferred-BcyLmMyV.mjs} +32 -5
- package/dist/index.d.mts +12 -5
- package/dist/index.mjs +1 -1
- package/dist/react.d.mts +7 -4
- package/dist/react.mjs +43 -5
- package/dist/replay-session-DFPRE4Ee.mjs +906 -0
- package/dist/{sink-DbEuphC-.mjs → sink-Ji0J42ul.mjs} +848 -188
- package/dist/{src-DfU4Cnb1.mjs → src-B3Giah8c.mjs} +545 -171
- package/package.json +19 -16
- package/dist/console-Bkd3hBGp.mjs +0 -73
- package/dist/replay-session-Cg3U1RS0.mjs +0 -596
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@maple-dev/browser",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.14.0",
|
|
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",
|
|
@@ -43,19 +43,20 @@
|
|
|
43
43
|
"build": "tsdown",
|
|
44
44
|
"typecheck": "tsrs --noEmit",
|
|
45
45
|
"test": "vitest run",
|
|
46
|
+
"test:e2e": "tsdown && vitest run -c vitest.e2e.config.ts",
|
|
46
47
|
"size": "bun scripts/size.ts"
|
|
47
48
|
},
|
|
48
49
|
"dependencies": {
|
|
49
|
-
"@opentelemetry/api": "^1.
|
|
50
|
-
"@opentelemetry/
|
|
51
|
-
"@opentelemetry/instrumentation
|
|
52
|
-
"@opentelemetry/instrumentation-
|
|
53
|
-
"@opentelemetry/
|
|
54
|
-
"@opentelemetry/
|
|
55
|
-
"@opentelemetry/
|
|
56
|
-
"@opentelemetry/sdk-
|
|
57
|
-
"@opentelemetry/sdk-trace
|
|
58
|
-
"@opentelemetry/semantic-conventions": "^1.
|
|
50
|
+
"@opentelemetry/api": "^1.10.0",
|
|
51
|
+
"@opentelemetry/core": "^3.0.0",
|
|
52
|
+
"@opentelemetry/instrumentation": "^0.300.0",
|
|
53
|
+
"@opentelemetry/instrumentation-fetch": "^0.300.0",
|
|
54
|
+
"@opentelemetry/instrumentation-xml-http-request": "^0.300.0",
|
|
55
|
+
"@opentelemetry/otlp-transformer": "^0.300.0",
|
|
56
|
+
"@opentelemetry/resources": "^3.0.0",
|
|
57
|
+
"@opentelemetry/sdk-logs": "^3.0.0",
|
|
58
|
+
"@opentelemetry/sdk-trace": "^3.0.0",
|
|
59
|
+
"@opentelemetry/semantic-conventions": "^1.44.0",
|
|
59
60
|
"rrweb": "^2.0.0-alpha.18",
|
|
60
61
|
"web-vitals": "^6.2.2"
|
|
61
62
|
},
|
|
@@ -64,13 +65,15 @@
|
|
|
64
65
|
"@maple/sdk-core": "0.1.0",
|
|
65
66
|
"@types/react": "^19.3.0",
|
|
66
67
|
"@types/react-dom": "^19.3.0",
|
|
67
|
-
"@vitest/browser-playwright": "^5.0
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"react
|
|
68
|
+
"@vitest/browser-playwright": "^5.1.0",
|
|
69
|
+
"fast-check": "^4.10.2",
|
|
70
|
+
"playwright": "^1.64.1",
|
|
71
|
+
"react": "^19.3.1",
|
|
72
|
+
"react-dom": "^19.3.1",
|
|
71
73
|
"tsdown": "^0.23.0",
|
|
72
74
|
"typescript": "^7.0.2",
|
|
73
|
-
"
|
|
75
|
+
"vite": "^8.3.5",
|
|
76
|
+
"vitest": "^5.1.0"
|
|
74
77
|
},
|
|
75
78
|
"peerDependencies": {
|
|
76
79
|
"react": ">=18"
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
import { M as safeEmit } from "./sink-DbEuphC-.mjs";
|
|
2
|
-
//#region ../browser-session/src/replay/capture/console.ts
|
|
3
|
-
const LEVELS = [
|
|
4
|
-
"log",
|
|
5
|
-
"info",
|
|
6
|
-
"warn",
|
|
7
|
-
"error",
|
|
8
|
-
"debug"
|
|
9
|
-
];
|
|
10
|
-
const MAX_MESSAGE = 2e3;
|
|
11
|
-
/** No array logged into a 2,000-character message needs more elements than this. */
|
|
12
|
-
const MAX_ARRAY_ELEMENTS = 100;
|
|
13
|
-
/**
|
|
14
|
-
* Capture `console.*` calls as session events. Wraps each method, emits a
|
|
15
|
-
* distilled record, then forwards to the original so the host app's console
|
|
16
|
-
* behaves normally. Never throws into the call site.
|
|
17
|
-
*/
|
|
18
|
-
function installConsoleCapture(emit) {
|
|
19
|
-
const original = {};
|
|
20
|
-
const wrappers = {};
|
|
21
|
-
let active = true;
|
|
22
|
-
for (const level of LEVELS) {
|
|
23
|
-
const orig = console[level];
|
|
24
|
-
original[level] = orig;
|
|
25
|
-
const wrapper = (...args) => {
|
|
26
|
-
if (active) safeEmit(emit, {
|
|
27
|
-
type: "console",
|
|
28
|
-
level,
|
|
29
|
-
message: formatArgs(args)
|
|
30
|
-
});
|
|
31
|
-
orig.apply(console, args);
|
|
32
|
-
};
|
|
33
|
-
wrappers[level] = wrapper;
|
|
34
|
-
console[level] = wrapper;
|
|
35
|
-
}
|
|
36
|
-
return () => {
|
|
37
|
-
active = false;
|
|
38
|
-
for (const level of LEVELS) {
|
|
39
|
-
const orig = original[level];
|
|
40
|
-
if (orig && console[level] === wrappers[level]) console[level] = orig;
|
|
41
|
-
}
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
function formatArgs(args) {
|
|
45
|
-
const text = args.map((a) => {
|
|
46
|
-
if (typeof a === "string") return a;
|
|
47
|
-
if (a instanceof Error) return `${a.name}: ${a.message}`;
|
|
48
|
-
try {
|
|
49
|
-
return boundedStringify(a, MAX_MESSAGE) ?? String(a);
|
|
50
|
-
} catch {
|
|
51
|
-
return String(a);
|
|
52
|
-
}
|
|
53
|
-
}).join(" ");
|
|
54
|
-
return text.length > MAX_MESSAGE ? `${text.slice(0, MAX_MESSAGE)}…` : text;
|
|
55
|
-
}
|
|
56
|
-
/**
|
|
57
|
-
* `JSON.stringify` that stops descending once roughly `budget` characters have
|
|
58
|
-
* been produced. The message is cut to `MAX_MESSAGE` anyway, and serializing a
|
|
59
|
-
* whole store object on every `console.log` first was a main-thread cost paid
|
|
60
|
-
* on the host app's hot path. A replacer returning `undefined` skips a value
|
|
61
|
-
* without visiting its children, so the walk is bounded by the budget.
|
|
62
|
-
*/
|
|
63
|
-
function boundedStringify(value, budget) {
|
|
64
|
-
let used = 0;
|
|
65
|
-
return JSON.stringify(value, (key, nested) => {
|
|
66
|
-
if (used > budget) return void 0;
|
|
67
|
-
used += key.length + (typeof nested === "string" ? nested.length : 4);
|
|
68
|
-
if (Array.isArray(nested) && nested.length > MAX_ARRAY_ELEMENTS) return nested.slice(0, MAX_ARRAY_ELEMENTS);
|
|
69
|
-
return nested;
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
//#endregion
|
|
73
|
-
export { installConsoleCapture as t };
|