@@ -8,7 +8,7 @@ import {Anchor, Button, Grid, Group, Text, ThemeIcon, Title} from "@mantine/core
88import { Account , StripeConnectAccountsResponse } from "../../../../../../types.ts" ;
99import paymentClasses from "./PaymentSettings.module.scss" ;
1010import classes from "../../ManageAccount.module.scss" ;
11- import { useEffect , useState } from "react" ;
11+ import { useEffect , useRef , useState } from "react" ;
1212import { IconAlertCircle , IconBrandStripe , IconCheck , IconExternalLink , IconInfoCircle } from '@tabler/icons-react' ;
1313import { Card } from "../../../../../common/Card" ;
1414import { formatCurrency } from "../../../../../../utilites/currency.ts" ;
@@ -19,6 +19,7 @@ import {VatSettings} from './VatSettings';
1919import { VatSettingsModal } from './VatSettings/VatSettingsModal.tsx' ;
2020import { VatNotice , getVatInfo } from './VatNotice' ;
2121import { useGetAccountVatSetting } from '../../../../../../queries/useGetAccountVatSetting.ts' ;
22+ import { trackEvent , AnalyticsEvents } from "../../../../../../utilites/analytics.ts" ;
2223
2324interface FeePlanDisplayProps {
2425 configuration ?: {
@@ -725,6 +726,27 @@ const PaymentSettings = () => {
725726
726727 const [ showVatModal , setShowVatModal ] = useState ( false ) ;
727728 const [ hasCheckedVatModal , setHasCheckedVatModal ] = useState ( false ) ;
729+ const hasTrackedStripeConnection = useRef ( false ) ;
730+
731+ // Track Stripe connection when user returns with completed setup
732+ useEffect ( ( ) => {
733+ if ( typeof window === 'undefined' ) return ;
734+ if ( hasTrackedStripeConnection . current ) return ;
735+ if ( ! stripeAccountsQuery . data ) return ;
736+
737+ const urlParams = new URLSearchParams ( window . location . search ) ;
738+ const isReturn = urlParams . get ( 'is_return' ) === '1' ;
739+ if ( ! isReturn ) return ;
740+
741+ const completedAccount = stripeAccountsQuery . data . stripe_connect_accounts . find (
742+ acc => acc . is_setup_complete
743+ ) ;
744+
745+ if ( completedAccount ) {
746+ hasTrackedStripeConnection . current = true ;
747+ trackEvent ( AnalyticsEvents . STRIPE_CONNECTED ) ;
748+ }
749+ } , [ stripeAccountsQuery . data ] ) ;
728750
729751 // Check if user is returning from Stripe and needs to fill VAT info
730752 // Only for Hi.Events Cloud - open-source doesn't have VAT handling
0 commit comments