From d85123318563db790a71d2acc25420bd8635fca0 Mon Sep 17 00:00:00 2001 From: Antariksh Mahajan Date: Mon, 14 Oct 2024 14:36:42 +0800 Subject: [PATCH] chore: add console logs for debugging --- frontend/src/features/public-form/PublicFormProvider.tsx | 4 ++++ frontend/src/features/public-form/utils/iframeMessaging.ts | 2 ++ 2 files changed, 6 insertions(+) diff --git a/frontend/src/features/public-form/PublicFormProvider.tsx b/frontend/src/features/public-form/PublicFormProvider.tsx index ecbbb21866..08a9893108 100644 --- a/frontend/src/features/public-form/PublicFormProvider.tsx +++ b/frontend/src/features/public-form/PublicFormProvider.tsx @@ -490,6 +490,7 @@ export const PublicFormProvider = ({ [PAYMENT_PRODUCT_FIELD_ID]: paymentProducts, ...formInputs }) => { + console.log('Called handleSubmitForm') const { form } = data ?? {} if (!form) return @@ -674,6 +675,7 @@ export const PublicFormProvider = ({ } } case FormResponseMode.Encrypt: { + console.log('In handler for FormResponseMode.Encrypt') // Using mutateAsync so react-hook-form goes into loading state. const formPaymentData: { @@ -719,6 +721,7 @@ export const PublicFormProvider = ({ // payment forms will have non-empty paymentData field paymentData, }) => { + console.log('In onSuccess for submitStorageModeFormFetchMutation') trackSubmitForm(form) postIFrameMessage({ state: 'submitted', submissionId }) @@ -785,6 +788,7 @@ export const PublicFormProvider = ({ // payment forms will have non-empty paymentData field paymentData, }) => { + console.log('In onSuccess for submitStorageModeFormMutation') trackSubmitForm(form) postIFrameMessage({ state: 'submitted', submissionId }) if (paymentData) { diff --git a/frontend/src/features/public-form/utils/iframeMessaging.ts b/frontend/src/features/public-form/utils/iframeMessaging.ts index 199ccf8f19..595d8e8f0b 100644 --- a/frontend/src/features/public-form/utils/iframeMessaging.ts +++ b/frontend/src/features/public-form/utils/iframeMessaging.ts @@ -11,8 +11,10 @@ const TRUSTED_TARGET_ORIGINS = [ export const postIFrameMessage = (message: PublicFormIFrameMessage): void => { // De-risk by wrapping in try-catch even though this is synchronous. This should // never block form submission. + console.log('Posting iframe message', JSON.stringify(message)) try { TRUSTED_TARGET_ORIGINS.forEach((origin) => { + console.log(`Posting iframe message to origin ${origin}`) window.parent.postMessage(message, origin) }) } catch (error) {