@libo11y/rum 0.4.0 → 0.6.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 +37 -20
- package/dist/actions/collector.js +2 -2
- package/dist/actions/naming.d.ts +1 -1
- package/dist/actions/naming.js +1 -1
- package/dist/actions/record.d.ts +1 -1
- package/dist/actions/record.js +1 -1
- package/dist/actions/settle.d.ts +1 -1
- package/dist/actions/settle.js +1 -1
- package/dist/bind.d.ts +1 -1
- package/dist/bootstrap/buffer.d.ts +1 -1
- package/dist/bootstrap/buffer.js +1 -1
- package/dist/bootstrap/replay.d.ts +1 -1
- package/dist/config/clamp.d.ts +2 -2
- package/dist/config/clamp.js +2 -2
- package/dist/config/remote.d.ts +30 -7
- package/dist/config/remote.js +78 -46
- package/dist/context-manager.d.ts +1 -1
- package/dist/context-manager.js +1 -1
- package/dist/contracts/binding.d.ts +4 -2
- package/dist/contracts/retention.d.ts +7 -3
- package/dist/contracts/runtime.d.ts +24 -14
- package/dist/contracts/session.d.ts +6 -1
- package/dist/contracts/summary.d.ts +2 -2
- package/dist/contracts/views.d.ts +3 -3
- package/dist/core-setup.d.ts +43 -8
- package/dist/core-setup.js +286 -71
- package/dist/core.d.ts +13 -9
- package/dist/core.js +6 -5
- package/dist/errors/breadcrumbs.d.ts +1 -1
- package/dist/errors/breadcrumbs.js +1 -1
- package/dist/errors/record.d.ts +1 -1
- package/dist/errors/record.js +1 -1
- package/dist/frustration/detect.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/internal.d.ts +15 -9
- package/dist/internal.js +4 -5
- package/dist/pending-spans.d.ts +1 -1
- package/dist/query.d.ts +1 -1
- package/dist/query.js +1 -1
- package/dist/retention/buffer.d.ts +9 -5
- package/dist/retention/buffer.js +41 -15
- package/dist/retention/exporters.d.ts +56 -2
- package/dist/retention/exporters.js +214 -0
- package/dist/session/manager.js +1 -1
- package/dist/session/sampling.js +1 -1
- package/dist/setup.d.ts +3 -1
- package/dist/setup.js +14 -6
- package/dist/span-processor.d.ts +3 -3
- package/dist/span-processor.js +2 -2
- package/dist/summary/accumulator.d.ts +7 -2
- package/dist/summary/accumulator.js +4 -2
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/dist/views/collector.js +8 -7
- package/dist/views/naming.d.ts +1 -1
- package/dist/views/naming.js +1 -1
- package/dist/views/tracker.d.ts +15 -6
- package/dist/views/tracker.js +10 -13
- package/dist/vitals/collector.js +2 -2
- package/dist/webext/config-storage.d.ts +15 -4
- package/dist/webext/config-storage.js +78 -27
- package/dist/webext/scope.d.ts +1 -1
- package/dist/webext/session-store.js +12 -2
- package/dist/webext/setup.d.ts +5 -2
- package/dist/webext/setup.js +29 -16
- package/dist/webext.d.ts +1 -1
- package/package.json +11 -8
package/dist/core.d.ts
CHANGED
|
@@ -4,15 +4,16 @@
|
|
|
4
4
|
* blocks it composes are here for the binding's own collectors and stores. Nothing reachable from
|
|
5
5
|
* here imports a browser-only module or reads a browser global at module evaluation (core.test.ts
|
|
6
6
|
* enforces both), so a bundler that does not tree-shake, such as Metro, pulls in nothing a phone
|
|
7
|
-
* cannot run. For libo11y packages only: it follows the package version
|
|
8
|
-
* promise
|
|
7
|
+
* cannot run. For libo11y packages only: it follows the package version and carries no
|
|
8
|
+
* compatibility promise.
|
|
9
9
|
*/
|
|
10
10
|
export { actionSpanName, actionSpanStart, recordInstantAction } from "./actions/record.ts";
|
|
11
11
|
export { createSettleTracker, type SettleOptions, type SettleTimers, type SettleTracker, } from "./actions/settle.ts";
|
|
12
12
|
export { ATTR_SESSION_ID, ATTR_USER_ID, summaryCountKey, summaryVitalKey } from "./attrs.ts";
|
|
13
|
+
export type { BootstrapEntry } from "./bootstrap/buffer.ts";
|
|
13
14
|
export { createBus } from "./bus.ts";
|
|
14
|
-
export { clampConfig, parseRemoteConfig, type RemoteConfigDocument, resolveLimits, } from "./config/clamp.ts";
|
|
15
|
-
export { CONFIG_STORAGE_KEY, createRemoteConfig, type RemoteConfig, type RemoteConfigConnection, remoteConfig, } from "./config/remote.ts";
|
|
15
|
+
export { clampConfig, parseRemoteConfig, type RemoteConfigDocument, type RemoteConfigLimits, type ResolvedLimits, resolveLimits, } from "./config/clamp.ts";
|
|
16
|
+
export { CONFIG_PINNED_STORAGE_KEY, CONFIG_STORAGE_KEY, createRemoteConfig, type RemoteConfig, type RemoteConfigClient, type RemoteConfigClientOptions, type RemoteConfigConnection, type RemoteConfigOpenOptions, type RemoteConfigOptions, type RemoteConfigStorage, type RemoteConfigTimers, remoteConfig, } from "./config/remote.ts";
|
|
16
17
|
export { rumContextManager } from "./context-manager.ts";
|
|
17
18
|
export type { RumBind, RumLifecycle, RumLifecycleHandlers, RumPlatformInfo, RumPlatformOptions, RumWrappers, } from "./contracts/binding.ts";
|
|
18
19
|
export type { RetentionBuffer, RetentionRouting } from "./contracts/retention.ts";
|
|
@@ -21,14 +22,15 @@ export type { SessionDecision, SessionEvent, SessionManager, SessionState, Sessi
|
|
|
21
22
|
export type { SummaryAccumulator, SummaryCountKey, SummaryView, VitalName } from "./contracts/summary.ts";
|
|
22
23
|
export type { ViewEvent, ViewStartOptions, ViewState, ViewTracker } from "./contracts/views.ts";
|
|
23
24
|
export { type ConfigCacheStorage, type RumCoreDeps, runtimeOf, SESSION_END_ELECTION_MILLIS, setupRumCore, } from "./core-setup.ts";
|
|
24
|
-
export { createBreadcrumbs } from "./errors/breadcrumbs.ts";
|
|
25
|
-
export { normalizeError } from "./errors/normalize.ts";
|
|
26
|
-
export { recordError, wasRecorded } from "./errors/record.ts";
|
|
27
|
-
export { createFrustrationDetector } from "./frustration/detect.ts";
|
|
25
|
+
export { type Breadcrumbs, createBreadcrumbs } from "./errors/breadcrumbs.ts";
|
|
26
|
+
export { type NormalizedError, normalizeError } from "./errors/normalize.ts";
|
|
27
|
+
export { type ErrorExtra, recordError, wasRecorded } from "./errors/record.ts";
|
|
28
|
+
export { createFrustrationDetector, type FrustrationDetector, type FrustrationDetectorOptions, } from "./frustration/detect.ts";
|
|
28
29
|
export { randomUuid } from "./ids.ts";
|
|
29
30
|
export type { AddErrorOptions, Rum, RumOptions } from "./options.ts";
|
|
31
|
+
export type { PendingSpans } from "./pending-spans.ts";
|
|
30
32
|
export { stripQuery } from "./query.ts";
|
|
31
|
-
export { createRetentionBuffer, RETENTION_QUEUE_DEFAULTS } from "./retention/buffer.ts";
|
|
33
|
+
export { createRetentionBuffer, RETENTION_QUEUE_DEFAULTS, type RetentionBufferOptions, } from "./retention/buffer.ts";
|
|
32
34
|
export { retainingLogExporter, retainingSpanExporter, withRetention } from "./retention/exporters.ts";
|
|
33
35
|
export { sessionsIn } from "./retention/sessions.ts";
|
|
34
36
|
export { createSessionManager, type SessionManagerOptions } from "./session/manager.ts";
|
|
@@ -37,6 +39,8 @@ export { parseSessionState, SESSION_STORAGE_KEY } from "./session/state.ts";
|
|
|
37
39
|
export { type ResolvedRum, resolveSettings } from "./settings.ts";
|
|
38
40
|
export { APP_LOAD_SPAN, type RumSpanProcessorOptions, rumSpanProcessor } from "./span-processor.ts";
|
|
39
41
|
export { createSummaryAccumulator, type SummaryOptions } from "./summary/accumulator.ts";
|
|
42
|
+
export { type MutationObserverCtor, type MutationObserverLike, VIEW_SPAN_CAP_MILLIS, type ViewsEnv, type ViewsOptions, viewsWith, } from "./views/collector.ts";
|
|
43
|
+
export type { HistoryHost } from "./views/history.ts";
|
|
40
44
|
export { afterNextPaint, type PaintHost } from "./views/paint.ts";
|
|
41
45
|
export { createViewTracker, type ViewTrackerOptions } from "./views/tracker.ts";
|
|
42
46
|
export { gatewayTransportOptions, withWireParams } from "./wire.ts";
|
package/dist/core.js
CHANGED
|
@@ -4,24 +4,24 @@
|
|
|
4
4
|
* blocks it composes are here for the binding's own collectors and stores. Nothing reachable from
|
|
5
5
|
* here imports a browser-only module or reads a browser global at module evaluation (core.test.ts
|
|
6
6
|
* enforces both), so a bundler that does not tree-shake, such as Metro, pulls in nothing a phone
|
|
7
|
-
* cannot run. For libo11y packages only: it follows the package version
|
|
8
|
-
* promise
|
|
7
|
+
* cannot run. For libo11y packages only: it follows the package version and carries no
|
|
8
|
+
* compatibility promise.
|
|
9
9
|
*/
|
|
10
10
|
export { actionSpanName, actionSpanStart, recordInstantAction } from "./actions/record.js";
|
|
11
11
|
export { createSettleTracker, } from "./actions/settle.js";
|
|
12
12
|
export { ATTR_SESSION_ID, ATTR_USER_ID, summaryCountKey, summaryVitalKey } from "./attrs.js";
|
|
13
13
|
export { createBus } from "./bus.js";
|
|
14
14
|
export { clampConfig, parseRemoteConfig, resolveLimits, } from "./config/clamp.js";
|
|
15
|
-
export { CONFIG_STORAGE_KEY, createRemoteConfig, remoteConfig, } from "./config/remote.js";
|
|
15
|
+
export { CONFIG_PINNED_STORAGE_KEY, CONFIG_STORAGE_KEY, createRemoteConfig, remoteConfig, } from "./config/remote.js";
|
|
16
16
|
export { rumContextManager } from "./context-manager.js";
|
|
17
17
|
export { runtimeOf, SESSION_END_ELECTION_MILLIS, setupRumCore, } from "./core-setup.js";
|
|
18
18
|
export { createBreadcrumbs } from "./errors/breadcrumbs.js";
|
|
19
19
|
export { normalizeError } from "./errors/normalize.js";
|
|
20
20
|
export { recordError, wasRecorded } from "./errors/record.js";
|
|
21
|
-
export { createFrustrationDetector } from "./frustration/detect.js";
|
|
21
|
+
export { createFrustrationDetector, } from "./frustration/detect.js";
|
|
22
22
|
export { randomUuid } from "./ids.js";
|
|
23
23
|
export { stripQuery } from "./query.js";
|
|
24
|
-
export { createRetentionBuffer, RETENTION_QUEUE_DEFAULTS } from "./retention/buffer.js";
|
|
24
|
+
export { createRetentionBuffer, RETENTION_QUEUE_DEFAULTS, } from "./retention/buffer.js";
|
|
25
25
|
export { retainingLogExporter, retainingSpanExporter, withRetention } from "./retention/exporters.js";
|
|
26
26
|
export { sessionsIn } from "./retention/sessions.js";
|
|
27
27
|
export { createSessionManager } from "./session/manager.js";
|
|
@@ -30,6 +30,7 @@ export { parseSessionState, SESSION_STORAGE_KEY } from "./session/state.js";
|
|
|
30
30
|
export { resolveSettings } from "./settings.js";
|
|
31
31
|
export { APP_LOAD_SPAN, rumSpanProcessor } from "./span-processor.js";
|
|
32
32
|
export { createSummaryAccumulator } from "./summary/accumulator.js";
|
|
33
|
+
export { VIEW_SPAN_CAP_MILLIS, viewsWith, } from "./views/collector.js";
|
|
33
34
|
export { afterNextPaint } from "./views/paint.js";
|
|
34
35
|
export { createViewTracker } from "./views/tracker.js";
|
|
35
36
|
export { gatewayTransportOptions, withWireParams } from "./wire.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The breadcrumb ring
|
|
2
|
+
* The breadcrumb ring: the last actions, view changes and requests, which every
|
|
3
3
|
* o11y.rum.error carries as o11y.rum.error.breadcrumbs, one per line, oldest first.
|
|
4
4
|
*/
|
|
5
5
|
/** The default number of breadcrumbs kept. */
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The breadcrumb ring
|
|
2
|
+
* The breadcrumb ring: the last actions, view changes and requests, which every
|
|
3
3
|
* o11y.rum.error carries as o11y.rum.error.breadcrumbs, one per line, oldest first.
|
|
4
4
|
*/
|
|
5
5
|
/** The default number of breadcrumbs kept. */
|
package/dist/errors/record.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The one path every error takes, from the errors() collector and from rum.addError: it is counted
|
|
3
3
|
* in the current view's summary for every consented session, published on the bus for frustration
|
|
4
|
-
* detection, retains the session
|
|
4
|
+
* detection, retains the session, and is emitted as o11y.rum.error (detail, so it is
|
|
5
5
|
* buffered for an unkept session) with the breadcrumbs, at most 100 events per view. An error while
|
|
6
6
|
* an action is open is emitted in the action's context.
|
|
7
7
|
*/
|
package/dist/errors/record.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* The one path every error takes, from the errors() collector and from rum.addError: it is counted
|
|
3
3
|
* in the current view's summary for every consented session, published on the bus for frustration
|
|
4
|
-
* detection, retains the session
|
|
4
|
+
* detection, retains the session, and is emitted as o11y.rum.error (detail, so it is
|
|
5
5
|
* buffered for an unkept session) with the breadcrumbs, at most 100 events per view. An error while
|
|
6
6
|
* an action is open is emitted in the action's context.
|
|
7
7
|
*/
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Frustration signals
|
|
2
|
+
* Frustration signals.
|
|
3
3
|
*
|
|
4
4
|
* Rage: rageClicks or more clicks on the same element selector within rageWindowMillis, reported
|
|
5
5
|
* once per burst, on the click that reaches the count. A burst ends when a click on that selector
|
package/dist/index.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
export { type ActionsOptions, actions } from "./actions/collector.ts";
|
|
5
5
|
export type { BootstrapEntry } from "./bootstrap/buffer.ts";
|
|
6
6
|
export type { RemoteConfigDocument, RemoteConfigLimits } from "./config/clamp.ts";
|
|
7
|
-
export { type RemoteConfig, type RemoteConfigClient, type RemoteConfigConnection, type RemoteConfigOpenOptions, type RemoteConfigOptions, type RemoteConfigTimers, remoteConfig, } from "./config/remote.ts";
|
|
7
|
+
export { type RemoteConfig, type RemoteConfigClient, type RemoteConfigConnection, type RemoteConfigOpenOptions, type RemoteConfigOptions, type RemoteConfigStorage, type RemoteConfigTimers, remoteConfig, } from "./config/remote.ts";
|
|
8
8
|
export type * from "./contracts/runtime.ts";
|
|
9
9
|
export type { SessionDecision, SessionEvent, SessionManager, SessionState, } from "./contracts/session.ts";
|
|
10
10
|
export type { SummaryAccumulator, SummaryCountKey, SummaryView, VitalName } from "./contracts/summary.ts";
|
package/dist/internal.d.ts
CHANGED
|
@@ -1,22 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @libo11y/rum/internal: what the RUM adapter packages and the browser fixtures compose. For
|
|
3
|
-
* libo11y packages only. It follows the package version
|
|
4
|
-
* no API report.
|
|
3
|
+
* libo11y packages only. It follows the package version and carries no compatibility promise.
|
|
5
4
|
*/
|
|
6
|
-
export { actionName, actionTarget, elementSelector } from "./actions/naming.ts";
|
|
5
|
+
export { actionName, actionTarget, type CssEscape, elementSelector } from "./actions/naming.ts";
|
|
7
6
|
export { ATTR_SESSION_ID, ATTR_USER_ID, summaryCountKey, summaryVitalKey } from "./attrs.ts";
|
|
8
|
-
export { afterLoadOn, BOOTSTRAP_KEY, bootstrapBuffer, installRumBootstrapOn, takeBootstrap, } from "./bootstrap/buffer.ts";
|
|
7
|
+
export { afterLoadOn, BOOTSTRAP_KEY, type BootstrapBuffer, type BootstrapClock, type BootstrapEntry, bootstrapBuffer, installRumBootstrapOn, type LoadHost, type RumBootstrapOptions, takeBootstrap, } from "./bootstrap/buffer.ts";
|
|
9
8
|
export { replayBootstrap } from "./bootstrap/replay.ts";
|
|
10
9
|
export { createBus } from "./bus.ts";
|
|
11
|
-
export { clampConfig, parseRemoteConfig, resolveLimits } from "./config/clamp.ts";
|
|
12
|
-
export { CONFIG_STORAGE_KEY, createRemoteConfig } from "./config/remote.ts";
|
|
10
|
+
export { clampConfig, parseRemoteConfig, type RemoteConfigDocument, type RemoteConfigLimits, type ResolvedLimits, resolveLimits, } from "./config/clamp.ts";
|
|
11
|
+
export { CONFIG_PINNED_STORAGE_KEY, CONFIG_STORAGE_KEY, createRemoteConfig, type RemoteConfig, type RemoteConfigClient, type RemoteConfigClientOptions, type RemoteConfigConnection, type RemoteConfigOpenOptions, type RemoteConfigOptions, type RemoteConfigStorage, type RemoteConfigTimers, } from "./config/remote.ts";
|
|
12
|
+
export type { RumBind, RumLifecycle, RumLifecycleHandlers, RumPlatformInfo, RumPlatformOptions, RumWrappers, } from "./contracts/binding.ts";
|
|
13
13
|
export type { RetentionBuffer, RetentionRouting } from "./contracts/retention.ts";
|
|
14
|
-
export type {
|
|
14
|
+
export type { CollectorName, EventBody, RequestStartHook, RumBus, RumCollector, RumRuntime, RumScope, RumSettings, RumSignal, } from "./contracts/runtime.ts";
|
|
15
|
+
export type { SessionDecision, SessionEvent, SessionManager, SessionState, SessionStore, } from "./contracts/session.ts";
|
|
16
|
+
export type { SummaryAccumulator, SummaryCountKey, SummaryView, VitalName } from "./contracts/summary.ts";
|
|
17
|
+
export type { ViewEvent, ViewStartOptions, ViewState, ViewTracker } from "./contracts/views.ts";
|
|
18
|
+
export type { ConfigCacheStorage, RumCoreDeps } from "./core-setup.ts";
|
|
15
19
|
export { randomUuid } from "./ids.ts";
|
|
20
|
+
export type { AddErrorOptions, Rum, RumOptions, RumSetupOptions, RumTelemetry } from "./options.ts";
|
|
21
|
+
export type { PendingSpans } from "./pending-spans.ts";
|
|
16
22
|
export { stripQuery } from "./query.ts";
|
|
17
|
-
export { createRetentionBuffer, RETENTION_QUEUE_DEFAULTS } from "./retention/buffer.ts";
|
|
23
|
+
export { createRetentionBuffer, RETENTION_QUEUE_DEFAULTS, type RetentionBufferOptions, } from "./retention/buffer.ts";
|
|
18
24
|
export { retainingLogExporter, retainingSpanExporter, withRetention } from "./retention/exporters.ts";
|
|
19
|
-
export { type BroadcastChannelLike, localStorageSessionStore, parseSessionState, SESSION_CHANNEL, SESSION_STORAGE_KEY, } from "./session/local-store.ts";
|
|
25
|
+
export { type BroadcastChannelLike, type LocalSessionStoreOptions, localStorageSessionStore, parseSessionState, SESSION_CHANNEL, SESSION_STORAGE_KEY, } from "./session/local-store.ts";
|
|
20
26
|
export { createSessionManager, type SessionManagerOptions } from "./session/manager.ts";
|
|
21
27
|
export { fnv1a32, sessionSampled } from "./session/sampling.ts";
|
|
22
28
|
export { type ResolvedRum, resolveSettings } from "./settings.ts";
|
package/dist/internal.js
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @libo11y/rum/internal: what the RUM adapter packages and the browser fixtures compose. For
|
|
3
|
-
* libo11y packages only. It follows the package version
|
|
4
|
-
* no API report.
|
|
3
|
+
* libo11y packages only. It follows the package version and carries no compatibility promise.
|
|
5
4
|
*/
|
|
6
5
|
export { actionName, actionTarget, elementSelector } from "./actions/naming.js";
|
|
7
6
|
export { ATTR_SESSION_ID, ATTR_USER_ID, summaryCountKey, summaryVitalKey } from "./attrs.js";
|
|
8
7
|
export { afterLoadOn, BOOTSTRAP_KEY, bootstrapBuffer, installRumBootstrapOn, takeBootstrap, } from "./bootstrap/buffer.js";
|
|
9
8
|
export { replayBootstrap } from "./bootstrap/replay.js";
|
|
10
9
|
export { createBus } from "./bus.js";
|
|
11
|
-
export { clampConfig, parseRemoteConfig, resolveLimits } from "./config/clamp.js";
|
|
12
|
-
export { CONFIG_STORAGE_KEY, createRemoteConfig } from "./config/remote.js";
|
|
10
|
+
export { clampConfig, parseRemoteConfig, resolveLimits, } from "./config/clamp.js";
|
|
11
|
+
export { CONFIG_PINNED_STORAGE_KEY, CONFIG_STORAGE_KEY, createRemoteConfig, } from "./config/remote.js";
|
|
13
12
|
export { randomUuid } from "./ids.js";
|
|
14
13
|
export { stripQuery } from "./query.js";
|
|
15
|
-
export { createRetentionBuffer, RETENTION_QUEUE_DEFAULTS } from "./retention/buffer.js";
|
|
14
|
+
export { createRetentionBuffer, RETENTION_QUEUE_DEFAULTS, } from "./retention/buffer.js";
|
|
16
15
|
export { retainingLogExporter, retainingSpanExporter, withRetention } from "./retention/exporters.js";
|
|
17
16
|
export { localStorageSessionStore, parseSessionState, SESSION_CHANNEL, SESSION_STORAGE_KEY, } from "./session/local-store.js";
|
|
18
17
|
export { createSessionManager } from "./session/manager.js";
|
package/dist/pending-spans.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Spans that start between a grant and the session loading
|
|
2
|
+
* Spans that start between a grant and the session loading. A session store may answer in a
|
|
3
3
|
* later task, as chrome.storage.session does, while web's documentLoad span starts and ends as soon
|
|
4
4
|
* as consent is granted. The span processor holds the spans that start in that window here. Once
|
|
5
5
|
* the session is known, each held span gets session.id and its view's o11y.rum.view.id: at once
|
package/dist/query.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
/** URL query policy
|
|
1
|
+
/** URL query policy: a query parameter is kept only when the app allows it. */
|
|
2
2
|
export declare function stripQuery(href: string, allow: ReadonlySet<string>): string;
|
package/dist/query.js
CHANGED
|
@@ -1,10 +1,14 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The retention buffer
|
|
2
|
+
* The retention buffer: detail of a session not yet kept,
|
|
3
3
|
* in its own IndexedDB queue so a reload keeps it and every tab of the session shares it. Flushing
|
|
4
4
|
* claims a few entries at a time with a lease and removes each one once it is handed over, so two
|
|
5
|
-
* tabs that both see the session become kept send each batch once.
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
* tabs that both see the session become kept send each batch once. A flush leases only the batches
|
|
6
|
+
* keep accepts, so another session's batches stay claimable while it sends. A clear or close ends
|
|
7
|
+
* every flush begun before it, and close closes the queue once the batches already handed over are
|
|
8
|
+
* removed.
|
|
9
|
+
* Where IndexedDB is unavailable, openQueue gives a memory queue and a reload loses it. The queue
|
|
10
|
+
* is opened on first use, so a caller that uses it only after consent creates no database before
|
|
11
|
+
* consent.
|
|
8
12
|
*/
|
|
9
13
|
import type { PersistentQueue } from "@libo11y/web/portable";
|
|
10
14
|
import type { RetentionBuffer } from "../contracts/retention.ts";
|
|
@@ -20,6 +24,6 @@ export interface RetentionBufferOptions {
|
|
|
20
24
|
/** Epoch milliseconds. Default Date.now. */
|
|
21
25
|
readonly now?: () => number;
|
|
22
26
|
/** The longest one send can take, the transport timeout. Default 10000. Sets the claim lease. */
|
|
23
|
-
readonly sendTimeoutMillis?: number;
|
|
27
|
+
readonly sendTimeoutMillis?: number | undefined;
|
|
24
28
|
}
|
|
25
29
|
export declare function createRetentionBuffer(opts: RetentionBufferOptions): RetentionBuffer;
|
package/dist/retention/buffer.js
CHANGED
|
@@ -16,6 +16,10 @@ export function createRetentionBuffer(opts) {
|
|
|
16
16
|
const lease = CLAIM_BATCH * (opts.sendTimeoutMillis ?? DEFAULT_SEND_TIMEOUT_MILLIS) + LEASE_MARGIN_MILLIS;
|
|
17
17
|
let opening;
|
|
18
18
|
let closed = false;
|
|
19
|
+
// Bumped by clear and close.
|
|
20
|
+
let epoch = 0;
|
|
21
|
+
/** Active hand-overs whose removals close() waits on before closing the queue. */
|
|
22
|
+
const handing = new Set();
|
|
19
23
|
const queue = () => {
|
|
20
24
|
opening ??= opts.open().catch((err) => {
|
|
21
25
|
diag.warn("o11y: rum: the retention buffer could not open", err);
|
|
@@ -34,26 +38,44 @@ export function createRetentionBuffer(opts) {
|
|
|
34
38
|
diag.warn("o11y: rum: a retention buffer write failed", err);
|
|
35
39
|
}
|
|
36
40
|
},
|
|
37
|
-
async flush(delivery, keep) {
|
|
38
|
-
|
|
39
|
-
|
|
41
|
+
async flush(delivery, keep, allowed) {
|
|
42
|
+
// A clear or close ends every flush begun before it: a batch it claimed before a revoke is
|
|
43
|
+
// never handed over, even under a grant that began since.
|
|
44
|
+
const e = epoch;
|
|
45
|
+
const ok = () => !closed && e === epoch && (allowed === undefined || allowed());
|
|
40
46
|
let sent = 0;
|
|
47
|
+
// A flush after close or before consent opens nothing.
|
|
48
|
+
if (!ok())
|
|
49
|
+
return sent;
|
|
41
50
|
try {
|
|
42
51
|
const q = await queue();
|
|
43
|
-
if (q === undefined)
|
|
44
|
-
return 0;
|
|
45
52
|
for (;;) {
|
|
46
|
-
|
|
47
|
-
|
|
53
|
+
if (q === undefined || !ok())
|
|
54
|
+
return sent;
|
|
55
|
+
// The queue leases only the batches keep accepts, in one transaction, so another session's
|
|
56
|
+
// batches stay claimable by that session's own flush while this one waits on the network.
|
|
57
|
+
const claimed = await q.claim(now(), CLAIM_BATCH, lease, keep);
|
|
58
|
+
if (claimed.length === 0)
|
|
48
59
|
return sent;
|
|
49
|
-
for (const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
60
|
+
for (const b of claimed) {
|
|
61
|
+
if (!ok())
|
|
62
|
+
return sent;
|
|
63
|
+
// A queue that ignores match leaves a refused batch leased until its lease runs out, unsent.
|
|
64
|
+
if (keep !== undefined && !keep(b))
|
|
65
|
+
continue;
|
|
66
|
+
// The delivery keeps a retryable failure in its own retry queue, so the entry is done here,
|
|
67
|
+
// and a batch handed over is removed even when the flush ends meanwhile.
|
|
68
|
+
const handed = delivery.deliver({ signal: b.signal, body: b.body }).then(() => {
|
|
54
69
|
sent++;
|
|
55
|
-
|
|
56
|
-
|
|
70
|
+
return q.remove([b.id]);
|
|
71
|
+
});
|
|
72
|
+
const tracked = handed.then(() => {
|
|
73
|
+
handing.delete(tracked);
|
|
74
|
+
}, () => {
|
|
75
|
+
handing.delete(tracked);
|
|
76
|
+
});
|
|
77
|
+
handing.add(tracked);
|
|
78
|
+
await handed;
|
|
57
79
|
}
|
|
58
80
|
}
|
|
59
81
|
}
|
|
@@ -84,6 +106,7 @@ export function createRetentionBuffer(opts) {
|
|
|
84
106
|
async clear() {
|
|
85
107
|
if (closed)
|
|
86
108
|
return;
|
|
109
|
+
epoch++;
|
|
87
110
|
try {
|
|
88
111
|
// Opens the queue if needed: a previous page of the session may have left entries.
|
|
89
112
|
await (await queue())?.clear();
|
|
@@ -98,7 +121,10 @@ export function createRetentionBuffer(opts) {
|
|
|
98
121
|
},
|
|
99
122
|
close() {
|
|
100
123
|
closed = true;
|
|
101
|
-
|
|
124
|
+
epoch++;
|
|
125
|
+
// The queue stays open until the batches already handed over are removed, so a later page
|
|
126
|
+
// never sends them again.
|
|
127
|
+
void Promise.all([...handing]).then(() => opening?.then((q) => q?.close()));
|
|
102
128
|
},
|
|
103
129
|
};
|
|
104
130
|
}
|
|
@@ -1,16 +1,70 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The retention router
|
|
2
|
+
* The retention router. Wraps the exporters @libo11y/web builds, so each batch is
|
|
3
3
|
* split by the session.id of its records: kept sessions go to the inner exporter, the current
|
|
4
4
|
* unkept session is serialized into the retention buffer, and an old unkept session is dropped.
|
|
5
5
|
* Every o11y.rum.view.summary record goes to the inner exporter, because summaries are sent for
|
|
6
|
-
* every consented session. Metrics pass through untouched.
|
|
6
|
+
* every consented session. Metrics pass through untouched. holdingSpanExporter and holdingLogExporter
|
|
7
|
+
* route the records of an exporter the app injected, or of a console exporter, the same way, holding
|
|
8
|
+
* the current unkept session's in memory.
|
|
7
9
|
*/
|
|
8
10
|
import type { ExporterSet } from "@libo11y/core";
|
|
9
11
|
import type { LogRecordExporter } from "@opentelemetry/sdk-logs";
|
|
10
12
|
import type { SpanExporter } from "@opentelemetry/sdk-trace";
|
|
11
13
|
import type { RetentionRouting } from "../contracts/retention.ts";
|
|
14
|
+
import type { SessionDecision } from "../contracts/session.ts";
|
|
12
15
|
/** A SpanExporter that routes each span by its session.id. */
|
|
13
16
|
export declare function retainingSpanExporter(inner: SpanExporter, routing: RetentionRouting): SpanExporter;
|
|
17
|
+
/** The most spans holdingSpanExporter holds. Past it the oldest are dropped first. */
|
|
18
|
+
export declare const HELD_SPANS_MAX = 1000;
|
|
19
|
+
/** The most log records holdingLogExporter holds. Past it the oldest are dropped first. */
|
|
20
|
+
export declare const HELD_LOGS_MAX = 1000;
|
|
21
|
+
/** What a holding exporter adds to the exporter it wraps. */
|
|
22
|
+
export interface Holding {
|
|
23
|
+
/**
|
|
24
|
+
* Exports, in the order they were held, the held items of every session decide now sends, and
|
|
25
|
+
* drops those of every session it drops. The items of a session still to be buffered stay held.
|
|
26
|
+
* The export waits for any export in flight, so the inner exporter never exports two batches at
|
|
27
|
+
* once, and is dropped if allowed is false when its turn comes.
|
|
28
|
+
*/
|
|
29
|
+
release(): void;
|
|
30
|
+
/**
|
|
31
|
+
* Drops the held items of sessionId. Without it, as on a revoke, drops every held item and settles
|
|
32
|
+
* every queued export without exporting it, so none runs under a later grant.
|
|
33
|
+
*/
|
|
34
|
+
discard(sessionId?: string): void;
|
|
35
|
+
/**
|
|
36
|
+
* Stops for good: drops what is held and queued, ends a shutdown still waiting for a release, and
|
|
37
|
+
* stops the inner exporter if nothing has yet. Called once the caller's shutdown deadline passed.
|
|
38
|
+
*/
|
|
39
|
+
close(): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
/** A SpanExporter that holds the spans of the current unkept session in memory. */
|
|
42
|
+
export interface HoldingSpanExporter extends SpanExporter, Holding {
|
|
43
|
+
}
|
|
44
|
+
/** A LogRecordExporter that holds the records of the current unkept session in memory. */
|
|
45
|
+
export interface HoldingLogExporter extends LogRecordExporter, Holding {
|
|
46
|
+
}
|
|
47
|
+
export interface HoldingOptions {
|
|
48
|
+
/** The most items held. Default HELD_SPANS_MAX or HELD_LOGS_MAX. */
|
|
49
|
+
readonly max?: number;
|
|
50
|
+
/** False while nothing may be exported, as after a revoke. A queued export that finds it false is dropped. Default always true. */
|
|
51
|
+
readonly allowed?: () => boolean;
|
|
52
|
+
/** How long one export may take. Default 30000. */
|
|
53
|
+
readonly timeoutMillis?: number;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* A SpanExporter that routes each span by its session.id as retainingSpanExporter does, but holds
|
|
57
|
+
* the spans to be buffered in memory, at most max of them, instead of in the retention buffer. The
|
|
58
|
+
* retention buffer sends through the platform's delivery, so an exporter the app injected, or the
|
|
59
|
+
* console exporter, would never see a span that waited there. A held span without a session.id is
|
|
60
|
+
* never released.
|
|
61
|
+
*/
|
|
62
|
+
export declare function holdingSpanExporter(inner: SpanExporter, decide: (sessionId: string | undefined) => SessionDecision, o?: HoldingOptions): HoldingSpanExporter;
|
|
63
|
+
/**
|
|
64
|
+
* A LogRecordExporter that routes each record as holdingSpanExporter routes spans, sending every
|
|
65
|
+
* o11y.rum.view.summary record at once, as retainingLogExporter does.
|
|
66
|
+
*/
|
|
67
|
+
export declare function holdingLogExporter(inner: LogRecordExporter, decide: (sessionId: string | undefined) => SessionDecision, o?: HoldingOptions): HoldingLogExporter;
|
|
14
68
|
/** A LogRecordExporter that routes each record by its session.id, sending every view summary. */
|
|
15
69
|
export declare function retainingLogExporter(inner: LogRecordExporter, routing: RetentionRouting): LogRecordExporter;
|
|
16
70
|
/** The exporter set with traces and logs routed by session. The metric reader is unchanged. */
|