@djangocfg/monitor 2.1.359 → 2.1.361
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/dist/client.cjs +68 -1
- package/dist/client.cjs.map +1 -1
- package/dist/client.mjs +68 -1
- package/dist/client.mjs.map +1 -1
- package/dist/index.cjs +67 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +67 -0
- package/dist/index.mjs.map +1 -1
- package/dist/server.cjs +67 -0
- package/dist/server.cjs.map +1 -1
- package/dist/server.mjs +67 -0
- package/dist/server.mjs.map +1 -1
- package/package.json +2 -2
- package/src/_api/generated/_cfg_monitor/openapi.json +197 -0
- package/src/_api/generated/helpers/auth.ts +27 -2
- package/src/_api/generated/openapi.json +197 -0
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.1.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "Django CFG API",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": "RESTful API with modern architecture"
|
|
7
|
+
},
|
|
8
|
+
"paths": {
|
|
9
|
+
"/cfg/monitor/ingest/": {
|
|
10
|
+
"post": {
|
|
11
|
+
"operationId": "cfg_monitor_ingest_create",
|
|
12
|
+
"description": "Accepts a batch of up to 50 frontend events. No authentication required — anonymous visitors can send events.",
|
|
13
|
+
"summary": "Ingest browser events",
|
|
14
|
+
"tags": [
|
|
15
|
+
"cfg_monitor"
|
|
16
|
+
],
|
|
17
|
+
"requestBody": {
|
|
18
|
+
"content": {
|
|
19
|
+
"application/json": {
|
|
20
|
+
"schema": {
|
|
21
|
+
"$ref": "#/components/schemas/IngestBatchRequest"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": true
|
|
26
|
+
},
|
|
27
|
+
"security": [
|
|
28
|
+
{}
|
|
29
|
+
],
|
|
30
|
+
"responses": {
|
|
31
|
+
"202": {
|
|
32
|
+
"description": "Accepted"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"x-async-capable": false
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"components": {
|
|
40
|
+
"schemas": {
|
|
41
|
+
"FrontendEventIngestRequest": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"description": "Single browser event payload.",
|
|
44
|
+
"properties": {
|
|
45
|
+
"event_type": {
|
|
46
|
+
"$ref": "#/components/schemas/FrontendEventTypeEnum"
|
|
47
|
+
},
|
|
48
|
+
"message": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"minLength": 1,
|
|
51
|
+
"maxLength": 5000
|
|
52
|
+
},
|
|
53
|
+
"level": {
|
|
54
|
+
"allOf": [
|
|
55
|
+
{
|
|
56
|
+
"$ref": "#/components/schemas/FrontendEventLevelEnum"
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"default": "error"
|
|
60
|
+
},
|
|
61
|
+
"stack_trace": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"default": "",
|
|
64
|
+
"maxLength": 10000
|
|
65
|
+
},
|
|
66
|
+
"url": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"default": "",
|
|
69
|
+
"maxLength": 2000
|
|
70
|
+
},
|
|
71
|
+
"fingerprint": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"default": "",
|
|
74
|
+
"maxLength": 64
|
|
75
|
+
},
|
|
76
|
+
"http_status": {
|
|
77
|
+
"type": [
|
|
78
|
+
"integer",
|
|
79
|
+
"null"
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"http_method": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"default": "",
|
|
85
|
+
"maxLength": 10
|
|
86
|
+
},
|
|
87
|
+
"http_url": {
|
|
88
|
+
"type": "string",
|
|
89
|
+
"default": "",
|
|
90
|
+
"maxLength": 2000
|
|
91
|
+
},
|
|
92
|
+
"session_id": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"default": "",
|
|
95
|
+
"maxLength": 64
|
|
96
|
+
},
|
|
97
|
+
"user_agent": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"default": "",
|
|
100
|
+
"maxLength": 500
|
|
101
|
+
},
|
|
102
|
+
"build_id": {
|
|
103
|
+
"type": "string",
|
|
104
|
+
"default": "",
|
|
105
|
+
"maxLength": 100
|
|
106
|
+
},
|
|
107
|
+
"environment": {
|
|
108
|
+
"type": "string",
|
|
109
|
+
"default": "",
|
|
110
|
+
"maxLength": 20
|
|
111
|
+
},
|
|
112
|
+
"extra": {},
|
|
113
|
+
"project_name": {
|
|
114
|
+
"type": "string",
|
|
115
|
+
"default": "",
|
|
116
|
+
"maxLength": 100
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"required": [
|
|
120
|
+
"event_type",
|
|
121
|
+
"message"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
"FrontendEventLevelEnum": {
|
|
125
|
+
"enum": [
|
|
126
|
+
"error",
|
|
127
|
+
"warning",
|
|
128
|
+
"info",
|
|
129
|
+
"debug"
|
|
130
|
+
],
|
|
131
|
+
"type": "string",
|
|
132
|
+
"description": "* `error` - Error\n* `warning` - Warning\n* `info` - Info\n* `debug` - Debug"
|
|
133
|
+
},
|
|
134
|
+
"FrontendEventTypeEnum": {
|
|
135
|
+
"enum": [
|
|
136
|
+
"JS_ERROR",
|
|
137
|
+
"NETWORK_ERROR",
|
|
138
|
+
"ERROR",
|
|
139
|
+
"WARNING",
|
|
140
|
+
"PAGE_VIEW",
|
|
141
|
+
"PERFORMANCE",
|
|
142
|
+
"CONSOLE"
|
|
143
|
+
],
|
|
144
|
+
"type": "string",
|
|
145
|
+
"description": "* `JS_ERROR` - Js Error\n* `NETWORK_ERROR` - Network Error\n* `ERROR` - Error\n* `WARNING` - Warning\n* `PAGE_VIEW` - Page View\n* `PERFORMANCE` - Performance\n* `CONSOLE` - Console"
|
|
146
|
+
},
|
|
147
|
+
"IngestBatchRequest": {
|
|
148
|
+
"type": "object",
|
|
149
|
+
"description": "Batch of up to 50 browser events.",
|
|
150
|
+
"properties": {
|
|
151
|
+
"events": {
|
|
152
|
+
"type": "array",
|
|
153
|
+
"items": {
|
|
154
|
+
"$ref": "#/components/schemas/FrontendEventIngestRequest"
|
|
155
|
+
},
|
|
156
|
+
"maxItems": 25,
|
|
157
|
+
"minItems": 1
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"required": [
|
|
161
|
+
"events"
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"securitySchemes": {
|
|
166
|
+
"apiKeyAuth": {
|
|
167
|
+
"type": "apiKey",
|
|
168
|
+
"in": "header",
|
|
169
|
+
"name": "X-API-Key"
|
|
170
|
+
},
|
|
171
|
+
"basicAuth": {
|
|
172
|
+
"type": "http",
|
|
173
|
+
"scheme": "basic"
|
|
174
|
+
},
|
|
175
|
+
"cookieAuth": {
|
|
176
|
+
"type": "apiKey",
|
|
177
|
+
"in": "cookie",
|
|
178
|
+
"name": "sessionid"
|
|
179
|
+
},
|
|
180
|
+
"jwtAuth": {
|
|
181
|
+
"type": "http",
|
|
182
|
+
"scheme": "bearer",
|
|
183
|
+
"bearerFormat": "JWT"
|
|
184
|
+
},
|
|
185
|
+
"jwtAuthWithLastLogin": {
|
|
186
|
+
"type": "http",
|
|
187
|
+
"scheme": "bearer",
|
|
188
|
+
"bearerFormat": "JWT"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"servers": [
|
|
193
|
+
{
|
|
194
|
+
"url": "http://localhost:8000"
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
}
|
|
@@ -4,6 +4,8 @@
|
|
|
4
4
|
// post-processed bottom of client.gen.ts. No circular import here.
|
|
5
5
|
// DO NOT EDIT — re-run `make gen`.
|
|
6
6
|
|
|
7
|
+
import { APIError } from './errors';
|
|
8
|
+
|
|
7
9
|
const ACCESS_KEY = 'cfg.access_token';
|
|
8
10
|
const REFRESH_KEY = 'cfg.refresh_token';
|
|
9
11
|
const API_KEY_KEY = 'cfg.api_key';
|
|
@@ -77,7 +79,11 @@ function detectLocale(): string | null {
|
|
|
77
79
|
return null;
|
|
78
80
|
}
|
|
79
81
|
|
|
80
|
-
/** Default baseUrl from `NEXT_PUBLIC_API_URL
|
|
82
|
+
/** Default baseUrl from `NEXT_PUBLIC_API_URL`.
|
|
83
|
+
*
|
|
84
|
+
* Both browser and server use NEXT_PUBLIC_API_URL — requests go
|
|
85
|
+
* directly to Django without Next.js proxy.
|
|
86
|
+
*/
|
|
81
87
|
function defaultBaseUrl(): string {
|
|
82
88
|
try {
|
|
83
89
|
if (typeof process !== 'undefined' && process.env) {
|
|
@@ -88,8 +94,15 @@ function defaultBaseUrl(): string {
|
|
|
88
94
|
return '';
|
|
89
95
|
}
|
|
90
96
|
|
|
91
|
-
/** Default API key fallback from `NEXT_PUBLIC_API_KEY`.
|
|
97
|
+
/** Default API key fallback from `NEXT_PUBLIC_API_KEY`.
|
|
98
|
+
*
|
|
99
|
+
* In the browser: returns null — requests go through the Next.js rewrite
|
|
100
|
+
* and the key is injected server-side (never exposed in the bundle).
|
|
101
|
+
* On the server: reads NEXT_PUBLIC_API_KEY as a fallback for SSR calls
|
|
102
|
+
* that bypass the rewrite (e.g. server components calling Django directly).
|
|
103
|
+
*/
|
|
92
104
|
function defaultApiKey(): string | null {
|
|
105
|
+
if (isBrowser) return null;
|
|
93
106
|
try {
|
|
94
107
|
if (typeof process !== 'undefined' && process.env?.NEXT_PUBLIC_API_KEY) {
|
|
95
108
|
return process.env.NEXT_PUBLIC_API_KEY;
|
|
@@ -132,6 +145,7 @@ type HeyClient = {
|
|
|
132
145
|
interceptors: {
|
|
133
146
|
request: { use(fn: (req: Request) => Request | Promise<Request>): void };
|
|
134
147
|
response: { use(fn: (res: Response, req: Request) => Response | Promise<Response>): void };
|
|
148
|
+
error: { use(fn: (err: unknown, res: Response | undefined, req: Request | undefined, opts: unknown) => unknown): void };
|
|
135
149
|
};
|
|
136
150
|
};
|
|
137
151
|
let _client: HeyClient | null = null;
|
|
@@ -301,6 +315,17 @@ export function installAuthOnClient(client: HeyClient): void {
|
|
|
301
315
|
return request;
|
|
302
316
|
});
|
|
303
317
|
|
|
318
|
+
// Wrap raw JSON error objects (thrown by hey-api on non-2xx responses) into
|
|
319
|
+
// APIError so callers can do `error instanceof APIError` and read
|
|
320
|
+
// `error.statusCode` / `error.response` consistently.
|
|
321
|
+
client.interceptors.error.use((err, res, req) => {
|
|
322
|
+
if (err instanceof APIError) return err;
|
|
323
|
+
const url = (req as Request | undefined)?.url ?? '';
|
|
324
|
+
const status = (res as Response | undefined)?.status ?? 0;
|
|
325
|
+
const statusText = (res as Response | undefined)?.statusText ?? '';
|
|
326
|
+
return new APIError(status, statusText, err, url);
|
|
327
|
+
});
|
|
328
|
+
|
|
304
329
|
client.interceptors.response.use(async (response, request) => {
|
|
305
330
|
if (response.status !== 401) return response;
|
|
306
331
|
|
|
@@ -0,0 +1,197 @@
|
|
|
1
|
+
{
|
|
2
|
+
"openapi": "3.1.0",
|
|
3
|
+
"info": {
|
|
4
|
+
"title": "Django CFG API",
|
|
5
|
+
"version": "1.0.0",
|
|
6
|
+
"description": "RESTful API with modern architecture"
|
|
7
|
+
},
|
|
8
|
+
"paths": {
|
|
9
|
+
"/cfg/monitor/ingest/": {
|
|
10
|
+
"post": {
|
|
11
|
+
"operationId": "cfg_monitor_ingest_create",
|
|
12
|
+
"description": "Accepts a batch of up to 50 frontend events. No authentication required — anonymous visitors can send events.",
|
|
13
|
+
"summary": "Ingest browser events",
|
|
14
|
+
"tags": [
|
|
15
|
+
"cfg_monitor"
|
|
16
|
+
],
|
|
17
|
+
"requestBody": {
|
|
18
|
+
"content": {
|
|
19
|
+
"application/json": {
|
|
20
|
+
"schema": {
|
|
21
|
+
"$ref": "#/components/schemas/IngestBatchRequest"
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"required": true
|
|
26
|
+
},
|
|
27
|
+
"security": [
|
|
28
|
+
{}
|
|
29
|
+
],
|
|
30
|
+
"responses": {
|
|
31
|
+
"202": {
|
|
32
|
+
"description": "Accepted"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"x-async-capable": false
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
"components": {
|
|
40
|
+
"schemas": {
|
|
41
|
+
"FrontendEventIngestRequest": {
|
|
42
|
+
"type": "object",
|
|
43
|
+
"description": "Single browser event payload.",
|
|
44
|
+
"properties": {
|
|
45
|
+
"event_type": {
|
|
46
|
+
"$ref": "#/components/schemas/FrontendEventTypeEnum"
|
|
47
|
+
},
|
|
48
|
+
"message": {
|
|
49
|
+
"type": "string",
|
|
50
|
+
"minLength": 1,
|
|
51
|
+
"maxLength": 5000
|
|
52
|
+
},
|
|
53
|
+
"level": {
|
|
54
|
+
"allOf": [
|
|
55
|
+
{
|
|
56
|
+
"$ref": "#/components/schemas/FrontendEventLevelEnum"
|
|
57
|
+
}
|
|
58
|
+
],
|
|
59
|
+
"default": "error"
|
|
60
|
+
},
|
|
61
|
+
"stack_trace": {
|
|
62
|
+
"type": "string",
|
|
63
|
+
"default": "",
|
|
64
|
+
"maxLength": 10000
|
|
65
|
+
},
|
|
66
|
+
"url": {
|
|
67
|
+
"type": "string",
|
|
68
|
+
"default": "",
|
|
69
|
+
"maxLength": 2000
|
|
70
|
+
},
|
|
71
|
+
"fingerprint": {
|
|
72
|
+
"type": "string",
|
|
73
|
+
"default": "",
|
|
74
|
+
"maxLength": 64
|
|
75
|
+
},
|
|
76
|
+
"http_status": {
|
|
77
|
+
"type": [
|
|
78
|
+
"integer",
|
|
79
|
+
"null"
|
|
80
|
+
]
|
|
81
|
+
},
|
|
82
|
+
"http_method": {
|
|
83
|
+
"type": "string",
|
|
84
|
+
"default": "",
|
|
85
|
+
"maxLength": 10
|
|
86
|
+
},
|
|
87
|
+
"http_url": {
|
|
88
|
+
"type": "string",
|
|
89
|
+
"default": "",
|
|
90
|
+
"maxLength": 2000
|
|
91
|
+
},
|
|
92
|
+
"session_id": {
|
|
93
|
+
"type": "string",
|
|
94
|
+
"default": "",
|
|
95
|
+
"maxLength": 64
|
|
96
|
+
},
|
|
97
|
+
"user_agent": {
|
|
98
|
+
"type": "string",
|
|
99
|
+
"default": "",
|
|
100
|
+
"maxLength": 500
|
|
101
|
+
},
|
|
102
|
+
"build_id": {
|
|
103
|
+
"type": "string",
|
|
104
|
+
"default": "",
|
|
105
|
+
"maxLength": 100
|
|
106
|
+
},
|
|
107
|
+
"environment": {
|
|
108
|
+
"type": "string",
|
|
109
|
+
"default": "",
|
|
110
|
+
"maxLength": 20
|
|
111
|
+
},
|
|
112
|
+
"extra": {},
|
|
113
|
+
"project_name": {
|
|
114
|
+
"type": "string",
|
|
115
|
+
"default": "",
|
|
116
|
+
"maxLength": 100
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"required": [
|
|
120
|
+
"event_type",
|
|
121
|
+
"message"
|
|
122
|
+
]
|
|
123
|
+
},
|
|
124
|
+
"FrontendEventLevelEnum": {
|
|
125
|
+
"enum": [
|
|
126
|
+
"error",
|
|
127
|
+
"warning",
|
|
128
|
+
"info",
|
|
129
|
+
"debug"
|
|
130
|
+
],
|
|
131
|
+
"type": "string",
|
|
132
|
+
"description": "* `error` - Error\n* `warning` - Warning\n* `info` - Info\n* `debug` - Debug"
|
|
133
|
+
},
|
|
134
|
+
"FrontendEventTypeEnum": {
|
|
135
|
+
"enum": [
|
|
136
|
+
"JS_ERROR",
|
|
137
|
+
"NETWORK_ERROR",
|
|
138
|
+
"ERROR",
|
|
139
|
+
"WARNING",
|
|
140
|
+
"PAGE_VIEW",
|
|
141
|
+
"PERFORMANCE",
|
|
142
|
+
"CONSOLE"
|
|
143
|
+
],
|
|
144
|
+
"type": "string",
|
|
145
|
+
"description": "* `JS_ERROR` - Js Error\n* `NETWORK_ERROR` - Network Error\n* `ERROR` - Error\n* `WARNING` - Warning\n* `PAGE_VIEW` - Page View\n* `PERFORMANCE` - Performance\n* `CONSOLE` - Console"
|
|
146
|
+
},
|
|
147
|
+
"IngestBatchRequest": {
|
|
148
|
+
"type": "object",
|
|
149
|
+
"description": "Batch of up to 50 browser events.",
|
|
150
|
+
"properties": {
|
|
151
|
+
"events": {
|
|
152
|
+
"type": "array",
|
|
153
|
+
"items": {
|
|
154
|
+
"$ref": "#/components/schemas/FrontendEventIngestRequest"
|
|
155
|
+
},
|
|
156
|
+
"maxItems": 25,
|
|
157
|
+
"minItems": 1
|
|
158
|
+
}
|
|
159
|
+
},
|
|
160
|
+
"required": [
|
|
161
|
+
"events"
|
|
162
|
+
]
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
"securitySchemes": {
|
|
166
|
+
"apiKeyAuth": {
|
|
167
|
+
"type": "apiKey",
|
|
168
|
+
"in": "header",
|
|
169
|
+
"name": "X-API-Key"
|
|
170
|
+
},
|
|
171
|
+
"basicAuth": {
|
|
172
|
+
"type": "http",
|
|
173
|
+
"scheme": "basic"
|
|
174
|
+
},
|
|
175
|
+
"cookieAuth": {
|
|
176
|
+
"type": "apiKey",
|
|
177
|
+
"in": "cookie",
|
|
178
|
+
"name": "sessionid"
|
|
179
|
+
},
|
|
180
|
+
"jwtAuth": {
|
|
181
|
+
"type": "http",
|
|
182
|
+
"scheme": "bearer",
|
|
183
|
+
"bearerFormat": "JWT"
|
|
184
|
+
},
|
|
185
|
+
"jwtAuthWithLastLogin": {
|
|
186
|
+
"type": "http",
|
|
187
|
+
"scheme": "bearer",
|
|
188
|
+
"bearerFormat": "JWT"
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
},
|
|
192
|
+
"servers": [
|
|
193
|
+
{
|
|
194
|
+
"url": "http://localhost:8000"
|
|
195
|
+
}
|
|
196
|
+
]
|
|
197
|
+
}
|