@maple-dev/browser 0.9.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 +86 -3
- package/dist/console-BrjBnOiX.mjs +73 -0
- package/dist/deferred-BDp5NC7U.mjs +723 -0
- package/dist/index.d.mts +165 -14
- package/dist/index.mjs +1 -854
- package/dist/react.d.mts +88 -0
- package/dist/react.mjs +130 -0
- package/dist/replay-session-DdVYdHc_.mjs +527 -0
- package/dist/{sink-DHPiMgU0.mjs → sink-BOR9_z4b.mjs} +293 -104
- package/dist/src-D4e1o0x4.mjs +1719 -0
- package/package.json +32 -10
- package/dist/replay-session-gSlAYwqV.mjs +0 -360
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import "@opentelemetry/api";
|
|
1
2
|
//#region ../browser-session/src/identity/identity.d.ts
|
|
2
3
|
/**
|
|
3
4
|
* Who the current visitor is.
|
|
@@ -34,11 +35,132 @@ type TrackProps = Readonly<Record<string, unknown>>;
|
|
|
34
35
|
/** A Maple hosting region. Each is a separate instance with its own ingest keys. */
|
|
35
36
|
type MapleRegion = "us" | "eu";
|
|
36
37
|
//#endregion
|
|
38
|
+
//#region ../sdk-core/src/http-status.d.ts
|
|
39
|
+
/** A status code, or an inclusive `[from, to]` range. */
|
|
40
|
+
type HttpStatusRange = number | readonly [number, number];
|
|
41
|
+
//#endregion
|
|
42
|
+
//#region ../sdk-core/src/error-filters.d.ts
|
|
43
|
+
type ErrorSource = "captureException" | "window.onerror" | "unhandledrejection";
|
|
44
|
+
interface ErrorFilterHint {
|
|
45
|
+
readonly source: ErrorSource;
|
|
46
|
+
/** What was thrown, before it was normalized into an `Error`. */
|
|
47
|
+
readonly originalError: unknown;
|
|
48
|
+
}
|
|
49
|
+
interface ErrorFilterOptions {
|
|
50
|
+
/** Drop errors whose `Name: message` contains a string or matches a RegExp. */
|
|
51
|
+
readonly ignore?: ReadonlyArray<string | RegExp>;
|
|
52
|
+
/** Report only errors whose top frame's script URL matches one of these. Errors with no frames are kept. */
|
|
53
|
+
readonly allowUrls?: ReadonlyArray<string | RegExp>;
|
|
54
|
+
/** Drop errors whose top frame's script URL matches one of these. */
|
|
55
|
+
readonly denyUrls?: ReadonlyArray<string | RegExp>;
|
|
56
|
+
/** Return `false` to drop the error. Runs after the lists; if it throws, the error is kept. */
|
|
57
|
+
readonly beforeCapture?: (error: Error, hint: ErrorFilterHint) => boolean;
|
|
58
|
+
/**
|
|
59
|
+
* HTTP response statuses that make a client request span an error (and so an
|
|
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.
|
|
63
|
+
*/
|
|
64
|
+
readonly captureHttpStatus?: ReadonlyArray<HttpStatusRange>;
|
|
65
|
+
/**
|
|
66
|
+
* Drop errors thrown from browser extensions and the benign `ResizeObserver
|
|
67
|
+
* loop` notices. Default true.
|
|
68
|
+
*/
|
|
69
|
+
readonly defaultFilters?: boolean;
|
|
70
|
+
}
|
|
71
|
+
//#endregion
|
|
72
|
+
//#region ../sdk-core/src/http-headers.d.ts
|
|
73
|
+
interface HeaderCaptureOptions {
|
|
74
|
+
readonly request?: ReadonlyArray<string>;
|
|
75
|
+
readonly response?: ReadonlyArray<string>;
|
|
76
|
+
}
|
|
77
|
+
//#endregion
|
|
78
|
+
//#region ../sdk-core/src/log-record.d.ts
|
|
79
|
+
type LogAttributeValue = string | number | boolean;
|
|
80
|
+
//#endregion
|
|
81
|
+
//#region ../sdk-core/src/options.d.ts
|
|
82
|
+
type ConsoleLevel = "debug" | "log" | "info" | "warn" | "error";
|
|
83
|
+
interface TracingSignalOptions {
|
|
84
|
+
/**
|
|
85
|
+
* Fraction of sessions whose traces are exported, 0–1. Default 1. Decided
|
|
86
|
+
* once per session, so a sampled session keeps every trace. Error spans are
|
|
87
|
+
* always exported.
|
|
88
|
+
*/
|
|
89
|
+
readonly sampleRate?: number;
|
|
90
|
+
/**
|
|
91
|
+
* Request and response headers to record on HTTP client spans, as
|
|
92
|
+
* `http.request.header.<name>` / `http.response.header.<name>`. Default none.
|
|
93
|
+
* Credential headers (`authorization`, `cookie`, `set-cookie`, ...) are never recorded.
|
|
94
|
+
*/
|
|
95
|
+
readonly captureHeaders?: HeaderCaptureOptions;
|
|
96
|
+
/** Span main-thread frames of 100ms or more. Default false. */
|
|
97
|
+
readonly longFrames?: boolean;
|
|
98
|
+
/** Span interactions of 200ms or more, split into input delay, processing and presentation. Default false. */
|
|
99
|
+
readonly slowInteractions?: boolean;
|
|
100
|
+
}
|
|
101
|
+
interface ReplayOptions {
|
|
102
|
+
/** Record session replays. Default true. */
|
|
103
|
+
readonly enabled?: boolean;
|
|
104
|
+
/** Fraction of sessions to record, 0–1. Default 1. */
|
|
105
|
+
readonly sampleRate?: number;
|
|
106
|
+
/**
|
|
107
|
+
* Fraction of the sessions not recorded that keep the last minute in memory,
|
|
108
|
+
* and upload it and record the rest of the session only if an error happens.
|
|
109
|
+
* 0–1, default 0.
|
|
110
|
+
*/
|
|
111
|
+
readonly onErrorSampleRate?: number;
|
|
112
|
+
/**
|
|
113
|
+
* Record `<canvas>` content at this many frames per second. Off by default,
|
|
114
|
+
* and never with `maskAllText`: canvas pixels can hold text.
|
|
115
|
+
*/
|
|
116
|
+
readonly canvasFps?: number;
|
|
117
|
+
/**
|
|
118
|
+
* Keep text bodies on the replay's network events for these full URLs, cut to
|
|
119
|
+
* `maxLength` characters (at most and by default 1,000). Nothing with
|
|
120
|
+
* `maskAllText`; request bodies only with `maskAllInputs` off.
|
|
121
|
+
*/
|
|
122
|
+
readonly networkBodies?: {
|
|
123
|
+
readonly urls: ReadonlyArray<string | RegExp>;
|
|
124
|
+
readonly maxLength?: number;
|
|
125
|
+
};
|
|
126
|
+
}
|
|
127
|
+
/** The signal options shared verbatim by `MapleBrowser.init` and the Effect client presets. */
|
|
128
|
+
interface SignalOptions {
|
|
129
|
+
readonly tracing?: TracingSignalOptions;
|
|
130
|
+
/** Which captured errors to drop, and which HTTP statuses count as errors. */
|
|
131
|
+
readonly errors?: ErrorFilterOptions;
|
|
132
|
+
/** Report Core Web Vitals as `browser.web_vital` log events. Default true. */
|
|
133
|
+
readonly webVitals?: boolean;
|
|
134
|
+
/** Keep the last clicks, inputs, navigations and console lines, and export them with the next error. Default true. */
|
|
135
|
+
readonly breadcrumbs?: boolean;
|
|
136
|
+
readonly logs?: {
|
|
137
|
+
/** Console levels exported as logs as they happen, e.g. `["warn", "error"]`. Default none. */
|
|
138
|
+
readonly captureConsole?: ReadonlyArray<ConsoleLevel>;
|
|
139
|
+
};
|
|
140
|
+
readonly reporting?: {
|
|
141
|
+
/** Content Security Policy violations as `maple.browser.csp_violation` WARN logs. Default true. */
|
|
142
|
+
readonly csp?: boolean;
|
|
143
|
+
/** Browser deprecation and intervention reports as `maple.browser.report` WARN logs. Default false. */
|
|
144
|
+
readonly browserReports?: boolean;
|
|
145
|
+
};
|
|
146
|
+
readonly transport?: {
|
|
147
|
+
/**
|
|
148
|
+
* Keep batches that could not be sent in IndexedDB for up to 24 hours and
|
|
149
|
+
* send them once the browser is back online or on the next page load. Default false.
|
|
150
|
+
*/
|
|
151
|
+
readonly offline?: boolean;
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
//#endregion
|
|
37
155
|
//#region src/config.d.ts
|
|
38
|
-
/** Public configuration for `MapleBrowser.init`. */
|
|
39
|
-
interface MapleBrowserConfig {
|
|
40
|
-
/**
|
|
41
|
-
|
|
156
|
+
/** Public configuration for `MapleBrowser.init`. The signal groups are shared with the Effect SDK. */
|
|
157
|
+
interface MapleBrowserConfig extends SignalOptions {
|
|
158
|
+
/**
|
|
159
|
+
* Public ingest key (`maple_pk_...`), sent as `Authorization: Bearer …` and
|
|
160
|
+
* nothing else. Leave it unset when a proxy at `endpoint` adds auth: tracing
|
|
161
|
+
* and replay still run, sending without the header.
|
|
162
|
+
*/
|
|
163
|
+
readonly ingestKey?: string;
|
|
42
164
|
/** Service name reported on traces and stored on replay sessions. */
|
|
43
165
|
readonly serviceName: string;
|
|
44
166
|
/**
|
|
@@ -67,7 +189,7 @@ interface MapleBrowserConfig {
|
|
|
67
189
|
readonly userId?: string | null | undefined;
|
|
68
190
|
/** End-user identity attached to sessions and browser spans. */
|
|
69
191
|
readonly user?: MapleIdentity | undefined;
|
|
70
|
-
readonly tracing?: {
|
|
192
|
+
readonly tracing?: TracingSignalOptions & {
|
|
71
193
|
/** Default true. */
|
|
72
194
|
readonly enabled?: boolean;
|
|
73
195
|
/**
|
|
@@ -77,6 +199,11 @@ interface MapleBrowserConfig {
|
|
|
77
199
|
* sink, and disabling this avoids redundant duplicate network spans.
|
|
78
200
|
*/
|
|
79
201
|
readonly instrumentFetch?: boolean;
|
|
202
|
+
/**
|
|
203
|
+
* Auto-instrument `XMLHttpRequest` (axios and older clients) the same way.
|
|
204
|
+
* Default true. Turn it off for the same reason as `instrumentFetch`.
|
|
205
|
+
*/
|
|
206
|
+
readonly instrumentXhr?: boolean;
|
|
80
207
|
/**
|
|
81
208
|
* Capture uncaught errors and unhandled promise rejections as error
|
|
82
209
|
* spans. Default true. Turn off only when another tracker already owns
|
|
@@ -91,12 +218,7 @@ interface MapleBrowserConfig {
|
|
|
91
218
|
*/
|
|
92
219
|
readonly propagateTraceHeaderCorsUrls?: ReadonlyArray<string | RegExp>;
|
|
93
220
|
};
|
|
94
|
-
readonly replay?:
|
|
95
|
-
/** Default true. */
|
|
96
|
-
readonly enabled?: boolean;
|
|
97
|
-
/** Fraction of sessions to record, 0–1. Default 1. */
|
|
98
|
-
readonly sampleRate?: number;
|
|
99
|
-
};
|
|
221
|
+
readonly replay?: ReplayOptions;
|
|
100
222
|
readonly privacy?: {
|
|
101
223
|
/** Mask all `<input>` values. Default true. */
|
|
102
224
|
readonly maskAllInputs?: boolean;
|
|
@@ -157,9 +279,24 @@ interface MapleBrowserHandle {
|
|
|
157
279
|
readonly shutdown: () => Promise<void>;
|
|
158
280
|
}
|
|
159
281
|
//#endregion
|
|
282
|
+
//#region src/logger.d.ts
|
|
283
|
+
type LogMethod = (message: string, attributes?: Readonly<Record<string, LogAttributeValue>>) => void;
|
|
284
|
+
interface MapleLogger {
|
|
285
|
+
readonly debug: LogMethod;
|
|
286
|
+
readonly info: LogMethod;
|
|
287
|
+
readonly warn: LogMethod;
|
|
288
|
+
readonly error: LogMethod;
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
//#region src/navigation.d.ts
|
|
292
|
+
interface TracedOptions {
|
|
293
|
+
/** Return `false` for throws that aren't errors, like redirects or not-found. Default: every throw is an error. */
|
|
294
|
+
readonly isFailure?: ((error: unknown) => boolean) | undefined;
|
|
295
|
+
}
|
|
296
|
+
//#endregion
|
|
160
297
|
//#region src/index.d.ts
|
|
161
298
|
/** The `MapleBrowser` namespace object. */
|
|
162
|
-
interface MapleBrowserApi {
|
|
299
|
+
export interface MapleBrowserApi {
|
|
163
300
|
init: (config: MapleBrowserConfig) => MapleBrowserHandle;
|
|
164
301
|
/**
|
|
165
302
|
* Attach, replace, or clear the end-user identity on the active session.
|
|
@@ -185,6 +322,20 @@ interface MapleBrowserApi {
|
|
|
185
322
|
captureException: (error: unknown, options?: CaptureExceptionOptions) => void;
|
|
186
323
|
/** Grant or revoke consent when `privacy.requireConsent` is on. */
|
|
187
324
|
setConsent: (granted: boolean) => void;
|
|
325
|
+
/** Call when a route change starts, with the new path. The first call in a page is the page load. */
|
|
326
|
+
startNavigation: (path: string) => void;
|
|
327
|
+
/** Call when the new route is ready, with its route pattern (`/projects/:id`), not the URL. */
|
|
328
|
+
endNavigation: (route?: string) => void;
|
|
329
|
+
/**
|
|
330
|
+
* Run data loading, like a route loader, in a span under the current navigation.
|
|
331
|
+
* Errors are recorded once and rethrown. Only requests started before `fn`'s first `await` nest under the span.
|
|
332
|
+
*/
|
|
333
|
+
traced: <T>(name: string, fn: () => Promise<T>, options?: TracedOptions) => Promise<T>;
|
|
334
|
+
/**
|
|
335
|
+
* Structured logs, exported as OpenTelemetry log records linked to the active
|
|
336
|
+
* span and the session. Safe before `init`: records queue until it runs.
|
|
337
|
+
*/
|
|
338
|
+
logger: MapleLogger;
|
|
188
339
|
}
|
|
189
340
|
/**
|
|
190
341
|
* Maple browser SDK. One call wires up OpenTelemetry tracing and rrweb session
|
|
@@ -204,6 +355,6 @@ interface MapleBrowserApi {
|
|
|
204
355
|
* MapleBrowser.track("checkout_completed", { plan: "pro", seats: 5 })
|
|
205
356
|
* ```
|
|
206
357
|
*/
|
|
207
|
-
declare const MapleBrowser: MapleBrowserApi;
|
|
358
|
+
export declare const MapleBrowser: MapleBrowserApi;
|
|
208
359
|
//#endregion
|
|
209
|
-
export {
|
|
360
|
+
export type { CaptureExceptionOptions, ConsoleLevel, ErrorFilterHint, ErrorFilterOptions, ErrorSource, HttpStatusRange, IdentifyInput, LogAttributeValue, MapleBrowserConfig, MapleBrowserHandle, MapleIdentity, MapleLogger, MapleRegion, ReplayOptions, SignalOptions, TracedOptions, TracingSignalOptions, TrackProps, TraitValue };
|