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

Develop #364

Merged
merged 7 commits into from
Feb 26, 2025
Merged

Develop #364

merged 7 commits into from
Feb 26, 2025

Conversation

ThisIsRaghavGupta
Copy link
Contributor

@ThisIsRaghavGupta ThisIsRaghavGupta commented Feb 26, 2025

Changes

WEB-3502 - Added ctActionMode query paramater to handle all url paramters

Changes to Public Facing API if any

NA

How Has This Been Tested?

Dev + QA Tested

Checklist

  • Code compiles without errors
  • Version Bump added to package.json & CHANGELOG.md
  • All tests pass
  • Build process is successful
  • Documentation has been updated (if needed)

Summary by CodeRabbit

  • New Features

    • Introduced a new URL query parameter to support multiple action modes, expanding how the system interprets URL queries.
  • Refactor

    • Streamlined the parameter handling logic for a more robust and modular experience.
    • Updated the SDK version to ensure consistency and improved behavior.
  • Documentation / Chores

    • Revised release notes and version information, now reflecting the updated version 1.13.1.

Copy link

coderabbitai bot commented Feb 26, 2025

Note

Currently processing new changes in this PR. This may take a few minutes, please wait...

📥 Commits

Reviewing files that changed from the base of the PR and between f700cbc and da72599.

⛔ Files ignored due to path filters (3)
  • clevertap.js.map is excluded by !**/*.map
  • clevertap.min.js is excluded by !**/*.min.js
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (6)
  • CHANGELOG.md (1 hunks)
  • clevertap.js (7 hunks)
  • package.json (1 hunks)
  • src/clevertap.js (2 hunks)
  • src/modules/visualBuilder/builder_constants.js (1 hunks)
  • src/modules/visualBuilder/pageBuilder.js (3 hunks)
 ____________________________________________________
< Veni, Vidi, Verificavi. I came, I saw, I verified. >
 ----------------------------------------------------
  \
   \   (\__/)
       (•ㅅ•)
       /   づ

Tip

CodeRabbit can enforce grammar and style rules using `languagetool`.

Configure languagetool in your project's settings in CodeRabbit enable/disable rules and categories. Refer to the LanguageTool Community to learn more.


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.
  • @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

@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

🧹 Nitpick comments (4)
CHANGELOG.md (1)

4-5: Improve clarity in the changelog entry.

Consider refining the wording to use plural “parameters” for consistency:

- - Added search parameter ctActionMode to handle all url query parameter
+ - Added search parameter ctActionMode to handle all URL query parameters
src/modules/visualBuilder/pageBuilder.js (1)

46-46: Complete the TODO for secure messaging.

A guarding mechanism to verify message origins helps avoid security issues like clickjacking or malicious postMessages. Let me know if you need help drafting it.

clevertap.js (2)

11133-11137: Add inline documentation for the new constants.

A brief description for each of these action modes (BUILDER, PREVIEW, SDK_CHECK) would enhance maintainability and make the code self-explanatory.


16369-16369: Centralize SDK version definition.

Hardcoding the version here and in other places can lead to discrepancies. Consider deduplicating by referencing a single version variable (e.g., from package.json) across all references.

📜 Review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between f700cbc and da72599.

