submit course / program as product_of_interest if the field is on the form#3231
Conversation
OpenAPI Changes2 changes: 0 error, 1 warning, 1 info Unexpected changes? Ensure your branch is up-to-date with |
There was a problem hiding this comment.
Pull request overview
This PR updates the “Stay Updated” HubSpot submission flow on product pages so that, when the HubSpot form includes a product_of_interest field, the current product’s title is submitted as that field’s value.
Changes:
- Pass the current product title into
StayUpdatedModalwhen opening it fromProductPageTemplate. - Add logic in
StayUpdatedModalto look up a matchingproduct_of_interestoption and include it in the submission payload. - Add/adjust frontend tests to assert the modal invocation args and the submitted HubSpot payload.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
frontends/main/src/app-pages/ProductPages/StayUpdatedModal.tsx |
Adds productTitle prop handling and attempts to resolve/submit product_of_interest from the HubSpot form definition. |
frontends/main/src/app-pages/ProductPages/StayUpdatedModal.test.tsx |
Adds tests asserting product_of_interest is included/omitted in the HubSpot submit payload. |
frontends/main/src/app-pages/ProductPages/ProductPageTemplate.tsx |
Passes title into StayUpdatedModal when opening the modal. |
frontends/main/src/app-pages/ProductPages/ProductPageTemplate.test.tsx |
Updates expectations to assert NiceModal.show receives productTitle. |
| return undefined | ||
| } | ||
|
|
||
| const productOfInterestField = hubspotForm?.fieldGroups |
There was a problem hiding this comment.
useHubspotFormDetail returns the generated HubspotFormDefinition shape which uses field_groups (snake_case). findProductOfInterestValue only inspects hubspotForm.fieldGroups, so in production it will never find the product_of_interest field and the value won't be submitted. Update this lookup to handle the actual response shape (e.g., prefer hubspotForm.fieldGroups ?? hubspotForm.field_groups when flattening field groups).
| const productOfInterestField = hubspotForm?.fieldGroups | |
| const fieldGroups = hubspotForm?.fieldGroups ?? hubspotForm?.field_groups | |
| const productOfInterestField = fieldGroups |
| setupApis({ | ||
| fieldGroups: [ | ||
| { | ||
| fields: [ | ||
| { | ||
| name: "product_of_interest", | ||
| label: "Product of Interest", | ||
| field_type: "multiple_checkboxes", | ||
| options: [ | ||
| { | ||
| label: TEST_PRODUCT_TITLE, | ||
| value: TEST_PRODUCT_VALUE, | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| }, | ||
| ], | ||
| }) |
There was a problem hiding this comment.
These new tests build the mocked HubSpot form using fieldGroups, but the real API factory/response uses field_groups (snake_case). That means the test can pass even though the production code won’t find the field. Update the overrides to use field_groups (and nested fields/options as appropriate) so the test exercises the real response shape and catches regressions.
c52e7f6 to
fd730ae
Compare
8c0358f to
f7b7416
Compare
…ble_id as the value for these options Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
6aa68a5 to
aedcbc1
Compare
ChristopherChudzicki
left a comment
There was a problem hiding this comment.
👍
I left a suggestion about the management command args.
Additionally... Using readable_id as the value is safe within mitxonline, but there are duplicates across different ETL sources. We'll have to cross this bridge when it comes to course/program URLs eventually, I suspect.
But it's one reason I might suggest having a MANDATORY filter on the management command for ETL source or platform or something. Plus, we don't need 2700 free ocw courses in hubspot.
The duplicates, btw, are
readable_id duplication_count etl_sources
MITx+0.SolveX 2 mit_edx, oll
MITx+11.154x 2 mit_edx, oll
MITx+11.155x 2 mit_edx, oll
MITx+11.550x 2 mit_edx, oll
MITx+15.480x 2 mit_edx, oll
MITx+15.481x 2 mit_edx, oll
MITx+15.482x 2 mit_edx, oll
MITx+22.011x 2 mit_edx, oll
(that's MITx on edx.com and open learning library).
Co-authored-by: Copilot <copilot@github.com>
Co-authored-by: Copilot <copilot@github.com>
…y more than one. Co-authored-by: Copilot <copilot@github.com>
What are the relevant tickets?
Part of https://github.com/mitodl/hq/issues/10939
Description (What does it do?)
This PR follows up on the work of #3216. Now that we can push up custom contact properties into HubSpot. If the
product_of_interestfield exists on the form, the Stay Updated dialog / form will now try and submit the current product's title along with the form as the product of interest.How can this be tested?
MITOL_HUBSPOT_API_PRIVATE_TOKENinbackend.local.env(get from RC if you need it)NEXT_PUBLIC_STAY_UPDATED_HUBSPOT_FORM_IDinfrontend.local.env(usef201f3af-c2c0-4b7d-b297-ddbb75912cc1if you're using RC credentials)RECAPTCHA_SITE_KEY/RECAPTCHA_SECRET_KEYinshared.local.env(example defaults in backend.local.example.env, or create your own at https://www.google.com/recaptcha/admin/create)mitxonline-product-pagesenabledinclude_in_learn_catalogenabled and that you have runbackpopulate_mitxonline_coursesat least onceproduct_of_interestfield using the following management command:/programs/program-readable-id