@djangocfg/layouts 2.1.379 → 2.1.381

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 CHANGED
@@ -126,6 +126,36 @@ When `routing` is set, `BaseApp` mounts a locale-aware `<Link>` adapter so every
126
126
 
127
127
  `baseApp.project` enables `window.monitor`. Debug panel: `Cmd+D` or `?debug=1`.
128
128
 
129
+ ### `MonitorBoundary`
130
+
131
+ Error boundary that automatically reports caught errors to `@djangocfg/monitor`. Use at page/layout level so unexpected render errors land in your backend dashboard.
132
+
133
+ ```tsx
134
+ import { MonitorBoundary } from '@djangocfg/layouts';
135
+
136
+ export default function Layout({ children }) {
137
+ return (
138
+ <MonitorBoundary variant="fullscreen" name="root-layout">
139
+ {children}
140
+ </MonitorBoundary>
141
+ );
142
+ }
143
+
144
+ // Per-section, non-fatal:
145
+ <MonitorBoundary variant="card" name="dashboard-stats" resetKeys={[pathname]}>
146
+ <StatsPanel />
147
+ </MonitorBoundary>
148
+
149
+ // Opt out of reporting (e.g. third-party iframe noise):
150
+ <MonitorBoundary reportToMonitor={false} variant="silent">
151
+ <EmbeddedWidget />
152
+ </MonitorBoundary>
153
+ ```
154
+
155
+ Wraps `Boundary` from `@djangocfg/ui-core` — same `variant`/`fallback`/`resetKeys` API, plus auto `FrontendMonitor.capture(...)`.
156
+
157
+ For local UI widgets that should not report to backend, use `Boundary` from `@djangocfg/ui-core` directly.
158
+
129
159
  ---
130
160
 
131
161
  ## Package exports
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/layouts",
3
- "version": "2.1.379",
3
+ "version": "2.1.381",
4
4
  "description": "Simple, straightforward layout components for Next.js - import and use with props",
5
5
  "keywords": [
6
6
  "layouts",
@@ -84,13 +84,13 @@
84
84
  "check": "tsc --noEmit"
85
85
  },
86
86
  "peerDependencies": {
87
- "@djangocfg/api": "^2.1.379",
88
- "@djangocfg/centrifugo": "^2.1.379",
89
- "@djangocfg/debuger": "^2.1.379",
90
- "@djangocfg/i18n": "^2.1.379",
91
- "@djangocfg/monitor": "^2.1.379",
92
- "@djangocfg/ui-core": "^2.1.379",
93
- "@djangocfg/ui-nextjs": "^2.1.379",
87
+ "@djangocfg/api": "^2.1.381",
88
+ "@djangocfg/centrifugo": "^2.1.381",
89
+ "@djangocfg/debuger": "^2.1.381",
90
+ "@djangocfg/i18n": "^2.1.381",
91
+ "@djangocfg/monitor": "^2.1.381",
92
+ "@djangocfg/ui-core": "^2.1.381",
93
+ "@djangocfg/ui-nextjs": "^2.1.381",
94
94
  "@hookform/resolvers": "^5.2.2",
95
95
  "consola": "^3.4.2",
96
96
  "lucide-react": "^0.545.0",
@@ -121,15 +121,15 @@
121
121
  "uuid": "^11.1.0"
122
122
  },
