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: onboard topsort destination #1842

Merged
merged 1 commit into from
Dec 13, 2024
Merged

Conversation

aanshi07
Copy link
Contributor

@aanshi07 aanshi07 commented Dec 12, 2024

What are the changes introduced in this PR?

Onboarded new destination : Topsort

What is the related Linear task?

Resolves INT-2661

UI:
Screenshot 2024-12-12 at 11 30 55 AM

Please explain the objectives of your changes below

Put down any required details on the broader aspect of your changes. If there are any dependent changes, mandatorily mention them here

Any changes to existing capabilities/behaviour, mention the reason & what are the changes ?

N/A

Any new dependencies introduced with this change?

N/A

Any new checks got introduced or modified in test suites. Please explain the changes.

N/A


Developer checklist

  • My code follows the style guidelines of this project

  • No breaking changes are being introduced.

  • All related docs linked with the PR?

  • All changes manually tested?

  • Any documentation changes needed with this change?

  • I have executed schemaGenerator tests and updated schema if needed

  • Are sensitive fields marked as secret in definition config?

  • My test cases and placeholders use only masked/sample values for sensitive fields

  • Is the PR limited to 10 file changes & one task?

Reviewer checklist

  • Is the type of change in the PR title appropriate as per the changes?

  • Verified that there are no credentials or confidential data exposed with the changes.

Summary by CodeRabbit

  • New Features

    • Introduced a new configuration file for the Topsort destination, defining key properties and settings.
    • Added a JSON schema for validating Topsort configuration settings.
    • Implemented a UI configuration structure for managing Topsort integration settings, including event mappings and consent management.
  • Tests

    • Added test cases for validating Topsort configuration scenarios, ensuring robustness in error handling and configuration validation.

Copy link

coderabbitai bot commented Dec 12, 2024

Walkthrough

This pull request introduces several new configuration files for the "TOPSORT" destination, including db-config.json, schema.json, and ui-config.json. Each file defines key properties, settings, and validation schemas for the integration. Additionally, a new test file is added to validate the configurations, covering various scenarios for connection modes, API keys, and event names. The changes collectively enhance the structure and management of configurations related to the TOPSORT destination.

Changes

File Path Change Summary
src/configurations/destinations/topsort/db-config.json New configuration file defining properties for TOPSORT integration, including supported source types and connection modes.
src/configurations/destinations/topsort/schema.json New JSON schema for configuration settings, specifying required fields and their types for topsort events.
src/configurations/destinations/topsort/ui-config.json New UI configuration file outlining templates and settings for user interface management related to TOPSORT.
test/data/validation/destinations/topsort.json New test cases for validating configurations, covering valid and invalid scenarios for connection modes and API keys.

Possibly related PRs

Suggested reviewers

  • lvrach
  • am6010
  • AchuthaSourabhC
  • krishna2020
  • ssbeefeater
  • debanjan97
  • cisse21
  • ruchiramoitra
  • 1abhishekpandey
  • ItsSudip
  • sandeepdsvs
  • shrouti1507

🐰 In the fields so bright and wide,
New configs for TOPSORT we now provide.
With schemas and tests, our work is done,
Hop along, let’s have some fun!
For every source and type we’ve set,
A happy integration, you can bet! 🌟


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. (Experiment)
  • @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.

@aanshi07 aanshi07 requested a review from utsabc December 12, 2024 13:33
Copy link

codecov bot commented Dec 12, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (e8c5167) to head (6d5c1d0).
Report is 10 commits behind head on develop.

Additional details and impacted files
@@            Coverage Diff            @@
##           develop     #1842   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            2         2           
  Lines           53        53           
  Branches         7         7           
=========================================
  Hits            53        53           

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

Copy link

@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: 4

🧹 Outside diff range and nitpick comments (7)
src/configurations/destinations/topsort/db-config.json (2)

35-103: Reduce configuration duplication in destConfig.

The configuration repeats the same set of keys (connectionMode, consentManagement, oneTrustCookieCategories, ketchConsentPurposes) for each platform. Consider refactoring to reduce duplication.

   "destConfig": {
     "defaultConfig": ["apiKey", "topsortEvents"],
-    "android": [
-      "connectionMode",
-      "consentManagement",
-      "oneTrustCookieCategories",
-      "ketchConsentPurposes"
-    ],
-    "ios": [...],
+    "commonConfig": [
+      "connectionMode",
+      "consentManagement",
+      "oneTrustCookieCategories",
+      "ketchConsentPurposes"
+    ],
+    "android": "commonConfig",
+    "ios": "commonConfig",
     // ... other platforms referencing commonConfig
   }

106-108: Consider adding beta expiration date.

The configuration is marked as beta. Consider adding an expiration date for the beta status to ensure it's reviewed for production readiness.

   "options": {
-    "isBeta": true
+    "isBeta": true,
+    "betaExpiresAt": "2025-03-31"
   }
test/data/validation/destinations/topsort.json (1)

122-131: Add test case for duplicate event mappings.

The test cases don't validate the scenario where the same Topsort event is mapped to multiple Rudderstack events. Add a test case to prevent duplicate mappings.

