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: UsagePulse initialisation flow #38555

Merged
merged 3 commits into from
Jan 9, 2025
Merged

Conversation

hetunandu
Copy link
Member

@hetunandu hetunandu commented Jan 9, 2025

Description

Ensures we wait for correct events before we send the usage pulse.

Fixes https://github.com/appsmithorg/cloud-services/issues/1839

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/12687921698
Commit: 63be981
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Thu, 09 Jan 2025 11:27:39 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

Release Notes

  • New Features

    • Enhanced analytics tracking with new segment initialization states
    • Improved user tracking and feature flag management
  • Technical Improvements

    • Added more granular state management for analytics
    • Refined user tracking initialization process
  • Performance

    • Optimized asynchronous effects for user and feature tracking

@hetunandu hetunandu requested a review from ayushpahwa as a code owner January 9, 2025 10:06
@hetunandu hetunandu requested a review from brayn003 January 9, 2025 10:06
Copy link
Contributor

coderabbitai bot commented Jan 9, 2025

Warning

Rate limit exceeded

@hetunandu has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 9 minutes and 25 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 886335a and 63be981.

📒 Files selected for processing (1)
  • app/client/src/ce/sagas/userSagas.tsx (4 hunks)

Walkthrough

This pull request introduces a comprehensive enhancement to the application's analytics state management. The changes span multiple files, focusing on adding new action creators, Redux constants, reducers, and selectors related to segment initialization. The modifications enable more granular tracking of analytics events, specifically around the initialization state of segment tracking, with improved error handling and state management.

Changes

File Change Summary
app/client/src/actions/analyticsActions.ts Added two new action creators: segmentInitSuccess() and segmentInitUncertain()
app/client/src/ce/constants/ReduxActionConstants.tsx Introduced two new action types: SEGMENT_INITIALIZED and SEGMENT_INIT_UNCERTAIN
app/client/src/ce/reducers/index.tsx Added AnalyticsReduxState to AppState interface under ui property
app/client/src/ce/reducers/uiReducers/index.tsx Integrated analyticsReducer into uiReducerObject
app/client/src/ce/sagas/userSagas.tsx Enhanced user tracking logic with new initialization and waiting mechanisms
app/client/src/reducers/uiReducers/analyticsReducer.ts Created new reducer for managing analytics state with segment initialization tracking
app/client/src/selectors/analyticsSelectors.ts Added getSegmentState selector function

Sequence Diagram

sequenceDiagram
    participant User
    participant App
    participant FeatureFlags
    participant SegmentTracker
    
    User->>App: Initiates Application
    App->>FeatureFlags: Fetch Feature Flags
    FeatureFlags-->>App: Feature Flags Loaded
    App->>SegmentTracker: Initialize Tracking
    alt Successful Initialization
        SegmentTracker-->>App: Segment Init Success
        App->>App: Dispatch segmentInitSuccess
    else Uncertain Initialization
        SegmentTracker-->>App: Segment Init Uncertain
        App->>App: Dispatch segmentInitUncertain
    end
Loading

Possibly related PRs

Suggested Labels

bug, enhancement, ok-to-test, high

Suggested Reviewers

  • albinAppsmith
  • sharat87

Poem

🔍 Tracking tales of data's dance,
Redux weaves its analytic trance
Segments whisper, actions sing
Of insights that new changes bring!
📊 Code evolves with graceful might 🚀

Finishing Touches

  • 📝 Generate Docstrings

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 generate docstrings to generate docstrings for this PR. (Beta)
  • @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
Copy link
Member Author

/build-deploy-preview

@github-actions github-actions bot added the Bug Something isn't working label Jan 9, 2025
Copy link

github-actions bot commented Jan 9, 2025

Deploying Your Preview: https://github.com/appsmithorg/appsmith/actions/runs/12687719287.
Workflow: On demand build Docker image and deploy preview.
skip-tests: . env: .
PR: 38555.
recreate: .

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
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between c302b64 and 886335a.

