Skip to content

Commit

Permalink
feat: update analyticsEvents handler conditioin: run on form redirect (
Browse files Browse the repository at this point in the history
  • Loading branch information
niktverd authored Apr 10, 2024
1 parent 9f0fba6 commit dea5bd3
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/components/YandexForm/YandexForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ const YandexForm = (props: YandexFormProps) => {
try {
const parsed = JSON.parse(data);
const height = parsed['iframe-height'];
const {message, name} = parsed;
const {message, name, redirectUrl} = parsed;
if (name !== `form${id}`) {
return;
}
Expand All @@ -112,7 +112,10 @@ const YandexForm = (props: YandexFormProps) => {
onLoad?.();
}

if (message === 'sent') {
if (message === 'sent' || redirectUrl) {
// event with redirectUrl is comming when form with redirect is used
// otherwise, message: 'sent' is not comming on such sort of forms
// to catch this event and handle analytics redirectUrl is added to condition
handleSubmit();
}
} catch (error) {
Expand Down

0 comments on commit dea5bd3

Please sign in to comment.