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

fix: Bug where identifyUser not called in cloud #37329

Merged
merged 1 commit into from
Nov 12, 2024

Conversation

hetunandu
Copy link
Member

@hetunandu hetunandu commented Nov 12, 2024

Description

Fix the bug where return was called before the await for cloud conditions. This made the identifyUser case being skipped almost always

Missed in #37303

Automation

/ok-to-test tags="@tag.Sanity"

🔍 Cypress test results

Tip

🟢 🟢 🟢 All cypress tests have passed! 🎉 🎉 🎉
Workflow run: https://github.com/appsmithorg/appsmith/actions/runs/11791461362
Commit: 94bc989
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Tue, 12 Nov 2024 06:23:58 UTC

Communication

Should the DevRel and Marketing teams inform users about this change?

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced analytics initialization process to ensure completion before user identification.
  • Bug Fixes

    • Improved error handling for analytics setup with Sentry logging.
  • Documentation

    • Updated function signatures for clarity and consistency.

Copy link
Contributor

coderabbitai bot commented Nov 12, 2024

Walkthrough

The changes in this pull request focus on the initializeAnalyticsAndTrackers function within AppsmithUtils.tsx. The main modification involves changing the return statements of AnalyticsUtil.initializeSegment calls from promises to awaited calls, ensuring the function completes analytics initialization before proceeding. Additionally, user identification logic is now executed within the analytics setup process, rather than at the end of the function. Various function signatures in the same file have also been updated without changes to their parameters.

Changes

File Path Change Summary
app/client/src/utils/AppsmithUtils.tsx - Updated initializeAnalyticsAndTrackers to await analytics initialization.
- Moved user identification logic into the try block.
- Updated function signatures for multiple exported functions without parameter changes.

Possibly related PRs

  • chore: ce changes decoupled mixpannel chunk #36979: This PR modifies the runUserSideEffectsSaga function to improve analytics tracking initialization, which is closely related to the changes made in the initializeAnalyticsAndTrackers function in the main PR.
  • fix: Analytics identify user not called correctly #37303: This PR also focuses on the analytics functionality, specifically ensuring that the identifyUser function is called correctly during the initialization process, which aligns with the user identification logic introduced in the main PR.

Suggested labels

Bug, ok-to-test

Suggested reviewers

  • vsvamsi1
  • dvj1988

🎉 In the realm of code, a change takes flight,
Awaiting analytics, all set to ignite!
User identities now shine in the light,
With functions aligned, everything feels right.
So here's to the tweaks, both big and small,
In the world of Appsmith, we’re having a ball! 🎈


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>, please review it.
    • 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 gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @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 using 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.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

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.

@hetunandu hetunandu added the ok-to-test Required label for CI label Nov 12, 2024
@github-actions github-actions bot added the Bug Something isn't working label Nov 12, 2024
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

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between b24b66f and 94bc989.

📒 Files selected for processing (1)
  • app/client/src/utils/AppsmithUtils.tsx (1 hunks)
🔇 Additional comments (1)
app/client/src/utils/AppsmithUtils.tsx (1)

101-101: LGTM! Proper async/await handling added.

The addition of await ensures that segment initialization completes before proceeding, fixing the original issue.

Also applies to: 104-104

Comment on lines +107 to +113

if (
!currentUser.isAnonymous &&
currentUser.username !== ANONYMOUS_USERNAME
) {
await AnalyticsUtil.identifyUser(currentUser);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

💡 Codebase verification

User identification is duplicated in HelpButton.tsx

Found another instance of identifyUser being called in app/client/src/pages/Editor/HelpButton.tsx. This could lead to duplicate user identification.

  • app/client/src/utils/AppsmithUtils.tsx: Main identification call
  • app/client/src/pages/Editor/HelpButton.tsx: Duplicate identification call with sendAdditionalData flag
🔗 Analysis chain

LGTM! User identification logic properly placed.

The user identification is now correctly placed within the analytics setup try-catch block and executes after segment initialization.

Let's verify that this is the only place where user identification is called:

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Search for other occurrences of identifyUser to ensure we're not duplicating the call
rg "identifyUser" --type ts --type tsx

Length of output: 66


Script:

#!/bin/bash
# Search for identifyUser occurrences using ripgrep with correct file type options
rg "identifyUser" -t ts -t tsx -t js -t jsx

Length of output: 71


Script:

#!/bin/bash
# Search for identifyUser using basic ripgrep without file type filters
rg "identifyUser"

# Also search for the AnalyticsUtil class usage
rg "AnalyticsUtil"

Length of output: 78941

@hetunandu hetunandu enabled auto-merge (squash) November 12, 2024 06:06
@hetunandu hetunandu merged commit 12ab7e6 into release Nov 12, 2024
47 checks passed
@hetunandu hetunandu deleted the fix/appsmith-utils-fix branch November 12, 2024 06:24
github-actions bot pushed a commit to Zeral-Zhang/appsmith that referenced this pull request Nov 20, 2024
## Description

Fix the bug where return was called before the await for cloud
conditions. This made the identifyUser case being skipped almost always


Missed in appsmithorg#37303


## Automation

/ok-to-test tags="@tag.Sanity"

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!IMPORTANT]
> 🟣 🟣 🟣 Your tests are running.
> Tests running at:
<https://github.com/appsmithorg/appsmith/actions/runs/11791461362>
> Commit: 94bc989
> Workflow: `PR Automation test suite`
> Tags: `@tag.Sanity`
> Spec: ``
> <hr>Tue, 12 Nov 2024 05:44:55 UTC
<!-- end of auto-generated comment: Cypress test results  -->


## Communication
Should the DevRel and Marketing teams inform users about this change?
- [ ] Yes
- [ ] No


<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->

## Summary by CodeRabbit

- **New Features**
- Enhanced analytics initialization process to ensure completion before
user identification.
  
- **Bug Fixes**
	- Improved error handling for analytics setup with Sentry logging.

- **Documentation**
	- Updated function signatures for clarity and consistency.

<!-- end of auto-generated comment: release notes by coderabbit.ai -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working ok-to-test Required label for CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants