Skip to content

Commit dea5bd3

Browse files
authored
feat: update analyticsEvents handler conditioin: run on form redirect (#918)
1 parent 9f0fba6 commit dea5bd3

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
@@ -102,7 +102,7 @@ const YandexForm = (props: YandexFormProps) => {
102102
try {
103103
const parsed = JSON.parse(data);
104104
const height = parsed['iframe-height'];
105-
const {message, name} = parsed;
105+
const {message, name, redirectUrl} = parsed;
106106
if (name !== `form${id}`) {
107107
return;
108108
}
@@ -112,7 +112,10 @@ const YandexForm = (props: YandexFormProps) => {
112112
onLoad?.();
113113
}
114114

115-
if (message === 'sent') {
115+
if (message === 'sent' || redirectUrl) {
116+
// event with redirectUrl is comming when form with redirect is used
117+
// otherwise, message: 'sent' is not comming on such sort of forms
118+
// to catch this event and handle analytics redirectUrl is added to condition
116119
handleSubmit();
117120
}
118121
} catch (error) {

0 commit comments

Comments
 (0)