@djangocfg/monitor 2.1.355 → 2.1.357

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 (34) hide show
  1. package/dist/client.cjs +102 -100
  2. package/dist/client.cjs.map +1 -1
  3. package/dist/client.d.cts +38 -31
  4. package/dist/client.d.ts +38 -31
  5. package/dist/client.mjs +103 -101
  6. package/dist/client.mjs.map +1 -1
  7. package/dist/index.cjs +932 -19
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +30 -30
  10. package/dist/index.d.ts +30 -30
  11. package/dist/index.mjs +932 -19
  12. package/dist/index.mjs.map +1 -1
  13. package/dist/server.cjs +74 -73
  14. package/dist/server.cjs.map +1 -1
  15. package/dist/server.d.cts +30 -30
  16. package/dist/server.d.ts +30 -30
  17. package/dist/server.mjs +74 -73
  18. package/dist/server.mjs.map +1 -1
  19. package/package.json +2 -2
  20. package/src/_api/generated/_cfg_monitor/api.ts +3 -3
  21. package/src/_api/generated/_cfg_monitor/hooks/useCfgMonitorIngestCreate.ts +7 -3
  22. package/src/_api/generated/_cfg_monitor/index.ts +1 -1
  23. package/src/_api/generated/_cfg_monitor/schemas/FrontendEventIngestRequest.ts +12 -12
  24. package/src/_api/generated/_cfg_monitor/schemas/{LevelEnum.ts → FrontendEventLevelEnum.ts} +2 -2
  25. package/src/_api/generated/_cfg_monitor/schemas/FrontendEventTypeEnum.ts +9 -0
  26. package/src/_api/generated/_cfg_monitor/schemas/index.ts +2 -2
  27. package/src/_api/generated/index.ts +1 -1
  28. package/src/_api/generated/sdk.gen.ts +1 -19
  29. package/src/_api/generated/types.gen.ts +35 -35
  30. package/src/_api/index.ts +1 -1
  31. package/src/client/MonitorProvider.tsx +10 -2
  32. package/src/client/transport/ingest.ts +2 -2
  33. package/src/server/index.ts +2 -2
  34. package/src/_api/generated/_cfg_monitor/schemas/EventTypeEnum.ts +0 -9
@@ -1,7 +1,7 @@
1
1
  // AUTO-GENERATED — barrel for zod schemas.
2
2
  // DO NOT EDIT.
3
3
 
4
- export * from "./EventTypeEnum";
5
4
  export * from "./FrontendEventIngestRequest";
5
+ export * from "./FrontendEventLevelEnum";
6
+ export * from "./FrontendEventTypeEnum";
6
7
  export * from "./IngestBatchRequest";
7
- export * from "./LevelEnum";
@@ -27,7 +27,7 @@ export { API as CfgMonitorAPI } from './_cfg_monitor';
27
27
  // available via the per-group import: `import { Auth } from
28
28
  // '<api>/_auth'`. To remove the alias, rename the OpenAPI tag on the
29
29
  // backend so the SDK class doesn't collide.
30
-
30
+ export { CfgMonitor } from './_cfg_monitor';
31
31
 
32
32
  // Shared utilities (errors, storage adapters, logger).
33
33
  export * from './helpers';
@@ -18,25 +18,7 @@ export type Options<TData extends TDataShape = TDataShape, ThrowOnError extends
18
18
  meta?: Record<string, unknown>;
19
19
  };
20
20
 