📒 Files selected for processing (7)
  • app/client/src/actions/analyticsActions.ts (1 hunks)
  • app/client/src/ce/constants/ReduxActionConstants.tsx (1 hunks)
  • app/client/src/ce/reducers/index.tsx (2 hunks)
  • app/client/src/ce/reducers/uiReducers/index.tsx (2 hunks)
  • app/client/src/ce/sagas/userSagas.tsx (4 hunks)
  • app/client/src/reducers/uiReducers/analyticsReducer.ts (1 hunks)
  • app/client/src/selectors/analyticsSelectors.ts (1 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (5)
  • GitHub Check: client-check-cyclic-deps / check-cyclic-dependencies
  • GitHub Check: client-lint / client-lint
  • GitHub Check: client-unit-tests / client-unit-tests
  • GitHub Check: client-prettier / prettier-check
  • GitHub Check: client-build / client-build
🔇 Additional comments (9)
app/client/src/selectors/analyticsSelectors.ts (1)

1-4: LGTM

The selector function is correctly implemented.

app/client/src/actions/analyticsActions.ts (1)

1-8: LGTM

The action creators are properly defined.

app/client/src/reducers/uiReducers/analyticsReducer.ts (2)

4-13: LGTM! Clean type definitions and state structure.

The type definitions and initial state setup follow Redux best practices with proper TypeScript types.


15-34: LGTM! Well-structured reducer handlers.

The handlers correctly maintain immutability and properly update the segment state.

app/client/src/ce/reducers/uiReducers/index.tsx (2)

42-42: LGTM! Clean import statement.

The analytics reducer import is properly placed with other reducer imports.


52-52: LGTM! Proper reducer integration.

The analytics reducer is correctly added to the UI reducer object.

app/client/src/ce/reducers/index.tsx (2)

67-67: LGTM! Proper type import.

The AnalyticsReduxState type import is correctly placed.


98-98: LGTM! Clean state interface update.

The analytics state is properly typed in the AppState interface.

app/client/src/ce/constants/ReduxActionConstants.tsx (1)

1219-1220: LGTM! Clear action type definitions.

The segment initialization action types follow the established naming convention and are properly placed in the AnalyticsActionTypes object.

app/client/src/ce/sagas/userSagas.tsx Outdated Show resolved Hide resolved
Copy link

github-actions bot commented Jan 9, 2025

🔴🔴🔴 Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 2, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

@hetunandu hetunandu added ok-to-test Required label for CI IDE Infra Issues related to the IDE infrastructure like saving changes labels Jan 9, 2025
hetunandu and others added 2 commits January 9, 2025 15:47
Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
Copy link

github-actions bot commented Jan 9, 2025

Deploy-Preview-URL: https://ce-38555.dp.appsmith.com

Copy link

github-actions bot commented Jan 9, 2025

🔴🔴🔴 Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 2, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

1 similar comment
Copy link

github-actions bot commented Jan 9, 2025

🔴🔴🔴 Cyclic Dependency Check:

This PR has increased the number of cyclic dependencies by 2, when compared with the release branch.

Refer this document to identify the cyclic dependencies introduced by this PR.

@RakshaKShetty
Copy link

RakshaKShetty commented Jan 9, 2025

@hetunandu i am able to see the usage pulse when i am try to access it anonymously but for the logged in user i am unable to see the usage pulse in deployed mode

@RakshaKShetty
Copy link

This looks good we can go ahead

Copy link
Contributor

@brayn003 brayn003 left a comment

Choose a reason for hiding this comment

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

nicely done

@hetunandu
Copy link
Member Author

We are going to fix the increase of cycle dependencies in another PR #38559

@hetunandu hetunandu merged commit 388fd81 into release Jan 9, 2025
40 of 43 checks passed
@hetunandu hetunandu deleted the fix/usage-pulse-anonymous-user branch January 9, 2025 13:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working IDE Infra Issues related to the IDE infrastructure like saving changes ok-to-test Required label for CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants