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: add support for group in appcues #1877

Merged
merged 3 commits into from
Oct 14, 2024

Conversation

anantjain45823
Copy link
Contributor

@anantjain45823 anantjain45823 commented Oct 10, 2024

PR Description

Adding support for group call in appcues.
Appcues Docs: https://docs.appcues.com/en_US/dev-installing-appcues/installation-overview-for-developers#identifying-groups-15
Please include a summary of the change along with the relevant motivation and context.

Linear task (optional)

Resolves INT-2682
Linear task link

Cross Browser Tests

Please confirm you have tested for the following browsers:

  • Chrome
  • Firefox
  • IE11

Sanity Suite

  • All sanity suite test cases pass locally

Security

  • The code changed/added as part of this pull request won't create any security issues with how the software is being used.

Summary by CodeRabbit

  • New Features

    • Introduced a new group method in the Appcues integration, enabling user grouping based on provided parameters.
  • Tests

    • Added a test suite for the group method to ensure functionality and correct parameter usage.

@anantjain45823 anantjain45823 self-assigned this Oct 10, 2024
@anantjain45823 anantjain45823 requested a review from a team as a code owner October 10, 2024 03:19
Copy link
Contributor

coderabbitai bot commented Oct 10, 2024

📝 Walkthrough
📝 Walkthrough

Walkthrough

The changes introduce a new group method to the Appcues class in the browser.js file, which allows for grouping users based on a rudderElement containing a groupId and traits. A corresponding test suite for this method is added in appcues.test.js, including a describe block and test cases that verify the method's functionality. The test mocks the Appcues SDK and checks that the group method is called with the correct parameters.

Changes

File Change Summary
packages/analytics-js-integrations/tests/integrations/Appcues/appcues.test.js Added a new test suite for the group method, including a describe block and two test cases for verification.
packages/analytics-js-integrations/src/integrations/Appcues/browser.js Introduced a new group method to the Appcues class, allowing user grouping based on rudderElement. Minor formatting changes in the identify method.

Sequence Diagram(s)

sequenceDiagram
    participant User
    participant Appcues
    participant SDK

    User->>Appcues: Call group(rudderElement)
    Appcues->>Appcues: Extract groupId and traits
    Appcues->>SDK: Call window.Appcues.group(groupId, traits)
Loading

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.

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: 0

🧹 Outside diff range and nitpick comments (2)
packages/analytics-js-integrations/src/integrations/Appcues/browser.js (1)

87-99: LGTM: Group method implementation looks good

The group method implementation aligns well with the PR objectives and follows the Appcues documentation. It correctly handles the case when groupId is not provided.

Consider adding error handling for the window.Appcues.group call. This can help catch and log any potential issues during the group identification process. Here's a suggested implementation:

 group(rudderElement) {
   const { groupId, traits } = rudderElement.message;
   if (!isDefinedAndNotNullAndNotEmpty(groupId)) {
     logger.error('group id is required');
     return;
   }
-  window.Appcues.group(
-    groupId, // unique, required
-    traits,
-  );
+  try {
+    window.Appcues.group(
+      groupId, // unique, required
+      traits,
+    );
+  } catch (error) {
+    logger.error('Error calling Appcues.group:', error);
+  }
 }

This change will ensure that any errors during the Appcues group call are caught and logged, improving the robustness of the integration.

packages/analytics-js-integrations/__tests__/integrations/Appcues/appcues.test.js (1)

165-186: LGTM: New test suite for Appcues group functionality added.

The new test suite for the group method is well-structured and covers the basic functionality. It correctly initializes the Appcues integration, mocks the SDK, and verifies the group method call with the expected parameters.

However, consider the following suggestions to enhance test coverage:

  1. Add a test case for when groupId is missing to ensure proper error handling.
  2. Include a test with nested traits to verify correct flattening of objects.
  3. Consider adding tests for potential error cases or edge scenarios.

Would you like me to provide example test cases for these scenarios?

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between cc239cf and 83d7c71.

📒 Files selected for processing (2)
  • packages/analytics-js-integrations/tests/integrations/Appcues/appcues.test.js (2 hunks)
  • packages/analytics-js-integrations/src/integrations/Appcues/browser.js (2 hunks)
🧰 Additional context used
🔇 Additional comments (2)
packages/analytics-js-integrations/src/integrations/Appcues/browser.js (1)

59-59: LGTM: Minor formatting improvement

The removal of the space before the condition check improves code consistency and adheres to common JavaScript formatting practices.

packages/analytics-js-integrations/__tests__/integrations/Appcues/appcues.test.js (1)

23-23: LGTM: Mock function for group added.

The addition of the group mock function to mockAppcuesSDK is appropriate and necessary for testing the new group functionality in the Appcues integration.

coderabbitai[bot]
coderabbitai bot previously approved these changes Oct 10, 2024
Copy link

codecov bot commented Oct 10, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 56.98%. Comparing base (97f028a) to head (820c916).
Report is 1 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #1877      +/-   ##
===========================================
+ Coverage    56.97%   56.98%   +0.01%     
===========================================
  Files          476      476              
  Lines        16244    16249       +5     
  Branches      3236     3249      +13     
===========================================
+ Hits          9255     9260       +5     
+ Misses        5771     5726      -45     
- Partials      1218     1263      +45     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link

github-actions bot commented Oct 10, 2024

size-limit report 📦

Name Size (Base) Size (Current) Size Limit Status
Plugins Module Federation Mapping - Legacy - CDN 332 B 332 B (0%) 512 B
Plugins - Legacy - CDN 15.48 KB 15.48 KB (0%) 16 KB
Plugins Module Federation Mapping - Modern - CDN 331 B 331 B (0%) 512 B
Plugins - Modern - CDN 7.2 KB 7.2 KB (0%) 7.5 KB
Common - No bundling 16.15 KB 16.15 KB (0%) 16.5 KB
Cookies Utils - Legacy - NPM (ESM) 1.54 KB 1.54 KB (0%) 2 KB
Cookies Utils - Legacy - NPM (CJS) 1.75 KB 1.75 KB (0%) 2 KB
Cookies Utils - Legacy - NPM (UMD) 1.53 KB 1.53 KB (0%) 2 KB
Cookies Utils - Modern - NPM (ESM) 1.17 KB 1.17 KB (0%) 1.5 KB
Cookies Utils - Modern - NPM (CJS) 1.4 KB 1.4 KB (0%) 1.5 KB
Cookies Utils - Modern - NPM (UMD) 1.16 KB 1.16 KB (0%) 1.5 KB
Load Snippet 757 B 757 B (0%) 1 KB
Core (v1.1) - NPM (ESM) 30.25 KB 30.25 KB (0%) 32 KB
Core (v1.1) - NPM (CJS) 30.48 KB 30.48 KB (0%) 32 KB
Core (v1.1) - NPM (UMD) 30.29 KB 30.29 KB (0%) 32 KB
Core (Content Script - v1.1) - NPM (ESM) 29.8 KB 29.8 KB (0%) 30.5 KB
Core (Content Script - v1.1) - NPM (CJS) 30.1 KB 30.1 KB (0%) 30.5 KB
Core (Content Script - v1.1) - NPM (UMD) 29.87 KB 29.87 KB (0%) 30 KB
Core - Legacy - CDN 47.35 KB 47.35 KB (0%) 48 KB
Core - Modern - CDN 24.24 KB 24.24 KB (0%) 24.5 KB
Core - Legacy - NPM (ESM) 47.22 KB 47.22 KB (0%) 48 KB
Core - Legacy - NPM (CJS) 47.47 KB 47.47 KB (0%) 48 KB
Core - Legacy - NPM (UMD) 47.23 KB 47.23 KB (0%) 48 KB
Core - Modern - NPM (ESM) 23.99 KB 23.99 KB (0%) 24.5 KB
Core - Modern - NPM (CJS) 24.19 KB 24.19 KB (0%) 24.5 KB
Core - Modern - NPM (UMD) 24.03 KB 24.03 KB (0%) 24.5 KB
Core (Bundled) - Legacy - NPM (ESM) 47.22 KB 47.22 KB (0%) 48 KB
Core (Bundled) - Legacy - NPM (CJS) 47.56 KB 47.56 KB (0%) 48 KB
Core (Bundled) - Legacy - NPM (UMD) 47.23 KB 47.23 KB (0%) 48 KB
Core (Bundled) - Modern - NPM (ESM) 38.63 KB 38.63 KB (0%) 39 KB
Core (Bundled) - Modern - NPM (CJS) 38.93 KB 38.93 KB (0%) 39.5 KB
Core (Bundled) - Modern - NPM (UMD) 38.68 KB 38.68 KB (0%) 39 KB
Core (Content Script) - Legacy - NPM (ESM) 46.76 KB 46.76 KB (0%) 48 KB
Core (Content Script) - Legacy - NPM (CJS) 47.01 KB 47.01 KB (0%) 47.5 KB
Core (Content Script) - Legacy - NPM (UMD) 46.73 KB 46.73 KB (0%) 47.5 KB
Core (Content Script) - Modern - NPM (ESM) 38.15 KB 38.15 KB (0%) 38.5 KB
Core (Content Script) - Modern - NPM (CJS) 38.37 KB 38.37 KB (0%) 38.5 KB
Core (Content Script) - Modern - NPM (UMD) 38.12 KB 38.12 KB (0%) 38.5 KB
Service Worker - Legacy - NPM (ESM) 30.61 KB 30.61 KB (0%) 31 KB
Service Worker - Legacy - NPM (CJS) 30.85 KB 30.85 KB (0%) 31 KB
Service Worker - Legacy - NPM (UMD) 30.63 KB 30.63 KB (0%) 31 KB
Service Worker - Modern - NPM (ESM) 25.74 KB 25.74 KB (0%) 26 KB
Service Worker - Modern - NPM (CJS) 26.02 KB 26.02 KB (0%) 26.5 KB
Service Worker - Modern - NPM (UMD) 25.79 KB 25.79 KB (0%) 26 KB
All Integrations - Legacy - CDN 94.16 KB 94.14 KB (-0.02% ▼) 95.3 KB
All Integrations - Modern - CDN 89.16 KB 89.31 KB (+0.17% ▲) 91 KB

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)
packages/analytics-js-integrations/__tests__/integrations/Appcues/appcues.test.js (2)

