@sipgate/integration-bridge 1.0.24 → 1.0.26
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.
|
@@ -2,5 +2,5 @@
|
|
|
2
2
|
import { NextFunction, Response } from 'express';
|
|
3
3
|
import { BridgeRequest } from '../models';
|
|
4
4
|
import { AsyncLocalStorage } from 'async_hooks';
|
|
5
|
-
export declare const
|
|
5
|
+
export declare const userIdStorage: AsyncLocalStorage<string>;
|
|
6
6
|
export declare function extractHeaderMiddleware(req: BridgeRequest<any>, res: Response, next: NextFunction): void;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.extractHeaderMiddleware = exports.
|
|
3
|
+
exports.extractHeaderMiddleware = exports.userIdStorage = void 0;
|
|
4
4
|
const async_hooks_1 = require("async_hooks");
|
|
5
5
|
const DEFAULT_LOCALE = 'de-DE';
|
|
6
|
-
exports.
|
|
6
|
+
exports.userIdStorage = new async_hooks_1.AsyncLocalStorage();
|
|
7
7
|
function extractHeaderMiddleware(req, res, next) {
|
|
8
8
|
const userId = req.get('x-user-id') || '';
|
|
9
9
|
const apiKey = req.get('x-provider-key') || '';
|
|
@@ -15,7 +15,7 @@ function extractHeaderMiddleware(req, res, next) {
|
|
|
15
15
|
apiUrl,
|
|
16
16
|
locale,
|
|
17
17
|
};
|
|
18
|
-
exports.
|
|
18
|
+
exports.userIdStorage.run(userId, () => next());
|
|
19
19
|
}
|
|
20
20
|
exports.extractHeaderMiddleware = extractHeaderMiddleware;
|
|
21
21
|
//# sourceMappingURL=extract-header.middleware.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-header.middleware.js","sourceRoot":"","sources":["../../src/middlewares/extract-header.middleware.ts"],"names":[],"mappings":";;;AAEA,6CAAgD;AAEhD,MAAM,cAAc,GAAG,OAAO,CAAC;AAElB,QAAA,
|
|
1
|
+
{"version":3,"file":"extract-header.middleware.js","sourceRoot":"","sources":["../../src/middlewares/extract-header.middleware.ts"],"names":[],"mappings":";;;AAEA,6CAAgD;AAEhD,MAAM,cAAc,GAAG,OAAO,CAAC;AAElB,QAAA,aAAa,GAAG,IAAI,+BAAiB,EAAU,CAAC;AAE7D,SAAgB,uBAAuB,CACrC,GAAuB,EACvB,GAAa,EACb,IAAkB;IAElB,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;IAC1C,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;IAC/C,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,gBAAgB,CAAC,IAAI,EAAE,CAAC;IAC/C,MAAM,MAAM,GAAG,GAAG,CAAC,GAAG,CAAC,mBAAmB,CAAC,IAAI,cAAc,CAAC;IAE9D,GAAG,CAAC,cAAc,GAAG;QACnB,MAAM;QACN,MAAM;QACN,MAAM;QACN,MAAM;KACP,CAAC;IAEF,qBAAa,CAAC,GAAG,CAAC,MAAM,EAAE,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC,CAAC;AAC1C,CAAC;AAlBD,0DAkBC"}
|
package/dist/util/logger.util.js
CHANGED
|
@@ -4,22 +4,14 @@ exports.warnLogger = exports.errorLogger = exports.infoLogger = void 0;
|
|
|
4
4
|
const api_1 = require("@opentelemetry/api");
|
|
5
5
|
const anonymize_key_1 = require("./anonymize-key");
|
|
6
6
|
const middlewares_1 = require("../middlewares");
|
|
7
|
-
function addMessageToTraceSpan(method, message, args
|
|
7
|
+
function addMessageToTraceSpan(method, message, args) {
|
|
8
8
|
const span = api_1.trace.getSpan(api_1.context.active());
|
|
9
|
-
if (
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
if (userId) {
|
|
15
|
-
data.push({ platypusUserId: userId });
|
|
9
|
+
if (span) {
|
|
10
|
+
span.addEvent(method, {
|
|
11
|
+
message,
|
|
12
|
+
args: args ? args.map((arg) => JSON.stringify(arg)).join(',') : '',
|
|
13
|
+
});
|
|
16
14
|
}
|
|
17
|
-
span.addEvent(method, {
|
|
18
|
-
message,
|
|
19
|
-
args: (data === null || data === void 0 ? void 0 : data.length) !== 0
|
|
20
|
-
? data.map((arg) => JSON.stringify(arg)).join(',')
|
|
21
|
-
: '',
|
|
22
|
-
});
|
|
23
15
|
}
|
|
24
16
|
/**
|
|
25
17
|
* Logging function equivalent to console.log
|
|
@@ -58,17 +50,19 @@ const warnLogger = (source, message, apiKey, ...args) => {
|
|
|
58
50
|
};
|
|
59
51
|
exports.warnLogger = warnLogger;
|
|
60
52
|
const logger = (logFn, source, message, apiKey, ...args) => {
|
|
61
|
-
|
|
62
|
-
const anonymizedApiKey = apiKey ? (0, anonymize_key_1.anonymizeKey)(apiKey) : undefined;
|
|
63
|
-
const formatedMessage = constructLogMessage(anonymizedApiKey ? `[${anonymizedApiKey}]` : undefined, `[${source}]`, message);
|
|
53
|
+
const formatedMessage = constructLogMessage(`[${source}]`, message);
|
|
64
54
|
if (process.env.NODE_ENV === 'development') {
|
|
65
55
|
logFn(formatedMessage, ...args);
|
|
66
56
|
return;
|
|
67
57
|
}
|
|
68
58
|
const data = Object.assign({}, args);
|
|
69
|
-
const userId = middlewares_1.
|
|
59
|
+
const userId = middlewares_1.userIdStorage.getStore();
|
|
70
60
|
if (userId) {
|
|
71
|
-
data.
|
|
61
|
+
data.userId = userId;
|
|
62
|
+
}
|
|
63
|
+
const anonymizedApiKey = apiKey ? (0, anonymize_key_1.anonymizeKey)(apiKey) : undefined;
|
|
64
|
+
if (anonymizedApiKey) {
|
|
65
|
+
data.apiKey = anonymizedApiKey;
|
|
72
66
|
}
|
|
73
67
|
logFn(JSON.stringify(Object.assign({ message: formatedMessage }, data)));
|
|
74
68
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"logger.util.js","sourceRoot":"","sources":["../../src/util/logger.util.ts"],"names":[],"mappings":";;;AAAA,4CAAoD;AAEpD,mDAA+C;AAC/C,
|
|
1
|
+
{"version":3,"file":"logger.util.js","sourceRoot":"","sources":["../../src/util/logger.util.ts"],"names":[],"mappings":";;;AAAA,4CAAoD;AAEpD,mDAA+C;AAC/C,gDAA+C;AAE/C,SAAS,qBAAqB,CAC5B,MAAgC,EAChC,OAAe,EACf,IAAgB;IAEhB,MAAM,IAAI,GAAG,WAAK,CAAC,OAAO,CAAC,aAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IAC7C,IAAI,IAAI,EAAE;QACR,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;YACpB,OAAO;YACP,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE;SACnE,CAAC,CAAC;KACJ;AACH,CAAC;AAED;;;;;;GAMG;AACI,MAAM,UAAU,GAAG,CACxB,MAAc,EACd,OAAe,EACf,MAAe,EACf,GAAG,IAAe,EACZ,EAAE;IACR,qBAAqB,CAAC,KAAK,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAEjD,MAAM,CAAC,OAAO,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,CAAC;AACzD,CAAC,CAAC;AATW,QAAA,UAAU,cASrB;AAEF;;;;;;GAMG;AACI,MAAM,WAAW,GAAG,CACzB,MAAc,EACd,OAAe,EACf,MAAe,EACf,GAAG,IAAe,EACZ,EAAE;IACR,qBAAqB,CAAC,OAAO,EAAE,OAAO,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC;IAEnD,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,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