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

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
@@ -2909,7 +2909,11 @@ declare type IncomingMessageBodyProps<T extends MessageType = MessageType> = Inc
2909
2909
  bubbleContentColor?: string;
2910
2910
  bubbleBackgroundColor?: string;
2911
2911
  };
2912
- surface?: 'bubble' | 'plain';
2912
+ /**
2913
+ * @deprecated The default layout no longer provides this value.
2914
+ * Render `children` in custom `MessageBody` components instead of branching on `surface`.
2915
+ */
2916
+ surface?: unknown;
2913
2917
  };
2914
2918
 
2915
2919
  export declare const IncomingMessageLayout: {
@@ -5050,9 +5054,11 @@ declare class LiveMetricManager {
5050
5054
  this.dispatch?.({ category, metricKey, data });
5051
5055
  };
5052
5056
  private readonly emitters: Record<MetricSource['type'], LiveMetricEmitter>;
5057
+ private isStarted = false;
5058
+ private registeredChatSDK?: ChatSDKType;
5053
5059
 
5054
- constructor(private readonly chatSDK: ChatSDKType) {
5055
- const getCurrentUserId = () => this.chatSDK.currentUser?.userId;
5060
+ constructor() {
5061
+ const getCurrentUserId = () => this.registeredChatSDK?.currentUser?.userId;
5056
5062
  this.emitters = {
5057
5063
  connection: new ConnectionMetricEmitter(this.emit),
5058
5064
  conversation: new ConversationMetricEmitter(this.emit),
@@ -5062,7 +5068,9 @@ declare class LiveMetricManager {
5062
5068
  };
5063
5069
  }
5064
5070
 
5065
- start(): void {
5071
+ start(chatSDK: ChatSDKType): void {
5072
+ if (this.isStarted) return;
5073
+
5066
5074
  const connectionHandler = new ConnectionHandler({
5067
5075
  onConnected: (userId) => this.trackConnection('connected', userId),
5068
5076
  onDisconnected: (userId) => this.trackConnection('disconnected', userId),
@@ -5087,8 +5095,10 @@ declare class LiveMetricManager {
5087
5095
  onUserLeft: (channel) => this.track({ type: 'handoff', channel }),
5088
5096
  });
5089
5097
 
5090
- this.chatSDK.addConnectionHandler(this.id, connectionHandler);
5091
- this.chatSDK.groupChannel.addGroupChannelHandler(this.id, channelHandler);
5098
+ chatSDK.addConnectionHandler(this.id, connectionHandler);
5099
+ chatSDK.groupChannel.addGroupChannelHandler(this.id, channelHandler);
5100
+ this.registeredChatSDK = chatSDK;
5101
+ this.isStarted = true;
5092
5102
  }
5093
5103
 
5094
5104
  /**
@@ -5104,11 +5114,15 @@ declare class LiveMetricManager {
5104
5114
  }
5105
5115
 
5106
5116
  dispose(): void {
5107
- this.chatSDK.removeConnectionHandler(this.id);
5108
- this.chatSDK.groupChannel.removeGroupChannelHandler(this.id);
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;
5109
5123
  }
5110
5124
 
5111
- private trackConnection(detail: ConnectionEventDetail, userId = this.chatSDK.currentUser?.userId): void {
5125
+ private trackConnection(detail: ConnectionEventDetail, userId = this.registeredChatSDK?.currentUser?.userId): void {
5112
5126
  if (userId) this.track({ type: 'connection', detail, userId });
5113
5127
  }
5114
5128
  }