+  {
+    "testTitle": "Duplicate Topsort event mappings",
+    "config": {
+      "apiKey": "test-api",
+      "topsortEvents": [
+        {
+          "to": "clicks",
+          "from": "Product Clicked"
+        },
+        {
+          "to": "clicks",
+          "from": "Product Viewed"
+        }
+      ]
+    },
+    "result": false,
+    "err": ["Duplicate Topsort event 'clicks' found in mappings"]
+  },
src/configurations/destinations/topsort/ui-config.json (1)

243-253: Add tooltip for consent category IDs.

The consent category IDs field would benefit from a tooltip explaining the expected format and providing examples of valid IDs.

   {
     "type": "tagInput",
     "label": "Enter consent category IDs",
     "note": "Input your consent category IDs by pressing 'Enter' after each entry. We recommend using IDs instead of names as IDs are unique and less likely to change over time, making them a more reliable choice.",
+    "tooltip": "Valid consent category IDs are alphanumeric strings (e.g., 'C0001', 'MARKETING_001'). Enter one ID at a time and press Enter.",
     "configKey": "consents",
     "tagKey": "consent",
     "placeholder": "e.g: Marketing",
     "default": [
       {
         "consent": ""
       }
     ]
   }
src/configurations/destinations/topsort/schema.json (3)

11-39: Consider enhancing event mapping validation.

While the basic structure is good, consider these improvements:

  1. Add required: ["from", "to"] to ensure both mapping fields are provided
  2. Add minItems and maxItems to prevent empty or overly large mappings
  3. Consider adding more e-commerce events like "Product List Viewed", "Promotion Viewed", etc.
       "topsortEvents": {
         "type": "array",
+        "minItems": 1,
+        "maxItems": 100,
         "items": {
           "type": "object",
+          "required": ["from", "to"],
           "properties": {
             "from": {
               "type": "string",
               "enum": [
                 "Product Clicked",
                 "Product Viewed",
                 "Product Added",
                 "Product Removed",
                 "Cart Viewed",
                 "Checkout Started",
                 "Checkout Step Viewed",
                 "Payment Info Entered",
                 "Order Updated",
                 "Order Completed",
                 "Order Refunded",
                 "Order Cancelled",
+                "Product List Viewed",
+                "Promotion Viewed",
+                "Promotion Clicked"
               ]
             },

688-824: Consolidate Ketch consent purposes schema.

Similar to previous sections, the Ketch consent purposes configuration can be simplified by extracting the common pattern.

+    "definitions": {
+      "ketchPurposeConfig": {
+        "type": "array",
+        "items": {
+          "type": "object",
+          "properties": {
+            "purpose": {
+              "type": "string",
+              "pattern": "(^\\{\\{.*\\|\\|(.*)\\}\\}$)|(^env[.].+)|^(.{0,100})$"
+            }
+          }
+        }
+      }
+    },
     "ketchConsentPurposes": {
       "type": "object",
       "properties": {
-        "android": {
-          "type": "array",
-          ...
-        },
+        "android": { "$ref": "#/definitions/ketchPurposeConfig" },
+        "ios": { "$ref": "#/definitions/ketchPurposeConfig" },

825-876: Simplify connection mode configuration.

Since all platforms are restricted to "cloud" mode, consider simplifying this section to reduce redundancy.

     "connectionMode": {
       "type": "object",
+      "additionalProperties": {
+        "type": "string",
+        "enum": ["cloud"]
+      },
       "properties": {
-        "android": {
-          "type": "string",
-          "enum": ["cloud"]
-        },
-        "ios": {
-          "type": "string",
-          "enum": ["cloud"]
-        },
+        "android": {},
+        "ios": {},
         // ... other platforms
       }
     }
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1f4e1c5 and 6d5c1d0.

📒 Files selected for processing (4)
  • src/configurations/destinations/topsort/db-config.json (1 hunks)
  • src/configurations/destinations/topsort/schema.json (1 hunks)
  • src/configurations/destinations/topsort/ui-config.json (1 hunks)
  • test/data/validation/destinations/topsort.json (1 hunks)
🔇 Additional comments (2)
src/configurations/destinations/topsort/db-config.json (1)

4-21: Consider adding validation for message types.

The configuration only supports 'track' message type for cloud sources. Consider if other message types like 'identify', 'page', or 'screen' should be supported for a complete integration.

src/configurations/destinations/topsort/schema.json (1)

1-10: LGTM: API key validation is properly configured.

The schema correctly enforces API key requirements with appropriate pattern matching for template syntax, environment variables, and direct values, with a reasonable maximum length limit.

@aanshi07 aanshi07 merged commit 2c683fe into develop Dec 13, 2024
23 checks passed
@aanshi07 aanshi07 deleted the feat.onboard_topsort_destination branch December 13, 2024 09:12
ItsSudip pushed a commit that referenced this pull request Dec 18, 2024
ItsSudip added a commit that referenced this pull request Dec 18, 2024
Co-authored-by: Aanshi Lahoti <110057617+aanshi07@users.noreply.github.com>
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.

3 participants