Fix/hubspot meetings embed - #5906
Conversation
✅ Deploy Preview for flowfuse-website ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
…c prop, import site.json in contact-us
dimitrieh
left a comment
There was a problem hiding this comment.
Yndira, approving this one. Checking the stored consent on mount fixes the calendar not showing after a reload.
I opened a follow-up for you to consider: #5910. It creates a new iframe on each mount rather than re-attaching the earlier one, keeps the fallback up until the iframe is actually there, and removes the embed when analytics consent is withdrawn. The trade-off is the one you avoided here: HubSpot's leftover listeners throw a console error after a client-side revisit, though the calendar itself works. If you agree with the approach, merge it after this one.
Builds on the consent check from the previous commits and replaces the retained-iframe approach: - Each mount calls hbspt.meetings.create() for its own container (unique id from useId), so a page reached by client-side navigation gets a fresh, correctly addressed iframe without rewriting HubSpot's src by hand. This also keeps the current HubSpot utk, and lets two instances coexist. - The fallback stays until an iframe is actually in the container, watched with a MutationObserver. HubSpot inserts it after create() returns, so setting embedded on script load emptied the slot early, and a blocked or stubbed script left neither calendar nor fallback. - The script 'load' listener is removed on unmount, so a stale instance can no longer call create() on another page. - Withdrawing analytics consent removes the embed. - The VPP blog post linked the retired round-robin calendar through a mangled URL; it now links /book-demo/. Known cost: HubSpot's script adds two window message listeners per iframe and never removes them. After a client-side revisit, the old iframe's consent listener throws "Cannot read properties of null (reading 'postMessage')" in HubSpot's own code when the new iframe loads. The calendar is unaffected.
|
Thanks @dimitrieh! I've implemented your suggestion, plus a couple of things on top. Could you take another look and merge if it's all OK? |

Description
Fixes the embedded HubSpot calendar (
/book-demo,/landing/tulip) not showing up in some cases, and keeps it behind analytics consent:cc:onConsent/cc:onChange, instead of thewindow._ffLoadMeetingsglobal (removed fromcookieconsent-config.js).site.meetings.salesRoundRobin./landing/tulipmoves to the shared calendar on purpose, and the VPP blog post links/book-demo/instead of the retired calendar.Known cost: HubSpot's script adds two window listeners per iframe and never removes them, so each client-side revisit adds two more and the old iframe's listener throws a TypeError in HubSpot's code. The calendar is unaffected.
Supersedes #5910.
Follow-ups
Related Issue(s)
Checklist