Skip to content

Clear some client-side events collected by analytics #8304

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 24 commits into from
Aug 19, 2024

Conversation

bsekachev
Copy link
Member

@bsekachev bsekachev commented Aug 14, 2024

Motivation and context

  • Minimize drag and resize events
  • Minimize zoom events

Resolved #7994

How has this been tested?

Checklist

  • I submit my changes into the develop branch
  • I have created a changelog fragment
  • I have updated the documentation accordingly
  • I have added tests to cover my changes
  • I have linked related issues (see GitHub docs)
  • I have increased versions of npm packages if it is necessary
    (cvat-canvas,
    cvat-core,
    cvat-data and
    cvat-ui)

License

  • I submit my code changes under the same MIT License that covers the project.
    Feel free to contact the maintainers if that's a concern.

Summary by CodeRabbit

  • New Features
    • Updated documentation to reflect the removal of deprecated client events, improving clarity for developers.
  • Bug Fixes
    • Minor version updates across various packages, indicating bug fixes and improvements.
  • Documentation
    • Updated analytics documentation to remove references to obsolete client events.
    • Simplified event signatures in the cvat-canvas documentation for better readability.
  • Chores
    • Cleaned up logging functionality across multiple components for a more streamlined experience.

Copy link
Contributor

coderabbitai bot commented Aug 14, 2024

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Walkthrough

This update streamlines the client event system by removing several outdated events, including restore:job, and deprecating others such as upload:annotations and change:attribute. Documentation and logging functionalities have been simplified across various components. Additionally, version numbers for multiple packages have been incremented, indicating bug fixes and minor improvements.

Changes

Files Change Summary
changelog.d/20240814_151947_boris_update_events.md, cvat-core/src/enums.ts Removed client events: restore:job, upload:annotations, lock:object, change:attribute, change:label.
cvat-canvas/README.md, cvat-canvas/src/typescript/canvasView.ts Simplified event signatures by removing return type annotations and detail properties.
cvat-canvas/package.json, cvat-core/package.json, cvat-ui/package.json Version updates: cvat-canvas from 2.20.8 to 2.20.9, cvat-core from 15.1.1 to 15.1.2, cvat-ui from 1.64.5 to 1.64.6.
cvat-core/src/logger.ts Simplified IgnoredRules type by removing EventScope.changeAttribute and related logging.
cvat-ui/src/actions/annotation-actions.ts Removed jobInfoGenerator function affecting annotation statistics.
cvat-ui/src/components/annotation-page/.../attribute-annotation-sidebar.tsx Removed jobInstance property from state and associated logging.
cvat-ui/src/components/annotation-page/canvas/views/canvas2d/canvas-wrapper.tsx Simplified logging by removing payload objects from drawObject and pasteObject events.
cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/... Modifications to ItemButtonsWrapper class; no specific public entity changes noted.
cvat/apps/events/serializers.py Adjusted ALLOWED_SCOPES in ClientEventsSerializer reflecting event scope removals.
site/content/en/docs/administration/advanced/analytics.md Updated documentation; removed references to deprecated client events.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant Server
    participant UI

    Client->>Server: Request to perform action (e.g., upload annotations)
    alt Event Supported
        Server->>Client: Acknowledge event
    else Event Deprecated
        Server->>Client: Return deprecation notice
    end

    Client->>UI: Update UI based on server response
Loading

🐰 In the meadow where bunnies hop,
We celebrate changes, let our hearts pop!
Events are trimmed, like grass in spring,
Simplified logs make our joy take wing.
With each little tweak, our code does shine,
Here’s to the updates, so bright and divine! 🌼✨


Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

