Skip to content
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

chore: Added new analytics parameter for git auto commit #29538

Merged
merged 1 commit into from
Dec 13, 2023

Conversation

nayan-rafiq
Copy link
Contributor

@nayan-rafiq nayan-rafiq commented Dec 12, 2023

Description

A refactor in the analytics events for Git. Also adds isSystemGenerated=false for regular commits.

PR fixes following issue(s)

Fixes #26769

Media

A video or a GIF is preferred. when using Loom, don’t embed because it looks like it’s a GIF. instead, just link to the video

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Chore (housekeeping or task changes that don't impact user perception)
  • This change requires a documentation update

Testing

How Has This Been Tested?

Please describe the tests that you ran to verify your changes. Also list any relevant details for your test configuration.
Delete anything that is not relevant

  • Manual
  • JUnit
  • Jest
  • Cypress

Test Plan

Add Testsmith test cases links that relate to this PR

Issues raised during DP testing

Link issues raised during DP testing for better visiblity and tracking (copy link from comments dropped on this PR)

Checklist:

Dev activity

  • My code follows the style guidelines of this project
  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • PR is being merged under a feature flag

QA activity:

  • Speedbreak features have been covered
  • Test plan covers all impacted features and areas of interest
  • Test plan has been peer reviewed by project stakeholders and other QA members
  • Manually tested functionality on DP
  • We had an implementation alignment call with stakeholders post QA Round 2
  • Cypress test cases have been added and approved by SDET/manual QA
  • Added Test Plan Approved label after Cypress tests were reviewed
  • Added Test Plan Approved label after JUnit tests were reviewed

Summary by CodeRabbit

  • New Features

    • Enhanced Git integration with the inclusion of repository URLs in auto-commit events.
    • Improved analytics tracking by utilizing repository URLs for version information.
  • Refactor

    • Standardized event naming by replacing string literals with enum constants in Git-related operations.
  • Bug Fixes

    • Fixed an issue in the analytics service by correcting the method signature for user ID hashing.
  • Documentation

    • Updated internal documentation to reflect changes in analytics and Git service logic.
  • Tests

    • Expanded test coverage to account for new repository URL handling in auto-commit events.

@nayan-rafiq nayan-rafiq self-assigned this Dec 12, 2023
@nayan-rafiq nayan-rafiq changed the title added new analytics parameter for git auto commit chore: Added new analytics parameter for git auto commit Dec 12, 2023
@github-actions github-actions bot added Git Platform Pod Issues related to the git & the app platform Git Product Issues related to version control product labels Dec 12, 2023
Copy link
Contributor

coderabbitai bot commented Dec 12, 2023

Walkthrough

Walkthrough

The recent updates to the codebase involve enhancements to Git-related functionalities, including the tracking of repository URLs in auto-commit events and analytics. Changes also include the introduction of an enum for analytics events and a modification in the user ID hashing logic for analytics. These alterations aim to refine the application's Git integration and analytics reporting, ensuring more precise data capture and streamlined operations.

Changes

File Path Change Summary
.../events/AutoCommitEvent.java Added repoUrl field to AutoCommitEvent class.
.../helpers/ce/GitAutoCommitHelperImpl.java Set repository URL in autoCommitEvent.
.../services/ce/AnalyticsServiceCEImpl.java Altered shouldHashUserId method signature to include isCloudHosting parameter.
.../services/ce/GitServiceCEImpl.java Replaced string event names with AnalyticsEvents enum constants; modified various method signatures.
.../solutions/ce/AutoCommitEventHandlerCEImpl.java Replaced projectProperties.getVersion() with autoCommitEvent.getRepoUrl() in triggerAnalyticsEvent.
.../solutions/AutoCommitEventHandlerImplTest.java Added setRepoUrl call in createEvent method for tests.

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 X ?


Tips

Chat with CodeRabbit Bot (@coderabbitai)

  • If you reply to a review comment from CodeRabbit, the bot will automatically respond.
  • To engage with CodeRabbit bot directly around the specific lines of code in the PR, mention @coderabbitai in your review comment
  • Note: Review comments are made on code diffs or files, not on the PR overview.
  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.

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 a review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai help to get help.

Note: For conversation with the bot, please use the review comments on code diffs or files.

CodeRabbit Configration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • The JSON schema for the configuration file is available here.
  • 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/coderabbit-overrides.v2.json

@github-actions github-actions bot added the skip-changelog Adding this label to a PR prevents it from being listed in the changelog label Dec 12, 2023
@nayan-rafiq
Copy link
Contributor Author

/ok-to-test

Copy link

Tests running at: https://github.com/appsmithorg/appsmith/actions/runs/7177896482.
Workflow: Appsmith External Integration Test Workflow.
Tags: ``.

Comment on lines 16 to +19
private String repoName;
private String authorName;
private String authorEmail;
private String repoUrl;
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 NOTE
Codebase verification is a beta feature.

The review of the codebase has revealed the following:

  • The repoUrl field is accessed and used in AutoCommitEventHandlerCEImpl.java, which aligns with the intended changes.
  • The test files AutoCommitEventHandlerImplTest.java and GitAutoCommitHelperImplTest.java instantiate AutoCommitEvent without setting the repoUrl. This may need to be updated to reflect the new field and ensure that tests cover the new functionality.
  • The main file GitAutoCommitHelperImpl.java also instantiates AutoCommitEvent without setting the repoUrl, which is likely an oversight and should be corrected.

Based on these findings, the following actions are recommended:

  • Verify and update the test files to include the repoUrl field in their instantiation of AutoCommitEvent.

  • Update the instantiation of AutoCommitEvent in GitAutoCommitHelperImpl.java to set the repoUrl field.

  • The test files AutoCommitEventHandlerImplTest.java and GitAutoCommitHelperImplTest.java should be verified and potentially updated to set the repoUrl when instantiating AutoCommitEvent.

  • The GitAutoCommitHelperImpl.java file should be updated to set the repoUrl field when instantiating AutoCommitEvent.

Analysis chain

The addition of the repoUrl field to the AutoCommitEvent class is consistent with the PR objectives and the AI-generated summaries. Ensure that all parts of the codebase that instantiate or use the AutoCommitEvent class are updated to handle the new repoUrl field appropriately.



Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Search for instances where `AutoCommitEvent` is instantiated to ensure `repoUrl` is being set.
rg 'new AutoCommitEvent' --files-with-matches
# Search for instances where `AutoCommitEvent` is used to ensure `repoUrl` is being handled.
rg 'AutoCommitEvent' --files-with-matches

Length of output: 1218



Script:

#!/bin/bash
# Check the instantiation of `AutoCommitEvent` in the test files to ensure `repoUrl` is being set.
rg 'new AutoCommitEvent' app/server/appsmith-server/src/test/java/com/appsmith/server/solutions/AutoCommitEventHandlerImplTest.java
rg 'new AutoCommitEvent' app/server/appsmith-server/src/test/java/com/appsmith/server/helpers/ce/GitAutoCommitHelperImplTest.java

# Check the instantiation of `AutoCommitEvent` in the main file to ensure `repoUrl` is being set.
rg 'new AutoCommitEvent' app/server/appsmith-server/src/main/java/com/appsmith/server/helpers/ce/GitAutoCommitHelperImpl.java

# Check the usage of `AutoCommitEvent` in the main files to ensure `repoUrl` is being handled.
rg 'AutoCommitEvent' app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AutoCommitEventHandlerCEImpl.java
rg 'AutoCommitEvent' app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AutoCommitEventHandlerCE.java
rg 'AutoCommitEvent' app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/AutoCommitEventHandler.java
rg 'AutoCommitEvent' app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/AutoCommitEventHandlerImpl.java

Length of output: 2737



Script:

#!/bin/bash
# Check for the access or modification of the `repoUrl` field in the files where `AutoCommitEvent` is used.
rg 'repoUrl' app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AutoCommitEventHandlerCEImpl.java
rg 'repoUrl' app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/ce/AutoCommitEventHandlerCE.java
rg 'repoUrl' app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/AutoCommitEventHandler.java
rg 'repoUrl' app/server/appsmith-server/src/main/java/com/appsmith/server/solutions/AutoCommitEventHandlerImpl.java

Length of output: 538

Copy link
Member

@AnaghHegde AnaghHegde left a comment

Choose a reason for hiding this comment

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

LGTM, one follow up question on why we removed the .getEventName() for the analytics?

Copy link

Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/7177896482.
Commit: ``.
Cypress dashboard url: Click here!
All cypress tests have passed 🎉🎉🎉

@nayan-rafiq
Copy link
Contributor Author

LGTM, one follow up question on why we removed the .getEventName() for the analytics?

@AnaghHegde Primary reason was to add some extra parameters for specific git events. In this case, we need to add a new parameter isSystemGenerated=false for commit events. One way was to do a string comparison inside the addAnalyticsForGitOperation method i.e. eventName.equals(AnalyticsEvents.GIT_COMMIT.getEventName()) . As we're always sending events from the enum, it would be better to accept the event enum instead of string inside the method. It'll ensure that we're not accidentally calling the addAnalyticsForGitOperation method with a arbitrary string as event name. Also, enum comparison is faster than string comparison.

@Aishwarya-U-R Aishwarya-U-R merged commit d83f4e2 into release Dec 13, 2023
25 checks passed
@Aishwarya-U-R Aishwarya-U-R deleted the chore/update-auto-commit-analytics-params branch December 13, 2023 17:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Git Platform Pod Issues related to the git & the app platform Git Product Issues related to version control product skip-changelog Adding this label to a PR prevents it from being listed in the changelog
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate RTS Migration end point with AutoCommit flow
3 participants