@utk09/ui-observability 0.1.1 → 0.2.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/CHANGELOG.md +66 -0
- package/README.md +29 -32
- package/dist/bus/bus.d.ts +11 -23
- package/dist/constants-DkrpC_xK.cjs +2 -0
- package/dist/constants-DkrpC_xK.cjs.map +1 -0
- package/dist/constants-NJNXpfPi.js +67 -0
- package/dist/constants-NJNXpfPi.js.map +1 -0
- package/dist/constants.d.ts +73 -6
- package/dist/core/breadcrumbs.d.ts +1 -6
- package/dist/core/diagnostics.d.ts +1 -1
- package/dist/core/journey.d.ts +11 -1
- package/dist/core/pipeline.d.ts +39 -18
- package/dist/core/record.d.ts +10 -0
- package/dist/index.cjs +3 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +496 -481
- package/dist/index.js.map +1 -1
- package/dist/indexeddb-storage-CH9NocOC.cjs +2 -0
- package/dist/indexeddb-storage-CH9NocOC.cjs.map +1 -0
- package/dist/indexeddb-storage-DAoHV_oL.js +154 -0
- package/dist/indexeddb-storage-DAoHV_oL.js.map +1 -0
- package/dist/models/config.d.ts +17 -261
- package/dist/storage/idb-driver.d.ts +67 -0
- package/dist/storage/indexeddb-storage.d.ts +1 -1
- package/dist/utils/console.d.ts +5 -8
- package/package.json +6 -6
- package/dist/constants-4eu3x1qw.js +0 -110
- package/dist/constants-4eu3x1qw.js.map +0 -1
- package/dist/constants-Daya7Mc-.cjs +0 -2
- package/dist/constants-Daya7Mc-.cjs.map +0 -1
- package/dist/indexeddb-storage-2PCdF5Ji.js +0 -88
- package/dist/indexeddb-storage-2PCdF5Ji.js.map +0 -1
- package/dist/indexeddb-storage-BhMUPgyG.cjs +0 -2
- package/dist/indexeddb-storage-BhMUPgyG.cjs.map +0 -1
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
const e=require("./constants-DkrpC_xK.cjs");function t(e){return e.error??Error(`the IndexedDB request failed`)}function n(e){return new Promise((n,r)=>{e.onsuccess=()=>{n(e.result)},e.onerror=()=>{r(t(e))}})}var r=class{name;connection=null;constructor(e){this.name=e}async put(e){await n((await this.store(`readwrite`)).put(e))}async takeOldest(t){return n((await this.store(`readonly`)).index(e.Z).getAll(null,t))}async takeBefore(t){let r=await this.store(`readonly`),i=IDBKeyRange.upperBound(t,!0);return n(r.index(e.Z).getAll(i))}async delete(e){await n((await this.store(`readwrite`)).delete(e))}async deleteMany(e){let t=await this.store(`readwrite`);await Promise.all(e.map(e=>n(t.delete(e))))}async bumpAttempts(e,t){let r=await n((await this.store(`readonly`)).get(e));r!==void 0&&await n((await this.store(`readwrite`)).put({...r,attempts:t}))}async count(){return n((await this.store(`readonly`)).count())}async clear(){await n((await this.store(`readwrite`)).clear())}async close(){let e=this.connection;e!==null&&(this.connection=null,(await e).close())}async store(t){return(await this.open()).transaction(e.Q,t).objectStore(e.Q)}open(){let n=this.connection;if(n!==null)return n;let r=new Promise((n,r)=>{let i=indexedDB.open(this.name,11);i.onupgradeneeded=()=>{let t=i.result;t.objectStoreNames.contains(`batches`)||t.createObjectStore(e.Q,{keyPath:`id`}).createIndex(e.Z,e.Z)},i.onsuccess=()=>{n(i.result)},i.onerror=()=>{r(t(i))}});return this.connection=r,r}};function i(e){return e.reduce((e,t)=>e+t.records.length,0)}var a=class{limits;diagnostics;onGap;name=e.qt;db;constructor(e,t,n,i){this.limits=t,this.diagnostics=n,this.onGap=i,this.db=new r(e)}async save(e){try{await this.db.put(e),await this.prune()}catch(t){if(t instanceof Error&&t.name===`QuotaExceededError`){this.diagnostics.report(`storage.quota_exceeded`,`IndexedDB is full, evicting the oldest`);let e=await this.diagnostics.guardAsync(`storage.degraded`,`evicting after a full disk`,()=>this.evictOldest(Math.ceil(this.limits.maxBatches/4)));e&&this.reportGap({...e,reason:`quota`});return}this.diagnostics.report(`storage.degraded`,`could not persist a batch`,{batchId:e.id},t)}}async take(e){return await this.diagnostics.guardAsync(`storage.degraded`,`reading stored batches`,()=>this.db.takeOldest(e))??[]}async remove(e){await this.diagnostics.guardAsync(`storage.degraded`,`deleting a batch`,()=>this.db.delete(e))}async bumpAttempts(e,t){await this.diagnostics.guardAsync(`storage.degraded`,`updating attempts`,()=>this.db.bumpAttempts(e,t))}async prune(){let e={batches:0,records:0,reason:`expired`};return await this.diagnostics.guardAsync(`storage.degraded`,`pruning`,async()=>{let t=Date.now()-this.limits.maxAgeMs,n=await this.db.takeBefore(t);n.length>0&&(await this.db.deleteMany(n.map(e=>e.id)),e.batches+=n.length,e.records+=i(n));let r=await this.db.count();if(r>this.limits.maxBatches){e.reason=`over_capacity`;let t=await this.evictOldest(r-this.limits.maxBatches);e.batches+=t.batches,e.records+=t.records}}),this.reportGap(e),e}async count(){return await this.diagnostics.guardAsync(`storage.degraded`,`counting`,()=>this.db.count())??0}async clear(){await this.diagnostics.guardAsync(`storage.degraded`,`clearing`,()=>this.db.clear())}async close(){await this.diagnostics.guardAsync(`storage.degraded`,`closing the database`,()=>this.db.close())}reportGap(e){e.batches!==0&&(this.diagnostics.report(`storage.evicted`,`dropped ${String(e.batches)} stored batches (${String(e.records)} records)`,{...e}),this.onGap?.(e))}async evictOldest(e){let t=await this.db.takeOldest(e);return await this.db.deleteMany(t.map(e=>e.id)),{batches:t.length,records:i(t)}}};exports.IndexedDbStorage=a;
|
|
2
|
+
//# sourceMappingURL=indexeddb-storage-CH9NocOC.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexeddb-storage-CH9NocOC.cjs","names":[],"sources":["../src/storage/idb-driver.ts","../src/storage/indexeddb-storage.ts"],"sourcesContent":["// src/storage/idb-driver.ts\n//\n// Raw IndexedDB mechanics for the batch store: opening, request promises, and the\n// createdAt-ordered reads. Everything above this file works in batches and ids.\n\nimport {\n INDEXEDDB_CREATED_AT_INDEX,\n INDEXEDDB_SCHEMA_VERSION,\n INDEXEDDB_STORE_NAME,\n} from \"../constants\";\nimport type { LogBatch } from \"../models/batch\";\n\n/**\n * Reads the failure off a request that has errored. A host whose request reports\n * no error gets a stand-in: rejecting with null makes the instanceof Error test\n * in save() false, and a full disk is then reported as an ordinary write failure.\n * @param request Request that fired onerror.\n * @returns The failure that stopped it.\n */\nfunction failureOf(request: IDBRequest): Error {\n return request.error ?? new Error(\"the IndexedDB request failed\");\n}\n\n/**\n * Resolves when an IndexedDB request succeeds and rejects with its error. The\n * request is read as IDBRequest<any>, so every caller names the type it expects.\n * @param request Request to await.\n * @returns The request result.\n */\nfunction promisify<T>(request: IDBRequest): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n request.onsuccess = () => {\n resolve(request.result as T);\n };\n request.onerror = () => {\n reject(failureOf(request));\n };\n });\n}\n\n/** One IndexedDB database holding undelivered batches keyed by id. */\nexport class IdbDriver {\n /** Open in progress or completed, reused so one database is opened per driver. */\n private connection: Promise<IDBDatabase> | null = null;\n\n /**\n * @param name IndexedDB database name.\n */\n constructor(private readonly name: string) {}\n\n /**\n * Writes a batch, replacing any batch already stored under the same id.\n * @param batch Batch to persist.\n */\n async put(batch: LogBatch): Promise<void> {\n const store = await this.store(\"readwrite\");\n await promisify(store.put(batch));\n }\n\n /**\n * Reads the oldest batches by createdAt without removing them.\n * @param limit Maximum number of batches to return.\n * @returns Batches in ascending createdAt order.\n */\n async takeOldest(limit: number): Promise<LogBatch[]> {\n const store = await this.store(\"readonly\");\n return promisify<LogBatch[]>(store.index(INDEXEDDB_CREATED_AT_INDEX).getAll(null, limit));\n }\n\n /**\n * Reads every batch created strictly before a cutoff.\n * @param cutoff Exclusive upper bound in epoch milliseconds.\n * @returns Batches older than the cutoff.\n */\n async takeBefore(cutoff: number): Promise<LogBatch[]> {\n const store = await this.store(\"readonly\");\n const range = IDBKeyRange.upperBound(cutoff, true);\n return promisify<LogBatch[]>(store.index(INDEXEDDB_CREATED_AT_INDEX).getAll(range));\n }\n\n /**\n * Deletes one batch. An id that is not stored resolves without error.\n * @param id Batch identifier.\n */\n async delete(id: string): Promise<void> {\n const store = await this.store(\"readwrite\");\n await promisify(store.delete(id));\n }\n\n /**\n * Deletes several batches in one transaction, so a partial failure leaves none\n * of them deleted.\n * @param ids Batch identifiers.\n */\n async deleteMany(ids: string[]): Promise<void> {\n const store = await this.store(\"readwrite\");\n await Promise.all(ids.map((id) => promisify(store.delete(id))));\n }\n\n /**\n * Rewrites the attempt count of a stored batch. An id that is not stored is\n * left alone: a batch already delivered and deleted must not be resurrected.\n * @param id Batch identifier.\n * @param attempts New absolute attempt count.\n */\n async bumpAttempts(id: string, attempts: number): Promise<void> {\n const read = await this.store(\"readonly\");\n const batch = await promisify<LogBatch | undefined>(read.get(id));\n if (batch === undefined) {\n return;\n }\n\n const write = await this.store(\"readwrite\");\n await promisify(write.put({ ...batch, attempts }));\n }\n\n /**\n * Counts stored batches.\n * @returns Total batch count.\n */\n async count(): Promise<number> {\n const store = await this.store(\"readonly\");\n return promisify<number>(store.count());\n }\n\n /** Deletes every stored batch. */\n async clear(): Promise<void> {\n const store = await this.store(\"readwrite\");\n await promisify(store.clear());\n }\n\n /** Closes the connection, if one was ever opened. */\n async close(): Promise<void> {\n const connection = this.connection;\n if (connection === null) {\n return;\n }\n\n this.connection = null;\n const db = await connection;\n db.close();\n }\n\n /**\n * Opens the batch store in a fresh transaction. A transaction is only valid\n * until control returns to the event loop, so every call takes a new one.\n * @param mode Transaction mode.\n * @returns The batch object store.\n */\n private async store(mode: IDBTransactionMode): Promise<IDBObjectStore> {\n const db = await this.open();\n return db.transaction(INDEXEDDB_STORE_NAME, mode).objectStore(INDEXEDDB_STORE_NAME);\n }\n\n /**\n * Opens the database once and hands the same connection to every later call.\n * @returns The open database.\n */\n private open(): Promise<IDBDatabase> {\n const existing = this.connection;\n if (existing !== null) {\n return existing;\n }\n\n const opening = new Promise<IDBDatabase>((resolve, reject) => {\n const request = indexedDB.open(this.name, INDEXEDDB_SCHEMA_VERSION);\n\n request.onupgradeneeded = () => {\n const db = request.result;\n // A database written by an earlier release already carries the store.\n // Creating it again throws ConstraintError and the upgrade aborts.\n if (!db.objectStoreNames.contains(INDEXEDDB_STORE_NAME)) {\n const store = db.createObjectStore(INDEXEDDB_STORE_NAME, { keyPath: \"id\" });\n store.createIndex(INDEXEDDB_CREATED_AT_INDEX, INDEXEDDB_CREATED_AT_INDEX);\n }\n };\n\n request.onsuccess = () => {\n resolve(request.result);\n };\n request.onerror = () => {\n reject(failureOf(request));\n };\n });\n\n this.connection = opening;\n return opening;\n }\n}\n","// src/storage/indexeddb-storage.ts\n//\n// Persistent storage adapter backed by IndexedDB with time-ordered indexing.\n\nimport { QUOTA_EVICTION_DIVISOR, QUOTA_EXCEEDED_ERROR, STORAGE_NAME_INDEXEDDB } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { LogBatch } from \"../models/batch\";\nimport type { GapReporter, PruneResult, StorageAdapter, StorageLimits } from \"../models/storage\";\nimport { IdbDriver } from \"./idb-driver\";\n\n/**\n * Sums the total count of records contained across an array of batches.\n * @param batches Batches to measure.\n * @returns Total record count.\n */\nfunction countRecords(batches: LogBatch[]): number {\n return batches.reduce((total, batch) => total + batch.records.length, 0);\n}\n\n/** Persistent StorageAdapter implementation backed by IndexedDB. */\nexport class IndexedDbStorage implements StorageAdapter {\n /** Storage adapter strategy name. */\n readonly name = STORAGE_NAME_INDEXEDDB;\n\n /** IndexedDB mechanics for the batch store. */\n private readonly db: IdbDriver;\n\n /**\n * @param dbName Database name.\n * @param limits Storage capacity and retention thresholds.\n * @param diagnostics Diagnostics reporter.\n * @param onGap Optional callback for dropped record reporting.\n */\n constructor(\n dbName: string,\n private readonly limits: StorageLimits,\n private readonly diagnostics: Diagnostics,\n private readonly onGap?: GapReporter,\n ) {\n this.db = new IdbDriver(dbName);\n }\n\n /**\n * Persists a batch to IndexedDB and triggers storage pruning.\n * @param batch Batch to store.\n */\n async save(batch: LogBatch): Promise<void> {\n try {\n await this.db.put(batch);\n await this.prune();\n } catch (error) {\n if (error instanceof Error && error.name === QUOTA_EXCEEDED_ERROR) {\n this.diagnostics.report(\"storage.quota_exceeded\", \"IndexedDB is full, evicting the oldest\");\n const evicted = await this.diagnostics.guardAsync(\n \"storage.degraded\",\n \"evicting after a full disk\",\n () => this.evictOldest(Math.ceil(this.limits.maxBatches / QUOTA_EVICTION_DIVISOR)),\n );\n if (evicted) {\n this.reportGap({ ...evicted, reason: \"quota\" });\n }\n return;\n }\n\n this.diagnostics.report(\n \"storage.degraded\",\n \"could not persist a batch\",\n { batchId: batch.id },\n error,\n );\n }\n }\n\n /**\n * Reads up to limit batches in chronological order without deletion.\n * @param limit Maximum number of batches to retrieve.\n * @returns Array of retrieved batches.\n */\n async take(limit: number): Promise<LogBatch[]> {\n const batches = await this.diagnostics.guardAsync(\n \"storage.degraded\",\n \"reading stored batches\",\n () => this.db.takeOldest(limit),\n );\n return batches ?? [];\n }\n\n /**\n * Deletes a batch from IndexedDB by ID.\n * @param id Batch identifier to delete.\n */\n async remove(id: string): Promise<void> {\n await this.diagnostics.guardAsync(\"storage.degraded\", \"deleting a batch\", () =>\n this.db.delete(id),\n );\n }\n\n /**\n * Updates delivery attempt count for a stored batch.\n * @param id Batch identifier.\n * @param attempts New absolute attempt count.\n */\n async bumpAttempts(id: string, attempts: number): Promise<void> {\n await this.diagnostics.guardAsync(\"storage.degraded\", \"updating attempts\", () =>\n this.db.bumpAttempts(id, attempts),\n );\n }\n\n /**\n * Removes expired batches and evicts oldest entries exceeding capacity.\n * @returns Prune summary metrics.\n */\n async prune(): Promise<PruneResult> {\n const result: PruneResult = { batches: 0, records: 0, reason: \"expired\" };\n\n await this.diagnostics.guardAsync(\"storage.degraded\", \"pruning\", async () => {\n const cutoff = Date.now() - this.limits.maxAgeMs;\n const expired = await this.db.takeBefore(cutoff);\n if (expired.length > 0) {\n await this.db.deleteMany(expired.map((batch) => batch.id));\n result.batches += expired.length;\n result.records += countRecords(expired);\n }\n\n const total = await this.db.count();\n if (total > this.limits.maxBatches) {\n result.reason = \"over_capacity\";\n const evicted = await this.evictOldest(total - this.limits.maxBatches);\n result.batches += evicted.batches;\n result.records += evicted.records;\n }\n });\n\n this.reportGap(result);\n return result;\n }\n\n /**\n * Returns total count of stored batches.\n * @returns Total batch count or 0 on failure.\n */\n async count(): Promise<number> {\n const total = await this.diagnostics.guardAsync(\"storage.degraded\", \"counting\", () =>\n this.db.count(),\n );\n return total ?? 0;\n }\n\n /** Deletes all stored batches from the database. */\n async clear(): Promise<void> {\n await this.diagnostics.guardAsync(\"storage.degraded\", \"clearing\", () => this.db.clear());\n }\n\n /** Closes the active IndexedDB connection. */\n async close(): Promise<void> {\n await this.diagnostics.guardAsync(\"storage.degraded\", \"closing the database\", () =>\n this.db.close(),\n );\n }\n\n /**\n * Reports dropped records to diagnostics and registered gap handlers.\n * @param result Prune result metrics.\n */\n private reportGap(result: PruneResult): void {\n if (result.batches === 0) {\n return;\n }\n\n this.diagnostics.report(\n \"storage.evicted\",\n `dropped ${String(result.batches)} stored batches (${String(result.records)} records)`,\n { ...result },\n );\n this.onGap?.(result);\n }\n\n /**\n * Deletes a specified count of the oldest stored batches. Unguarded: both callers\n * guard it, and swallowing the failure here reports an eviction that did not\n * happen.\n * @param howMany Number of oldest batches to evict.\n * @returns Metrics of evicted batches and records.\n */\n private async evictOldest(howMany: number): Promise<Omit<PruneResult, \"reason\">> {\n const doomed = await this.db.takeOldest(howMany);\n await this.db.deleteMany(doomed.map((batch) => batch.id));\n\n return { batches: doomed.length, records: countRecords(doomed) };\n }\n}\n"],"mappings":"4CAmBA,SAAS,EAAU,EAA4B,CAC7C,OAAO,EAAQ,OAAa,MAAM,8BAA8B,CAClE,CAQA,SAAS,EAAa,EAAiC,CACrD,OAAO,IAAI,SAAY,EAAS,IAAW,CACzC,EAAQ,cAAkB,CACxB,EAAQ,EAAQ,MAAW,CAC7B,EACA,EAAQ,YAAgB,CACtB,EAAO,EAAU,CAAO,CAAC,CAC3B,CACF,CAAC,CACH,CAGA,IAAa,EAAb,KAAuB,CAOQ,KAL7B,WAAkD,KAKlD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O,MAHa,KAAK,YAAY,WAAW,mBAAoB,eAClE,KAAK,GAAG,MAAM,CAChB,GACgB,CAClB,CAGA,MAAM,OAAuB,CAC3B,MAAM,KAAK,YAAY,WAAW,mBAAoB,eAAkB,KAAK,GAAG,MAAM,CAAC,CACzF,CAGA,MAAM,OAAuB,CAC3B,MAAM,KAAK,YAAY,WAAW,mBAAoB,2BACpD,KAAK,GAAG,MAAM,CAChB,CACF,CAMA,UAAkB,EAA2B,CACvC,EAAO,UAAY,IAIvB,KAAK,YAAY,OACf,kBACA,WAAW,OAAO,EAAO,OAAO,EAAE,mBAAmB,OAAO,EAAO,OAAO,EAAE,WAC5E,CAAE,GAAG,CAAO,CACd,EACA,KAAK,QAAQ,CAAM,EACrB,CASA,MAAc,YAAY,EAAuD,CAC/E,IAAM,EAAS,MAAM,KAAK,GAAG,WAAW,CAAO,EAG/C,OAFA,MAAM,KAAK,GAAG,WAAW,EAAO,IAAK,GAAU,EAAM,EAAE,CAAC,EAEjD,CAAE,QAAS,EAAO,OAAQ,QAAS,EAAa,CAAM,CAAE,CACjE,CACF"}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
import { Q as e, Z as t, qt as n } from "./constants-NJNXpfPi.js";
|
|
2
|
+
//#region src/storage/idb-driver.ts
|
|
3
|
+
function r(e) {
|
|
4
|
+
return e.error ?? /* @__PURE__ */ Error("the IndexedDB request failed");
|
|
5
|
+
}
|
|
6
|
+
function i(e) {
|
|
7
|
+
return new Promise((t, n) => {
|
|
8
|
+
e.onsuccess = () => {
|
|
9
|
+
t(e.result);
|
|
10
|
+
}, e.onerror = () => {
|
|
11
|
+
n(r(e));
|
|
12
|
+
};
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
var a = class {
|
|
16
|
+
name;
|
|
17
|
+
connection = null;
|
|
18
|
+
constructor(e) {
|
|
19
|
+
this.name = e;
|
|
20
|
+
}
|
|
21
|
+
async put(e) {
|
|
22
|
+
await i((await this.store("readwrite")).put(e));
|
|
23
|
+
}
|
|
24
|
+
async takeOldest(e) {
|
|
25
|
+
return i((await this.store("readonly")).index(t).getAll(null, e));
|
|
26
|
+
}
|
|
27
|
+
async takeBefore(e) {
|
|
28
|
+
let n = await this.store("readonly"), r = IDBKeyRange.upperBound(e, !0);
|
|
29
|
+
return i(n.index(t).getAll(r));
|
|
30
|
+
}
|
|
31
|
+
async delete(e) {
|
|
32
|
+
await i((await this.store("readwrite")).delete(e));
|
|
33
|
+
}
|
|
34
|
+
async deleteMany(e) {
|
|
35
|
+
let t = await this.store("readwrite");
|
|
36
|
+
await Promise.all(e.map((e) => i(t.delete(e))));
|
|
37
|
+
}
|
|
38
|
+
async bumpAttempts(e, t) {
|
|
39
|
+
let n = await i((await this.store("readonly")).get(e));
|
|
40
|
+
n !== void 0 && await i((await this.store("readwrite")).put({
|
|
41
|
+
...n,
|
|
42
|
+
attempts: t
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
45
|
+
async count() {
|
|
46
|
+
return i((await this.store("readonly")).count());
|
|
47
|
+
}
|
|
48
|
+
async clear() {
|
|
49
|
+
await i((await this.store("readwrite")).clear());
|
|
50
|
+
}
|
|
51
|
+
async close() {
|
|
52
|
+
let e = this.connection;
|
|
53
|
+
e !== null && (this.connection = null, (await e).close());
|
|
54
|
+
}
|
|
55
|
+
async store(t) {
|
|
56
|
+
return (await this.open()).transaction(e, t).objectStore(e);
|
|
57
|
+
}
|
|
58
|
+
open() {
|
|
59
|
+
let n = this.connection;
|
|
60
|
+
if (n !== null) return n;
|
|
61
|
+
let i = new Promise((n, i) => {
|
|
62
|
+
let a = indexedDB.open(this.name, 11);
|
|
63
|
+
a.onupgradeneeded = () => {
|
|
64
|
+
let n = a.result;
|
|
65
|
+
n.objectStoreNames.contains("batches") || n.createObjectStore(e, { keyPath: "id" }).createIndex(t, t);
|
|
66
|
+
}, a.onsuccess = () => {
|
|
67
|
+
n(a.result);
|
|
68
|
+
}, a.onerror = () => {
|
|
69
|
+
i(r(a));
|
|
70
|
+
};
|
|
71
|
+
});
|
|
72
|
+
return this.connection = i, i;
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
//#endregion
|
|
76
|
+
//#region src/storage/indexeddb-storage.ts
|
|
77
|
+
function o(e) {
|
|
78
|
+
return e.reduce((e, t) => e + t.records.length, 0);
|
|
79
|
+
}
|
|
80
|
+
var s = class {
|
|
81
|
+
limits;
|
|
82
|
+
diagnostics;
|
|
83
|
+
onGap;
|
|
84
|
+
name = n;
|
|
85
|
+
db;
|
|
86
|
+
constructor(e, t, n, r) {
|
|
87
|
+
this.limits = t, this.diagnostics = n, this.onGap = r, this.db = new a(e);
|
|
88
|
+
}
|
|
89
|
+
async save(e) {
|
|
90
|
+
try {
|
|
91
|
+
await this.db.put(e), await this.prune();
|
|
92
|
+
} catch (t) {
|
|
93
|
+
if (t instanceof Error && t.name === "QuotaExceededError") {
|
|
94
|
+
this.diagnostics.report("storage.quota_exceeded", "IndexedDB is full, evicting the oldest");
|
|
95
|
+
let e = await this.diagnostics.guardAsync("storage.degraded", "evicting after a full disk", () => this.evictOldest(Math.ceil(this.limits.maxBatches / 4)));
|
|
96
|
+
e && this.reportGap({
|
|
97
|
+
...e,
|
|
98
|
+
reason: "quota"
|
|
99
|
+
});
|
|
100
|
+
return;
|
|
101
|
+
}
|
|
102
|
+
this.diagnostics.report("storage.degraded", "could not persist a batch", { batchId: e.id }, t);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
async take(e) {
|
|
106
|
+
return await this.diagnostics.guardAsync("storage.degraded", "reading stored batches", () => this.db.takeOldest(e)) ?? [];
|
|
107
|
+
}
|
|
108
|
+
async remove(e) {
|
|
109
|
+
await this.diagnostics.guardAsync("storage.degraded", "deleting a batch", () => this.db.delete(e));
|
|
110
|
+
}
|
|
111
|
+
async bumpAttempts(e, t) {
|
|
112
|
+
await this.diagnostics.guardAsync("storage.degraded", "updating attempts", () => this.db.bumpAttempts(e, t));
|
|
113
|
+
}
|
|
114
|
+
async prune() {
|
|
115
|
+
let e = {
|
|
116
|
+
batches: 0,
|
|
117
|
+
records: 0,
|
|
118
|
+
reason: "expired"
|
|
119
|
+
};
|
|
120
|
+
return await this.diagnostics.guardAsync("storage.degraded", "pruning", async () => {
|
|
121
|
+
let t = Date.now() - this.limits.maxAgeMs, n = await this.db.takeBefore(t);
|
|
122
|
+
n.length > 0 && (await this.db.deleteMany(n.map((e) => e.id)), e.batches += n.length, e.records += o(n));
|
|
123
|
+
let r = await this.db.count();
|
|
124
|
+
if (r > this.limits.maxBatches) {
|
|
125
|
+
e.reason = "over_capacity";
|
|
126
|
+
let t = await this.evictOldest(r - this.limits.maxBatches);
|
|
127
|
+
e.batches += t.batches, e.records += t.records;
|
|
128
|
+
}
|
|
129
|
+
}), this.reportGap(e), e;
|
|
130
|
+
}
|
|
131
|
+
async count() {
|
|
132
|
+
return await this.diagnostics.guardAsync("storage.degraded", "counting", () => this.db.count()) ?? 0;
|
|
133
|
+
}
|
|
134
|
+
async clear() {
|
|
135
|
+
await this.diagnostics.guardAsync("storage.degraded", "clearing", () => this.db.clear());
|
|
136
|
+
}
|
|
137
|
+
async close() {
|
|
138
|
+
await this.diagnostics.guardAsync("storage.degraded", "closing the database", () => this.db.close());
|
|
139
|
+
}
|
|
140
|
+
reportGap(e) {
|
|
141
|
+
e.batches !== 0 && (this.diagnostics.report("storage.evicted", `dropped ${String(e.batches)} stored batches (${String(e.records)} records)`, { ...e }), this.onGap?.(e));
|
|
142
|
+
}
|
|
143
|
+
async evictOldest(e) {
|
|
144
|
+
let t = await this.db.takeOldest(e);
|
|
145
|
+
return await this.db.deleteMany(t.map((e) => e.id)), {
|
|
146
|
+
batches: t.length,
|
|
147
|
+
records: o(t)
|
|
148
|
+
};
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
//#endregion
|
|
152
|
+
export { s as IndexedDbStorage };
|
|
153
|
+
|
|
154
|
+
//# sourceMappingURL=indexeddb-storage-DAoHV_oL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"indexeddb-storage-DAoHV_oL.js","names":[],"sources":["../src/storage/idb-driver.ts","../src/storage/indexeddb-storage.ts"],"sourcesContent":["// src/storage/idb-driver.ts\n//\n// Raw IndexedDB mechanics for the batch store: opening, request promises, and the\n// createdAt-ordered reads. Everything above this file works in batches and ids.\n\nimport {\n INDEXEDDB_CREATED_AT_INDEX,\n INDEXEDDB_SCHEMA_VERSION,\n INDEXEDDB_STORE_NAME,\n} from \"../constants\";\nimport type { LogBatch } from \"../models/batch\";\n\n/**\n * Reads the failure off a request that has errored. A host whose request reports\n * no error gets a stand-in: rejecting with null makes the instanceof Error test\n * in save() false, and a full disk is then reported as an ordinary write failure.\n * @param request Request that fired onerror.\n * @returns The failure that stopped it.\n */\nfunction failureOf(request: IDBRequest): Error {\n return request.error ?? new Error(\"the IndexedDB request failed\");\n}\n\n/**\n * Resolves when an IndexedDB request succeeds and rejects with its error. The\n * request is read as IDBRequest<any>, so every caller names the type it expects.\n * @param request Request to await.\n * @returns The request result.\n */\nfunction promisify<T>(request: IDBRequest): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n request.onsuccess = () => {\n resolve(request.result as T);\n };\n request.onerror = () => {\n reject(failureOf(request));\n };\n });\n}\n\n/** One IndexedDB database holding undelivered batches keyed by id. */\nexport class IdbDriver {\n /** Open in progress or completed, reused so one database is opened per driver. */\n private connection: Promise<IDBDatabase> | null = null;\n\n /**\n * @param name IndexedDB database name.\n */\n constructor(private readonly name: string) {}\n\n /**\n * Writes a batch, replacing any batch already stored under the same id.\n * @param batch Batch to persist.\n */\n async put(batch: LogBatch): Promise<void> {\n const store = await this.store(\"readwrite\");\n await promisify(store.put(batch));\n }\n\n /**\n * Reads the oldest batches by createdAt without removing them.\n * @param limit Maximum number of batches to return.\n * @returns Batches in ascending createdAt order.\n */\n async takeOldest(limit: number): Promise<LogBatch[]> {\n const store = await this.store(\"readonly\");\n return promisify<LogBatch[]>(store.index(INDEXEDDB_CREATED_AT_INDEX).getAll(null, limit));\n }\n\n /**\n * Reads every batch created strictly before a cutoff.\n * @param cutoff Exclusive upper bound in epoch milliseconds.\n * @returns Batches older than the cutoff.\n */\n async takeBefore(cutoff: number): Promise<LogBatch[]> {\n const store = await this.store(\"readonly\");\n const range = IDBKeyRange.upperBound(cutoff, true);\n return promisify<LogBatch[]>(store.index(INDEXEDDB_CREATED_AT_INDEX).getAll(range));\n }\n\n /**\n * Deletes one batch. An id that is not stored resolves without error.\n * @param id Batch identifier.\n */\n async delete(id: string): Promise<void> {\n const store = await this.store(\"readwrite\");\n await promisify(store.delete(id));\n }\n\n /**\n * Deletes several batches in one transaction, so a partial failure leaves none\n * of them deleted.\n * @param ids Batch identifiers.\n */\n async deleteMany(ids: string[]): Promise<void> {\n const store = await this.store(\"readwrite\");\n await Promise.all(ids.map((id) => promisify(store.delete(id))));\n }\n\n /**\n * Rewrites the attempt count of a stored batch. An id that is not stored is\n * left alone: a batch already delivered and deleted must not be resurrected.\n * @param id Batch identifier.\n * @param attempts New absolute attempt count.\n */\n async bumpAttempts(id: string, attempts: number): Promise<void> {\n const read = await this.store(\"readonly\");\n const batch = await promisify<LogBatch | undefined>(read.get(id));\n if (batch === undefined) {\n return;\n }\n\n const write = await this.store(\"readwrite\");\n await promisify(write.put({ ...batch, attempts }));\n }\n\n /**\n * Counts stored batches.\n * @returns Total batch count.\n */\n async count(): Promise<number> {\n const store = await this.store(\"readonly\");\n return promisify<number>(store.count());\n }\n\n /** Deletes every stored batch. */\n async clear(): Promise<void> {\n const store = await this.store(\"readwrite\");\n await promisify(store.clear());\n }\n\n /** Closes the connection, if one was ever opened. */\n async close(): Promise<void> {\n const connection = this.connection;\n if (connection === null) {\n return;\n }\n\n this.connection = null;\n const db = await connection;\n db.close();\n }\n\n /**\n * Opens the batch store in a fresh transaction. A transaction is only valid\n * until control returns to the event loop, so every call takes a new one.\n * @param mode Transaction mode.\n * @returns The batch object store.\n */\n private async store(mode: IDBTransactionMode): Promise<IDBObjectStore> {\n const db = await this.open();\n return db.transaction(INDEXEDDB_STORE_NAME, mode).objectStore(INDEXEDDB_STORE_NAME);\n }\n\n /**\n * Opens the database once and hands the same connection to every later call.\n * @returns The open database.\n */\n private open(): Promise<IDBDatabase> {\n const existing = this.connection;\n if (existing !== null) {\n return existing;\n }\n\n const opening = new Promise<IDBDatabase>((resolve, reject) => {\n const request = indexedDB.open(this.name, INDEXEDDB_SCHEMA_VERSION);\n\n request.onupgradeneeded = () => {\n const db = request.result;\n // A database written by an earlier release already carries the store.\n // Creating it again throws ConstraintError and the upgrade aborts.\n if (!db.objectStoreNames.contains(INDEXEDDB_STORE_NAME)) {\n const store = db.createObjectStore(INDEXEDDB_STORE_NAME, { keyPath: \"id\" });\n store.createIndex(INDEXEDDB_CREATED_AT_INDEX, INDEXEDDB_CREATED_AT_INDEX);\n }\n };\n\n request.onsuccess = () => {\n resolve(request.result);\n };\n request.onerror = () => {\n reject(failureOf(request));\n };\n });\n\n this.connection = opening;\n return opening;\n }\n}\n","// src/storage/indexeddb-storage.ts\n//\n// Persistent storage adapter backed by IndexedDB with time-ordered indexing.\n\nimport { QUOTA_EVICTION_DIVISOR, QUOTA_EXCEEDED_ERROR, STORAGE_NAME_INDEXEDDB } from \"../constants\";\nimport type { Diagnostics } from \"../core/diagnostics\";\nimport type { LogBatch } from \"../models/batch\";\nimport type { GapReporter, PruneResult, StorageAdapter, StorageLimits } from \"../models/storage\";\nimport { IdbDriver } from \"./idb-driver\";\n\n/**\n * Sums the total count of records contained across an array of batches.\n * @param batches Batches to measure.\n * @returns Total record count.\n */\nfunction countRecords(batches: LogBatch[]): number {\n return batches.reduce((total, batch) => total + batch.records.length, 0);\n}\n\n/** Persistent StorageAdapter implementation backed by IndexedDB. */\nexport class IndexedDbStorage implements StorageAdapter {\n /** Storage adapter strategy name. */\n readonly name = STORAGE_NAME_INDEXEDDB;\n\n /** IndexedDB mechanics for the batch store. */\n private readonly db: IdbDriver;\n\n /**\n * @param dbName Database name.\n * @param limits Storage capacity and retention thresholds.\n * @param diagnostics Diagnostics reporter.\n * @param onGap Optional callback for dropped record reporting.\n */\n constructor(\n dbName: string,\n private readonly limits: StorageLimits,\n private readonly diagnostics: Diagnostics,\n private readonly onGap?: GapReporter,\n ) {\n this.db = new IdbDriver(dbName);\n }\n\n /**\n * Persists a batch to IndexedDB and triggers storage pruning.\n * @param batch Batch to store.\n */\n async save(batch: LogBatch): Promise<void> {\n try {\n await this.db.put(batch);\n await this.prune();\n } catch (error) {\n if (error instanceof Error && error.name === QUOTA_EXCEEDED_ERROR) {\n this.diagnostics.report(\"storage.quota_exceeded\", \"IndexedDB is full, evicting the oldest\");\n const evicted = await this.diagnostics.guardAsync(\n \"storage.degraded\",\n \"evicting after a full disk\",\n () => this.evictOldest(Math.ceil(this.limits.maxBatches / QUOTA_EVICTION_DIVISOR)),\n );\n if (evicted) {\n this.reportGap({ ...evicted, reason: \"quota\" });\n }\n return;\n }\n\n this.diagnostics.report(\n \"storage.degraded\",\n \"could not persist a batch\",\n { batchId: batch.id },\n error,\n );\n }\n }\n\n /**\n * Reads up to limit batches in chronological order without deletion.\n * @param limit Maximum number of batches to retrieve.\n * @returns Array of retrieved batches.\n */\n async take(limit: number): Promise<LogBatch[]> {\n const batches = await this.diagnostics.guardAsync(\n \"storage.degraded\",\n \"reading stored batches\",\n () => this.db.takeOldest(limit),\n );\n return batches ?? [];\n }\n\n /**\n * Deletes a batch from IndexedDB by ID.\n * @param id Batch identifier to delete.\n */\n async remove(id: string): Promise<void> {\n await this.diagnostics.guardAsync(\"storage.degraded\", \"deleting a batch\", () =>\n this.db.delete(id),\n );\n }\n\n /**\n * Updates delivery attempt count for a stored batch.\n * @param id Batch identifier.\n * @param attempts New absolute attempt count.\n */\n async bumpAttempts(id: string, attempts: number): Promise<void> {\n await this.diagnostics.guardAsync(\"storage.degraded\", \"updating attempts\", () =>\n this.db.bumpAttempts(id, attempts),\n );\n }\n\n /**\n * Removes expired batches and evicts oldest entries exceeding capacity.\n * @returns Prune summary metrics.\n */\n async prune(): Promise<PruneResult> {\n const result: PruneResult = { batches: 0, records: 0, reason: \"expired\" };\n\n await this.diagnostics.guardAsync(\"storage.degraded\", \"pruning\", async () => {\n const cutoff = Date.now() - this.limits.maxAgeMs;\n const expired = await this.db.takeBefore(cutoff);\n if (expired.length > 0) {\n await this.db.deleteMany(expired.map((batch) => batch.id));\n result.batches += expired.length;\n result.records += countRecords(expired);\n }\n\n const total = await this.db.count();\n if (total > this.limits.maxBatches) {\n result.reason = \"over_capacity\";\n const evicted = await this.evictOldest(total - this.limits.maxBatches);\n result.batches += evicted.batches;\n result.records += evicted.records;\n }\n });\n\n this.reportGap(result);\n return result;\n }\n\n /**\n * Returns total count of stored batches.\n * @returns Total batch count or 0 on failure.\n */\n async count(): Promise<number> {\n const total = await this.diagnostics.guardAsync(\"storage.degraded\", \"counting\", () =>\n this.db.count(),\n );\n return total ?? 0;\n }\n\n /** Deletes all stored batches from the database. */\n async clear(): Promise<void> {\n await this.diagnostics.guardAsync(\"storage.degraded\", \"clearing\", () => this.db.clear());\n }\n\n /** Closes the active IndexedDB connection. */\n async close(): Promise<void> {\n await this.diagnostics.guardAsync(\"storage.degraded\", \"closing the database\", () =>\n this.db.close(),\n );\n }\n\n /**\n * Reports dropped records to diagnostics and registered gap handlers.\n * @param result Prune result metrics.\n */\n private reportGap(result: PruneResult): void {\n if (result.batches === 0) {\n return;\n }\n\n this.diagnostics.report(\n \"storage.evicted\",\n `dropped ${String(result.batches)} stored batches (${String(result.records)} records)`,\n { ...result },\n );\n this.onGap?.(result);\n }\n\n /**\n * Deletes a specified count of the oldest stored batches. Unguarded: both callers\n * guard it, and swallowing the failure here reports an eviction that did not\n * happen.\n * @param howMany Number of oldest batches to evict.\n * @returns Metrics of evicted batches and records.\n */\n private async evictOldest(howMany: number): Promise<Omit<PruneResult, \"reason\">> {\n const doomed = await this.db.takeOldest(howMany);\n await this.db.deleteMany(doomed.map((batch) => batch.id));\n\n return { batches: doomed.length,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,CAAC,GACzD,EAAO,WAAW,EAAQ,QAC1B,EAAO,WAAW,EAAa,CAAO;GAGxC,IAAM,IAAQ,MAAM,KAAK,GAAG,MAAM;GAClC,IAAI,IAAQ,KAAK,OAAO,YAAY;IAClC,EAAO,SAAS;IAChB,IAAM,IAAU,MAAM,KAAK,YAAY,IAAQ,KAAK,OAAO,UAAU;IAErE,AADA,EAAO,WAAW,EAAQ,SAC1B,EAAO,WAAW,EAAQ;GAC5B;EACF,CAAC,GAED,KAAK,UAAU,CAAM,GACd;CACT;CAMA,MAAM,QAAyB;EAI7B,OAAO,MAHa,KAAK,YAAY,WAAW,oBAAoB,kBAClE,KAAK,GAAG,MAAM,CAChB,KACgB;CAClB;CAGA,MAAM,QAAuB;EAC3B,MAAM,KAAK,YAAY,WAAW,oBAAoB,kBAAkB,KAAK,GAAG,MAAM,CAAC;CACzF;CAGA,MAAM,QAAuB;EAC3B,MAAM,KAAK,YAAY,WAAW,oBAAoB,8BACpD,KAAK,GAAG,MAAM,CAChB;CACF;CAMA,UAAkB,GAA2B;EACvC,EAAO,YAAY,MAIvB,KAAK,YAAY,OACf,mBACA,WAAW,OAAO,EAAO,OAAO,EAAE,mBAAmB,OAAO,EAAO,OAAO,EAAE,YAC5E,EAAE,GAAG,EAAO,CACd,GACA,KAAK,QAAQ,CAAM;CACrB;CASA,MAAc,YAAY,GAAuD;EAC/E,IAAM,IAAS,MAAM,KAAK,GAAG,WAAW,CAAO;EAG/C,OAFA,MAAM,KAAK,GAAG,WAAW,EAAO,KAAK,MAAU,EAAM,EAAE,CAAC,GAEjD;GAAE,SAAS,EAAO;GAAQ,SAAS,EAAa,CAAM;EAAE;CACjE;AACF"}
|
package/dist/models/config.d.ts
CHANGED
|
@@ -47,66 +47,6 @@ export interface WebVitalsModule {
|
|
|
47
47
|
*/
|
|
48
48
|
onTTFB: (report: WebVitalsReporter) => void;
|
|
49
49
|
}
|
|
50
|
-
/** Batching policy for one record stream (logs or metrics). */
|
|
51
|
-
export interface StreamOptions {
|
|
52
|
-
/** Max time a partial batch waits before it is sent, in milliseconds. */
|
|
53
|
-
flushIntervalMs: number;
|
|
54
|
-
/** Max records per batch before it is sent early. */
|
|
55
|
-
batchSize: number;
|
|
56
|
-
}
|
|
57
|
-
/** The two record streams, batched independently. */
|
|
58
|
-
export interface StreamsOptions {
|
|
59
|
-
/** Log stream batching. */
|
|
60
|
-
logs: StreamOptions;
|
|
61
|
-
/** Metric stream batching. */
|
|
62
|
-
metrics: StreamOptions;
|
|
63
|
-
}
|
|
64
|
-
/** Storage policy for undelivered records. */
|
|
65
|
-
export interface StorageOptions {
|
|
66
|
-
/**
|
|
67
|
-
* Backing store.
|
|
68
|
-
* @default "auto"
|
|
69
|
-
*/
|
|
70
|
-
strategy: StorageStrategy;
|
|
71
|
-
/**
|
|
72
|
-
* IndexedDB database name. Used only when the strategy resolves to indexeddb.
|
|
73
|
-
* @default "UiObservability"
|
|
74
|
-
*/
|
|
75
|
-
dbName: string;
|
|
76
|
-
/**
|
|
77
|
-
* Max batches held at once. Oldest are evicted past this.
|
|
78
|
-
* @default 500
|
|
79
|
-
*/
|
|
80
|
-
maxBatches: number;
|
|
81
|
-
/**
|
|
82
|
-
* Max batch age before it is dropped rather than retried, in milliseconds.
|
|
83
|
-
* @default 24 * 60 * 60 * 1000
|
|
84
|
-
*/
|
|
85
|
-
maxAgeMs: number;
|
|
86
|
-
/**
|
|
87
|
-
* Max delivery attempts before a batch is dead-lettered.
|
|
88
|
-
* @default 5
|
|
89
|
-
*/
|
|
90
|
-
maxAttempts: number;
|
|
91
|
-
}
|
|
92
|
-
/** Backoff schedule for redelivering a stored batch. */
|
|
93
|
-
export interface RetryOptions {
|
|
94
|
-
/**
|
|
95
|
-
* First backoff step, in milliseconds. Each attempt doubles it.
|
|
96
|
-
* @default 2000
|
|
97
|
-
*/
|
|
98
|
-
baseDelayMs: number;
|
|
99
|
-
/**
|
|
100
|
-
* Backoff ceiling, in milliseconds.
|
|
101
|
-
* @default 60000
|
|
102
|
-
*/
|
|
103
|
-
maxDelayMs: number;
|
|
104
|
-
/**
|
|
105
|
-
* How often to check for stored work when nothing has failed recently, in milliseconds.
|
|
106
|
-
* @default 30000
|
|
107
|
-
*/
|
|
108
|
-
idleDelayMs: number;
|
|
109
|
-
}
|
|
110
50
|
/** Sampling policy: which records survive. */
|
|
111
51
|
export interface SamplingOptions {
|
|
112
52
|
/**
|
|
@@ -120,29 +60,11 @@ export interface SamplingOptions {
|
|
|
120
60
|
*/
|
|
121
61
|
rates: Record<string, number>;
|
|
122
62
|
/**
|
|
123
|
-
* Log types always kept, regardless of sampling rate.
|
|
63
|
+
* Log types always kept, regardless of the sampling rate.
|
|
124
64
|
* @default ["action"]
|
|
125
65
|
*/
|
|
126
66
|
alwaysSampleTypes: string[];
|
|
127
67
|
}
|
|
128
|
-
/** Lifetime rules for a journey (one user task spanning several contexts). */
|
|
129
|
-
export interface JourneyOptions {
|
|
130
|
-
/**
|
|
131
|
-
* Max time a journey stays open before it's treated as abandoned, in milliseconds.
|
|
132
|
-
* @default 30 * 60 * 1000
|
|
133
|
-
*/
|
|
134
|
-
maxAgeMs: number;
|
|
135
|
-
/**
|
|
136
|
-
* Whether closing the owning context ends the journey for everyone.
|
|
137
|
-
* @default false
|
|
138
|
-
*/
|
|
139
|
-
endOnOwnerClose: boolean;
|
|
140
|
-
/**
|
|
141
|
-
* Query parameter checked at boot for a seeded journey token.
|
|
142
|
-
* @default "__uiobs_journey"
|
|
143
|
-
*/
|
|
144
|
-
urlParam: string;
|
|
145
|
-
}
|
|
146
68
|
/** Bus settings: how this context discovers, trusts, and messages the others. */
|
|
147
69
|
export interface BusOptions {
|
|
148
70
|
/**
|
|
@@ -150,26 +72,11 @@ export interface BusOptions {
|
|
|
150
72
|
* @default "auto"
|
|
151
73
|
*/
|
|
152
74
|
mode: BusMode;
|
|
153
|
-
/**
|
|
154
|
-
* BroadcastChannel name for the control plane.
|
|
155
|
-
* @default "ui_observability_control"
|
|
156
|
-
*/
|
|
157
|
-
channelName: string;
|
|
158
75
|
/**
|
|
159
76
|
* Origins allowed to send postMessage records to this document. Required for any document receiving them from a cross-origin iframe.
|
|
160
77
|
* @default []
|
|
161
78
|
*/
|
|
162
79
|
trustedOrigins: string[];
|
|
163
|
-
/**
|
|
164
|
-
* Max time a forwarder waits for an owner to answer before applying the orphan policy, in milliseconds.
|
|
165
|
-
* @default 1500
|
|
166
|
-
*/
|
|
167
|
-
handshakeTimeoutMs: number;
|
|
168
|
-
/**
|
|
169
|
-
* Which OpenFin context owns delivery.
|
|
170
|
-
* @default "provider"
|
|
171
|
-
*/
|
|
172
|
-
openFinHost: "provider" | "self";
|
|
173
80
|
/**
|
|
174
81
|
* Which OpenFin context this is. Only the platform provider answers a
|
|
175
82
|
* handshake, so setting this wrong makes every view send for itself.
|
|
@@ -178,25 +85,8 @@ export interface BusOptions {
|
|
|
178
85
|
* @default "auto"
|
|
179
86
|
*/
|
|
180
87
|
openFinRole: "auto" | "provider" | "client";
|
|
181
|
-
/**
|
|
182
|
-
* Max records a context buffers before its bus role is determined.
|
|
183
|
-
* @default 500
|
|
184
|
-
*/
|
|
185
|
-
maxBootBufferRecords: number;
|
|
186
|
-
/**
|
|
187
|
-
* Forwarder behavior when no owner answers: `auto` retries in a
|
|
188
|
-
* cross-origin frame and promotes elsewhere, `promote` becomes a sender
|
|
189
|
-
* immediately, `retry` retries then promotes as a last resort.
|
|
190
|
-
* @default "auto"
|
|
191
|
-
*/
|
|
192
|
-
orphanPolicy: "auto" | "promote" | "retry";
|
|
193
|
-
/**
|
|
194
|
-
* Handshake attempts allowed before promoting under the "retry" policy.
|
|
195
|
-
* @default 3
|
|
196
|
-
*/
|
|
197
|
-
maxHandshakeAttempts: number;
|
|
198
88
|
}
|
|
199
|
-
/** What the library instruments automatically. Everything but errors is off by default. */
|
|
89
|
+
/** What the library instruments automatically. Everything but errors and rejections is off by default. */
|
|
200
90
|
export interface CaptureOptions {
|
|
201
91
|
/**
|
|
202
92
|
* Log uncaught errors from `window.onerror`.
|
|
@@ -238,11 +128,6 @@ export interface CaptureOptions {
|
|
|
238
128
|
* @default false
|
|
239
129
|
*/
|
|
240
130
|
webVitals: boolean;
|
|
241
|
-
/**
|
|
242
|
-
* Breadcrumbs kept as context for the next error.
|
|
243
|
-
* @default 50
|
|
244
|
-
*/
|
|
245
|
-
maxBreadcrumbs: number;
|
|
246
131
|
/**
|
|
247
132
|
* URLs excluded from logging. The ingest endpoint is always included.
|
|
248
133
|
* @default []
|
|
@@ -253,68 +138,14 @@ export interface CaptureOptions {
|
|
|
253
138
|
* @default []
|
|
254
139
|
*/
|
|
255
140
|
propagateTraceHeaderTo: (string | RegExp)[];
|
|
256
|
-
/**
|
|
257
|
-
* Window within which identical errors are counted but not re-sent, in milliseconds.
|
|
258
|
-
* @default 5000
|
|
259
|
-
*/
|
|
260
|
-
errorDedupeMs: number;
|
|
261
141
|
/**
|
|
262
142
|
* Supplies the `web-vitals` module without a hard dependency on the package.
|
|
263
143
|
* @returns A promise resolving to the `web-vitals` module.
|
|
264
144
|
*/
|
|
265
145
|
webVitalsLoader?: () => Promise<WebVitalsModule>;
|
|
266
146
|
}
|
|
267
|
-
/**
|
|
268
|
-
export
|
|
269
|
-
/**
|
|
270
|
-
* Max record body length, in characters.
|
|
271
|
-
* @default 4096
|
|
272
|
-
*/
|
|
273
|
-
maxBodyChars: number;
|
|
274
|
-
/**
|
|
275
|
-
* Max length of a single string attribute, in characters.
|
|
276
|
-
* @default 8192
|
|
277
|
-
*/
|
|
278
|
-
maxAttributeChars: number;
|
|
279
|
-
/**
|
|
280
|
-
* Max attributes per record.
|
|
281
|
-
* @default 128
|
|
282
|
-
*/
|
|
283
|
-
maxAttributeCount: number;
|
|
284
|
-
/**
|
|
285
|
-
* Max stack trace length, in characters. Larger than `maxAttributeChars`.
|
|
286
|
-
* @default 8192
|
|
287
|
-
*/
|
|
288
|
-
maxStackChars: number;
|
|
289
|
-
/**
|
|
290
|
-
* Max depth walked into a nested value before truncating.
|
|
291
|
-
* @default 6
|
|
292
|
-
*/
|
|
293
|
-
maxDepth: number;
|
|
294
|
-
/**
|
|
295
|
-
* Max items kept from an array, set, or map.
|
|
296
|
-
* @default 100
|
|
297
|
-
*/
|
|
298
|
-
maxArrayLength: number;
|
|
299
|
-
/**
|
|
300
|
-
* Max total attribute bytes per record, checked after sanitize and redact.
|
|
301
|
-
* @default 32768
|
|
302
|
-
*/
|
|
303
|
-
maxRecordBytes: number;
|
|
304
|
-
}
|
|
305
|
-
/** Console mirroring, for development. */
|
|
306
|
-
export interface ConsoleOptions {
|
|
307
|
-
/**
|
|
308
|
-
* Whether to mirror at all.
|
|
309
|
-
* @default false
|
|
310
|
-
*/
|
|
311
|
-
enabled: boolean;
|
|
312
|
-
/**
|
|
313
|
-
* Min level to mirror. Independent of `minLevel`.
|
|
314
|
-
* @default "DEBUG"
|
|
315
|
-
*/
|
|
316
|
-
level: LogLevel;
|
|
317
|
-
}
|
|
147
|
+
/** Console mirroring. `false` is off, `true` mirrors from DEBUG, a level mirrors from that level up. */
|
|
148
|
+
export type ConsoleOption = boolean | LogLevel;
|
|
318
149
|
/** Options passed to `configure()`. Only `endpoint` is required. */
|
|
319
150
|
export interface ObservabilityConfig {
|
|
320
151
|
/** Ingest endpoint URL. Required. */
|
|
@@ -344,39 +175,11 @@ export interface ObservabilityConfig {
|
|
|
344
175
|
* @default "INFO"
|
|
345
176
|
*/
|
|
346
177
|
minLevel?: LogLevel;
|
|
347
|
-
/**
|
|
348
|
-
|
|
349
|
-
/**
|
|
350
|
-
* Log stream batching.
|
|
351
|
-
* @default { flushIntervalMs: 2000, batchSize: 100 }
|
|
352
|
-
*/
|
|
353
|
-
logs?: Partial<StreamOptions>;
|
|
354
|
-
/**
|
|
355
|
-
* Metric stream batching.
|
|
356
|
-
* @default { flushIntervalMs: 10000, batchSize: 500 }
|
|
357
|
-
*/
|
|
358
|
-
metrics?: Partial<StreamOptions>;
|
|
359
|
-
};
|
|
360
|
-
/**
|
|
361
|
-
* Max concurrent ingest requests, across both streams.
|
|
362
|
-
* @default 2
|
|
363
|
-
*/
|
|
364
|
-
maxConcurrentRequests?: number;
|
|
365
|
-
/**
|
|
366
|
-
* Max time one ingest request may take before it is aborted and retried, in milliseconds.
|
|
367
|
-
* @default 15000
|
|
368
|
-
*/
|
|
369
|
-
requestTimeoutMs?: number;
|
|
370
|
-
/**
|
|
371
|
-
* Whether to gzip a payload past `compressionThresholdBytes`.
|
|
178
|
+
/**
|
|
179
|
+
* Whether to gzip a payload past the compression threshold. Set "none" for an ingest endpoint that rejects gzip.
|
|
372
180
|
* @default "gzip"
|
|
373
181
|
*/
|
|
374
182
|
compression?: "gzip" | "none";
|
|
375
|
-
/**
|
|
376
|
-
* Min payload size to compress, in bytes.
|
|
377
|
-
* @default 1024
|
|
378
|
-
*/
|
|
379
|
-
compressionThresholdBytes?: number;
|
|
380
183
|
/**
|
|
381
184
|
* Wire format: a name, or a custom implementation.
|
|
382
185
|
* @default "otlp"
|
|
@@ -390,25 +193,15 @@ export interface ObservabilityConfig {
|
|
|
390
193
|
/** Extra request headers, or a function returning them. */
|
|
391
194
|
headers?: Record<string, string> | (() => Record<string, string> | Promise<Record<string, string>>);
|
|
392
195
|
/**
|
|
393
|
-
*
|
|
394
|
-
* @
|
|
395
|
-
*/
|
|
396
|
-
storage?: Partial<StorageOptions>;
|
|
397
|
-
/**
|
|
398
|
-
* Backoff schedule for redelivering them.
|
|
399
|
-
* @see {@link RetryOptions}
|
|
196
|
+
* Backing store for undelivered records.
|
|
197
|
+
* @default "auto"
|
|
400
198
|
*/
|
|
401
|
-
|
|
199
|
+
storage?: StorageStrategy;
|
|
402
200
|
/**
|
|
403
201
|
* Sampling policy.
|
|
404
202
|
* @see {@link SamplingOptions}
|
|
405
203
|
*/
|
|
406
204
|
sampling?: Partial<SamplingOptions>;
|
|
407
|
-
/**
|
|
408
|
-
* Journey lifetime rules.
|
|
409
|
-
* @see {@link JourneyOptions}
|
|
410
|
-
*/
|
|
411
|
-
journey?: Partial<JourneyOptions>;
|
|
412
205
|
/**
|
|
413
206
|
* Bus discovery, trust, and messaging settings.
|
|
414
207
|
* @see {@link BusOptions}
|
|
@@ -420,15 +213,10 @@ export interface ObservabilityConfig {
|
|
|
420
213
|
*/
|
|
421
214
|
capture?: Partial<CaptureOptions>;
|
|
422
215
|
/**
|
|
423
|
-
*
|
|
424
|
-
* @
|
|
425
|
-
*/
|
|
426
|
-
limits?: Partial<LimitOptions>;
|
|
427
|
-
/**
|
|
428
|
-
* Console mirroring.
|
|
429
|
-
* @see {@link ConsoleOptions}
|
|
216
|
+
* Console mirroring, for development.
|
|
217
|
+
* @default false
|
|
430
218
|
*/
|
|
431
|
-
console?:
|
|
219
|
+
console?: ConsoleOption;
|
|
432
220
|
/**
|
|
433
221
|
* Rewrites or drops a record before it's sent.
|
|
434
222
|
* @param record The record about to be sent.
|
|
@@ -455,41 +243,17 @@ export interface ResolvedConfig {
|
|
|
455
243
|
enabled: boolean;
|
|
456
244
|
/** Min level logged. */
|
|
457
245
|
minLevel: LogLevel;
|
|
458
|
-
/**
|
|
459
|
-
* Per-stream batching.
|
|
460
|
-
* @see {@link StreamsOptions}
|
|
461
|
-
*/
|
|
462
|
-
streams: StreamsOptions;
|
|
463
|
-
/** Max concurrent ingest requests, across both streams. */
|
|
464
|
-
maxConcurrentRequests: number;
|
|
465
|
-
/** Max time one ingest request may take before it is aborted and retried, in milliseconds. */
|
|
466
|
-
requestTimeoutMs: number;
|
|
467
|
-
/** Whether to gzip a payload past `compressionThresholdBytes`. */
|
|
246
|
+
/** Whether to gzip a payload past the compression threshold. */
|
|
468
247
|
compression: "gzip" | "none";
|
|
469
|
-
/** Min payload size to compress, in bytes. */
|
|
470
|
-
compressionThresholdBytes: number;
|
|
471
248
|
/** Passed to `fetch`. */
|
|
472
249
|
credentials: RequestCredentials;
|
|
473
|
-
/**
|
|
474
|
-
|
|
475
|
-
* @see {@link StorageOptions}
|
|
476
|
-
*/
|
|
477
|
-
storage: StorageOptions;
|
|
478
|
-
/**
|
|
479
|
-
* Backoff schedule for redelivering a stored batch.
|
|
480
|
-
* @see {@link RetryOptions}
|
|
481
|
-
*/
|
|
482
|
-
retry: RetryOptions;
|
|
250
|
+
/** Backing store for undelivered records. */
|
|
251
|
+
storage: StorageStrategy;
|
|
483
252
|
/**
|
|
484
253
|
* Sampling policy.
|
|
485
254
|
* @see {@link SamplingOptions}
|
|
486
255
|
*/
|
|
487
256
|
sampling: SamplingOptions;
|
|
488
|
-
/**
|
|
489
|
-
* Journey lifetime rules.
|
|
490
|
-
* @see {@link JourneyOptions}
|
|
491
|
-
*/
|
|
492
|
-
journey: JourneyOptions;
|
|
493
257
|
/**
|
|
494
258
|
* Bus discovery, trust, and messaging settings.
|
|
495
259
|
* @see {@link BusOptions}
|
|
@@ -500,16 +264,8 @@ export interface ResolvedConfig {
|
|
|
500
264
|
* @see {@link CaptureOptions}
|
|
501
265
|
*/
|
|
502
266
|
capture: CaptureOptions;
|
|
503
|
-
/**
|
|
504
|
-
|
|
505
|
-
* @see {@link LimitOptions}
|
|
506
|
-
*/
|
|
507
|
-
limits: LimitOptions;
|
|
508
|
-
/**
|
|
509
|
-
* Console mirroring.
|
|
510
|
-
* @see {@link ConsoleOptions}
|
|
511
|
-
*/
|
|
512
|
-
console: ConsoleOptions;
|
|
267
|
+
/** Min level mirrored to the console, or null when mirroring is off. */
|
|
268
|
+
console: LogLevel | null;
|
|
513
269
|
/** Wire format implementation, resolved from a name or passed directly. */
|
|
514
270
|
serializer: LogSerializer;
|
|
515
271
|
/** Extra request headers, or a function returning them. */
|