Skip to content

Conversation

DarshanKumarA
Copy link

Closes #22617

What does this PR do?

This PR prevents the main dashboard's Google Tag Manager (GTM) container from loading on the booking success page (/[user]/book/success).

Currently, the incorrect dashboard GTM script loads on this page, which can lead to skewed analytics data. This change isolates the booking success page from the main app's analytics container by adding a path check in the GoogleTagManagerComponent. This ensures only the correct booking-flow analytics are active.

Visual Demo (For contributors especially)

N/A — This change affects a background analytics script and has no direct visual component. The verification is done by inspecting network requests as described in the testing steps below.

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code.
  • N/A
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

This change can be verified by checking for the absence of the GTM script on the booking success page.

Note for Testers: The dashboard GTM script is also configured to only load for users with a US-based geolocation. If you are testing from outside the US, the script will not load on any page. This is expected. The key is to confirm it remains unloaded on the success page.

  1. Run the application and open your browser's Developer Tools (F12) to the Network tab.
  2. In the "Filter" box, type gtm.js.
  3. Test Case A: Normal Page
    • Navigate to a standard dashboard page, like /event-types.
    • Expected Result: If testing from the US, the gtm.js script should appear in the network log. If outside the US, the log will be empty (this is OK).
  4. Test Case B: Booking Success Page
    • Go through a full booking flow and land on the booking success page.
    • Expected Result: The network log should remain empty. The gtm.js script must not load on this page, regardless of your location. This confirms the fix is working.

Copy link

vercel bot commented Jul 19, 2025

@DarshanKumarA is attempting to deploy a commit to the cal Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Jul 19, 2025

Walkthrough

The change updates the GoogleTagManagerComponent in the apps/web/components/GTM.tsx file. It introduces the use of usePathname from next/navigation to determine the current URL path. A new check is added to identify if the user is on the "/book/success" page, and if so, the component returns null, preventing the Google Tag Manager from loading on that page. The conditions for rendering the component now include this new check in addition to existing checks for user location, GTM ID presence, and geolocation loading status. No changes were made to exported or public entity signatures.

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

apps/web/components/GTM.tsx

Oops! Something went wrong! :(

ESLint: 8.57.1

ESLint couldn't find the plugin "eslint-plugin-playwright".

(The package "eslint-plugin-playwright" was not found when loaded as a Node module from the directory "".)

It's likely that the plugin isn't installed correctly. Try reinstalling by running the following:

npm install eslint-plugin-playwright@latest --save-dev

The plugin "eslint-plugin-playwright" was referenced from the config file in ".eslintrc.js".

If you still can't figure out the problem, please stop by https://eslint.org/chat/help to chat with the team.


📜 Recent review details

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

📥 Commits

Reviewing files that changed from the base of the PR and between 9d65b6f and ec70267.

📒 Files selected for processing (1)
  • apps/web/components/GTM.tsx (2 hunks)
🧰 Additional context used
🧠 Learnings (2)
📓 Common learnings
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.341Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/RoutingFunnel.tsx:15-17
Timestamp: 2025-07-15T12:58:40.497Z
Learning: In the insights routing funnel component (packages/features/insights/components/RoutingFunnel.tsx), the useColumnFilters exclusions are intentionally different from the general useInsightsParameters exclusions. RoutingFunnel specifically excludes only ["createdAt"] while useInsightsParameters excludes ["bookingUserId", "formId", "createdAt", "eventTypeId"]. This difference is by design.
apps/web/components/GTM.tsx (2)
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/FailedBookingsByField.tsx:65-71
Timestamp: 2025-07-15T12:59:34.341Z
Learning: In the FailedBookingsByField component (packages/features/insights/components/FailedBookingsByField.tsx), although routingFormId is typed as optional in useInsightsParameters, the system automatically enforces a routing form filter, so routingFormId is always present in practice. This means the data always contains only one entry, making the single-entry destructuring approach safe.
Learnt from: eunjae-lee
PR: calcom/cal.com#22106
File: packages/features/insights/components/RoutingFunnel.tsx:15-17
Timestamp: 2025-07-15T12:58:40.497Z
Learning: In the insights routing funnel component (packages/features/insights/components/RoutingFunnel.tsx), the useColumnFilters exclusions are intentionally different from the general useInsightsParameters exclusions. RoutingFunnel specifically excludes only ["createdAt"] while useInsightsParameters excludes ["bookingUserId", "formId", "createdAt", "eventTypeId"]. This difference is by design.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Install dependencies / Yarn install & cache
  • GitHub Check: Codacy Static Code Analysis
  • GitHub Check: Security Check
🔇 Additional comments (4)
apps/web/components/GTM.tsx (4)

3-4: LGTM! Correct import for Next.js navigation.

The import statement is correctly added and the comment provides helpful context for the change.


50-50: LGTM! Proper hook usage.

The usePathname hook is correctly used following React hooks best practices.


51-51: LGTM! Good defensive programming with optional chaining.

The path checking logic correctly uses optional chaining and the endsWith() method. The pattern should effectively match booking success pages as intended by the PR objectives.


52-52: LGTM! Correctly implements the GTM blocking logic.

The addition of isBookingSuccessPage to the conditional check perfectly implements the PR requirement to prevent GTM loading on booking success pages while maintaining all existing functionality.

✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 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.
    • Explain this complex logic.
    • 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 explain this code block.
    • @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 explain its main purpose.
    • @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.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

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 generate sequence diagram to generate a sequence diagram of the changes in 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.

@graphite-app graphite-app bot requested a review from a team July 19, 2025 07:47
@graphite-app graphite-app bot added the community Created by Linear-GitHub Sync label Jul 19, 2025
@github-actions github-actions bot added booking-page area: booking page, public booking page, booker consumer 🧹 Improvements Improvements to existing features. Mostly UX/UI labels Jul 19, 2025
@dosubot dosubot bot added the 🐛 bug Something isn't working label Jul 19, 2025
Copy link

graphite-app bot commented Jul 19, 2025

Graphite Automations

"Add consumer team as reviewer" took an action on this PR • (07/19/25)

1 reviewer was added to this PR based on Keith Williams's automation.

"Add community label" took an action on this PR • (07/19/25)

1 label was added to this PR based on Keith Williams's automation.

@DarshanKumarA
Copy link
Author

Hi team, thanks for the opportunity to contribute!

It looks like the automated CI checks are failing with a couple of configuration issues. I'm seeing errors related to:

A missing eslint-plugin-playwright dependency.

A request to update the global npm version to 11.4.2.

These seem to be project-level tooling issues. My code changes for the GTM fix are ready for review when you get a chance. Let me know if you need anything else from me!

Copy link
Contributor

github-actions bot commented Aug 3, 2025

This PR is being marked as stale due to inactivity.

@github-actions github-actions bot added the Stale label Aug 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
booking-page area: booking page, public booking page, booker 🐛 bug Something isn't working community Created by Linear-GitHub Sync consumer 🧹 Improvements Improvements to existing features. Mostly UX/UI Stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Prevent loading of dashboard GTM container on booking success page
1 participant