@utk09/ui-observability 0.1.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.
Files changed (62) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +217 -0
  3. package/dist/bus/bus.d.ts +134 -0
  4. package/dist/bus/links.d.ts +106 -0
  5. package/dist/capture/errors.d.ts +34 -0
  6. package/dist/capture/interactions.d.ts +29 -0
  7. package/dist/capture/network.d.ts +40 -0
  8. package/dist/capture/types.d.ts +78 -0
  9. package/dist/capture/web-vitals.d.ts +21 -0
  10. package/dist/constants-D8-4Ged5.cjs +2 -0
  11. package/dist/constants-D8-4Ged5.cjs.map +1 -0
  12. package/dist/constants-DbvMIryP.js +110 -0
  13. package/dist/constants-DbvMIryP.js.map +1 -0
  14. package/dist/constants.d.ts +339 -0
  15. package/dist/core/breadcrumbs.d.ts +48 -0
  16. package/dist/core/config.d.ts +16 -0
  17. package/dist/core/context.d.ts +35 -0
  18. package/dist/core/diagnostics.d.ts +76 -0
  19. package/dist/core/journey.d.ts +112 -0
  20. package/dist/core/logger.d.ts +117 -0
  21. package/dist/core/pipeline.d.ts +75 -0
  22. package/dist/core/record.d.ts +72 -0
  23. package/dist/core/runtime.d.ts +146 -0
  24. package/dist/core/sampling.d.ts +9 -0
  25. package/dist/index.cjs +4 -0
  26. package/dist/index.cjs.map +1 -0
  27. package/dist/index.d.ts +167 -0
  28. package/dist/index.js +2577 -0
  29. package/dist/index.js.map +1 -0
  30. package/dist/indexeddb-storage-DvsvCUlO.cjs +2 -0
  31. package/dist/indexeddb-storage-DvsvCUlO.cjs.map +1 -0
  32. package/dist/indexeddb-storage-DwpCDRnX.js +88 -0
  33. package/dist/indexeddb-storage-DwpCDRnX.js.map +1 -0
  34. package/dist/models/batch.d.ts +22 -0
  35. package/dist/models/bus.d.ts +97 -0
  36. package/dist/models/config.d.ts +528 -0
  37. package/dist/models/log-record.d.ts +54 -0
  38. package/dist/models/serializer.d.ts +23 -0
  39. package/dist/models/storage.d.ts +62 -0
  40. package/dist/storage/emergency-queue.d.ts +16 -0
  41. package/dist/storage/factory.d.ts +13 -0
  42. package/dist/storage/indexeddb-storage.d.ts +69 -0
  43. package/dist/storage/keys.d.ts +8 -0
  44. package/dist/storage/local-storage.d.ts +80 -0
  45. package/dist/storage/memory-storage.d.ts +52 -0
  46. package/dist/transport/compression.d.ts +7 -0
  47. package/dist/transport/errors.d.ts +29 -0
  48. package/dist/transport/exit-flush.d.ts +63 -0
  49. package/dist/transport/http-transport.d.ts +63 -0
  50. package/dist/transport/retry-engine.d.ts +69 -0
  51. package/dist/transport/serializers/ecs.d.ts +3 -0
  52. package/dist/transport/serializers/otlp.d.ts +3 -0
  53. package/dist/utils/console.d.ts +24 -0
  54. package/dist/utils/identity.d.ts +36 -0
  55. package/dist/utils/lock.d.ts +15 -0
  56. package/dist/utils/platform.d.ts +36 -0
  57. package/dist/utils/sanitize.d.ts +47 -0
  58. package/dist/utils/sequence.d.ts +15 -0
  59. package/dist/utils/timer.d.ts +19 -0
  60. package/dist/utils/tracing.d.ts +55 -0
  61. package/dist/utils/unref.d.ts +9 -0
  62. package/package.json +106 -0
