@sendbird/ai-agent-messenger-react 1.34.3 → 1.35.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.ts CHANGED
@@ -1590,7 +1590,7 @@ declare interface ContextObject {
1590
1590
  context: Record<string, string>;
1591
1591
  }
1592
1592
 
1593
- export declare const Conversation: ({ children, onNavigateToConversationList, channelUrl, onClearChannelUrl, shouldMarkAsRead, announcementsEnabled, conversationStatsEnabled, initialFocusTarget, style, closedChannelUrl, onClearClosedChannelUrl, }: ConversationProps) => JSX.Element;
1593
+ export declare const Conversation: ({ children, onNavigateToConversationList, channelUrl, onClearChannelUrl, shouldMarkAsRead, shouldInitializeConversation, announcementsEnabled, conversationStatsEnabled, initialFocusTarget, style, closedChannelUrl, onClearClosedChannelUrl, }: ConversationProps) => JSX.Element;
1594
1594
 
1595
1595
  export declare const ConversationContext: Context<ConversationContextValue | null>;
1596
1596
 
@@ -1600,6 +1600,8 @@ declare interface ConversationContextProps {
1600
1600
  onClearChannelUrl?: () => void;
1601
1601
  shouldMarkAsRead?: boolean;
1602
1602
  conversationStatsEnabled?: boolean;
1603
+ /** @internal */
1604
+ shouldInitializeConversation?: boolean;
1603
1605
  }
1604
1606
 
1605
1607
  export declare const ConversationContextProvider: ({ children, ...props }: PropsWithChildren<ConversationContextProps>) => JSX.Element;
@@ -2436,6 +2438,8 @@ export declare type ConversationProps = PropsWithChildren<{
2436
2438
  onClearChannelUrl?: () => void;
2437
2439
  onNavigateToConversationList?: () => void;
2438
2440
  shouldMarkAsRead?: boolean;
2441
+ /** @internal */
2442
+ shouldInitializeConversation?: boolean;
2439
2443
  announcementsEnabled?: boolean;
2440
2444
  conversationStatsEnabled?: boolean;
2441
2445
  initialFocusTarget?: ConversationInitialFocusTarget;
@@ -5054,11 +5058,9 @@ declare class LiveMetricManager {
5054
5058
  this.dispatch?.({ category, metricKey, data });
5055
5059
  };
5056
5060
  private readonly emitters: Record<MetricSource['type'], LiveMetricEmitter>;
5057
- private isStarted = false;
5058
- private registeredChatSDK?: ChatSDKType;
5059
5061
 
5060
- constructor() {
5061
- const getCurrentUserId = () => this.registeredChatSDK?.currentUser?.userId;
5062
+ constructor(private readonly chatSDK: ChatSDKType) {
5063
+ const getCurrentUserId = () => this.chatSDK.currentUser?.userId;
5062
5064
  this.emitters = {
5063
5065
  connection: new ConnectionMetricEmitter(this.emit),
5064
5066
  conversation: new ConversationMetricEmitter(this.emit),
@@ -5068,9 +5070,7 @@ declare class LiveMetricManager {
5068
5070
  };
5069
5071
  }
5070
5072
 
5071
- start(chatSDK: ChatSDKType): void {
5072
- if (this.isStarted) return;
5073
-
5073
+ start(): void {
5074
5074
  const connectionHandler = new ConnectionHandler({
5075
5075
  onConnected: (userId) => this.trackConnection('connected', userId),
5076
5076
  onDisconnected: (userId) => this.trackConnection('disconnected', userId),
@@ -5095,10 +5095,8 @@ declare class LiveMetricManager {
5095
5095
  onUserLeft: (channel) => this.track({ type: 'handoff', channel }),
5096
5096
  });
5097
5097
 
5098
- chatSDK.addConnectionHandler(this.id, connectionHandler);
5099
- chatSDK.groupChannel.addGroupChannelHandler(this.id, channelHandler);
5100
- this.registeredChatSDK = chatSDK;
5101
- this.isStarted = true;
5098
+ this.chatSDK.addConnectionHandler(this.id, connectionHandler);
5099
+ this.chatSDK.groupChannel.addGroupChannelHandler(this.id, channelHandler);
5102
5100
  }
5103
5101
 
5104
5102
  /**
@@ -5114,15 +5112,11 @@ declare class LiveMetricManager {
5114
5112
  }
5115
5113
 
5116
5114
  dispose(): void {
5117
- if (!this.isStarted || !this.registeredChatSDK) return;
5118
-
5119
- this.registeredChatSDK.removeConnectionHandler(this.id);
5120
- this.registeredChatSDK.groupChannel.removeGroupChannelHandler(this.id);
5121
- this.registeredChatSDK = undefined;
5122
- this.isStarted = false;
5115
+ this.chatSDK.removeConnectionHandler(this.id);
5116
+ this.chatSDK.groupChannel.removeGroupChannelHandler(this.id);
5123
5117
  }
5124
5118
 
5125
- private trackConnection(detail: ConnectionEventDetail, userId = this.registeredChatSDK?.currentUser?.userId): void {
5119
+ private trackConnection(detail: ConnectionEventDetail, userId = this.chatSDK.currentUser?.userId): void {
5126
5120
  if (userId) this.track({ type: 'connection', detail, userId });
5127
5121
  }
5128
5122
  }