Skip to content

Commit fbc29e5

Browse files
authored
feat: update analyticsEvents handler conditioin: run on form redirect (#918) (#921)
1 parent dd4dd58 commit fbc29e5

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

src/components/YandexForm/YandexForm.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ const YandexForm = (props: YandexFormProps) => {
115115
try {
116116
const parsed = JSON.parse(data);
117117
const height = parsed['iframe-height'];
118-
const {message, name} = parsed;
118+
const {message, name, redirectUrl} = parsed;
119119
if (name !== `form${id}`) {
120120
return;
121121
}
@@ -125,7 +125,10 @@ const YandexForm = (props: YandexFormProps) => {
125125
onLoad?.();
126126
}
127127

128-
if (message === 'sent') {
128+
if (message === 'sent' || redirectUrl) {
129+
// event with redirectUrl is comming when form with redirect is used
130+
// otherwise, message: 'sent' is not comming on such sort of forms
131+
// to catch this event and handle analytics redirectUrl is added to condition
129132
handleSubmit();
130133
}
131134
} catch (error) {

0 commit comments

Comments
 (0)