feat(miniprogram): 埋点事件追踪服务
- 新增 analytics.ts:trackEvent/trackPageView/flushEvents - 事件队列本地缓存,批量上报到 /analytics/batch - 首页 page_view、预约创建、随访提交、健康数据录入四个关键埋点
This commit is contained in:
@@ -4,6 +4,7 @@ import Taro from '@tarojs/taro';
|
||||
import { listDoctors, createAppointment, calendarView } from '../../../services/appointment';
|
||||
import { useAuthStore } from '../../../stores/auth';
|
||||
import { TEMPLATE_IDS } from '@/services/wechat-templates';
|
||||
import { trackEvent } from '@/services/analytics';
|
||||
import StepIndicator from '../../../components/StepIndicator';
|
||||
import WeekCalendar from '../../../components/WeekCalendar';
|
||||
import './index.scss';
|
||||
@@ -112,6 +113,7 @@ export default function AppointmentCreate() {
|
||||
reason: reason.trim() || undefined,
|
||||
});
|
||||
Taro.showToast({ title: '预约成功', icon: 'success' });
|
||||
trackEvent('appointment_create', { doctor_id: selectedDoctor.id, date: appointmentDate });
|
||||
// 订阅消息引导
|
||||
const tmplId = TEMPLATE_IDS.APPOINTMENT_REMINDER;
|
||||
if (tmplId) {
|
||||
|
||||
@@ -4,6 +4,7 @@ import Taro, { useRouter } from '@tarojs/taro';
|
||||
import { getTaskDetail, submitRecord } from '../../../services/followup';
|
||||
import type { FollowUpTask } from '../../../services/followup';
|
||||
import { TEMPLATE_IDS } from '@/services/wechat-templates';
|
||||
import { trackEvent } from '@/services/analytics';
|
||||
import Loading from '../../../components/Loading';
|
||||
import ErrorState from '../../../components/ErrorState';
|
||||
import './index.scss';
|
||||
@@ -42,6 +43,7 @@ export default function FollowUpDetail() {
|
||||
content: { text: content.trim() },
|
||||
});
|
||||
Taro.showToast({ title: '提交成功', icon: 'success' });
|
||||
trackEvent('followup_submit', { task_id: id });
|
||||
const tmplId = TEMPLATE_IDS.FOLLOWUP_REMINDER;
|
||||
if (tmplId) {
|
||||
try { await Taro.requestSubscribeMessage({ tmplIds: [tmplId] }); } catch { /* 用户拒绝 */ }
|
||||
|
||||
@@ -5,6 +5,7 @@ import { z } from 'zod';
|
||||
import { inputVitalSign } from '../../../services/health';
|
||||
import { useAuthStore } from '../../../stores/auth';
|
||||
import { useHealthStore } from '@/stores/health';
|
||||
import { trackEvent } from '@/services/analytics';
|
||||
import './index.scss';
|
||||
|
||||
const INDICATORS = [
|
||||
@@ -76,6 +77,7 @@ export default function HealthInput() {
|
||||
});
|
||||
clearCache();
|
||||
Taro.showToast({ title: '录入成功', icon: 'success' });
|
||||
trackEvent('health_data_input', { type: indicatorType });
|
||||
setTimeout(() => Taro.navigateBack(), 1000);
|
||||
} catch (e: unknown) {
|
||||
const msg = e instanceof Error ? e.message : '录入失败';
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useAuthStore } from '../../stores/auth';
|
||||
import { useHealthStore } from '../../stores/health';
|
||||
import EmptyState from '../../components/EmptyState';
|
||||
import Loading from '../../components/Loading';
|
||||
import { trackPageView } from '@/services/analytics';
|
||||
import './index.scss';
|
||||
|
||||
export default function Index() {
|
||||
@@ -13,6 +14,7 @@ export default function Index() {
|
||||
useDidShow(() => {
|
||||
restoreAuth();
|
||||
refreshToday();
|
||||
trackPageView('home');
|
||||
});
|
||||
|
||||
const hour = new Date().getHours();
|
||||
|
||||
Reference in New Issue
Block a user