'use client'; import { useEffect } from 'react'; import { useLocalization } from '@akinon/next/hooks'; import { Button } from '@theme/components'; import { useInstallPrompt } from '@theme/hooks/use-install-prompt'; import { pushEventGA4 } from '@theme/utils/gtm'; const trackEvent = (event: string, params: Record) => { try { pushEventGA4(event, params); } catch { // dataLayer unavailable (GTM blocked, script not loaded yet) } }; export const InstallPrompt = () => { const { canInstall, isIOS, install, dismiss } = useInstallPrompt(); const { t } = useLocalization(); useEffect(() => { if (!canInstall) return; trackEvent('pwa_install_prompt_shown', { platform: isIOS ? 'ios' : 'native' }); }, [canInstall, isIOS]); if (!canInstall) return null; const handleInstall = async () => { trackEvent('pwa_install_prompt_clicked', { platform: 'native' }); const outcome = await install(); if (outcome) { trackEvent('pwa_install_prompt_outcome', { outcome }); } }; const handleDismiss = () => { trackEvent('pwa_install_prompt_dismissed', { platform: isIOS ? 'ios' : 'native' }); dismiss(); }; return (

{t('common.install.title')}

{isIOS ? t('common.install.description.ios') : t('common.install.description.default')}

{!isIOS && ( )}
); };