@od-oneapp/observability 2026.2.1701 → 2026.2.2301-canary
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 +3 -3
- package/README.md +6 -6
- package/client-next.d.mts +6 -6
- package/client-next.mjs +4 -4
- package/client.d.mts +3 -3
- package/client.mjs +1 -1
- package/client.mjs.map +1 -1
- package/core-BKuLZf5B.mjs +95 -0
- package/core-BKuLZf5B.mjs.map +1 -0
- package/env.d.mts +2 -2
- package/env.mjs +1 -1
- package/env.mjs.map +1 -1
- package/{factory-DkY353r8.mjs → factory-CuW4AM5b.mjs} +2 -2
- package/factory-CuW4AM5b.mjs.map +1 -0
- package/hooks-useObservability.d.mts +1 -1
- package/hooks-useObservability.mjs +1 -1
- package/hooks-useObservability.mjs.map +1 -1
- package/{index-CpcdzWrF.d.mts → index-CyBL4Sra.d.mts} +3 -3
- package/{index-CpcdzWrF.d.mts.map → index-CyBL4Sra.d.mts.map} +1 -1
- package/index.mjs +1 -1
- package/index.mjs.map +1 -1
- package/{manager-BxQqOPEg.d.mts → manager-0G9cdhWY.d.mts} +2 -2
- package/{manager-BxQqOPEg.d.mts.map → manager-0G9cdhWY.d.mts.map} +1 -1
- package/package.json +53 -40
- package/{plugin-lPdJirTY.mjs → plugin-AzRcMmXa.mjs} +2 -2
- package/plugin-AzRcMmXa.mjs.map +1 -0
- package/{plugin-CP895lBx.mjs → plugin-BjJ3pgvT.mjs} +2 -2
- package/plugin-BjJ3pgvT.mjs.map +1 -0
- package/{plugin-Bfq-o3nr.d.mts → plugin-BqLvYLQZ.d.mts} +1 -1
- package/{plugin-Bfq-o3nr.d.mts.map → plugin-BqLvYLQZ.d.mts.map} +1 -1
- package/plugin-BrzKQ9II.mjs +593 -0
- package/plugin-BrzKQ9II.mjs.map +1 -0
- package/{plugin-Bt-ygG1m.d.mts → plugin-C11_suJr.d.mts} +4 -4
- package/{plugin-Bt-ygG1m.d.mts.map → plugin-C11_suJr.d.mts.map} +1 -1
- package/{plugin-CaQxviDs.d.mts → plugin-Cn23gGuY.d.mts} +2 -2
- package/{plugin-CaQxviDs.d.mts.map → plugin-Cn23gGuY.d.mts.map} +1 -1
- package/plugins-betterstack-env.mjs +1 -1
- package/plugins-betterstack-env.mjs.map +1 -1
- package/plugins-betterstack.d.mts +2 -2
- package/plugins-betterstack.mjs +1 -1
- package/plugins-console.d.mts +1 -1
- package/plugins-sentry-env.d.mts +4 -4
- package/plugins-sentry-env.mjs +1 -1
- package/plugins-sentry-env.mjs.map +1 -1
- package/plugins-sentry-microfrontend-env.mjs +1 -1
- package/plugins-sentry-microfrontend-env.mjs.map +1 -1
- package/plugins-sentry-microfrontend.d.mts +1 -1
- package/plugins-sentry-microfrontend.mjs +1 -1
- package/plugins-sentry.d.mts +2 -2
- package/plugins-sentry.mjs +1 -1
- package/server-edge.d.mts +4 -4
- package/server-edge.mjs +2 -2
- package/server-next.d.mts +6 -6
- package/server-next.mjs +4 -4
- package/server.d.mts +3 -3
- package/server.mjs +1 -1
- package/server.mjs.map +1 -1
- package/{utils-DjjqCeoW.d.mts → utils-BGdqvezr.d.mts} +4 -3
- package/utils-BGdqvezr.d.mts.map +1 -0
- package/factory-DkY353r8.mjs.map +0 -1
- package/plugin-CP895lBx.mjs.map +0 -1
- package/plugin-CxeJHHeJ.mjs +0 -1195
- package/plugin-CxeJHHeJ.mjs.map +0 -1
- package/plugin-lPdJirTY.mjs.map +0 -1
- package/utils-DjjqCeoW.d.mts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -68,8 +68,8 @@
|
|
|
68
68
|
**Vector Types:**
|
|
69
69
|
- Added comprehensive JSDoc for optional vendor-specific methods
|
|
70
70
|
|
|
71
|
-
**Affected packages:** @repo/email, @repo/internationalization, @
|
|
72
|
-
@
|
|
71
|
+
**Affected packages:** @repo/email, @repo/internationalization, @od-oneapp/uni-ui, @repo/pptx-editor, @od-oneapp/ai,
|
|
72
|
+
@od-oneapp/ai-oneapp, @repo/observability, @repo/feature-flags, @od-oneapp/ui-mcp
|
|
73
73
|
|
|
74
74
|
- Updated dependencies []:
|
|
75
|
-
- @
|
|
75
|
+
- @od-oneapp/shared@2025.11.1201
|
package/README.md
CHANGED
|
@@ -36,7 +36,7 @@ performance monitoring, and tracing across client, server, and edge environments
|
|
|
36
36
|
|
|
37
37
|
```typescript
|
|
38
38
|
// ✅ CORRECT: Logging (Canonical)
|
|
39
|
-
import { logInfo, logError } from "@
|
|
39
|
+
import { logInfo, logError } from "@od-oneapp/shared/logger";
|
|
40
40
|
|
|
41
41
|
// ✅ CORRECT: Observability initialization (Next.js Server Component)
|
|
42
42
|
import { observability } from "@repo/observability/server/next";
|
|
@@ -74,7 +74,7 @@ pnpm add @repo/observability
|
|
|
74
74
|
```tsx
|
|
75
75
|
"use client";
|
|
76
76
|
|
|
77
|
-
import { logInfo, logError } from "@
|
|
77
|
+
import { logInfo, logError } from "@od-oneapp/shared/logger";
|
|
78
78
|
|
|
79
79
|
export function UserProfile() {
|
|
80
80
|
const handleClick = async () => {
|
|
@@ -94,7 +94,7 @@ export function UserProfile() {
|
|
|
94
94
|
|
|
95
95
|
```tsx
|
|
96
96
|
import { getObservability } from "@repo/observability/server-next";
|
|
97
|
-
import { logInfo, logError } from "@
|
|
97
|
+
import { logInfo, logError } from "@od-oneapp/shared/logger";
|
|
98
98
|
|
|
99
99
|
export default async function ServerPage() {
|
|
100
100
|
const observability = await getObservability();
|
|
@@ -115,7 +115,7 @@ export default async function ServerPage() {
|
|
|
115
115
|
|
|
116
116
|
```typescript
|
|
117
117
|
import { getObservability } from "@repo/observability/server-next";
|
|
118
|
-
import { logInfo, logError } from "@
|
|
118
|
+
import { logInfo, logError } from "@od-oneapp/shared/logger";
|
|
119
119
|
import { NextRequest, NextResponse } from "next/server";
|
|
120
120
|
|
|
121
121
|
export async function POST(request: NextRequest) {
|
|
@@ -177,7 +177,7 @@ LOGTAIL_SOURCE_TOKEN=your-token # Legacy name
|
|
|
177
177
|
### Basic Logging
|
|
178
178
|
|
|
179
179
|
```typescript
|
|
180
|
-
import { logDebug, logInfo, logWarn, logError } from "@
|
|
180
|
+
import { logDebug, logInfo, logWarn, logError } from "@od-oneapp/shared/logger";
|
|
181
181
|
|
|
182
182
|
logDebug("Processing request", { requestId: "123" });
|
|
183
183
|
logInfo("User logged in", { userId: "user-456" });
|
|
@@ -424,7 +424,7 @@ class CustomPlugin implements ObservabilityPlugin {
|
|
|
424
424
|
|
|
425
425
|
### Logging (Canonical)
|
|
426
426
|
|
|
427
|
-
Logging is now handled by the `@
|
|
427
|
+
Logging is now handled by the `@od-oneapp/shared/logger` package.
|
|
428
428
|
|
|
429
429
|
- `logDebug(message, context?)` - Debug logging
|
|
430
430
|
- `logInfo(message, context?)` - Info logging
|
package/client-next.d.mts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { a as Breadcrumb, c as ObservabilityConfig, d as ObservabilityServer, f as ObservabilityUser, l as ObservabilityContext, o as LogLevel, s as ObservabilityClient, u as ObservabilityScope } from "./plugin-
|
|
2
|
-
import { t as ObservabilityManager } from "./manager-
|
|
3
|
-
import { n as ObservabilityBuilder, t as createObservability } from "./index-
|
|
4
|
-
import { n as BetterStackPluginConfig, t as BetterStackPlugin } from "./plugin-
|
|
1
|
+
import { a as Breadcrumb, c as ObservabilityConfig, d as ObservabilityServer, f as ObservabilityUser, l as ObservabilityContext, o as LogLevel, s as ObservabilityClient, u as ObservabilityScope } from "./plugin-BqLvYLQZ.mjs";
|
|
2
|
+
import { t as ObservabilityManager } from "./manager-0G9cdhWY.mjs";
|
|
3
|
+
import { n as ObservabilityBuilder, t as createObservability } from "./index-CyBL4Sra.mjs";
|
|
4
|
+
import { n as BetterStackPluginConfig, t as BetterStackPlugin } from "./plugin-Cn23gGuY.mjs";
|
|
5
5
|
import { Env } from "./plugins-betterstack-env.mjs";
|
|
6
6
|
import { ConsolePlugin, ConsolePluginConfig } from "./plugins-console.mjs";
|
|
7
|
-
import { n as SentryPluginConfig, t as SentryPlugin } from "./plugin-
|
|
7
|
+
import { n as SentryPluginConfig, t as SentryPlugin } from "./plugin-C11_suJr.mjs";
|
|
8
8
|
import { Env as Env$1 } from "./plugins-sentry-env.mjs";
|
|
9
9
|
import "./plugins-sentry.mjs";
|
|
10
|
-
import { c as MicroFrontendMode, i as SentryMicroFrontendPlugin, l as SentryMicroFrontendConfig, s as BackstageAppConfig } from "./utils-
|
|
10
|
+
import { c as MicroFrontendMode, i as SentryMicroFrontendPlugin, l as SentryMicroFrontendConfig, s as BackstageAppConfig } from "./utils-BGdqvezr.mjs";
|
|
11
11
|
import "./plugins-sentry-microfrontend.mjs";
|
|
12
12
|
|
|
13
13
|
//#region src/client-next.d.ts
|
package/client-next.mjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { shouldEnableConsole } from "./index.mjs";
|
|
2
2
|
import { env } from "./env.mjs";
|
|
3
|
-
import { n as ObservabilityBuilder, t as createObservability } from "./factory-
|
|
3
|
+
import { n as ObservabilityBuilder, t as createObservability } from "./factory-CuW4AM5b.mjs";
|
|
4
4
|
import { ConsolePlugin, createConsolePlugin } from "./plugins-console.mjs";
|
|
5
5
|
import { env as env$1 } from "./plugins-betterstack-env.mjs";
|
|
6
|
-
import { n as createBetterStackPlugin, t as BetterStackPlugin } from "./plugin-
|
|
6
|
+
import { n as createBetterStackPlugin, t as BetterStackPlugin } from "./plugin-AzRcMmXa.mjs";
|
|
7
7
|
import { env as env$2 } from "./plugins-sentry-env.mjs";
|
|
8
|
-
import { n as createSentryPlugin, t as SentryPlugin } from "./plugin-
|
|
9
|
-
import { t as SentryMicroFrontendPlugin } from "./plugin-
|
|
8
|
+
import { n as createSentryPlugin, t as SentryPlugin } from "./plugin-BjJ3pgvT.mjs";
|
|
9
|
+
import { t as SentryMicroFrontendPlugin } from "./plugin-BrzKQ9II.mjs";
|
|
10
10
|
|
|
11
11
|
//#region src/client-next.ts
|
|
12
12
|
/**
|
package/client.d.mts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { a as Breadcrumb, c as ObservabilityConfig, d as ObservabilityServer, f as ObservabilityUser, l as ObservabilityContext, o as LogLevel, s as ObservabilityClient, u as ObservabilityScope } from "./plugin-
|
|
2
|
-
import { t as ObservabilityManager } from "./manager-
|
|
3
|
-
import { n as ObservabilityBuilder, t as createObservability } from "./index-
|
|
1
|
+
import { a as Breadcrumb, c as ObservabilityConfig, d as ObservabilityServer, f as ObservabilityUser, l as ObservabilityContext, o as LogLevel, s as ObservabilityClient, u as ObservabilityScope } from "./plugin-BqLvYLQZ.mjs";
|
|
2
|
+
import { t as ObservabilityManager } from "./manager-0G9cdhWY.mjs";
|
|
3
|
+
import { n as ObservabilityBuilder, t as createObservability } from "./index-CyBL4Sra.mjs";
|
|
4
4
|
|
|
5
5
|
//#region src/client.d.ts
|
|
6
6
|
declare const observability: ObservabilityManager;
|
package/client.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { shouldEnableConsole } from "./index.mjs";
|
|
2
2
|
import { env } from "./env.mjs";
|
|
3
|
-
import { n as ObservabilityBuilder, t as createObservability } from "./factory-
|
|
3
|
+
import { n as ObservabilityBuilder, t as createObservability } from "./factory-CuW4AM5b.mjs";
|
|
4
4
|
import { createConsolePlugin } from "./plugins-console.mjs";
|
|
5
5
|
|
|
6
6
|
//#region src/client.ts
|
package/client.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["/**\n * @fileoverview Auto-configuring client export for browser environments (non-Next.js)\n * Auto-configuring client export for browser environments (non-Next.js)\n */\n\nimport { env } from '../env';\n\nimport { ObservabilityBuilder } from './factory/builder';\nimport { createConsolePlugin } from './plugins/console';\nimport { shouldEnableConsole } from './shared';\n\n/**\n * Auto-configured observability for browser environments\n * Automatically sets up console logging based on environment variables\n */\nconst builder = ObservabilityBuilder.create();\n\n// Console logging control using shared utility\nconst enableConsole = shouldEnableConsole(\n env.NEXT_PUBLIC_NODE_ENV,\n env.NEXT_PUBLIC_OBSERVABILITY_CONSOLE_ENABLED,\n env.NEXT_PUBLIC_OBSERVABILITY_DEBUG,\n);\n\n// Always add console plugin, control via enabled flag\nbuilder.withPlugin(\n createConsolePlugin({\n prefix: '[Browser]',\n enabled: enableConsole,\n }),\n);\n\n// Note: Sentry and Better Stack would typically be configured by the app\n// This is just a fallback for non-Next.js browser usage\n\n/**\n * Pre-configured observability instance for browser environments\n * Includes console logging with automatic environment-based configuration\n */\nexport const observability = builder.build();\n\n// Export types and utilities\nexport * from './core/types';\nexport { createObservability } from './factory';\nexport { ObservabilityBuilder } from './factory/builder';\n\n/**\n * Synchronous logger functions for non-Next.js browser environments.\n * These are bound to a pre-built observability instance at module load time.\n *\n * Note: For Next.js apps, use `@repo/observability/client/next` instead,\n * which provides async loggers that support lazy initialization.\n *\n * @example\n * ```typescript\n * import { logInfo, logError } from '@
|
|
1
|
+
{"version":3,"file":"client.mjs","names":[],"sources":["../src/client.ts"],"sourcesContent":["/**\n * @fileoverview Auto-configuring client export for browser environments (non-Next.js)\n * Auto-configuring client export for browser environments (non-Next.js)\n */\n\nimport { env } from '../env';\n\nimport { ObservabilityBuilder } from './factory/builder';\nimport { createConsolePlugin } from './plugins/console';\nimport { shouldEnableConsole } from './shared';\n\n/**\n * Auto-configured observability for browser environments\n * Automatically sets up console logging based on environment variables\n */\nconst builder = ObservabilityBuilder.create();\n\n// Console logging control using shared utility\nconst enableConsole = shouldEnableConsole(\n env.NEXT_PUBLIC_NODE_ENV,\n env.NEXT_PUBLIC_OBSERVABILITY_CONSOLE_ENABLED,\n env.NEXT_PUBLIC_OBSERVABILITY_DEBUG,\n);\n\n// Always add console plugin, control via enabled flag\nbuilder.withPlugin(\n createConsolePlugin({\n prefix: '[Browser]',\n enabled: enableConsole,\n }),\n);\n\n// Note: Sentry and Better Stack would typically be configured by the app\n// This is just a fallback for non-Next.js browser usage\n\n/**\n * Pre-configured observability instance for browser environments\n * Includes console logging with automatic environment-based configuration\n */\nexport const observability = builder.build();\n\n// Export types and utilities\nexport * from './core/types';\nexport { createObservability } from './factory';\nexport { ObservabilityBuilder } from './factory/builder';\n\n/**\n * Synchronous logger functions for non-Next.js browser environments.\n * These are bound to a pre-built observability instance at module load time.\n *\n * Note: For Next.js apps, use `@repo/observability/client/next` instead,\n * which provides async loggers that support lazy initialization.\n *\n * @example\n * ```typescript\n * import { logInfo, logError } from '@od-oneapp/shared/logger';\n * logInfo('User logged in', { userId: '123' });\n * logError('Failed to save data', { error: err });\n * ```\n */\n// Legacy function for backward compatibility (no-op)\n/**\n * @deprecated Configuration now happens through the observability system\n */\nexport const configureLogger = () => {\n // No-op: Configuration now happens through the observability system\n};\n\n// Re-export type\nexport type LogContext = Record<string, any>;\n"],"mappings":";;;;;;;;;;;;;;AAeA,MAAM,UAAU,qBAAqB,QAAQ;AAG7C,MAAM,gBAAgB,oBACpB,IAAI,sBACJ,IAAI,2CACJ,IAAI,gCACL;AAGD,QAAQ,WACN,oBAAoB;CAClB,QAAQ;CACR,SAAS;CACV,CAAC,CACH;;;;;AASD,MAAa,gBAAgB,QAAQ,OAAO;;;;;;;;;;;;;;;;;;AAyB5C,MAAa,wBAAwB"}
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
//#region ../shared/src/logger/core.ts
|
|
2
|
+
/**
|
|
3
|
+
* @fileoverview Canonical logger for the OneApp platform.
|
|
4
|
+
*
|
|
5
|
+
* This module provides isomorphic logging functions that work in any environment
|
|
6
|
+
* (Browser, Node.js, Edge). Logs directly to console with runtime information.
|
|
7
|
+
*
|
|
8
|
+
* Preferred usage is to import from '@od-oneapp/shared/logger'.
|
|
9
|
+
*/
|
|
10
|
+
/**
|
|
11
|
+
* Get runtime environment information.
|
|
12
|
+
*
|
|
13
|
+
* Detects the current runtime environment (browser, Node.js, edge, Bun) and returns
|
|
14
|
+
* detailed information about the environment type, version, and capabilities.
|
|
15
|
+
*
|
|
16
|
+
* @returns Runtime information object with type, version, and environment-specific details
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* ```typescript
|
|
20
|
+
* const runtime = getRuntimeInfo();
|
|
21
|
+
* // Returns: { type: 'node', version: '22.0.0', major: 22, minor: 0, isNode22Plus: true, isNextJs: true }
|
|
22
|
+
* // or: { type: 'browser', isNextJs: true }
|
|
23
|
+
* // or: { type: 'edge', variant: 'vercel' }
|
|
24
|
+
* ```
|
|
25
|
+
*/
|
|
26
|
+
const getRuntimeInfo = () => {
|
|
27
|
+
if (typeof globalThis !== "undefined" && globalThis.EdgeRuntime) return {
|
|
28
|
+
type: "edge",
|
|
29
|
+
variant: "vercel"
|
|
30
|
+
};
|
|
31
|
+
if (typeof globalThis !== "undefined" && globalThis.caches && typeof globalThis.caches !== "undefined") return {
|
|
32
|
+
type: "edge",
|
|
33
|
+
variant: "cloudflare"
|
|
34
|
+
};
|
|
35
|
+
if (typeof globalThis !== "undefined" && "window" in globalThis && typeof globalThis.window !== "undefined" && typeof globalThis.window.document !== "undefined" && typeof globalThis.window.navigator !== "undefined") return {
|
|
36
|
+
type: "browser",
|
|
37
|
+
isNextJs: Boolean(globalThis.window.__NEXT_DATA__)
|
|
38
|
+
};
|
|
39
|
+
if (typeof process !== "undefined" && process.versions?.bun) return {
|
|
40
|
+
type: "bun",
|
|
41
|
+
version: process.versions.bun
|
|
42
|
+
};
|
|
43
|
+
if (typeof process !== "undefined" && process.versions?.node) {
|
|
44
|
+
const nodeVersion = parseInt(process.versions.node.split(".")[0] ?? "0");
|
|
45
|
+
const nodeVersionMinor = parseInt(process.versions.node.split(".")[1] ?? "0");
|
|
46
|
+
if (nodeVersion < 22) console.warn(`[Observability] Node ${process.versions.node} detected. Node 22+ is required for optimal performance and latest features.`);
|
|
47
|
+
return {
|
|
48
|
+
type: "node",
|
|
49
|
+
version: process.versions.node,
|
|
50
|
+
major: nodeVersion,
|
|
51
|
+
minor: nodeVersionMinor,
|
|
52
|
+
isNode22Plus: nodeVersion >= 22,
|
|
53
|
+
isNextJs: Boolean(process.env.NEXT_RUNTIME) || Boolean(process.env.__NEXT_RUNTIME) || Boolean(process.env.NEXT_PUBLIC_VERCEL_ENV)
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return { type: "unknown" };
|
|
57
|
+
};
|
|
58
|
+
const runtimeInfo = getRuntimeInfo();
|
|
59
|
+
/**
|
|
60
|
+
* Create a generic log function factory.
|
|
61
|
+
*
|
|
62
|
+
* Factory function that creates log functions for different levels (debug, info, warn, error).
|
|
63
|
+
* Logs directly to console with runtime information.
|
|
64
|
+
*/
|
|
65
|
+
const createLogFunction = (level) => {
|
|
66
|
+
return (message, context) => {
|
|
67
|
+
if (message instanceof Error) if (context) console[level](`[${runtimeInfo.type}]`, message, context);
|
|
68
|
+
else console[level](`[${runtimeInfo.type}]`, message);
|
|
69
|
+
else {
|
|
70
|
+
const contextStr = context ? JSON.stringify(context) : "";
|
|
71
|
+
const logMessage = contextStr ? `${message} ${contextStr}` : message;
|
|
72
|
+
console[level](`[${runtimeInfo.type}]`, logMessage);
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Log a debug message (isomorphic - works in any environment).
|
|
78
|
+
*/
|
|
79
|
+
const logDebug = createLogFunction("debug");
|
|
80
|
+
/**
|
|
81
|
+
* Log an info message (isomorphic - works in any environment).
|
|
82
|
+
*/
|
|
83
|
+
const logInfo = createLogFunction("info");
|
|
84
|
+
/**
|
|
85
|
+
* Log a warning message (isomorphic - works in any environment).
|
|
86
|
+
*/
|
|
87
|
+
const logWarn = createLogFunction("warn");
|
|
88
|
+
/**
|
|
89
|
+
* Log an error message (isomorphic - works in any environment).
|
|
90
|
+
*/
|
|
91
|
+
const logError = createLogFunction("error");
|
|
92
|
+
|
|
93
|
+
//#endregion
|
|
94
|
+
export { logError as n, logWarn as r, logDebug as t };
|
|
95
|
+
//# sourceMappingURL=core-BKuLZf5B.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-BKuLZf5B.mjs","names":[],"sources":["../../shared/src/logger/core.ts"],"sourcesContent":["/**\n * @fileoverview Canonical logger for the OneApp platform.\n *\n * This module provides isomorphic logging functions that work in any environment\n * (Browser, Node.js, Edge). Logs directly to console with runtime information.\n *\n * Preferred usage is to import from '@od-oneapp/shared/logger'.\n */\n\n/**\n * Get runtime environment information.\n *\n * Detects the current runtime environment (browser, Node.js, edge, Bun) and returns\n * detailed information about the environment type, version, and capabilities.\n *\n * @returns Runtime information object with type, version, and environment-specific details\n *\n * @example\n * ```typescript\n * const runtime = getRuntimeInfo();\n * // Returns: { type: 'node', version: '22.0.0', major: 22, minor: 0, isNode22Plus: true, isNextJs: true }\n * // or: { type: 'browser', isNextJs: true }\n * // or: { type: 'edge', variant: 'vercel' }\n * ```\n */\nexport const getRuntimeInfo = () => {\n // 1. Edge runtime detection (Vercel Edge, Cloudflare Workers)\n // Check these before browser because they might have a partial window mock\n if (typeof globalThis !== 'undefined' && (globalThis as any).EdgeRuntime) {\n return { type: 'edge', variant: 'vercel' };\n }\n if (\n typeof globalThis !== 'undefined' &&\n (globalThis as any).caches &&\n typeof (globalThis as any).caches !== 'undefined'\n ) {\n return { type: 'edge', variant: 'cloudflare' };\n }\n\n // 2. Browser detection\n if (\n typeof globalThis !== 'undefined' &&\n 'window' in globalThis &&\n typeof (globalThis as any).window !== 'undefined' &&\n typeof (globalThis as any).window.document !== 'undefined' &&\n typeof (globalThis as any).window.navigator !== 'undefined'\n ) {\n return { type: 'browser', isNextJs: Boolean((globalThis as any).window.__NEXT_DATA__) };\n }\n\n // 3. Bun detection\n if (typeof process !== 'undefined' && (process as any).versions?.bun) {\n return { type: 'bun', version: (process as any).versions.bun };\n }\n\n // 4. Node.js detection with version check\n if (typeof process !== 'undefined' && process.versions?.node) {\n const nodeVersion = parseInt(process.versions.node.split('.')[0] ?? '0');\n const nodeVersionMinor = parseInt(process.versions.node.split('.')[1] ?? '0');\n\n if (nodeVersion < 22) {\n // Note: Using console.warn here as observability system may not be initialized yet\n // eslint-disable-next-line no-console\n console.warn(\n `[Observability] Node ${process.versions.node} detected. Node 22+ is required for optimal performance and latest features.`,\n );\n }\n\n return {\n type: 'node',\n version: process.versions.node,\n major: nodeVersion,\n minor: nodeVersionMinor,\n isNode22Plus: nodeVersion >= 22,\n isNextJs:\n Boolean(process.env.NEXT_RUNTIME) ||\n Boolean(process.env.__NEXT_RUNTIME) ||\n Boolean(process.env.NEXT_PUBLIC_VERCEL_ENV),\n };\n }\n\n // Fallback\n return { type: 'unknown' };\n};\n\n// Cache the runtime info\nconst runtimeInfo = getRuntimeInfo();\n\n/**\n * Get cached runtime environment information.\n *\n * Returns the runtime information that was detected at module load time.\n * This is cached to avoid repeated detection checks.\n *\n * @returns Cached runtime information object\n */\nexport const getRuntimeEnvironment = () => runtimeInfo;\n\n/**\n * Detect if code is running in a browser environment\n * Extracted to shared utility to avoid duplication\n * @returns true if running in browser, false otherwise\n */\nexport function isBrowser(): boolean {\n return (\n typeof globalThis !== 'undefined' &&\n 'window' in globalThis &&\n typeof (globalThis as any).window !== 'undefined' &&\n typeof (globalThis as any).window.document !== 'undefined' &&\n typeof (globalThis as any).window.navigator !== 'undefined'\n );\n}\n\n/**\n * Determine if console logging should be enabled based on environment\n * Centralized logic to avoid duplication across entry points\n * @param envNodeEnv - The NEXT_PUBLIC_NODE_ENV value\n * @param consoleEnabled - The NEXT_PUBLIC_OBSERVABILITY_CONSOLE_ENABLED value (explicit control)\n * @param debugEnabled - The NEXT_PUBLIC_OBSERVABILITY_DEBUG value\n * @returns boolean indicating if console should be enabled\n */\nexport function shouldEnableConsole(\n envNodeEnv?: string,\n consoleEnabled?: boolean,\n debugEnabled?: boolean,\n): boolean {\n const isDevelopment = envNodeEnv === 'development' || process.env.NODE_ENV === 'development';\n\n // Priority: explicit control > development mode > debug mode\n if (consoleEnabled !== undefined) {\n return consoleEnabled;\n }\n if (isDevelopment) {\n return true;\n }\n return debugEnabled ?? false;\n}\n\n/**\n * Create a generic log function factory.\n *\n * Factory function that creates log functions for different levels (debug, info, warn, error).\n * Logs directly to console with runtime information.\n */\nconst createLogFunction = (level: 'debug' | 'info' | 'warn' | 'error') => {\n return (message: string | Error, context?: any): void => {\n if (message instanceof Error) {\n // For Error objects, log the error itself (console.error will show stack trace)\n // and include context as additional arguments\n if (context) {\n // eslint-disable-next-line no-console\n (console[level] as any)(`[${runtimeInfo.type}]`, message, context);\n } else {\n // eslint-disable-next-line no-console\n (console[level] as any)(`[${runtimeInfo.type}]`, message);\n }\n } else {\n // For string messages, format with context\n const contextStr = context ? JSON.stringify(context) : '';\n const logMessage = contextStr ? `${message} ${contextStr}` : message;\n // eslint-disable-next-line no-console\n (console[level] as any)(`[${runtimeInfo.type}]`, logMessage);\n }\n };\n};\n\n/**\n * Log a debug message (isomorphic - works in any environment).\n */\nexport const logDebug = createLogFunction('debug');\n\n/**\n * Log an info message (isomorphic - works in any environment).\n */\nexport const logInfo = createLogFunction('info');\n\n/**\n * Log a warning message (isomorphic - works in any environment).\n */\nexport const logWarn = createLogFunction('warn');\n\n/**\n * Log an error message (isomorphic - works in any environment).\n */\nexport const logError = createLogFunction('error');\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAyBA,MAAa,uBAAuB;AAGlC,KAAI,OAAO,eAAe,eAAgB,WAAmB,YAC3D,QAAO;EAAE,MAAM;EAAQ,SAAS;EAAU;AAE5C,KACE,OAAO,eAAe,eACrB,WAAmB,UACpB,OAAQ,WAAmB,WAAW,YAEtC,QAAO;EAAE,MAAM;EAAQ,SAAS;EAAc;AAIhD,KACE,OAAO,eAAe,eACtB,YAAY,cACZ,OAAQ,WAAmB,WAAW,eACtC,OAAQ,WAAmB,OAAO,aAAa,eAC/C,OAAQ,WAAmB,OAAO,cAAc,YAEhD,QAAO;EAAE,MAAM;EAAW,UAAU,QAAS,WAAmB,OAAO,cAAc;EAAE;AAIzF,KAA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ts
|
|
2
2
|
declare const env: Readonly<{
|
|
3
3
|
NEXT_PUBLIC_OBSERVABILITY_CONSOLE_ENABLED?: boolean | undefined;
|
|
4
|
-
NEXT_PUBLIC_NODE_ENV: "development" | "
|
|
4
|
+
NEXT_PUBLIC_NODE_ENV: "development" | "production" | "test";
|
|
5
5
|
NEXT_PUBLIC_OBSERVABILITY_DEBUG: boolean;
|
|
6
6
|
}>;
|
|
7
7
|
declare function safeEnv(): Readonly<{
|
|
8
8
|
NEXT_PUBLIC_OBSERVABILITY_CONSOLE_ENABLED?: boolean | undefined;
|
|
9
|
-
NEXT_PUBLIC_NODE_ENV: "development" | "
|
|
9
|
+
NEXT_PUBLIC_NODE_ENV: "development" | "production" | "test";
|
|
10
10
|
NEXT_PUBLIC_OBSERVABILITY_DEBUG: boolean;
|
|
11
11
|
}>;
|
|
12
12
|
type Env = typeof env;
|
package/env.mjs
CHANGED
package/env.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"env.mjs","names":[],"sources":["../env.ts"],"sourcesContent":["/**\n * @fileoverview Core environment configuration for the observability package\n * Core environment configuration for the observability package\n * Provider-specific configurations are handled by their respective plugins\n */\n\nimport { logWarn } from '@
|
|
1
|
+
{"version":3,"file":"env.mjs","names":[],"sources":["../env.ts"],"sourcesContent":["/**\n * @fileoverview Core environment configuration for the observability package\n * Core environment configuration for the observability package\n * Provider-specific configurations are handled by their respective plugins\n */\n\nimport { logWarn } from '@od-oneapp/shared/logger';\nimport { createEnv } from '@t3-oss/env-core';\nimport { z } from 'zod/v4';\n\n// Create validated env object\nexport const env = createEnv({\n server: {\n // Core observability config only - providers handle their own\n },\n clientPrefix: 'NEXT_PUBLIC_',\n client: {\n // Core configuration available on both client and server\n NEXT_PUBLIC_NODE_ENV: z.enum(['development', 'test', 'production']).default('development'),\n NEXT_PUBLIC_OBSERVABILITY_DEBUG: z\n .string()\n .optional()\n .transform(val => val === 'true')\n .default(false),\n NEXT_PUBLIC_OBSERVABILITY_CONSOLE_ENABLED: z\n .string()\n .optional()\n .transform(val => (val === 'true' ? true : val === 'false' ? false : undefined)),\n },\n runtimeEnv: process.env,\n emptyStringAsUndefined: true,\n onInvalidAccess: (variable: string) => {\n throw new Error(\n `❌ Attempted to access a server-side environment variable on the client: ${variable}`,\n );\n },\n onValidationError: error => {\n logWarn('Observability package environment validation failed', { error });\n // Don't throw in packages - use fallbacks\n return undefined as never;\n },\n});\n\n// Helper for non-Next.js contexts (Node.js, workers, tests)\nexport function safeEnv() {\n try {\n if (env && typeof env === 'object') return env;\n } catch {\n // Environment validation failed, use fallbacks\n }\n\n // Fallback values for resilience\n return {\n // Core configuration only\n NEXT_PUBLIC_NODE_ENV: process.env.NODE_ENV ?? 'development',\n NEXT_PUBLIC_OBSERVABILITY_DEBUG: process.env.NEXT_PUBLIC_OBSERVABILITY_DEBUG === 'true',\n NEXT_PUBLIC_OBSERVABILITY_CONSOLE_ENABLED:\n process.env.NEXT_PUBLIC_OBSERVABILITY_CONSOLE_ENABLED === 'true'\n ? true\n : process.env.NEXT_PUBLIC_OBSERVABILITY_CONSOLE_ENABLED === 'false'\n ? false\n : undefined,\n };\n}\n\n// Export type\nexport type Env = typeof env;\n"],"mappings":";;;;;;;;;;AAWA,MAAa,MAAM,UAAU;CAC3B,QAAQ,EAEP;CACD,cAAc;CACd,QAAQ;EAEN,sBAAsB,EAAE,KAAK;GAAC;GAAe;GAAQ;GAAa,CAAC,CAAC,QAAQ,cAAc;EAC1F,iCAAiC,EAC9B,QAAQ,CACR,UAAU,CACV,WAAU,QAAO,QAAQ,OAAO,CAChC,QAAQ,MAAM;EACjB,2CAA2C,EACxC,QAAQ,CACR,UAAU,CACV,WAAU,QAAQ,QAAQ,SAAS,OAAO,QAAQ,UAAU,QAAQ,OAAW;EACnF;CACD,YAAY,QAAQ;CACpB,wBAAwB;CACxB,kBAAkB,aAAqB;AACrC,QAAM,IAAI,MACR,2EAA2E,WAC5E;;CAEH,oBAAmB,UAAS;AAC1B,UAAQ,uDAAuD,EAAE,OAAO,CAAC;;CAI5E,CAAC;AAGF,SAAgB,UAAU;AACxB,KAAI;AACF,MAAI,OAAO,OAAO,QAAQ,SAAU,QAAO;SACrC;AAKR,QAAO;EAEL;EACA,iCAAiC,QAAQ,IAAI,oCAAoC;EACjF,2CACE,QAAQ,IAAI,8CAA8C,SACtD,OACA,QAAQ,IAAI,8CAA8C,UACxD,QACA;EACT"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { logError, logWarn } from "
|
|
1
|
+
import { n as logError, r as logWarn } from "./core-BKuLZf5B.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/core/manager.ts
|
|
4
4
|
/**
|
|
@@ -377,4 +377,4 @@ function createObservability(plugins, options) {
|
|
|
377
377
|
|
|
378
378
|
//#endregion
|
|
379
379
|
export { ObservabilityBuilder as n, ObservabilityManager as r, createObservability as t };
|
|
380
|
-
//# sourceMappingURL=factory-
|
|
380
|
+
//# sourceMappingURL=factory-CuW4AM5b.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory-CuW4AM5b.mjs","names":[],"sources":["../src/core/manager.ts","../src/factory/builder.ts","../src/factory/index.ts"],"sourcesContent":["/**\n * @fileoverview ObservabilityManager - Core orchestrator for multiple observability providers\n * ObservabilityManager - Core orchestrator for multiple observability providers\n */\n\nimport { logError, logWarn } from '@od-oneapp/shared/logs';\n\nimport type { ObservabilityPlugin, ObservabilityServerPlugin, PluginLifecycle } from './plugin';\nimport type {\n Breadcrumb,\n LogLevel,\n ObservabilityContext,\n ObservabilityScope,\n ObservabilityServer,\n ObservabilityUser,\n} from './types';\n\n/**\n * Manager that orchestrates multiple observability plugins\n * Broadcasts all method calls to enabled plugins\n */\nexport class ObservabilityManager implements ObservabilityServer {\n private plugins = new Map<string, ObservabilityPlugin | ObservabilityServerPlugin>();\n private initialized = false;\n private initializationPromise: Promise<void> | null = null;\n private lifecycle: PluginLifecycle = {};\n private initializationError: Error | null = null;\n\n /**\n * Create a new ObservabilityManager instance.\n *\n * @param lifecycle - Optional lifecycle callbacks for plugin events\n */\n constructor(lifecycle?: PluginLifecycle) {\n if (lifecycle) {\n this.lifecycle = lifecycle;\n }\n }\n\n /**\n * Add a plugin to the manager\n */\n addPlugin(plugin: ObservabilityPlugin | ObservabilityServerPlugin): this {\n this.plugins.set(plugin.name, plugin);\n return this;\n }\n\n /**\n * Get a specific plugin by name.\n *\n * @param name - Name of the plugin to retrieve\n * @returns Plugin instance if found, undefined otherwise\n */\n getPlugin<T extends ObservabilityPlugin>(name: string): T | undefined {\n return this.plugins.get(name) as T;\n }\n\n /**\n * Get all registered plugins.\n *\n * @returns Array of all registered plugins\n */\n getPlugins(): ObservabilityPlugin[] {\n return Array.from(this.plugins.values());\n }\n\n /**\n * List all registered plugins (alias for getPlugins).\n *\n * @returns Array of all registered plugins\n */\n listPlugins(): ObservabilityPlugin[] {\n return this.getPlugins();\n }\n\n /**\n * Initialize all plugins\n * Note: Failed initialization is retryable - subsequent calls will re-attempt initialization.\n * This allows recovery from transient failures (network issues, temporary misconfigurations).\n */\n async initialize(): Promise<void> {\n // If there's already an initialization in progress, wait for it\n if (this.initializationPromise) {\n return this.initializationPromise;\n }\n\n // If already initialized successfully, return early\n if (this.initialized) {\n return;\n }\n\n // Allow retry if previous attempt failed\n if (this.initializationError) {\n // Log retry attempt for debugging\n logWarn('ObservabilityManager: Retrying failed initialization');\n // Clear previous error to allow fresh attempt\n this.initializationError = null;\n }\n\n // Create the initialization promise and store it to prevent concurrent calls\n this.initializationPromise = this.doInitialize();\n\n try {\n await this.initializationPromise;\n } finally {\n // Clear the promise after initialization completes (success or failure)\n this.initializationPromise = null;\n }\n }\n\n private async doInitialize(): Promise<void> {\n const initPromises = Array.from(this.plugins.values())\n .filter(plugin => plugin.enabled && plugin.initialize)\n .map(async plugin => {\n try {\n if (plugin.initialize) {\n await plugin.initialize();\n }\n this.lifecycle.onInitialized?.(plugin);\n } catch (error) {\n logError(`Failed to initialize plugin ${plugin.name}`, {\n error,\n pluginName: plugin.name,\n });\n this.lifecycle.onError?.(error as Error, plugin);\n // Re-throw to propagate error to Promise.all\n throw error;\n }\n });\n\n try {\n await Promise.all(initPromises);\n this.initialized = true;\n } catch (error) {\n this.initializationError = error instanceof Error ? error : new Error(String(error));\n throw this.initializationError;\n }\n }\n\n /**\n * Check if initialization had an error\n * @returns `true` if initialization failed, `false` otherwise\n */\n hasInitializationError(): boolean {\n return this.initializationError !== null;\n }\n\n /**\n * Get the initialization error if one occurred\n * @returns The initialization error or `null` if no error\n */\n getInitializationError(): Error | null {\n return this.initializationError;\n }\n\n /**\n * Shutdown all plugins\n */\n async shutdown(): Promise<void> {\n const shutdownPromises = Array.from(this.plugins.values())\n .filter(plugin => plugin.shutdown)\n .map(async plugin => {\n try {\n if (plugin.shutdown) {\n await plugin.shutdown();\n }\n this.lifecycle.onShutdown?.(plugin);\n } catch (error) {\n logError(`Failed to shutdown plugin ${plugin.name}`, { error, pluginName: plugin.name });\n this.lifecycle.onError?.(error as Error, plugin);\n }\n });\n\n await Promise.allSettled(shutdownPromises);\n this.initialized = false;\n }\n\n /**\n * Broadcast exception to all enabled plugins.\n *\n * @param error - Error object or unknown error value\n * @param context - Optional additional context data\n */\n captureException(error: Error | unknown, context?: ObservabilityContext): void {\n this.broadcast(plugin => plugin.captureException(error, context));\n }\n\n /**\n * Broadcast message to all enabled plugins.\n *\n * @param message - Message to log\n * @param level - Log level (default: 'info')\n * @param context - Optional additional context data\n */\n captureMessage(message: string, level: LogLevel = 'info', context?: ObservabilityContext): void {\n this.broadcast(plugin => plugin.captureMessage(message, level, context));\n }\n\n /**\n * Validate and sanitize user data to prevent injection and DoS attacks\n * @param user - User data to validate\n * @returns Validated user data with length limits and format validation applied\n */\n private validateUser(user: ObservabilityUser | null): ObservabilityUser | null {\n if (!user) return null;\n\n // Validate required ID field\n const id = String(user.id).trim().slice(0, 255);\n if (!id) {\n // Log warning but don't throw - graceful degradation\n logWarn('ObservabilityManager: User ID is empty, ignoring user data');\n return null;\n }\n\n const validated: ObservabilityUser = { id };\n\n // Validate email format if provided\n if ('email' in user && user.email) {\n const email = String(user.email).trim().slice(0, 255);\n // More robust email validation - RFC 5322 simplified but stricter\n // Allows: alphanumeric, dots, plus, hyphens, underscores before @\n // Requires: valid domain with at least one dot after @\n if (\n email &&\n // eslint-disable-next-line security/detect-unsafe-regex -- Safe: bounded input (max 255 chars), RFC 5322 compliant pattern\n /^[a-zA-Z0-9.!#$%&'*+/=?^_`{|}~-]+@[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(?:\\.[a-zA-Z0-9](?:[a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/.test(\n email,\n )\n ) {\n validated.email = email;\n }\n }\n\n // Validate username if provided\n if ('username' in user && user.username) {\n const username = String(user.username).trim().slice(0, 255);\n if (username) {\n validated.username = username;\n }\n }\n\n // Validate IP address format if provided\n if ('ip_address' in user && user.ip_address) {\n const ip = String(user.ip_address).trim();\n // Stricter IP validation\n // IPv4: Each octet must be 0-255\n const isValidIPv4 =\n // eslint-disable-next-line security/detect-unsafe-regex -- Safe: bounded pattern for IPv4 validation, input is trimmed string\n /^(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(\n ip,\n );\n // IPv6: Basic format check (full validation is complex, this catches most invalid cases)\n const looksLikeIPv6 =\n /^[0-9a-fA-F:]+$/.test(ip) && ip.includes(':') && ip.split(':').length <= 8;\n\n if (isValidIPv4 || looksLikeIPv6) {\n validated.ip_address = ip.slice(0, 45); // IPv6 max length\n }\n }\n\n return validated;\n }\n\n /**\n * Set user on all enabled plugins\n * User data is validated and sanitized before being set\n * @param user - User data to set (will be validated)\n */\n setUser(user: ObservabilityUser | null): void {\n const validatedUser = this.validateUser(user);\n this.broadcast(plugin => plugin.setUser(validatedUser));\n }\n\n /**\n * Add breadcrumb to all enabled plugins.\n *\n * @param breadcrumb - Breadcrumb data to add\n */\n addBreadcrumb(breadcrumb: Breadcrumb): void {\n this.broadcast(plugin => plugin.addBreadcrumb(breadcrumb));\n }\n\n /**\n * Execute callback within scope for all enabled plugins.\n *\n * @param callback - Callback that receives the scope\n */\n withScope(callback: (scope: ObservabilityScope) => void): void {\n this.broadcast(plugin => plugin.withScope(callback));\n }\n\n /**\n * Flush all plugins that support it.\n *\n * Waits for all enabled plugins with flush capability to send pending events.\n *\n * @param timeout - Maximum time to wait in milliseconds\n * @returns Promise resolving to true if all plugins flushed successfully\n */\n async flush(timeout?: number): Promise<boolean> {\n const flushPromises = Array.from(this.plugins.values())\n .filter((plugin): plugin is ObservabilityServerPlugin => {\n return plugin.enabled && 'flush' in plugin && typeof plugin.flush === 'function';\n })\n .map(plugin => plugin.flush(timeout));\n\n if (flushPromises.length === 0) {\n return true;\n }\n\n const results = await Promise.allSettled(flushPromises);\n return results.every(result => result.status === 'fulfilled' && result.value === true);\n }\n\n /**\n * Helper to broadcast a method call to all enabled plugins\n * Uses nested try-catch to ensure errors in error handling don't prevent other plugins from executing\n */\n private broadcast(fn: (plugin: ObservabilityPlugin) => void): void {\n this.plugins.forEach(plugin => {\n if (plugin.enabled) {\n try {\n fn(plugin);\n } catch (error) {\n // Safely handle error without throwing - nested try-catch ensures resilience\n try {\n logError(`Plugin ${plugin.name} error`, { error, pluginName: plugin.name });\n } catch {\n // Logger unavailable - continue silently\n }\n\n try {\n this.lifecycle.onError?.(error as Error, plugin);\n } catch {\n // Error handler failed - continue to next plugin\n }\n }\n }\n });\n }\n\n /**\n * Check if manager has any enabled plugins.\n *\n * @returns True if at least one plugin is enabled, false otherwise\n */\n hasEnabledPlugins(): boolean {\n return Array.from(this.plugins.values()).some(plugin => plugin.enabled);\n }\n\n /**\n * Get names of all enabled plugins.\n *\n * @returns Array of plugin names that are currently enabled\n */\n getEnabledPluginNames(): string[] {\n return Array.from(this.plugins.values())\n .filter(plugin => plugin.enabled)\n .map(plugin => plugin.name);\n }\n}\n","/**\n * @fileoverview ObservabilityBuilder - Fluent API for building observability instances\n * ObservabilityBuilder - Fluent API for building observability instances\n */\n\nimport { logError } from '@od-oneapp/shared/logs';\n\nimport { ObservabilityManager } from '../core/manager';\n\nimport type {\n ObservabilityPlugin,\n ObservabilityServerPlugin,\n PluginLifecycle,\n} from '../core/plugin';\n\n/**\n * Builder for creating configured ObservabilityManager instances\n */\nexport class ObservabilityBuilder {\n private plugins: (ObservabilityPlugin | ObservabilityServerPlugin)[] = [];\n private lifecycle: PluginLifecycle = {};\n private autoInitialize = true;\n\n /**\n * Add a plugin to the observability stack\n * @param plugin - Observability plugin to add\n * @returns Builder instance for chaining\n */\n withPlugin(plugin: ObservabilityPlugin | ObservabilityServerPlugin): this {\n if (plugin) {\n this.plugins.push(plugin);\n }\n return this;\n }\n\n /**\n * Add multiple plugins at once\n * @param plugins - Array of observability plugins to add\n * @returns Builder instance for chaining\n */\n withPlugins(plugins: (ObservabilityPlugin | ObservabilityServerPlugin)[]): this {\n if (plugins && Array.isArray(plugins)) {\n const validPlugins = plugins.filter(plugin => plugin != null);\n this.plugins.push(...validPlugins);\n }\n return this;\n }\n\n /**\n * Set lifecycle callbacks for plugin management\n * @param lifecycle - Lifecycle callback configuration\n * @returns Builder instance for chaining\n */\n withLifecycle(lifecycle: PluginLifecycle): this {\n this.lifecycle = { ...this.lifecycle, ...lifecycle };\n return this;\n }\n\n /**\n * Configure whether to auto-initialize plugins (default: true)\n */\n withAutoInitialize(autoInitialize: boolean): this {\n this.autoInitialize = autoInitialize;\n return this;\n }\n\n /**\n * Build the ObservabilityManager instance\n * @returns Configured ObservabilityManager instance\n */\n build(): ObservabilityManager {\n const manager = new ObservabilityManager(this.lifecycle);\n\n // Add all plugins\n this.plugins.forEach(plugin => manager.addPlugin(plugin));\n\n // Auto-initialize if enabled and not in edge runtime\n if (\n this.autoInitialize &&\n typeof process !== 'undefined' &&\n process.env.NEXT_RUNTIME !== 'edge'\n ) {\n // Initialize asynchronously with safe error handling\n void (async () => {\n try {\n await manager.initialize();\n } catch (error) {\n // Store error in manager for later inspection\n // Note: We can't directly set private property, but manager stores it internally\n\n // Try logError, but don't fail if unavailable\n try {\n logError('Failed to initialize observability', { error });\n } catch {\n // Logger unavailable - error is stored in manager via initialize() method\n }\n }\n })();\n }\n\n return manager;\n }\n\n /**\n * Build and initialize the ObservabilityManager instance\n * @returns Promise resolving to initialized ObservabilityManager\n */\n async buildWithAutoInit(): Promise<ObservabilityManager> {\n const manager = new ObservabilityManager(this.lifecycle);\n\n // Add all plugins\n this.plugins.forEach(plugin => manager.addPlugin(plugin));\n\n // Initialize all plugins - catch errors but still return manager (graceful degradation)\n try {\n await manager.initialize();\n } catch {\n // Error is stored in manager, but we still return it for graceful degradation\n // This allows the application to continue even if observability initialization fails\n }\n\n return manager;\n }\n\n /**\n * Create a new builder instance\n * @returns New ObservabilityBuilder instance\n */\n static create(): ObservabilityBuilder {\n return new ObservabilityBuilder();\n }\n}\n","/**\n * @fileoverview Factory functions for creating observability instances\n * Factory functions for creating observability instances\n */\n\nimport { ObservabilityManager } from '../core/manager';\n\nimport { ObservabilityBuilder } from './builder';\n\nimport type { ObservabilityPlugin, ObservabilityServerPlugin } from '../core/plugin';\n\nexport { ObservabilityManager } from '../core/manager';\nexport { ObservabilityBuilder } from './builder';\n\n/**\n * Create an observability instance with the provided plugins.\n *\n * Factory function that creates a configured ObservabilityManager with the given plugins.\n * Provides a simpler API than using ObservabilityBuilder directly.\n *\n * @param plugins - Array of observability plugins to include\n * @param options - Optional configuration options\n * @param options.autoInitialize - Whether to auto-initialize plugins (default: true)\n * @returns Configured ObservabilityManager instance\n *\n * @example\n * ```typescript\n * const obs = createObservability([\n * createConsolePlugin(),\n * createSentryPlugin({ dsn: '...' }),\n * ], { autoInitialize: true });\n * ```\n */\nexport function createObservability(\n plugins: (ObservabilityPlugin | ObservabilityServerPlugin)[],\n options?: {\n autoInitialize?: boolean;\n },\n): ObservabilityManager {\n const builder = new ObservabilityBuilder();\n\n if (options?.autoInitialize !== undefined) {\n builder.withAutoInitialize(options.autoInitialize);\n }\n\n return builder.withPlugins(plugins).build();\n}\n\n/**\n * Create a no-op observability instance for testing or when observability is disabled.\n *\n * Returns an ObservabilityManager with no plugins configured. All observability methods\n * will be no-ops. Useful for testing or when observability should be disabled.\n *\n * Note: For logging, use @od-oneapp/shared/logger instead.\n *\n * @returns Empty ObservabilityManager instance\n *\n * @example\n * ```typescript\n * const obs = createNoOpObservability();\n * obs.captureMessage('This will not be logged'); // No-op\n * ```\n */\nexport function createNoOpObservability(): ObservabilityManager {\n return new ObservabilityManager();\n}\n"],"mappings":";;;;;;;;;;;AAqBA,IAAa,uBAAb,MAAiE;CAC/D,AAAQ,0BAAU,IAAI,KAA8D;CACpF,AAAQ,cAAc;CACtB,AAAQ,wBAA8C;CACtD,AAAQ,YAA6B,EAAE;CACvC,AAAQ,sBAAoC;;;;;;CAO5C,YAAY,WAA6B;AACvC,MAAI,UACF,MAAK,YAAY;;;;;CAOrB,UAAU,QAA+D;AACvE,OAAK,QAAQ,IAAI,OAAO,MAAM,OAAO;AACrC,SAAO;;;;;;;;CAST,UAAyC,MAA6B;AACpE,SAAO,KAAK,QAAQ,IAAI,KAAK;;;;;;;CAQ/B,aAAoC;AAClC,SAAO,MAAM,KAAK,KAAK,QAAQ,QAAQ,CAAC;;;;;;;CAQ1C,cAAqC;AACnC,SAAO,KAAK,YAAY;;;;;;;CAQ1B,MAAM,aAA4B;AAEhC,MAAI,KAAK,sBACP,QAAO,KAAK;AAId,MAAI,KAAK,YACP;AAIF,MAAI,KAAK,qBAAqB;AAE5B,WAAQ,uDAAuD;AAE/D,QAAK,sBAAsB;;AAI7B,OAAK,wBAAwB,KAAK,cAAc;AAEhD,MAAI;AACF,SAAM,KAAK;YACH;AAER,QAAK,wBAAwB;;;CAIjC,MAAc,eAA8B;EAC1C,MAAM,eAAe,MAAM,KAAK,KAAK,QAAQ,QA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AOT,QAA8B;EAC5B,MAAM,UAAU,IAAI,qBAAqB,KAAK,UAAU;AAGxD,OAAK,QAAQ,SAAQ,WAAU,QAAQ,UAAU,OAAO,CAAC;AAGzD,MACE,KAAK,kBACL,OAAO,YAAY,eACnB,QAAQ,IAAI,iBAAiB,OAG7B,EAAM,YAAY;AAChB,OAAI;AACF,UAAM,QAAQ,YAAY;YACnB,OAAO;AAKd,QAAI;AACF,cAAS,sCAAsC,EAAE,OAAO,CAAC;YACnD;;MAIR;AAGN,SAAO;;;;;;CAOT,MAAM,oBAAmD;EACvD,MAAM,UAAU,IAAI,qBAAqB,KAAK,UAAU;AAGxD,OAAK,QAAQ,SAAQ,WAAU,QAAQ,UAAU,OAAO,CAAC;AAGzD,MAAI;AACF,SAAM,QAAQ,YAAY;UACpB;AAKR,SAAO;;;;;;CAOT,OAAO,SAA+B;AACpC,SAAO,IAAI,sBAAsB;;;;;;;;;;;;;;;;;;;;;;;;;AChGrC,SAAgB,oBACd,SACA,SAGsB;CACtB,MAAM,UAAU,IAAI,sBAAsB;AAE1C,KAAI,SAAS,mBAAmB,OAC9B,SAAQ,mBAAmB,QAAQ,eAAe;AAGpD,QAAO,QAAQ,YAAY,QAAQ,CAAC,OAAO"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { t as ObservabilityManager } from "./manager-
|
|
1
|
+
import { t as ObservabilityManager } from "./manager-0G9cdhWY.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/hooks/useObservability.d.ts
|
|
4
4
|
declare function setObservabilityPromise(promise: Promise<ObservabilityManager>): void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"hooks-useObservability.mjs","names":[],"sources":["../src/hooks/useObservability.ts"],"sourcesContent":["/**\n * @fileoverview React hooks for observability integration\n * React hooks for observability integration\n * Optimized for React 19 features including use() hook and automatic error boundaries\n */\n\n'use client';\n\nimport { use, useEffect, useSyncExternalStore } from 'react';\n\nimport { logDebug, logError } from '@
|
|
1
|
+
{"version":3,"file":"hooks-useObservability.mjs","names":[],"sources":["../src/hooks/useObservability.ts"],"sourcesContent":["/**\n * @fileoverview React hooks for observability integration\n * React hooks for observability integration\n * Optimized for React 19 features including use() hook and automatic error boundaries\n */\n\n'use client';\n\nimport { use, useEffect, useSyncExternalStore } from 'react';\n\nimport { logDebug, logError } from '@od-oneapp/shared/logs';\n\nimport type { ObservabilityManager } from '../core/manager';\n\n/**\n * Global observability instance promise for React 19's use() hook\n * This allows components to suspend while waiting for initialization\n */\nlet observabilityPromise: Promise<ObservabilityManager> | null = null;\n\n/**\n * Set the observability promise for React 19 Suspense integration\n * @param promise - Promise that resolves to ObservabilityManager\n */\nexport function setObservabilityPromise(promise: Promise<ObservabilityManager>): void {\n observabilityPromise = promise;\n}\n\n/**\n * React 19+ hook that suspends until observability is ready\n * Uses the new use() hook for automatic Suspense integration\n *\n * @example\n * ```tsx\n * 'use client';\n *\n * import { Suspense } from 'react';\n * import { useObservability } from '@repo/observability/hooks/useObservability';\n * import { logInfo } from '@od-oneapp/shared/logs';\n *\n * function MyComponent() {\n * const observability = useObservability();\n *\n * useEffect(() => {\n * logInfo('Component mounted');\n * }, [observability]);\n *\n * return <div>Hello</div>;\n * }\n *\n * export default function Page() {\n * return (\n * <Suspense fallback={<div>Loading...</div>}>\n * <MyComponent />\n * </Suspense>\n * );\n * }\n * ```\n */\nexport function useObservability(): ObservabilityManager {\n if (!observabilityPromise) {\n throw new Error(\n 'Observability promise not set. Call setObservabilityPromise() during module initialization.',\n );\n }\n\n // React 19's use() hook automatically suspends until promise resolves\n return use(observabilityPromise);\n}\n\n// Module-level state for legacy hook (fixes state recreation bug)\nlet legacyCurrentInstance: ObservabilityManager | undefined = undefined;\nconst legacyListeners = new Set<() => void>();\nlet legacyInitialized = false;\n\n/**\n * Legacy hook for React 18 compatibility\n * Returns observability instance once available, undefined during initialization\n * Does not use Suspense\n *\n * @deprecated Use useObservability() with Suspense for React 19+\n */\nexport function useObservabilityLegacy(): ObservabilityManager | undefined {\n const subscribe = (callback: () => void) => {\n legacyListeners.add(callback);\n\n // If promise exists and instance not yet resolved, wait for it\n if (observabilityPromise && !legacyInitialized) {\n legacyInitialized = true;\n void (async () => {\n try {\n const instance = await observabilityPromise;\n legacyCurrentInstance = instance;\n legacyListeners.forEach(listener => {\n listener();\n });\n } catch {\n legacyInitialized = false; // Allow retry on failure\n }\n })();\n }\n\n return () => {\n legacyListeners.delete(callback);\n };\n };\n\n const getSnapshot = (): ObservabilityManager | undefined => {\n return legacyCurrentInstance;\n };\n\n return useSyncExternalStore(subscribe, getSnapshot);\n}\n\n/**\n * Hook to track component lifecycle events\n * Automatically logs mount, update, and unmount events\n *\n * @param componentName - Name of the component for logging\n * @param deps - Dependencies to track for updates\n *\n * @example\n * ```tsx\n * 'use client';\n *\n * import { useObservabilityLifecycle } from '@repo/observability/hooks/useObservability';\n *\n * function UserProfile({ userId }: { userId: string }) {\n * useObservabilityLifecycle('UserProfile', [userId]);\n *\n * return <div>User {userId}</div>;\n * }\n * ```\n */\nexport function useObservabilityLifecycle(\n componentName: string,\n deps: readonly unknown[] = [],\n): void {\n useEffect(() => {\n // Log mount\n logDebug(`Component mounted: ${componentName}`, {\n component: componentName,\n event: 'mount',\n });\n\n // Log unmount\n return () => {\n logDebug(`Component unmounted: ${componentName}`, {\n component: componentName,\n event: 'unmount',\n });\n };\n }, deps);\n}\n\n/**\n * Hook to automatically report errors to observability\n * Compatible with React 19 error boundaries\n *\n * @param error - Error to report\n * @param errorInfo - Additional error information\n *\n * @example\n * ```tsx\n * 'use client';\n *\n * import { useObservabilityError } from '@repo/observability/hooks/useObservability';\n *\n * function MyComponent() {\n * const [error, setError] = useState<Error | null>(null);\n *\n * useObservabilityError(error, { component: 'MyComponent' });\n *\n * if (error) {\n * return <div>Error occurred</div>;\n * }\n *\n * return <div>Hello</div>;\n * }\n * ```\n */\nexport function useObservabilityError(\n error: Error | null | undefined,\n errorInfo?: Record<string, unknown>,\n): void {\n useEffect(() => {\n if (error && observabilityPromise) {\n void (async () => {\n try {\n const obs = await observabilityPromise;\n obs.captureException(error, {\n extra: errorInfo,\n tags: {\n source: 'react-component',\n },\n });\n } catch (reportError) {\n logError('Failed to report error to observability', {\n error: reportError,\n originalError: error,\n });\n }\n })();\n }\n }, [error, errorInfo]);\n}\n"],"mappings":";;;;;;;;;;;;;;;AAkBA,IAAI,uBAA6D;;;;;AAMjE,SAAgB,wBAAwB,SAA8C;AACpF,wBAAuB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkCzB,SAAgB,mBAAyC;AACvD,KAAI,CAAC,qBACH,OAAM,IAAI,MACR,8FACD;AAIH,QAAO,IAAI,qBAAqB;;AAIlC,IAAI,wBAA0D;AAC9D,MAAM,kCAAkB,IAAI,KAAiB;AAC7C,IAAI,oBAAoB;;;;;;;;AASxB,SAAgB,yBAA2D;CACzE,MAAM,aAAa,aAAyB;AAC1C,kBAAgB,IAAI,SAAS;AAG7B,MAAI,wBAAwB,CAAC,mBAAmB;AAC9C,uBAAoB;AACpB,IAAM,YAAY;AAChB,QAAI;AAEF,6BADiB,MAAM;AAEvB,qBAAgB,SAAQ,aAAY;AAClC,gBAAU;OACV;YACI;AACN,yBAAoB;;OAEpB;;AAGN,eAAa;AACX,mBAAgB,OAAO,SAAS;;;CAIpC,MAAM,oBAAsD;AAC1D,SAAO;;AAGT,QAAO,qBAAqB,WAAW,YAAY;;;;;;;;;;;;;;;;;;;;;;AAuBrD,SAAgB,0BACd,eACA,OAA2B,EAAE,EACvB;AACN,iBAAgB;AAEd,WAAS,sBAAsB,iBAAiB;GAC9C,WAAW;GACX,OAAO;GACR,CAAC;AAGF,eAAa;AACX,YAAS,wBAAwB,iBAAiB;IAChD,WAAW;IACX,OAAO;IACR,CAAC;;IAEH,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BV,SAAgB,sBACd,OACA,WACM;AACN,iBAAgB;AACd,MAAI,SAAS,qBACX,EAAM,YAAY;AAChB,OAAI;AAEF,KADY,MAAM,sBACd,iBAAiB,OAAO;KAC1B,OAAO;KACP,MAAM,EACJ,QAAQ,mBACT;KACF,CAAC;YACK,aAAa;AACpB,aAAS,2CAA2C;KAClD,OAAO;KACP,eAAe;KAChB,CAAC;;MAEF;IAEL,CAAC,OAAO,UAAU,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { i as PluginLifecycle, n as ObservabilityServerPlugin, t as ObservabilityPlugin } from "./plugin-
|
|
2
|
-
import { t as ObservabilityManager } from "./manager-
|
|
1
|
+
import { i as PluginLifecycle, n as ObservabilityServerPlugin, t as ObservabilityPlugin } from "./plugin-BqLvYLQZ.mjs";
|
|
2
|
+
import { t as ObservabilityManager } from "./manager-0G9cdhWY.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/factory/builder.d.ts
|
|
5
5
|
declare class ObservabilityBuilder {
|
|
@@ -21,4 +21,4 @@ declare function createObservability(plugins: (ObservabilityPlugin | Observabili
|
|
|
21
21
|
}): ObservabilityManager;
|
|
22
22
|
//#endregion
|
|
23
23
|
export { ObservabilityBuilder as n, createObservability as t };
|
|
24
|
-
//# sourceMappingURL=index-
|
|
24
|
+
//# sourceMappingURL=index-CyBL4Sra.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index-
|
|
1
|
+
{"version":3,"file":"index-CyBL4Sra.d.mts","names":[],"sources":["../src/factory/builder.ts","../src/factory/index.ts"],"mappings":";;;;cAkBa,oBAAA;EAAA,QACH,OAAA;EAAA,QACA,SAAA;EAAA,QACA,cAAA;EAOR,UAAA,CAAW,MAAA,EAAQ,mBAAA,GAAsB,yBAAA;EAYzC,WAAA,CAAY,OAAA,GAAU,mBAAA,GAAsB,yBAAA;EAa5C,aAAA,CAAc,SAAA,EAAW,eAAA;EAQzB,kBAAA,CAAmB,cAAA;EASnB,KAAA,CAAA,GAAS,oBAAA;EAqCH,iBAAA,CAAA,GAAqB,OAAA,CAAQ,oBAAA;EAAA,OAqB5B,MAAA,CAAA,GAAU,oBAAA;AAAA;;;iBC/FH,mBAAA,CACd,OAAA,GAAU,mBAAA,GAAsB,yBAAA,KAChC,OAAA;EACE,cAAA;AAAA,IAED,oBAAA"}
|
package/index.mjs
CHANGED
package/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/shared.ts"],"sourcesContent":["/**\n * @fileoverview Shared observability utilities and types\n * Shared observability utilities and types\n */\n\nimport { logWarn } from '@
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/shared.ts"],"sourcesContent":["/**\n * @fileoverview Shared observability utilities and types\n * Shared observability utilities and types\n */\n\nimport { logWarn } from '@od-oneapp/shared/logger';\n\n/**\n * Get runtime environment information.\n *\n * Detects the current runtime environment (browser, Node.js, edge, Bun) and returns\n * detailed information about the environment type, version, and capabilities.\n *\n * @returns Runtime information object with type, version, and environment-specific details\n *\n * @example\n * ```typescript\n * const runtime = getRuntimeInfo();\n * // Returns: { type: 'node', version: '22.0.0', major: 22, minor: 0, isNode22Plus: true, isNextJs: true }\n * // or: { type: 'browser', isNextJs: true }\n * // or: { type: 'edge', variant: 'vercel' }\n * ```\n */\nexport const getRuntimeInfo = () => {\n // Edge runtime detection (Vercel Edge, Cloudflare Workers)\n if (typeof globalThis !== 'undefined' && (globalThis as any).EdgeRuntime) {\n return { type: 'edge', variant: 'vercel' };\n }\n if (\n typeof globalThis !== 'undefined' &&\n (globalThis as any).caches &&\n typeof (globalThis as any).caches !== 'undefined'\n ) {\n return { type: 'edge', variant: 'cloudflare' };\n }\n\n // Bun detection\n if (typeof process !== 'undefined' && process.versions?.bun) {\n return { type: 'bun', version: process.versions.bun };\n }\n\n // Browser detection (more robust)\n if (\n typeof globalThis !== 'undefined' &&\n 'window' in globalThis &&\n typeof (globalThis as any).window !== 'undefined' &&\n typeof (globalThis as any).window.document !== 'undefined' &&\n typeof (globalThis as any).window.navigator !== 'undefined'\n ) {\n return { type: 'browser', isNextJs: Boolean((globalThis as any).window.__NEXT_DATA__) };\n }\n\n // Node.js detection with version check\n if (typeof process !== 'undefined' && process.versions?.node) {\n const nodeVersion = parseInt(process.versions.node.split('.')[0] ?? '0');\n const nodeVersionMinor = parseInt(process.versions.node.split('.')[1] ?? '0');\n\n if (nodeVersion < 22) {\n // Note: Using logWarn here - observability system may not be initialized yet, but shared logger is always available\n logWarn(\n `[Observability] Node ${process.versions.node} detected. Node 22+ is required for optimal performance and latest features.`,\n );\n }\n\n return {\n type: 'node',\n version: process.versions.node,\n major: nodeVersion,\n minor: nodeVersionMinor,\n isNode22Plus: nodeVersion >= 22,\n isNextJs:\n Boolean(process.env.NEXT_RUNTIME) ||\n Boolean(process.env.__NEXT_RUNTIME) ||\n Boolean(process.env.NEXT_PUBLIC_VERCEL_ENV),\n };\n }\n\n // Fallback\n return { type: 'unknown' };\n};\n\n// Cache the runtime info\nconst runtimeInfo = getRuntimeInfo();\n\n/**\n * Get cached runtime environment information.\n *\n * Returns the runtime information that was detected at module load time.\n * This is cached to avoid repeated detection checks.\n *\n * @returns Cached runtime information object\n *\n * @example\n * ```typescript\n * const runtime = getRuntimeEnvironment();\n * console.log(runtime.type); // 'node', 'browser', 'edge', etc.\n * ```\n */\nexport const getRuntimeEnvironment = () => runtimeInfo;\n\n/**\n * Detect if code is running in a browser environment\n * Extracted to shared utility to avoid duplication\n * @returns true if running in browser, false otherwise\n */\nexport function isBrowser(): boolean {\n return (\n typeof globalThis !== 'undefined' &&\n 'window' in globalThis &&\n typeof (globalThis as any).window !== 'undefined' &&\n typeof (globalThis as any).window.document !== 'undefined' &&\n typeof (globalThis as any).window.navigator !== 'undefined'\n );\n}\n\n/**\n * Determine if console logging should be enabled based on environment\n * Centralized logic to avoid duplication across entry points\n * @param envNodeEnv - The NEXT_PUBLIC_NODE_ENV value\n * @param consoleEnabled - The NEXT_PUBLIC_OBSERVABILITY_CONSOLE_ENABLED value (explicit control)\n * @param debugEnabled - The NEXT_PUBLIC_OBSERVABILITY_DEBUG value\n * @returns boolean indicating if console should be enabled\n */\nexport function shouldEnableConsole(\n envNodeEnv?: string,\n consoleEnabled?: boolean,\n debugEnabled?: boolean,\n): boolean {\n const isDevelopment = envNodeEnv === 'development' || process.env.NODE_ENV === 'development';\n\n // Priority: explicit control > development mode > debug mode\n if (consoleEnabled !== undefined) {\n return consoleEnabled;\n }\n if (isDevelopment) {\n return true;\n }\n return debugEnabled ?? false;\n}\n\n// Export types for convenience - removed for Rollup compatibility\n\n// Note: For direct access to observability instances, import from environment-specific modules:\n// - @repo/observability/client-next\n// - @repo/observability/server-next\n// - @repo/observability/server-edge\n// - @repo/observability/client\n// - @repo/observability/server\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,uBAAuB;AAElC,KAAI,OAAO,eAAe,eAAgB,WAAmB,YAC3D,QAAO;EAAE,MAAM;EAAQ,SAAS;EAAU;AAE5C,KACE,OAAO,eAAe,eACrB,WAAmB,UACpB,OAAQ,WAAmB,WAAW,YAEtC,QAAO;EAAE,MAAM;EAAQ,SAAS;EAAc;AAIhD,KAAI,OAAO,YAAY,eAAe,QAAQ,UAAU,IACtD,QAAO;EAAE,MAAM;EAAO,SAAS,QAAQ,SAAS;EAAK;AAIvD,KACE,OAAO,eAAe,eACtB,YAAY,cACZ,OAAQ,WAAmB,WAAW,eACtC,OAAQ,WAAmB,OAAO,aAAa,eAC/C,OAAQ,WAAmB,OAAO,cAAc,YAEhD,QAAO;EAAE,MAAM;EAAW,UAAU,QAAS,WAAmB,OAAO,cAAc;EAAE;AAIzF,KAAI,OAAO,YAAY,eAAe,QAAQ,UAAU,MAAM;EAC5D,MAAM,cAAc,SAAS,QAAQ,SAAS,KAAK,MAAM,IAAI,CAAC,MAAM,IAAI;EACxE,MAAM,mBAAmB,SAAS,QAAQ,SAAS,KAAK,MAAM,IAAI,CAAC,MAAM,IAAI;AAE7E,MAAI,cAAc,GAEhB,SACE,wBAAwB,QAAQ,SAAS,KAAK,8EAC/C;AAGH,SAAO;GACL,MAAM;GACN,SAAS,QAAQ,SAAS;GAC1B,OAAO;GACP,OAAO;GACP,cAAc,eAAe;GAC7B,UACE,QAAQ,QAAQ,IAAI,aAAa,IACjC,QAAQ,QAAQ,IAAI,eAAe,IACnC,QAAQ,QAAQ,IAAI,uBAAuB;GAC9C;;AAIH,QAAO,EAAE,MAAM,WAAW;;AAI5B,MAAM,cAAc,gBAAgB;;;;;;;;;;;;;;;AAgBpC,MAAa,8BAA8B;;;;;;AAO3C,SAAgB,YAAqB;AACnC,QACE,OAAO,eAAe,eACtB,YAAY,cACZ,OAAQ,WAAmB,WAAW,eACtC,OAAQ,WAAmB,OAAO,aAAa,eAC/C,OAAQ,WAAmB,OAAO,cAAc;;;;;;;;;;AAYpD,SAAgB,oBACd,YACA,gBACA,cACS;CACT,MAAM,gBAAgB,eAAe,iBAAiB;AAGtD,KAAI,mBAAmB,OACrB,QAAO;AAET,KAAI,cACF,QAAO;AAET,QAAO,gBAAgB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as Breadcrumb, d as ObservabilityServer, f as ObservabilityUser, i as PluginLifecycle, l as ObservabilityContext, n as ObservabilityServerPlugin, o as LogLevel, t as ObservabilityPlugin, u as ObservabilityScope } from "./plugin-
|
|
1
|
+
import { a as Breadcrumb, d as ObservabilityServer, f as ObservabilityUser, i as PluginLifecycle, l as ObservabilityContext, n as ObservabilityServerPlugin, o as LogLevel, t as ObservabilityPlugin, u as ObservabilityScope } from "./plugin-BqLvYLQZ.mjs";
|
|
2
2
|
|
|
3
3
|
//#region src/core/manager.d.ts
|
|
4
4
|
declare class ObservabilityManager implements ObservabilityServer {
|
|
@@ -30,4 +30,4 @@ declare class ObservabilityManager implements ObservabilityServer {
|
|
|
30
30
|
}
|
|
31
31
|
//#endregion
|
|
32
32
|
export { ObservabilityManager as t };
|
|
33
|
-
//# sourceMappingURL=manager-
|
|
33
|
+
//# sourceMappingURL=manager-0G9cdhWY.d.mts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"manager-
|
|
1
|
+
{"version":3,"file":"manager-0G9cdhWY.d.mts","names":[],"sources":["../src/core/manager.ts"],"mappings":";;;cAqBa,oBAAA,YAAgC,mBAAA;EAAA,QACnC,OAAA;EAAA,QACA,WAAA;EAAA,QACA,qBAAA;EAAA,QACA,SAAA;EAAA,QACA,mBAAA;cAOI,SAAA,GAAY,eAAA;EASxB,SAAA,CAAU,MAAA,EAAQ,mBAAA,GAAsB,yBAAA;EAWxC,SAAA,WAAoB,mBAAA,CAAA,CAAqB,IAAA,WAAe,CAAA;EASxD,UAAA,CAAA,GAAc,mBAAA;EASd,WAAA,CAAA,GAAe,mBAAA;EAST,UAAA,CAAA,GAAc,OAAA;EAAA,QA8BN,YAAA;EAiCd,sBAAA,CAAA;EAQA,sBAAA,CAAA,GAA0B,KAAA;EAOpB,QAAA,CAAA,GAAY,OAAA;EAyBlB,gBAAA,CAAiB,KAAA,EAAO,KAAA,YAAiB,OAAA,GAAU,oBAAA;EAWnD,cAAA,CAAe,OAAA,UAAiB,KAAA,GAAO,QAAA,EAAmB,OAAA,GAAU,oBAAA;EAAA,QAS5D,YAAA;EAiER,OAAA,CAAQ,IAAA,EAAM,iBAAA;EAUd,aAAA,CAAc,UAAA,EAAY,UAAA;EAS1B,SAAA,CAAU,QAAA,GAAW,KAAA,EAAO,kBAAA;EAYtB,KAAA,CAAM,OAAA,YAAmB,OAAA;EAAA,QAmBvB,SAAA;EA4BR,iBAAA,CAAA;EASA,qBAAA,CAAA;AAAA"}
|