@efa-one/sdk 1.15.1 → 1.16.1
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/backend/reporting.d.ts +4 -4
- package/backend/reporting.js +22 -12
- package/package.json +4 -4
package/backend/reporting.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
type LogLevel = 'debug' | 'info' | 'warn' | 'error';
|
|
2
|
-
export declare function reportEvent(eventType: string, payload?: Record<string, unknown>,
|
|
3
|
-
export declare function reportLog(level: LogLevel, message: string, context?: Record<string, unknown
|
|
4
|
-
export declare function reportMetric(metricName: string, value: number, dimensions?: Record<string, unknown
|
|
5
|
-
export declare function reportActivity(action: string,
|
|
2
|
+
export declare function reportEvent(eventType: string, payload?: Record<string, unknown>, userId?: string): void;
|
|
3
|
+
export declare function reportLog(level: LogLevel, message: string, context?: Record<string, unknown>): void;
|
|
4
|
+
export declare function reportMetric(metricName: string, value: number, dimensions?: Record<string, unknown>): void;
|
|
5
|
+
export declare function reportActivity(action: string, resource?: string, userId?: string): void;
|
|
6
6
|
export {};
|
package/backend/reporting.js
CHANGED
|
@@ -4,28 +4,38 @@ exports.reportEvent = reportEvent;
|
|
|
4
4
|
exports.reportLog = reportLog;
|
|
5
5
|
exports.reportMetric = reportMetric;
|
|
6
6
|
exports.reportActivity = reportActivity;
|
|
7
|
-
function ingest(entries
|
|
7
|
+
function ingest(entries) {
|
|
8
8
|
const url = process.env.REPORTING_URL;
|
|
9
9
|
if (!url)
|
|
10
10
|
return;
|
|
11
11
|
const headers = { 'Content-Type': 'application/json' };
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const registryKey = process.env.SERVICE_AUTH_KEY;
|
|
13
|
+
if (registryKey)
|
|
14
|
+
headers['X-Service-Auth-Key'] = registryKey;
|
|
15
|
+
fetch(url, { method: 'POST', headers, body: JSON.stringify(entries) })
|
|
16
|
+
.then((res) => {
|
|
17
|
+
if (!res.ok) {
|
|
18
|
+
console.error(JSON.stringify({ level: 'error', msg: 'Reporting ingest rejected', status: res.status }));
|
|
19
|
+
}
|
|
20
|
+
})
|
|
21
|
+
.catch((err) => {
|
|
15
22
|
console.error(JSON.stringify({ level: 'error', msg: 'Reporting ingest failed', err: String(err) }));
|
|
16
23
|
});
|
|
17
24
|
}
|
|
18
25
|
const appName = () => process.env.APP_NAME ?? 'app';
|
|
19
26
|
const appVersion = () => process.env.APP_VERSION ?? 'dev';
|
|
20
|
-
function reportEvent(eventType, payload,
|
|
21
|
-
ingest([{ type: 'event', sourceApp: appName(), appVersion: appVersion(), eventType, payload }]
|
|
27
|
+
function reportEvent(eventType, payload, userId) {
|
|
28
|
+
ingest([{ type: 'event', sourceApp: appName(), appVersion: appVersion(), eventType, userId, payload }]);
|
|
22
29
|
}
|
|
23
|
-
function reportLog(level, message, context
|
|
24
|
-
ingest([{ type: 'log', sourceApp: appName(), appVersion: appVersion(), level, message, context }]
|
|
30
|
+
function reportLog(level, message, context) {
|
|
31
|
+
ingest([{ type: 'log', sourceApp: appName(), appVersion: appVersion(), level, message, context }]);
|
|
25
32
|
}
|
|
26
|
-
function reportMetric(metricName, value, dimensions
|
|
27
|
-
ingest([{ type: 'metric', sourceApp: appName(), appVersion: appVersion(), metricName, value, dimensions }]
|
|
33
|
+
function reportMetric(metricName, value, dimensions) {
|
|
34
|
+
ingest([{ type: 'metric', sourceApp: appName(), appVersion: appVersion(), metricName, value, dimensions }]);
|
|
28
35
|
}
|
|
29
|
-
function reportActivity(action,
|
|
30
|
-
|
|
36
|
+
function reportActivity(action, resource, userId) {
|
|
37
|
+
if (!userId) {
|
|
38
|
+
console.warn(JSON.stringify({ level: 'warn', msg: 'reportActivity without userId — kernel will drop this entry', action }));
|
|
39
|
+
}
|
|
40
|
+
ingest([{ type: 'activity', sourceApp: appName(), appVersion: appVersion(), action, userId, resource }]);
|
|
31
41
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@efa-one/sdk",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.16.1",
|
|
4
4
|
"description": "Offizielles SDK für efa-one-Apps: Auth/Session, Service-Discovery, Gateway-Client, Audit/Reporting/Mail/Notifications, Permission- und Capability-Registrierung sowie das Frontend-IPC-/i18n-Toolkit.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
}
|
|
106
106
|
},
|
|
107
107
|
"devDependencies": {
|
|
108
|
-
"@eslint/js": "^
|
|
108
|
+
"@eslint/js": "^10.0.1",
|
|
109
109
|
"@radix-ui/react-dialog": "^1.1.4",
|
|
110
110
|
"@radix-ui/react-dropdown-menu": "^2.1.4",
|
|
111
111
|
"@radix-ui/react-tooltip": "^1.1.6",
|
|
@@ -118,11 +118,11 @@
|
|
|
118
118
|
"@types/supertest": "^7.2.0",
|
|
119
119
|
"@vitest/coverage-v8": "^4.1.11",
|
|
120
120
|
"cookie-parser": "^1.4.6",
|
|
121
|
-
"eslint": "^9.
|
|
121
|
+
"eslint": "^10.9.1",
|
|
122
122
|
"eslint-plugin-react-hooks": "^7.1.1",
|
|
123
123
|
"express": "^4.19.2",
|
|
124
124
|
"i18next": "^23.11.0",
|
|
125
|
-
"i18next-http-backend": "^
|
|
125
|
+
"i18next-http-backend": "^3.0.5",
|
|
126
126
|
"jsonwebtoken": "^9.0.2",
|
|
127
127
|
"lucide-react": "^0.577.0",
|
|
128
128
|
"pg": "^8.12.0",
|