Share
Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai generate interesting stats about this repository and render them as a table.
    • @coderabbitai show all the console.log statements in this repository.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (invoked as PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Additionally, you can add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Outside diff range, codebase verification and nitpick comments (4)
cvat-canvas/README.md (1)

75-77: Clarify expected outputs for canvas.dragshape and canvas.resizeshape.

The removal of return type annotations for these events might lead to ambiguity. Consider providing a brief description of the expected outputs to aid developers in understanding these events.

-    - canvas.dragshape
+    - canvas.dragshape // Expected output: { id: number } (if applicable)
-    - canvas.resizeshape
+    - canvas.resizeshape // Expected output: { id: number } (if applicable)
cvat-ui/src/components/annotation-page/attribute-annotation-workspace/attribute-annotation-sidebar/attribute-annotation-sidebar.tsx (1)

2-2: Logging functionality related to jobInstance is still present. The jobInstance property is still used in various parts of the codebase, including logging actions. This suggests that the changes might not fully align with the new logging strategy or requirements.

  • cvat-ui/src/components/annotation-page/canvas/views/canvas2d/canvas-wrapper.tsx: Contains multiple instances of jobInstance.logger.log(...).
  • cvat-ui/src/actions/annotation-actions.ts: Contains instances of jobInstance.logger.log(...).

Please review these occurrences to ensure alignment with the new logging strategy.

Analysis chain

Verify changes to the logging mechanism.

The jobInstance property and related logging functionality have been removed. Ensure that this change aligns with the new logging strategy or requirements.

Also applies to: 122-122

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify the removal of logging functionality related to jobInstance.

# Test: Search for any remaining logging related to jobInstance in the codebase. Expect: No direct logging for these actions.
rg --type js 'logger\.log.*jobInstance'

Length of output: 41


Script:

#!/bin/bash
# Description: Search for any remaining references to jobInstance in the codebase.

# Test: Look for any occurrences of jobInstance to ensure all related functionality is removed.
rg 'jobInstance'

Length of output: 39883

cvat-ui/src/components/annotation-page/canvas/views/canvas2d/canvas-wrapper.tsx (1)

760-762: Ensure logging sufficiency for resizeObject.

The logging for resizeObject in the onCanvasShapeResized method does not include specific identifiers or additional context. This might result in insufficient logging for debugging or auditing purposes. Consider enhancing the log details to include relevant identifiers or context to ensure comprehensive logging.

  • Location: cvat-ui/src/components/annotation-page/canvas/views/canvas2d/canvas-wrapper.tsx, line 760
Analysis chain

Ensure logging sufficiency for resizeObject.

The logging call for resizeObject no longer includes specific identifiers. Verify that this meets the logging requirements and no essential information is omitted.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the logging for `resizeObject` is sufficient.

# Test: Search for logging calls related to `resizeObject` to ensure no critical information is lost.
rg --type tsx 'logger\.log\(EventScope\.resizeObject' -A 3

Length of output: 88


Script:

#!/bin/bash
# Description: Verify that the logging for `resizeObject` is sufficient.

# Define `tsx` as a recognized file type for ripgrep
rg --type-add 'tsx:*.{ts,tsx}' --type tsx 'logger\.log\(EventScope\.resizeObject' -A 3

Length of output: 521

cvat-ui/src/actions/annotation-actions.ts (1)

892-892: Enhance Job Loading Logging for Comprehensiveness

The current logging for job loading captures only the duration. Consider reviewing and potentially enhancing the logging to include additional information such as job ID, status, or any errors encountered during the loading process to ensure comprehensiveness.

  • cvat-ui/src/actions/annotation-actions.ts: Line with await job.logger.log(EventScope.loadJob, { duration: Date.now() - start });
Analysis chain

Ensure comprehensive logging for job loading.

The logging for job loading now focuses on duration. Verify that this meets the logging requirements and no essential information is omitted.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the logging for job loading is comprehensive.

# Test: Search for logging calls related to job loading to ensure no critical information is lost.
rg --type ts 'logger\.log\(EventScope\.loadJob' -A 3

Length of output: 375


Script:

#!/bin/bash
# Search for all logging statements in the annotation-actions.ts file to check for additional job loading logs
rg --type ts 'logger\.log' cvat-ui/src/actions/annotation-actions.ts -A 3

Length of output: 1620

Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

Commits

Files that changed from the base of the PR and between 8d0095f and 6f30485.

Files selected for processing (20)
  • changelog.d/20240814_151947_boris_update_events.md (1 hunks)
  • changelog.d/20240814_153835_boris_update_events.md (1 hunks)
  • cvat-canvas/README.md (1 hunks)
  • cvat-canvas/package.json (1 hunks)
  • cvat-canvas/src/typescript/canvasView.ts (2 hunks)
  • cvat-core/package.json (1 hunks)
  • cvat-core/src/enums.ts (2 hunks)
  • cvat-core/src/logger.ts (2 hunks)
  • cvat-ui/package.json (1 hunks)
  • cvat-ui/src/actions/annotation-actions.ts (4 hunks)
  • cvat-ui/src/actions/boundaries-actions.ts (2 hunks)
  • cvat-ui/src/actions/import-actions.ts (2 hunks)
  • cvat-ui/src/components/annotation-page/attribute-annotation-workspace/attribute-annotation-sidebar/attribute-annotation-sidebar.tsx (7 hunks)
  • cvat-ui/src/components/annotation-page/canvas/views/canvas2d/canvas-wrapper.tsx (3 hunks)
  • cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/object-buttons.tsx (2 hunks)
  • cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/object-item-details.tsx (3 hunks)
  • cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/object-item.tsx (2 hunks)
  • cvat-ui/src/utils/event-recorder.ts (2 hunks)
  • cvat/apps/events/serializers.py (1 hunks)
  • site/content/en/docs/administration/advanced/analytics.md (1 hunks)
Files skipped from review due to trivial changes (7)
  • changelog.d/20240814_151947_boris_update_events.md
  • changelog.d/20240814_153835_boris_update_events.md
  • cvat-canvas/package.json
  • cvat-core/package.json
  • cvat-ui/package.json
  • cvat-ui/src/actions/boundaries-actions.ts
  • cvat-ui/src/actions/import-actions.ts
Additional context used
LanguageTool
site/content/en/docs/administration/advanced/analytics.md

[uncategorized] ~136-~136: Loose punctuation mark.
Context: ...ent events: - load:cvat - load:job, save:job - send:exception - `draw...

(UNLIKELY_OPENING_PUNCTUATION)


[uncategorized] ~140-~140: Loose punctuation mark.
Context: ...ob -send:exception -draw:object, paste:object, copy:object, propaga...

(UNLIKELY_OPENING_PUNCTUATION)

Additional comments not posted (14)
cvat-ui/src/utils/event-recorder.ts (1)

32-37: Enhance logging with additional environment details.

The added properties (screenWidth, screenHeight, language, hardwareConcurrency, deviceMemory, jsHeapSizeLimit) provide valuable context for debugging and analytics. The use of lodash for safe property access is a good practice to prevent runtime errors.

cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/object-item-details.tsx (2)

11-11: Use ThunkDispatch for improved type safety.

Switching to ThunkDispatch enhances type safety and clarity when dispatching asynchronous actions. This aligns with best practices for using Redux Thunk.


80-80: Consider implications of removing logging in changeAttribute.

The removal of the logging functionality in changeAttribute may simplify the component but could impact traceability of attribute changes. Ensure that this change aligns with the overall logging strategy.

cvat/apps/events/serializers.py (1)

32-36: Streamline allowed event scopes.

The modification of ALLOWED_SCOPES reflects a shift in focus or functionality. Ensure that the removal of these scopes aligns with the application's requirements and does not impact necessary functionality. Consider updating documentation to reflect these changes.

cvat-core/src/enums.ts (1)

Line range hint 74-74:
Verify the impact of removed events on the codebase.

The removal of constants like restoreJob, uploadAnnotations, sendTaskInfo, lockObject, changeAttribute, and changeLabel may affect other parts of the codebase that rely on these events. Ensure that all references to these events have been updated or removed.

Verification successful

Removed EventScope constants are not used elsewhere in the codebase.

The removed constants restoreJob, uploadAnnotations, sendTaskInfo, lockObject, changeAttribute, and changeLabel from the EventScope enum are not referenced in any .ts files. This indicates that their removal does not affect other parts of the codebase.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that removed EventScope constants are not used elsewhere in the codebase.

# Test: Search for the removed constants. Expect: No occurrences.
rg --type typescript $'EventScope.restoreJob|EventScope.uploadAnnotations|EventScope.sendTaskInfo|EventScope.lockObject|EventScope.changeAttribute|EventScope.changeLabel'

Length of output: 206


Script:

#!/bin/bash
# Description: Verify that removed EventScope constants are not used elsewhere in the codebase.

# Test: Search for the removed constants in .ts files. Expect: No occurrences.
rg 'EventScope.restoreJob|EventScope.uploadAnnotations|EventScope.sendTaskInfo|EventScope.lockObject|EventScope.changeAttribute|EventScope.changeLabel' --glob '*.ts'

Length of output: 167

cvat-core/src/logger.ts (1)

32-32: Verify the impact of removing EventScope.changeAttribute from IgnoredRules.

Ensure that the removal of EventScope.changeAttribute from IgnoredRules does not affect any existing logging functionality that might rely on this event being ignored.

Verification successful

Removal of EventScope.changeAttribute is safe and has no impact.

The search confirmed that EventScope.changeAttribute is not used elsewhere in the codebase. Therefore, its removal from IgnoredRules does not affect any existing logging functionality.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the removal of `EventScope.changeAttribute` does not affect logging functionality.

# Test: Search for the usage of `EventScope.changeAttribute` in the codebase. Expect: No occurrences.
rg --type typescript $'EventScope.changeAttribute'

Length of output: 84


Script:

#!/bin/bash
# Description: Verify that the removal of `EventScope.changeAttribute` does not affect logging functionality.

# Test: Search for the usage of `EventScope.changeAttribute` in the codebase. Expect: No occurrences.
rg 'EventScope.changeAttribute'

Length of output: 31

cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/object-buttons.tsx (1)

116-118: Verify changes to the logging mechanism.

The logging functionality for lock and unlock actions has been removed. Ensure that this change aligns with the new logging strategy or requirements.

Also applies to: 124-126

cvat-ui/src/containers/annotation-page/standard-workspace/objects-side-bar/object-item.tsx (1)

323-325: Verify changes to the logging mechanism.

The logging functionality for label changes has been removed. Ensure that this change aligns with the new logging strategy or requirements.

site/content/en/docs/administration/advanced/analytics.md (1)

136-136: Remove redundant punctuation.

The bullet points for client events should not start with a hyphen when listed in a markdown format.

- - `load:cvat`
+ `load:cvat`

Likely invalid or redundant comment.

Tools
LanguageTool

[uncategorized] ~136-~136: Loose punctuation mark.
Context: ...ent events: - load:cvat - load:job, save:job - send:exception - `draw...

(UNLIKELY_OPENING_PUNCTUATION)

cvat-ui/src/components/annotation-page/canvas/views/canvas2d/canvas-wrapper.tsx (2)

755-757: Ensure logging sufficiency for dragObject.

The logging call for dragObject no longer includes specific identifiers. Verify that this meets the logging requirements and no essential information is omitted.


667-669: Simplify logging while ensuring it meets requirements.

The logging for drawObject and pasteObject events has been simplified by removing detailed properties. Ensure that this change aligns with the application's logging requirements and that no critical information is lost.

cvat-ui/src/actions/annotation-actions.ts (1)

813-813: Simplify logging for rotateImage.

The logging for rotateImage has been simplified by removing the angle parameter. Ensure that this change aligns with the application's logging requirements and that no critical information is lost.

Verification successful

Simplified logging for rotateImage is acceptable.

The logging simplification for rotateImage does not appear to affect other parts of the codebase, as there are no additional references to EventScope.rotateImage. Thus, no critical information is lost by removing the angle parameter.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify that the simplified logging for `rotateImage` is sufficient.

# Test: Search for logging calls related to `rotateImage` to ensure no critical information is lost.
rg --type ts 'logger\.log\(EventScope\.rotateImage' -A 3

Length of output: 334


Script:

#!/bin/bash
# Search for all references to EventScope.rotateImage to understand its usage and significance.
rg 'EventScope\.rotateImage' -A 3

Length of output: 311

cvat-canvas/src/typescript/canvasView.ts (2)

Line range hint 1456-1456:
Simplification acknowledged: Verify event handler updates.

The removal of the detail property from the canvas.resizeshape event simplifies the event structure. Ensure that any event handlers relying on this detail are updated accordingly.

Verification successful

Event handlers updated: No reliance on removed detail property found.

The search did not reveal any event handlers for canvas.resizeshape that rely on the removed detail property, indicating that the handlers have been updated or do not require this property. This supports the simplification of the event structure.

Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify if the event handlers for `canvas.resizeshape` are updated to not rely on the removed `detail` property.

# Test: Search for event handlers for `canvas.resizeshape`. Expect: No usage of the removed `detail` property.
rg --type javascript --type typescript -A 5 $'canvas.resizeshape'

Length of output: 99


Script:

#!/bin/bash
# Description: Verify if the event handlers for `canvas.resizeshape` are updated to not rely on the removed `detail` property.

# Corrected Test: Search for event handlers for `canvas.resizeshape`. Expect: No usage of the removed `detail` property.
rg --glob '*.js' --glob '*.ts' -A 5 $'canvas.resizeshape'

Length of output: 549


Line range hint 1104-1104:
Simplification acknowledged: Verify event handler updates.

The removal of the detail property from the canvas.dragshape event simplifies the event structure. Ensure that any event handlers relying on this detail are updated accordingly.

- `send:task_info`

- `draw:object`, `paste:object`, `copy:object`, `propagate:object`, `drag:object`, `resize:object`, `delete:object`, `lock:object`, `merge:objects`, `split:objects`, `group:objects`, `slice:object`,
- `draw:object`, `paste:object`, `copy:object`, `propagate:object`, `drag:object`, `resize:object`, `delete:object`, `merge:objects`, `split:objects`, `group:objects`, `slice:object`,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove redundant punctuation.

The bullet points for client events should not start with a hyphen when listed in a markdown format.

- - `draw:object`, `paste:object`, `copy:object`, `propagate:object`, `drag:object`, `resize:object`, `delete:object`, `merge:objects`, `split:objects`, `group:objects`, `slice:object`,
+ `draw:object`, `paste:object`, `copy:object`, `propagate:object`, `drag:object`, `resize:object`, `delete:object`, `merge:objects`, `split:objects`, `group:objects`, `slice:object`,
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- `draw:object`, `paste:object`, `copy:object`, `propagate:object`, `drag:object`, `resize:object`, `delete:object`, `merge:objects`, `split:objects`, `group:objects`, `slice:object`,
`draw:object`, `paste:object`, `copy:object`, `propagate:object`, `drag:object`, `resize:object`, `delete:object`, `merge:objects`, `split:objects`, `group:objects`, `slice:object`,
Tools
LanguageTool

[uncategorized] ~140-~140: Loose punctuation mark.
Context: ...ob -send:exception -draw:object, paste:object, copy:object, propaga...

(UNLIKELY_OPENING_PUNCTUATION)

@codecov-commenter
Copy link

codecov-commenter commented Aug 15, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 83.33%. Comparing base (a69e122) to head (b7d7420).

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #8304   +/-   ##
========================================
  Coverage    83.33%   83.33%           
========================================
  Files          391      391           
  Lines        41566    41563    -3     
  Branches      3839     3838    -1     
========================================
- Hits         34639    34637    -2     
+ Misses        6927     6926    -1     
Components Coverage Δ
cvat-ui 79.55% <100.00%> (-0.01%) ⬇️
cvat-server 86.69% <ø> (+<0.01%) ⬆️

Copy link

@bsekachev bsekachev merged commit 0c5545b into develop Aug 19, 2024
33 checks passed
@bsekachev bsekachev deleted the bs/update_events branch August 20, 2024 07:20
@cvat-bot cvat-bot bot mentioned this pull request Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Total duration of zoom, change attributes and resize events
2 participants