⛔ Files ignored due to path filters (3)
  • clevertap.js.map is excluded by !**/*.map
  • clevertap.min.js is excluded by !**/*.min.js
  • yarn.lock is excluded by !**/yarn.lock, !**/*.lock
📒 Files selected for processing (6)
  • CHANGELOG.md (1 hunks)
  • clevertap.js (7 hunks)
  • package.json (1 hunks)
  • src/clevertap.js (2 hunks)
  • src/modules/visualBuilder/builder_constants.js (1 hunks)
  • src/modules/visualBuilder/pageBuilder.js (3 hunks)
✅ Files skipped from review due to trivial changes (1)
  • package.json
🔇 Additional comments (9)
src/modules/visualBuilder/builder_constants.js (1)

8-12: Centralize query parameters for maintainability.

Defining a dedicated object for your visual editor query parameters is a neat approach. This ensures a single source of truth for references to builder-related mode checks and prevents typos.

src/clevertap.js (2)

46-46: Importing handleActionMode looks appropriate.

The addition of handleActionMode alongside addAntiFlicker aligns with the refactoring in pageBuilder.js. No issues spotted here.


659-659:

❓ Verification inconclusive

Verify that checkBuilder references are fully removed.

Ensure there are no leftover references to the old checkBuilder method in the project.


🏁 Script executed:

#!/bin/bash
# Searching for any legacy references to checkBuilder
rg "checkBuilder" -A 5

Length of output: 22


Action Required: Verify Complete Removal of 'checkBuilder' References

Based on our recent searches using ripgrep, there are no detected occurrences of "checkBuilder" in the codebase. The code snippet in src/clevertap.js now correctly calls handleActionMode on line 659, suggesting that the legacy checkBuilder method has been replaced or removed.

However, given that the search output was empty (which could be due to the command’s limitations or missing indirect references), please perform a manual verification to ensure that no dynamic or indirect usages of checkBuilder remain.

src/modules/visualBuilder/pageBuilder.js (2)

1-44: Refactored function improves readability.

Renaming checkBuilder to handleActionMode and leveraging a switch statement for each mode is clearer and more maintainable. This helps ensure each action mode is handled consistently.


168-173: Removing ctActionMode in preview ensures cleaner URLs.

Stripping out ctActionMode avoids polluting the preview mode with development query params. This is a reasonable approach for end-user clarity.

clevertap.js (4)

11390-11396: Verify downstream impact of stripping out ‘ctActionMode’.

Removing the ctActionMode parameter upon entering preview mode might confuse users who rely on that query for debugging or direct linking. Ensure that removing it aligns with the expected user flow and does not hinder future debugging steps.


11481-11481: Double-check URL matching logic.

Comparing d.url with the modified url might fail if they differ only by trailing slashes or protocol casing. Consider normalizing both strings or using a more robust comparison if partial matches are valid.


14623-14623: Version bump looks good.

Thanks for keeping the library version up to date.


16182-16182: Ensure handleActionMode is free of window references in non-browser contexts.

If the library can run in server-side rendering (SSR) setups or Web Workers, referencing window may result in runtime errors.

Comment on lines +11199 to +11252
const handleActionMode = (logger, accountId) => {
const searchParams = new URLSearchParams(window.location.search);
const ctType = searchParams.get('ctActionMode');

if (search === '?ctBuilder') {
// open in visual builder mode
logger.debug('open in visual builder mode');
window.addEventListener('message', handleMessageEvent, false);
if (ctType) {
const parentWindow = window.opener;

if (parentWindow) {
parentWindow.postMessage({
message: 'builder',
originUrl: window.location.href
}, '*');
}
switch (ctType) {
case WVE_QUERY_PARAMS.BUILDER:
logger.debug('open in visual builder mode');
window.addEventListener('message', handleMessageEvent, false);

return;
}
if (parentWindow) {
parentWindow.postMessage({
message: 'builder',
originUrl: window.location.href
}, '*');
}

if (search === '?ctBuilderPreview') {
window.addEventListener('message', handleMessageEvent, false);
break;

if (parentWindow) {
parentWindow.postMessage({
message: 'preview',
originUrl: window.location.href
}, '*');
}
}
case WVE_QUERY_PARAMS.PREVIEW:
logger.debug('preview of visual editor');
window.addEventListener('message', handleMessageEvent, false);

if (parentWindow) {
parentWindow.postMessage({
message: 'preview',
originUrl: window.location.href
}, '*');
}

if (search === '?ctBuilderSDKCheck') {
if (parentWindow) {
const sdkVersion = '1.13.0';
parentWindow.postMessage({
message: 'SDKVersion',
accountId,
originUrl: window.location.href,
sdkVersion
}, '*');
break;

case WVE_QUERY_PARAMS.SDK_CHECK:
if (parentWindow) {
logger.debug('SDK version check');
const sdkVersion = '1.13.1';
parentWindow.postMessage({
message: 'SDKVersion',
accountId,
originUrl: window.location.href,
sdkVersion
}, '*');
}

break;

default:
logger.debug("unknown query param ".concat(ctType));
break;
}
}
};
}; // TODO: Add a guarding mechanism to skip postMessages from non trusted sources
Copy link

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Guard postMessages from untrusted sources.

The handleActionMode function currently sends and listens to postMessage events without verifying the sender’s domain. Although there's a TODO comment hinting at a fix, this is potentially a security risk.

Want help adding domain checks or a robust validation mechanism to mitigate any XSS or phishing vectors?

@ThisIsRaghavGupta ThisIsRaghavGupta merged commit 20f3f6c into master Feb 26, 2025
5 checks passed
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