21
- export class Cfg {
22
- /**
23
- * Ingest browser events
24
- *
25
- * Accepts a batch of up to 50 frontend events. No authentication required — anonymous visitors can send events.
26
- */
27
- public static cfgMonitorIngestCreate<ThrowOnError extends boolean = false>(options: Options<CfgMonitorIngestCreateData, ThrowOnError>) {
28
- return (options.client ?? client).post<CfgMonitorIngestCreateResponses, unknown, ThrowOnError>({
29
- url: '/cfg/monitor/ingest/',
30
- ...options,
31
- headers: {
32
- 'Content-Type': 'application/json',
33
- ...options.headers
34
- }
35
- });
36
- }
37
- }
38
-
39
- export class Monitor {
21
+ export class CfgMonitor {
40
22
  /**
41
23
  * Ingest browser events
42
24
  *
@@ -4,6 +4,40 @@ export type ClientOptions = {
4
4
  baseUrl: 'http://localhost:8000' | (string & {});
5
5
  };
6
6
 
7
+ /**
8
+ * Single browser event payload.
9
+ */
10
+ export type FrontendEventIngestRequest = {
11
+ event_type: FrontendEventTypeEnum;
12
+ message: string;
13
+ level?: FrontendEventLevelEnum;
14
+ stack_trace?: string;
15
+ url?: string;
16
+ fingerprint?: string;
17
+ http_status?: number | null;
18
+ http_method?: string;
19
+ http_url?: string;
20
+ session_id?: string;
21
+ user_agent?: string;
22
+ build_id?: string;
23
+ environment?: string;
24
+ extra?: unknown;
25
+ project_name?: string;
26
+ };
27
+
28
+ /**
29
+ * * `error` - Error
30
+ * * `warning` - Warning
31
+ * * `info` - Info
32
+ * * `debug` - Debug
33
+ */
34
+ export enum FrontendEventLevelEnum {
35
+ ERROR = 'error',
36
+ WARNING = 'warning',
37
+ INFO = 'info',
38
+ DEBUG = 'debug'
39
+ }
40
+
7
41
  /**
8
42
  * * `JS_ERROR` - Js Error
9
43
  * * `NETWORK_ERROR` - Network Error
@@ -13,7 +47,7 @@ export type ClientOptions = {
13
47
  * * `PERFORMANCE` - Performance
14
48
  * * `CONSOLE` - Console
15
49
  */
16
- export enum EventTypeEnum {
50
+ export enum FrontendEventTypeEnum {
17
51
  JS_ERROR = 'JS_ERROR',
18
52
  NETWORK_ERROR = 'NETWORK_ERROR',
19
53
  ERROR = 'ERROR',
@@ -23,27 +57,6 @@ export enum EventTypeEnum {
23
57
  CONSOLE = 'CONSOLE'
24
58
  }
25
59
 
26
- /**
27
- * Single browser event payload.
28
- */
29
- export type FrontendEventIngestRequest = {
30
- build_id?: string;
31
- environment?: string;
32
- event_type: EventTypeEnum;
33
- extra?: unknown;
34
- fingerprint?: string;
35
- http_method?: string;
36
- http_status?: number | null;
37
- http_url?: string;
38
- level?: LevelEnum;
39
- message: string;
40
- project_name?: string;
41
- session_id?: string;
42
- stack_trace?: string;
43
- url?: string;
44
- user_agent?: string;
45
- };
46
-
47
60
  /**
48
61
  * Batch of up to 50 browser events.
49
62
  */
@@ -51,19 +64,6 @@ export type IngestBatchRequest = {
51
64
  events: Array<FrontendEventIngestRequest>;
52
65
  };
53
66
 
54
- /**
55
- * * `error` - Error
56
- * * `warning` - Warning
57
- * * `info` - Info
58
- * * `debug` - Debug
59
- */
60
- export enum LevelEnum {
61
- ERROR = 'error',
62
- WARNING = 'warning',
63
- INFO = 'info',
64
- DEBUG = 'debug'
65
- }
66
-
67
67
  export type CfgMonitorIngestCreateData = {
68
68
  body: IngestBatchRequest;
69
69
  path?: never;
package/src/_api/index.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  export { monitorApi, configureMonitorApi, BaseClient } from './BaseClient'
2
2
  export type { FrontendEventIngestRequest, IngestBatchRequest } from './generated/_cfg_monitor/types.gen'
3
- export { EventTypeEnum as EventType, LevelEnum as EventLevel } from './generated/_cfg_monitor/types.gen'
3
+ export { FrontendEventTypeEnum as EventType, FrontendEventLevelEnum as EventLevel } from './generated/_cfg_monitor/types.gen'
4
4
 
5
5
  /** Ingest path — matches the generated client. Single source of truth for sendBeacon fallback. */
6
6
  export const INGEST_PATH = '/cfg/monitor/ingest/'
@@ -22,7 +22,7 @@
22
22
  * }
23
23
  */
24
24
 
25
- import { useEffect } from 'react'
25
+ import { memo, useEffect } from 'react'
26
26
  import { FrontendMonitor } from './index'
27
27
  import { initWindowMonitor } from './window'
28
28
  import type { MonitorConfig } from '../types'
@@ -32,7 +32,13 @@ export interface MonitorProviderProps extends MonitorConfig {
32
32
  children?: React.ReactNode
33
33
  }
34
34
 
35
- export function MonitorProvider({ children, ...config }: MonitorProviderProps) {
35
+ /**
36
+ * MonitorProvider — initialises FrontendMonitor on mount.
37
+ *
38
+ * Memoised: re-renders only when `children` or config props change.
39
+ * The init effect runs once on mount (config is captured in closure).
40
+ */
41
+ function MonitorProviderRaw({ children, ...config }: MonitorProviderProps) {
36
42
  useEffect(() => {
37
43
  FrontendMonitor.init(config)
38
44
  initWindowMonitor()
@@ -41,3 +47,5 @@ export function MonitorProvider({ children, ...config }: MonitorProviderProps) {
41
47
 
42
48
  return children ?? null
43
49
  }
50
+
51
+ export const MonitorProvider = memo(MonitorProviderRaw)
@@ -1,5 +1,5 @@
1
1
  import { monitorApi, INGEST_PATH } from '../../_api'
2
- import { Monitor } from '../../_api/generated/sdk.gen'
2
+ import { CfgMonitor } from '../../_api/generated/sdk.gen'
3
3
  import type { IngestBatchRequest } from '../../_api'
4
4
 
5
5
  /**
@@ -27,5 +27,5 @@ export async function sendBatch(
27
27
  return
28
28
  }
29
29
 
30
- await Monitor.cfgMonitorIngestCreate({ body: batch, throwOnError: true })
30
+ await CfgMonitor.cfgMonitorIngestCreate({ body: batch, throwOnError: true })
31
31
  }
@@ -23,7 +23,7 @@
23
23
  */
24
24
 
25
25
  import { configureMonitorApi, EventType, EventLevel } from '../_api'
26
- import { Monitor } from '../_api/generated/sdk.gen'
26
+ import { CfgMonitor } from '../_api/generated/sdk.gen'
27
27
  import type { FrontendEventIngestRequest } from '../_api'
28
28
  import type { ServerMonitorConfig } from '../types'
29
29
 
@@ -35,7 +35,7 @@ let _config: ServerMonitorConfig = {}
35
35
  async function send(events: FrontendEventIngestRequest[]): Promise<void> {
36
36
  if (events.length === 0) return
37
37
  try {
38
- await Monitor.cfgMonitorIngestCreate({ body: { events }, throwOnError: true })
38
+ await CfgMonitor.cfgMonitorIngestCreate({ body: { events }, throwOnError: true })
39
39
  } catch {
40
40
  // Never throw from monitor
41
41
  }
@@ -1,9 +0,0 @@
1
- // AUTO-GENERATED by cmdop_server / devtools.generator.ts_extras
2
- // Source: OpenAPI 3.1 components.schemas
3
- // DO NOT EDIT — re-run `make gen-clients`.
4
-
5
- import { z } from "zod";
6
-
7
- export const EventTypeEnumSchema = z.enum(["JS_ERROR", "NETWORK_ERROR", "ERROR", "WARNING", "PAGE_VIEW", "PERFORMANCE", "CONSOLE"]);
8
-
9
- export type EventTypeEnum = z.infer<typeof EventTypeEnumSchema>;