@od-oneapp/observability 2026.2.2001-canary.1 → 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.
Files changed (51) hide show
  1. package/client-next.d.mts +6 -6
  2. package/client-next.mjs +4 -4
  3. package/client.d.mts +3 -3
  4. package/client.mjs +1 -1
  5. package/{core-BgKCqXjb.mjs → core-BKuLZf5B.mjs} +5 -5
  6. package/core-BKuLZf5B.mjs.map +1 -0
  7. package/env.d.mts +2 -2
  8. package/env.mjs +1 -1
  9. package/{factory-d1469fpz.mjs → factory-CuW4AM5b.mjs} +2 -2
  10. package/{factory-d1469fpz.mjs.map → factory-CuW4AM5b.mjs.map} +1 -1
  11. package/hooks-useObservability.d.mts +1 -1
  12. package/hooks-useObservability.mjs +1 -1
  13. package/{index-CktVJJqJ.d.mts → index-CyBL4Sra.d.mts} +3 -3
  14. package/{index-CktVJJqJ.d.mts.map → index-CyBL4Sra.d.mts.map} +1 -1
  15. package/index.mjs +1 -1
  16. package/{manager-CONEYB97.d.mts → manager-0G9cdhWY.d.mts} +2 -2
  17. package/{manager-CONEYB97.d.mts.map → manager-0G9cdhWY.d.mts.map} +1 -1
  18. package/package.json +23 -3
  19. package/{plugin-LhaOv4eq.mjs → plugin-AzRcMmXa.mjs} +2 -2
  20. package/{plugin-LhaOv4eq.mjs.map → plugin-AzRcMmXa.mjs.map} +1 -1
  21. package/{plugin-DApSl5bY.mjs → plugin-BjJ3pgvT.mjs} +2 -2
  22. package/{plugin-DApSl5bY.mjs.map → plugin-BjJ3pgvT.mjs.map} +1 -1
  23. package/{plugin-pvH_kv0a.d.mts → plugin-BqLvYLQZ.d.mts} +1 -1
  24. package/{plugin-pvH_kv0a.d.mts.map → plugin-BqLvYLQZ.d.mts.map} +1 -1
  25. package/{plugin-CuRZ8qQf.mjs → plugin-BrzKQ9II.mjs} +2 -2
  26. package/{plugin-CuRZ8qQf.mjs.map → plugin-BrzKQ9II.mjs.map} +1 -1
  27. package/{plugin-81171XQL.d.mts → plugin-C11_suJr.d.mts} +2 -2
  28. package/{plugin-81171XQL.d.mts.map → plugin-C11_suJr.d.mts.map} +1 -1
  29. package/{plugin-CEOGIJFN.d.mts → plugin-Cn23gGuY.d.mts} +2 -2
  30. package/{plugin-CEOGIJFN.d.mts.map → plugin-Cn23gGuY.d.mts.map} +1 -1
  31. package/plugins-betterstack-env.mjs +1 -1
  32. package/plugins-betterstack.d.mts +2 -2
  33. package/plugins-betterstack.mjs +1 -1
  34. package/plugins-console.d.mts +1 -1
  35. package/plugins-sentry-env.mjs +1 -1
  36. package/plugins-sentry-microfrontend-env.mjs +1 -1
  37. package/plugins-sentry-microfrontend.d.mts +1 -1
  38. package/plugins-sentry-microfrontend.mjs +1 -1
  39. package/plugins-sentry.d.mts +2 -2
  40. package/plugins-sentry.mjs +1 -1
  41. package/server-edge.d.mts +4 -4
  42. package/server-edge.mjs +2 -2
  43. package/server-next.d.mts +6 -6
  44. package/server-next.mjs +4 -4
  45. package/server.d.mts +3 -3
  46. package/server.mjs +1 -1
  47. package/{utils-6Gg4fkvH.d.mts → utils-BGdqvezr.d.mts} +3 -3
  48. package/{utils-6Gg4fkvH.d.mts.map → utils-BGdqvezr.d.mts.map} +1 -1
  49. package/core-BgKCqXjb.mjs.map +0 -1
  50. package/logs-DkncIKEw.mjs +0 -112
  51. package/logs-DkncIKEw.mjs.map +0 -1
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-pvH_kv0a.mjs";
2
- import { t as ObservabilityManager } from "./manager-CONEYB97.mjs";
3
- import { n as ObservabilityBuilder, t as createObservability } from "./index-CktVJJqJ.mjs";
4
- import { n as BetterStackPluginConfig, t as BetterStackPlugin } from "./plugin-CEOGIJFN.mjs";
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-81171XQL.mjs";
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-6Gg4fkvH.mjs";
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-d1469fpz.mjs";
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-LhaOv4eq.mjs";
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-DApSl5bY.mjs";
9
- import { t as SentryMicroFrontendPlugin } from "./plugin-CuRZ8qQf.mjs";
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-pvH_kv0a.mjs";
2
- import { t as ObservabilityManager } from "./manager-CONEYB97.mjs";
3
- import { n as ObservabilityBuilder, t as createObservability } from "./index-CktVJJqJ.mjs";
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-d1469fpz.mjs";
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
@@ -32,14 +32,14 @@ const getRuntimeInfo = () => {
32
32
  type: "edge",
33
33
  variant: "cloudflare"
34
34
  };
