@factorypure/logger 1.0.4 → 1.0.6

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/index.d.ts CHANGED
@@ -31,9 +31,8 @@ type LoggerOptions = {
31
31
  notifyClient?: Notify;
32
32
  fatalErrorSlackChannel: string;
33
33
  };
34
- export declare const attachRequestId: (asyncLocalStorage: AsyncLocalStorage<any>, user: {
34
+ export declare const attachRequestId: (asyncLocalStorage: AsyncLocalStorage<any>, user?: {
35
35
  id: number;
36
- email: string;
37
36
  }) => (req: Request, _res: Response, next: NextFunction) => void;
38
37
  export declare const logCrashes: () => void;
39
38
  export declare const reportCrashes: (logger: LogStream) => void;
package/dist/index.js CHANGED
@@ -145,11 +145,13 @@ export default class LoggerClient {
145
145
  export const attachRequestId = (asyncLocalStorage, user) => {
146
146
  return (req, _res, next) => {
147
147
  const availableCharacters = "qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM0987654321";
148
- let id = `userId-${user.id}:userEmail-${user.email}:`;
149
- while (id.length < 10) {
150
- id +=
148
+ let id = user ? `userId-${user.id}:` : 'system-request:';
149
+ let uniqueKey = '';
150
+ while (uniqueKey.length < 10) {
151
+ uniqueKey +=
151
152
  availableCharacters[Math.floor(Math.random() * availableCharacters.length)];
152
153
  }
154
+ id = id + uniqueKey;
153
155
  req.headers["X-Request-Id"] = id;
154
156
  asyncLocalStorage.run(id, next);
155
157
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@factorypure/logger",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "description": "",
5
5
  "main": "./dist/index.js",
6
6
  "types": "./dist/index.d.ts",