@djangocfg/layouts 2.1.216 → 2.1.218

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
@@ -49,6 +49,7 @@ export default function RootLayout({ children }) {
49
49
  - **PwaProvider** - PWA installation (optional)
50
50
  - **ErrorTrackingProvider** - Error handling and tracking
51
51
  - **ErrorBoundary** - React error boundary
52
+ - **MonitorProvider** - Frontend error monitoring via `@djangocfg/monitor` (optional)
52
53
  - **MCP Chat Widget** - AI chat assistant (optional)
53
54
 
54
55
  **Global components:**
@@ -104,6 +105,22 @@ export default function RootLayout({ children }) {
104
105
  }
105
106
  ```
106
107
 
108
+ **Monitor prop** — pass `monitor` to enable frontend error monitoring (installs `window.monitor` in DevTools):
109
+
110
+ ```tsx
111
+ <AppLayout
112
+ monitor={{
113
+ project: 'my-app',
114
+ environment: process.env.NODE_ENV,
115
+ }}
116
+ // ...
117
+ >
118
+ {children}
119
+ </AppLayout>
120
+ ```
121
+
122
+ After mount, `window.monitor.error(...)`, `.warn(...)`, `.flush()`, `.status()` are available in the browser console.
123
+
107
124
  **Layout priority:** Admin → Private → Public → Fallback
108
125
 
109
126
  **noLayoutPaths:** Paths that render without any layout wrapper. Useful for fullscreen pages (terminal, embed, print). Providers (auth, theme, centrifugo) are still applied.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@djangocfg/layouts",
3
- "version": "2.1.216",
3
+ "version": "2.1.218",
4
4
  "description": "Simple, straightforward layout components for Next.js - import and use with props",
5
5
  "keywords": [
6
6
  "layouts",
@@ -74,17 +74,18 @@
74
74
  "check": "tsc --noEmit"
75
75
  },
76
76
  "peerDependencies": {
77
- "@djangocfg/api": "^2.1.216",
78
- "@djangocfg/centrifugo": "^2.1.216",
79
- "@djangocfg/i18n": "^2.1.216",
80
- "@djangocfg/ui-core": "^2.1.216",
81
- "@djangocfg/ui-nextjs": "^2.1.216",
82
- "@djangocfg/ui-tools": "^2.1.216",
77
+ "@djangocfg/api": "^2.1.218",
78
+ "@djangocfg/centrifugo": "^2.1.218",
79
+ "@djangocfg/i18n": "^2.1.218",
80
+ "@djangocfg/monitor": "^2.1.218",
81
+ "@djangocfg/ui-core": "^2.1.218",
82
+ "@djangocfg/ui-nextjs": "^2.1.218",
83
+ "@djangocfg/ui-tools": "^2.1.218",
83
84
  "@hookform/resolvers": "^5.2.2",
84
85
  "consola": "^3.4.2",
85
86
  "lucide-react": "^0.545.0",
86
87
  "moment": "^2.30.1",
87
- "next": ">=16.0.0",
88
+ "next": "^16.0.10",
88
89
  "p-retry": "^7.0.0",
89
90
  "react": "^19.1.0",
90
91
  "react-dom": "^19.1.0",
@@ -93,7 +94,12 @@
93
94
  "swr": "^2.3.7",
94
95
  "tailwindcss": "^4.1.18",
95
96
  "tailwindcss-animate": "^1.0.7",
96
- "zod": "^4.3.4"
97
+ "zod": "^4.3.6"
98
+ },
99
+ "peerDependenciesMeta": {
100
+ "@djangocfg/monitor": {
101
+ "optional": true
102
+ }
97
103
  },
98
104
  "dependencies": {
99
105
  "nextjs-toploader": "^3.9.17",
@@ -102,13 +108,14 @@
102
108
  "uuid": "^11.1.0"
103
109
  },
104
110
  "devDependencies": {
105
- "@djangocfg/api": "^2.1.216",
106
- "@djangocfg/i18n": "^2.1.216",
107
- "@djangocfg/centrifugo": "^2.1.216",
108
- "@djangocfg/typescript-config": "^2.1.216",
109
- "@djangocfg/ui-core": "^2.1.216",
110
- "@djangocfg/ui-nextjs": "^2.1.216",
111
- "@djangocfg/ui-tools": "^2.1.216",
111
+ "@djangocfg/api": "^2.1.218",
112
+ "@djangocfg/i18n": "^2.1.218",
113
+ "@djangocfg/centrifugo": "^2.1.218",
114
+ "@djangocfg/monitor": "^2.1.218",
115
+ "@djangocfg/typescript-config": "^2.1.218",
116
+ "@djangocfg/ui-core": "^2.1.218",
117
+ "@djangocfg/ui-nextjs": "^2.1.218",
118
+ "@djangocfg/ui-tools": "^2.1.218",
112
119
  "@types/node": "^24.7.2",
113
120
  "@types/react": "^19.1.0",
114
121
  "@types/react-dom": "^19.1.0",
@@ -155,6 +155,8 @@ export interface ErrorTrackingProviderProps {
155
155
  centrifugo?: Partial<CentrifugoErrorConfig>;
156
156
  runtime?: Partial<RuntimeErrorConfig>;
157
157
  onError?: (error: ErrorDetail) => boolean | void;
158
+ /** Called with the raw ErrorDetail for every tracked error. Wire to FrontendMonitor.capture() (via toMonitorEvent) to forward errors to the backend. */
159
+ onMonitorCapture?: (detail: ErrorDetail) => void;
158
160
  }
159
161
 
160
162
  /**
@@ -170,6 +172,7 @@ export function ErrorTrackingProvider({
170
172
  centrifugo: userCentrifugoConfig,
171
173
  runtime: userRuntimeConfig,
172
174
  onError,
175
+ onMonitorCapture,
173
176
  }: ErrorTrackingProviderProps) {
174
177
  const [errors, setErrors] = useState<StoredError[]>([]);
175
178
 
@@ -240,6 +243,13 @@ export function ErrorTrackingProvider({
240
243
  return updated.slice(0, config.maxErrors);
241
244
  });
242
245
 
246
+ // Forward raw ErrorDetail to monitor bridge (fire-and-forget)
247
+ if (onMonitorCapture) {
248
+ try {
249
+ onMonitorCapture(detail);
250
+ } catch { /* never crash */ }
251
+ }
252
+
243
253
  // Call custom error handler
244
254
  const shouldShowToast = onError?.(detail) !== false;
245
255
 
@@ -252,7 +262,7 @@ export function ErrorTrackingProvider({
252
262
  });
253
263
  }
254
264
  },
255
- [onError]
265
+ [onError, onMonitorCapture]
256
266
  );
257
267
 
258
268
  /**
@@ -50,6 +50,7 @@ import type {
50
50
  PwaInstallConfig,
51
51
  } from '../types';
52
52
  import type { AuthConfig } from '@djangocfg/api/auth';
53
+ import type { MonitorConfig } from '@djangocfg/monitor';
53
54
 
54
55
  export type LayoutMode = 'public' | 'private' | 'admin';
55
56
 
@@ -135,6 +136,9 @@ export interface AppLayoutProps {
135
136
 
136
137
  /** i18n configuration for locale switching (applies to all layouts) */
137
138
  i18n?: I18nLayoutConfig;
139
+
140
+ /** Monitor configuration — initialises window.monitor + auto-captures JS errors & console */
141
+ monitor?: MonitorConfig;
138
142
  }
139
143
 
140
144
  /**
@@ -256,6 +260,7 @@ export function AppLayout(props: AppLayoutProps) {
256
260
  swr,
257
261
  mcpChat,
258
262
  pwaInstall,
263
+ monitor,
259
264
  } = props;
260
265
 
261
266
  return (
@@ -269,6 +274,7 @@ export function AppLayout(props: AppLayoutProps) {
269
274
  swr={swr}
270
275
  mcpChat={mcpChat}
271
276
  pwaInstall={pwaInstall}
277
+ monitor={monitor}
272
278
  >
273
279
  <AppLayoutContent {...props} />
274
280
  </BaseApp>
@@ -42,6 +42,7 @@ import dynamic from 'next/dynamic';
42
42
  import NextTopLoader from 'nextjs-toploader';
43
43
  import { SWRConfig } from 'swr';
44
44
 
45
+ import { MonitorProvider } from '@djangocfg/monitor/client';
45
46
  import { getCentrifugoAuthTokenRetrieve } from '@djangocfg/api';
46
47
  import { AuthProvider } from '@djangocfg/api/auth';
47
48
  import { CentrifugoProvider } from '@djangocfg/centrifugo';
@@ -84,6 +85,7 @@ export function BaseApp({
84
85
  swr,
85
86
  mcpChat,
86
87
  pwaInstall,
88
+ monitor,
87
89
  }: BaseAppProps) {
88
90
  // ErrorBoundary is enabled by default
89
91
  const enableErrorBoundary = errorBoundary?.enabled !== false;
@@ -128,6 +130,7 @@ export function BaseApp({
128
130
  network={errorTracking?.network}
129
131
  onError={errorTracking?.onError}
130
132
  >
133
+ {monitor && <MonitorProvider {...monitor} />}
131
134
  {children}
132
135
  <NextTopLoader
133
136
  color="hsl(var(--primary))"
@@ -14,6 +14,7 @@ import type { ErrorBoundaryConfig, ErrorTrackingConfig } from '../../components/
14
14
 
15
15
  // Import local provider configs
16
16
  import type { ThemeConfig, SWRConfigOptions, McpChatConfig, CentrifugoConfig } from './providers.types';
17
+ import type { MonitorConfig } from '@djangocfg/monitor';
17
18
 
18
19
  // ============================================================================
19
20
  // Base Layout Props
@@ -54,4 +55,7 @@ export interface BaseLayoutProps {
54
55
 
55
56
  /** PWA Install configuration (from snippets/PWAInstall) */
56
57
  pwaInstall?: PwaInstallConfig;
58
+
59
+ /** Monitor configuration — initialises window.monitor + auto-captures JS errors & console */
60
+ monitor?: MonitorConfig;
57
61
  }
@@ -8,6 +8,10 @@ export * from './Breadcrumbs';
8
8
  export * from './AuthDialog';
9
9
  export * from './Analytics';
10
10
 
11
+ // MonitorProvider lives in @djangocfg/monitor/client — re-exported here for convenience
12
+ export { MonitorProvider } from '@djangocfg/monitor/client';
13
+ export type { MonitorProviderProps } from '@djangocfg/monitor/client';
14
+
11
15
  // MCP Chat (AI-powered documentation assistant)
12
16
  export {
13
17
  AIChatWidget,