@od-oneapp/observability 2026.2.2001-canary.1 → 2026.2.2899-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/README.md +65 -488
- package/client-next.d.mts +9 -10
- package/client-next.d.mts.map +1 -1
- package/client-next.mjs +32 -11
- package/client-next.mjs.map +1 -1
- package/client.d.mts +4 -4
- package/client.mjs +1 -1
- package/{core-BgKCqXjb.mjs → core-BKuLZf5B.mjs} +5 -5
- package/core-BKuLZf5B.mjs.map +1 -0
- package/env.mjs +1 -1
- package/{factory-d1469fpz.mjs → factory-3sE5n2Ox.mjs} +2 -2
- package/{factory-d1469fpz.mjs.map → factory-3sE5n2Ox.mjs.map} +1 -1
- package/hooks-useObservability.d.mts +1 -1
- package/hooks-useObservability.mjs +1 -1
- package/{index-CktVJJqJ.d.mts → index-BBs_2frZ.d.mts} +3 -3
- package/{index-CktVJJqJ.d.mts.map → index-BBs_2frZ.d.mts.map} +1 -1
- package/index.d.mts +3 -1
- package/index.d.mts.map +1 -1
- package/index.mjs +3 -2
- package/index.mjs.map +1 -1
- package/load-provider-BOS_NnZa.mjs +57 -0
- package/load-provider-BOS_NnZa.mjs.map +1 -0
- package/load-provider-mEuA8Tkf.d.mts +9 -0
- package/load-provider-mEuA8Tkf.d.mts.map +1 -0
- package/{manager-CONEYB97.d.mts → manager-GGdKqdV2.d.mts} +2 -2
- package/{manager-CONEYB97.d.mts.map → manager-GGdKqdV2.d.mts.map} +1 -1
- package/package.json +29 -3
- package/{plugin-CuRZ8qQf.mjs → plugin-BQobbBEK.mjs} +3 -3
- package/plugin-BQobbBEK.mjs.map +1 -0
- package/{plugin-pvH_kv0a.d.mts → plugin-CD6OSG7J.d.mts} +15 -2
- package/{plugin-pvH_kv0a.d.mts.map → plugin-CD6OSG7J.d.mts.map} +1 -1
- package/plugins-betterstack-env.mjs +1 -1
- package/plugins-betterstack.d.mts +25 -3
- package/plugins-betterstack.d.mts.map +1 -0
- package/plugins-betterstack.mjs +50 -2
- package/plugins-betterstack.mjs.map +1 -0
- package/plugins-console.d.mts +1 -1
- package/plugins-sentry-env.d.mts +2 -37
- package/plugins-sentry-env.mjs +2 -78
- package/plugins-sentry-microfrontend-env.mjs +1 -1
- package/plugins-sentry-microfrontend.d.mts +1 -1
- package/plugins-sentry-microfrontend.mjs +1 -1
- package/plugins-sentry.d.mts +4 -3
- package/plugins-sentry.mjs +2 -2
- package/server-edge.d.mts +7 -6
- package/server-edge.d.mts.map +1 -1
- package/server-edge.mjs +20 -7
- package/server-edge.mjs.map +1 -1
- package/server-next.d.mts +9 -9
- package/server-next.d.mts.map +1 -1
- package/server-next.mjs +38 -18
- package/server-next.mjs.map +1 -1
- package/server.d.mts +4 -4
- package/server.mjs +1 -1
- package/types-BoUA-o3M.d.mts +121 -0
- package/types-BoUA-o3M.d.mts.map +1 -0
- package/{utils-6Gg4fkvH.d.mts → utils-cqicHWHw.d.mts} +4 -4
- package/{utils-6Gg4fkvH.d.mts.map → utils-cqicHWHw.d.mts.map} +1 -1
- package/core-BgKCqXjb.mjs.map +0 -1
- package/logs-DkncIKEw.mjs +0 -112
- package/logs-DkncIKEw.mjs.map +0 -1
- package/plugin-81171XQL.d.mts +0 -254
- package/plugin-81171XQL.d.mts.map +0 -1
- package/plugin-CEOGIJFN.d.mts +0 -61
- package/plugin-CEOGIJFN.d.mts.map +0 -1
- package/plugin-CuRZ8qQf.mjs.map +0 -1
- package/plugin-DApSl5bY.mjs +0 -534
- package/plugin-DApSl5bY.mjs.map +0 -1
- package/plugin-LhaOv4eq.mjs +0 -234
- package/plugin-LhaOv4eq.mjs.map +0 -1
- package/plugins-sentry-env.d.mts.map +0 -1
- package/plugins-sentry-env.mjs.map +0 -1
package/README.md
CHANGED
|
@@ -1,523 +1,100 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @od-oneapp/observability
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
performance monitoring, and tracing across client, server, and edge environments with support for multiple providers
|
|
5
|
-
(Sentry, BetterStack, Console).
|
|
3
|
+
Centralized observability manager for OneApp.
|
|
6
4
|
|
|
7
|
-
##
|
|
5
|
+
## Current Model (Sentry-first)
|
|
8
6
|
|
|
9
|
-
-
|
|
10
|
-
-
|
|
11
|
-
-
|
|
7
|
+
- `console` is built-in
|
|
8
|
+
- `sentry` is loaded dynamically from `@od-oneapp/integration-sentry`
|
|
9
|
+
- Non-Sentry providers are not auto-loaded
|
|
10
|
+
- BetterStack exports are deprecated compatibility shims
|
|
12
11
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
**Core:**
|
|
16
|
-
|
|
17
|
-
- `.` - Shared utilities and types
|
|
18
|
-
- `./client` - Browser (non-Next.js)
|
|
19
|
-
- `./server` - Node.js server
|
|
20
|
-
- `./client/next` - Next.js client components
|
|
21
|
-
- `./server/next` - Next.js server components
|
|
22
|
-
- `./server/edge` - Edge runtime
|
|
23
|
-
- `./env` - Environment configuration
|
|
24
|
-
|
|
25
|
-
**Plugins:**
|
|
26
|
-
|
|
27
|
-
- `./plugins/console` - Console logging plugin
|
|
28
|
-
- `./plugins/sentry` - Sentry error tracking
|
|
29
|
-
- `./plugins/betterstack` - BetterStack logging
|
|
30
|
-
- `./plugins/logtape` - LogTape integration
|
|
31
|
-
- `./plugins/sentry-microfrontend` - Micro-frontend Sentry
|
|
32
|
-
|
|
33
|
-
**Environment Configs:** Each plugin exports `./plugins/{name}/env`
|
|
34
|
-
|
|
35
|
-
### AI Usage Hints
|
|
36
|
-
|
|
37
|
-
```typescript
|
|
38
|
-
// ✅ CORRECT: Logging (Canonical)
|
|
39
|
-
import { logInfo, logError } from "@od-oneapp/shared/logger";
|
|
40
|
-
|
|
41
|
-
// ✅ CORRECT: Observability initialization (Next.js Server Component)
|
|
42
|
-
import { observability } from "@repo/observability/server/next";
|
|
43
|
-
|
|
44
|
-
// ✅ CORRECT: Observability initialization (Next.js Client Component)
|
|
45
|
-
import { getObservability } from "@repo/observability/client/next";
|
|
46
|
-
|
|
47
|
-
// ✅ CORRECT: Edge Runtime (Middleware, Edge API Routes)
|
|
48
|
-
import { observability } from "@repo/observability/server/edge";
|
|
49
|
-
```
|
|
50
|
-
|
|
51
|
-
## Features
|
|
52
|
-
|
|
53
|
-
- 🔌 **Plugin-Based**: Extensible architecture supporting multiple providers
|
|
54
|
-
- 🌐 **Multi-Environment**: Client, server, Next.js, edge runtime support
|
|
55
|
-
- 📊 **Performance Monitoring**: Web Vitals, custom metrics, distributed tracing
|
|
56
|
-
- 🛡️ **Type-Safe**: Full TypeScript with strict type checking
|
|
57
|
-
- 🔄 **Graceful Degradation**: Continues operation if providers fail
|
|
58
|
-
- 🎯 **Error Tracking**: Structured error reporting with breadcrumbs
|
|
59
|
-
- 🚀 **Zero-Config**: Auto-detection based on environment variables
|
|
60
|
-
- 🔐 **Security-First**: Input validation and sanitization
|
|
61
|
-
|
|
62
|
-
## Installation
|
|
63
|
-
|
|
64
|
-
Already included in the monorepo. Add to your workspace:
|
|
12
|
+
## Install
|
|
65
13
|
|
|
66
14
|
```bash
|
|
67
|
-
pnpm add @
|
|
68
|
-
```
|
|
69
|
-
|
|
70
|
-
## Quick Start
|
|
71
|
-
|
|
72
|
-
### Next.js Client Component
|
|
73
|
-
|
|
74
|
-
```tsx
|
|
75
|
-
"use client";
|
|
76
|
-
|
|
77
|
-
import { logInfo, logError } from "@od-oneapp/shared/logger";
|
|
78
|
-
|
|
79
|
-
export function UserProfile() {
|
|
80
|
-
const handleClick = async () => {
|
|
81
|
-
try {
|
|
82
|
-
logInfo("User profile viewed", { userId: "123" });
|
|
83
|
-
// Your logic here
|
|
84
|
-
} catch (error) {
|
|
85
|
-
logError(error as Error, { component: "UserProfile" });
|
|
86
|
-
}
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
return <button onClick={handleClick}>View Profile</button>;
|
|
90
|
-
}
|
|
91
|
-
```
|
|
92
|
-
|
|
93
|
-
### Next.js Server Component
|
|
94
|
-
|
|
95
|
-
```tsx
|
|
96
|
-
import { getObservability } from "@repo/observability/server-next";
|
|
97
|
-
import { logInfo, logError } from "@od-oneapp/shared/logger";
|
|
98
|
-
|
|
99
|
-
export default async function ServerPage() {
|
|
100
|
-
const observability = await getObservability();
|
|
101
|
-
logInfo("Server page rendered", { page: "/dashboard" });
|
|
102
|
-
|
|
103
|
-
try {
|
|
104
|
-
const data = await fetchData();
|
|
105
|
-
return <div>{data}</div>;
|
|
106
|
-
} catch (error) {
|
|
107
|
-
logError(error as Error);
|
|
108
|
-
observability.captureException(error as Error);
|
|
109
|
-
throw error;
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
### API Route
|
|
115
|
-
|
|
116
|
-
```typescript
|
|
117
|
-
import { getObservability } from "@repo/observability/server-next";
|
|
118
|
-
import { logInfo, logError } from "@od-oneapp/shared/logger";
|
|
119
|
-
import { NextRequest, NextResponse } from "next/server";
|
|
120
|
-
|
|
121
|
-
export async function POST(request: NextRequest) {
|
|
122
|
-
const observability = await getObservability();
|
|
123
|
-
|
|
124
|
-
try {
|
|
125
|
-
const body = await request.json();
|
|
126
|
-
|
|
127
|
-
observability.setUser({ id: body.userId, email: body.email });
|
|
128
|
-
logInfo("API request", { endpoint: "/api/users" });
|
|
129
|
-
|
|
130
|
-
const result = await processRequest(body);
|
|
131
|
-
return NextResponse.json({ success: true, data: result });
|
|
132
|
-
} catch (error) {
|
|
133
|
-
logError(error as Error, { endpoint: "/api/users" });
|
|
134
|
-
observability.captureException(error as Error, { endpoint: "/api/users" });
|
|
135
|
-
return NextResponse.json({ error: "Internal error" }, { status: 500 });
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
```
|
|
139
|
-
|
|
140
|
-
## Environment Variables
|
|
141
|
-
|
|
142
|
-
### Core Configuration
|
|
143
|
-
|
|
144
|
-
```bash
|
|
145
|
-
NODE_ENV=development | production
|
|
146
|
-
NEXT_PUBLIC_OBSERVABILITY_DEBUG=true
|
|
147
|
-
NEXT_PUBLIC_OBSERVABILITY_CONSOLE_ENABLED=true
|
|
148
|
-
```
|
|
149
|
-
|
|
150
|
-
### Sentry
|
|
151
|
-
|
|
152
|
-
```bash
|
|
153
|
-
SENTRY_DSN=https://key@sentry.io/project
|
|
154
|
-
NEXT_PUBLIC_SENTRY_DSN=https://key@sentry.io/project # Client-side
|
|
155
|
-
SENTRY_ENVIRONMENT=production
|
|
156
|
-
SENTRY_RELEASE=v1.0.0
|
|
157
|
-
SENTRY_ORG=your-org
|
|
158
|
-
SENTRY_PROJECT=your-project
|
|
159
|
-
SENTRY_TRACES_SAMPLE_RATE=0.1
|
|
160
|
-
SENTRY_PROFILES_SAMPLE_RATE=0.1
|
|
161
|
-
SENTRY_REPLAYS_SESSION_SAMPLE_RATE=0.1
|
|
162
|
-
SENTRY_REPLAYS_ON_ERROR_SAMPLE_RATE=1.0
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### BetterStack (Logtail)
|
|
166
|
-
|
|
167
|
-
```bash
|
|
168
|
-
BETTER_STACK_SOURCE_TOKEN=your-token
|
|
169
|
-
NEXT_PUBLIC_BETTER_STACK_SOURCE_TOKEN=your-token # Client-side
|
|
170
|
-
BETTER_STACK_INGESTING_URL=https://in.logs.betterstack.com
|
|
171
|
-
BETTERSTACK_STATUS_PAGE_ID=your-page-id
|
|
172
|
-
LOGTAIL_SOURCE_TOKEN=your-token # Legacy name
|
|
173
|
-
```
|
|
174
|
-
|
|
175
|
-
## Usage Examples
|
|
176
|
-
|
|
177
|
-
### Basic Logging
|
|
178
|
-
|
|
179
|
-
```typescript
|
|
180
|
-
import { logDebug, logInfo, logWarn, logError } from "@od-oneapp/shared/logger";
|
|
181
|
-
|
|
182
|
-
logDebug("Processing request", { requestId: "123" });
|
|
183
|
-
logInfo("User logged in", { userId: "user-456" });
|
|
184
|
-
logWarn("Rate limit approaching", { currentRate: 95 });
|
|
185
|
-
logError("Failed to save data", { operation: "db.save" });
|
|
186
|
-
```
|
|
187
|
-
|
|
188
|
-
### Exception Tracking
|
|
189
|
-
|
|
190
|
-
```typescript
|
|
191
|
-
try {
|
|
192
|
-
await riskyOperation();
|
|
193
|
-
} catch (error) {
|
|
194
|
-
observability.captureException(error, {
|
|
195
|
-
extra: { userId: user.id, operation: "checkout" },
|
|
196
|
-
tags: { environment: "production", feature: "checkout" }
|
|
197
|
-
});
|
|
198
|
-
throw error;
|
|
199
|
-
}
|
|
200
|
-
```
|
|
201
|
-
|
|
202
|
-
### User Context
|
|
203
|
-
|
|
204
|
-
```typescript
|
|
205
|
-
// Set user context (attached to all future events)
|
|
206
|
-
observability.setUser({
|
|
207
|
-
id: "user-123",
|
|
208
|
-
email: "john@example.com",
|
|
209
|
-
username: "johndoe"
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
// Clear user context (e.g., on logout)
|
|
213
|
-
observability.setUser(null);
|
|
214
|
-
```
|
|
215
|
-
|
|
216
|
-
### Breadcrumbs
|
|
217
|
-
|
|
218
|
-
```typescript
|
|
219
|
-
// Track user journey
|
|
220
|
-
observability.addBreadcrumb({
|
|
221
|
-
message: "User clicked checkout",
|
|
222
|
-
category: "user-action",
|
|
223
|
-
level: "info",
|
|
224
|
-
data: { cartTotal: 99.99 }
|
|
225
|
-
});
|
|
226
|
-
|
|
227
|
-
// When error occurs, breadcrumbs provide context
|
|
228
|
-
observability.captureException(new Error("Payment failed"));
|
|
229
|
-
```
|
|
230
|
-
|
|
231
|
-
### Performance Monitoring (Sentry)
|
|
232
|
-
|
|
233
|
-
```typescript
|
|
234
|
-
import { observability, SentryPlugin } from "@repo/observability/server-next";
|
|
235
|
-
|
|
236
|
-
const sentry = observability.getPlugin<SentryPlugin>("sentry");
|
|
237
|
-
|
|
238
|
-
if (sentry) {
|
|
239
|
-
const transaction = sentry.startTransaction({
|
|
240
|
-
name: "Process Order",
|
|
241
|
-
op: "http.server"
|
|
242
|
-
});
|
|
243
|
-
|
|
244
|
-
try {
|
|
245
|
-
const span = sentry.startSpan({ name: "Validate Cart", op: "validation" });
|
|
246
|
-
await validateCart(cart);
|
|
247
|
-
span?.finish();
|
|
248
|
-
|
|
249
|
-
transaction?.finish();
|
|
250
|
-
} catch (error) {
|
|
251
|
-
transaction?.finish();
|
|
252
|
-
throw error;
|
|
253
|
-
}
|
|
254
|
-
}
|
|
255
|
-
```
|
|
256
|
-
|
|
257
|
-
### Web Vitals (Client-Side)
|
|
258
|
-
|
|
259
|
-
```tsx
|
|
260
|
-
"use client";
|
|
261
|
-
|
|
262
|
-
import { getObservability, SentryPlugin } from "@repo/observability/client-next";
|
|
263
|
-
|
|
264
|
-
export function WebVitalsReporter() {
|
|
265
|
-
useEffect(() => {
|
|
266
|
-
const reportWebVitals = async (metric: any) => {
|
|
267
|
-
const obs = await getObservability();
|
|
268
|
-
const sentry = obs.getPlugin<SentryPlugin>("sentry");
|
|
269
|
-
|
|
270
|
-
if (sentry) {
|
|
271
|
-
sentry.recordWebVital(metric.name, metric.value, {
|
|
272
|
-
rating: metric.rating,
|
|
273
|
-
unit: "millisecond"
|
|
274
|
-
});
|
|
275
|
-
}
|
|
276
|
-
};
|
|
277
|
-
|
|
278
|
-
import("web-vitals").then(({ onCLS, onFID, onFCP, onLCP, onTTFB }) => {
|
|
279
|
-
onCLS(reportWebVitals);
|
|
280
|
-
onFID(reportWebVitals);
|
|
281
|
-
onFCP(reportWebVitals);
|
|
282
|
-
onLCP(reportWebVitals);
|
|
283
|
-
onTTFB(reportWebVitals);
|
|
284
|
-
});
|
|
285
|
-
}, []);
|
|
286
|
-
|
|
287
|
-
return null;
|
|
288
|
-
}
|
|
289
|
-
```
|
|
290
|
-
|
|
291
|
-
## Provider Plugins
|
|
292
|
-
|
|
293
|
-
### Sentry
|
|
294
|
-
|
|
295
|
-
Error tracking, performance monitoring, session replay.
|
|
296
|
-
|
|
297
|
-
```typescript
|
|
298
|
-
import { createSentryPlugin } from "@repo/observability/plugins/sentry";
|
|
299
|
-
|
|
300
|
-
const sentry = createSentryPlugin({
|
|
301
|
-
dsn: process.env.SENTRY_DSN,
|
|
302
|
-
environment: process.env.NODE_ENV,
|
|
303
|
-
tracesSampleRate: 1.0,
|
|
304
|
-
replaysSessionSampleRate: 0.1
|
|
305
|
-
});
|
|
15
|
+
pnpm add @od-oneapp/observability @od-oneapp/integration-sentry @sentry/nextjs
|
|
306
16
|
```
|
|
307
17
|
|
|
308
|
-
|
|
18
|
+
## Next.js Runtime Usage
|
|
309
19
|
|
|
310
|
-
|
|
20
|
+
### Client
|
|
311
21
|
|
|
312
|
-
```
|
|
313
|
-
import {
|
|
22
|
+
```ts
|
|
23
|
+
import { createClientObservability } from '@od-oneapp/observability/client/next';
|
|
314
24
|
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
25
|
+
const obs = await createClientObservability({
|
|
26
|
+
providers: {
|
|
27
|
+
sentry: {
|
|
28
|
+
enabled: true,
|
|
29
|
+
options: {
|
|
30
|
+
dsn: process.env.NEXT_PUBLIC_SENTRY_DSN,
|
|
31
|
+
},
|
|
32
|
+
},
|
|
33
|
+
},
|
|
319
34
|
});
|
|
320
35
|
```
|
|
321
36
|
|
|
322
|
-
###
|
|
323
|
-
|
|
324
|
-
Development logging to console.
|
|
37
|
+
### Server
|
|
325
38
|
|
|
326
|
-
```
|
|
327
|
-
import {
|
|
39
|
+
```ts
|
|
40
|
+
import { createServerObservability } from '@od-oneapp/observability/server/next';
|
|
328
41
|
|
|
329
|
-
const
|
|
330
|
-
|
|
331
|
-
|
|
42
|
+
const obs = await createServerObservability({
|
|
43
|
+
providers: {
|
|
44
|
+
sentry: {
|
|
45
|
+
enabled: true,
|
|
46
|
+
options: {
|
|
47
|
+
dsn: process.env.SENTRY_DSN,
|
|
48
|
+
},
|
|
49
|
+
},
|
|
50
|
+
},
|
|
332
51
|
});
|
|
333
52
|
```
|
|
334
53
|
|
|
335
|
-
###
|
|
336
|
-
|
|
337
|
-
Specialized for micro-frontend architectures.
|
|
54
|
+
### Edge
|
|
338
55
|
|
|
339
|
-
```
|
|
340
|
-
import {
|
|
56
|
+
```ts
|
|
57
|
+
import { createEdgeObservability } from '@od-oneapp/observability/server/edge';
|
|
341
58
|
|
|
342
|
-
const
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
backstageApps: {
|
|
346
|
-
"my-app": "https://app-dsn@sentry.io/123"
|
|
59
|
+
const obs = await createEdgeObservability({
|
|
60
|
+
providers: {
|
|
61
|
+
sentry: { enabled: true },
|
|
347
62
|
},
|
|
348
|
-
globalTags: { team: "platform", version: "1.0.0" }
|
|
349
63
|
});
|
|
350
64
|
```
|
|
351
65
|
|
|
352
|
-
##
|
|
353
|
-
|
|
354
|
-
### Multi-Provider Setup
|
|
355
|
-
|
|
356
|
-
```typescript
|
|
357
|
-
import { ObservabilityBuilder } from "@repo/observability/factory/builder";
|
|
358
|
-
import { createSentryPlugin } from "@repo/observability/plugins/sentry";
|
|
359
|
-
import { createBetterStackPlugin } from "@repo/observability/plugins/betterstack";
|
|
360
|
-
|
|
361
|
-
const observability = ObservabilityBuilder.create()
|
|
362
|
-
.withPlugin(createSentryPlugin({ dsn: process.env.SENTRY_DSN }))
|
|
363
|
-
.withPlugin(createBetterStackPlugin({ sourceToken: process.env.LOGTAIL_TOKEN }))
|
|
364
|
-
.withLifecycle({
|
|
365
|
-
onError: (error, plugin) => console.error(`${plugin.name} error:`, error),
|
|
366
|
-
onInitialized: (plugin) => console.log(`${plugin.name} initialized`)
|
|
367
|
-
})
|
|
368
|
-
.build();
|
|
369
|
-
```
|
|
370
|
-
|
|
371
|
-
### Custom Plugin
|
|
372
|
-
|
|
373
|
-
```typescript
|
|
374
|
-
import { ObservabilityPlugin } from "@repo/observability";
|
|
375
|
-
|
|
376
|
-
class CustomPlugin implements ObservabilityPlugin {
|
|
377
|
-
name = "custom";
|
|
378
|
-
enabled = true;
|
|
379
|
-
|
|
380
|
-
getClient() {
|
|
381
|
-
return undefined;
|
|
382
|
-
}
|
|
383
|
-
async initialize() {
|
|
384
|
-
/* Setup */
|
|
385
|
-
}
|
|
386
|
-
async shutdown() {
|
|
387
|
-
/* Cleanup */
|
|
388
|
-
}
|
|
389
|
-
|
|
390
|
-
captureException(error: Error | unknown, context?: any) {
|
|
391
|
-
// Your implementation
|
|
392
|
-
}
|
|
393
|
-
|
|
394
|
-
captureMessage(message: string, level = "info", context?: any) {
|
|
395
|
-
// Your implementation
|
|
396
|
-
}
|
|
397
|
-
|
|
398
|
-
setUser(user: any) {
|
|
399
|
-
/* Your implementation */
|
|
400
|
-
}
|
|
401
|
-
addBreadcrumb(breadcrumb: any) {
|
|
402
|
-
/* Your implementation */
|
|
403
|
-
}
|
|
404
|
-
withScope(callback: any) {
|
|
405
|
-
callback({});
|
|
406
|
-
}
|
|
407
|
-
}
|
|
408
|
-
```
|
|
409
|
-
|
|
410
|
-
## API Reference
|
|
411
|
-
|
|
412
|
-
### ObservabilityManager
|
|
413
|
-
|
|
414
|
-
- `addPlugin(plugin)` - Add plugin
|
|
415
|
-
- `getPlugin<T>(name)` - Get plugin by name
|
|
416
|
-
- `initialize()` - Initialize all plugins
|
|
417
|
-
- `shutdown()` - Shutdown all plugins
|
|
418
|
-
- `captureException(error, context?)` - Capture exception
|
|
419
|
-
- `captureMessage(message, level?, context?)` - Capture message
|
|
420
|
-
- `setUser(user)` - Set user context
|
|
421
|
-
- `addBreadcrumb(breadcrumb)` - Add breadcrumb
|
|
422
|
-
- `withScope(callback)` - Scoped context
|
|
423
|
-
- `flush(timeout?)` - Flush pending events
|
|
424
|
-
|
|
425
|
-
### Logging (Canonical)
|
|
426
|
-
|
|
427
|
-
Logging is now handled by the `@od-oneapp/shared/logger` package.
|
|
428
|
-
|
|
429
|
-
- `logDebug(message, context?)` - Debug logging
|
|
430
|
-
- `logInfo(message, context?)` - Info logging
|
|
431
|
-
- `logWarn(message, context?)` - Warning logging
|
|
432
|
-
- `logError(message, context?)` - Error logging
|
|
433
|
-
|
|
434
|
-
### ObservabilityBuilder
|
|
435
|
-
|
|
436
|
-
- `create()` - New builder instance
|
|
437
|
-
- `withPlugin(plugin)` - Add single plugin
|
|
438
|
-
- `withPlugins(plugins)` - Add multiple plugins
|
|
439
|
-
- `withLifecycle(lifecycle)` - Set lifecycle hooks
|
|
440
|
-
- `withAutoInitialize(enabled)` - Configure auto-init
|
|
441
|
-
- `build()` - Build manager
|
|
442
|
-
- `buildWithAutoInit()` - Build and initialize
|
|
443
|
-
|
|
444
|
-
## Testing
|
|
445
|
-
|
|
446
|
-
```bash
|
|
447
|
-
pnpm test # Run tests
|
|
448
|
-
pnpm test:coverage # With coverage
|
|
449
|
-
pnpm typecheck # Type checking
|
|
450
|
-
pnpm lint # Lint code
|
|
451
|
-
```
|
|
452
|
-
|
|
453
|
-
## Troubleshooting
|
|
454
|
-
|
|
455
|
-
### Plugins not initializing
|
|
456
|
-
|
|
457
|
-
```typescript
|
|
458
|
-
if (observability.hasInitializationError()) {
|
|
459
|
-
console.error("Init failed:", observability.getInitializationError());
|
|
460
|
-
}
|
|
461
|
-
console.log("Enabled:", observability.getEnabledPluginNames());
|
|
462
|
-
```
|
|
463
|
-
|
|
464
|
-
### Events not in Sentry
|
|
465
|
-
|
|
466
|
-
Check DSN, sampling rates, and debug mode:
|
|
467
|
-
|
|
468
|
-
```bash
|
|
469
|
-
SENTRY_DEBUG=true
|
|
470
|
-
```
|
|
471
|
-
|
|
472
|
-
### "Accessed server variable on client"
|
|
473
|
-
|
|
474
|
-
Use `NEXT_PUBLIC_` prefix for client-side variables:
|
|
475
|
-
|
|
476
|
-
```bash
|
|
477
|
-
NEXT_PUBLIC_SENTRY_DSN=https://key@sentry.io/project
|
|
478
|
-
```
|
|
479
|
-
|
|
480
|
-
## Best Practices
|
|
481
|
-
|
|
482
|
-
1. Use environment-specific exports
|
|
483
|
-
2. Set user context after authentication
|
|
484
|
-
3. Add breadcrumbs for error context
|
|
485
|
-
4. Use structured context objects
|
|
486
|
-
5. Sample performance data in production
|
|
487
|
-
6. Flush before process termination
|
|
488
|
-
7. Never log sensitive data (passwords, tokens, PII)
|
|
489
|
-
|
|
490
|
-
## Security
|
|
491
|
-
|
|
492
|
-
- ✅ User data automatically validated and sanitized
|
|
493
|
-
- ✅ Field length limits prevent DoS
|
|
494
|
-
- ✅ Unknown fields stripped for security
|
|
495
|
-
- ✅ Environment variables type-checked
|
|
496
|
-
- ⚠️ Use `beforeSend` hooks to scrub sensitive info
|
|
497
|
-
|
|
498
|
-
## Documentation
|
|
66
|
+
## DSN Auto-Detection
|
|
499
67
|
|
|
500
|
-
|
|
68
|
+
If you omit provider config, Sentry is auto-loaded when either env var is present:
|
|
69
|
+
- `SENTRY_DSN`
|
|
70
|
+
- `NEXT_PUBLIC_SENTRY_DSN`
|
|
501
71
|
|
|
502
|
-
|
|
503
|
-
- **Architecture**: See "Architecture" section above
|
|
504
|
-
- **API Reference**: See "API Reference" section above
|
|
72
|
+
## Provider Config Types
|
|
505
73
|
|
|
506
|
-
|
|
74
|
+
- `ObservabilityProviderName = 'console' | 'sentry'`
|
|
75
|
+
- `ObservabilityProvidersConfig`
|
|
76
|
+
- `NextObservabilityOptions`
|
|
77
|
+
- `MissingProviderPackageError`
|
|
507
78
|
|
|
508
|
-
|
|
79
|
+
If Sentry is configured but the integration package is missing, runtime throws `MissingProviderPackageError` with install guidance.
|
|
509
80
|
|
|
510
|
-
##
|
|
81
|
+
## Sentry Integration Package
|
|
511
82
|
|
|
512
|
-
|
|
83
|
+
Use `@od-oneapp/integration-sentry/config` for Next.js SDK configuration (`Sentry.init` and `withSentryConfig`).
|
|
513
84
|
|
|
514
|
-
|
|
85
|
+
It supports deterministic first-class layering:
|
|
86
|
+
- `runtime.common`
|
|
87
|
+
- `runtime.server`
|
|
88
|
+
- `runtime.edge`
|
|
89
|
+
- `runtime.client`
|
|
90
|
+
- `build`
|
|
515
91
|
|
|
516
|
-
|
|
92
|
+
Escape hatches are available as:
|
|
93
|
+
- `rawServer`
|
|
94
|
+
- `rawEdge`
|
|
95
|
+
- `rawClient`
|
|
96
|
+
- `rawBuild`
|
|
517
97
|
|
|
518
|
-
|
|
519
|
-
reviews
|
|
520
|
-
- **[Technical Guides](../../apps/docs/content/docs/packages/observability/)** - Implementation guides and best
|
|
521
|
-
practices
|
|
98
|
+
## BetterStack Deprecation
|
|
522
99
|
|
|
523
|
-
|
|
100
|
+
`@od-oneapp/observability/plugins/betterstack` remains temporarily for backward compatibility, but it is a no-op shim and should be removed from app code.
|
package/client-next.d.mts
CHANGED
|
@@ -1,20 +1,19 @@
|
|
|
1
|
-
import { a as Breadcrumb, c as
|
|
2
|
-
import { t as ObservabilityManager } from "./manager-
|
|
3
|
-
import { n as ObservabilityBuilder, t as createObservability } from "./index-
|
|
4
|
-
import {
|
|
1
|
+
import { a as Breadcrumb, c as ObservabilityClient, d as ObservabilityProviderConfig, f as ObservabilityProviderName, g as ObservabilityUser, h as ObservabilityServer, l as ObservabilityConfig, m as ObservabilityScope, o as LogLevel, p as ObservabilityProvidersConfig, s as NextObservabilityOptions, u as ObservabilityContext } from "./plugin-CD6OSG7J.mjs";
|
|
2
|
+
import { t as ObservabilityManager } from "./manager-GGdKqdV2.mjs";
|
|
3
|
+
import { n as ObservabilityBuilder, t as createObservability } from "./index-BBs_2frZ.mjs";
|
|
4
|
+
import { t as MissingProviderPackageError } from "./load-provider-mEuA8Tkf.mjs";
|
|
5
5
|
import { Env } from "./plugins-betterstack-env.mjs";
|
|
6
|
+
import { BetterStackPlugin, BetterStackPluginConfig } from "./plugins-betterstack.mjs";
|
|
6
7
|
import { ConsolePlugin, ConsolePluginConfig } from "./plugins-console.mjs";
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import "./plugins-sentry.mjs";
|
|
10
|
-
import { c as MicroFrontendMode, i as SentryMicroFrontendPlugin, l as SentryMicroFrontendConfig, s as BackstageAppConfig } from "./utils-6Gg4fkvH.mjs";
|
|
8
|
+
import { Env as Env$1, SentryPlugin, SentryPluginConfig } from "./plugins-sentry.mjs";
|
|
9
|
+
import { c as MicroFrontendMode, i as SentryMicroFrontendPlugin, l as SentryMicroFrontendConfig, s as BackstageAppConfig } from "./utils-cqicHWHw.mjs";
|
|
11
10
|
import "./plugins-sentry-microfrontend.mjs";
|
|
12
11
|
|
|
13
12
|
//#region src/client-next.d.ts
|
|
14
|
-
declare function createClientObservability(): Promise<ObservabilityManager>;
|
|
13
|
+
declare function createClientObservability(options?: NextObservabilityOptions): Promise<ObservabilityManager>;
|
|
15
14
|
declare function getObservability(): Promise<ObservabilityManager>;
|
|
16
15
|
declare const configureLogger: () => void;
|
|
17
16
|
type LogContext = Record<string, any>;
|
|
18
17
|
//#endregion
|
|
19
|
-
export { type BackstageAppConfig, type Env as BetterStackEnv, BetterStackPlugin, type BetterStackPluginConfig, Breadcrumb, ConsolePlugin, type ConsolePluginConfig, LogContext, LogLevel, type MicroFrontendMode, ObservabilityBuilder, ObservabilityClient, ObservabilityConfig, ObservabilityContext, ObservabilityScope, ObservabilityServer, ObservabilityUser, type Env$1 as SentryEnv, type SentryMicroFrontendConfig, SentryMicroFrontendPlugin, SentryPlugin, type SentryPluginConfig, configureLogger, createClientObservability, createObservability, getObservability };
|
|
18
|
+
export { type BackstageAppConfig, type Env as BetterStackEnv, BetterStackPlugin, type BetterStackPluginConfig, Breadcrumb, ConsolePlugin, type ConsolePluginConfig, LogContext, LogLevel, type MicroFrontendMode, MissingProviderPackageError, NextObservabilityOptions, ObservabilityBuilder, ObservabilityClient, ObservabilityConfig, ObservabilityContext, ObservabilityProviderConfig, ObservabilityProviderName, ObservabilityProvidersConfig, ObservabilityScope, ObservabilityServer, ObservabilityUser, type Env$1 as SentryEnv, type SentryMicroFrontendConfig, SentryMicroFrontendPlugin, SentryPlugin, type SentryPluginConfig, configureLogger, createClientObservability, createObservability, getObservability };
|
|
20
19
|
//# sourceMappingURL=client-next.d.mts.map
|
package/client-next.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client-next.d.mts","names":[],"sources":["../src/client-next.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"client-next.d.mts","names":[],"sources":["../src/client-next.ts"],"mappings":";;;;;;;;;;;;iBA6DsB,yBAAA,CACpB,OAAA,GAAU,wBAAA,GACT,OAAA,CAAQ,oBAAA;AAAA,iBAgDW,gBAAA,CAAA,GAAoB,OAAA,CAAQ,oBAAA;AAAA,cAsDrC,eAAA;AAAA,KAKD,UAAA,GAAa,MAAA"}
|