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

feat: Added analytics for pulse failure #37781

Merged
merged 1 commit into from
Nov 28, 2024

Conversation

albinAppsmith
Copy link
Collaborator

@albinAppsmith albinAppsmith commented Nov 27, 2024

Description

Tip

Add a TL;DR when the description is longer than 500 words or extremely technical (helps the content, marketing, and DevRel team).

Please also include relevant motivation and context. List any dependencies that are required for this change. Add links to Notion, Figma or any other documents that might be relevant to the PR.

Fixes https://github.com/appsmithorg/appsmith-ee/issues/5606

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/12049087739
Commit: 18929d4
Cypress dashboard.
Tags: @tag.Sanity
Spec:


Wed, 27 Nov 2024 11:51:54 UTC

Communication

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

  • Yes
  • No

Summary by CodeRabbit

  • New Features

    • Enhanced analytics tracking with new event types: "CANVAS_HOVER" and "MALFORMED_USAGE_PULSE".
    • Improved error reporting in the fetchWithRetry function, capturing additional context during failures.
  • Bug Fixes

    • Added logging for better monitoring of malformed usage scenarios.

Copy link
Contributor

coderabbitai bot commented Nov 27, 2024

Walkthrough

The changes in this pull request involve the addition of new string literals to the EventLocation and EventName types in analyticsUtilTypes.ts, specifically "CANVAS_HOVER" and "MALFORMED_USAGE_PULSE". Additionally, in utils.ts, new variables for instanceId and anonymousUserId are introduced within the fetchWithRetry function, enhancing error handling by logging these identifiers when retries are exhausted. The overall structure and functionality of the existing code remain unchanged.

Changes

File Path Change Summary
app/client/src/ce/utils/analyticsUtilTypes.ts Added "CANVAS_HOVER" and "MALFORMED_USAGE_PULSE" to EventLocation and EventName types.
app/client/src/usagePulse/utils.ts Introduced instanceId and anonymousUserId variables in fetchWithRetry, modified error logging.

Possibly related PRs

Suggested labels

Enhancement, Bug, ok-to-test

Suggested reviewers

  • dvj1988
  • nidhi-nair
  • rajatagrawal

🎉 In the code's dance, new strings take flight,
Events to track, in the day and the night.
With identifiers added, we log with delight,
Error handling's sharper, our future looks bright! 🌟
Cheers to the changes, let the analytics flow,
In the world of code, watch our insights grow! 📈


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.

@github-actions github-actions bot added the Enhancement New feature or request label Nov 27, 2024
@albinAppsmith albinAppsmith added the ok-to-test Required label for CI label Nov 27, 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: 0

🧹 Outside diff range and nitpick comments (2)
app/client/src/usagePulse/utils.ts (2)

43-48: Consider including error details in analytics

While the analytics capture identifies the failure occurrence, adding error details would help with debugging.

 } else {
   // add analytics for failed usage pulse
   AnalyticsUtil.logEvent("MALFORMED_USAGE_PULSE", {
     anonymousUserId,
     instanceId,
+    error: res.statusText,
+    status: res.status
   });
 }

Line range hint 12-17: Technical Debt: Consider addressing TODOs and type safety

  1. The function could return a Promise for better control flow
  2. The url parameter should have a specific type instead of any

Would you like me to propose a typed implementation that returns a Promise?

📜 Review details

Configuration used: .coderabbit.yaml
Review profile: CHILL

📥 Commits

Reviewing files that changed from the base of the PR and between 62724e9 and 18929d4.

📒 Files selected for processing (2)
  • app/client/src/ce/utils/analyticsUtilTypes.ts (1 hunks)
  • app/client/src/usagePulse/utils.ts (3 hunks)
🔇 Additional comments (4)
app/client/src/usagePulse/utils.ts (2)

9-9: LGTM: Import addition is clean and well-placed


20-22: LGTM: Variable initialization is well-placed

The variables are correctly initialized before usage and maintain proper scope.

✅ Verification successful

Variables are correctly initialized and used

Based on the search results, the variables instanceId and anonymousUserId are properly initialized and used in the fetch request's payload. They are not duplicated in the existing payload structure and are essential for the analytics tracking functionality.

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Verify that these identifiers aren't already available in the payload
ast-grep --pattern 'payload: Record<string, unknown>' -A 10

Length of output: 61


Script:

#!/bin/bash
# Search for usage of instanceId and anonymousUserId in the file
rg -A 5 "instanceId|anonymousUserId" "app/client/src/usagePulse/utils.ts"

# Look for the function definition containing these variables
ast-grep --pattern 'function $_($$$) {
  $$$
  const instanceId = getInstanceId($$$)
  const anonymousUserId = AnalyticsUtil.getAnonymousId()
  $$$
}'

Length of output: 786


Script:

#!/bin/bash
# Check the payload construction to verify if these IDs are already included
ast-grep --pattern 'function getPayload($$$) {
  $$$
}'

Length of output: 57

app/client/src/ce/utils/analyticsUtilTypes.ts (2)

355-355: LGTM: MALFORMED_USAGE_PULSE event addition

The new analytics event aligns with the PR objective of tracking pulse failures.


354-354: Verify the relevance of CANVAS_HOVER event

The addition of "CANVAS_HOVER" event appears unrelated to the PR's objective of adding pulse failure analytics.

@albinAppsmith
Copy link
Collaborator Author

/build-deploy-preview skip-test=true

Copy link

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

Copy link

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

@albinAppsmith albinAppsmith merged commit 5e89edf into release Nov 28, 2024
50 checks passed
@albinAppsmith albinAppsmith deleted the padmin/pulse-failure-event branch November 28, 2024 06:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement New feature or request ok-to-test Required label for CI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants