Support for decoupled submissions

Created on 14 November 2024, about 2 months ago

Problem/Motivation

When other Frontends are used, and Drupal is just backend, the pageUri, pageName, hutk and ipAddress should be properly passed as Frontend --> Drupal backend --> Hubspot API.
Which is not possible how.

Proposed resolution

Frontend should pass the values either in headers (recommended) either in submission body.
Headers are recommended, but will require to adjust CORS settings in services.yml to allow `hubspot-context` header.
In case if this not possible Frontend may pass values in request body as `hubspot_context` key. But in this way there is some complexity: hubspot cookie will be saved in submission by Webforms, which is not good. During submitting to hubspot API HubspotWebformHandler.php will unset `hubspot_context` from submission and resave it. This will trigger handlers again, HubspotWebformHandler will protect itself from double submitting to Hubspot API with static::$suppressResending, but not other handlers. If user don't want to remove `hubspot_context` and trigger double save, then set `dont_remove` property in request to non-falsy value.
In both cases (header `hubspot-context` or body `hubspot_context` passing) should be json encoded array - string. With keys pageUri, pageName, hutk, ipAddress, dont_remove - each is optional.
Before submitting HubspotWebformHandler will try to resolve hubspot context as first non-empty from:
- current request headers
- current request body
- saved submission body
and remove from submission body if present and `dont_remove` is not falsy

Remaining tasks

Accept and merge implementations by module owner.

User interface changes

None.

API changes

Handler can accept new data from header or body or submission body as described above.

Data model changes

none.

Soon I will add merge request with solution code.

✨ Feature request
Status

Active

Version

3.0

Component

Code

Created by

πŸ‡ΊπŸ‡¦Ukraine mykola dolynskyi Poltava

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Merge Requests

Comments & Activities

Production build 0.71.5 2024