fix(analytics,ui): remove duplicate contact conversion and add brand identity to homepage hero
- Remove redundant `trackConversion('contact_form_submission')` in contact-content-v3.tsx
and rely on `trackContactForm(..., true)` to avoid double-counting conversions in GA4
- Update contact-content-v3.test.tsx assertions to match single analytics call
- Add Logo + company name + NOVALON to homepage HeroSection in home-content-v14.tsx
- Update homepage visual regression baselines across desktop/tablet/mobile
- Record progress in README.md
This commit is contained in:
@@ -370,10 +370,19 @@ describe('ContactContentV3 - 联系表单集成测试', () => {
|
||||
// 成功消息同时出现在 form 成功状态和 toast 中,用 getAllByText
|
||||
expect(screen.getAllByText('感谢您的留言,我们会尽快与您联系。').length).toBeGreaterThanOrEqual(1);
|
||||
|
||||
// Should have called analytics
|
||||
// Should have called analytics exactly once via trackContactForm
|
||||
const { trackContactForm, trackConversion } = await import('@/lib/analytics');
|
||||
expect(trackContactForm).toHaveBeenCalled();
|
||||
expect(trackConversion).toHaveBeenCalledWith('contact_form_submission');
|
||||
expect(trackContactForm).toHaveBeenCalledTimes(1);
|
||||
expect(trackContactForm).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
name: '张三',
|
||||
email: 'zhangsan@example.com',
|
||||
company: '咨询产品方案',
|
||||
}),
|
||||
true,
|
||||
);
|
||||
// trackConversion 不应再被显式调用,避免重复上报 conversion
|
||||
expect(trackConversion).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it('should show error toast when API returns error', async () => {
|
||||
|
||||
@@ -19,7 +19,7 @@ import {
|
||||
HelpCircle,
|
||||
ArrowRight,
|
||||
} from 'lucide-react';
|
||||
import { trackContactForm, trackConversion } from '@/lib/analytics';
|
||||
import { trackContactForm } from '@/lib/analytics';
|
||||
import { BreadcrumbSchema } from '@/components/seo/structured-data';
|
||||
import { LegacyTooltip as Tooltip } from '@/components/ui/tooltip';
|
||||
|
||||
@@ -166,12 +166,16 @@ function ContactFormContent({ data }: { data: ContactData }) {
|
||||
const resultData = await response.json();
|
||||
|
||||
if (response.ok && (resultData.success === 'true' || resultData.success === true)) {
|
||||
trackContactForm({
|
||||
name: formData.name,
|
||||
email: formData.email,
|
||||
company: formData.subject,
|
||||
});
|
||||
trackConversion('contact_form_submission');
|
||||
// trackContactForm 内部已发送 form_submit 事件并触发 conversion,
|
||||
// 不再额外调用 trackConversion,避免同一个提交被重复计为两次转化。
|
||||
trackContactForm(
|
||||
{
|
||||
name: formData.name,
|
||||
email: formData.email,
|
||||
company: formData.subject,
|
||||
},
|
||||
true,
|
||||
);
|
||||
setToastMessage(data.successMessage || '提交成功!我们会尽快与您联系。');
|
||||
setToastType('success');
|
||||
setShowToast(true);
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
'use client';
|
||||
|
||||
import { useRef } from 'react';
|
||||
import Image from 'next/image';
|
||||
import { motion } from 'framer-motion';
|
||||
import { ScrollReveal, StaggerReveal } from '@/components/ui/scroll-reveal';
|
||||
import { Badge } from '@/components/ui/badge';
|
||||
import { ArrowRight, Lightbulb, Database, Layers } from 'lucide-react';
|
||||
import { cn } from '@/lib/utils';
|
||||
import { EASE_OUT } from '@/components/ui/page-decoration';
|
||||
import { COMPANY_INFO } from '@/lib/constants';
|
||||
|
||||
// ===== 服务数据降级兜底 =====
|
||||
const FALLBACK_SERVICES = [
|
||||
@@ -104,6 +106,31 @@ function HeroSection({ heroData, stats }: {
|
||||
|
||||
<div className="max-w-container mx-auto px-4 sm:px-6 lg:px-10 relative z-10 w-full py-24 sm:py-32 md:py-40 lg:py-48">
|
||||
<div className="max-w-4xl">
|
||||
{/* 品牌标识:Logo + 公司名 */}
|
||||
<motion.div
|
||||
initial={{ opacity: 0, y: 20 }}
|
||||
animate={{ opacity: 1, y: 0 }}
|
||||
transition={{ duration: 0.6, delay: 0, ease: EASE_OUT }}
|
||||
className="flex items-center gap-3 mb-8"
|
||||
>
|
||||
<Image
|
||||
src="/logo.svg"
|
||||
alt={`${COMPANY_INFO.name} Logo`}
|
||||
width={48}
|
||||
height={48}
|
||||
className="h-10 w-auto sm:h-12"
|
||||
priority
|
||||
/>
|
||||
<div className="flex flex-col">
|
||||
<span className="text-sm sm:text-base font-semibold text-ink leading-tight">
|
||||
{COMPANY_INFO.name}
|
||||
</span>
|
||||
<span className="text-[10px] sm:text-xs tracking-[0.2em] text-text-muted uppercase">
|
||||
NOVALON
|
||||
</span>
|
||||
</div>
|
||||
</motion.div>
|
||||
|
||||
{/* 主标题:大胆、直接 */}
|
||||
<motion.h1
|
||||
initial={{ opacity: 0, y: 40 }}
|
||||
|
||||
Reference in New Issue
Block a user