@usecrow/ui 0.1.8 → 0.1.9

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.cjs CHANGED
@@ -2292,7 +2292,9 @@ function CrowWidget({
2292
2292
  variant = "floating",
2293
2293
  styles: propStyles,
2294
2294
  previewMode = false,
2295
- onReady
2295
+ onReady,
2296
+ onIdentify,
2297
+ tools
2296
2298
  }) {
2297
2299
  const { styles, isLoading: isLoadingStyles, agentName } = useWidgetStyles({
2298
2300
  productId,
@@ -2425,6 +2427,23 @@ function CrowWidget({
2425
2427
  onReady?.();
2426
2428
  }
2427
2429
  }, [isLoadingStyles, onReady]);
2430
+ React3.useEffect(() => {
2431
+ if (!isLoadingStyles && onIdentify) {
2432
+ const identify = (data) => {
2433
+ if (!data.token) {
2434
+ console.error("[Crow] identify() requires a token");
2435
+ return;
2436
+ }
2437
+ window.crow?.("identify", data);
2438
+ };
2439
+ onIdentify(identify);
2440
+ }
2441
+ }, [isLoadingStyles, onIdentify]);
2442
+ React3.useEffect(() => {
2443
+ if (tools && Object.keys(tools).length > 0) {
2444
+ window.crow?.("registerTools", tools);
2445
+ }
2446
+ }, [tools]);
2428
2447
  const handleSend = (message) => {
2429
2448
  if (!message.trim()) return;
2430
2449
  setIsCollapsed(false);