@prodact.ai/sdk 0.0.8 → 0.0.10

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/react.js CHANGED
@@ -1242,7 +1242,15 @@ var UserFlowTracker = class {
1242
1242
  console.warn("[UserFlow] Cannot track outside browser environment");
1243
1243
  return null;
1244
1244
  }
1245
+ console.log("[UserFlow] start() called", {
1246
+ enabled: this.config.enabled,
1247
+ samplingRate: this.config.samplingRate,
1248
+ currentState: this.state,
1249
+ apiUrl: this.apiUrl,
1250
+ hasSessionToken: !!this.sessionToken
1251
+ });
1245
1252
  if (!this.config.enabled) {
1253
+ console.warn("[UserFlow] Tracking disabled by config");
1246
1254
  return null;
1247
1255
  }
1248
1256
  if (this.state === "tracking") {
@@ -2023,11 +2031,13 @@ Check the Network tab in DevTools for more details.`
2023
2031
  role: "assistant",
2024
2032
  content: result.message?.content || result.response || "",
2025
2033
  visualFlows: result.flows || [],
2026
- images: result.images || []
2034
+ images: result.images || [],
2035
+ userFlows: result.userFlows || []
2027
2036
  };
2028
2037
  await this.log("info", "Chat response received", {
2029
2038
  hasFlows: (result.flows || []).length > 0,
2030
- hasImages: (result.images || []).length > 0
2039
+ hasImages: (result.images || []).length > 0,
2040
+ hasUserFlows: (result.userFlows || []).length > 0
2031
2041
  });
2032
2042
  this.emit("message", chatMessage);
2033
2043
  return chatMessage;
@@ -2593,6 +2603,15 @@ Check the Network tab in DevTools for more details.`
2593
2603
  */
2594
2604
  async initUserFlowTracking() {
2595
2605
  try {
2606
+ console.log(
2607
+ "%c\u{1F4CA} Initializing User Flow Tracking",
2608
+ "background: #8b5cf6; color: #fff; padding: 2px 6px; border-radius: 3px;",
2609
+ {
2610
+ config: this.config.userFlows,
2611
+ apiUrl: this.config.apiUrl,
2612
+ sdkKey: this.config.sdkKey ? "present" : "missing"
2613
+ }
2614
+ );
2596
2615
  this.userFlowTracker = new UserFlowTracker(this.config.userFlows);
2597
2616
  this.userFlowTracker.initialize(
2598
2617
  this.sessionToken,
@@ -2602,12 +2621,27 @@ Check the Network tab in DevTools for more details.`
2602
2621
  const recordingSessionId = this.recorder?.getSessionId?.() || null;
2603
2622
  const sessionId = await this.userFlowTracker.start(recordingSessionId);
2604
2623
  if (sessionId) {
2624
+ console.log(
2625
+ "%c\u2705 User Flow Tracking Started",
2626
+ "background: #10b981; color: #fff; padding: 2px 6px; border-radius: 3px;",
2627
+ { flowSessionId: sessionId, linkedRecordingSession: recordingSessionId }
2628
+ );
2605
2629
  await this.log("info", "User flow tracking started", {
2606
2630
  flowSessionId: sessionId,
2607
2631
  linkedRecordingSession: recordingSessionId
2608
2632
  });
2633
+ } else {
2634
+ console.warn(
2635
+ "%c\u26A0\uFE0F User Flow Tracking: No session ID returned",
2636
+ "background: #f59e0b; color: #000; padding: 2px 6px; border-radius: 3px;"
2637
+ );
2609
2638
  }
2610
2639
  } catch (error) {
2640
+ console.error(
2641
+ "%c\u274C User Flow Tracking Failed",
2642
+ "background: #ef4444; color: #fff; padding: 2px 6px; border-radius: 3px;",
2643
+ error
2644
+ );
2611
2645
  await this.log("warn", "Failed to initialize user flow tracking", {
2612
2646
  error: error instanceof Error ? error.message : String(error)
2613
2647
  });
@@ -3516,6 +3550,80 @@ function ProduckChat({
3516
3550
  ]
3517
3551
  },
3518
3552
  imgIdx
3553
+ )) }),
3554
+ msg.userFlows && msg.userFlows.length > 0 && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { marginTop: "12px" }, children: msg.userFlows.filter((uf) => uf.hasReplay).slice(0, 2).map((userFlow, ufIdx) => /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3555
+ "div",
3556
+ {
3557
+ style: {
3558
+ marginTop: ufIdx > 0 ? "8px" : 0,
3559
+ padding: "12px",
3560
+ borderRadius: "8px",
3561
+ border: `1px solid ${isDark ? "#374151" : "#e5e7eb"}`,
3562
+ backgroundColor: isDark ? "#1f2937" : "#f9fafb"
3563
+ },
3564
+ children: [
3565
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: {
3566
+ display: "flex",
3567
+ alignItems: "center",
3568
+ justifyContent: "space-between",
3569
+ marginBottom: "8px"
3570
+ }, children: [
3571
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
3572
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: { fontSize: "16px" }, children: "\u{1F3AC}" }),
3573
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: {
3574
+ fontWeight: 600,
3575
+ fontSize: "13px",
3576
+ color: isDark ? "#f3f4f6" : "#111827"
3577
+ }, children: userFlow.title })
3578
+ ] }),
3579
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { style: {
3580
+ fontSize: "11px",
3581
+ padding: "2px 6px",
3582
+ backgroundColor: primaryColor + "20",
3583
+ color: primaryColor,
3584
+ borderRadius: "4px"
3585
+ }, children: [
3586
+ userFlow.eventCount,
3587
+ " steps"
3588
+ ] })
3589
+ ] }),
3590
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { style: {
3591
+ fontSize: "12px",
3592
+ color: isDark ? "#9ca3af" : "#6b7280",
3593
+ marginBottom: "10px",
3594
+ lineHeight: 1.4
3595
+ }, children: userFlow.description }),
3596
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
3597
+ "button",
3598
+ {
3599
+ onClick: () => {
3600
+ const replayUrl = `${window.location.origin}/recordings/${userFlow.recordingId}`;
3601
+ window.open(replayUrl, "_blank", "width=1200,height=800");
3602
+ },
3603
+ style: {
3604
+ display: "flex",
3605
+ alignItems: "center",
3606
+ gap: "6px",
3607
+ padding: "8px 12px",
3608
+ backgroundColor: primaryColor,
3609
+ color: "#fff",
3610
+ border: "none",
3611
+ borderRadius: "6px",
3612
+ fontSize: "12px",
3613
+ fontWeight: 500,
3614
+ cursor: "pointer",
3615
+ width: "100%",
3616
+ justifyContent: "center"
3617
+ },
3618
+ children: [
3619
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "\u25B6\uFE0F" }),
3620
+ /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "Watch Session Replay" })
3621
+ ]
3622
+ }
3623
+ )
3624
+ ]
3625
+ },
3626
+ userFlow.id || ufIdx
3519
3627
  )) })
3520
3628
  ]
3521
3629
  }