From 3222f344552bbc2ebc3743b5f6e913d8983ee6b3 Mon Sep 17 00:00:00 2001 From: Piotr Gawron <p.gawron@atcomp.pl> Date: Thu, 16 May 2024 11:40:43 +0200 Subject: [PATCH] provide timestamp in error data --- src/utils/error-report/ErrorData.ts | 2 +- src/utils/error-report/errorReporting.test.ts | 5 +++++ src/utils/error-report/errorReporting.ts | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/utils/error-report/ErrorData.ts b/src/utils/error-report/ErrorData.ts index ba1abdde..64ef0f63 100644 --- a/src/utils/error-report/ErrorData.ts +++ b/src/utils/error-report/ErrorData.ts @@ -3,7 +3,7 @@ export type ErrorData = { login: string | null; email: string | null; browser: string | null; - timestamp: string | null; + timestamp: number | null; version: string | null; comment: string | null; stacktrace: string; diff --git a/src/utils/error-report/errorReporting.test.ts b/src/utils/error-report/errorReporting.test.ts index c90ef65c..7adb535c 100644 --- a/src/utils/error-report/errorReporting.test.ts +++ b/src/utils/error-report/errorReporting.test.ts @@ -47,4 +47,9 @@ describe('createErrorData', () => { expect(error.login).not.toBe('anonymous'); expect(error.login).toBe(loginFixture.login); }); + + it('should add timestamp', () => { + const error = createErrorData(new Error()); + expect(error.timestamp).not.toBeNull(); + }); }); diff --git a/src/utils/error-report/errorReporting.ts b/src/utils/error-report/errorReporting.ts index 348769f5..5d867950 100644 --- a/src/utils/error-report/errorReporting.ts +++ b/src/utils/error-report/errorReporting.ts @@ -23,7 +23,8 @@ export const createErrorData = (error: Error | SerializedError | undefined): Err email: null, // TODO javaStacktrace: null, // TODO stacktrace, - timestamp: null, // TODO + // eslint-disable-next-line no-magic-numbers + timestamp: Math.floor(+new Date() / 1000), version: null, // TODO }; return errorData; -- GitLab