Skip to content

Conversation

@marcoferreiradev
Copy link
Contributor

@marcoferreiradev marcoferreiradev commented Jan 5, 2026

What is this Contribution About?

Fixes a bug where ignoreStructuredData=true was still sending JSON-LD to search engine bots, causing duplicate structured data on sites with custom LD+JSON implementations.

Changes:

  • Replaces boolean ignoreStructuredData with explicit structuredDataControl prop offering three modes: "always include" (default), "disable for users" (bots only), "disable for all" (completely disabled)
  • Extracts shared logic into reusable shouldIncludeStructuredData utility
  • Maintains backward compatibility by deprecating old prop with fallback logic
  • Applies fix to both PDP and PLP SEO sections

Before: Bots received duplicate @type":"ProductDetailsPage" when custom structured data existed
After: Sites can properly exclude section's structured data while maintaining custom implementations

Issue Link

N/A - Bug identified during bot testing with curl

Demonstration Link

Tested with Googlebot user-agent simulation - structured data now correctly excluded when configured

Summary by CodeRabbit

  • New Features

    • Adds three granular structured-data control modes to fine-tune when JSON-LD is emitted, improving SEO behavior.
    • Smarter bot-aware delivery: structured data can be targeted differently for crawlers vs. regular users.
  • Deprecations

    • Legacy boolean structured-data flag deprecated; migrate to the new control mechanism for greater flexibility and clearer defaults.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 5, 2026

📝 Walkthrough

Walkthrough

Adds a structured data control mechanism and utility to determine JSON-LD inclusion by mode ("disable for users" | "disable for all" | "always include"), and integrates it into PDP and PLP SEO components, deprecating the boolean ignoreStructuredData flag.

Changes

Cohort / File(s) Summary
Structured Data Control Utilities
commerce/utils/structuredData.ts
New module exporting StructuredDataControl type and shouldIncludeStructuredData(jsonLD, control?, isBot) which returns whether to include JSON‑LD based on control mode and bot status.
PDP SEO Component
commerce/sections/Seo/SeoPDPV2.tsx
Added structuredDataControl?: StructuredDataControl to Props; imported utility; deprecated ignoreStructuredData; derive mode from structuredDataControl/ignoreStructuredData; compute jsonLDs via shouldIncludeStructuredData(...).
PLP SEO Component
commerce/sections/Seo/SeoPLPV2.tsx
Added structuredDataControl?: StructuredDataControl to ConfigJsonLD; imported utility; derive mode from structuredDataControl/ignoreStructuredData; determine JSON‑LD emission with shouldIncludeStructuredData(...); deprecated ignoreStructuredData.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐇 I nibbled on code where JSON‑LD grew,
Three little modes now guide what to do.
Bots get a nibble, users may hide,
A rabbit-approved toggle—soft, not wide.
Hooray for structured data, tidy and new! 🥕

Pre-merge checks and finishing touches

❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 66.67% which is insufficient. The required threshold is 80.00%. You can run @coderabbitai generate docstrings to improve docstring coverage.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and specifically summarizes the main change: replacing boolean ignoreStructuredData with explicit structuredDataControl to prevent structured data from being sent to bots when explicitly disabled.
Description check ✅ Passed The description covers the key aspects: the bug being fixed, changes made (new prop with three modes), backward compatibility, and affected components. While Issue Link and Demonstration Link sections could be more detailed, the core required information is provided.
✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 5, 2026

Tagging Options

Should a new tag be published when this PR is merged?

  • 👍 for Patch 0.133.23 update
  • 🎉 for Minor 0.134.0 update
  • 🚀 for Major 1.0.0 update

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

Fix all issues with AI Agents 🤖
In @commerce/sections/Seo/SeoPDPV2.tsx:
- Line 55: Remove the default assignment for structuredDataControl in the
destructuring of the component props so it can be undefined and allow the
existing fallback that checks ignoreStructuredData to operate; specifically, in
SeoPDPV2.tsx remove the `= "always include"` default on structuredDataControl
(so the nullish coalescing later that uses ignoreStructuredData will work), and
apply the same change to the other occurrences noted around the 78–84 region to
restore backward compatibility with ignoreStructuredData.
🧹 Nitpick comments (1)
commerce/utils/structuredData.ts (1)

7-16: Logic is correct but could be slightly clearer.

The function correctly implements the intended behavior:

  • "always include" → includes for all
  • "disable for users" → includes only for bots
  • "disable for all" → never includes

The compound boolean expression works but may be harder to parse at a glance.

🔎 Optional: More explicit structure for readability
 export function shouldIncludeStructuredData(
   jsonLD: unknown,
   control: StructuredDataControl = "always include",
   isBot: boolean,
 ): boolean {
   if (!jsonLD) return false;
 
-  return control !== "disable for all" &&
-    (control !== "disable for users" || isBot);
+  switch (control) {
+    case "disable for all":
+      return false;
+    case "disable for users":
+      return isBot;
+    case "always include":
+    default:
+      return true;
+  }
 }
📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 30ca287 and 07b52df.

📒 Files selected for processing (3)
  • commerce/sections/Seo/SeoPDPV2.tsx
  • commerce/sections/Seo/SeoPLPV2.tsx
  • commerce/utils/structuredData.ts
🧰 Additional context used
🧬 Code graph analysis (2)
commerce/sections/Seo/SeoPLPV2.tsx (1)
commerce/utils/structuredData.ts (2)
  • StructuredDataControl (2-5)
  • shouldIncludeStructuredData (7-16)
commerce/sections/Seo/SeoPDPV2.tsx (1)
commerce/utils/structuredData.ts (2)
  • StructuredDataControl (2-5)
  • shouldIncludeStructuredData (7-16)
🔇 Additional comments (6)
commerce/utils/structuredData.ts (1)

2-5: Clear and well-designed type definition.

The three-mode approach provides better control than the previous boolean, aligning well with the PR objective to prevent duplicate structured data when custom LD+JSON is used.

commerce/sections/Seo/SeoPLPV2.tsx (3)

9-12: LGTM!

Clean import of the new utility function and type from the shared module.


21-31: Good deprecation strategy and documentation.

The deprecation notice on ignoreStructuredData with clear guidance to use structuredDataControl instead is well done. The JSDoc for the new prop clearly explains the three modes and warns about third-party integration implications.


96-103: Backward compatibility handled correctly.

The fallback logic properly maps:

  • structuredDataControl takes precedence when set
  • Legacy ignoreStructuredData: true"disable for users" (preserving original bot-only behavior)
  • Legacy ignoreStructuredData: false/undefined"always include"

This ensures existing configurations continue to work as expected.

commerce/sections/Seo/SeoPDPV2.tsx (2)

9-12: LGTM!

Consistent import pattern with SeoPLPV2.tsx.


27-38: Deprecation and new prop documented consistently with PLP.

Good alignment between PDP and PLP interfaces.

- Replace boolean `ignoreStructuredData` with explicit `structuredDataControl` options
- Fix bug where bots still received JSON-LD even when `ignoreStructuredData=true`
- Add "always include" (default), "disable for users", and "disable for all" modes
- Deprecate `ignoreStructuredData` with backward compatibility
- Extract shared logic to `shouldIncludeStructuredData` utility
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

🧹 Nitpick comments (1)
commerce/sections/Seo/SeoPDPV2.tsx (1)

30-38: Deprecation and new API properly documented!

The changes mirror the PLP implementation with clear deprecation notices and comprehensive JSDoc for the new property.

Note: The API structure differs slightly from SeoPLPV2 (which nests structuredDataControl inside ConfigJsonLD), but this appears intentional given PDP's simpler configuration needs.

📜 Review details

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 07b52df and a77b9ad.

📒 Files selected for processing (3)
  • commerce/sections/Seo/SeoPDPV2.tsx
  • commerce/sections/Seo/SeoPLPV2.tsx
  • commerce/utils/structuredData.ts
🚧 Files skipped from review as they are similar to previous changes (1)
  • commerce/utils/structuredData.ts
🧰 Additional context used
🧬 Code graph analysis (2)
commerce/sections/Seo/SeoPLPV2.tsx (1)
commerce/utils/structuredData.ts (2)
  • StructuredDataControl (2-5)
  • shouldIncludeStructuredData (7-16)
commerce/sections/Seo/SeoPDPV2.tsx (1)
commerce/utils/structuredData.ts (2)
  • StructuredDataControl (2-5)
  • shouldIncludeStructuredData (7-16)
🔇 Additional comments (7)
commerce/sections/Seo/SeoPLPV2.tsx (4)

9-12: LGTM!

The imports correctly bring in the utility function and type definition needed for the new structured data control mechanism.


23-31: Well-documented deprecation and new API!

The deprecation notice clearly directs users to the new structuredDataControl property, and the JSDoc for the new property is comprehensive, explaining all three modes and potential integration impacts.


96-99: Backward compatibility correctly preserved!

The mode derivation logic properly handles the deprecated ignoreStructuredData flag while respecting the new structuredDataControl when provided. The mapping of ignoreStructuredData=true to "disable for users" maintains the original behavior.


101-103: Clean integration of the utility function!

The structured data inclusion logic correctly delegates to shouldIncludeStructuredData, passing all required parameters and producing the expected jsonLDs array.

commerce/sections/Seo/SeoPDPV2.tsx (3)

9-12: LGTM!

The imports are correct and consistent with the companion PLP implementation.


78-80: Backward compatibility correctly implemented!

The mode derivation properly handles the deprecated ignoreStructuredData flag with a clear comment. The logic correctly defaults to "always include" when neither prop is provided, maintaining expected behavior.


82-84: Clean utility integration!

The structured data inclusion logic correctly uses shouldIncludeStructuredData with proper parameter passing, consistent with the PLP implementation.

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.

1 participant