35
- if (typeof process !== "undefined" && process.versions?.bun) return {
36
- type: "bun",
37
- version: process.versions.bun
38
- };
39
35
  if (typeof globalThis !== "undefined" && "window" in globalThis && typeof globalThis.window !== "undefined" && typeof globalThis.window.document !== "undefined" && typeof globalThis.window.navigator !== "undefined") return {
40
36
  type: "browser",
41
37
  isNextJs: Boolean(globalThis.window.__NEXT_DATA__)
42
38
  };
39
+ if (typeof process !== "undefined" && process.versions?.bun) return {
40
+ type: "bun",
41
+ version: process.versions.bun
42
+ };
43
43
  if (typeof process !== "undefined" && process.versions?.node) {
44
44
  const nodeVersion = parseInt(process.versions.node.split(".")[0] ?? "0");
45
45
  const nodeVersionMinor = parseInt(process.versions.node.split(".")[1] ?? "0");
@@ -92,4 +92,4 @@ const logError = createLogFunction("error");
92
92
 
93
93
  //#endregion
94
94
  export { logError as n, logWarn as r, logDebug as t };
95
- //# sourceMappingURL=core-BgKCqXjb.mjs.map
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/**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,KAAI,QAEF,CAAC,QAAQ,OAAe,IAAI,YAAY,KAAK,IAAI,SAAS,QAAQ;MAGlE,CAAC,QAAQ,OAAe,IAAI,YAAY,KAAK,IAAI,QAAQ;OAEtD;GAEL,MAAM,aAAa,UAAU,KAAK,UAAU,QAAQ,GAAG;GACvD,MAAM,aAAa,aAAa,GAAG,QAAQ,GAAG,eAAe;AAE7D,GAAC,QAAQ,OAAe,IAAI,YAAY,KAAK,IAAI,WAAW;;;;;;;AAQlE,MAAa,WAAW,kBAAkB,QAAQ;;;;AAKlD,MAAa,UAAU,kBAAkB,OAAO;;;;AAKhD,MAAa,UAAU,kBAAkB,OAAO;;;;AAKhD,MAAa,WAAW,kBAAkB,QAAQ"}
package/env.d.mts CHANGED
@@ -1,12 +1,12 @@
1
1
  //#region env.d.ts
2
2
  declare const env: Readonly<{
3
3
  NEXT_PUBLIC_OBSERVABILITY_CONSOLE_ENABLED?: boolean | undefined;
4
- NEXT_PUBLIC_NODE_ENV: "development" | "test" | "production";
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" | "test" | "production";
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
@@ -1,4 +1,4 @@
1
- import { r as logWarn } from "./core-BgKCqXjb.mjs";
1
+ import { r as logWarn } from "./core-BKuLZf5B.mjs";
2
2
  import { createEnv } from "@t3-oss/env-core";
3
3
  import { z } from "zod/v4";
4
4
 
@@ -1,4 +1,4 @@
1
- import { n as logError, r as logWarn } from "./logs-DkncIKEw.mjs";
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-d1469fpz.mjs.map
380
+ //# sourceMappingURL=factory-CuW4AM5b.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory-d1469fpz.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"],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AAU,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
+ {"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,QAAQ,CAAC,CACnD,QAAO,WAAU,OAAO,WAAW,OAAO,WAAW,CACrD,IAAI,OAAM,WAAU;AACnB,OAAI;AACF,QAAI,OAAO,WACT,OAAM,OAAO,YAAY;AAE3B,SAAK,UAAU,gBAAgB,OAAO;YAC/B,OAAO;AACd,aAAS,+BAA+B,OAAO,QAAQ;KACrD;KACA,YAAY,OAAO;KACpB,CAAC;AACF,SAAK,UAAU,UAAU,OAAgB,OAAO;AAEhD,UAAM;;IAER;AAEJ,MAAI;AACF,SAAM,QA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;;;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-CONEYB97.mjs";
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,6 +1,6 @@
1
1
  'use client';
2
2
 
3
- import { n as logError, t as logDebug } from "./logs-DkncIKEw.mjs";
3
+ import { n as logError, t as logDebug } from "./core-BKuLZf5B.mjs";
4
4
  import { use, useEffect, useSyncExternalStore } from "react";
5
5
 
6
6
  //#region src/hooks/useObservability.ts
@@ -1,5 +1,5 @@
1
- import { i as PluginLifecycle, n as ObservabilityServerPlugin, t as ObservabilityPlugin } from "./plugin-pvH_kv0a.mjs";
2
- import { t as ObservabilityManager } from "./manager-CONEYB97.mjs";
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-CktVJJqJ.d.mts.map
24
+ //# sourceMappingURL=index-CyBL4Sra.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index-CktVJJqJ.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"}
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
@@ -1,4 +1,4 @@
1
- import { r as logWarn } from "./core-BgKCqXjb.mjs";
1
+ import { r as logWarn } from "./core-BKuLZf5B.mjs";
2
2
 
3
3
  //#region src/shared.ts
4
4
  /**
@@ -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-pvH_kv0a.mjs";
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-CONEYB97.d.mts.map
33
+ //# sourceMappingURL=manager-0G9cdhWY.d.mts.map
@@ -1 +1 @@
1
- {"version":3,"file":"manager-CONEYB97.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,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EAAA,QAmBvB,SAAA;EA4BR,iBAAA,CAAA;EASA,qBAAA,CAAA;AAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@od-oneapp/observability",
3
- "version": "2026.2.2001-canary.1",
3
+ "version": "2026.2.2301-canary",
4
4
  "description": "Observability package with provider subpackages",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -81,8 +81,6 @@
81
81
  "default": "./hooks-useObservability.mjs"
82
82
  }
83
83
  },
84
- "peerDependencies": {},
85
- "peerDependenciesMeta": {},
86
84
  "repository": {
87
85
  "type": "git",
88
86
  "url": "https://github.com/OneDigital-Product/monorepo.git",
@@ -169,5 +167,27 @@
169
167
  }
170
168
  },
171
169
  "registry": "https://registry.npmjs.org/"
170
+ },
171
+ "main": "./index.mjs",
172
+ "types": "./index.d.mts",
173
+ "dependencies": {
174
+ "@od-oneapp/integration-betterstack": "canary",
175
+ "@od-oneapp/integration-sentry": "canary",
176
+ "@sentry/nextjs": "^10.38.0",
177
+ "@od-oneapp/shared": "canary",
178
+ "@t3-oss/env-core": "^0.13.10",
179
+ "zod": "4.3.6"
180
+ },
181
+ "peerDependencies": {
182
+ "next": "16.1.6",
183
+ "react": "^19.2.4"
184
+ },
185
+ "peerDependenciesMeta": {
186
+ "next": {
187
+ "optional": true
188
+ },
189
+ "react": {
190
+ "optional": true
191
+ }
172
192
  }
173
193
  }
@@ -1,4 +1,4 @@
1
- import { n as logError, r as logWarn } from "./core-BgKCqXjb.mjs";
1
+ import { n as logError, r as logWarn } from "./core-BKuLZf5B.mjs";
2
2
  import { safeEnv } from "./plugins-betterstack-env.mjs";
3
3
 
4
4
  //#region src/plugins/betterstack/plugin.ts
@@ -231,4 +231,4 @@ const createBetterStackPlugin = (config) => {
231
231
 
232
232
  //#endregion
233
233
  export { createBetterStackPlugin as n, BetterStackPlugin as t };
234
- //# sourceMappingURL=plugin-LhaOv4eq.mjs.map
234
+ //# sourceMappingURL=plugin-AzRcMmXa.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"plugin-LhaOv4eq.mjs","names":[],"sources":["../src/plugins/betterstack/plugin.ts"],"sourcesContent":["/**\n * @fileoverview Better Stack (Logtail) plugin implementation\n * Better Stack (Logtail) plugin implementation\n * Updated to use official @logtail packages\n */\n\nimport { logError, logWarn } from '@od-oneapp/shared/logger';\n\nimport { safeEnv } from './env';\n\nimport type { ObservabilityServerPlugin } from '../../core/plugin';\nimport type {\n Breadcrumb,\n LogLevel,\n ObservabilityContext,\n ObservabilityUser,\n} from '../../core/types';\n\n/**\n * Maximum number of breadcrumbs to include in error/message context\n * Limits context size to prevent excessive data transmission\n */\nconst MAX_BREADCRUMBS_IN_CONTEXT = 10;\n\n/**\n * Maximum number of breadcrumbs to store in memory\n * Prevents unbounded memory growth while maintaining useful history\n */\nconst MAX_BREADCRUMBS_STORED = 100;\n\n/**\n * Minimal Logtail interface for common methods across all @logtail packages\n */\ninterface LogtailClient {\n info(message: string, data?: any): void;\n warn(message: string, data?: any): void;\n error(message: string, data?: any): void;\n debug(message: string, data?: any): void;\n flush(): Promise<void>;\n}\n\n/**\n * Better Stack plugin configuration\n */\nexport interface BetterStackPluginConfig {\n /**\n * The @logtail package to use (e.g., '@logtail/js', '@logtail/next')\n * If not provided, the plugin will auto-detect based on environment\n */\n logtailPackage?: string;\n\n // Core configuration options\n sourceToken?: string;\n endpoint?: string;\n logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'off';\n enabled?: boolean;\n\n // Advanced options\n batchInterval?: number;\n batchSize?: number;\n retryCount?: number;\n retryBackoff?: boolean;\n middleware?: any[];\n}\n\n/**\n * Better Stack plugin implementation using official @logtail packages\n */\n/**\n * Better Stack (Logtail) plugin implementation.\n *\n * Integrates Better Stack logging service into the observability system.\n * Uses official @logtail packages (@logtail/js or @logtail/next) for unified\n * logging across environments.\n */\nexport class BetterStackPlugin<\n T extends LogtailClient = LogtailClient,\n> implements ObservabilityServerPlugin<T> {\n name = 'betterstack';\n enabled: boolean;\n protected client: T | undefined;\n protected initialized = false;\n protected logtailPackage: string;\n protected currentUser: ObservabilityUser | null = null;\n protected breadcrumbs: Breadcrumb[] = [];\n protected breadcrumbIndex = 0;\n protected config: BetterStackPluginConfig;\n\n /**\n * Create a new BetterStackPlugin instance.\n *\n * @param config - Better Stack plugin configuration\n */\n constructor(config: BetterStackPluginConfig = {}) {\n this.config = config;\n const env = safeEnv();\n // Auto-enable if token is provided\n const hasToken =\n config.sourceToken ??\n env.BETTER_STACK_SOURCE_TOKEN ??\n env.BETTERSTACK_SOURCE_TOKEN ??\n env.LOGTAIL_SOURCE_TOKEN ??\n env.NEXT_PUBLIC_BETTER_STACK_SOURCE_TOKEN ??\n env.NEXT_PUBLIC_BETTERSTACK_TOKEN ??\n env.NEXT_PUBLIC_LOGTAIL_TOKEN;\n this.enabled = config.enabled ?? Boolean(hasToken);\n\n // Determine Logtail package to use\n this.logtailPackage = config.logtailPackage ?? this.detectLogtailPackage();\n }\n\n /**\n * Detect which Logtail package to use based on the runtime environment.\n *\n * @returns Package name ('@logtail/next' for Next.js, '@logtail/js' otherwise)\n */\n private detectLogtailPackage(): string {\n // Next.js environments use Next.js package\n if (process.env.NEXT_RUNTIME) {\n return '@logtail/next';\n }\n // All other environments use the unified js package (bundles both node and browser)\n return '@logtail/js';\n }\n\n getClient(): T | undefined {\n return this.client;\n }\n\n /**\n * Get safe environment access (for testing/mocking).\n *\n * @returns Environment configuration object\n */\n protected getSafeEnv() {\n return safeEnv();\n }\n\n async initialize(config?: BetterStackPluginConfig): Promise<void> {\n if (this.initialized || !this.enabled) return;\n\n const env = safeEnv();\n const mergedConfig = { ...this.config, ...config };\n\n // Get source token with priority: config > new env vars > legacy env vars\n const sourceToken =\n mergedConfig.sourceToken ??\n env.BETTER_STACK_SOURCE_TOKEN ??\n env.NEXT_PUBLIC_BETTER_STACK_SOURCE_TOKEN ??\n env.LOGTAIL_SOURCE_TOKEN ??\n env.BETTERSTACK_SOURCE_TOKEN ??\n env.NEXT_PUBLIC_LOGTAIL_TOKEN ??\n env.NEXT_PUBLIC_BETTERSTACK_TOKEN;\n\n if (!sourceToken) {\n logWarn('Better Stack plugin: No source token provided, skipping initialization');\n this.enabled = false;\n return;\n }\n\n try {\n // Dynamic import of the specified Logtail package\n const LogtailModule = await import(/* webpackIgnore: true */ this.logtailPackage);\n\n // Handle different export patterns\n const LogtailClass = LogtailModule.default ?? LogtailModule.Logtail ?? LogtailModule;\n\n if (!LogtailClass) {\n logError(`Better Stack plugin: Could not find Logtail class in ${this.logtailPackage}`, {\n logtailPackage: this.logtailPackage,\n });\n this.enabled = false;\n return;\n }\n\n // Build configuration object\n const logtailConfig: any = {\n sourceToken,\n };\n\n // Add optional configuration\n if (\n mergedConfig.endpoint ??\n env.BETTER_STACK_INGESTING_URL ??\n env.NEXT_PUBLIC_BETTER_STACK_INGESTING_URL\n ) {\n logtailConfig.endpoint =\n mergedConfig.endpoint ??\n env.BETTER_STACK_INGESTING_URL ??\n env.NEXT_PUBLIC_BETTER_STACK_INGESTING_URL;\n }\n\n // Initialize the client\n this.client = new LogtailClass(logtailConfig) as T;\n\n this.initialized = true;\n } catch (error) {\n logError(`Failed to import Logtail package '${this.logtailPackage}'`, {\n error,\n logtailPackage: this.logtailPackage,\n });\n this.enabled = false;\n }\n }\n\n async shutdown(): Promise<void> {\n if (this.client && this.initialized) {\n await this.client.flush();\n this.initialized = false;\n }\n }\n\n captureException(error: Error | unknown, context?: ObservabilityContext): void {\n if (!this.enabled || !this.client) return;\n\n const errorObj = error instanceof Error ? error : new Error(String(error));\n\n // Build structured data\n const data = {\n error: {\n name: errorObj.name,\n message: errorObj.message,\n stack: errorObj.stack,\n },\n context: context?.extra,\n tags: context?.tags,\n user: context?.user ?? this.currentUser,\n breadcrumbs: this.getRecentBreadcrumbs(MAX_BREADCRUMBS_IN_CONTEXT),\n };\n\n this.client.error(errorObj.message, data);\n }\n\n captureMessage(message: string, level: LogLevel = 'info', context?: ObservabilityContext): void {\n if (!this.enabled || !this.client) return;\n\n // Build structured data\n const data = {\n level,\n context: context?.extra,\n tags: context?.tags,\n user: context?.user ?? this.currentUser,\n breadcrumbs: this.getRecentBreadcrumbs(MAX_BREADCRUMBS_IN_CONTEXT),\n };\n\n // Map log levels to Logtail methods\n switch (level) {\n case 'debug':\n this.client.debug(message, data);\n break;\n case 'warning':\n this.client.warn(message, data);\n break;\n case 'error':\n this.client.error(message, data);\n break;\n case 'info':\n default:\n this.client.info(message, data);\n break;\n }\n }\n\n setUser(user: ObservabilityUser | null): void {\n if (!this.enabled) return;\n this.currentUser = user;\n }\n\n addBreadcrumb(breadcrumb: Breadcrumb): void {\n if (!this.enabled) return;\n\n const enriched = {\n ...breadcrumb,\n timestamp: breadcrumb.timestamp ?? Date.now() / 1000,\n };\n\n // Use circular buffer to avoid array reallocation\n if (this.breadcrumbs.length < MAX_BREADCRUMBS_STORED) {\n this.breadcrumbs.push(enriched);\n } else {\n // Overwrite oldest entry (circular buffer)\n this.breadcrumbs[this.breadcrumbIndex] = enriched;\n this.breadcrumbIndex = (this.breadcrumbIndex + 1) % MAX_BREADCRUMBS_STORED;\n }\n }\n\n /**\n * Get the most recent breadcrumbs in chronological order\n * @param count - Number of breadcrumbs to retrieve\n * @returns Array of recent breadcrumbs\n */\n private getRecentBreadcrumbs(count: number): Breadcrumb[] {\n const { length } = this.breadcrumbs;\n if (length === 0) return [];\n if (length <= count) return this.breadcrumbs.slice();\n\n // If buffer is not full yet, return last N items from end of array\n if (length < MAX_BREADCRUMBS_STORED) {\n return this.breadcrumbs.slice(length - count);\n }\n\n // Circular buffer logic:\n // - When the buffer is full, `this.breadcrumbIndex` points to the oldest entry (the next to be overwritten).\n // - The most recent breadcrumb is at index `(this.breadcrumbIndex - 1 + length) % length`.\n // - To get the last `count` breadcrumbs in chronological order, we start at\n // `(this.breadcrumbIndex - count + length) % length` and read `count` entries, wrapping around as needed.\n // - This ensures we always get the correct slice, even if the buffer has wrapped around.\n const result: Breadcrumb[] = [];\n const start = (this.breadcrumbIndex - count + length) % length;\n\n for (let i = 0; i < count; i++) {\n const index = (start + i) % length;\n const breadcrumb = this.breadcrumbs[index];\n if (breadcrumb) {\n result.push(breadcrumb);\n }\n }\n\n return result;\n }\n\n withScope(callback: (scope: any) => void): void {\n if (!this.enabled) return;\n\n try {\n // Simple scope implementation\n const scope = {\n setContext: (_key: string, _context: unknown) => {\n // Could store this for next log entry\n },\n setUser: (user: ObservabilityUser | null) => {\n this.setUser(user);\n },\n };\n callback(scope);\n } catch {\n // Gracefully handle scope errors\n }\n }\n\n async flush(_timeout?: number): Promise<boolean> {\n if (!this.enabled || !this.client) return true;\n\n try {\n await this.client.flush();\n return true;\n } catch (error) {\n logError('Better Stack flush error', { error });\n return false;\n }\n }\n}\n\n/**\n * Factory function to create a Better Stack plugin.\n *\n * Creates a configured BetterStackPlugin instance with optional configuration.\n * Auto-detects the appropriate @logtail package based on the environment.\n *\n * @param config - Optional Better Stack plugin configuration\n * @returns BetterStackPlugin instance\n *\n * @example\n * ```typescript\n * const betterstack = createBetterStackPlugin({\n * sourceToken: '...',\n * logLevel: 'info',\n * });\n * ```\n */\nexport const createBetterStackPlugin = <T extends LogtailClient = LogtailClient>(\n config?: BetterStackPluginConfig,\n): BetterStackPlugin<T> => {\n return new BetterStackPlugin<T>(config);\n};\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAM,6BAA6B;;;;;AAMnC,MAAM,yBAAyB;;;;;;;;;;;AA+C/B,IAAa,oBAAb,MAE0C;CACxC,OAAO;CACP;CACA,AAAU;CACV,AAAU,cAAc;CACxB,AAAU;CACV,AAAU,cAAwC;CAClD,AAAU,cAA4B,EAAE;CACxC,AAAU,kBAAkB;CAC5B,AAAU;;;;;;CAOV,YAAY,SAAkC,EAAE,EAAE;AAChD,OAAK,SAAS;EACd,MAAM,MAAM,SAAS;EAErB,MAAM,WACJ,OAAO,eACP,IAAI,6BACJ,IAAI,4BACJ,IAAI,wBACJ,IAAI,yCACJ,IAAI,iCACJ,IA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E;AAC3B,MAAI,UAAU,MAAO,QAAO,KAAK,YAAY,OAAO;AAGpD,MAAI,SAAS,uBACX,QAAO,KAAK,YAAY,MAAM,SAAS,MAAM;EAS/C,MAAM,SAAuB,EAAE;EAC/B,MAAM,SAAS,KAAK,kBAAkB,QAAQ,UAAU;AAExD,OAAK,IAAI,IAAI,GAAG,IAAI,OAAO,KAAK;GAC9B,MAAM,SAAS,QAAQ,KAAK;GAC5B,MAAM,aAAa,KAAK,YAAY;AACpC,OAAI,WACF,QAAO,KAAK,WAAW;;AAI3B,SAAO;;CAGT,UAAU,UAAsC;AAC9C,MAAI,CAAC,KAAK,QAAS;AAEnB,MAAI;AAUF,YARc;IACZ,aAAa,MAAc,aAAsB;IAGjD,UAAU,SAAmC;AAC3C,UAAK,QAAQ,KAAK;;IAErB,CACc;UACT;;CAKV,MAAM,MAAM,UAAqC;AAC/C,MAAI,CAAC,KAAK,WAAW,CAAC,KAAK,OAAQ,QAAO;AAE1C,MAAI;AACF,SAAM,KAAK,OAAO,OAAO;AACzB,UAAO;WACA,OAAO;AACd,YAAS,4BAA4B,EAAE,OAAO,CAAC;AAC/C,UAAO;;;;;;;;;;;;;;;;;;;;;AAsBb,MAAa,2BACX,WACyB;AACzB,QAAO,IAAI,kBAAqB,OAAO"}
1
+ {"version":3,"file":"plugin-AzRcMmXa.mjs","names":[],"sources":["../src/plugins/betterstack/plugin.ts"],"sourcesContent":["/**\n * @fileoverview Better Stack (Logtail) plugin implementation\n * Better Stack (Logtail) plugin implementation\n * Updated to use official @logtail packages\n */\n\nimport { logError, logWarn } from '@od-oneapp/shared/logger';\n\nimport { safeEnv } from './env';\n\nimport type { ObservabilityServerPlugin } from '../../core/plugin';\nimport type {\n Breadcrumb,\n LogLevel,\n ObservabilityContext,\n ObservabilityUser,\n} from '../../core/types';\n\n/**\n * Maximum number of breadcrumbs to include in error/message context\n * Limits context size to prevent excessive data transmission\n */\nconst MAX_BREADCRUMBS_IN_CONTEXT = 10;\n\n/**\n * Maximum number of breadcrumbs to store in memory\n * Prevents unbounded memory growth while maintaining useful history\n */\nconst MAX_BREADCRUMBS_STORED = 100;\n\n/**\n * Minimal Logtail interface for common methods across all @logtail packages\n */\ninterface LogtailClient {\n info(message: string, data?: any): void;\n warn(message: string, data?: any): void;\n error(message: string, data?: any): void;\n debug(message: string, data?: any): void;\n flush(): Promise<void>;\n}\n\n/**\n * Better Stack plugin configuration\n */\nexport interface BetterStackPluginConfig {\n /**\n * The @logtail package to use (e.g., '@logtail/js', '@logtail/next')\n * If not provided, the plugin will auto-detect based on environment\n */\n logtailPackage?: string;\n\n // Core configuration options\n sourceToken?: string;\n endpoint?: string;\n logLevel?: 'debug' | 'info' | 'warn' | 'error' | 'off';\n enabled?: boolean;\n\n // Advanced options\n batchInterval?: number;\n batchSize?: number;\n retryCount?: number;\n retryBackoff?: boolean;\n middleware?: any[];\n}\n\n/**\n * Better Stack plugin implementation using official @logtail packages\n */\n/**\n * Better Stack (Logtail) plugin implementation.\n *\n * Integrates Better Stack logging service into the observability system.\n * Uses official @logtail packages (@logtail/js or @logtail/next) for unified\n * logging across environments.\n */\nexport class BetterStackPlugin<\n T extends LogtailClient = LogtailClient,\n> implements ObservabilityServerPlugin<T> {\n name = 'betterstack';\n enabled: boolean;\n protected client: T | undefined;\n protected initialized = false;\n protected logtailPackage: string;\n protected currentUser: ObservabilityUser | null = null;\n protected breadcrumbs: Breadcrumb[] = [];\n protected breadcrumbIndex = 0;\n protected config: BetterStackPluginConfig;\n\n /**\n * Create a new BetterStackPlugin instance.\n *\n * @param config - Better Stack plugin configuration\n */\n constructor(config: BetterStackPluginConfig = {}) {\n this.config = config;\n const env = safeEnv();\n // Auto-enable if token is provided\n const hasToken =\n config.sourceToken ??\n env.BETTER_STACK_SOURCE_TOKEN ??\n env.BETTERSTACK_SOURCE_TOKEN ??\n env.LOGTAIL_SOURCE_TOKEN ??\n env.NEXT_PUBLIC_BETTER_STACK_SOURCE_TOKEN ??\n env.NEXT_PUBLIC_BETTERSTACK_TOKEN ??\n env.NEXT_PUBLIC_LOGTAIL_TOKEN;\n this.enabled = config.enabled ?? Boolean(hasToken);\n\n // Determine Logtail package to use\n this.logtailPackage = config.logtailPackage ?? this.detectLogtailPackage();\n }\n\n /**\n * Detect which Logtail package to use based on the runtime environment.\n *\n * @returns Package name ('@logtail/next' for Next.js, '@logtail/js' otherwise)\n */\n private detectLogtailPackage(): string {\n // Next.js environments use Next.js package\n if (process.env.NEXT_RUNTIME) {\n return '@logtail/next';\n }\n // All other environments use the unified js package (bundles both node and browser)\n return '@logtail/js';\n }\n\n getClient(): T | undefined {\n return this.client;\n }\n\n /**\n * Get safe environment access (for testing/mocking).\n *\n * @returns Environment configuration object\n */\n protected getSafeEnv() {\n return safeEnv();\n }\n\n async initialize(config?: BetterStackPluginConfig): Promise<void> {\n if (this.initialized || !this.enabled) return;\n\n const env = safeEnv();\n const mergedConfig = { ...this.config, ...config };\n\n // Get source token with priority: config > new env vars > legacy env vars\n const sourceToken =\n mergedConfig.sourceToken ??\n env.BETTER_STACK_SOURCE_TOKEN ??\n env.NEXT_PUBLIC_BETTER_STACK_SOURCE_TOKEN ??\n env.LOGTAIL_SOURCE_TOKEN ??\n env.BETTERSTACK_SOURCE_TOKEN ??\n env.NEXT_PUBLIC_LOGTAIL_TOKEN ??\n env.NEXT_PUBLIC_BETTERSTACK_TOKEN;\n\n if (!sourceToken) {\n logWarn('Better Stack plugin: No source token provided, skipping initialization');\n this.enabled = false;\n return;\n }\n\n try {\n // Dynamic import of the specified Logtail package\n const LogtailModule = await import(/* webpackIgnore: true */ this.logtailPackage);\n\n // Handle different export patterns\n const LogtailClass = LogtailModule.default ?? LogtailModule.Logtail ?? LogtailModule;\n\n if (!LogtailClass) {\n logError(`Better Stack plugin: Could not find Logtail class in ${this.logtailPackage}`, {\n logtailPackage: this.logtailPackage,\n });\n this.enabled = false;\n return;\n }\n\n // Build configuration object\n const logtailConfig: any = {\n sourceToken,\n };\n\n // Add optional configuration\n if (\n mergedConfig.endpoint ??\n env.BETTER_STACK_INGESTING_URL ??\n env.NEXT_PUBLIC_BETTER_STACK_INGESTING_URL\n ) {\n logtailConfig.endpoint =\n mergedConfig.endpoint ??\n env.BETTER_STACK_INGESTING_URL ??\n env.NEXT_PUBLIC_BETTER_STACK_INGESTING_URL;\n }\n\n // Initialize the client\n this.client = new LogtailClass(logtailConfig) as T;\n\n this.initialized = true;\n } catch (error) {\n logError(`Failed to import Logtail package '${this.logtailPackage}'`, {\n error,\n logtailPackage: this.logtailPackage,\n });\n this.enabled = false;\n }\n }\n\n async shutdown(): Promise<void> {\n if (this.client && this.initialized) {\n await this.client.flush();\n this.initialized = false;\n }\n }\n\n captureException(error: Error | unknown, context?: ObservabilityContext): void {\n if (!this.enabled || !this.client) return;\n\n const errorObj = error instanceof Error ? error : new Error(String(error));\n\n // Build structured data\n const data = {\n error: {\n name: errorObj.name,\n message: errorObj.message,\n stack: errorObj.stack,\n },\n context: context?.extra,\n tags: context?.tags,\n user: context?.user ?? this.currentUser,\n breadcrumbs: this.getRecentBreadcrumbs(MAX_BREADCRUMBS_IN_CONTEXT),\n };\n\n this.client.error(errorObj.message, data);\n }\n\n captureMessage(message: string, level: LogLevel = 'info', context?: ObservabilityContext): void {\n if (!this.enabled || !this.client) return;\n\n // Build structured data\n const data = {\n level,\n context: context?.extra,\n tags: context?.tags,\n user: context?.user ?? this.currentUser,\n breadcrumbs: this.getRecentBreadcrumbs(MAX_BREADCRUMBS_IN_CONTEXT),\n };\n\n // Map log levels to Logtail methods\n switch (level) {\n case 'debug':\n this.client.debug(message, data);\n break;\n case 'warning':\n this.client.warn(message, data);\n break;\n case 'error':\n this.client.error(message, data);\n break;\n case 'info':\n default:\n this.client.info(message, data);\n break;\n }\n }\n\n setUser(user: ObservabilityUser | null): void {\n if (!this.enabled) return;\n this.currentUser = user;\n }\n\n addBreadcrumb(breadcrumb: Breadcrumb): void {\n if (!this.enabled) return;\n\n const enriched = {\n ...breadcrumb,\n timestamp: breadcrumb.timestamp ?? Date.now() / 1000,\n };\n\n // Use circular buffer to avoid array reallocation\n if (this.breadcrumbs.length < MAX_BREADCRUMBS_STORED) {\n this.breadcrumbs.push(enriched);\n } else {\n // Overwrite oldest entry (circular buffer)\n this.breadcrumbs[this.breadcrumbIndex] = enriched;\n this.breadcrumbIndex = (this.breadcrumbIndex + 1) % MAX_BREADCRUMBS_STORED;\n }\n }\n\n /**\n * Get the most recent breadcrumbs in chronological order\n * @param count - Number of breadcrumbs to retrieve\n * @returns Array of recent breadcrumbs\n */\n private getRecentBreadcrumbs(count: number): Breadcrumb[] {\n const { length } = this.breadcrumbs;\n if (length === 0) return [];\n if (length <= count) return this.breadcrumbs.slice();\n\n // If buffer is not full yet, return last N items from end of array\n if (length < MAX_BREADCRUMBS_STORED) {\n return this.breadcrumbs.slice(length - count);\n }\n\n // Circular buffer logic:\n // - When the buffer is full, `this.breadcrumbIndex` points to the oldest entry (the next to be overwritten).\n // - The most recent breadcrumb is at index `(this.breadcrumbIndex - 1 + length) % length`.\n // - To get the last `count` breadcrumbs in chronological order, we start at\n // `(this.breadcrumbIndex - count + length) % length` and read `count` entries, wrapping around as needed.\n // - This ensures we always get the correct slice, even if the buffer has wrapped around.\n const result: Breadcrumb[] = [];\n const start = (this.breadcrumbIndex - count + length) % length;\n\n for (let i = 0; i < count; i++) {\n const index = (start + i) % length;\n const breadcrumb = this.breadcrumbs[index];\n if (breadcrumb) {\n result.push(breadcrumb);\n }\n }\n\n return result;\n }\n\n withScope(callback: (scope: any) => void): void {\n if (!this.enabled) return;\n\n try {\n // Simple scope implementation\n const scope = {\n setContext: (_key: string, _context: unknown) => {\n // Could store this for next log entry\n },\n setUser: (user: ObservabilityUser | null) => {\n this.setUser(user);\n },\n };\n callback(scope);\n } catch {\n // Gracefully handle scope errors\n }\n }\n\n async flush(_timeout?: number): Promise<boolean> {\n if (!this.enabled || !this.client) return true;\n\n try {\n await this.client.flush();\n return true;\n } catch (error) {\n logError('Better Stack flush error', { error });\n return false;\n }\n }\n}\n\n/**\n * Factory function to create a Better Stack plugin.\n *\n * Creates a configured BetterStackPlugin instance with optional configuration.\n * Auto-detects the appropriate @logtail package based on the environment.\n *\n * @param config - Optional Better Stack plugin configuration\n * @returns BetterStackPlugin instance\n *\n * @example\n * ```typescript\n * const betterstack = createBetterStackPlugin({\n * sourceToken: '...',\n * logLevel: 'info',\n * });\n * ```\n */\nexport const createBetterStackPlugin = <T extends LogtailClient = LogtailClient>(\n config?: BetterStackPluginConfig,\n): BetterStackPlugin<T> => {\n return new BetterStackPlugin<T>(config);\n};\n"],"mappings":";;;;;;;;;;;;;AAsBA,MAAM,6BAA6B;;;;;AAMnC,MAAM,yBAAyB;;;;;;;;;;;AA+C/B,IAAa,oBAAb,MAE0C;CACxC,OAAO;CACP;CACA,AAAU;CACV,AAAU,cAAc;CACxB,AAAU;CACV,AAAU,cAAwC;CAClD,AAAU,cAA4B,EAAE;CACxC,AAAU,kBAAkB;CAC5B,AAAU;;;;;;CAOV,YAAY,SAAkC,EAAE,EAAE;AAChD,OAAK,SAAS;EACd,MAAM,MAAM,SAAS;EAErB,MAAM,WACJ,OAAO,eACP,IAAI,6BACJ,IAAI,4BACJ,IAAI,wBACJ,IAAI,yCACJ,IAAI,iCACJ,IAAI;AACN,OAAK,UAAU,OAAO,WAAW,QAAQ,SAAS;AAGlD,OAAK,iBAAiB,OAAO,kBAAkB,KAAK,sBAAsB;;;;;;;CAQ5E,AAAQ,uBAA+B;AAErC,MAAI,QAAQ,IAAI,aACd,QAAO;AAGT,SAAO;;CAGT,YAA2B;AACzB,SAAO,KAAK;;;;;;;CAQd,AAAU,aAAa;AACrB,SAAO,SAAS;;CAGlB,MAAM,WAAW,QAAiD;AAChE,MAAI,KAAK,eAAe,CAAC,KAAK,QAAS;EAEvC,MAAM,MAAM,SAAS;EACrB,MAAM,eAAe;GAAE,GAAG,KAAK;GAAQ,GAAG;GAAQ;EAGlD,MAAM,cACJ,aAAa,eACb,IAAI,6BACJ,IAAI,y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D,UAAU,SAAmC;AAC3C,UAAK,QAAQ,KAAK;;IAErB,CACc;UACT;;CAKV,MAAM,MAAM,UAAqC;AAC/C,MAAI,CAAC,KAAK,WAAW,CAAC,KAAK,OAAQ,QAAO;AAE1C,MAAI;AACF,SAAM,KAAK,OAAO,OAAO;AACzB,UAAO;WACA,OAAO;AACd,YAAS,4BAA4B,EAAE,OAAO,CAAC;AAC/C,UAAO;;;;;;;;;;;;;;;;;;;;;AAsBb,MAAa,2BACX,WACyB;AACzB,QAAO,IAAI,kBAAqB,OAAO"}
@@ -1,4 +1,4 @@
1
- import { n as logError, r as logWarn, t as logDebug } from "./core-BgKCqXjb.mjs";
1
+ import { n as logError, r as logWarn, t as logDebug } from "./core-BKuLZf5B.mjs";
2
2
  import { isBrowser } from "./index.mjs";
3
3
  import { safeEnv } from "./plugins-sentry-env.mjs";
4
4
 
@@ -531,4 +531,4 @@ const createSentryPlugin = (config) => {
531
531
 
532
532
  //#endregion
533
533
  export { createSentryPlugin as n, defaultBeforeSendLog as r, SentryPlugin as t };
534
- //# sourceMappingURL=plugin-DApSl5bY.mjs.map
534
+ //# sourceMappingURL=plugin-BjJ3pgvT.mjs.map