123
123
  "devDependencies": {
124
- "@djangocfg/api": "^2.1.379",
125
- "@djangocfg/centrifugo": "^2.1.379",
126
- "@djangocfg/debuger": "^2.1.379",
127
- "@djangocfg/i18n": "^2.1.379",
128
- "@djangocfg/monitor": "^2.1.379",
129
- "@djangocfg/typescript-config": "^2.1.379",
130
- "@djangocfg/ui-core": "^2.1.379",
131
- "@djangocfg/ui-nextjs": "^2.1.379",
132
- "@djangocfg/ui-tools": "^2.1.379",
124
+ "@djangocfg/api": "^2.1.381",
125
+ "@djangocfg/centrifugo": "^2.1.381",
126
+ "@djangocfg/debuger": "^2.1.381",
127
+ "@djangocfg/i18n": "^2.1.381",
128
+ "@djangocfg/monitor": "^2.1.381",
129
+ "@djangocfg/typescript-config": "^2.1.381",
130
+ "@djangocfg/ui-core": "^2.1.381",
131
+ "@djangocfg/ui-nextjs": "^2.1.381",
132
+ "@djangocfg/ui-tools": "^2.1.381",
133
133
  "@types/node": "^24.7.2",
134
134
  "@types/react": "^19.1.0",
135
135
  "@types/react-dom": "^19.1.0",
@@ -0,0 +1,56 @@
1
+ 'use client';
2
+
3
+ import { Boundary } from '@djangocfg/ui-core/components';
4
+ import type { BoundaryProps } from '@djangocfg/ui-core/components';
5
+ import { EventLevel, EventType, FrontendMonitor } from '@djangocfg/monitor/client';
6
+ import type { ErrorInfo, ReactNode } from 'react';
7
+
8
+ export interface MonitorBoundaryProps extends Omit<BoundaryProps, 'onError'> {
9
+ /** Optional name forwarded to FrontendMonitor.extra.source for filtering. */
10
+ name?: string;
11
+ /** Additional handler called alongside the monitor capture. */
12
+ onError?: (error: Error, info: ErrorInfo) => void;
13
+ /** Disable monitor reporting (still catches and renders fallback). */
14
+ reportToMonitor?: boolean;
15
+ children: ReactNode;
16
+ }
17
+
18
+ /**
19
+ * Boundary + auto-reporting to @djangocfg/monitor.
20
+ * Use at the page/layout level so unexpected render errors are captured in your backend.
21
+ *
22
+ * For widgets you don't want to report (chat, embeds), use `Boundary` from ui-core directly.
23
+ */
24
+ export function MonitorBoundary({
25
+ name,
26
+ onError,
27
+ reportToMonitor = true,
28
+ ...rest
29
+ }: MonitorBoundaryProps) {
30
+ return (
31
+ <Boundary
32
+ {...rest}
33
+ name={name}
34
+ onError={(error, info) => {
35
+ if (reportToMonitor) {
36
+ try {
37
+ FrontendMonitor.capture({
38
+ event_type: EventType.ERROR,
39
+ level: EventLevel.ERROR,
40
+ message: error.message || 'Unhandled React render error',
41
+ stack_trace: error.stack,
42
+ url: typeof window !== 'undefined' ? window.location.href : undefined,
43
+ extra: {
44
+ source: name ?? 'boundary',
45
+ componentStack: info.componentStack,
46
+ },
47
+ });
48
+ } catch {
49
+ // Never let monitor failures crash the boundary itself.
50
+ }
51
+ }
52
+ onError?.(error, info);
53
+ }}
54
+ />
55
+ );
56
+ }
@@ -3,6 +3,8 @@
3
3
  */
4
4
 
5
5
  export { ErrorBoundary } from './ErrorBoundary';
6
+ export { MonitorBoundary } from './MonitorBoundary';
7
+ export type { MonitorBoundaryProps } from './MonitorBoundary';
6
8
  export { ErrorLayout } from './ErrorLayout';
7
9
  export type { ErrorLayoutProps } from './ErrorLayout';
8
10
  export { getErrorContent, ERROR_CODES } from './errorConfig';
@@ -186,8 +186,8 @@ export function UserMenu({
186
186
  {profileGroups.map((group, groupIndex) => (
187
187
  <div key={groupIndex}>
188
188
  {group.title && (
189
- <div className="px-4 py-2">
190
- <p className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
189
+ <div className="px-4 pt-2 pb-1">
190
+ <p className="text-[11px] font-normal text-muted-foreground/70">
191
191
  {group.title}
192
192
  </p>
193
193
  </div>
@@ -229,7 +229,7 @@ export function UserMenu({
229
229
  ))}
230
230
  {localeMenu && (
231
231
  <div className="border-t border-border/50 px-4 pt-3">
232
- <p className="text-xs font-semibold uppercase tracking-wider text-muted-foreground">
232
+ <p className="text-[11px] font-normal text-muted-foreground/70">
233
233
  {labels.language}
234
234
  </p>
235
235
  <div className="mt-2 flex flex-wrap gap-2">
@@ -293,7 +293,7 @@ export function UserMenu({
293
293
  {groupIndex > 0 && <DropdownMenuSeparator />}
294
294
  <DropdownMenuGroup>
295
295
  {group.title && (
296
- <DropdownMenuLabel className="text-xs font-semibold text-muted-foreground uppercase tracking-wider">
296
+ <DropdownMenuLabel className="text-[11px] font-normal text-muted-foreground/70 py-1">
297
297
  {group.title}
298
298
  </DropdownMenuLabel>
299
299
  )}