diff --git a/changelog.d/20240320_125513_klakhov_event_for_logged_out_user.md b/changelog.d/20240320_125513_klakhov_event_for_logged_out_user.md new file mode 100644 index 000000000000..8fec0155e89a --- /dev/null +++ b/changelog.d/20240320_125513_klakhov_event_for_logged_out_user.md @@ -0,0 +1,3 @@ +### Fixed + +- Sending `/events` request from logged-out user () diff --git a/cvat-core/package.json b/cvat-core/package.json index 5e57ad15cc68..ab537343f248 100644 --- a/cvat-core/package.json +++ b/cvat-core/package.json @@ -1,6 +1,6 @@ { "name": "cvat-core", - "version": "15.0.1", + "version": "15.0.2", "type": "module", "description": "Part of Computer Vision Tool which presents an interface for client-side integration", "main": "src/api.ts", diff --git a/cvat-core/src/index.ts b/cvat-core/src/index.ts index e4bdde9ba091..2843767e254d 100644 --- a/cvat-core/src/index.ts +++ b/cvat-core/src/index.ts @@ -160,7 +160,7 @@ export default interface CVATCore { enabled: boolean; onEmptyMaskOccurrence: () => void | null; }; - onOrganizationChange: typeof config.onOrganizationChange; + onOrganizationChange: (newOrgId: number | null) => void | null; globalObjectsCounter: typeof config.globalObjectsCounter; }, client: { diff --git a/cvat-core/src/logger.ts b/cvat-core/src/logger.ts index d13b1d7a6fe3..1e8fdb174213 100644 --- a/cvat-core/src/logger.ts +++ b/cvat-core/src/logger.ts @@ -225,6 +225,8 @@ Object.defineProperties(Logger.prototype.save, { // potentially new events may be generated during saving // that is why we add this.collection this.collection = [...collectionToSend, ...this.collection]; + + throw error; } finally { this.saving = false; } diff --git a/cvat-ui/src/components/cvat-app.tsx b/cvat-ui/src/components/cvat-app.tsx index 9c60ae5adf80..22898f153b63 100644 --- a/cvat-ui/src/components/cvat-app.tsx +++ b/cvat-ui/src/components/cvat-app.tsx @@ -1,5 +1,5 @@ // Copyright (C) 2020-2022 Intel Corporation -// Copyright (C) 2022-2023 CVAT.ai Corporation +// Copyright (C) 2022-2024 CVAT.ai Corporation // // SPDX-License-Identifier: MIT @@ -71,7 +71,7 @@ import showPlatformNotification, { } from 'utils/platform-checker'; import '../styles.scss'; import appConfig from 'config'; -import EventRecorder from 'utils/controls-logger'; +import EventRecorder from 'utils/event-recorder'; import { authQuery } from 'utils/auth-query'; import EmailConfirmationPage from './email-confirmation-pages/email-confirmed'; import EmailVerificationSentPage from './email-confirmation-pages/email-verification-sent'; @@ -149,7 +149,6 @@ class CVATApplication extends React.PureComponent window.document.hasFocus, userActivityCallback); - EventRecorder.initSave(); core.config.onOrganizationChange = (newOrgId: number | null) => { if (newOrgId === null) { @@ -254,7 +253,7 @@ class CVATApplication extends React.PureComponent { - core.logger.save().finally(() => { + const scheduleSave = (): void => { this.#savingTimeout = null; this.initSave(); - }); + }; + core.logger.save() + .then(scheduleSave) + .catch((error) => { + if (error?.code === 401) { + this.cancelSave(); + } else { + scheduleSave(); + } + }); }, CONTROLS_LOGS_INTERVAL); } + public cancelSave(): void { + if (this.#savingTimeout) { + window.clearTimeout(this.#savingTimeout); + this.#savingTimeout = null; + } + } + private filterClassName(cls: string): string { if (typeof cls === 'string') { return cls.split(' ').filter((_cls: string) => _cls.startsWith('cvat')).join(' ');