176-193: LGTM: Comprehensive test cases for the group method.

Both test cases are well-structured and cover important scenarios:

  1. The first test correctly verifies the behavior when both groupId and traits are present.
  2. The second test appropriately checks that the group method is not called when groupId is missing.

These tests follow good practices and provide good coverage for the new group functionality.

Consider adding a test case for when groupId is present but traits is empty or missing. This would further improve the test coverage.


23-23: Overall, excellent addition of group functionality tests.

The changes introduce well-structured and comprehensive tests for the new group method in the Appcues integration. The additions are consistent with the existing test patterns and provide good coverage of the new functionality. The mock updates and test cases are appropriately implemented.

To further enhance the test suite:

  1. Consider adding a test case for when groupId is present but traits is empty or missing.
  2. If there are any specific requirements or edge cases for the group method mentioned in the Appcues documentation, consider adding tests for those scenarios as well.

Also applies to: 165-193

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL

📥 Commits

Files that changed from the base of the PR and between 83d7c71 and e2d322d.

📒 Files selected for processing (1)
  • packages/analytics-js-integrations/tests/integrations/Appcues/appcues.test.js (2 hunks)
🧰 Additional context used
🔇 Additional comments (2)
packages/analytics-js-integrations/__tests__/integrations/Appcues/appcues.test.js (2)

23-23: LGTM: Mock implementation for group method added.

The addition of the group mock in the mockAppcuesSDK function is appropriate and consistent with the new functionality being tested. This change enables isolated testing of the group method.


165-175: LGTM: Well-structured test suite setup for group tests.

The new test suite for Appcues group tests is properly set up with a descriptive title. The rudderElement object is well-defined with the necessary properties (groupId and traits) for comprehensive group testing.

Copy link

sonarcloud bot commented Oct 14, 2024

@anantjain45823 anantjain45823 merged commit d01522a into develop Oct 14, 2024
12 checks passed
@anantjain45823 anantjain45823 deleted the feat.support_group_in_appcues_1 branch October 14, 2024 06:57
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.

4 participants