@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,55 @@
1
+ import type { Diagnostics } from "../core/diagnostics";
2
+ /** W3C trace context fields attached to log records and network headers. */
3
+ export interface TraceContext {
4
+ /** Hexadecimal 32-character W3C trace identifier. */
5
+ traceId: string;
6
+ /** Hexadecimal 16-character W3C span identifier. */
7
+ spanId: string;
8
+ /** Bitfield byte containing W3C trace flags. */
9
+ traceFlags: number;
10
+ }
11
+ /** Trigger classification for rotating the ambient trace context. */
12
+ export type RotateReason = "start" | "interaction" | "navigation" | "explicit" | "maxAge";
13
+ /**
14
+ * Generates a random 32-character hex string conforming to W3C trace ID format.
15
+ * Exported for callers starting their own trace. A wrong-width id is dropped by
16
+ * the backend without a word.
17
+ * @returns 32-character hexadecimal trace ID.
18
+ */
19
+ export declare function newTraceId(): string;
20
+ /**
21
+ * Generates a random 16-character hex string conforming to W3C span ID format.
22
+ * @returns 16-character hexadecimal span ID.
23
+ */
24
+ export declare function newSpanId(): string;
25
+ /** Manages ambient distributed trace contexts and resolves active OpenTelemetry spans. */
26
+ export declare class TraceEngine {
27
+ private readonly diagnostics;
28
+ private readonly maxAgeMs;
29
+ /**
30
+ * Active ambient trace context. Instance state, never module state. Two runtimes
31
+ * in one document must not share a trace id.
32
+ */
33
+ private ambient;
34
+ /**
35
+ * @param diagnostics Diagnostics reporter.
36
+ * @param maxAgeMs Maximum lifetime of an un-rotated ambient trace in milliseconds.
37
+ */
38
+ constructor(diagnostics: Diagnostics, maxAgeMs?: number);
39
+ /**
40
+ * Resolves trace context, prioritizing active OpenTelemetry spans over the ambient trace.
41
+ * @returns Active TraceContext.
42
+ */
43
+ resolve(): TraceContext;
44
+ /**
45
+ * Rotates the ambient trace context to mark the start of a new logical operation.
46
+ * @param _reason Event reason triggering the rotation.
47
+ * @returns Newly created TraceContext.
48
+ */
49
+ rotate(_reason: RotateReason): TraceContext;
50
+ /**
51
+ * Generates W3C traceparent headers using registered OpenTelemetry propagators or ambient fallback.
52
+ * @returns Header map containing traceparent.
53
+ */
54
+ headers(): Record<string, string>;
55
+ }
@@ -0,0 +1,9 @@
1
+ /** Cross-platform timer handle representing browser numeric IDs or Node Timeout objects. */
2
+ export type TimerHandle = number | {
3
+ unref?: () => void;
4
+ };
5
+ /**
6
+ * Unreferences a timer handle to prevent it from keeping a Node.js process alive.
7
+ * @param timer Timer handle returned by setTimeout.
8
+ */
9
+ export declare function unrefTimer(timer: TimerHandle): void;
package/package.json ADDED
@@ -0,0 +1,106 @@
1
+ {
2
+ "name": "@utk09/ui-observability",
3
+ "version": "0.1.0",
4
+ "description": "UI observability and logging for browser, OpenFin and webview applications",
5
+ "license": "Apache-2.0",
6
+ "keywords": [
7
+ "observability",
8
+ "logging",
9
+ "telemetry",
10
+ "otlp",
11
+ "opentelemetry",
12
+ "browser",
13
+ "frontend",
14
+ "microfrontend",
15
+ "openfin",
16
+ "web-vitals"
17
+ ],
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/utk09-NCL/ui-observability.git"
21
+ },
22
+ "homepage": "https://github.com/utk09-NCL/ui-observability#readme",
23
+ "bugs": {
24
+ "url": "https://github.com/utk09-NCL/ui-observability/issues"
25
+ },
26
+ "publishConfig": {
27
+ "access": "public"
28
+ },
29
+ "type": "module",
30
+ "sideEffects": false,
31
+ "engines": {
32
+ "node": ">=20.19.0"
33
+ },
34
+ "files": [
35
+ "dist"
36
+ ],
37
+ "main": "./dist/index.cjs",
38
+ "module": "./dist/index.js",
39
+ "types": "./dist/index.d.ts",
40
+ "exports": {
41
+ ".": {
42
+ "types": "./dist/index.d.ts",
43
+ "import": "./dist/index.js",
44
+ "require": "./dist/index.cjs"
45
+ },
46
+ "./package.json": "./package.json"
47
+ },
48
+ "workspaces": [
49
+ "playground/react",
50
+ "playground/angular",
51
+ "playground/microfrontend/host",
52
+ "playground/microfrontend/remote-blotter",
53
+ "playground/microfrontend/remote-ticket"
54
+ ],
55
+ "scripts": {
56
+ "dev": "concurrently -k \"npm:dev:*\"",
57
+ "dev:vanilla": "vite",
58
+ "dev:ingest": "node tools/mock-ingest-server.mjs",
59
+ "dev:cross-origin": "vite --config vite.cross-origin.config.ts",
60
+ "example:react": "npm run dev --workspace @example/react",
61
+ "example:angular": "npm run dev --workspace @example/angular",
62
+ "example:microfrontend": "concurrently -k \"npm run dev --workspace @example/mf-blotter\" \"npm run dev --workspace @example/mf-ticket\" \"npm run dev --workspace @example/mf-host\"",
63
+ "build": "rimraf dist && tsc --project tsconfig.build.json && vite build",
64
+ "build:watch": "vite build --watch",
65
+ "lint": "eslint .",
66
+ "lint:fix": "eslint . --fix",
67
+ "format": "prettier --write .",
68
+ "format:check": "prettier --check .",
69
+ "test": "vitest run",
70
+ "test:watch": "vitest",
71
+ "test:coverage": "vitest run --coverage",
72
+ "typecheck": "tsc --noEmit",
73
+ "verify": "npm run format:check && npm run typecheck && npm run lint && npm run build && npm run test:coverage",
74
+ "prepublishOnly": "npm run verify"
75
+ },
76
+ "dependencies": {
77
+ "@opentelemetry/api": "1.9.1",
78
+ "dexie": "4.4.5",
79
+ "rxjs": "7.8.2"
80
+ },
81
+ "peerDependencies": {
82
+ "web-vitals": "^4 || ^5 || ^6"
83
+ },
84
+ "peerDependenciesMeta": {
85
+ "web-vitals": {
86
+ "optional": true
87
+ }
88
+ },
89
+ "devDependencies": {
90
+ "@eslint/js": "10.0.1",
91
+ "@types/node": "26.2.0",
92
+ "@vitest/coverage-istanbul": "4.1.11",
93
+ "concurrently": "10.0.5",
94
+ "eslint": "10.9.0",
95
+ "eslint-config-prettier": "10.1.8",
96
+ "fake-indexeddb": "6.2.5",
97
+ "happy-dom": "20.11.6",
98
+ "prettier": "3.9.6",
99
+ "rimraf": "6.1.3",
100
+ "typescript": "~5.9.3",
101
+ "typescript-eslint": "8.67.0",
102
+ "vite": "8.2.2",
103
+ "vitest": "4.1.11",
104
+ "web-vitals": "6.1.1"
105
+ }
106
+ }