Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix(analytics): stabilize conversation hook identity (#16981)

AmAzing-39981567d77b
diff --git a/src/business/client/hooks/useBusinessConversationAnalytics.test.ts b/src/business/client/hooks/useBusinessConversationAnalytics.test.ts
new file mode 100644
index 00000000000..e6ed6c4471f
--- /dev/null
+++ b/src/business/client/hooks/useBusinessConversationAnalytics.test.ts
@@ -0,0 +1,18 @@
+import { renderHook } from '@testing-library/react';
+import { describe, expect, it } from 'vitest';
+
+import { useBusinessConversationAnalytics } from './useBusinessConversationAnalytics';
+
+describe('useBusinessConversationAnalytics', () => {
+ it('returns stable empty hooks across rerenders', () => {
+ const { result, rerender } = renderHook(() =>
+ useBusinessConversationAnalytics({ agentId: 'agent-1' }),
+ );
+ const initialHooks = result.current;
+
+ rerender();
+
+ expect(result.current).toBe(initialHooks);
+ expect(result.current).toEqual({});
+ });
+});
diff --git a/src/business/client/hooks/useBusinessConversationAnalytics.ts b/src/business/client/hooks/useBusinessConversationAnalytics.ts
index 14672d197b3..fa1089e8ef6 100644
--- a/src/business/client/hooks/useBusinessConversationAnalytics.ts
+++ b/src/business/client/hooks/useBusinessConversationAnalytics.ts
@@ -1,5 +1,7 @@
import type { ConversationContext, ConversationHooks } from '@/features/Conversation/types';
+const EMPTY_HOOKS: ConversationHooks = {};
+
export const useBusinessConversationAnalytics = (
_context: ConversationContext,
-): ConversationHooks => ({});
+): ConversationHooks => EMPTY_HOOKS;