feat: 修复动态 reducer 注入导致的运行时错误

This commit is contained in:
zdl
2025-11-26 13:59:26 +08:00
parent a0b688da80
commit e6ede81c78
2 changed files with 62 additions and 10 deletions

View File

@@ -114,6 +114,16 @@ function AppContent() {
// 初始化 PostHog
dispatch(posthogSliceModule.initializePostHog());
// ⚡ 刷新注入前缓存的事件(避免丢失)
const pendingEvents = posthogSliceModule.flushPendingEventsBeforeInjection();
if (pendingEvents.length > 0) {
logger.info('App', `刷新 ${pendingEvents.length} 个注入前缓存的事件`);
pendingEvents.forEach(({ eventName, properties }) => {
posthogModule.trackEventAsync(eventName, properties);
});
}
logger.info('App', 'PostHog 模块空闲时加载完成Redux 初始化已触发');
} catch (error) {
logger.error('App', 'PostHog 加载失败', error);