Skip to content

Commit 0c5545b

Browse files
authored
Clear some client-side events collected by analytics (cvat-ai#8304)
1 parent a69e122 commit 0c5545b

File tree

21 files changed

+89
-155
lines changed

21 files changed

+89
-155
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
### Removed
2+
3+
- Client event `restore:job` (<https://github.com/cvat-ai/cvat/pull/8304>)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
### Deprecated
2+
3+
- Client events `upload:annotations`, `lock:object`, `change:attribute`, `change:label`
4+
(<https://github.com/cvat-ai/cvat/pull/8304>)

cvat-canvas/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -72,9 +72,9 @@ Standard JS events are used.
7272
- canvas.reshape
7373
- canvas.fit
7474
- canvas.regionselected => {points: number[]}
75-
- canvas.dragshape => {id: number}
75+
- canvas.dragshape => {duration: number, state: ObjectState}
7676
- canvas.roiselected => {points: number[]}
77-
- canvas.resizeshape => {id: number}
77+
- canvas.resizeshape => {duration: number, state: ObjectState}
7878
- canvas.contextmenu => { mouseEvent: MouseEvent, objectState: ObjectState, pointID: number }
7979
- canvas.message => { messages: { type: 'text' | 'list'; content: string | string[]; className?: string; icon?: 'info' | 'loading' }[] | null, topic: string }
8080
- canvas.error => { exception: Error, domain?: string }

cvat-canvas/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cvat-canvas",
3-
"version": "2.20.8",
3+
"version": "2.20.9",
44
"type": "module",
55
"description": "Part of Computer Vision Annotation Tool which presents its canvas library",
66
"main": "src/canvas.ts",

cvat-canvas/src/typescript/canvasView.ts

+8-2
Original file line numberDiff line numberDiff line change
@@ -1074,6 +1074,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
10741074
}
10751075

10761076
if (state) {
1077+
let start = Date.now();
10771078
let aborted = false;
10781079
let skeletonSVGTemplate: SVG.G = null;
10791080
shape.addClass('cvat_canvas_shape_draggable');
@@ -1084,6 +1085,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
10841085
draggableInstance.on('dragstart', (): void => {
10851086
onDragStart();
10861087
this.draggableShape = shape;
1088+
start = Date.now();
10871089
}).on('dragmove', (e: CustomEvent): void => {
10881090
onDragMove();
10891091
if (state.shapeType === 'skeleton' && e.target) {
@@ -1159,7 +1161,8 @@ export class CanvasViewImpl implements CanvasView, Listener {
11591161
bubbles: false,
11601162
cancelable: true,
11611163
detail: {
1162-
id: state.clientID,
1164+
state,
1165+
duration: Date.now() - start,
11631166
},
11641167
}),
11651168
);
@@ -1243,6 +1246,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
12431246
if (state) {
12441247
let resized = false;
12451248
let aborted = false;
1249+
let start = Date.now();
12461250

12471251
(resizableInstance as any)
12481252
.resize({
@@ -1252,6 +1256,7 @@ export class CanvasViewImpl implements CanvasView, Listener {
12521256
.on('resizestart', (): void => {
12531257
onResizeStart();
12541258
resized = false;
1259+
start = Date.now();
12551260
this.resizableShape = shape;
12561261
})
12571262
.on('resizing', (e: CustomEvent): void => {
@@ -1344,7 +1349,8 @@ export class CanvasViewImpl implements CanvasView, Listener {
13441349
bubbles: false,
13451350
cancelable: true,
13461351
detail: {
1347-
id: state.clientID,
1352+
state,
1353+
duration: Date.now() - start,
13481354
},
13491355
}),
13501356
);

cvat-core/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cvat-core",
3-
"version": "15.1.1",
3+
"version": "15.1.2",
44
"type": "module",
55
"description": "Part of Computer Vision Tool which presents an interface for client-side integration",
66
"main": "src/api.ts",

cvat-core/src/enums.ts

+1-6
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,9 @@ export enum EventScope {
9494
loadTool = 'load:cvat',
9595

9696
loadJob = 'load:job',
97+
loadWorkspace = 'load:workspace',
9798
saveJob = 'save:job',
98-
restoreJob = 'restore:job',
99-
uploadAnnotations = 'upload:annotations',
10099
exception = 'send:exception',
101-
sendTaskInfo = 'send:task_info',
102100

103101
drawObject = 'draw:object',
104102
pasteObject = 'paste:object',
@@ -107,14 +105,11 @@ export enum EventScope {
107105
dragObject = 'drag:object',
108106
resizeObject = 'resize:object',
109107
deleteObject = 'delete:object',
110-
lockObject = 'lock:object',
111108
mergeObjects = 'merge:objects',
112109
splitObjects = 'split:objects',
113110
groupObjects = 'group:objects',
114111
sliceObject = 'slice:object',
115112
joinObjects = 'join:objects',
116-
changeAttribute = 'change:attribute',
117-
changeLabel = 'change:label',
118113

119114
changeFrame = 'change:frame',
120115
zoomImage = 'zoom:image',

cvat-core/src/logger.ts

+10-19
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,13 @@ function sleep(ms): Promise<void> {
1616
}
1717

1818
function defaultUpdate(previousEvent: Event, currentPayload: JSONEventPayload): JSONEventPayload {
19+
const count = Number.isInteger(previousEvent.payload.count) ? previousEvent.payload.count as number : 1;
20+
1921
return {
2022
...previousEvent.payload,
2123
...currentPayload,
24+
count: count + 1,
25+
duration: Date.now() - previousEvent.timestamp.getTime(),
2226
};
2327
}
2428

@@ -29,19 +33,14 @@ interface IgnoreRule {
2933
update: (previousEvent: Event, currentPayload: JSONEventPayload) => JSONEventPayload;
3034
}
3135

32-
type IgnoredRules = (
33-
EventScope.zoomImage | EventScope.changeAttribute |
34-
EventScope.changeFrame | EventScope.exception
35-
);
36-
3736
class Logger {
3837
public clientID: string;
3938
public collection: Array<Event>;
4039
public lastSentEvent: Event | null;
41-
public ignoreRules: Record<IgnoredRules, IgnoreRule>;
40+
public ignoreRules: Record<string, IgnoreRule>;
4241
public isActiveChecker: () => boolean;
4342
public saving: boolean;
44-
public compressedScopes: Array<IgnoredRules>;
43+
public compressedScopes: Array<EventScope>;
4544

4645
constructor() {
4746
this.clientID = Date.now().toString().substr(-6);
@@ -54,6 +53,8 @@ class Logger {
5453
[EventScope.zoomImage]: {
5554
lastEvent: null,
5655
ignore: (previousEvent: Event): boolean => {
56+
// previous event from the same scope is the latest push event in the collection
57+
// it means, no more events were pushed between the previous and this one
5758
const [lastCollectionEvent] = this.collection.slice(-1);
5859
return previousEvent === lastCollectionEvent;
5960
},
@@ -78,16 +79,6 @@ class Logger {
7879
};
7980
},
8081
},
81-
[EventScope.changeAttribute]: {
82-
lastEvent: null,
83-
ignore(previousEvent: Event, currentPayload: JSONEventPayload): boolean {
84-
return (
85-
currentPayload.object_id === previousEvent.payload.object_id &&
86-
currentPayload.id === previousEvent.payload.id
87-
);
88-
},
89-
update: defaultUpdate,
90-
},
9182
[EventScope.changeFrame]: {
9283
lastEvent: null,
9384
ignore(previousEvent: Event, currentPayload: JSONEventPayload): boolean {
@@ -168,7 +159,7 @@ Object.defineProperties(Logger.prototype.log, {
168159
}
169160

170161
if (scope in this.ignoreRules) {
171-
const ignoreRule = this.ignoreRules[scope as IgnoredRules];
162+
const ignoreRule = this.ignoreRules[scope];
172163
const { lastEvent } = ignoreRule;
173164
if (lastEvent && ignoreRule.ignore(lastEvent, payload)) {
174165
lastEvent.payload = ignoreRule.update(lastEvent, payload);
@@ -189,7 +180,7 @@ Object.defineProperties(Logger.prototype.log, {
189180
this.collection.push(event);
190181

191182
if (scope in this.ignoreRules) {
192-
this.ignoreRules[scope as IgnoredRules].lastEvent = event;
183+
this.ignoreRules[scope].lastEvent = event;
193184
}
194185
};
195186

cvat-ui/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "cvat-ui",
3-
"version": "1.64.5",
3+
"version": "1.64.6",
44
"description": "CVAT single-page application",
55
"main": "src/index.tsx",
66
"scripts": {

cvat-ui/src/actions/annotation-actions.ts

+3-33
Original file line numberDiff line numberDiff line change
@@ -88,31 +88,6 @@ export function computeZRange(states: any[]): number[] {
8888
return [minZ, maxZ];
8989
}
9090

91-
export async function jobInfoGenerator(job: any): Promise<Record<string, number>> {
92-
const { total } = await job.annotations.statistics();
93-
return {
94-
'frame count': job.stopFrame - job.startFrame + 1,
95-
'track count':
96-
total.rectangle.shape +
97-
total.rectangle.track +
98-
total.polygon.shape +
99-
total.polygon.track +
100-
total.polyline.shape +
101-
total.polyline.track +
102-
total.points.shape +
103-
total.points.track +
104-
total.cuboid.shape +
105-
total.cuboid.track,
106-
'object count': total.total,
107-
'box count': total.rectangle.shape + total.rectangle.track,
108-
'polygon count': total.polygon.shape + total.polygon.track,
109-
'polyline count': total.polyline.shape + total.polyline.track,
110-
'points count': total.points.shape + total.points.track,
111-
'cuboids count': total.cuboid.shape + total.cuboid.track,
112-
'tag count': total.tag,
113-
};
114-
}
115-
11691
export enum AnnotationActionTypes {
11792
GET_JOB = 'GET_JOB',
11893
GET_JOB_SUCCESS = 'GET_JOB_SUCCESS',
@@ -835,7 +810,7 @@ export function rotateCurrentFrame(rotation: Rotation): AnyAction {
835810

836811
const frameAngle = (frameAngles[frameNumber - startFrame] + (rotation === Rotation.CLOCKWISE90 ? 90 : 270)) % 360;
837812

838-
job.logger.log(EventScope.rotateImage, { angle: frameAngle });
813+
job.logger.log(EventScope.rotateImage);
839814

840815
return {
841816
type: AnnotationActionTypes.ROTATE_FRAME,
@@ -914,7 +889,7 @@ export function getJobAsync({
914889
throw new Error('Requested resource id is not valid');
915890
}
916891

917-
const loadJobEvent = await logger.log(EventScope.loadJob, {}, true);
892+
const start = Date.now();
918893

919894
getCore().config.globalObjectsCounter = 0;
920895
const [job] = await cvat.jobs.get({ jobID });
@@ -962,12 +937,7 @@ export function getJobAsync({
962937
}
963938
}
964939

965-
loadJobEvent.close({
966-
...await jobInfoGenerator(job),
967-
jobID: job.id,
968-
taskID: job.taskId,
969-
projectID: job.projectId,
970-
});
940+
await job.logger.log(EventScope.loadJob, { duration: Date.now() - start });
971941

972942
const openTime = Date.now();
973943
dispatch({

cvat-ui/src/actions/boundaries-actions.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
// Copyright (C) 2020-2022 Intel Corporation
2-
// Copyright (C) 2022-2023 CVAT.ai Corporation
2+
// Copyright (C) 2022-2024 CVAT.ai Corporation
33
//
44
// SPDX-License-Identifier: MIT
55

66
import {
77
ActionUnion, createAction, ThunkAction, ThunkDispatch,
88
} from 'utils/redux';
99
import { getCore } from 'cvat-core-wrapper';
10-
import { EventScope } from 'cvat-logger';
1110
import { fetchAnnotationsAsync } from './annotation-actions';
1211

1312
const cvat = getCore();
@@ -46,8 +45,6 @@ export function resetAfterErrorAsync(): ThunkAction {
4645
const frameData = await job.frames.get(frameNumber);
4746
const colors = [...cvat.enums.colors];
4847

49-
await job.logger.log(EventScope.restoreJob);
50-
5148
dispatch(boundariesActions.resetAfterError({
5249
job,
5350
states: [],

cvat-ui/src/actions/import-actions.ts

-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { CombinedState } from 'reducers';
88
import {
99
getCore, Storage, Job, Task, Project, ProjectOrTaskOrJob,
1010
} from 'cvat-core-wrapper';
11-
import { EventScope } from 'cvat-logger';
1211
import { getProjectsAsync } from './projects-actions';
1312
import { AnnotationActionTypes, fetchAnnotationsAsync } from './annotation-actions';
1413
import {
@@ -136,7 +135,6 @@ export const importDatasetAsync = (
136135
if (shouldListenForProgress(rqID, state.requests)) {
137136
await listen(rqID, dispatch);
138137

139-
await (instance as Job).logger.log(EventScope.uploadAnnotations);
140138
await (instance as Job).annotations.clear({ reload: true });
141139
await (instance as Job).actions.clear();
142140

cvat-ui/src/components/annotation-page/annotation-page.tsx

+9-1
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ import { Workspace } from 'reducers';
2525
import { usePrevious } from 'utils/hooks';
2626
import EventRecorder from 'utils/event-recorder';
2727
import { readLatestFrame } from 'utils/remember-latest-frame';
28+
import { EventScope } from 'cvat-core/src/enums';
2829

2930
interface Props {
3031
job: Job | null | undefined;
@@ -40,7 +41,8 @@ interface Props {
4041

4142
export default function AnnotationPageComponent(props: Props): JSX.Element {
4243
const {
43-
job, fetching, annotationsInitialized, workspace, frameNumber, getJob, closeJob, saveLogs, changeFrame,
44+
job, fetching, annotationsInitialized, workspace, frameNumber,
45+
getJob, closeJob, saveLogs, changeFrame,
4446
} = props;
4547
const prevJob = usePrevious(job);
4648
const prevFetching = usePrevious(fetching);
@@ -126,6 +128,12 @@ export default function AnnotationPageComponent(props: Props): JSX.Element {
126128
}
127129
}, [job, fetching, prevJob, prevFetching]);
128130

131+
useEffect(() => {
132+
if (job) {
133+
job.logger.log(EventScope.loadWorkspace, { obj_name: workspace });
134+
}
135+
}, [job, workspace]);
136+
129137
if (job === null || !annotationsInitialized) {
130138
return <Spin size='large' className='cvat-spinner' />;
131139
}

0 commit comments

Comments
 (0)