Skip to content

Read sourcegraphAnonymousUid cookie value into HubSpot forms

Warren Gifford requested to merge fa/read-cookie-into-forms into main

Created by: attfarhan

Closes https://github.com/sourcegraph/sourcegraph/issues/11658.

This PR populates the hidden anonymous user ID field in HubSpot forms with the cookie value in sourcegraphAnonymousUid.

For any HubSpot form created using our createHubSpotForm function, when the form loads, we will read the sourcegraphAnonymousUid cookie value and populate the anonymous_user_id field in the form with the value. One thing to note is that this PR also changes the polyfill we currently have for jQuery.

The polyfill is from this article, which outlines how to provide custom callbacks to embedded HubSpot forms without importing jQuery: https://www.unstack.com/blog/hubspot-on-form-submit-callbacks-without-jquery. The old polyfill was taken from https://community.hubspot.com/t5/APIs-Integrations/Form-callback-throws-unrelated-jquery-error/m-p/232127/highlight/true#M11023 AFAICT, and replacing it with the new code does not seem to have any side effects. This is generally frustrating as the HubSpot embedded forms have a hard dependency on jQuery, but this feels like a reasonable workaround.

Merge request reports

Loading