Skip to content

Commit

Permalink
Merge pull request #1123 from prezly/feature/dev-12745-add-subscribe-…
Browse files Browse the repository at this point in the history
…form-submit-event

[DEV-12745] Track when subscribe form is submitted
  • Loading branch information
kudlajz authored Apr 5, 2024
2 parents 1a6a707 + bcf86e2 commit e3746b3
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
4 changes: 4 additions & 0 deletions modules/SubscribeForm/ui/SubscribeForm.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
'use client';

import Captcha from '@hcaptcha/react-hcaptcha';
import { ACTIONS, useAnalytics } from '@prezly/analytics-nextjs';
import type { Newsroom } from '@prezly/sdk';
import { PrivacyPortal, translations } from '@prezly/theme-kit-nextjs';
import type { FormEvent } from 'react';
Expand All @@ -22,6 +23,7 @@ interface Props {
}

export function SubscribeForm({ newsroom }: Props) {
const { track } = useAnalytics();
const { locale: localeCode, formatMessage } = useIntl();

const captchaRef = useRef<Captcha>(null);
Expand Down Expand Up @@ -59,6 +61,8 @@ export function SubscribeForm({ newsroom }: Props) {
return;
}

track(ACTIONS.SUBSCRIBE_FORM_SUBMIT);

const redirect = PrivacyPortal.generateUrl(newsroom, localeCode, { email });

window.location.href = redirect;
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
"@hcaptcha/react-hcaptcha": "1.9.3",
"@headlessui/react": "1.7.18",
"@playwright/test": "^1.33.0",
"@prezly/analytics-nextjs": "2.0.0",
"@prezly/analytics-nextjs": "2.0.1",
"@prezly/content-renderer-react-js": "0.35.0",
"@prezly/sdk": "20.3.0",
"@prezly/story-content-format": "0.64.0",
Expand Down

0 comments on commit e3746b3

Please sign in to comment.