@@ -0,0 +1,167 @@
1
+ import type { WorkerLike } from "./bus/links";
2
+ import type { Journey } from "./core/journey";
3
+ import { OneLogger, type OneLoggerOptions } from "./core/logger";
4
+ import type { ObservabilityConfig } from "./models/config";
5
+ import type { MetricType } from "./models/log-record";
6
+ export { OneLogger };
7
+ export type { Journey, ObservabilityConfig, OneLoggerOptions };
8
+ export type { WorkerLike } from "./bus/links";
9
+ export type { DiagnosticCode, DiagnosticEvent } from "./core/diagnostics";
10
+ export type { LogLevel, LogRecord, LogType, MetricType } from "./models/log-record";
11
+ export type { LogSerializer, SerializedBatch } from "./models/serializer";
12
+ export type { StorageAdapter } from "./models/storage";
13
+ /**
14
+ * Initializes or reconfigures the observability runtime instance.
15
+ * @param config Consumer configuration options.
16
+ */
17
+ export declare function configure(config: Partial<ObservabilityConfig>): void;
18
+ /**
19
+ * Retrieves or creates a cached logger instance for a namespace.
20
+ * @param namespace Application subsystem or module namespace.
21
+ * @param options Scoped context merged into records emitted by this logger.
22
+ * @returns Cached OneLogger instance.
23
+ */
24
+ export declare function getLogger(namespace: string, options?: OneLoggerOptions): OneLogger;
25
+ /**
26
+ * Logs a trace-level debug record.
27
+ * @param message Detail message.
28
+ * @param payload Optional contextual attributes.
29
+ */
30
+ export declare function trace(message: string, payload?: Record<string, unknown>): void;
31
+ /**
32
+ * Logs a debug-level record.
33
+ * @param message Detail message.
34
+ * @param payload Optional contextual attributes.
35
+ */
36
+ export declare function debug(message: string, payload?: Record<string, unknown>): void;
37
+ /**
38
+ * Logs an informational record.
39
+ * @param message Informational message.
40
+ * @param payload Optional contextual attributes.
41
+ */
42
+ export declare function info(message: string, payload?: Record<string, unknown>): void;
43
+ /**
44
+ * Logs a warning record.
45
+ * @param message Warning message.
46
+ * @param payload Optional contextual attributes.
47
+ */
48
+ export declare function warn(message: string, payload?: Record<string, unknown>): void;
49
+ /**
50
+ * Logs an error record with causal error and breadcrumbs.
51
+ * @param message Error summary.
52
+ * @param err Caught error instance or reason.
53
+ * @param payload Optional contextual attributes.
54
+ */
55
+ export declare function error(message: string, err?: unknown, payload?: Record<string, unknown>): void;
56
+ /**
57
+ * Logs a discrete user interaction action.
58
+ * @param name Action identifier.
59
+ * @param payload Optional action attributes.
60
+ */
61
+ export declare function logAction(name: string, payload?: Record<string, unknown>): void;
62
+ /**
63
+ * Logs an application lifecycle or domain event.
64
+ * @param name Event identifier.
65
+ * @param payload Optional event attributes.
66
+ */
67
+ export declare function logEvent(name: string, payload?: Record<string, unknown>): void;
68
+ /**
69
+ * Logs a numerical metric measurement.
70
+ * @param name Metric identifier.
71
+ * @param value Measured value.
72
+ * @param unit Unit of measurement.
73
+ * @param type Metric type classification.
74
+ * @param attributes Optional metric attributes.
75
+ */
76
+ export declare function logMetric(name: string, value: number, unit?: string, type?: MetricType, attributes?: Record<string, unknown>): void;
77
+ /**
78
+ * Measures the execution time of a synchronous function and logs a duration metric.
79
+ * @param label Metric name prefix.
80
+ * @param fn Synchronous function to time.
81
+ * @param attributes Optional contextual attributes.
82
+ * @returns Result returned by the timed function.
83
+ */
84
+ export declare function timeSync<T>(label: string, fn: () => T, attributes?: Record<string, unknown>): T;
85
+ /**
86
+ * Measures the execution time of an asynchronous function and logs a duration metric.
87
+ * @param label Metric name prefix.
88
+ * @param fn Asynchronous function to time.
89
+ * @param attributes Optional contextual attributes.
90
+ * @returns Promise resolving to the result of the timed function.
91
+ */
92
+ export declare function timeAsync<T>(label: string, fn: () => Promise<T>, attributes?: Record<string, unknown>): Promise<T>;
93
+ /**
94
+ * Sets a key-value pair on ambient context included in subsequent records.
95
+ * @param key Attribute key.
96
+ * @param value Attribute value.
97
+ */
98
+ export declare function setContext(key: string, value: unknown): void;
99
+ /**
100
+ * Merges multiple key-value pairs into the ambient context.
101
+ * @param values Key-value map of attributes to add.
102
+ */
103
+ export declare function setContextMap(values: Record<string, unknown>): void;
104
+ /**
105
+ * Removes an attribute from the ambient context.
106
+ * @param key Attribute key to delete.
107
+ */
108
+ export declare function removeContext(key: string): void;
109
+ /**
110
+ * Starts a new journey correlation context.
111
+ * @param name Journey workflow identifier.
112
+ * @param options Configuration options including parent linking.
113
+ * @returns Started Journey instance.
114
+ */
115
+ export declare function startJourney(name: string, options?: {
116
+ parent?: boolean;
117
+ }): Journey;
118
+ /** Terminates the active journey correlation context. */
119
+ export declare function endJourney(): void;
120
+ /**
121
+ * Returns the currently active journey, or null if none is in progress.
122
+ * @returns Active Journey instance or null.
123
+ */
124
+ export declare function currentJourney(): Journey | null;
125
+ /**
126
+ * Serializes active journey metadata into a cross-context URL token.
127
+ * @returns Serialized token string, or undefined if no journey is active.
128
+ */
129
+ export declare function getJourneyToken(): string | undefined;
130
+ /**
131
+ * Adopts a serialized journey token into this application realm.
132
+ * @param token Serialized journey token.
133
+ * @returns True if token was valid and successfully adopted.
134
+ */
135
+ export declare function adoptJourney(token: string): boolean;
136
+ /**
137
+ * Connects a Web Worker or MessagePort to the document bus for record routing.
138
+ * @param worker Target Worker or MessagePort instance.
139
+ */
140
+ export declare function registerWorker(worker: WorkerLike): void;
141
+ /** Rotates trace context to begin a new distributed trace. */
142
+ export declare function startTrace(): void;
143
+ /**
144
+ * Returns W3C traceparent headers for outgoing HTTP request propagation.
145
+ * @returns Map of trace header keys and values.
146
+ */
147
+ export declare function getTraceHeaders(): Record<string, string>;
148
+ /**
149
+ * Flushes all pending log batches across pipeline streams.
150
+ * @returns Promise resolving once queued batches are processed.
151
+ */
152
+ export declare function flush(): Promise<void>;
153
+ /**
154
+ * Counts the batches waiting in storage for delivery.
155
+ * @returns Promise resolving to the number of stored batches. A forwarder reports 0, because it persists nothing.
156
+ */
157
+ export declare function getQueueDepth(): Promise<number>;
158
+ /**
159
+ * Returns a snapshot of cumulative diagnostic event counts.
160
+ * @returns Map of diagnostic fault codes to occurrence counts.
161
+ */
162
+ export declare function getDiagnosticCounters(): Record<string, number>;
163
+ /**
164
+ * Flushes pending records and tears down all runtime subsystems.
165
+ * @returns Promise resolving once shutdown completes.
166
+ */
167
+ export declare function shutdown(): Promise<void>;